@jsb188/mday 1.1.10 → 1.1.12

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 (210) hide show
  1. package/package.json +140 -54
  2. package/src/constants/agentMemory.ts +123 -0
  3. package/src/constants/agentNote.ts +212 -0
  4. package/src/constants/aiChat.ts +10 -0
  5. package/src/constants/billing.ts +126 -0
  6. package/src/constants/campaign.ts +236 -0
  7. package/src/constants/contact.ts +72 -0
  8. package/src/constants/csvExport.ts +133 -0
  9. package/src/constants/dataTable.ts +21 -21
  10. package/src/constants/dataTableFieldTypes.generated.ts +59 -0
  11. package/src/constants/docAccess.ts +33 -0
  12. package/src/constants/dt.ts +234 -0
  13. package/src/constants/email.ts +125 -7
  14. package/src/constants/fieldDoc.ts +104 -0
  15. package/src/constants/graphqlReactivity.ts +196 -0
  16. package/src/constants/integration.ts +8 -9
  17. package/src/constants/log.ts +14 -408
  18. package/src/constants/logDisplay/README.md +88 -0
  19. package/src/constants/logDisplay/defaults.ts +39 -0
  20. package/src/constants/logDisplay/index.ts +27 -0
  21. package/src/constants/logDisplay/operations/arable.ts +16 -0
  22. package/src/constants/logDisplay/operations/farmersMarket.ts +10 -0
  23. package/src/constants/logDisplay/operations/foodManufacturing.ts +13 -0
  24. package/src/constants/logDisplay/shared/accounting.ts +13 -0
  25. package/src/constants/logDisplay/shared/interactions.ts +13 -0
  26. package/src/constants/logDisplay/shared/rackTemperatures.ts +42 -0
  27. package/src/constants/logTaxonomy.generated.ts +2207 -0
  28. package/src/constants/noteDoc.ts +77 -0
  29. package/src/constants/organization.ts +18 -21
  30. package/src/constants/pageRoute.ts +23 -0
  31. package/src/constants/qrCode.ts +30 -0
  32. package/src/constants/sheet.ts +126 -14
  33. package/src/constants/sms.ts +18 -0
  34. package/src/constants/square.ts +6 -6
  35. package/src/constants/storage.ts +80 -7
  36. package/src/constants/usage.ts +82 -0
  37. package/src/constants/workflowSteps.ts +60 -0
  38. package/src/schemas/editLogEntry.ts +836 -780
  39. package/src/schemas/inboundContact.ts +60 -55
  40. package/src/schemas/logsQuery.ts +55 -49
  41. package/src/types/account.d.ts +4 -1
  42. package/src/types/agentMemory.d.ts +98 -0
  43. package/src/types/agentNote.d.ts +443 -0
  44. package/src/types/billing.d.ts +537 -0
  45. package/src/types/campaign.d.ts +1533 -0
  46. package/src/types/contact.d.ts +15 -0
  47. package/src/types/csvExport.d.ts +213 -0
  48. package/src/types/dataAnalysis.d.ts +44 -0
  49. package/src/types/dataTable.d.ts +115 -403
  50. package/src/types/definitionElement.d.ts +35 -0
  51. package/src/types/docAccess.d.ts +96 -0
  52. package/src/types/dt.d.ts +257 -0
  53. package/src/types/email.d.ts +184 -24
  54. package/src/types/emailReplyReport.d.ts +76 -0
  55. package/src/types/fieldDoc.d.ts +702 -0
  56. package/src/types/fieldDocContract.d.ts +90 -0
  57. package/src/types/inboundContact.d.ts +10 -1
  58. package/src/types/log.d.ts +254 -295
  59. package/src/types/logDisplay.types.ts +85 -0
  60. package/src/types/organization.d.ts +91 -43
  61. package/src/types/pageRoute.d.ts +48 -0
  62. package/src/types/qrCode.d.ts +96 -0
  63. package/src/types/richText.d.ts +81 -0
  64. package/src/types/sheet.d.ts +678 -129
  65. package/src/types/sms.d.ts +38 -0
  66. package/src/types/storage.d.ts +449 -129
  67. package/src/types/usage.d.ts +106 -0
  68. package/src/types/workflow.d.ts +315 -54
  69. package/src/utils/agentMemory.ts +15 -0
  70. package/src/utils/agentNote.ts +850 -0
  71. package/src/utils/aiChat.ts +43 -0
  72. package/src/utils/aiChatWork.ts +64 -0
  73. package/src/utils/billing.ts +37 -0
  74. package/src/utils/campaign.ts +1174 -0
  75. package/src/utils/campaignAI.ts +72 -0
  76. package/src/utils/campaignAccess.ts +239 -0
  77. package/src/utils/campaignEmail.ts +601 -0
  78. package/src/utils/campaignEmailCompiler.ts +372 -0
  79. package/src/utils/campaignEmailImages.ts +60 -0
  80. package/src/utils/campaignEmailStyles.ts +544 -0
  81. package/src/utils/campaignLifecycle.ts +104 -0
  82. package/src/utils/campaignPreview.ts +285 -0
  83. package/src/utils/contact.ts +50 -0
  84. package/src/utils/csvExport.ts +19 -0
  85. package/src/utils/dataTable.ts +95 -618
  86. package/src/utils/dataTableFieldTypeRegistry.ts +106 -0
  87. package/src/utils/dataTableRelativeDate.ts +447 -0
  88. package/src/utils/definitionElement.ts +84 -0
  89. package/src/utils/docAccess.ts +383 -0
  90. package/src/utils/documentName.ts +53 -0
  91. package/src/utils/email.ts +317 -51
  92. package/src/utils/emailReplyReport.test.ts +187 -0
  93. package/src/utils/emailReplyReport.ts +143 -0
  94. package/src/utils/fieldDoc.ts +157 -0
  95. package/src/utils/fieldDocAnswers.ts +128 -0
  96. package/src/utils/fieldDocDefaults.ts +36 -0
  97. package/src/utils/fieldDocProgram.ts +36 -0
  98. package/src/utils/fieldDocSummary.ts +30 -0
  99. package/src/utils/log.ts +276 -192
  100. package/src/utils/logDisplay.helpers.ts +177 -0
  101. package/src/utils/logDisplay.ts +87 -0
  102. package/src/utils/logRegistryValue.ts +90 -0
  103. package/src/utils/logStoreRead.ts +262 -0
  104. package/src/utils/logTaxonomy.helpers.ts +17 -0
  105. package/src/utils/logTaxonomy.ts +76 -0
  106. package/src/utils/logTaxonomyDisplay.ts +395 -0
  107. package/src/utils/noteDoc.ts +609 -0
  108. package/src/utils/organization.ts +337 -84
  109. package/src/utils/pageRoute.ts +71 -0
  110. package/src/utils/qrCode.helpers.ts +189 -0
  111. package/src/utils/qrCode.test.ts +519 -0
  112. package/src/utils/qrCode.ts +273 -0
  113. package/src/utils/richTextHTML.ts +385 -0
  114. package/src/utils/sheet.ts +199 -107
  115. package/src/utils/sheetAxisMove.ts +616 -0
  116. package/src/utils/sheetBootstrap.ts +1402 -0
  117. package/src/utils/sheetCellLiteral.ts +101 -0
  118. package/src/utils/sheetCommand.ts +358 -0
  119. package/src/utils/sheetDesign.ts +705 -0
  120. package/src/utils/sheetExport.ts +186 -0
  121. package/src/utils/sheetFeatureReference.ts +183 -0
  122. package/src/utils/sheetFormulaArgs.ts +168 -0
  123. package/src/utils/sheetFormulaCompile.ts +475 -0
  124. package/src/utils/sheetFormulaConditionalAggregate.ts +254 -0
  125. package/src/utils/sheetFormulaCriteria.ts +656 -0
  126. package/src/utils/sheetFormulaDate.ts +444 -0
  127. package/src/utils/sheetFormulaEvaluation.ts +899 -0
  128. package/src/utils/sheetFormulaEvaluator.ts +997 -0
  129. package/src/utils/sheetFormulaFunctionHandlers.ts +403 -0
  130. package/src/utils/sheetFormulaLogical.ts +116 -0
  131. package/src/utils/sheetFormulaLookup.ts +488 -0
  132. package/src/utils/sheetFormulaMath.ts +48 -0
  133. package/src/utils/sheetFormulaParser.ts +729 -0
  134. package/src/utils/sheetFormulaRange.ts +330 -0
  135. package/src/utils/sheetFormulaReference.ts +703 -0
  136. package/src/utils/sheetFormulaReferenceAggregates.ts +313 -0
  137. package/src/utils/sheetFormulaReferenceDates.ts +237 -0
  138. package/src/utils/sheetFormulaReferenceLogical.ts +330 -0
  139. package/src/utils/sheetFormulaReferenceLookup.ts +341 -0
  140. package/src/utils/sheetFormulaReferenceMath.ts +95 -0
  141. package/src/utils/sheetFormulaReferenceRewrite.ts +220 -0
  142. package/src/utils/sheetFormulaReferenceText.ts +462 -0
  143. package/src/utils/sheetFormulaSyntax.ts +1027 -0
  144. package/src/utils/sheetFormulaText.ts +430 -0
  145. package/src/utils/sheetJournal.ts +200 -0
  146. package/src/utils/sheetNumberFormat.ts +1012 -0
  147. package/src/utils/sheetPreview.ts +68 -0
  148. package/src/utils/sheetSequence.ts +118 -0
  149. package/src/utils/sheetSnapshot.ts +739 -0
  150. package/src/utils/sheetStructureEdit.ts +914 -0
  151. package/src/utils/sheetStructureReferences.ts +389 -0
  152. package/src/utils/square.ts +22 -12
  153. package/src/utils/storage.ts +198 -0
  154. package/src/utils/table-route.ts +127 -11
  155. package/src/utils/time.ts +12 -0
  156. package/src/utils/workflow.ts +334 -40
  157. package/src/utils/workflowLogFingerprint.ts +302 -0
  158. package/src/utils/workflowLogRevisionSnapshot.ts +424 -0
  159. package/src/utils/workflowProgress.ts +280 -0
  160. package/src/utils/workflowTriggers.ts +61 -0
  161. package/tests/agentNote.test.ts +395 -0
  162. package/tests/campaignAI.test.ts +119 -0
  163. package/tests/campaignAccess.test.ts +239 -0
  164. package/tests/campaignEmail.test.ts +441 -0
  165. package/tests/campaignLifecycle.test.ts +134 -0
  166. package/tests/campaignPublication.test.ts +309 -0
  167. package/tests/dataTableFieldTypeRegistry.test.ts +111 -0
  168. package/tests/dataTableRelativeDate.test.ts +412 -0
  169. package/tests/docAccess.test.ts +525 -0
  170. package/tests/editLogEntry.test.ts +112 -0
  171. package/tests/email.test.ts +39 -0
  172. package/tests/fieldDocProgram.test.ts +114 -0
  173. package/tests/logDisplay.fixtures.ts +67 -0
  174. package/tests/logDisplay.test.ts +227 -0
  175. package/tests/noteDoc.test.ts +514 -0
  176. package/tests/richTextHTML.test.ts +185 -0
  177. package/tests/sheetAxisMove.test.ts +352 -0
  178. package/tests/sheetBootstrap.test.ts +1967 -0
  179. package/tests/sheetFeatureReference.test.ts +22 -0
  180. package/tests/sheetFormulaCriteria.test.ts +269 -0
  181. package/tests/sheetFormulaEvaluator.test.ts +468 -0
  182. package/tests/sheetFormulaFunctions.test.ts +538 -0
  183. package/tests/sheetFormulaLanguage.test.ts +361 -0
  184. package/tests/sheetFormulaParity.fixtures.ts +872 -0
  185. package/tests/sheetFormulaParity.test.ts +188 -0
  186. package/tests/sheetFormulaRange.test.ts +167 -0
  187. package/tests/sheetFormulaReference.test.ts +78 -0
  188. package/tests/sheetFormulaReferenceRewrite.test.ts +117 -0
  189. package/tests/sheetFormulaTextDate.test.ts +512 -0
  190. package/tests/sheetSequence.test.ts +22 -0
  191. package/tests/sheetSnapshot.test.ts +134 -0
  192. package/tests/sheetStructureEdit.test.ts +537 -0
  193. package/tests/sheetStructureReferences.test.ts +589 -0
  194. package/tests/workflowLifecycleStatus.test.ts +60 -0
  195. package/tests/workflowLogFingerprint.test.ts +203 -0
  196. package/tests/workflowLogRevisionSnapshot.test.ts +96 -0
  197. package/tests/workflowProgress.test.ts +180 -0
  198. package/tests/workflowTriggers.test.ts +29 -0
  199. package/tsconfig.json +10 -10
  200. package/vitest.config.ts +8 -0
  201. package/src/constants/log-activityTexts.ts +0 -235
  202. package/src/constants/product.ts +0 -42
  203. package/src/constants/report.ts +0 -44
  204. package/src/schemas/organization.ts +0 -65
  205. package/src/schemas/productsQuery.ts +0 -53
  206. package/src/schemas/reportsQuery.ts +0 -20
  207. package/src/types/product.d.ts +0 -84
  208. package/src/types/report.d.ts +0 -290
  209. package/src/utils/product-calEvent.ts +0 -455
  210. package/src/utils/report.ts +0 -158
