@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
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Note document ("noteDoc") constants, shared by the Deno server sanitizer
3
+ * and the web note editor. A note's content is one ProseMirror-shaped JSON
4
+ * tree restricted to the closed node/mark vocabulary declared here; anything
5
+ * outside this vocabulary is removed by sanitizeNoteDoc on every write.
6
+ */
7
+
8
+ import { COLORS } from '@jsb188/app/constants/app.ts';
9
+
10
+ // Stamped on every sanitized document; bump only with a migration path
11
+ export const NOTE_DOC_VERSION = 1;
12
+
13
+ // Every block-level node type a note document may contain
14
+ export const NOTE_BLOCK_TYPES = [
15
+ 'paragraph',
16
+ 'heading',
17
+ 'bulletList',
18
+ 'orderedList',
19
+ 'listItem',
20
+ 'blockquote',
21
+ 'divider',
22
+ 'image',
23
+ ] as const;
24
+
25
+ // Every inline node type a text-bearing block may contain
26
+ export const NOTE_INLINE_TYPES = ['text', 'hardBreak'] as const;
27
+
28
+ // Every inline mark type a text run may carry
29
+ export const NOTE_MARK_TYPES = [
30
+ 'bold',
31
+ 'italic',
32
+ 'underline',
33
+ 'strike',
34
+ 'code',
35
+ 'color',
36
+ 'highlight',
37
+ 'link',
38
+ ] as const;
39
+
40
+ // Block types that contain other blocks; every other block type is either
41
+ // an inline-content leaf (paragraph, heading) or a void leaf (divider, image)
42
+ export const NOTE_CONTAINER_BLOCK_TYPES = [
43
+ 'bulletList',
44
+ 'orderedList',
45
+ 'listItem',
46
+ 'blockquote',
47
+ ] as const;
48
+
49
+ // Which block types each container allows as direct children; the sanitizer
50
+ // unwraps/converts/wraps anything else (it never keeps illegal nesting)
51
+ export const NOTE_NESTING_RULES: Record<string, readonly string[]> = {
52
+ doc: [
53
+ 'paragraph',
54
+ 'heading',
55
+ 'bulletList',
56
+ 'orderedList',
57
+ 'blockquote',
58
+ 'divider',
59
+ 'image',
60
+ ],
61
+ bulletList: ['listItem'],
62
+ orderedList: ['listItem'],
63
+ listItem: ['paragraph', 'bulletList', 'orderedList'],
64
+ blockquote: ['paragraph'],
65
+ };
66
+
67
+ // Valid tokens for color/highlight marks: the shared 21-color app palette
68
+ export const NOTE_COLOR_TOKENS: readonly string[] = COLORS;
69
+
70
+ // Sanitizer caps against oversized/hostile documents; the sanitizer
71
+ // truncates the tail once a cap is reached
72
+ export const NOTE_MAX_DEPTH = 6;
73
+ export const NOTE_MAX_BLOCKS = 2000;
74
+ export const NOTE_MAX_TEXT_CHARS = 200000;
75
+
76
+ // link mark hrefs must match this (kills javascript:/data:/etc URLs)
77
+ export const NOTE_LINK_HREF_REGEX = /^(https?:|mailto:)/i;
@@ -4,27 +4,31 @@
4
4
  export const OPERATION_ENUMS = [
5
5
  // Farms
6
6
  'ARABLE',
7
- 'LIVESTOCK',
8
7
 
9
8
  // Umbrella orgs
10
9
  'FARMERS_MARKET',
11
10
  'GROWER_NETWORK',
12
11
 
13
- // External orgs
14
- 'RESTAURANT',
15
- 'VENDOR',
16
- 'WHOLESALE_FOOD',
17
- 'UNKNOWN',
12
+ // External orgs
13
+ 'RESTAURANT',
14
+ 'VENDOR',
15
+ 'WHOLESALE_FOOD',
16
+ 'UNKNOWN',
17
+
18
+ // Project-scheduled operations (appended; see note above)
19
+ 'CONSTRUCTION',
20
+ 'UTILITIES',
21
+ 'CHILDCARE',
22
+
23
+ // Registry-logged operations (appended; see note above)
24
+ 'CONSTRUCTION_INSPECTION_AGENCY',
25
+ 'EMERGENCY_MEDICAL_SERVICES_AGENCY',
26
+ 'FOOD_MANUFACTURING',
18
27
  ];
