@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,14 +1,16 @@
1
1
  import {
2
- COMPLIANCE_DOCUMENT_TYPE_ENUMS,
3
- OPERATION_ENUMS,
4
- ORG_CONTACTS,
5
- ROLE_CATEGORY_ENUMS,
6
- ROLE_ENUMS
2
+ COMPLIANCE_DOCUMENT_TYPE_ENUMS,
3
+ OPERATION_ENUMS,
4
+ ORG_CONTACTS,
5
+ ROLE_CATEGORY_ENUMS,
6
+ ROLE_ENUMS,
7
7
  } from '../constants/organization.ts';
8
- import { PRODUCT_FEATURES } from '../constants/product.ts';
9
8
 
10
9
  import type { AddressObj } from '@jsb188/app/types/other.d.ts';
11
- import type { IntegrationConnectionData, IntegrationConnectionGQL } from './integration.d.ts';
10
+ import type {
11
+ IntegrationConnectionData,
12
+ IntegrationConnectionGQL,
13
+ } from './integration.d.ts';
12
14
  import type { StorageData, StorageGQL } from './storage.d.ts';
13
15
  import type { OrganizationRouteSettingsObj } from '../utils/table-route.ts';
14
16
 
@@ -16,12 +18,16 @@ import type { OrganizationRouteSettingsObj } from '../utils/table-route.ts';
16
18
  * Enums
17
19
  */
18
20
 
19
- export type OrganizationFeatureEnum = typeof PRODUCT_FEATURES[number];
20
- export type OrganizationRoleEnum = typeof ROLE_ENUMS[number];
21
- export type OrganizationOperationEnum = typeof OPERATION_ENUMS[number];
22
- export type OrganizationDepartmentEnum = typeof ORG_CONTACTS[number];
23
- export type OrganizationRoleCategoryEnum = typeof ROLE_CATEGORY_ENUMS[number];
24
- export type OrganizationComplianceType = typeof COMPLIANCE_DOCUMENT_TYPE_ENUMS[number];
21
+ export type OrganizationRoleEnum = (typeof ROLE_ENUMS)[number];
22
+ // Known keys retain autocomplete, while registry-launched operations remain
23
+ // valid without requiring a TypeScript/codegen change.
24
+ export type OrganizationOperationEnum =
25
+ | (typeof OPERATION_ENUMS)[number]
26
+ | (string & {});
27
+ export type OrganizationDepartmentEnum = (typeof ORG_CONTACTS)[number];
28
+ export type OrganizationRoleCategoryEnum = (typeof ROLE_CATEGORY_ENUMS)[number];
29
+ export type OrganizationComplianceType =
30
+ (typeof COMPLIANCE_DOCUMENT_TYPE_ENUMS)[number];
25
31
 
26
32
  /**
27
33
  * Query filters
@@ -76,20 +82,40 @@ export interface OrganizationData {
76
82
  __table: 'organizations';
77
83
  id: bigint;
78
84
  stripeCustomerId: string | null;
79
- inboundEmail: string | null;
85
+ emailHandle: string | null;
80
86
  name: string;
81
87
  commodities: string[] | null;
82
88
  operation: OrganizationOperationEnum;
83
- features: OrganizationFeatureEnum[];
84
89
  settings?: OrganizationSettingsObj | null;
90
+ directory?: OrgContact[] | null; // Own organization_contacts rows mapped to contacts (attached by fetch paths)
85
91
  address?:
86
92
  | null
87
- | AddressObj & {
88
- __table: 'organization_addresses';
89
- organizationId: bigint;
90
- };
93
+ | (AddressObj & {
94
+ __table: 'organization_addresses';
95
+ organizationId: bigint;
96
+ });
91
97
  integrations?: IntegrationConnectionData[] | null;
92
98
  activated: boolean;
99
+ authorizationEpoch?: number | bigint;
100
+ }
101
+
102
+ /**
103
+ * Organization directory contact row (organization_contacts table).
104
+ * "ownerOrgId" NULL means the org's own directory entry; set means a private
105
+ * per-department override maintained by that parent org for this child org.
106
+ */
107
+
108
+ export interface OrganizationContactData {
109
+ __table: 'organization_contacts';
110
+ id: bigint;
111
+ organizationId: bigint;
112
+ ownerOrgId?: bigint | null;
113
+ department: OrganizationDepartmentEnum;
114
+ name?: string | null;
115
+ emailAddress?: string | null;
116
+ phoneNumber?: string | null;
117
+ createdAt: Date;
118
+ updatedAt: Date;
93
119
  }
94
120
 