@@ -1,18 +1,56 @@
1
- import type { DATA_TABLE_FIELD_TYPE_ENUMS } from '../constants/dataTable.ts';
2
-
3
- export type DataTableFieldTypeEnum = typeof DATA_TABLE_FIELD_TYPE_ENUMS[number];
4
-
5
- export type DataTableFieldTypeGQL = DataTableFieldTypeEnum;
6
-
7
- export type DataTableCellReferenceStatus = 'NONE' | 'ACTIVE' | 'DELETED';
8
-
9
- export type DataTableRecordValue =
10
- | string
11
- | number
12
- | boolean
13
- | null
14
- | Record<string, any>
15
- | any[];
1
+ import type {
2
+ DtCellScalar,
3
+ DtColumnOriginEnum,
4
+ DtCoverageWarningCodeEnum,
5
+ DtRunCauseEnum,
6
+ DtSourceEnum,
7
+ DtSyncStateEnum,
8
+ DtTableKindEnum,
9
+ } from './dt.d.ts';
10
+ import type {
11
+ DATA_TABLE_FIELD_TYPE_ENUMS,
12
+ DATA_TABLE_RELATIVE_DATE_BOUNDARY_ENUMS,
13
+ DATA_TABLE_RELATIVE_DATE_OPERATOR_ENUMS,
14
+ DATA_TABLE_RELATIVE_DATE_UNIT_ENUMS,
15
+ } from '../constants/dataTable.ts';
16
+
17
+ export type DataTableFieldTypeEnum = (typeof DATA_TABLE_FIELD_TYPE_ENUMS)[number];
18
+
19
+ export type DataTableRelativeDateUnitEnum = (typeof DATA_TABLE_RELATIVE_DATE_UNIT_ENUMS)[number];
20
+
21
+ export type DataTableRelativeDateBoundaryEnum = (typeof DATA_TABLE_RELATIVE_DATE_BOUNDARY_ENUMS)[number];
22
+
23
+ export type DataTableRelativeDateOperatorEnum = (typeof DATA_TABLE_RELATIVE_DATE_OPERATOR_ENUMS)[number];
24
+
25
+ /**
26
+ * A relative date: the START or END of the unit period that contains the
27
+ * organization-local today, shifted by offset units (ISO weeks start Monday).
28
+ */
29
+ export interface DataTableRelativeDateObj {
30
+ unit: DataTableRelativeDateUnitEnum;
31
+ offset: number;
32
+ boundary: DataTableRelativeDateBoundaryEnum;
33
+ }
34
+
35
+ /**
36
+ * The organization time zone and its local date that one query resolves
37
+ * every relative date against.
38
+ */
39
+ export interface DataTableRelativeDateContextObj {
40
+ timeZone: string;
41
+ today: string;
42
+ }
43
+
44
+ /**
45
+ * One resolved relative date: the boundary day (YYYY-MM-DD) for date columns
46
+ * and the boundary instant (ISO with the zone offset) for datetime columns.
47
+ */
48
+ export interface DataTableRelativeDateResolvedObj {
49
+ date: string;
50
+ instant: string;
51
+ }
52
+
53
+ export type DataTableRecordValue = string | number | boolean | null | Record<string, any> | any[];
16
54
 
