@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,343 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
parseSheetFormulaCellReference,
|
|
4
|
+
parseSheetFormulaExpression,
|
|
5
|
+
tokenizeSheetFormulaReferences,
|
|
6
|
+
} from '../src/utils/sheet.ts';
|
|
7
|
+
import {
|
|
8
|
+
getInverseSheetAxisMoveInput,
|
|
9
|
+
getMovedSheetAxisDesign,
|
|
10
|
+
getSheetAxisMoveDestinationIndex,
|
|
11
|
+
normalizeSheetAxisMoveInput,
|
|
12
|
+
rewriteSheetFormulaForAxisMove,
|
|
13
|
+
type SheetAxisMoveIndexes,
|
|
14
|
+
} from '../src/utils/sheetAxisMove.ts';
|
|
15
|
+
|
|
16
|
+
const FILE_CONSTANTS = {
|
|
17
|
+
currentSheetTabId: 'tab-current',
|
|
18
|
+
otherSheetTabId: 'tab-other',
|
|
19
|
+
sheetTabIdByNameKey: new Map([
|
|
20
|
+
['current', 'tab-current'],
|
|
21
|
+
['other', 'tab-other'],
|
|
22
|
+
['other tab', 'tab-other'],
|
|
23
|
+
['a1', 'tab-other'],
|
|
24
|
+
]),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* Rewrite one formula through a column permutation in the shared server/client
|
|
29
|
+
* implementation while resolving qualifiers against the test workbook.
|
|
30
|
+
*/
|
|
31
|
+
function rewriteColumnFormula(
|
|
32
|
+
value: string,
|
|
33
|
+
indexes: SheetAxisMoveIndexes,
|
|
34
|
+
movedSheetTabId = FILE_CONSTANTS.currentSheetTabId,
|
|
35
|
+
) {
|
|
36
|
+
return rewriteSheetFormulaForAxisMove(value, {
|
|
37
|
+
axis: 'COLUMN',
|
|
38
|
+
formulaSheetTabId: FILE_CONSTANTS.currentSheetTabId,
|
|
39
|
+
indexes,
|
|
40
|
+
movedSheetTabId,
|
|
41
|
+
sheetTabIdByNameKey: FILE_CONSTANTS.sheetTabIdByNameKey,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
describe('Sheet axis move inversion', () => {
|
|
46
|
+
it.each([
|
|
47
|
+
{
|
|
48
|
+
axis: 'COLUMN' as const,
|
|
49
|
+
sourceEndIndex: 3,
|
|
50
|
+
sourceStartIndex: 2,
|
|
51
|
+
targetStartIndex: 6,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
axis: 'ROW' as const,
|
|
55
|
+
sourceEndIndex: 7,
|
|
56
|
+
sourceStartIndex: 5,
|
|
57
|
+
targetStartIndex: 2,
|
|
58
|
+
},
|
|
59
|
+
])('restores every affected index for a $axis move', (move) => {
|
|
60
|
+
const inverse = getInverseSheetAxisMoveInput(move);
|
|
61
|
+
const forwardIndexes = normalizeSheetAxisMoveInput(move, 10);
|
|
62
|
+
const inverseIndexes = normalizeSheetAxisMoveInput(inverse, 10);
|
|
63
|
+
|
|
64
|
+
expect(inverse).toEqual({
|
|
65
|
+
axis: move.axis,
|
|
66
|
+
sourceEndIndex:
|
|
67
|
+
move.targetStartIndex + (move.sourceEndIndex - move.sourceStartIndex),
|
|
68
|
+
sourceStartIndex: move.targetStartIndex,
|
|
69
|
+
targetStartIndex: move.sourceStartIndex,
|
|
70
|
+
});
|
|
71
|
+
for (let index = 1; index <= 10; index += 1) {
|
|
72
|
+
const movedIndex = getSheetAxisMoveDestinationIndex(
|
|
73
|
+
index,
|
|
74
|
+
forwardIndexes,
|
|
75
|
+
);
|
|
76
|
+
expect(getSheetAxisMoveDestinationIndex(movedIndex, inverseIndexes)).toBe(
|
|
77
|
+
index,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('Sheet sparse axis design movement', () => {
|
|
84
|
+
it('moves sparse design across a million-column span without materializing holes', () => {
|
|
85
|
+
const moved = getMovedSheetAxisDesign({
|
|
86
|
+
axisDesign: {
|
|
87
|
+
'1': { width: 80 },
|
|
88
|
+
'2': { width: 120 },
|
|
89
|
+
'1000000': { hidden: true },
|
|
90
|
+
},
|
|
91
|
+
sourceEndIndex: 2,
|
|
92
|
+
sourceStartIndex: 2,
|
|
93
|
+
targetEndIndex: 1_000_000,
|
|
94
|
+
targetStartIndex: 1_000_000,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
expect(moved).toEqual({
|
|
98
|
+
'1': { width: 80 },
|
|
99
|
+
'999999': { hidden: true },
|
|
100
|
+
'1000000': { width: 120 },
|
|
101
|
+
});
|
|
102
|
+
expect(Object.keys(moved)).toHaveLength(3);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe('Sheet axis move formulas', () => {
|
|
107
|
+
it('rejects fractional client-authored axis bounds instead of rounding them', () => {
|
|
108
|
+
expect(() =>
|
|
109
|
+
normalizeSheetAxisMoveInput(
|
|
110
|
+
{
|
|
111
|
+
axis: 'COLUMN',
|
|
112
|
+
sourceEndIndex: 2,
|
|
113
|
+
sourceStartIndex: 1.5,
|
|
114
|
+
targetStartIndex: 3,
|
|
115
|
+
},
|
|
116
|
+
10,
|
|
117
|
+
),
|
|
118
|
+
).toThrowError('INVALID_SHEET_AXIS_MOVE');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('parses relative and mixed absolute cell references', () => {
|
|
122
|
+
expect(parseSheetFormulaCellReference('C3')).toEqual({
|
|
123
|
+
columnIndex: 3,
|
|
124
|
+
columnLabel: 'C',
|
|
125
|
+
rowIndex: 3,
|
|
126
|
+
});
|
|
127
|
+
expect(parseSheetFormulaCellReference('$C3')).toEqual({
|
|
128
|
+
columnAbsolute: true,
|
|
129
|
+
columnIndex: 3,
|
|
130
|
+
columnLabel: 'C',
|
|
131
|
+
rowIndex: 3,
|
|
132
|
+
});
|
|
133
|
+
expect(parseSheetFormulaCellReference('C$3')).toEqual({
|
|
134
|
+
columnIndex: 3,
|
|
135
|
+
columnLabel: 'C',
|
|
136
|
+
rowAbsolute: true,
|
|
137
|
+
rowIndex: 3,
|
|
138
|
+
});
|
|
139
|
+
expect(parseSheetFormulaCellReference("'Other Tab'!$C$3")).toEqual({
|
|
140
|
+
columnAbsolute: true,
|
|
141
|
+
columnIndex: 3,
|
|
142
|
+
columnLabel: 'C',
|
|
143
|
+
rowAbsolute: true,
|
|
144
|
+
rowIndex: 3,
|
|
145
|
+
sheetName: 'Other Tab',
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('parses quoted and unquoted sheet qualifiers as complete references', () => {
|
|
150
|
+
const quotedNode = parseSheetFormulaExpression("'Other Tab'!$A$1");
|
|
151
|
+
const unquotedNode = parseSheetFormulaExpression('Other!B2');
|
|
152
|
+
|
|
153
|
+
expect(quotedNode).toMatchObject({
|
|
154
|
+
kind: 'CELL_REFERENCE',
|
|
155
|
+
reference: {
|
|
156
|
+
columnAbsolute: true,
|
|
157
|
+
columnIndex: 1,
|
|
158
|
+
rowAbsolute: true,
|
|
159
|
+
rowIndex: 1,
|
|
160
|
+
sheetName: 'Other Tab',
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
expect(unquotedNode).toMatchObject({
|
|
164
|
+
kind: 'CELL_REFERENCE',
|
|
165
|
+
reference: {
|
|
166
|
+
columnIndex: 2,
|
|
167
|
+
rowIndex: 2,
|
|
168
|
+
sheetName: 'Other',
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
expect(
|
|
172
|
+
tokenizeSheetFormulaReferences("='Other Tab'!$A$1 + Other!B2"),
|
|
173
|
+
).toEqual([
|
|
174
|
+
expect.objectContaining({
|
|
175
|
+
columnAbsolute: true,
|
|
176
|
+
kind: 'SHEET_CELL',
|
|
177
|
+
rowAbsolute: true,
|
|
178
|
+
sheetName: 'Other Tab',
|
|
179
|
+
text: "'Other Tab'!$A$1",
|
|
180
|
+
}),
|
|
181
|
+
expect.objectContaining({
|
|
182
|
+
kind: 'SHEET_CELL',
|
|
183
|
+
sheetName: 'Other',
|
|
184
|
+
text: 'Other!B2',
|
|
185
|
+
}),
|
|
186
|
+
]);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('preserves absolute markers when structural column moves rewrite references', () => {
|
|
190
|
+
expect(
|
|
191
|
+
rewriteColumnFormula(
|
|
192
|
+
"='Other Tab'!$A1 + 'Other Tab'!A$1 + 'Other Tab'!$A$1",
|
|
193
|
+
{
|
|
194
|
+
sourceEndIndex: 1,
|
|
195
|
+
sourceStartIndex: 1,
|
|
196
|
+
targetEndIndex: 3,
|
|
197
|
+
targetStartIndex: 3,
|
|
198
|
+
},
|
|
199
|
+
FILE_CONSTANTS.otherSheetTabId,
|
|
200
|
+
),
|
|
201
|
+
).toEqual({
|
|
202
|
+
changed: true,
|
|
203
|
+
status: 'CHANGED',
|
|
204
|
+
text: "='Other Tab'!$C1 + 'Other Tab'!C$1 + 'Other Tab'!$C$1",
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('treats a cell-like tab name as a qualifier instead of a local cell', () => {
|
|
209
|
+
expect(parseSheetFormulaExpression('A1!B2')).toMatchObject({
|
|
210
|
+
kind: 'CELL_REFERENCE',
|
|
211
|
+
reference: {
|
|
212
|
+
columnIndex: 2,
|
|
213
|
+
rowIndex: 2,
|
|
214
|
+
sheetName: 'A1',
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
expect(
|
|
218
|
+
rewriteColumnFormula(
|
|
219
|
+
'=A1!B2',
|
|
220
|
+
{
|
|
221
|
+
sourceEndIndex: 2,
|
|
222
|
+
sourceStartIndex: 2,
|
|
223
|
+
targetEndIndex: 3,
|
|
224
|
+
targetStartIndex: 3,
|
|
225
|
+
},
|
|
226
|
+
FILE_CONSTANTS.otherSheetTabId,
|
|
227
|
+
),
|
|
228
|
+
).toEqual({
|
|
229
|
+
changed: true,
|
|
230
|
+
status: 'CHANGED',
|
|
231
|
+
text: '=A1!C2',
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it('does not mistake the inequality operator for a sheet qualifier', () => {
|
|
236
|
+
expect(parseSheetFormulaExpression('A1 != 0')).toMatchObject({
|
|
237
|
+
kind: 'BINARY_EXPRESSION',
|
|
238
|
+
operator: '!=',
|
|
239
|
+
});
|
|
240
|
+
expect(
|
|
241
|
+
rewriteColumnFormula('=A1 != 0', {
|
|
242
|
+
sourceEndIndex: 1,
|
|
243
|
+
sourceStartIndex: 1,
|
|
244
|
+
targetEndIndex: 2,
|
|
245
|
+
targetStartIndex: 2,
|
|
246
|
+
}),
|
|
247
|
+
).toEqual({
|
|
248
|
+
changed: true,
|
|
249
|
+
status: 'CHANGED',
|
|
250
|
+
text: '=B1 != 0',
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it('preserves leading and end qualifier spelling while moving range coordinates', () => {
|
|
255
|
+
const indexes = {
|
|
256
|
+
sourceEndIndex: 1,
|
|
257
|
+
sourceStartIndex: 1,
|
|
258
|
+
targetEndIndex: 3,
|
|
259
|
+
targetStartIndex: 3,
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
expect(
|
|
263
|
+
rewriteColumnFormula(
|
|
264
|
+
'=Other!A1:A2',
|
|
265
|
+
indexes,
|
|
266
|
+
FILE_CONSTANTS.otherSheetTabId,
|
|
267
|
+
),
|
|
268
|
+
).toMatchObject({
|
|
269
|
+
changed: true,
|
|
270
|
+
text: '=Other!C1:C2',
|
|
271
|
+
});
|
|
272
|
+
expect(
|
|
273
|
+
rewriteColumnFormula(
|
|
274
|
+
'=A1:Other!A2',
|
|
275
|
+
indexes,
|
|
276
|
+
FILE_CONSTANTS.otherSheetTabId,
|
|
277
|
+
),
|
|
278
|
+
).toMatchObject({
|
|
279
|
+
changed: true,
|
|
280
|
+
text: '=C1:Other!C2',
|
|
281
|
+
});
|
|
282
|
+
expect(
|
|
283
|
+
rewriteColumnFormula(
|
|
284
|
+
"=A1:'Other Tab'!A2",
|
|
285
|
+
indexes,
|
|
286
|
+
FILE_CONSTANTS.otherSheetTabId,
|
|
287
|
+
),
|
|
288
|
+
).toMatchObject({
|
|
289
|
+
changed: true,
|
|
290
|
+
text: "=C1:'Other Tab'!C2",
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it('keeps reversed range endpoint orientation after a contiguous move', () => {
|
|
295
|
+
expect(
|
|
296
|
+
rewriteColumnFormula(
|
|
297
|
+
'=Other!B2:A1',
|
|
298
|
+
{
|
|
299
|
+
sourceEndIndex: 2,
|
|
300
|
+
sourceStartIndex: 1,
|
|
301
|
+
targetEndIndex: 4,
|
|
302
|
+
targetStartIndex: 3,
|
|
303
|
+
},
|
|
304
|
+
FILE_CONSTANTS.otherSheetTabId,
|
|
305
|
+
),
|
|
306
|
+
).toEqual({
|
|
307
|
+
changed: true,
|
|
308
|
+
status: 'CHANGED',
|
|
309
|
+
text: '=Other!D2:C1',
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it('leaves ranges unchanged when their referenced rectangle is invariant', () => {
|
|
314
|
+
expect(
|
|
315
|
+
rewriteColumnFormula('=SUM(A1:B1)', {
|
|
316
|
+
sourceEndIndex: 1,
|
|
317
|
+
sourceStartIndex: 1,
|
|
318
|
+
targetEndIndex: 2,
|
|
319
|
+
targetStartIndex: 2,
|
|
320
|
+
}),
|
|
321
|
+
).toEqual({
|
|
322
|
+
changed: false,
|
|
323
|
+
status: 'UNCHANGED',
|
|
324
|
+
text: '=SUM(A1:B1)',
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('rejects a range whose cells become discontiguous', () => {
|
|
329
|
+
expect(
|
|
330
|
+
rewriteColumnFormula('=SUM(B1:C1)', {
|
|
331
|
+
sourceEndIndex: 2,
|
|
332
|
+
sourceStartIndex: 1,
|
|
333
|
+
targetEndIndex: 4,
|
|
334
|
+
targetStartIndex: 3,
|
|
335
|
+
}),
|
|
336
|
+
).toEqual({
|
|
337
|
+
changed: false,
|
|
338
|
+
reason: 'DISCONTIGUOUS_RANGE',
|
|
339
|
+
status: 'UNSAFE',
|
|
340
|
+
text: '=SUM(B1:C1)',
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
});
|