19
28
 
20
- export const PARENT_ORG_OPERATIONS = [
21
- 'FARMERS_MARKET',
22
- 'GROWER_NETWORK',
23
- ];
29
+ export const PARENT_ORG_OPERATIONS = ['FARMERS_MARKET', 'GROWER_NETWORK'];
24
30
 
25
- export const AUDITOR_ORG_OPERATIONS = [
26
- 'GROWER_NETWORK',
27
- ];
31
+ export const AUDITOR_ORG_OPERATIONS = ['GROWER_NETWORK'];
28
32
 
29
33
  // Membership roles
30
34
  // Order of roles matter (for visualization)
@@ -38,14 +42,7 @@ export const ROLE_CATEGORY_ENUMS = ['EMPLOYEES_ONLY', 'MANAGERS_ONLY'];
38
42
 
39
43
  // Org departments
40
44
 
41
- export const ORG_CONTACTS = [
42
- 'PRIMARY_CONTACT',
43
- 'ACCOUNTS_RECEIVABLE',
44
- 'SALES',
45
- 'CUSTOMER_SERVICE',
46
- 'SHIPPING_RECEIVING',
47
- 'OTHER',
48
- ];
45
+ export const ORG_CONTACTS = ['PRIMARY_CONTACT', 'ACCOUNTS_RECEIVABLE', 'SALES', 'CUSTOMER_SERVICE', 'SHIPPING_RECEIVING', 'OTHER'];
49
46
 
50
47
  // Compliance
51
48
 
@@ -0,0 +1,23 @@
1
+ // Custom organization page route constants
2
+
3
+ // Queries that a custom page route can use as its data source
4
+ export const PAGE_ROUTE_QUERY_ENUMS = ['LOG_ENTRIES', 'CHILD_ORGANIZATIONS'];
5
+
6
+ // Slugs that can never be used for custom page routes (single-character slugs are always rejected)
7
+ export const PAGE_ROUTE_RESERVED_SLUGS = [
8
+ 'workspaces',
9
+ 'workspace',
10
+ 'grids',
11
+ 'grid',
12
+ 'tables',
13
+ 'table',
14
+ 'workflows',
15
+ 'workflow',
16
+ 'billing',
17
+ 'inbox',
18
+ ];
19
+
20
+ export const PAGE_ROUTE_SLUG_MIN_LENGTH = 2;
21
+ export const PAGE_ROUTE_SLUG_MAX_LENGTH = 40;
22
+ export const PAGE_ROUTE_MAX_COLUMNS = 30;
23
+ export const PAGE_ROUTE_ICON_NAME_MAX_LENGTH = 80;
@@ -0,0 +1,30 @@
1
+ export const QR_CODE_LIMITS = {
2
+ maxTextBytes: 2_000,
3
+ nameLength: 120,
4
+ publicIdBytes: 16,
5
+ maxFields: 50,
6
+ fieldKeyLength: 80,
7
+ fieldDescriptionLength: 120,
8
+ fieldValueLength: 255,
9
+ displayNameLength: 120,
10
+ referenceIdLength: 40,
11
+ // Bounds for external scanned JSON envelopes, not editable QR field values.
12
+ maxJSONDepth: 16,
13
+ maxJSONNodes: 2_000,
14
+ } as const;
15
+
16
+ export const QR_CODE_PAYLOAD_VERSION = 3 as const;
17
+
18
+ export const QR_CODE_REFERENCE_TYPES = ['ORGANIZATION_SITE', 'CHILD_ORGANIZATION'] as const;
19
+
20
+ export const QR_CODE_REFERENCE_ID_PREFIXES = {
21
+ ORGANIZATION_SITE: 'site',
22
+ CHILD_ORGANIZATION: 'org',
23
+ } as const;
24
+
25
+ export const QR_CODE_APP_FIELD_REFERENCE_TYPES = {
26
+ siteLocation: 'ORGANIZATION_SITE',
27
+ childOrg: 'CHILD_ORGANIZATION',
28
+ } as const;
29
+
30
+ export const QR_CODE_RENDER_OPTIONS = { errorCorrectionLevel: 'M', margin: 4 } as const;
@@ -1,20 +1,132 @@
1
- export const SHEET_CELL_SOURCE_TYPE_ENUMS = [
2
- 'USER',
3
- 'REGION_GENERATED',
4
- 'REGION_OVERRIDE',
5
- ] as const;
1
+ export const SHEET_CELL_TEXT_WRAP_ENUMS = ['OVERFLOW', 'WRAP', 'CLIP'] as const;
6
2
 