95
121
  export interface OrganizationSiteData {
@@ -119,25 +145,40 @@ export interface MergedOrgContact extends OrgContact {
119
145
  locked?: boolean;
120
146
  }
121
147
 
122
- export interface OrganizationSidebarItemObj {
148
+ export type OrganizationSidebarItemKindEnum = 'LINK' | 'BREAK' | 'GROUP';
149
+
150
+ export interface OrganizationSidebarLinkItemObj {
151
+ kind?: 'LINK' | null;
123
152
  slug: string;
124
153
  label: string;
125
154
  iconName: string | null;
155
+ order?: number | null;
156
+ }
157
+
158
+ export interface OrganizationSidebarBreakItemObj {
159
+ kind: 'BREAK';
160
+ order?: number | null;
126
161
  }
127
162
 
128
- export interface OrganizationSidebarGroupObj {
129
- title: string;
163
+ export interface OrganizationSidebarGroupItemObj {
164
+ kind: 'GROUP';
165
+ label: string;
130
166
  items: OrganizationSidebarItemObj[];
167
+ order?: number | null;
131
168
  }
132
169
 
170
+ export type OrganizationSidebarItemObj =
171
+ | OrganizationSidebarLinkItemObj
172
+ | OrganizationSidebarBreakItemObj
173
+ | OrganizationSidebarGroupItemObj;
174
+
133
175
  export interface OrganizationSettingsObj {
134
176
  timeZone: string | null;
135
177
  language: string | null;
136
178
  color: string | null;
137
179
  priorityService: boolean;
138
- directory?: OrgContact[];
139
180
  routes?: Record<string, OrganizationRouteSettingsObj>;
140
- sidebar?: OrganizationSidebarGroupObj[] | null;
181
+ sidebar?: OrganizationSidebarItemObj[] | null;
141
182
  }
142
183
 
143
184
  export interface OrganizationChildData {
@@ -145,13 +186,13 @@ export interface OrganizationChildData {
145
186
  parentId: number | bigint | null;
146
187
  childId: number | bigint;
147
188
  organization: OrganizationData;
148
- preferredContacts?: {
149
- [key: OrganizationDepartmentEnum]: Partial<{
150
- name: string | null;
151
- phoneNumber: string | null;
152
- emailAddress: string | null;
153
- }>;
154
- };
189
+ preferredContacts?: {
190
+ [key: OrganizationDepartmentEnum]: Partial<{
191
+ name: string | null;
192
+ phoneNumber: string | null;
193
+ emailAddress: string | null;
194
+ }>;
195
+ };
155
196
  memory?: string | null;
156
197
  affiliated: boolean;
157
198
  addedAt: Date;
@@ -187,18 +228,19 @@ export interface OrganizationComplianceGQL {
187
228
  }
188
229
 
189
230
  export interface OrganizationGQL {
190
- __deleted?: boolean;
231
+ __deleted?: boolean;
191
232
 
192
233
  id: string;
234
+ readableId?: string | null;
193
235
  stripeCustomerId: string | null;
194
- inboundEmail: string | null;
236
+ emailHandle: string | null;
195
237
  name: string;
196
238
  commodities: string[] | null;
197
239
  address: AddressObj;
198
240
  operation: OrganizationOperationEnum;
199
241
  compliance: OrganizationComplianceGQL[] | null;
200
242
  integrations: IntegrationConnectionGQL[] | null;
201
- features: OrganizationFeatureEnum[];
243
+ logTaxonomy?: import('./log.d.ts').LogTaxonomyGQL | null;
202
244
  settings?: OrganizationSettingsObj | null;
203
245
  directory: OrgContact[];
204
246
  activated: boolean;
@@ -246,7 +288,7 @@ export interface OrganizationRelAccountGQL {
246
288
  }
247
289
 
248
290
  export interface OrganizationRelGQL {
249
- __deleted?: boolean;
291
+ __deleted?: boolean;
250
292
 
251
293
  id: string;
252
294
  organizationId?: string;
@@ -258,13 +300,13 @@ export interface OrganizationRelGQL {
258
300
  }
259
301
 
260
302
  export interface OrganizationChildGQL {
261
- __deleted?: boolean;
303
+ __deleted?: boolean;
262
304
 
263
305
  id: string;
264
- parentId: string;
265
- cursor: string;
306
+ parentId: string;
307
+ cursor: string;
266
308
  organization: OrganizationGQL;
267
- preferredContacts: OrgContact[];
309
+ preferredContacts: OrgContact[];
268
310
  memory?: string | null;
269
311
  affiliated: boolean;
270
312
  addedAt: Date;
@@ -291,7 +333,8 @@ export interface OrganizationComplianceObj {
291
333
  notes?: string;
292
334
  }
293
335
 
294
- export interface OrganizationComplianceData extends Omit<OrganizationComplianceObj, 'expirationDate'> {
336
+ export interface OrganizationComplianceData
337
+ extends Omit<OrganizationComplianceObj, 'expirationDate'> {
295
338
  __table: 'organization_compliances';
296
339
  id: number;
297
340
  organizationId: number;
@@ -0,0 +1,48 @@
1
+ export type PageRouteQueryEnum = 'LOG_ENTRIES' | 'CHILD_ORGANIZATIONS';
2
+
3
+ export interface PageRouteLogEntriesFilterObj {
4
+ siteId?: number | string | null;
5
+ preset?: string | null;
6
+ types?: string[] | null;
7
+ activities?: string[] | null;
8
+ startDate?: string | null;
9
+ endDate?: string | null;
10
+ query?: string | null;
11
+ }
12
+
13
+ export interface PageRouteChildOrgsFilterObj {
14
+ childOrgIds?: (number | string)[] | null;
15
+ affiliated?: boolean | null;
16
+ }
17
+
18
+ export interface PageRouteFiltersObj {
19
+ logEntries?: PageRouteLogEntriesFilterObj | null;
20
+ childOrgs?: PageRouteChildOrgsFilterObj | null;
21
+ }
22
+
23
+ export interface OrganizationPageRouteData {
24
+ id: number | bigint;
25
+ organizationId: number | bigint;
26
+ slug: string;
27
+ query: PageRouteQueryEnum;
28
+ filters: PageRouteFiltersObj;
29
+ columns: string[];
30
+ iconName?: string | null;
31
+ starred: boolean;
32
+ createdAt: Date;
33
+ updatedAt: Date;
34
+ }
35
+
36
+ export interface OrgPageRouteGQL {
37
+ id: string;
38
+ organizationId: string;
39
+ slug: string;
40
+ query: PageRouteQueryEnum;
41
+ logEntriesFilter?: PageRouteLogEntriesFilterObj | null;
42
+ childOrgsFilter?: PageRouteChildOrgsFilterObj | null;
43
+ columns: string[];
44
+ iconName?: string | null;
45
+ starred?: boolean | null;
46
+ createdAt?: string | null;
47
+ updatedAt?: string | null;
48
+ }
@@ -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
+ }