@jsb188/mday 1.1.10 → 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.
Files changed (119) hide show
  1. package/package.json +105 -54
  2. package/src/constants/agentDoc.ts +12 -0
  3. package/src/constants/agentMemory.ts +154 -0
  4. package/src/constants/aiChat.ts +5 -0
  5. package/src/constants/campaign.ts +127 -0
  6. package/src/constants/dataTable.ts +35 -9
  7. package/src/constants/dataTableFieldTypes.generated.ts +63 -0
  8. package/src/constants/docAccess.ts +32 -0
  9. package/src/constants/email.ts +20 -4
  10. package/src/constants/fieldDoc.ts +34 -0
  11. package/src/constants/graphqlReactivity.ts +113 -0
  12. package/src/constants/integration.ts +8 -9
  13. package/src/constants/log.ts +7 -410
  14. package/src/constants/logActivityGroupColors.generated.ts +19 -0
  15. package/src/constants/logTaxonomy.generated.ts +1103 -0
  16. package/src/constants/noteDoc.ts +77 -0
  17. package/src/constants/organization.ts +13 -15
  18. package/src/constants/pageRoute.ts +23 -0
  19. package/src/constants/schedule.ts +220 -0
  20. package/src/constants/scheduleRuleTemplateSeed.ts +138 -0
  21. package/src/constants/scheduleRuleTemplates.generated.ts +145 -0
  22. package/src/constants/sheet.ts +154 -6
  23. package/src/constants/sheetRegionSources.generated.ts +578 -0
  24. package/src/constants/square.ts +6 -6
  25. package/src/constants/storage.ts +56 -7
  26. package/src/constants/usage.ts +79 -0
  27. package/src/schemas/editLogEntry.ts +1010 -777
  28. package/src/schemas/fieldDocsQuery.ts +12 -0
  29. package/src/schemas/inboundContact.ts +60 -55
  30. package/src/schemas/logsQuery.ts +55 -49
  31. package/src/schemas/organization.ts +49 -46
  32. package/src/types/account.d.ts +4 -1
  33. package/src/types/agentDoc.d.ts +64 -0
  34. package/src/types/agentMemory.d.ts +74 -0
  35. package/src/types/campaign.d.ts +683 -0
  36. package/src/types/dataTable.d.ts +175 -256
  37. package/src/types/docAccess.d.ts +96 -0
  38. package/src/types/email.d.ts +83 -12
  39. package/src/types/fieldDoc.d.ts +273 -0
  40. package/src/types/inboundContact.d.ts +2 -1
  41. package/src/types/log.d.ts +209 -341
  42. package/src/types/noteDoc.d.ts +86 -0
  43. package/src/types/organization.d.ts +83 -40
  44. package/src/types/pageRoute.d.ts +48 -0
  45. package/src/types/schedule.d.ts +391 -0
  46. package/src/types/sheet.d.ts +862 -30
  47. package/src/types/storage.d.ts +206 -125
  48. package/src/types/usage.d.ts +106 -0
  49. package/src/types/workflow.d.ts +149 -18
  50. package/src/utils/agentDoc.ts +109 -0
  51. package/src/utils/aiChat.ts +26 -0
  52. package/src/utils/campaign.ts +741 -0
  53. package/src/utils/campaignFormEditor.ts +871 -0
  54. package/src/utils/dataTable.ts +425 -410
  55. package/src/utils/dataTableFieldTypeRegistry.ts +105 -0
  56. package/src/utils/dataTableRealtimeAuthority.ts +209 -0
  57. package/src/utils/dataTableRealtimeSelection.ts +134 -0
  58. package/src/utils/dataTableRowDocument.ts +508 -0
  59. package/src/utils/dataTableSource.ts +230 -0
  60. package/src/utils/docAccess.ts +383 -0
  61. package/src/utils/documentName.ts +53 -0
  62. package/src/utils/email.ts +112 -53
  63. package/src/utils/fieldDoc.ts +113 -0
  64. package/src/utils/log.ts +169 -176
  65. package/src/utils/logRegistryValue.ts +90 -0
  66. package/src/utils/logStoreRead.ts +266 -0
  67. package/src/utils/logTaxonomy.ts +76 -0
  68. package/src/utils/logTaxonomyDisplay.ts +439 -0
  69. package/src/utils/noteDoc.ts +827 -0
  70. package/src/utils/organization.ts +510 -91
  71. package/src/utils/pageRoute.ts +71 -0
  72. package/src/utils/schedule.ts +799 -0
  73. package/src/utils/scheduleEvaluation.ts +1994 -0
  74. package/src/utils/scheduleICS.ts +246 -0
  75. package/src/utils/scheduleRuleTemplates.ts +188 -0
  76. package/src/utils/sheet.ts +4842 -39
  77. package/src/utils/sheetAxisMove.ts +830 -0
  78. package/src/utils/sheetBootstrap.ts +1769 -0
  79. package/src/utils/sheetCommand.ts +423 -0
  80. package/src/utils/sheetExport.ts +238 -0
  81. package/src/utils/sheetFormulaEvaluation.ts +914 -0
  82. package/src/utils/sheetFormulaEvaluator.ts +852 -0
  83. package/src/utils/sheetJournal.ts +78 -0
  84. package/src/utils/sheetNumberFormat.ts +1211 -0
  85. package/src/utils/sheetRegion.ts +374 -0
  86. package/src/utils/sheetRegionFilter.ts +1259 -0
  87. package/src/utils/sheetRegionSourceRegistry.ts +594 -0
  88. package/src/utils/sheetSequence.ts +148 -0
  89. package/src/utils/sheetSnapshot.ts +992 -0
  90. package/src/utils/sheetStructureEdit.ts +1284 -0
  91. package/src/utils/square.ts +22 -12
  92. package/src/utils/storage.ts +152 -0
  93. package/src/utils/table-route.ts +127 -11
  94. package/src/utils/workflow.ts +191 -23
  95. package/tests/dataTableFieldTypeRegistry.test.ts +110 -0
  96. package/tests/docAccess.test.ts +525 -0
  97. package/tests/editLogEntry.test.ts +112 -0
  98. package/tests/noteDoc.test.ts +669 -0
  99. package/tests/schedule.test.ts +693 -0
  100. package/tests/scheduleEvaluation.test.ts +1970 -0
  101. package/tests/scheduleICS.test.ts +208 -0
  102. package/tests/scheduleRuleTemplates.test.ts +176 -0
  103. package/tests/scheduleSweepInvariants.test.ts +428 -0
  104. package/tests/sheetAxisMove.test.ts +343 -0
  105. package/tests/sheetFormulaEvaluator.test.ts +575 -0
  106. package/tests/sheetRegionFilter.test.ts +1135 -0
  107. package/tests/sheetSequence.test.ts +41 -0
  108. package/tests/sheetStructureEdit.test.ts +82 -0
  109. package/tsconfig.json +10 -10
  110. package/vitest.config.ts +8 -0
  111. package/src/constants/log-activityTexts.ts +0 -235
  112. package/src/constants/product.ts +0 -42
  113. package/src/constants/report.ts +0 -44
  114. package/src/schemas/productsQuery.ts +0 -53
  115. package/src/schemas/reportsQuery.ts +0 -20
  116. package/src/types/product.d.ts +0 -84
  117. package/src/types/report.d.ts +0 -290
  118. package/src/utils/product-calEvent.ts +0 -455
  119. package/src/utils/report.ts +0 -158
@@ -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
+ });