@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,391 @@
1
+ import type {
2
+ SCHEDULE_ACTOR_TYPE_ENUMS,
3
+ SCHEDULE_ASSIGNMENT_STATUS_ENUMS,
4
+ SCHEDULE_CALENDAR_KIND_ENUMS,
5
+ SCHEDULE_DEMAND_SOURCE_ENUMS,
6
+ SCHEDULE_EVALUATION_STATUS_ENUMS,
7
+ SCHEDULE_FEED_SCOPE_ENUMS,
8
+ SCHEDULE_NOTIFICATION_CHANNEL_ENUMS,
9
+ SCHEDULE_NOTIFICATION_EVENT_KIND_ENUMS,
10
+ SCHEDULE_OCCURRENCE_KIND_ENUMS,
11
+ SCHEDULE_OCCURRENCE_STATUS_ENUMS,
12
+ SCHEDULE_RECURRENCE_FREQ_ENUMS,
13
+ SCHEDULE_REQUEST_KIND_ENUMS,
14
+ SCHEDULE_REQUEST_STATUS_ENUMS,
15
+ SCHEDULE_RULE_KIND_ENUMS,
16
+ SCHEDULE_RULE_SEVERITY_ENUMS,
17
+ } from '../constants/schedule.ts';
18
+ import type { DocAccessBaseObj } from './docAccess.d.ts';
19
+
20
+ export type ScheduleCalendarKindEnum =
21
+ (typeof SCHEDULE_CALENDAR_KIND_ENUMS)[number];
22
+ export type ScheduleOccurrenceKindEnum =
23
+ (typeof SCHEDULE_OCCURRENCE_KIND_ENUMS)[number];
24
+ export type ScheduleOccurrenceStatusEnum =
25
+ (typeof SCHEDULE_OCCURRENCE_STATUS_ENUMS)[number];
26
+ export type ScheduleActorTypeEnum = (typeof SCHEDULE_ACTOR_TYPE_ENUMS)[number];
27
+ export type ScheduleAssignmentStatusEnum =
28
+ (typeof SCHEDULE_ASSIGNMENT_STATUS_ENUMS)[number];
29
+ export type ScheduleDemandSourceEnum =
30
+ (typeof SCHEDULE_DEMAND_SOURCE_ENUMS)[number];
31
+ export type ScheduleRuleKindEnum = (typeof SCHEDULE_RULE_KIND_ENUMS)[number];
32
+ export type ScheduleRuleSeverityEnum =
33
+ (typeof SCHEDULE_RULE_SEVERITY_ENUMS)[number];
34
+ export type ScheduleEvaluationStatusEnum =
35
+ (typeof SCHEDULE_EVALUATION_STATUS_ENUMS)[number];
36
+ export type ScheduleRequestKindEnum =
37
+ (typeof SCHEDULE_REQUEST_KIND_ENUMS)[number];
38
+ export type ScheduleRequestStatusEnum =
39
+ (typeof SCHEDULE_REQUEST_STATUS_ENUMS)[number];
40
+ export type ScheduleFeedScopeEnum = (typeof SCHEDULE_FEED_SCOPE_ENUMS)[number];
41
+ export type ScheduleNotificationEventKindEnum =
42
+ (typeof SCHEDULE_NOTIFICATION_EVENT_KIND_ENUMS)[number];
43
+ export type ScheduleNotificationChannelEnum =
44
+ (typeof SCHEDULE_NOTIFICATION_CHANNEL_ENUMS)[number];
45
+ export type ScheduleRecurrenceFreqEnum =
46
+ (typeof SCHEDULE_RECURRENCE_FREQ_ENUMS)[number];
47
+
48
+ /**
49
+ * Every *Data interface below models a database row, so ids are the shapes
50
+ * Postgres hands back. Client-facing ids are serialized GenericID strings and
51
+ * live on the GraphQL types instead, never on these.
52
+ */
53
+ export type ScheduleId = number | bigint;
54
+
55
+ /**
56
+ * One recurrence rule, stored as schedule_series."recurrence" JSONB.
57
+ *
58
+ * - byWeekday uses the JavaScript convention (0 = Sunday ... 6 = Saturday)
59
+ * and applies to WEEKLY rules
60
+ * - byMonthDay applies to MONTHLY and YEARLY rules; -1 means the last day of
61
+ * the month
62
+ * - byMonth (1 = January ... 12 = December) applies to YEARLY rules
63
+ * - count and until both bound the series; whichever is reached first wins
64
+ */
65
+
66
+ export interface ScheduleRecurrenceObj {
67
+ freq: ScheduleRecurrenceFreqEnum;
68
+ interval?: number | null;
69
+ byWeekday?: number[] | null;
70
+ byMonthDay?: number[] | null;
71
+ byMonth?: number[] | null;
72
+ count?: number | null;
73
+ until?: string | null;
74
+ }
75
+
76
+ /**
77
+ * One slot requirement, both as a schedule_slots row and as an entry of
78
+ * schedule_series."slotTemplate". "predicate" narrows who may fill the slot;
79
+ * an empty predicate means anyone.
80
+ */
81
+
82
+ export interface ScheduleSlotPredicateObj {
83
+ roles?: string[] | null;
84
+ qualifications?: string[] | null;
85
+ tags?: string[] | null;
86
+ }
87
+
88
+ export interface ScheduleSlotTemplateObj {
89
+ key: string;
90
+ label?: string | null;
91
+ requiredCount: number;
92
+ predicate?: ScheduleSlotPredicateObj | null;
93
+ ordinal?: number | null;
94
+ }
95
+
96
+ export interface ScheduleSlotData extends ScheduleSlotTemplateObj {
97
+ id: ScheduleId;
98
+ occurrenceId: ScheduleId;
99
+ ordinal: number;
100
+ createdAt?: Date | string;
101
+ updatedAt?: Date | string;
102
+ }
103
+
104
+ /**
105
+ * A calendar: the unit of sharing, of ICS subscription, and of constraint
106
+ * evaluation. "access" is the base policy only; per-grantee overrides live in
107
+ * access_grants rows with entityType 'SCHEDULE_CALENDAR'.
108
+ */
109
+
110
+ export interface ScheduleCalendarData {
111
+ __table?: string;
112
+ id: ScheduleId;
113
+ organizationId: ScheduleId;
114
+ kind: ScheduleCalendarKindEnum;
115
+ name: string;
116
+ description?: string | null;
117
+ timeZone: string;
118
+ siteId?: ScheduleId | null;
119
+ access?: DocAccessBaseObj | null;
120
+ color?: string | null;
121
+ settings?: Record<string, unknown> | null;
122
+ ordinal: number;
123
+ createdByAccountId?: ScheduleId | null;
124
+ deletedAt?: Date | string | null;
125
+ createdAt?: Date | string;
126
+ updatedAt?: Date | string;
127
+ // Attached by fetch paths that resolve the viewer's permission
128
+ viewerPermission?: string | null;
129
+ }
130
+
131
+ /**
132
+ * What an occurrence occupies: a room, a position, a vehicle, a booth.
133
+ */
134
+
135
+ export interface ScheduleResourceData {
136
+ __table?: string;
137
+ id: ScheduleId;
138
+ organizationId: ScheduleId;
139
+ siteId?: ScheduleId | null;
140
+ kind: string;
141
+ key: string;
142
+ name: string;
143
+ capacity?: number | null;
144
+ config?: Record<string, unknown> | null;
145
+ ordinal: number;
146
+ retiredAt?: Date | string | null;
147
+ createdAt?: Date | string;
148
+ updatedAt?: Date | string;
149
+ }
150
+
151
+ /**
152
+ * A recurrence rule. Never read by calendar queries — the horizon job
153
+ * materializes concrete occurrences from it.
154
+ */
155
+
156
+ export interface ScheduleSeriesData {
157
+ __table?: string;
158
+ id: ScheduleId;
159
+ organizationId: ScheduleId;
160
+ calendarId: ScheduleId;
161
+ resourceId?: ScheduleId | null;
162
+ siteId?: ScheduleId | null;
163
+ kind: ScheduleOccurrenceKindEnum;
164
+ title: string;
165
+ note?: string | null;
166
+ location?: string | null;
167
+ recurrence: ScheduleRecurrenceObj;
168
+ timeZone: string;
169
+ startsAt: Date | string;
170
+ endsAt?: Date | string | null;
171
+ durationMinutes: number;
172
+ allDay: boolean;
173
+ slotTemplate: ScheduleSlotTemplateObj[];
174
+ materializedThrough?: Date | string | null;
175
+ active: boolean;
176
+ createdByAccountId?: ScheduleId | null;
177
+ deletedAt?: Date | string | null;
178
+ createdAt?: Date | string;
179
+ updatedAt?: Date | string;
180
+ }
181
+
182
+ /**
183
+ * One concrete scheduled thing. Series-generated rows carry
184
+ * ("seriesId", "recurrenceKey"); "detached" marks a row the user has taken
185
+ * ownership of, which regeneration never overwrites or deletes.
186
+ */
187
+
188
+ export interface ScheduleOccurrenceData {
189
+ __table?: string;
190
+ id: ScheduleId;
191
+ organizationId: ScheduleId;
192
+ calendarId: ScheduleId;
193
+ seriesId?: ScheduleId | null;
194
+ recurrenceKey?: Date | string | null;
195
+ resourceId?: ScheduleId | null;
196
+ siteId?: ScheduleId | null;
197
+ kind: ScheduleOccurrenceKindEnum;
198
+ title: string;
199
+ note?: string | null;
200
+ location?: string | null;
201
+ startAt: Date | string;
202
+ endAt: Date | string;
203
+ timeZone: string;
204
+ allDay: boolean;
205
+ status: ScheduleOccurrenceStatusEnum;
206
+ detached: boolean;
207
+ version: number | bigint;
208
+ createdByAccountId?: ScheduleId | null;
209
+ publishedAt?: Date | string | null;
210
+ canceledAt?: Date | string | null;
211
+ deletedAt?: Date | string | null;
212
+ createdAt?: Date | string;
213
+ updatedAt?: Date | string;
214
+ // Attached by fetch paths that hydrate relations
215
+ slots?: ScheduleSlotData[];
216
+ assignments?: ScheduleAssignmentData[];
217
+ resource?: ScheduleResourceData | null;
218
+ }
219
+
220
+ /**
221
+ * One participation record. Exactly one actor id is set and it matches
222
+ * "actorType". "startAt"/"endAt" are null unless the assignment covers only
223
+ * part of its occurrence.
224
+ */
225
+
226
+ export interface ScheduleAssignmentData {
227
+ __table?: string;
228
+ id: ScheduleId;
229
+ organizationId: ScheduleId;
230
+ occurrenceId: ScheduleId;
231
+ slotId?: ScheduleId | null;
232
+ actorType: ScheduleActorTypeEnum;
233
+ actorAccountId?: ScheduleId | null;
234
+ actorOrganizationId?: ScheduleId | null;
235
+ actorContactId?: ScheduleId | null;
236
+ status: ScheduleAssignmentStatusEnum;
237
+ startAt?: Date | string | null;
238
+ endAt?: Date | string | null;
239
+ assignedByAccountId?: ScheduleId | null;
240
+ releasedAt?: Date | string | null;
241
+ createdAt?: Date | string;
242
+ updatedAt?: Date | string;
243
+ }
244
+
245
+ /**
246
+ * An aggregate quantity over an interval that drives derived staffing
247
+ * requirements. Never identifies a person.
248
+ */
249
+
250
+ export interface ScheduleDemandData {
251
+ __table?: string;
252
+ id: ScheduleId;
253
+ organizationId: ScheduleId;
254
+ resourceId?: ScheduleId | null;
255
+ category: string;
256
+ startAt: Date | string;
257
+ endAt: Date | string;
258
+ quantity: number;
259
+ source: ScheduleDemandSourceEnum;
260
+ createdByAccountId?: ScheduleId | null;
261
+ createdAt?: Date | string;
262
+ updatedAt?: Date | string;
263
+ }
264
+
265
+ /**
266
+ * One constraint rule. Resolution precedence is most-specific-wins:
267
+ * resource > calendar > organization > operation default.
268
+ */
269
+
270
+ export interface ScheduleRuleData {
271
+ __table?: string;
272
+ id: ScheduleId;
273
+ operationTypeId?: ScheduleId | null;
274
+ organizationId?: ScheduleId | null;
275
+ calendarId?: ScheduleId | null;
276
+ resourceId?: ScheduleId | null;
277
+ kind: ScheduleRuleKindEnum;
278
+ label?: string | null;
279
+ // Which rule template this was built from, if any; a hand-written rule has
280
+ // none and renders with the generic message for its kind
281
+ templateKey?: string | null;
282
+ config: Record<string, unknown>;
283
+ severity: ScheduleRuleSeverityEnum;
284
+ effectiveFrom?: Date | string | null;
285
+ effectiveTo?: Date | string | null;
286
+ ordinal: number;
287
+ version: number | bigint;
288
+ retiredAt?: Date | string | null;
289
+ createdAt?: Date | string;
290
+ updatedAt?: Date | string;
291
+ }
292
+
293
+ /**
294
+ * One rule template: the wording and defaults an organization sees behind a
295
+ * rule kind. Resolution is organization -> operation type -> platform default,
296
+ * so a vertical can be given its own language without a schema change.
297
+ */
298
+
299
+ export interface ScheduleRuleTemplateObj {
300
+ kind: string;
301
+ key: string;
302
+ label: string;
303
+ description: string | null;
304
+ // "{token}" placeholders filled from a violation's detail object
305
+ messageTemplate: string;
306
+ defaultConfig: Record<string, unknown> | null;
307
+ defaultSeverity: string;
308
+ ordinal: number;
309
+ }
310
+
311
+ export interface ScheduleRuleTemplateData extends ScheduleRuleTemplateObj {
312
+ __table?: string;
313
+ id: ScheduleId;
314
+ operationTypeId?: ScheduleId | null;
315
+ organizationId?: ScheduleId | null;
316
+ retiredAt?: Date | string | null;
317
+ createdAt?: Date | string;
318
+ updatedAt?: Date | string;
319
+ }
320
+
321
+ export interface ScheduleEvaluationData {
322
+ __table?: string;
323
+ id: ScheduleId;
324
+ organizationId: ScheduleId;
325
+ calendarId: ScheduleId;
326
+ windowStart: Date | string;
327
+ windowEnd: Date | string;
328
+ inputHash?: string | null;
329
+ status: ScheduleEvaluationStatusEnum;
330
+ segmentCount: number;
331
+ violationCount: number;
332
+ errorMessage?: string | null;
333
+ startedAt: Date | string;
334
+ finishedAt?: Date | string | null;
335
+ }
336
+
337
+ export interface ScheduleViolationData {
338
+ __table?: string;
339
+ id: ScheduleId;
340
+ organizationId: ScheduleId;
341
+ calendarId: ScheduleId;
342
+ evaluationId: ScheduleId;
343
+ ruleId?: ScheduleId | null;
344
+ kind: ScheduleRuleKindEnum;
345
+ severity: ScheduleRuleSeverityEnum;
346
+ resourceId?: ScheduleId | null;
347
+ occurrenceId?: ScheduleId | null;
348
+ actorAccountId?: ScheduleId | null;
349
+ segmentStart: Date | string;
350
+ segmentEnd: Date | string;
351
+ detail: Record<string, unknown>;
352
+ acknowledgedByAccountId?: ScheduleId | null;
353
+ acknowledgedAt?: Date | string | null;
354
+ createdAt?: Date | string;
355
+ }
356
+
357
+ export interface ScheduleRequestData {
358
+ __table?: string;
359
+ id: ScheduleId;
360
+ organizationId: ScheduleId;
361
+ calendarId: ScheduleId;
362
+ kind: ScheduleRequestKindEnum;
363
+ status: ScheduleRequestStatusEnum;
364
+ requesterAccountId: ScheduleId;
365
+ sourceAssignmentId?: ScheduleId | null;
366
+ targetAssignmentId?: ScheduleId | null;
367
+ targetOccurrenceId?: ScheduleId | null;
368
+ claimedByAccountId?: ScheduleId | null;
369
+ startAt?: Date | string | null;
370
+ endAt?: Date | string | null;
371
+ reason?: string | null;
372
+ autoApproved: boolean;
373
+ decidedByAccountId?: ScheduleId | null;
374
+ decidedAt?: Date | string | null;
375
+ decisionNote?: string | null;
376
+ expiresAt?: Date | string | null;
377
+ createdAt?: Date | string;
378
+ updatedAt?: Date | string;
379
+ }
380
+
381
+ /**
382
+ * One expanded instance produced by the recurrence expander, before it is
383
+ * written as an occurrence row. "recurrenceKey" is the instant the rule
384
+ * produced and never changes, even when the instance is later moved.
385
+ */
386
+
387
+ export interface ScheduleExpandedInstance {
388
+ recurrenceKey: Date;
389
+ startAt: Date;
390
+ endAt: Date;
391
+ }