@jsb188/mday 1.1.8 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +105 -35
- package/src/constants/agentDoc.ts +12 -0
- package/src/constants/agentMemory.ts +154 -0
- package/src/constants/aiChat.ts +5 -0
- package/src/constants/campaign.ts +127 -0
- package/src/constants/dataTable.ts +48 -0
- package/src/constants/dataTableFieldTypes.generated.ts +63 -0
- package/src/constants/docAccess.ts +32 -0
- package/src/constants/email.ts +44 -0
- package/src/constants/fieldDoc.ts +34 -0
- package/src/constants/graphqlReactivity.ts +113 -0
- package/src/constants/inboundContact.ts +8 -0
- package/src/constants/integration.ts +13 -0
- package/src/constants/log.ts +7 -366
- package/src/constants/logActivityGroupColors.generated.ts +19 -0
- package/src/constants/logTaxonomy.generated.ts +1103 -0
- package/src/constants/noteDoc.ts +77 -0
- package/src/constants/organization.ts +18 -11
- package/src/constants/pageRoute.ts +23 -0
- package/src/constants/schedule.ts +220 -0
- package/src/constants/scheduleRuleTemplateSeed.ts +138 -0
- package/src/constants/scheduleRuleTemplates.generated.ts +145 -0
- package/src/constants/sheet.ts +168 -0
- package/src/constants/sheetRegionSources.generated.ts +578 -0
- package/src/constants/square.ts +16 -0
- package/src/constants/storage.ts +61 -0
- package/src/constants/usage.ts +79 -0
- package/src/schemas/editLogEntry.ts +1017 -738
- package/src/schemas/fieldDocsQuery.ts +12 -0
- package/src/schemas/inboundContact.ts +77 -0
- package/src/schemas/logsQuery.ts +57 -316
- package/src/schemas/organization.ts +53 -213
- package/src/types/account.d.ts +81 -0
- package/src/types/agentDoc.d.ts +64 -0
- package/src/types/agentMemory.d.ts +74 -0
- package/src/types/campaign.d.ts +683 -0
- package/src/types/dataTable.d.ts +366 -0
- package/src/types/docAccess.d.ts +96 -0
- package/src/types/email.d.ts +142 -0
- package/src/types/fieldDoc.d.ts +273 -0
- package/src/types/inboundContact.d.ts +57 -0
- package/src/types/integration.d.ts +42 -0
- package/src/types/log.d.ts +169 -190
- package/src/types/noteDoc.d.ts +86 -0
- package/src/types/organization.d.ts +175 -76
- package/src/types/pageRoute.d.ts +48 -0
- package/src/types/schedule.d.ts +391 -0
- package/src/types/sheet.d.ts +1130 -0
- package/src/types/storage.d.ts +242 -0
- package/src/types/usage.d.ts +106 -0
- package/src/types/workflow.d.ts +305 -0
- package/src/utils/agentDoc.ts +109 -0
- package/src/utils/aiChat.ts +26 -0
- package/src/utils/campaign.ts +741 -0
- package/src/utils/campaignFormEditor.ts +871 -0
- package/src/utils/dataTable.ts +849 -0
- package/src/utils/dataTableFieldTypeRegistry.ts +105 -0
- package/src/utils/dataTableRealtimeAuthority.ts +209 -0
- package/src/utils/dataTableRealtimeSelection.ts +134 -0
- package/src/utils/dataTableRowDocument.ts +508 -0
- package/src/utils/dataTableSource.ts +230 -0
- package/src/utils/docAccess.ts +383 -0
- package/src/utils/documentName.ts +53 -0
- package/src/utils/email.ts +172 -0
- package/src/utils/fieldDoc.ts +113 -0
- package/src/utils/log.ts +173 -778
- package/src/utils/logRegistryValue.ts +90 -0
- package/src/utils/logStoreRead.ts +266 -0
- package/src/utils/logTaxonomy.ts +76 -0
- package/src/utils/logTaxonomyDisplay.ts +439 -0
- package/src/utils/noteDoc.ts +827 -0
- package/src/utils/organization.ts +683 -81
- package/src/utils/pageRoute.ts +71 -0
- package/src/utils/schedule.ts +799 -0
- package/src/utils/scheduleEvaluation.ts +1994 -0
- package/src/utils/scheduleICS.ts +246 -0
- package/src/utils/scheduleRuleTemplates.ts +188 -0
- package/src/utils/sheet.ts +4973 -0
- package/src/utils/sheetAxisMove.ts +830 -0
- package/src/utils/sheetBootstrap.ts +1769 -0
- package/src/utils/sheetCommand.ts +423 -0
- package/src/utils/sheetExport.ts +238 -0
- package/src/utils/sheetFormulaEvaluation.ts +914 -0
- package/src/utils/sheetFormulaEvaluator.ts +852 -0
- package/src/utils/sheetJournal.ts +78 -0
- package/src/utils/sheetNumberFormat.ts +1211 -0
- package/src/utils/sheetRegion.ts +374 -0
- package/src/utils/sheetRegionFilter.ts +1259 -0
- package/src/utils/sheetRegionSourceRegistry.ts +594 -0
- package/src/utils/sheetSequence.ts +148 -0
- package/src/utils/sheetSnapshot.ts +992 -0
- package/src/utils/sheetStructureEdit.ts +1284 -0
- package/src/utils/square.ts +32 -0
- package/src/utils/storage.ts +152 -0
- package/src/utils/table-route.ts +262 -0
- package/src/utils/workflow.ts +380 -0
- package/tests/dataTableFieldTypeRegistry.test.ts +110 -0
- package/tests/docAccess.test.ts +525 -0
- package/tests/editLogEntry.test.ts +112 -0
- package/tests/noteDoc.test.ts +669 -0
- package/tests/schedule.test.ts +693 -0
- package/tests/scheduleEvaluation.test.ts +1970 -0
- package/tests/scheduleICS.test.ts +208 -0
- package/tests/scheduleRuleTemplates.test.ts +176 -0
- package/tests/scheduleSweepInvariants.test.ts +428 -0
- package/tests/sheetAxisMove.test.ts +343 -0
- package/tests/sheetFormulaEvaluator.test.ts +575 -0
- package/tests/sheetRegionFilter.test.ts +1135 -0
- package/tests/sheetSequence.test.ts +41 -0
- package/tests/sheetStructureEdit.test.ts +82 -0
- package/tsconfig.json +12 -0
- package/vitest.config.ts +8 -0
- package/src/constants/log-activityTexts.ts +0 -209
- package/src/constants/product.ts +0 -66
- package/src/constants/report.ts +0 -25
- package/src/schemas/childOrganizationsQuery.ts +0 -44
- package/src/schemas/productsQuery.ts +0 -145
- package/src/schemas/reportsQuery.ts +0 -107
- package/src/types/action.d.ts +0 -42
- package/src/types/product.d.ts +0 -173
- package/src/types/report.d.ts +0 -203
- package/src/utils/product-calEvent.ts +0 -508
- package/src/utils/route-helpers.ts +0 -583
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Zod schema for query params to filter
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const FieldDocsFilterSchema = z.object({
|
|
8
|
+
preset: z.string().optional().nullable(),
|
|
9
|
+
fieldDocGroupId: z.string().optional().nullable(),
|
|
10
|
+
startPeriod: z.string().optional().nullable(),
|
|
11
|
+
endPeriod: z.string().optional().nullable(),
|
|
12
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import i18n from '@jsb188/app/i18n/index.ts';
|
|
2
|
+
import type { InboundContactGQL } from '../types/inboundContact.d.ts';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Length values for validation
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const MIN_LEN_VALUES = {
|
|
9
|
+
email: 100,
|
|
10
|
+
memory: 750,
|
|
11
|
+
personName: 120,
|
|
12
|
+
phone: 40,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Schema; Edit inbound contact
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export function makeEditInboundContactSchema(
|
|
20
|
+
formId: string,
|
|
21
|
+
focusedName: string,
|
|
22
|
+
formValues: Partial<InboundContactGQL>, // always append with "|| nodeData"
|
|
23
|
+
) {
|
|
24
|
+
return {
|
|
25
|
+
listData: [
|
|
26
|
+
{
|
|
27
|
+
__type: 'input',
|
|
28
|
+
item: {
|
|
29
|
+
name: 'personName',
|
|
30
|
+
maxLength: MIN_LEN_VALUES.personName,
|
|
31
|
+
label: i18n.t('form.name'),
|
|
32
|
+
placeholder: formValues.personName || '',
|
|
33
|
+
autoComplete: 'off',
|
|
34
|
+
focused: focusedName === formId + '_personName',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
__type: 'input',
|
|
39
|
+
item: {
|
|
40
|
+
name: 'email',
|
|
41
|
+
maxLength: MIN_LEN_VALUES.email,
|
|
42
|
+
label: i18n.t('form.email'),
|
|
43
|
+
placeholder: formValues.email || '',
|
|
44
|
+
autoComplete: 'off',
|
|
45
|
+
type: 'email',
|
|
46
|
+
focused: focusedName === formId + '_email',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
__type: 'input',
|
|
51
|
+
item: {
|
|
52
|
+
name: 'phone',
|
|
53
|
+
maxLength: MIN_LEN_VALUES.phone,
|
|
54
|
+
label: i18n.t('form.phone'),
|
|
55
|
+
placeholder: formValues.phone || '',
|
|
56
|
+
autoComplete: 'off',
|
|
57
|
+
type: 'tel',
|
|
58
|
+
focused: focusedName === formId + '_phone',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
__type: 'textarea',
|
|
63
|
+
item: {
|
|
64
|
+
name: 'memory',
|
|
65
|
+
maxLength: MIN_LEN_VALUES.memory,
|
|
66
|
+
label: i18n.t('form.memories'),
|
|
67
|
+
description: i18n.t('form.ai_memories_desc'),
|
|
68
|
+
placeholder: formValues.memory || '',
|
|
69
|
+
autoComplete: 'off',
|
|
70
|
+
minHeight: 80,
|
|
71
|
+
focused: focusedName === formId + '_memory',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
rules: [],
|
|
76
|
+
};
|
|
77
|
+
}
|
package/src/schemas/logsQuery.ts
CHANGED
|
@@ -1,50 +1,54 @@
|
|
|
1
|
-
import { isFutureCalDate, isValidCalDate } from '@jsb188/app/utils/datetime';
|
|
2
|
-
import { indexToTimeZone, isValidTimeZone } from '@jsb188/app/utils/timeZone';
|
|
1
|
+
import { isFutureCalDate, isValidCalDate } from '@jsb188/app/utils/datetime.ts';
|
|
3
2
|
import { z } from 'zod';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import {
|
|
4
|
+
LOG_ANY_ACTIVITY_ENUMS,
|
|
5
|
+
LOG_ANY_TYPE_ENUMS,
|
|
6
|
+
LOG_SORT_ENUMS,
|
|
7
|
+
LOG_TYPES_BY_OPERATION,
|
|
8
|
+
} from '../constants/log.ts';
|
|
9
|
+
import type { FilterLogEntriesArgs, LogTypeEnum } from '../types/log.d.ts';
|
|
10
|
+
import type { OrganizationOperationEnum } from '../types/organization.d.ts';
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* Zod schema for query params to filter
|
|
11
14
|
*/
|
|
12
15
|
|
|
13
|
-
export const FilterLogEntriesSchema = z
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.nullable(),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
16
|
+
export const FilterLogEntriesSchema = z
|
|
17
|
+
.object({
|
|
18
|
+
siteId: z.string().optional().nullable(),
|
|
19
|
+
preset: z.string().optional().nullable(),
|
|
20
|
+
types: z.array(z.enum(LOG_ANY_TYPE_ENUMS)).nullable(),
|
|
21
|
+
activities: z.array(z.enum(LOG_ANY_ACTIVITY_ENUMS)).optional().nullable(),
|
|
22
|
+
startDate: z
|
|
23
|
+
.string()
|
|
24
|
+
.refine((sd) => isValidCalDate(sd), { message: 'START_DATE_INVALID' })
|
|
25
|
+
.refine((sd) => !isFutureCalDate(sd, 1), {
|
|
26
|
+
message: 'START_DATE_FUTURE_NOT_ALLOWED',
|
|
27
|
+
})
|
|
28
|
+
.nullable(),
|
|
29
|
+
endDate: z
|
|
30
|
+
.string()
|
|
31
|
+
.refine((ed) => isValidCalDate(ed), { message: 'END_DATE_INVALID' })
|
|
32
|
+
.nullable(),
|
|
33
|
+
query: z.string().nullable(),
|
|
34
|
+
})
|
|
35
|
+
.refine(
|
|
36
|
+
(data) => {
|
|
37
|
+
if (!data.endDate) {
|
|
38
|
+
// No need to validate if endDate is not provided
|
|
39
|
+
return true;
|
|
40
|
+
} else if (!data.startDate) {
|
|
41
|
+
// If endDate is provided, startDate is required
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
// End date must be after or equal to start date
|
|
45
|
+
return data.endDate >= data.startDate;
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
message: 'END_DATE_MUST_BE_AFTER_START_DATE',
|
|
49
|
+
path: ['endDate'], // where to attach the error
|
|
50
|
+
},
|
|
51
|
+
);
|
|
48
52
|
|
|
49
53
|
/**
|
|
50
54
|
* Convert list of digits to log type enums
|
|
@@ -67,286 +71,23 @@ export function convertDigitsToLogTypes(
|
|
|
67
71
|
return null;
|
|
68
72
|
}
|
|
69
73
|
|
|
70
|
-
return logTypes
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Convert list of log type enums to digits
|
|
81
|
-
* @param operationType - The type of operation for organization
|
|
82
|
-
* @param types - Array of log type enums
|
|
83
|
-
* @returns String made of digits (indexes) representing log types
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
export function convertLogTypesToDigits(
|
|
87
|
-
operationType: OrganizationOperationEnum | null,
|
|
88
|
-
types: FilterLogEntriesArgs['types'],
|
|
89
|
-
): string | null {
|
|
90
|
-
if (!operationType || !types) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const logTypes = LOG_TYPES_BY_OPERATION[operationType] as LogTypeEnum[];
|
|
95
|
-
if (!logTypes) {
|
|
96
|
-
console.warn(`No log types found for operation type: ${operationType}`);
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return logTypes.map((type: LogTypeEnum) => {
|
|
101
|
-
return types.includes(type) ? '1' : '0';
|
|
102
|
-
}).join('');
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Create a filter object for logEntries() query from the URL search query.
|
|
107
|
-
* @param operation - The type of operation for organization
|
|
108
|
-
* @param searchQuery - The search query string from the URL
|
|
109
|
-
* @param otherFiltersObj - Additional filter properties to merge into the result
|
|
110
|
-
* @returns FilterLogEntriesArgs - The filter object to be used in the logEntries() query
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
export function getLogFiltersFromURL(
|
|
114
|
-
operation: OrganizationOperationEnum | null,
|
|
115
|
-
searchQuery: string,
|
|
116
|
-
otherFiltersObj?: {
|
|
117
|
-
withoutPreset?: Partial<FilterLogEntriesArgs>,
|
|
118
|
-
withPreset?: Partial<FilterLogEntriesArgs>
|
|
119
|
-
}
|
|
120
|
-
) {
|
|
121
|
-
if (!searchQuery && otherFiltersObj?.withPreset) {
|
|
122
|
-
return {
|
|
123
|
-
operation: operation!,
|
|
124
|
-
...otherFiltersObj.withPreset
|
|
125
|
-
};
|
|
126
|
-
} else if (searchQuery === '?preset=none' && otherFiltersObj?.withoutPreset) {
|
|
127
|
-
return {
|
|
128
|
-
operation: operation!,
|
|
129
|
-
...otherFiltersObj.withoutPreset
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const urlParams = new URLSearchParams(searchQuery);
|
|
134
|
-
|
|
135
|
-
let startDate = urlParams.get('sd');
|
|
136
|
-
let endDate = urlParams.get('ed');
|
|
137
|
-
if (startDate && !endDate) {
|
|
138
|
-
endDate = startDate;
|
|
139
|
-
} else if (endDate && !startDate) {
|
|
140
|
-
startDate = endDate;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const filter: FilterLogEntriesArgs = {
|
|
144
|
-
operation: operation!,
|
|
145
|
-
types: convertDigitsToLogTypes(operation, urlParams.get('t')), // (urlParams.get('t') || null) as FilterLogEntriesArgs['type'] | null,
|
|
146
|
-
startDate,
|
|
147
|
-
endDate,
|
|
148
|
-
timeZone: indexToTimeZone(urlParams.get('z')),
|
|
149
|
-
query: urlParams.get('q') || '',
|
|
150
|
-
...otherFiltersObj?.withoutPreset,
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const validation = FilterLogEntriesSchema.safeParse(filter);
|
|
154
|
-
if (!validation.success) {
|
|
155
|
-
// console.log('validation error', validation.error);
|
|
156
|
-
// Return null and force the client to go to a valid page
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return filter;
|
|
74
|
+
return logTypes
|
|
75
|
+
.map((type: LogTypeEnum, i: number) => {
|
|
76
|
+
const value = typesStr.charAt(i);
|
|
77
|
+
if (value === '1') {
|
|
78
|
+
return type;
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
})
|
|
82
|
+
.filter(Boolean) as FilterLogEntriesArgs['types'];
|
|
161
83
|
}
|
|
162
84
|
|
|
163
85
|
/**
|
|
164
86
|
* Get Sort enum value from URL
|
|
165
87
|
*/
|
|
166
88
|
|
|
167
|
-
export function getLogSorValueFromURL(
|
|
168
|
-
searchQuery: string,
|
|
169
|
-
) {
|
|
170
|
-
const urlParams = new URLSearchParams(searchQuery);
|
|
171
|
-
const sortIndex = urlParams.get('s');
|
|
172
|
-
return LOG_SORT_ENUMS[Number(sortIndex) - 1] || null;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Test if URL search query is valid against actual filter object
|
|
177
|
-
*/
|
|
178
|
-
|
|
179
|
-
export function logsSearchQueryIsValid(
|
|
180
|
-
searchQuery: string,
|
|
181
|
-
filter: FilterLogEntriesArgs | null
|
|
182
|
-
) {
|
|
183
|
-
if (!filter) {
|
|
184
|
-
return !searchQuery; // If no filter, searchQuery must be empty to be valid
|
|
185
|
-
} else if (!searchQuery || searchQuery === '?preset=none') {
|
|
186
|
-
return true; // If no searchQuery, any filter is valid
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const urlParams = new URLSearchParams(searchQuery);
|
|
190
|
-
// const operation = urlParams.get('o');
|
|
191
|
-
// const types = urlParams.get('t');
|
|
192
|
-
const accountId = urlParams.get('a');
|
|
193
|
-
const startDate = urlParams.get('sd');
|
|
194
|
-
const endDate = urlParams.get('ed');
|
|
195
|
-
const timeZone = urlParams.get('z');
|
|
196
|
-
const query = urlParams.get('q');
|
|
197
|
-
|
|
198
|
-
// console.log(
|
|
199
|
-
// 'a', !!filter.accountId === !!accountId,
|
|
200
|
-
// 'sd', !!filter.startDate === !!startDate,
|
|
201
|
-
// 'ed', !!filter.endDate === !!endDate,
|
|
202
|
-
// 'z', !!filter.timeZone === !!timeZone,
|
|
203
|
-
// 'q', !!filter.query === !!query
|
|
204
|
-
// );
|
|
205
|
-
|
|
206
|
-
return (
|
|
207
|
-
// operation is allowed to pass through
|
|
208
|
-
// !!filter.operation === !!operation &&
|
|
209
|
-
// !!filter.types?.length === !!types && // Allow this to pass because of forced filters from page
|
|
210
|
-
!!filter.accountId === !!accountId &&
|
|
211
|
-
!!filter.startDate === !!startDate &&
|
|
212
|
-
!!filter.endDate === !!endDate &&
|
|
213
|
-
!!filter.timeZone === !!timeZone &&
|
|
214
|
-
!!filter.query === !!query
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Create URL from search query params.
|
|
220
|
-
* This function assumes the query parameters are valid and well-formed.
|
|
221
|
-
* @param operationType - Type of operation for organization
|
|
222
|
-
* @param orgGenericId - Generic ID of the organization
|
|
223
|
-
* @param searchQuery - Search query string from the URL
|
|
224
|
-
* @param fileType - Type of file ('pdf' or 'csv')
|
|
225
|
-
* @returns FilterLogEntriesArgs - The filter object to be used in the logEntries() query
|
|
226
|
-
*/
|
|
227
|
-
|
|
228
|
-
export function createLogsFileNameFromURL(
|
|
229
|
-
operationType: OrganizationOperationEnum | null,
|
|
230
|
-
orgGenericId: string,
|
|
231
|
-
searchQuery: string,
|
|
232
|
-
fileType: string
|
|
233
|
-
) {
|
|
89
|
+
export function getLogSorValueFromURL(searchQuery: string) {
|
|
234
90
|
const urlParams = new URLSearchParams(searchQuery);
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
const a = urlParams.get('a');
|
|
238
|
-
const sd = urlParams.get('sd');
|
|
239
|
-
const ed = urlParams.get('ed');
|
|
240
|
-
const z = urlParams.get('z');
|
|
241
|
-
const q = urlParams.get('q');
|
|
242
|
-
|
|
243
|
-
let checkStr = '';
|
|
244
|
-
let paramStr = '';
|
|
245
|
-
|
|
246
|
-
if (o) {
|
|
247
|
-
checkStr += o;
|
|
248
|
-
} else {
|
|
249
|
-
const ix = OPERATION_ENUMS.indexOf(operationType || '');
|
|
250
|
-
checkStr += String(ix + 1);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
if (t?.split('')?.some(letter => letter !== '0')) {
|
|
254
|
-
checkStr += '1';
|
|
255
|
-
paramStr += `_${t}`;
|
|
256
|
-
} else {
|
|
257
|
-
checkStr += '0';
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (a) {
|
|
261
|
-
checkStr += '1';
|
|
262
|
-
paramStr += `_${a}`;
|
|
263
|
-
} else {
|
|
264
|
-
checkStr += '0';
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (sd) {
|
|
268
|
-
checkStr += '1';
|
|
269
|
-
paramStr += `_${sd}`;
|
|
270
|
-
} else {
|
|
271
|
-
checkStr += '0';
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (ed) {
|
|
275
|
-
checkStr += '1';
|
|
276
|
-
paramStr += `_${ed}`;
|
|
277
|
-
} else {
|
|
278
|
-
checkStr += '0';
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
if (z) {
|
|
282
|
-
checkStr += '1';
|
|
283
|
-
paramStr += `_${z}`;
|
|
284
|
-
} else {
|
|
285
|
-
checkStr += '0';
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (q) {
|
|
289
|
-
checkStr += '1';
|
|
290
|
-
paramStr += `_${q}`;
|
|
291
|
-
} else {
|
|
292
|
-
checkStr += '0';
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if (checkStr.split('').every(digit => digit === '0')) {
|
|
296
|
-
return `logs_${orgGenericId}_x${paramStr}.${fileType}`;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
return `logs_${orgGenericId}_${checkStr}${paramStr}.${fileType}`;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Create URL search params from a filter object
|
|
304
|
-
* @param filter - The filter object to convert to URL search params
|
|
305
|
-
* @param sort - Optional sort enum value
|
|
306
|
-
* @param skipOperation - Whether to skip including the operation in the params
|
|
307
|
-
* @returns URLSearchParams - The search params object
|
|
308
|
-
*/
|
|
309
|
-
|
|
310
|
-
export function createSearchParamsFromFilter(
|
|
311
|
-
filter: FilterLogEntriesArgs,
|
|
312
|
-
sort?: LogSortEnum | null,
|
|
313
|
-
skipOperation?: boolean,
|
|
314
|
-
): URLSearchParams {
|
|
315
|
-
const params = new URLSearchParams();
|
|
316
|
-
const { operation } = filter;
|
|
317
|
-
|
|
318
|
-
if (operation && !skipOperation) {
|
|
319
|
-
params.set('o', String(OPERATION_ENUMS.indexOf(operation) + 1));
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if (filter.types && operation) {
|
|
323
|
-
const typeDigits = convertLogTypesToDigits(operation, filter.types);
|
|
324
|
-
if (typeDigits) {
|
|
325
|
-
params.set('t', typeDigits);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
if (filter.accountId) {
|
|
330
|
-
params.set('a', filter.accountId);
|
|
331
|
-
}
|
|
332
|
-
if (filter.startDate) {
|
|
333
|
-
params.set('sd', filter.startDate);
|
|
334
|
-
}
|
|
335
|
-
if (filter.endDate) {
|
|
336
|
-
params.set('ed', filter.endDate);
|
|
337
|
-
}
|
|
338
|
-
if (filter.timeZone) {
|
|
339
|
-
params.set('z', filter.timeZone);
|
|
340
|
-
}
|
|
341
|
-
if (filter.query) {
|
|
342
|
-
params.set('q', filter.query);
|
|
343
|
-
}
|
|
344
|
-
if (sort) {
|
|
345
|
-
params.set('s', String(LOG_SORT_ENUMS.indexOf(sort) + 1));
|
|
346
|
-
}
|
|
347
|
-
if (!params.size && filter.preset === null) {
|
|
348
|
-
params.set('preset', 'none');
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
return params;
|
|
91
|
+
const sortIndex = urlParams.get('s');
|
|
92
|
+
return LOG_SORT_ENUMS[Number(sortIndex) - 1] || null;
|
|
352
93
|
}
|