@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.
Files changed (123) hide show
  1. package/package.json +105 -35
  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 +48 -0
  7. package/src/constants/dataTableFieldTypes.generated.ts +63 -0
  8. package/src/constants/docAccess.ts +32 -0
  9. package/src/constants/email.ts +44 -0
  10. package/src/constants/fieldDoc.ts +34 -0
  11. package/src/constants/graphqlReactivity.ts +113 -0
  12. package/src/constants/inboundContact.ts +8 -0
  13. package/src/constants/integration.ts +13 -0
  14. package/src/constants/log.ts +7 -366
  15. package/src/constants/logActivityGroupColors.generated.ts +19 -0
  16. package/src/constants/logTaxonomy.generated.ts +1103 -0
  17. package/src/constants/noteDoc.ts +77 -0
  18. package/src/constants/organization.ts +18 -11
  19. package/src/constants/pageRoute.ts +23 -0
  20. package/src/constants/schedule.ts +220 -0
  21. package/src/constants/scheduleRuleTemplateSeed.ts +138 -0
  22. package/src/constants/scheduleRuleTemplates.generated.ts +145 -0
  23. package/src/constants/sheet.ts +168 -0
  24. package/src/constants/sheetRegionSources.generated.ts +578 -0
  25. package/src/constants/square.ts +16 -0
  26. package/src/constants/storage.ts +61 -0
  27. package/src/constants/usage.ts +79 -0
  28. package/src/schemas/editLogEntry.ts +1017 -738
  29. package/src/schemas/fieldDocsQuery.ts +12 -0
  30. package/src/schemas/inboundContact.ts +77 -0
  31. package/src/schemas/logsQuery.ts +57 -316
  32. package/src/schemas/organization.ts +53 -213
  33. package/src/types/account.d.ts +81 -0
  34. package/src/types/agentDoc.d.ts +64 -0
  35. package/src/types/agentMemory.d.ts +74 -0
  36. package/src/types/campaign.d.ts +683 -0
  37. package/src/types/dataTable.d.ts +366 -0
  38. package/src/types/docAccess.d.ts +96 -0
  39. package/src/types/email.d.ts +142 -0
  40. package/src/types/fieldDoc.d.ts +273 -0
  41. package/src/types/inboundContact.d.ts +57 -0
  42. package/src/types/integration.d.ts +42 -0
  43. package/src/types/log.d.ts +169 -190
  44. package/src/types/noteDoc.d.ts +86 -0
  45. package/src/types/organization.d.ts +175 -76
  46. package/src/types/pageRoute.d.ts +48 -0
  47. package/src/types/schedule.d.ts +391 -0
  48. package/src/types/sheet.d.ts +1130 -0
  49. package/src/types/storage.d.ts +242 -0
  50. package/src/types/usage.d.ts +106 -0
  51. package/src/types/workflow.d.ts +305 -0
  52. package/src/utils/agentDoc.ts +109 -0
  53. package/src/utils/aiChat.ts +26 -0
  54. package/src/utils/campaign.ts +741 -0
  55. package/src/utils/campaignFormEditor.ts +871 -0
  56. package/src/utils/dataTable.ts +849 -0
  57. package/src/utils/dataTableFieldTypeRegistry.ts +105 -0
  58. package/src/utils/dataTableRealtimeAuthority.ts +209 -0
  59. package/src/utils/dataTableRealtimeSelection.ts +134 -0
  60. package/src/utils/dataTableRowDocument.ts +508 -0
  61. package/src/utils/dataTableSource.ts +230 -0
  62. package/src/utils/docAccess.ts +383 -0
  63. package/src/utils/documentName.ts +53 -0
  64. package/src/utils/email.ts +172 -0
  65. package/src/utils/fieldDoc.ts +113 -0
  66. package/src/utils/log.ts +173 -778
  67. package/src/utils/logRegistryValue.ts +90 -0
  68. package/src/utils/logStoreRead.ts +266 -0
  69. package/src/utils/logTaxonomy.ts +76 -0
  70. package/src/utils/logTaxonomyDisplay.ts +439 -0
  71. package/src/utils/noteDoc.ts +827 -0
  72. package/src/utils/organization.ts +683 -81
  73. package/src/utils/pageRoute.ts +71 -0
  74. package/src/utils/schedule.ts +799 -0
  75. package/src/utils/scheduleEvaluation.ts +1994 -0
  76. package/src/utils/scheduleICS.ts +246 -0
  77. package/src/utils/scheduleRuleTemplates.ts +188 -0
  78. package/src/utils/sheet.ts +4973 -0
  79. package/src/utils/sheetAxisMove.ts +830 -0
  80. package/src/utils/sheetBootstrap.ts +1769 -0
  81. package/src/utils/sheetCommand.ts +423 -0
  82. package/src/utils/sheetExport.ts +238 -0
  83. package/src/utils/sheetFormulaEvaluation.ts +914 -0
  84. package/src/utils/sheetFormulaEvaluator.ts +852 -0
  85. package/src/utils/sheetJournal.ts +78 -0
  86. package/src/utils/sheetNumberFormat.ts +1211 -0
  87. package/src/utils/sheetRegion.ts +374 -0
  88. package/src/utils/sheetRegionFilter.ts +1259 -0
  89. package/src/utils/sheetRegionSourceRegistry.ts +594 -0
  90. package/src/utils/sheetSequence.ts +148 -0
  91. package/src/utils/sheetSnapshot.ts +992 -0
  92. package/src/utils/sheetStructureEdit.ts +1284 -0
  93. package/src/utils/square.ts +32 -0
  94. package/src/utils/storage.ts +152 -0
  95. package/src/utils/table-route.ts +262 -0
  96. package/src/utils/workflow.ts +380 -0
  97. package/tests/dataTableFieldTypeRegistry.test.ts +110 -0
  98. package/tests/docAccess.test.ts +525 -0
  99. package/tests/editLogEntry.test.ts +112 -0
  100. package/tests/noteDoc.test.ts +669 -0
  101. package/tests/schedule.test.ts +693 -0
  102. package/tests/scheduleEvaluation.test.ts +1970 -0
  103. package/tests/scheduleICS.test.ts +208 -0
  104. package/tests/scheduleRuleTemplates.test.ts +176 -0
  105. package/tests/scheduleSweepInvariants.test.ts +428 -0
  106. package/tests/sheetAxisMove.test.ts +343 -0
  107. package/tests/sheetFormulaEvaluator.test.ts +575 -0
  108. package/tests/sheetRegionFilter.test.ts +1135 -0
  109. package/tests/sheetSequence.test.ts +41 -0
  110. package/tests/sheetStructureEdit.test.ts +82 -0
  111. package/tsconfig.json +12 -0
  112. package/vitest.config.ts +8 -0
  113. package/src/constants/log-activityTexts.ts +0 -209
  114. package/src/constants/product.ts +0 -66
  115. package/src/constants/report.ts +0 -25
  116. package/src/schemas/childOrganizationsQuery.ts +0 -44
  117. package/src/schemas/productsQuery.ts +0 -145
  118. package/src/schemas/reportsQuery.ts +0 -107
  119. package/src/types/action.d.ts +0 -42
  120. package/src/types/product.d.ts +0 -173
  121. package/src/types/report.d.ts +0 -203
  122. package/src/utils/product-calEvent.ts +0 -508
  123. package/src/utils/route-helpers.ts +0 -583
