@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
@@ -1,58 +1,79 @@
1
1
  import {
2
- FILE_STATUS_ENUMS,
3
- STORAGE_INTENT_ENUMS,
4
- } from "../constants/storage.ts";
5
- import type { OrganizationData } from "./organization.d.ts";
2
+ FILE_STATUS_ENUMS,
3
+ STORAGE_INTENT_ENUMS,
4
+ } from '../constants/storage.ts';
5
+ import type { OrganizationData } from './organization.d.ts';
6
6
 
7
7
  /**
8
8
  * Enums
9
9
  */
10
10
 
11
- export type StorageIntentEnum = typeof STORAGE_INTENT_ENUMS[number];
12
- export type FileStatusEnum = typeof FILE_STATUS_ENUMS[number];
11
+ export type StorageIntentEnum = (typeof STORAGE_INTENT_ENUMS)[number];
12
+ export type FileStatusEnum = (typeof FILE_STATUS_ENUMS)[number];
13
13
 
14
14
  export type CSVColumnFormat =
15
- | "NUMBER"
16
- | "NUMBER_ROUND"
17
- | "DECIMAL_1"
18
- | "DECIMAL_2"
19
- | "CURRENCY"
20
- | "PERCENT"
21
- | "STRING";
22
-
23
- export type CSVFooterSummaryExpression =
24
- | "SUM"
25
- | "AVG"
26
- | "MIN"
27
- | "MAX"
28
- | "COUNT"
29
- | "CUSTOM";
30
-
31
- export interface CSVColumnRequest {
32
- label: string;
33
- format: CSVColumnFormat;
34
- hint: string;
15
+ | 'NUMBER'
16
+ | 'NUMBER_ROUND'
17
+ | 'DECIMAL_1'
18
+ | 'DECIMAL_2'
19
+ | 'CURRENCY'
20
+ | 'PERCENT'
21
+ | 'STRING';
22
+
23
+ export type CSVFooterFn = 'SUM' | 'AVG' | 'MIN' | 'MAX' | 'COUNT' | 'TEXT';
24
+
25
+ export type CSVExportVisibility = 'PRIVATE' | 'PUBLIC';
26
+
27
+ export type CSVExportSource = 'SMS' | 'WEB';
28
+
29
+ export type GeneratedFileDeliveredVia = 'SMS' | 'EMAIL' | 'NONE';
30
+
31
+ export interface CSVExportColumnSpec {
32
+ label: string; // CSV header
33
+ format: CSVColumnFormat;
34
+ hint: string; // How to source/derive the value
35
35
  }
36
36
 
37
- export interface CSVFooterSummaryRowRequest {
38
- label: string;
39
- expression: CSVFooterSummaryExpression;
40
- format: CSVColumnFormat;
41
- formula?: string;
37
+ export interface CSVExportFooterSpec {
38
+ label: string;
39
+ fn: CSVFooterFn;
40
+ of?: string | null; // Column label the fn applies to (not for TEXT)
41
+ value?: string | null; // Literal text when fn === "TEXT"
42
42
  }
43
43
 
44
- export interface CSVFileCreationRequest {
45
- fileName: string;
46
- fileDescription?: string;
47
- maxRowsLength: number;
48
- dataStartDate: string;
49
- dataEndDate: string;
50
- descriptionOfDataToSearch: string;
51
- analysisGoal: string;
52
- columns: CSVColumnRequest[];
53
- footerSummaryRows?: CSVFooterSummaryRowRequest[];
54
- sentFromSMS?: boolean;
55
- [key: string]: unknown;
44
+ export interface CSVExportFileSpec {
45
+ fileName: string; // <= 70
46
+ fileDescription: string; // <= 100
47
+ dataStartDate: string; // YYYY-MM-DD
48
+ dataEndDate: string; // YYYY-MM-DD
49
+ descriptionOfDataToSearch: string;
50
+ analysisGoal?: string | null;
51
+ maxRows?: number | null;
52
+ columns: CSVExportColumnSpec[];
53
+ footerRows?: CSVExportFooterSpec[] | null;
54
+ }
55
+
56
+ export interface CSVExportRecipient {
57
+ channel: 'SMS' | 'EMAIL';
58
+ address: string;
59
+ }
60
+
61
+ /**
62
+ * storage_generated.payload for one AI CSV export file row
63
+ */
64
+
65
+ export interface CSVExportGeneratedPayload {
66
+ kind: 'CSV_EXPORT_FILE';
67
+ batchId: string; // uuid shared by all files of one request
68
+ spec: CSVExportFileSpec;
69
+ visibility: CSVExportVisibility;
70
+ requestSource: CSVExportSource;
71
+
72
+ // Set on completion by the create_csv_file tool
73
+ rowCount?: number | null;
74
+ columnCount?: number | null;
75
+ csvBytes?: number | null;
76
+ truncated?: boolean | null;
56
77
  }
57
78
 
58
79
  /**
@@ -60,94 +81,154 @@ export interface CSVFileCreationRequest {
60
81
  */
61
82
 
62
83
  export interface StorageData {
63
- __table: "storage";
64
- id: number;
65
- oaiFileId: string | null;
66
- organizationId: number | null;
67
- accountId: number | null;
68
- uri: string;
69
- size: number;
70
- checked: boolean;
71
- at: Date;
72
- contentType: string;
73
- values: Record<string, any> | null;
84
+ __table: 'storage';
85
+ id: number;
86
+ oaiFileId: string | null;
87
+ organizationId: number | null;
88
+ accountId: number | null;
89
+ uri: string;
90
+ size: number;
91
+ checked: boolean;
92
+ at: Date;
93
+ contentType: string;
94
+ intent: StorageIntentEnum | null;
95
+ values: Record<string, any> | null;
74
96
  }
75
97
 
76
98
  export interface StorageGeneratedData {
77
- __table: "storage_generated";
78
-
79
- code: string;
80
- fileName: string;
81
- fileDescription: string;
82
- summaryReport: string | null;
83
- payload: CSVFileCreationRequest | Record<string, any>;
84
- accountId: number | bigint;
85
- organizationId: number | bigint;
86
- organization?: OrganizationData;
87
- account?: {
88
- id: number | bigint;
89
- profile?: {
90
- id: number | bigint;
91
- firstName: string | null;
92
- lastName: string | null;
93
- } | null;
94
- email?: {
95
- id: number | bigint;
96
- address: string | null;
97
- } | null;
98
- phone?: {
99
- id: number | bigint;
100
- number: string | null;
101
- } | null;
102
- };
103
- storageId: number | bigint | null;
104
- status: FileStatusEnum;
105
- generatedAt: Date | null;
106
- createdAt: Date;
107
- updatedAt: Date;
99
+ __table: 'storage_generated';
100
+
101
+ code: string;
102
+ fileName: string;
103
+ fileDescription: string;
104
+ summaryReport: string | null;
105
+ payload: CSVExportGeneratedPayload | Record<string, any>;
106
+ accountId: number | bigint;
107
+ organizationId: number | bigint;
108
+ organization?: OrganizationData;
109
+ account?: {
110
+ id: number | bigint;
111
+ profile?: {
112
+ id: number | bigint;
113
+ firstName: string | null;
114
+ lastName: string | null;
115
+ } | null;
116
+ email?: {
117
+ id: number | bigint;
118
+ address: string | null;
119
+ } | null;
120
+ phone?: {
121
+ id: number | bigint;
122
+ number: string | null;
123
+ } | null;
124
+ };
125
+ storageId: number | bigint | null;
126
+ status: FileStatusEnum;
127
+ generatedAt: Date | null;
128
+ isPublic: boolean;
129
+ downloadKey: string | null;
130
+ downloadKeyExpiresAt: Date | null;
131
+ downloadCount: number;
132
+ lastDownloadedAt: Date | null;
133
+ deliveredVia: GeneratedFileDeliveredVia | null;
134
+ expiresAt: Date | null;
135
+ createdAt: Date;
136
+ updatedAt: Date;
137
+ }
138
+
139
+ /**
140
+ * GraphQL shape for the /app/downloads list ("GeneratedFile" type)
141
+ */
142
+
143
+ export interface GeneratedFileGQL {
144
+ __deleted?: boolean;
145
+
146
+ id: string; // storage_generated.code
147
+ cursor?: string | null;
148
+ fileName: string;
149
+ fileDescription: string;
150
+ summaryReport: string | null;
151
+ status: FileStatusEnum;
152
+ isPublic: boolean;
153
+ deliveredVia: GeneratedFileDeliveredVia;
154
+ downloadCount: number;
155
+ lastDownloadedAt: string | null; // ISO Date string
156
+ activeLinkExpiresAt: string | null; // ISO Date string (downloadKeyExpiresAt)
157
+ expiresAt: string | null; // ISO Date string (file retention deadline)
158
+ generatedAt: string | null; // ISO Date string
159
+ createdAt: string; // ISO Date string
160
+ createdByName: string | null;
161
+ hasFile: boolean;
108
162
  }
109
163
 
110
164
  export interface StorageGQL {
111
- __deleted?: boolean;
112
-
113
- id: string;
114
- organizationId: string | null;
115
- accountId: string | null;
116
- uri: string;
117
- size: number;
118
- checked: boolean;
119
- at: string; // ISO Date string
120
- contentType: string;
121
-
122
- // client-side only
123
- uploadStatus?: "ERROR" | "UPLOADING" | null;
124
-
125
- // metadata
126
- name: string | null;
127
- description?: string | null;
128
- aiNote?: string | null;
165
+ __deleted?: boolean;
166
+
167
+ id: string;
168
+ organizationId: string | null;
169
+ accountId: string | null;
170
+ uri: string;
171
+ size: number;
172
+ checked: boolean;
173
+ at: string; // ISO Date string
174
+ contentType: string;
175
+ intent: StorageIntentEnum | null;
176
+
177
+ // client-side only
178
+ uploadStatus?: 'ERROR' | 'UPLOADING' | null;
179
+
180
+ // metadata
181
+ name: string | null;
182
+ description?: string | null;
183
+ aiNote?: string | null;
129
184
  }
130
185
 
131
186
  export type StorageUploadEvent = Partial<{
132
- oaiFileId: string;
133
- uploaderAccountId: number | bigint | string;
134
- values: Partial<{
135
- name: string;
136
- description: string;
137
- aiNote: string;
138
- cacheDuration: number;
139
-
140
- // For PDF only
141
- pageCount: number;
142
- isEncrypted: boolean;
143
- pdfVersion: string;
144
- }>;
145
- uploadIntent: {
146
- intent: StorageIntentEnum;
147
- entries: [string, string][];
148
- };
149
- upsertQuery?: RelatedDocumentUpsertQuery;
150
- realTimeUpdate?: string; // JSON.stringified object; "{{storageId}}" will be replaced with actual storage ID after upload
187
+ oaiFileId: string;
188
+ uploaderAccountId: number | bigint | string;
189
+
190
+ // What the file was uploaded for; promoted to the storage.intent column by
191
+ // the GCS finalize webhook (upsertFileToStorage)
192
+ intent: StorageIntentEnum;
193
+
194
+ values: Partial<{
195
+ name: string;
196
+ description: string;
197
+ aiNote: string;
198
+ cacheDuration: number;
199
+
200
+ // Chat channel the file came from (set for AI chat files; web composer
201
+ // uploads carry it from their initial "UNUSED" upload)
202
+ source: 'SMS' | 'WEB' | 'EMAIL';
203
+
204
+ // Provenance for files received through a Postmark inbound webhook.
205
+ inboundEmailId: string;
206
+ postmarkMessageId: string;
207
+ attachmentIndex: number;
208
+ contentHash: string;
209
+ contentId: string | null;
210
+ recipientEmail: string;
211
+
212
+ // Original intent retained while a log relationship owns the file.
213
+ intentBeforeLog: StorageIntentEnum;
214
+
215
+ // Marks a temporary intent upload as claimed so cleanup crons keep it
216
+ consumedAt: string;
217
+
218
+ // Marks a stale upload as reserved by cleanup so consumers stop claiming it
219
+ cleanupStartedAt: string;
220
+
221
+ // For PDF only
222
+ pageCount: number;
223
+ isEncrypted: boolean;
224
+ pdfVersion: string;
225
+ }>;
226
+ uploadIntent: {
227
+ intent: StorageIntentEnum;
228
+ entries: [string, string][];
229
+ };
230
+ upsertQuery?: RelatedDocumentUpsertQuery;
231
+ realTimeUpdate?: string; // JSON.stringified object; "{{storageId}}" will be replaced with actual storage ID after upload
151
232
  }>;
152
233
 
153
234
  /**
@@ -155,7 +236,7 @@ export type StorageUploadEvent = Partial<{
155
236
  */
156
237
 
157
238
  export interface RelatedDocumentUpsertQuery {
158
- __table: string;
159
- conflictKeys: string[];
160
- data: Record<string, any>;
239
+ __table: string;
240
+ conflictKeys: string[];
241
+ data: Record<string, any>;
161
242
  }
@@ -0,0 +1,106 @@
1
+ import type {
2
+ USAGE_EXCLUSION_REASONS,
3
+ USAGE_METERS,
4
+ USAGE_OPERATIONS,
5
+ USAGE_ORIGINS,
6
+ USAGE_PROVIDERS,
7
+ USAGE_SCHEMA_VERSION,
8
+ USAGE_SOURCE_TYPES,
9
+ } from '../constants/usage.ts';
10
+
11
+ export type UsageSchemaVersion = typeof USAGE_SCHEMA_VERSION;
12
+ export type UsageMeterEnum = (typeof USAGE_METERS)[number];
13
+ export type UsageOriginEnum = (typeof USAGE_ORIGINS)[number];
14
+ export type UsageExclusionReasonEnum = (typeof USAGE_EXCLUSION_REASONS)[number];
15
+ export type UsageProviderEnum = (typeof USAGE_PROVIDERS)[number];
16
+ export type UsageOperationEnum = (typeof USAGE_OPERATIONS)[number];
17
+ export type UsageSourceTypeEnum = (typeof USAGE_SOURCE_TYPES)[number];
18
+
19
+ /*
20
+ * Organization attribution supplied by the product path that caused usage.
21
+ */
22
+ export interface OrganizationUsageAttribution {
23
+ tracking: 'ORGANIZATION';
24
+ organizationId: number | bigint;
25
+ accountId?: number | bigint | null;
26
+ origin: UsageOriginEnum;
27
+ }
28
+
29
+ /*
30
+ * Deliberate exclusion supplied for platform-owned or non-production work.
31
+ */
32
+ export interface ExcludedUsageAttribution {
33
+ tracking: 'EXCLUDED';
34
+ reason: UsageExclusionReasonEnum;
35
+ }
36
+
37
+ export type UsageAttribution =
38
+ | OrganizationUsageAttribution
39
+ | ExcludedUsageAttribution;
40
+
41
+ /*
42
+ * One positive integer measurement within a provider usage envelope.
43
+ */
44
+ export interface UsageQuantityInput {
45
+ meter: UsageMeterEnum;
46
+ quantity: number;
47
+ }
48
+
49
+ /*
50
+ * Provider result normalized before it enters the durable usage outbox.
51
+ */
52
+ export interface UsageEnvelopeInput {
53
+ schemaVersion?: UsageSchemaVersion;
54
+ sourceType: UsageSourceTypeEnum;
55
+ sourceId: string;
56
+ provider: UsageProviderEnum;
57
+ operation: UsageOperationEnum;
58
+ model?: string | null;
59
+ occurredAt?: Date | string;
60
+ quantities: UsageQuantityInput[];
61
+ metadata?: Record<string, unknown>;
62
+ }
63
+
64
+ /*
65
+ * Fully attributed schema-versioned payload stored in the durable outbox.
66
+ */
67
+ export interface UsageEnvelopeJobPayload
68
+ extends Omit<UsageEnvelopeInput, 'occurredAt' | 'schemaVersion'> {
69
+ schemaVersion: UsageSchemaVersion;
70
+ organizationId: string;
71
+ accountId: string | null;
72
+ origin: UsageOriginEnum;
73
+ occurredAt: string;
74
+ }
75
+
76
+ /*
77
+ * Append-only usage ledger row returned by server-side reads.
78
+ */
79
+ export interface UsageEventData {
80
+ __table?: 'usage_events';
81
+ id: number | bigint;
82
+ schemaVersion: UsageSchemaVersion;
83
+ organizationId: number | bigint;
84
+ accountId: number | bigint | null;
85
+ meter: UsageMeterEnum;
86
+ quantity: number | bigint;
87
+ origin: UsageOriginEnum;
88
+ sourceType: UsageSourceTypeEnum;
89
+ sourceId: string;
90
+ provider: UsageProviderEnum;
91
+ operation: UsageOperationEnum;
92
+ model: string | null;
93
+ metadata: Record<string, unknown>;
94
+ occurredAt: Date;
95
+ createdAt: Date;
96
+ }
97
+
98
+ /*
99
+ * Bigint-safe meter and origin aggregate used by billing-facing queries.
100
+ */
101
+ export interface OrganizationUsageSummaryData {
102
+ meter: UsageMeterEnum;
103
+ origin: UsageOriginEnum;
104
+ quantity: string;
105
+ eventCount: string;
106
+ }