7
- export const SHEET_REGION_TYPE_ENUMS = [
8
- 'DATA_TABLE',
9
- ] as const;
3
+ export const SHEET_CELL_TEXT_ALIGN_ENUMS = ['LEFT', 'CENTER', 'RIGHT'] as const;
4
+
5
+ export const SHEET_CELL_VERTICAL_ALIGN_ENUMS = ['TOP', 'MIDDLE', 'BOTTOM'] as const;
6
+
7
+ export const SHEET_STRUCTURE_OPERATION_ENUMS = ['INSERT_ROW_ABOVE', 'INSERT_COLUMN_LEFT', 'DELETE_ROW', 'DELETE_COLUMN'] as const;
8
+
9
+ export const SHEET_CELL_VALUE_TYPE_ENUMS = ['CELL_INT', 'CELL_FLOAT', 'CELL_DATE', 'CELL_BOOLEAN', 'CELL_TEXT'] as const;
10
10
 
11
- export const SHEET_REGION_CONFLICT_POLICY_ENUMS = [
12
- 'TRUNCATE_AT_FIRST_BLOCKER',
11
+ export const SHEET_CELL_NUMBER_FORMAT_TYPE_ENUMS = [
12
+ 'AUTOMATIC',
13
+ 'TEXT',
14
+ 'NUMBER',
15
+ 'PERCENT',
16
+ 'SCIENTIFIC',
17
+ 'ACCOUNTING',
18
+ 'FINANCIAL',
19
+ 'CURRENCY',
20
+ 'CURRENCY_ROUNDED',
21
+ 'DATE',
22
+ 'TIME',
23
+ 'DATE_TIME',
24
+ 'DURATION',
25
+ 'CUSTOM',
13
26
  ] as const;
14
27
 
15
- export const SHEET_DEFAULT_ROW_COUNT = 1000;
28
+ // Canonical Google-Sheets-style pattern per preset number format type; null
29
+ // types render raw (AUTOMATIC) or require an explicit saved pattern (CUSTOM).
30
+ // The "$" literal is substituted with the locale currency symbol at resolve time.
31
+ export const SHEET_NUMBER_FORMAT_PRESET_PATTERNS: Record<(typeof SHEET_CELL_NUMBER_FORMAT_TYPE_ENUMS)[number], string | null> = {
32
+ AUTOMATIC: null,
33
+ TEXT: '@',
34
+ NUMBER: '#,##0.00',
35
+ PERCENT: '0.00%',
36
+ SCIENTIFIC: '0.00E+00',
37
+ ACCOUNTING: '_("$"* #,##0.00_);_("$"* (#,##0.00);_("$"* "-"??_);_(@_)',
38
+ FINANCIAL: '#,##0.00;(#,##0.00)',
39
+ CURRENCY: '"$"#,##0.00',
40
+ CURRENCY_ROUNDED: '"$"#,##0',
41
+ DATE: 'm/d/yyyy',
42
+ TIME: 'h:mm:ss AM/PM',
43
+ DATE_TIME: 'm/d/yyyy h:mm:ss',
44
+ DURATION: '[h]:mm:ss',
45
+ CUSTOM: null,
46
+ };
47
+
48
+ export const GRID_ITEM_SORT_ENUMS = ['UPDATED_AT_DESC', 'TITLE_ASC'] as const;
49
+
50
+ export const SHEET_EXPORT_FORMAT_ENUMS = ['CSV', 'TSV', 'XLSX', 'PDF'] as const;
51
+
52
+ // Journaled sheet_tab_changes row kinds, in the order of the table's CHECK
53
+ // constraint. CELLS rows carry cell images, COMPUTED rows carry
54
+ // derived write-backs (computed fields only); every other kind is a
55
+ // presentation/structure row applied by its own payload shape.
56
+ export const SHEET_TAB_CHANGE_KIND_ENUMS = ['CELLS', 'COMPUTED', 'STRUCTURE', 'DESIGN'] as const;
57
+
58
+ export const GRID_ITEM_LIST_LIMIT = 1000;
59
+ export const SHEET_MAX_ROW_COUNT = 500;
60
+ // Largest column count a sheet can reach today: the server import parser caps
61
+ // imported worksheets at 256 columns (sheetOps-import-parse.ts maxColumns must
62
+ // stay in sync with this)
63
+ export const SHEET_MAX_COLUMN_COUNT = 256;
64
+
65
+ export const SHEET_DEFAULT_ROW_COUNT = SHEET_MAX_ROW_COUNT;
16
66
  export const SHEET_DEFAULT_COLUMN_COUNT = 26;
17
- export const SHEET_VIEWPORT_MAX_ROWS = 400;
18
- export const SHEET_VIEWPORT_MAX_COLUMNS = 100;
67
+ // Viewport clamps must cover the full sheet caps: the client fetches the whole
68
+ // sheet in one sheetView query and never refetches while scrolling, so any
69
+ // clamp below the sheet caps renders the overflow rows/columns permanently
70
+ // blank (rows 401-500 were blank when this was 400)
71
+ export const SHEET_VIEWPORT_MAX_ROWS = SHEET_MAX_ROW_COUNT;
72
+ export const SHEET_VIEWPORT_MAX_COLUMNS = SHEET_MAX_COLUMN_COUNT;
19
73
  export const SHEET_DEFAULT_COLUMN_WIDTH = 160;
20
- export const SHEET_DEFAULT_ROW_HEIGHT = 28;
74
+
75
+ // Maximum UTF-16 length stored or relayed for one editable Sheet cell value.
76
+ export const SHEET_CELL_TEXT_MAX_CHARS = 10_000;
77
+
78
+ // Maximum UTF-16 length stored or relayed for one Sheet cell note.
79
+ export const SHEET_CELL_NOTE_MAX_CHARS = 2_000;
80
+
81
+ // Hard cap for one complete Sheet realtime event encoded as UTF-8 JSON.
82
+ export const SHEET_REALTIME_RELAY_MAX_BYTES = 64 * 1024;
83
+
84
+ // One durable command read set stays bounded identically across browser,
85
+ // IndexedDB, GraphQL, REST beacon, and server transaction validation.
86
+ export const SHEET_COMMAND_PRECONDITION_MAX_SHEET_CELLS = 10_000;
87
+
88
+ // Version 5 accepts ordinary spreadsheet references and builtins. Stored ASTs
89
+ // from older versions must be recompiled from their authored formula text.
90
+ export const SHEET_FORMULA_LANGUAGE_VERSION = 5;
91
+ export const SHEET_FORMULA_MIN_STORED_AST_VERSION = 5;
92
+
93
+ // Builtins that also accept the legacy '@name(...)' spelling. Newer builtins
94
+ // never do, so '@index(...)', '@text(...)' and similar are unknown functions
95
+ export const SHEET_FORMULA_AT_PREFIX_BUILTIN_FUNCTION_NAMES = [
96
+ 'ABS',
97
+ 'AVERAGE',
98
+ 'CEILING',
99
+ 'COUNT',
100
+ 'COUNTA',
101
+ 'DATE',
102
+ 'DAY',
103
+ 'FLOOR',
104
+ 'IF',
105
+ 'IFERROR',
106
+ 'IFNA',
107
+ 'INCLUDES',
108
+ 'MAX',
109
+ 'MIN',
110
+ 'MOD',
111
+ 'MONTH',
112
+ 'NOW',
113
+ 'POWER',
114
+ 'ROUND',
115
+ 'ROUNDDOWN',
116
+ 'ROUNDUP',
117
+ 'REGEXMATCH',
118
+ 'SUM',
119
+ 'TODAY',
120
+ 'YEAR',
121
+ ] as const;
122
+
123
+ // Display tokens for formula error codes (Excel/Sheets spelling). Codes that
124
+ // are not listed display the generic '#ERROR!' token.
125
+ export const SHEET_FORMULA_ERROR_DISPLAY_BY_CODE: Readonly<Record<string, string>> = {
126
+ DIVIDE_BY_ZERO: '#DIV/0!',
127
+ INVALID_NUMBER: '#NUM!',
128
+ INVALID_REFERENCE: '#REF!',
129
+ INVALID_VALUE: '#VALUE!',
130
+ NOT_FOUND: '#N/A',
131
+ };
132
+ export const SHEET_FORMULA_ERROR_FALLBACK_DISPLAY = '#ERROR!';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Supported outbound SMS providers.
3
+ */
4
+ export const SMS_PROVIDER_ENUMS = ['TWILIO', 'TELNYX'] as const;
5
+
6
+ /**
7
+ * Durable outbound SMS lifecycle statuses.
8
+ */
9
+ export const SMS_OUTBOUND_STATUS_ENUMS = [
10
+ 'QUEUED',
11
+ 'PROCESSING',
12
+ 'SENT',
13
+ 'DELIVERED',
14
+ 'FAILED',
15
+ 'DELIVERY_UNKNOWN',
16
+ 'BOUNCED',
17
+ 'BLOCKED',
18
+ ] as const;
@@ -2,14 +2,14 @@ import type { IntegrationConnectionStatusEnum } from './integration.ts';
2
2
  import { INTEGRATION_CONNECTION_STATUSES } from './integration.ts';
3
3
 
4
4
  export const SQUARE_OAUTH_SCOPES = [
5
- 'MERCHANT_PROFILE_READ',
6
- 'PAYMENTS_READ',
7
- 'ORDERS_READ',
8
- 'ORDERS_WRITE',
9
- 'PAYMENTS_WRITE',
5
+ 'MERCHANT_PROFILE_READ',
6
+ 'PAYMENTS_READ',
7
+ 'ORDERS_READ',
8
+ 'ORDERS_WRITE',
9
+ 'PAYMENTS_WRITE',
10
10
  ] as const;
11
11
 
12
- export type SquareOAuthScope = typeof SQUARE_OAUTH_SCOPES[number];
12
+ export type SquareOAuthScope = (typeof SQUARE_OAUTH_SCOPES)[number];
13
13
 
14
14
  export const SQUARE_CONNECTION_STATUSES = INTEGRATION_CONNECTION_STATUSES;
15
15
 
@@ -1,12 +1,85 @@
1
-
1
+ // The storage_intents DB enum keeps retired labels; code never writes them.
2
2
  export const STORAGE_INTENT_ENUMS = [
3
- 'REPORT_SUBMISSION_FILE',
4
- 'CREATE_COMPLIANCE_DOCUMENT',
3
+ 'CAMPAIGN_HEADER_IMAGE',
4
+ 'CAMPAIGN_ELEMENT_IMAGE',
5
+ 'CREATE_COMPLIANCE_DOCUMENT',
6
+ 'IMPORT_SHEET_FILE',
7
+ 'EXPORT_SHEET_FILE',
8
+ 'AI_CHAT_FILE',
9
+ 'CAMPAIGN_GENERATION_FILE',
10
+ 'CAMPAIGN_TEMPLATE_PREVIEW',
11
+ 'AI_GENERATED_FILE',
12
+ 'LOG_FILE',
13
+ 'UNUSED',
14
+ 'STATIC',
15
+ ] as const;
16
+
17
+ // Public form header images are resized by the asset route before display.
18
+ export const CAMPAIGN_HEADER_IMAGE_CONTENT_TYPES = ['image/jpeg', 'image/png', 'image/webp'] as const;
19
+
20
+ export const CAMPAIGN_HEADER_IMAGE_MAX_FILE_SIZE = 10 * 1024 * 1024;
21
+
22
+ // Email/form content images may retain animation and use any browser image MIME.
23
+ export const CAMPAIGN_ELEMENT_IMAGE_MAX_FILE_SIZE = 20 * 1024 * 1024;
24
+
25
+ // How long AI-generated files (CSV exports) stay downloadable before the
26
+ // daily cron reaps the GCS object; storage_generated rows stay as history
27
+ export const GENERATED_FILE_RETENTION_DAYS = 180;
28
+
29
+ // Who may list/download a generated file inside its organization: everyone
30
+ // with generated-files access, or only the account that requested it
31
+ export const GENERATED_FILE_VISIBILITY_ENUMS = ['ORGANIZATION', 'REQUESTER'] as const;
32
+
33
+ // How many times one minted download link (web or SMS) may be redeemed
34
+ // before it stops serving bytes; expiry ends a link regardless of uses
35
+ export const GENERATED_FILE_DOWNLOAD_MAX_USES = 3;
36
+
37
+ // Maximum number of files that can be attached to a single AI chat message
38
+ export const MAX_AI_CHAT_ATTACHMENTS = 5;
39
+
40
+ // Maximum number of source files accepted by one public-form generation
41
+ export const MAX_PUBLIC_FORM_GENERATION_FILES = 10;
42
+
43
+ // File extensions the AI chat composer accepts. Images/documents become model files;
44
+ // audio/video use the shared media decoder before entering model context.
45
+ export const AI_CHAT_FILE_EXTENSIONS = [
46
+ // Images (input_image)
47
+ 'gif',
48
+ 'jpeg',
49
+ 'jpg',
50
+ 'png',
51
+ 'webp',
52
+ // Documents (input_file)
53
+ 'csv',
54
+ 'doc',
55
+ 'docx',
56
+ 'md',
57
+ 'pdf',
58
+ 'tsv',
59
+ 'txt',
60
+ 'xls',
61
+ 'xlsx',
62
+ // Audio recordings and videos (decoded into transcript and timestamped frames)
63
+ 'aac',
64
+ 'amr',
65
+ 'flac',
66
+ 'm4a',
67
+ 'mp3',
68
+ 'ogg',
69
+ 'opus',
70
+ 'wav',
71
+ '3gp',
72
+ '3gpp',
73
+ 'm4v',
74
+ 'mkv',
75
+ 'mov',
76
+ 'mp4',
77
+ 'webm',
5
78
  ];
6
79
 
7
80
  export const FILE_STATUS_ENUMS = [
8
- 'PENDING', // default value
9
- 'PROCESSING',
10
- 'COMPLETED',
11
- 'FAILED',
81
+ 'PENDING', // default value
82
+ 'PROCESSING',
83
+ 'COMPLETED',
84
+ 'FAILED',
12
85
  ] as const;
@@ -0,0 +1,82 @@
1
+ /*
2
+ * Version written into every durable usage-tracking envelope and ledger row.
3
+ */
4
+ export const USAGE_SCHEMA_VERSION = 1 as const;
5
+
6
+ /*
7
+ * Raw quantities measured at provider boundaries. Prices and allowances are
8
+ * intentionally not represented in this measurement contract.
9
+ */
10
+ export const USAGE_METERS = [
11
+ 'SMS_OUTBOUND_MESSAGES',
12
+ 'EMAIL_OUTBOUND_MESSAGES',
13
+ 'AI_INPUT_TOKENS',
14
+ 'AI_OUTPUT_TOKENS',
15
+ 'AI_AUDIO_SECONDS',
16
+ 'AI_MODERATION_REQUESTS',
17
+ ] as const;
18
+
19
+ /*
20
+ * Product paths that can cause organization-attributed provider usage.
21
+ */
22
+ export const USAGE_ORIGINS = [
23
+ 'AI_CHAT',
24
+ 'CHAT_SUMMARY',
25
+ 'WORKFLOW',
26
+ 'REMINDER',
27
+ 'EMAIL_ASSISTANT',
28
+ 'SMS_ASSISTANT',
29
+ 'TRANSLATION',
30
+ 'LOG_EMBEDDING',
31
+ 'VOICE_TRANSCRIPTION',
32
+ 'CSV_EXPORT',
33
+ 'CAMPAIGN',
34
+ 'FIELD_DOC',
35
+ 'FORM_SUBMISSION',
36
+ 'USER_ACTION',
37
+ 'SCHEDULE',
38
+ 'AGENT_NOTE',
39
+ ] as const;
40
+
41
+ /*
42
+ * Explicit reasons why a provider call is not organization-billable usage.
43
+ */
44
+ export const USAGE_EXCLUSION_REASONS = [
45
+ 'AUTHENTICATION',
46
+ 'DEVELOPMENT',
47
+ 'PLATFORM_OPERATION',
48
+ ] as const;
49
+
50
+ /*
51
+ * Provider boundaries supported by the first usage-tracking schema version.
52
+ */
53
+ export const USAGE_PROVIDERS = [
54
+ 'OPENAI',
55
+ 'POSTMARK',
56
+ 'TWILIO',
57
+ 'TELNYX',
58
+ ] as const;
59
+
60
+ /*
61
+ * Provider operation categories retained for usage reporting and rating.
62
+ */
63
+ export const USAGE_OPERATIONS = [
64
+ 'RESPONSE',
65
+ 'EMBEDDING',
66
+ 'TRANSCRIPTION',
67
+ 'MODERATION',
68
+ 'SMS_SEND',
69
+ 'EMAIL_SEND',
70
+ ] as const;
71
+
72
+ /*
73
+ * Stable source identity categories used with sourceId for idempotency.
74
+ */
75
+ export const USAGE_SOURCE_TYPES = [
76
+ 'OPENAI_RESPONSE',
77
+ 'OPENAI_EMBEDDING',
78
+ 'OPENAI_TRANSCRIPTION',
79
+ 'OPENAI_MODERATION',
80
+ 'OUTBOUND_SMS',
81
+ 'OUTBOUND_EMAIL',
82
+ ] as const;
@@ -0,0 +1,60 @@
1
+ /* Shared authoring limits for human-readable workflow descriptions. */
2
+ export const WORKFLOW_STEP_TEXT_MAX_LENGTH = 120;
3
+ export const WORKFLOW_STEP_ACTION_WORDS = [
4
+ 'Add',
5
+ 'Ask',
6
+ 'Assign',
7
+ 'Calculate',
8
+ 'Check',
9
+ 'Choose',
10
+ 'Collect',
11
+ 'Compare',
12
+ 'Complete',
13
+ 'Confirm',
14
+ 'Contact',
15
+ 'Copy',
16
+ 'Create',
17
+ 'Delete',
18
+ 'Determine',
19
+ 'Email',
20
+ 'Evaluate',
21
+ 'Fill',
22
+ 'Find',
23
+ 'Finish',
24
+ 'Flag',
25
+ 'Generate',
26
+ 'Identify',
27
+ 'Keep',
28
+ 'Link',
29
+ 'List',
30
+ 'Mark',
31
+ 'Match',
32
+ 'Notify',
33
+ 'Prepare',
34
+ 'Read',
35
+ 'Record',
36
+ 'Remind',
37
+ 'Remove',
38
+ 'Report',
39
+ 'Request',
40
+ 'Resolve',
41
+ 'Resend',
42
+ 'Review',
43
+ 'Save',
44
+ 'Schedule',
45
+ 'Select',
46
+ 'Send',
47
+ 'Set',
48
+ 'Skip',
49
+ 'Sort',
50
+ 'Stop',
51
+ 'Summarize',
52
+ 'Track',
53
+ 'Treat',
54
+ 'Update',
55
+ 'Use',
56
+ 'Validate',
57
+ 'Verify',
58
+ 'Wait',
59
+ ] as const;
60
+ export const WORKFLOW_STEP_TEXT_PATTERN = `^(?:${WORKFLOW_STEP_ACTION_WORDS.join('|')})\\b`;