@@ -0,0 +1,148 @@
1
+ import type {
2
+ SheetJournalSeq,
3
+ SheetJournalSeqInput,
4
+ } from '../types/sheet.d.ts';
5
+
6
+ export const SHEET_JOURNAL_ZERO_SEQ: SheetJournalSeq = '0';
7
+ export const SHEET_JOURNAL_MAX_SEQ: SheetJournalSeq = '9223372036854775807';
8
+
9
+ const FILE_CONSTANTS = {
10
+ maxSeq: BigInt(SHEET_JOURNAL_MAX_SEQ),
11
+ };
12
+
13
+ /*
14
+ * Parse one journal cursor into its canonical non-negative base-10 string.
15
+ * Wire values are decimal strings; database callers may supply bigint.
16
+ */
17
+ export function parseSheetJournalSeq(
18
+ value: SheetJournalSeqInput,
19
+ ): SheetJournalSeq | null {
20
+ if (value === null || value === undefined || value === '') {
21
+ return null;
22
+ }
23
+ if (typeof value !== 'string' && typeof value !== 'bigint') {
24
+ return null;
25
+ }
26
+
27
+ if (typeof value === 'string' && !/^(0|[1-9]\d*)$/.test(value)) {
28
+ return null;
29
+ }
30
+
31
+ try {
32
+ const parsed = BigInt(value);
33
+ return parsed >= 0n && parsed <= FILE_CONSTANTS.maxSeq
34
+ ? parsed.toString()
35
+ : null;
36
+ } catch {
37
+ return null;
38
+ }
39
+ }
40
+
41
+ /*
42
+ * Normalize an optional journal cursor, using zero only for absent or invalid
43
+ * values. Use parseSheetJournalSeq directly when invalid input must heal.
44
+ */
45
+ export function normalizeSheetJournalSeq(
46
+ value: SheetJournalSeqInput,
47
+ ): SheetJournalSeq {
48
+ return parseSheetJournalSeq(value) || SHEET_JOURNAL_ZERO_SEQ;
49
+ }
50
+
51
+ /*
52
+ * Return a required journal cursor or throw when its value is absent, unsafe,
53
+ * or malformed. Database and server-emission boundaries use this fail-closed
54
+ * form so an invalid counter can never masquerade as zero.
55
+ */
56
+ export function requireSheetJournalSeq(
57
+ value: SheetJournalSeqInput,
58
+ ): SheetJournalSeq {
59
+ const seq = parseSheetJournalSeq(value);
60
+ if (seq === null) {
61
+ throw new TypeError(
62
+ 'Sheet journal seq must be a non-negative bigint or base-10 string.',
63
+ );
64
+ }
65
+
66
+ return seq;
67
+ }
68
+
69
+ /*
70
+ * Return an exact revision from storage, accepting a JavaScript number only
71
+ * while it is a non-negative safe integer. Wire callers remain string-only.
72
+ */
73
+ export function requireSheetStorageRevision(
74
+ value: SheetJournalSeqInput | number,
75
+ ): SheetJournalSeq {
76
+ if (typeof value === 'number') {
77
+ if (!Number.isSafeInteger(value) || value < 0) {
78
+ throw new TypeError(
79
+ 'Sheet storage revision must be an exact non-negative integer.',
80
+ );
81
+ }
82
+ return requireSheetJournalSeq(BigInt(value));
83
+ }
84
+
85
+ return requireSheetJournalSeq(value);
86
+ }
87
+
88
+ /*
89
+ * Return one required non-negative design revision without accepting a
90
+ * precision-unsafe JavaScript number or synthesizing a missing revision.
91
+ */
92
+ export function requireSheetDesignRevision(value: unknown): SheetJournalSeq {
93
+ if (typeof value !== 'string' && typeof value !== 'bigint') {
94
+ throw new TypeError(
95
+ 'Sheet design revision must be a non-negative bigint or base-10 string.',
96
+ );
97
+ }
98
+
99
+ return requireSheetJournalSeq(value);
100
+ }
101
+
102
+ /*
103
+ * Compare two journal cursors without converting either cursor to Number.
104
+ */
105
+ export function compareSheetJournalSeq(
106
+ left: SheetJournalSeqInput,
107
+ right: SheetJournalSeqInput,
108
+ ): -1 | 0 | 1 {
109
+ const leftSeq = BigInt(normalizeSheetJournalSeq(left));
110
+ const rightSeq = BigInt(normalizeSheetJournalSeq(right));
111
+
112
+ return leftSeq < rightSeq ? -1 : leftSeq > rightSeq ? 1 : 0;
113
+ }
114
+
115
+ /*
116
+ * Return the later of two journal cursors as a canonical decimal string.
117
+ */
118
+ export function getLaterSheetJournalSeq(
119
+ left: SheetJournalSeqInput,
120
+ right: SheetJournalSeqInput,
121
+ ): SheetJournalSeq {
122
+ const normalizedLeft = normalizeSheetJournalSeq(left);
123
+ const normalizedRight = normalizeSheetJournalSeq(right);
124
+
125
+ return compareSheetJournalSeq(normalizedLeft, normalizedRight) >= 0
126
+ ? normalizedLeft
127
+ : normalizedRight;
128
+ }
129
+
130
+ /*
131
+ * Return whether a journal cursor is greater than zero.
132
+ */
133
+ export function sheetJournalSeqIsPositive(value: SheetJournalSeqInput) {
134
+ return compareSheetJournalSeq(value, SHEET_JOURNAL_ZERO_SEQ) > 0;
135
+ }
136
+
137
+ /*
138
+ * Return whether an incoming range starts beyond the next consecutive cursor.
139
+ */
140
+ export function sheetJournalSeqHasGap(
141
+ incomingStart: SheetJournalSeqInput,
142
+ lastSeen: SheetJournalSeqInput,
143
+ ) {
144
+ const incomingSeq = BigInt(normalizeSheetJournalSeq(incomingStart));
145
+ const lastSeenSeq = BigInt(normalizeSheetJournalSeq(lastSeen));
146
+
147
+ return incomingSeq > lastSeenSeq + 1n;
148
+ }