17
55
  export interface DataTableDesignCellOptionObj {
18
56
  label: string;
@@ -20,428 +58,102 @@ export interface DataTableDesignCellOptionObj {
20
58
  color?: string | null;
21
59
  }
22
60
 
61
+ /* One typed column a value is coerced into (dataset conversion and select-option matching). */
23
62
  export interface DataTableDesignCellObj {
24
63
  key: string;
25
64
  label: string;
26
- humanLabel?: string | null;
27
- iconName?: string | null;
28
65
  fieldType: DataTableFieldTypeEnum;
29
- humanFieldType: DataTableFieldTypeEnum;
30
- format?: string | null;
31
- instructions?: string | null;
32
- source?: {
33
- path: string;
34
- table: string;
35
- } | null;
36
66
  options?: DataTableDesignCellOptionObj[];
37
- openLink?: boolean;
38
- humansOnly?: boolean;
39
- humansCannotEdit?: boolean; // If true, humans cannot edit this cell
40
- hidden?: boolean; // If true, this cell is hidden from the default dataTable grid
41
- indexed?: boolean;
42
- width?: number | null;
43
- }
44
-
45
- export interface DataTableDesignViewColumnSourceObj {
46
- type: 'MASTER_CELL' | 'FORMULA' | 'STATIC' | 'DIMENSION' | 'CUSTOM' | 'RELATED_RECORD' | 'COMPUTED';
47
- cellKey?: string | null;
48
- formulaKey?: string | null;
49
- dimensionKey?: string | null;
50
- table?: string | null;
51
- path?: string | null;
52
- sourceCellKey?: string | null;
53
- sourceCellKeys?: string[];
54
- operation?: 'SUM' | null;
55
- }
56
-
57
- export interface DataTableDesignViewDimensionObj {
58
- key: string;
59
- label?: string | null;
60
- source?: DataTableDesignViewColumnSourceObj | null;
61
- }
62
-
63
- export interface DataTableDesignViewGeneratorDateSeriesObj {
64
- key: string;
65
- label?: string | null;
66
- sourceCellKey?: string | null;
67
- grain: 'DAY' | 'WEEK';
68
- weekStart?: 'MONDAY';
69
- range: {
70
- type: 'CURRENT_MONTH' | 'FIXED';
71
- start?: string;
72
- end?: string;
73
- };
74
- }
75
-
76
- export interface DataTableDesignViewGeneratorDimensionObj {
77
- key: string;
78
- label?: string | null;
79
- source:
80
- | {
81
- type: 'MASTER_CELL_OPTIONS';
82
- cellKey: string;
83
- }
84
- | {
85
- type: 'STATIC_VALUES';
86
- values: Array<{
87
- value: string;
88
- label?: string | null;
89
- }>;
90
- };
91
- }
92
-
93
- export interface DataTableDesignViewGeneratorMeasureObj {
94
- key: string;
95
- label?: string | null;
96
- operation: 'COUNT' | 'SUM';
97
- sourceCellKey?: string | null;
98
- }
99
-
100
- export interface DataTableDesignViewGeneratorObj {
101
- keyPrefix: string;
102
- dateSeries?: DataTableDesignViewGeneratorDateSeriesObj;
103
- dimensions?: DataTableDesignViewGeneratorDimensionObj[];
104
- measures?: DataTableDesignViewGeneratorMeasureObj[];
105
- }
106
-
107
- export interface DataTableDesignViewRowModelObj {
108
- type: 'MASTER_ROWS' | 'GROUPED_ROWS';
109
- dimensions?: DataTableDesignViewDimensionObj[];
110
- generator?: DataTableDesignViewGeneratorObj | null;
111
67
  }
112
68
 
113
- export interface DataTableDesignViewColumnObj {
69
+ /* One column of a read-only data table, as the shared dataTableFragment selects it. */
70
+ export interface DataTableColumnGQL {
114
71
  key: string;
115
72
  label: string;
116
- humanLabel?: string | null;
117
- iconName?: string | null;
118
- fieldType?: DataTableFieldTypeEnum | null;
119
- humanFieldType: DataTableFieldTypeEnum;
120
- source?: DataTableDesignViewColumnSourceObj | null;
121
- options?: DataTableDesignCellOptionObj[];
122
- openLink?: boolean;
123
- humansCannotEdit?: boolean;
124
- width?: number | null;
73
+ type: string;
74
+ origin: DtColumnOriginEnum;
75
+ unit?: string | null;
76
+ currency?: string | null;
77
+ retired: boolean;
125
78
  }
126
79
 
127
- export interface DataTableDesignViewFilterObj {
128
- id: string;
80
+ /* One projection gap of a SOURCE table: source data the table cannot show. */
81
+ export interface DataTableCoverageWarningGQL {
82
+ code: DtCoverageWarningCodeEnum;
129
83
  columnKey: string;
130
- operator: string;
131
- value?: any;
132
- enabled?: boolean;
84
+ message: string;
133
85
  }
134
86
 
135
- export interface DataTableDesignViewSortObj {
136
- columnKey: string;
137
- direction: 'ASC' | 'DESC';
138
- }
139
-
140
- export interface DataTableDesignViewGroupObj {
141
- columnKey: string;
142
- direction?: 'ASC' | 'DESC';
143
- }
144
-
145
- export interface DataTableDesignViewObj {
87
+ /* The AI note that owns a table. */
88
+ export interface DataTableOwnerNoteGQL {
146
89
  id: string;
147
- name: string;
148
- layout: 'GRID';
149
- iconName?: string | null;
150
- color?: string | null;
151
- description?: string | null;
152
- rowModel?: DataTableDesignViewRowModelObj | null;
153
- columns: DataTableDesignViewColumnObj[];
154
- columnsOrder?: string[];
155
- filters?: DataTableDesignViewFilterObj[];
156
- sorts?: DataTableDesignViewSortObj[];
157
- groups?: DataTableDesignViewGroupObj[];
158
- stickyTop?: number | null;
159
- stickyLeft?: number | null;
160
- humansCannotEdit?: boolean | null;
161
- }
162
-
163
- export interface DataTableDesignObj {
164
- cells: DataTableDesignCellObj[];
165
- cellsOrder?: string[];
166
- views?: DataTableDesignViewObj[];
167
- viewsOrder?: string[];
168
- defaultViewId?: string | null;
169
- instructions?: string;
170
- humansCannotEdit?: boolean; // If true, humans cannot edit any cells in this dataTable
171
- stickyTop?: number;
172
- stickyLeft?: number;
173
- }
174
-
175
- export interface DataTableData {
176
- __table: 'data_tables';
177
-
178
- id: number | bigint;
179
- organizationId: number | bigint;
180
- name: string;
181
- title: string;
182
- description?: string | null;
183
- design: DataTableDesignObj;
184
- active: boolean;
185
- createdAt: Date;
186
- updatedAt: Date;
187
- }
188
-
189
- export interface DataTableRowData {
190
- __table: 'data_table_rows';
191
-
192
- id: number | bigint;
193
- organizationId: number | bigint;
194
- dataTableId: number | bigint;
195
- identifier?: string | null;
196
- viewId?: string | null;
197
- viewRowKey?: string | null;
198
- position: number;
199
- metadata: Record<string, any>;
200
- }
201
-
202
- export interface DataTableRecordData {
203
- __table: 'data_table_records';
204
-
205
- id: number | bigint;
206
- dataTableId: number | bigint;
207
- dataTableRowId: number | bigint;
208
- cellKey: string;
209
- iconName?: string | null;
210
- value?: DataTableRecordValue;
211
- textValue?: string | null;
212
- numberValue?: number | null;
213
- booleanValue?: boolean | null;
214
- dateValue?: Date | string | null;
215
- datetimeValue?: Date | string | null;
216
- relatedTable?: string | null;
217
- relatedId?: number | bigint | null;
218
- referenceDataTableId?: number | bigint | null;
219
- referenceDataTableRowId?: number | bigint | null;
220
- referenceCellKey?: string | null;
221
- createdAt: Date;
222
- updatedAt: Date;
223
- }
224
-
225
- export interface DataTableCellReferenceGQL {
226
- dataTableId?: string | null;
227
- dataTableRowId?: string | null;
228
- cellKey?: string | null;
229
- }
230
-
231
- export interface DataTableDesignCellOptionGQL {
232
- label: string;
233
- value: string;
234
- color?: string | null;
235
- }
236
-
237
- export interface DataTableDesignCellSourceGQL {
238
- path: string;
239
- table: string;
240
- }
241
-
242
- export interface DataTableDesignCellGQL {
243
- key: string;
244
- label: string;
245
- humanLabel?: string | null;
246
- iconName?: string | null;
247
- fieldType: DataTableFieldTypeGQL;
248
- humanFieldType: DataTableFieldTypeGQL;
249
- format?: string | null;
250
- instructions?: string | null;
251
- source?: DataTableDesignCellSourceGQL | null;
252
- options?: DataTableDesignCellOptionGQL[];
253
- openLink?: boolean | null;
254
- humansOnly?: boolean | null;
255
- humansCannotEdit?: boolean | null;
256
- hidden?: boolean | null;
257
- indexed?: boolean | null;
258
- width?: number | null;
259
- }
260
-
261
- export interface DataTableDesignViewColumnSourceGQL {
262
- type: 'MASTER_CELL' | 'FORMULA' | 'STATIC' | 'DIMENSION' | 'CUSTOM' | 'RELATED_RECORD' | 'COMPUTED';
263
- cellKey?: string | null;
264
- formulaKey?: string | null;
265
- dimensionKey?: string | null;
266
- table?: string | null;
267
- path?: string | null;
268
- sourceCellKey?: string | null;
269
- sourceCellKeys?: string[];
270
- operation?: 'SUM' | null;
271
- }
272
-
273
- export interface DataTableDesignViewDimensionGQL {
274
- key: string;
275
- label?: string | null;
276
- source?: DataTableDesignViewColumnSourceGQL | null;
277
- }
278
-
279
- export interface DataTableDesignViewGeneratorDateSeriesGQL {
280
- key: string;
281
- label?: string | null;
282
- sourceCellKey?: string | null;
283
- grain: 'DAY' | 'WEEK';
284
- weekStart?: 'MONDAY' | null;
285
- range: {
286
- type: 'CURRENT_MONTH' | 'FIXED';
287
- start?: string | null;
288
- end?: string | null;
289
- };
290
- }
291
-
292
- export interface DataTableDesignViewGeneratorDimensionGQL {
293
- key: string;
294
- label?: string | null;
295
- source:
296
- | {
297
- type: 'MASTER_CELL_OPTIONS';
298
- cellKey: string;
299
- }
300
- | {
301
- type: 'STATIC_VALUES';
302
- values: Array<{
303
- value: string;
304
- label?: string | null;
305
- }>;
306
- };
307
- }
308
-
309
- export interface DataTableDesignViewGeneratorMeasureGQL {
310
- key: string;
311
- label?: string | null;
312
- operation: 'COUNT' | 'SUM';
313
- sourceCellKey?: string | null;
314
- }
315
-
316
- export interface DataTableDesignViewGeneratorGQL {
317
- keyPrefix: string;
318
- dateSeries?: DataTableDesignViewGeneratorDateSeriesGQL | null;
319
- dimensions?: DataTableDesignViewGeneratorDimensionGQL[];
320
- measures?: DataTableDesignViewGeneratorMeasureGQL[];
321
- }
322
-
323
- export interface DataTableDesignViewRowModelGQL {
324
- type: 'MASTER_ROWS' | 'GROUPED_ROWS';
325
- dimensions?: DataTableDesignViewDimensionGQL[];
326
- generator?: DataTableDesignViewGeneratorGQL | null;
327
- }
328
-
329
- export interface DataTableDesignViewColumnGQL {
330
- key: string;
331
- label: string;
332
- humanLabel?: string | null;
333
- iconName?: string | null;
334
- fieldType?: DataTableFieldTypeGQL | null;
335
- humanFieldType: DataTableFieldTypeGQL;
336
- source?: DataTableDesignViewColumnSourceGQL | null;
337
- options?: DataTableDesignCellOptionGQL[];
338
- openLink?: boolean | null;
339
- humansCannotEdit?: boolean | null;
340
- width?: number | null;
341
- }
342
-
343
- export interface DataTableDesignViewFilterGQL {
344
- id: string;
345
- columnKey: string;
346
- operator: string;
347
- value?: string | null;
348
- enabled?: boolean | null;
349
- }
350
-
351
- export interface DataTableDesignViewSortGQL {
352
- columnKey: string;
353
- direction: 'ASC' | 'DESC';
354
- }
355
-
356
- export interface DataTableDesignViewGroupGQL {
357
- columnKey: string;
358
- direction?: 'ASC' | 'DESC' | null;
359
- }
360
-
361
- export interface DataTableDesignViewGQL {
362
- id: string;
363
- name: string;
364
- layout: 'GRID';
365
- iconName?: string | null;
366
- color?: string | null;
367
- description?: string | null;
368
- rowModel?: DataTableDesignViewRowModelGQL | null;
369
- columns: DataTableDesignViewColumnGQL[];
370
- columnsOrder: string[];
371
- filters: DataTableDesignViewFilterGQL[];
372
- sorts: DataTableDesignViewSortGQL[];
373
- groups: DataTableDesignViewGroupGQL[];
374
- stickyTop?: number | null;
375
- stickyLeft?: number | null;
376
- humansCannotEdit?: boolean | null;
377
- }
378
-
379
- export interface DataTableDesignGQL {
380
- id: string;
381
- cells: DataTableDesignCellGQL[];
382
- cellsOrder: string[];
383
- views?: DataTableDesignViewGQL[];
384
- viewsOrder?: string[];
385
- defaultViewId?: string | null;
386
- instructions?: string | null;
387
- humansCannotEdit?: boolean | null;
388
- stickyTop?: number | null;
389
- stickyLeft?: number | null;
90
+ headline: string | null;
91
+ emoji: string;
390
92
  }
391
93
 
94
+ /* One read-only data table (GraphQL DataTable; dataTableFragment). */
392
95
  export interface DataTableGQL {
393
96
  __deleted?: boolean;
394
97
 
395
98
  id: string;
99
+ cursor?: string | null;
396
100
  organizationId: string;
397
101
 
398
- name: string;
102
+ kind: DtTableKindEnum;
103
+ source?: DtSourceEnum | null;
399
104
  title: string;
400
105
  description?: string | null;
401
- design: DataTableDesignGQL;
402
- active: boolean;
106
+ rowCount: number;
107
+ /* Table revision serialized as BigInt text. */
108
+ revision: string;
109
+ syncState: DtSyncStateEnum;
110
+ syncError?: string | null;
111
+ /* Last committed batch of any kind (sync, AI column, agent write): "data as of". */
112
+ syncedAt?: string | null;
113
+ derivePausedAt?: string | null;
114
+ derivePauseReason?: string | null;
115
+ canManage: boolean;
116
+ archivedAt?: string | null;
117
+
118
+ columns: DataTableColumnGQL[];
119
+ coverageWarnings: DataTableCoverageWarningGQL[];
120
+ ownerNote?: DataTableOwnerNoteGQL | null;
403
121
 
404
122
  createdAt: string;
405
123
  updatedAt: string;
406
124
  }
407
125
 
126
+ /* One live row (GraphQL DataTableRow; dataTableRowFragment). "cells" maps column keys to values. */
408
127
  export interface DataTableRowGQL {
409
- __deleted?: boolean;
410
-
411
128
  id: string;
412
- cursor: string;
413
- organizationId: string;
414
- dataTableId: string;
415
-
416
- identifier?: string | null;
417
- viewId?: string | null;
418
- viewRowKey?: string | null;
419
- position: number;
420
- metadata: string;
421
- cells?: DataTableCellGQL[];
422
- updatedAt?: string | null;
129
+ key: string;
130
+ cells: Record<string, DtCellScalar>;
131
+ sourceReadableId?: string | null;
132
+ derivePending: boolean;
133
+ deriveError?: string | null;
134
+ changedAt: string;
135
+ // Keyset cursor after this row; the client attaches it to the last row of a page
136
+ cursor?: string | null;
423
137
  }
424
138
 
425
- export interface DataTableCellGQL {
426
- __deleted?: boolean;
139
+ /* One keyset page of live rows (GraphQL DataTableRowPage). */
140
+ export interface DataTableRowPageGQL {
141
+ items: DataTableRowGQL[];
142
+ nextCursor?: string | null;
143
+ revision: string;
144
+ }
427
145
 
146
+ /* One recorded change batch of a table (GraphQL DataTableRun; dataTableRunFragment). */
147
+ export interface DataTableRunGQL {
428
148
  id: string;
429
- dataTableId: string;
430
- dataTableRowId: string;
431
-
432
- cellKey: string;
433
- iconName?: string | null;
434
- value?: string | null;
435
- textValue?: string | null;
436
- numberValue?: number | null;
437
- booleanValue?: boolean | null;
438
- dateValue?: string | null;
439
- datetimeValue?: string | null;
440
- relatedTable?: string | null;
441
- relatedId?: string | null;
442
- reference?: DataTableCellReferenceGQL | null;
443
- referenceStatus?: DataTableCellReferenceStatus | null;
444
-
445
- createdAt: string;
446
- updatedAt: string;
149
+ cause: DtRunCauseEnum;
150
+ added: number;
151
+ changed: number;
152
+ removed: number;
153
+ derived: number;
154
+ llmCalls: number;
155
+ reason?: string | null;
156
+ error?: string | null;
157
+ startedAt: string;
158
+ finishedAt?: string | null;
447
159
  }
@@ -0,0 +1,35 @@
1
+ import type { StorageData } from './storage.d.ts';
2
+
3
+ /**
4
+ * Definition elements; the row shape shared by field_doc_elements and
5
+ * campaign_template_elements. Both store one definition as flat element rows:
6
+ * SECTION elements are the top-level containers ("parentId" IS NULL) and every
7
+ * other element is a child of exactly one section. Each domain keeps its own
8
+ * kinds, option shape, settings flags and extra columns.
9
+ */
10
+
11
+ export interface DefinitionElementBaseData<KindEnum extends string, OptionObj, SettingsObj, StorageRelObj> {
12
+ id: number | bigint;
13
+ parentId?: number | bigint | null; // NULL for SECTION elements
14
+ kind: KindEnum;
15
+ key: string; // Answers reference this key; unique per definition
16
+ order: number;
17
+ label?: string | null;
18
+ description?: string | null;
19
+ options?: OptionObj[] | null;
20
+ required?: boolean;
21
+ settings?: SettingsObj | null;
22
+ storageRels?: StorageRelObj[]; // Element images
23
+ }
24
+
25
+ // One ordered element image; each domain adds its table name and element foreign key
26
+ export interface DefinitionElementStorageRelBaseData {
27
+ storageId: number | bigint;
28
+ order: number;
29
+ file: StorageData;
30
+ }
31
+
32
+ // One hydrated top-level section with its ordered child elements
33
+ export type DefinitionSectionWithElementsObj<ElementObj> = ElementObj & {
34
+ elements: ElementObj[];
35
+ };
@@ -0,0 +1,96 @@
1
+ import type {
2
+ DOC_ACCESS_ENTITY_TYPE_ENUMS,
3
+ DOC_ACCESS_GRANTEE_TYPE_ENUMS,
4
+ DOC_ACCESS_SCOPE_ENUMS,
5
+ DOC_GRANT_PERMISSION_ENUMS,
6
+ DOC_PERMISSION_ENUMS,
7
+ } from '../constants/docAccess.ts';
8
+
9
+ export type DocPermissionEnum = (typeof DOC_PERMISSION_ENUMS)[number];
10
+ export type DocGrantPermissionEnum =
11
+ (typeof DOC_GRANT_PERMISSION_ENUMS)[number];
12
+ export type DocAccessGranteeTypeEnum =
13
+ (typeof DOC_ACCESS_GRANTEE_TYPE_ENUMS)[number];
14
+ export type DocAccessEntityTypeEnum =
15
+ (typeof DOC_ACCESS_ENTITY_TYPE_ENUMS)[number];
16
+ export type DocAccessScopeEnum = (typeof DOC_ACCESS_SCOPE_ENUMS)[number];
17
+
18
+ /**
19
+ * Base access policy stored on the document row itself (jsonb "access"):
20
+ * - team: what every owner-org member gets ("NONE" restricts the document
21
+ * to grant holders and owner-org members with the document edit ACL)
22
+ * - public: what everyone with the link gets
23
+ * - network: what every member of the owner org's network (child)
24
+ * organizations gets
25
+ */
26
+
27
+ export interface DocAccessBaseObj {
28
+ team: DocPermissionEnum;
29
+ public: DocPermissionEnum;
30
+ network: DocPermissionEnum;
31
+ }
32
+
33
+ /**
34
+ * One access grant for one account or one organization. A grant overrides
35
+ * the base policy for its grantee (ACCOUNT grants override the team rule,
36
+ * ORGANIZATION grants override the network rule), so it can raise or lower
37
+ * access, including an explicit "NONE" block. Grants are stored relationally
38
+ * in access_grants; ids are serialized GenericIDs on the client and parsed
39
+ * numeric ids in server storage.
40
+ */
41
+
42
+ export interface DocAccessGrantObj {
43
+ granteeType: DocAccessGranteeTypeEnum;
44
+ granteeId: string | number | bigint;
45
+ permission: DocGrantPermissionEnum;
46
+ }
47
+
48
+ /**
49
+ * Full access settings for one document: the base policy plus the grants
50
+ * list. Fetch paths that skip the grants table leave "grants" undefined.
51
+ */
52
+
53
+ export interface DocAccessObj extends DocAccessBaseObj {
54
+ grants?: DocAccessGrantObj[] | null;
55
+ }
56
+
57
+ /**
58
+ * Viewer facts needed to evaluate one document's access settings.
59
+ * - isOwnerOrgMember: viewer passes the owner org's "general_read" ACL
60
+ * - isAdminOrOwner: viewer's role in the owner org is ADMIN or OWNER
61
+ * (admins and owners always keep full view and edit access)
62
+ * - hasWriteACL: viewer passes the owner org's "general_write" ACL; the
63
+ * team policy only grants EDIT to members who can write org data
64
+ * (read-only members cap at VIEW unless an explicit grant raises them)
65
+ * - isNetworkOrgMember: viewer belongs to one of the owner org's network
66
+ * (child) organizations
67
+ * - viewerOrganizationIds: every organization the viewer belongs to
68
+ */
69
+
70
+ export interface DocAccessViewerCtx {
71
+ accountId?: string | number | bigint | null;
72
+ isOwnerOrgMember?: boolean | null;
73
+ isAdminOrOwner?: boolean | null;
74
+ hasWriteACL?: boolean | null;
75
+ isNetworkOrgMember?: boolean | null;
76
+ viewerOrganizationIds?: Array<string | number | bigint> | null;
77
+ }
78
+
79
+ /**
80
+ * One access_grants database row.
81
+ */
82
+
83
+ export interface DocAccessGrantData {
84
+ __table: 'access_grants';
85
+
86
+ id: number | bigint;
87
+ organizationId: number | bigint;
88
+ entityType: DocAccessEntityTypeEnum;
89
+ entityId: number | bigint;
90
+ granteeType: DocAccessGranteeTypeEnum;
91
+ granteeAccountId?: number | bigint | null;
92
+ granteeOrganizationId?: number | bigint | null;
93
+ permission: DocGrantPermissionEnum;
94
+ createdAt: Date;
95
+ updatedAt: Date;
96
+ }