@jsb188/mday 1.1.2

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 (202) hide show
  1. package/package.json +142 -0
  2. package/src/constants/agentMemory.ts +166 -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 +22 -0
  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 +146 -0
  14. package/src/constants/fieldDoc.ts +104 -0
  15. package/src/constants/graphqlReactivity.ts +196 -0
  16. package/src/constants/inboundContact.ts +8 -0
  17. package/src/constants/integration.ts +13 -0
  18. package/src/constants/log.ts +21 -0
  19. package/src/constants/logDisplay/README.md +88 -0
  20. package/src/constants/logDisplay/defaults.ts +39 -0
  21. package/src/constants/logDisplay/index.ts +27 -0
  22. package/src/constants/logDisplay/operations/arable.ts +16 -0
  23. package/src/constants/logDisplay/operations/farmersMarket.ts +10 -0
  24. package/src/constants/logDisplay/operations/foodManufacturing.ts +13 -0
  25. package/src/constants/logDisplay/shared/accounting.ts +13 -0
  26. package/src/constants/logDisplay/shared/interactions.ts +13 -0
  27. package/src/constants/logDisplay/shared/rackTemperatures.ts +42 -0
  28. package/src/constants/logTaxonomy.generated.ts +2199 -0
  29. package/src/constants/noteDoc.ts +77 -0
  30. package/src/constants/organization.ts +60 -0
  31. package/src/constants/pageRoute.ts +23 -0
  32. package/src/constants/qrCode.ts +30 -0
  33. package/src/constants/sheet.ts +132 -0
  34. package/src/constants/sms.ts +18 -0
  35. package/src/constants/square.ts +16 -0
  36. package/src/constants/storage.ts +85 -0
  37. package/src/constants/usage.ts +82 -0
  38. package/src/constants/workflowSteps.ts +60 -0
  39. package/src/schemas/editLogEntry.ts +879 -0
  40. package/src/schemas/inboundContact.ts +77 -0
  41. package/src/schemas/logsQuery.ts +93 -0
  42. package/src/types/account.d.ts +81 -0
  43. package/src/types/agentMemory.d.ts +100 -0
  44. package/src/types/agentNote.d.ts +441 -0
  45. package/src/types/billing.d.ts +537 -0
  46. package/src/types/campaign.d.ts +1533 -0
  47. package/src/types/contact.d.ts +15 -0
  48. package/src/types/csvExport.d.ts +213 -0
  49. package/src/types/dataAnalysis.d.ts +44 -0
  50. package/src/types/dataTable.d.ts +159 -0
  51. package/src/types/definitionElement.d.ts +35 -0
  52. package/src/types/docAccess.d.ts +96 -0
  53. package/src/types/dt.d.ts +257 -0
  54. package/src/types/email.d.ts +231 -0
  55. package/src/types/emailReplyReport.d.ts +76 -0
  56. package/src/types/fieldDoc.d.ts +702 -0
  57. package/src/types/fieldDocContract.d.ts +90 -0
  58. package/src/types/inboundContact.d.ts +65 -0
  59. package/src/types/integration.d.ts +42 -0
  60. package/src/types/log.d.ts +338 -0
  61. package/src/types/logDisplay.types.ts +85 -0
  62. package/src/types/organization.d.ts +350 -0
  63. package/src/types/pageRoute.d.ts +48 -0
  64. package/src/types/qrCode.d.ts +96 -0
  65. package/src/types/richText.d.ts +81 -0
  66. package/src/types/sheet.d.ts +847 -0
  67. package/src/types/sms.d.ts +38 -0
  68. package/src/types/storage.d.ts +481 -0
  69. package/src/types/usage.d.ts +106 -0
  70. package/src/types/workflow.d.ts +435 -0
  71. package/src/utils/agentMemory.ts +15 -0
  72. package/src/utils/agentNote.ts +850 -0
  73. package/src/utils/aiChat.ts +43 -0
  74. package/src/utils/aiChatWork.ts +64 -0
  75. package/src/utils/billing.ts +37 -0
  76. package/src/utils/campaign.ts +1173 -0
  77. package/src/utils/campaignAI.ts +72 -0
  78. package/src/utils/campaignAccess.ts +239 -0
  79. package/src/utils/campaignEmail.ts +601 -0
  80. package/src/utils/campaignEmailCompiler.ts +372 -0
  81. package/src/utils/campaignEmailImages.ts +60 -0
  82. package/src/utils/campaignEmailStyles.ts +544 -0
  83. package/src/utils/campaignLifecycle.ts +104 -0
  84. package/src/utils/campaignPreview.ts +285 -0
  85. package/src/utils/contact.ts +50 -0
  86. package/src/utils/csvExport.ts +19 -0
  87. package/src/utils/dataTable.ts +311 -0
  88. package/src/utils/dataTableFieldTypeRegistry.ts +106 -0
  89. package/src/utils/dataTableRelativeDate.ts +447 -0
  90. package/src/utils/definitionElement.ts +84 -0
  91. package/src/utils/docAccess.ts +383 -0
  92. package/src/utils/documentName.ts +53 -0
  93. package/src/utils/email.ts +379 -0
  94. package/src/utils/emailReplyReport.test.ts +187 -0
  95. package/src/utils/emailReplyReport.ts +143 -0
  96. package/src/utils/fieldDoc.ts +157 -0
  97. package/src/utils/fieldDocAnswers.ts +128 -0
  98. package/src/utils/fieldDocDefaults.ts +36 -0
  99. package/src/utils/fieldDocProgram.ts +36 -0
  100. package/src/utils/fieldDocSummary.ts +30 -0
  101. package/src/utils/log.ts +357 -0
  102. package/src/utils/logDisplay.helpers.ts +177 -0
  103. package/src/utils/logDisplay.ts +87 -0
  104. package/src/utils/logRegistryValue.ts +90 -0
  105. package/src/utils/logStoreRead.ts +262 -0
  106. package/src/utils/logTaxonomy.helpers.ts +17 -0
  107. package/src/utils/logTaxonomy.ts +76 -0
  108. package/src/utils/logTaxonomyDisplay.ts +395 -0
  109. package/src/utils/noteDoc.ts +609 -0
  110. package/src/utils/organization.ts +669 -0
  111. package/src/utils/pageRoute.ts +71 -0
  112. package/src/utils/qrCode.helpers.ts +189 -0
  113. package/src/utils/qrCode.test.ts +519 -0
  114. package/src/utils/qrCode.ts +273 -0
  115. package/src/utils/richTextHTML.ts +385 -0
  116. package/src/utils/sheet.ts +262 -0
  117. package/src/utils/sheetAxisMove.ts +616 -0
  118. package/src/utils/sheetBootstrap.ts +1402 -0
  119. package/src/utils/sheetCellLiteral.ts +101 -0
  120. package/src/utils/sheetCommand.ts +358 -0
  121. package/src/utils/sheetDesign.ts +705 -0
  122. package/src/utils/sheetExport.ts +186 -0
  123. package/src/utils/sheetFeatureReference.ts +183 -0
  124. package/src/utils/sheetFormulaArgs.ts +168 -0
  125. package/src/utils/sheetFormulaCompile.ts +475 -0
  126. package/src/utils/sheetFormulaConditionalAggregate.ts +254 -0
  127. package/src/utils/sheetFormulaCriteria.ts +656 -0
  128. package/src/utils/sheetFormulaDate.ts +444 -0
  129. package/src/utils/sheetFormulaEvaluation.ts +899 -0
  130. package/src/utils/sheetFormulaEvaluator.ts +997 -0
  131. package/src/utils/sheetFormulaFunctionHandlers.ts +403 -0
  132. package/src/utils/sheetFormulaLogical.ts +116 -0
  133. package/src/utils/sheetFormulaLookup.ts +488 -0
  134. package/src/utils/sheetFormulaMath.ts +48 -0
  135. package/src/utils/sheetFormulaParser.ts +729 -0
  136. package/src/utils/sheetFormulaRange.ts +330 -0
  137. package/src/utils/sheetFormulaReference.ts +703 -0
  138. package/src/utils/sheetFormulaReferenceAggregates.ts +313 -0
  139. package/src/utils/sheetFormulaReferenceDates.ts +237 -0
  140. package/src/utils/sheetFormulaReferenceLogical.ts +330 -0
  141. package/src/utils/sheetFormulaReferenceLookup.ts +341 -0
  142. package/src/utils/sheetFormulaReferenceMath.ts +95 -0
  143. package/src/utils/sheetFormulaReferenceRewrite.ts +220 -0
  144. package/src/utils/sheetFormulaReferenceText.ts +462 -0
  145. package/src/utils/sheetFormulaSyntax.ts +1027 -0
  146. package/src/utils/sheetFormulaText.ts +430 -0
  147. package/src/utils/sheetJournal.ts +200 -0
  148. package/src/utils/sheetNumberFormat.ts +1012 -0
  149. package/src/utils/sheetPreview.ts +68 -0
  150. package/src/utils/sheetSequence.ts +118 -0
  151. package/src/utils/sheetSnapshot.ts +739 -0
  152. package/src/utils/sheetStructureEdit.ts +914 -0
  153. package/src/utils/sheetStructureReferences.ts +389 -0
  154. package/src/utils/square.ts +32 -0
  155. package/src/utils/storage.ts +198 -0
  156. package/src/utils/table-route.ts +262 -0
  157. package/src/utils/time.ts +12 -0
  158. package/src/utils/workflow.ts +506 -0
  159. package/src/utils/workflowLogFingerprint.ts +302 -0
  160. package/src/utils/workflowLogRevisionSnapshot.ts +424 -0
  161. package/src/utils/workflowProgress.ts +280 -0
  162. package/src/utils/workflowTriggers.ts +61 -0
  163. package/tests/agentNote.test.ts +395 -0
  164. package/tests/campaignAI.test.ts +119 -0
  165. package/tests/campaignAccess.test.ts +239 -0
  166. package/tests/campaignEmail.test.ts +441 -0
  167. package/tests/campaignLifecycle.test.ts +134 -0
  168. package/tests/campaignPublication.test.ts +309 -0
  169. package/tests/dataTableFieldTypeRegistry.test.ts +111 -0
  170. package/tests/dataTableRelativeDate.test.ts +412 -0
  171. package/tests/docAccess.test.ts +525 -0
  172. package/tests/editLogEntry.test.ts +112 -0
  173. package/tests/email.test.ts +39 -0
  174. package/tests/fieldDocProgram.test.ts +114 -0
  175. package/tests/logDisplay.fixtures.ts +67 -0
  176. package/tests/logDisplay.test.ts +227 -0
  177. package/tests/noteDoc.test.ts +514 -0
  178. package/tests/richTextHTML.test.ts +185 -0
  179. package/tests/sheetAxisMove.test.ts +352 -0
  180. package/tests/sheetBootstrap.test.ts +1967 -0
  181. package/tests/sheetFeatureReference.test.ts +22 -0
  182. package/tests/sheetFormulaCriteria.test.ts +269 -0
  183. package/tests/sheetFormulaEvaluator.test.ts +468 -0
  184. package/tests/sheetFormulaFunctions.test.ts +538 -0
  185. package/tests/sheetFormulaLanguage.test.ts +361 -0
  186. package/tests/sheetFormulaParity.fixtures.ts +872 -0
  187. package/tests/sheetFormulaParity.test.ts +188 -0
  188. package/tests/sheetFormulaRange.test.ts +167 -0
  189. package/tests/sheetFormulaReference.test.ts +78 -0
  190. package/tests/sheetFormulaReferenceRewrite.test.ts +117 -0
  191. package/tests/sheetFormulaTextDate.test.ts +512 -0
  192. package/tests/sheetSequence.test.ts +22 -0
  193. package/tests/sheetSnapshot.test.ts +134 -0
  194. package/tests/sheetStructureEdit.test.ts +537 -0
  195. package/tests/sheetStructureReferences.test.ts +589 -0
  196. package/tests/workflowLifecycleStatus.test.ts +60 -0
  197. package/tests/workflowLogFingerprint.test.ts +203 -0
  198. package/tests/workflowLogRevisionSnapshot.test.ts +96 -0
  199. package/tests/workflowProgress.test.ts +180 -0
  200. package/tests/workflowTriggers.test.ts +29 -0
  201. package/tsconfig.json +12 -0
  202. package/vitest.config.ts +8 -0
@@ -0,0 +1,90 @@
1
+ /* Published form semantics and current answers. Answers have no revision history. */
2
+ export type FieldDocScalarAnswerType =
3
+ | 'TEXT'
4
+ | 'NUMBER'
5
+ | 'INTEGER'
6
+ | 'BOOLEAN'
7
+ | 'DATE'
8
+ | 'TIME'
9
+ | 'CHOICE'
10
+ | 'MULTI_CHOICE'
11
+ | 'MEASUREMENT';
12
+ export type FieldDocAnswerType = FieldDocScalarAnswerType | 'TABLE';
13
+ export type FieldDocAnswerState = 'UNANSWERED' | 'PROPOSED' | 'ANSWERED' | 'NOT_APPLICABLE' | 'NEEDS_REVIEW';
14
+ export type FieldDocScalarValue = string | number | boolean | string[] | { amount: number; unit: string } | null;
15
+ export type FieldDocValue = FieldDocScalarValue | FieldDocTableValue;
16
+
17
+ export interface FieldDocScalarAnswerRules {
18
+ type: FieldDocScalarAnswerType;
19
+ defaultValue?: FieldDocScalarValue;
20
+ militaryTime?: boolean;
21
+ trueLabel?: string;
22
+ falseLabel?: string;
23
+ allowOther?: boolean;
24
+ unit?: string;
25
+ allowedUnits?: string[];
26
+ min?: number;
27
+ max?: number;
28
+ maxLength?: number;
29
+ acceptableRange?: { min?: number; max?: number; severity: 'WARNING' | 'FAIL' };
30
+ optionGrades?: Record<string, 'PASS' | 'WARNING' | 'FAIL'>;
31
+ }
32
+
33
+ export interface FieldDocTableColumn {
34
+ key: string;
35
+ label: string;
36
+ required?: boolean;
37
+ options?: string[];
38
+ answer: FieldDocScalarAnswerRules;
39
+ }
40
+
41
+ export interface FieldDocTableAnswerRules {
42
+ type: 'TABLE';
43
+ columns: FieldDocTableColumn[];
44
+ defaultValue?: FieldDocTableValue | null;
45
+ }
46
+
47
+ export type FieldDocAnswerRules = FieldDocScalarAnswerRules | FieldDocTableAnswerRules;
48
+
49
+ export interface FieldDocTableRow {
50
+ id: string;
51
+ cells: Record<string, FieldDocScalarValue>;
52
+ }
53
+
54
+ export interface FieldDocTableValue {
55
+ rows: FieldDocTableRow[];
56
+ }
57
+
58
+ export interface FieldDocEvidence {
59
+ logId: string;
60
+ revisionNumber: number | null;
61
+ }
62
+
63
+ export interface FieldDocIssue {
64
+ id: string;
65
+ severity: 'WARNING' | 'FAIL';
66
+ status: 'OPEN' | 'RESOLVED';
67
+ description: string;
68
+ correctiveAction?: string;
69
+ resolution?: string;
70
+ evidence: FieldDocEvidence[];
71
+ resolutionEvidence?: FieldDocEvidence[];
72
+ }
73
+
74
+ export interface FieldDocAnswer {
75
+ value: FieldDocValue;
76
+ state: FieldDocAnswerState;
77
+ reason?: string;
78
+ note?: string;
79
+ evidence: FieldDocEvidence[];
80
+ issues: FieldDocIssue[];
81
+ confirmation?: { logId: string; revisionNumber: number; quote: string; valueHash: string };
82
+ originalValue?: { amount: number; unit: string } | FieldDocTableValue;
83
+ }
84
+
85
+ export interface FieldDocAnswers {
86
+ schemaVersion: 2;
87
+ // Submission matching metadata; never a question answer or a unique key.
88
+ __identifierHint?: string;
89
+ questions: Record<string, FieldDocAnswer>;
90
+ }
@@ -0,0 +1,65 @@
1
+ import type { OrganizationData } from './organization.d.ts';
2
+ import type { INBOUND_CONTACT_SORT_ENUMS } from '../constants/inboundContact.ts';
3
+
4
+ export type InboundContactsSortEnum =
5
+ (typeof INBOUND_CONTACT_SORT_ENUMS)[number];
6
+
7
+ export interface InboundContactsQueryArgs {
8
+ query?: string | null;
9
+ emailEligible?: boolean | null;
10
+ sort?: InboundContactsSortEnum | null;
11
+ }
12
+
13
+ /**
14
+ * Inbound contact relationship to one organization.
15
+ */
16
+ export interface InboundContactOrgData {
17
+ __table: 'inbound_contact_orgs';
18
+ inboundContactId: bigint;
19
+ organizationId: bigint;
20
+ organization?: OrganizationData | null;
21
+ }
22
+
23
+ /**
24
+ * Inbound contact memory record owned by one organization.
25
+ */
26
+ export interface InboundContactData {
27
+ __table: 'inbound_contacts';
28
+ id: bigint;
29
+ organizationId: bigint;
30
+ personName: string | null;
31
+ email: string | null;
32
+ phone: string | null;
33
+ memory: string | null;
34
+ orgs?: InboundContactOrgData[] | null;
35
+ createdAt: Date;
36
+ updatedAt: Date;
37
+ }
38
+
39
+ /**
40
+ * GraphQL inbound contact relationship to one organization.
41
+ */
42
+ export interface InboundContactOrgGQL {
43
+ organizationId: string;
44
+ name: string | null;
45
+ }
46
+
47
+ /**
48
+ * GraphQL inbound contact memory record.
49
+ */
50
+ export interface InboundContactGQL {
51
+ __deleted?: boolean;
52
+
53
+ id: string;
54
+ organizationId: string;
55
+ cursor: string;
56
+ personName: string | null;
57
+ email: string | null;
58
+ emailEligible: boolean;
59
+ campaignEmailSuppressed: boolean;
60
+ phone: string | null;
61
+ memory: string | null;
62
+ associated?: InboundContactOrgGQL[] | null;
63
+ createdAt: string;
64
+ updatedAt: string;
65
+ }
@@ -0,0 +1,42 @@
1
+ import type { IntegrationConnectionStatusEnum } from '../constants/integration.ts';
2
+ import type { SquareConnectionCapabilities } from '../utils/square.ts';
3
+
4
+ /**
5
+ * Integration connection database object.
6
+ */
7
+ export interface IntegrationConnectionData {
8
+ __table: 'integrations';
9
+ id: bigint;
10
+ organizationId: bigint;
11
+ provider: 'SQUARE';
12
+ externalAccountId: string | null;
13
+ scopes: string[];
14
+ status: IntegrationConnectionStatusEnum;
15
+ expiresAt: Date | null;
16
+ refreshTokenExpiresAt: Date | null;
17
+ lastSyncedAt: Date | null;
18
+ lastTokenRefreshAt: Date | null;
19
+ lastError: string | null;
20
+ createdAt: Date;
21
+ updatedAt: Date;
22
+ }
23
+
24
+ /**
25
+ * GraphQL data for integration connection types.
26
+ */
27
+ export interface IntegrationConnectionGQL {
28
+ id: string;
29
+ organizationId: string;
30
+ provider: 'SQUARE';
31
+ externalAccountId: string | null;
32
+ scopes: string[];
33
+ status: IntegrationConnectionStatusEnum;
34
+ expiresAt: string | null;
35
+ refreshTokenExpiresAt: string | null;
36
+ lastSyncedAt: string | null;
37
+ lastTokenRefreshAt: string | null;
38
+ lastError: string | null;
39
+ capabilities: SquareConnectionCapabilities;
40
+ createdAt: string | null;
41
+ updatedAt: string | null;
42
+ }
@@ -0,0 +1,338 @@
1
+ import { REQUEST_SOURCE_ENUMS } from '@jsb188/app/constants/agent.ts';
2
+ import type { LabelAndValue } from '@jsb188/app/types/other.d.ts';
3
+ import { LOG_SORT_ENUMS } from '../constants/log.ts';
4
+ import type { OrganizationOperationEnum } from '../types/organization.d.ts';
5
+ import type { AccountObj } from './account.d.ts';
6
+ import type { AppliedMemoriesSnapshot } from './agentMemory.d.ts';
7
+ import type { StorageGQL } from './storage.d.ts';
8
+
9
+ /**
10
+ * Enums
11
+ */
12
+
13
+ export type LogContentName = 'log' | 'invoice' | 'receipt'; // For UI visuals, client-side only
14
+ export type LogSortEnum = (typeof LOG_SORT_ENUMS)[number];
15
+ export type RequestSourceEnum = (typeof REQUEST_SOURCE_ENUMS)[number];
16
+
17
+ // Activity and group keys are registry data and can be extended per organization.
18
+ export type LogTypeEnum = string;
19
+ export type LogActivityEnum = string;
20
+
21
+ /**
22
+ * Structured text translated for one ordered log item.
23
+ */
24
+
25
+ export interface LogTranslationValueText {
26
+ ordinal: number;
27
+ label: string;
28
+ }
29
+
30
+ /**
31
+ * Structured text translated for one keyed log field.
32
+ */
33
+
34
+ export interface LogTranslationFieldText {
35
+ key: string;
36
+ textValue: string;
37
+ }
38
+
39
+ /**
40
+ * One locale-specific translation of the current original log text.
41
+ */
42
+
43
+ export interface LogTranslationLocaleText {
44
+ translatedAt: string;
45
+ summary: string | null;
46
+ notes: string | null;
47
+ item: string | null;
48
+ values: LogTranslationValueText[];
49
+ fields: LogTranslationFieldText[];
50
+ searchText: string;
51
+ }
52
+
53
+ /**
54
+ * Stored JSONB translation bundle keyed by target language code.
55
+ */
56
+
57
+ export interface LogTranslationBundle {
58
+ version: 1;
59
+ sourceHash: string;
60
+ originalLanguage: string;
61
+ // Target languages checked by the detector that required no translated payload.
62
+ noTranslationLanguages: string[];
63
+ texts: Record<string, LogTranslationLocaleText>;
64
+ }
65
+
66
+ /**
67
+ * GraphQL representation of one locale-specific translation.
68
+ */
69
+
70
+ export interface LogTranslationLocaleTextGQL extends LogTranslationLocaleText {
71
+ language: string;
72
+ }
73
+
74
+ /**
75
+ * GraphQL representation of a stored translation bundle.
76
+ */
77
+
78
+ export interface LogTranslationBundleGQL extends Omit<LogTranslationBundle, 'noTranslationLanguages' | 'texts'> {
79
+ texts: LogTranslationLocaleTextGQL[];
80
+ }
81
+
82
+ /**
83
+ * Read-only log text selected for a viewer's display language.
84
+ */
85
+
86
+ export interface LogDisplayText {
87
+ summary: string;
88
+ notes: string | null;
89
+ item: string | null;
90
+ values: LabelAndValue[] | null;
91
+ fields: LogEntryDetailsFieldGQL[] | null;
92
+ }
93
+
94
+ /**
95
+ * Canonical translatable source payload used for hashing and LLM input.
96
+ */
97
+
98
+ export interface LogTranslationSourceTexts {
99
+ summary: string | null;
100
+ notes: string | null;
101
+ item: string | null;
102
+ values: LogTranslationValueText[];
103
+ fields: LogTranslationFieldText[];
104
+ }
105
+
106
+ /**
107
+ * Shared log details fields
108
+ */
109
+
110
+ export interface LogDetailsBase {
111
+ id: number | bigint;
112
+ childOrg?: {
113
+ id: number | bigint;
114
+ name: string;
115
+ operation?: OrganizationOperationEnum | null;
116
+ };
117
+ childOrgId?: number | bigint | null;
118
+ fieldDocId?: number | bigint | null;
119
+ fieldDocSubmissionId?: number | bigint | null;
120
+ siteId?: number | bigint | null;
121
+ site?: {
122
+ id: number | bigint;
123
+ name: string;
124
+ };
125
+ location?: {
126
+ name: string;
127
+ } | null;
128
+ notes: string | null;
129
+ translation: LogTranslationBundle | null;
130
+ }
131
+
132
+ // All operations use one registry-driven details shape.
133
+ export interface LogEntryDetailsData extends LogDetailsBase {
134
+ __table: 'log_entry_details';
135
+ activity: string;
136
+ logType?: string | null;
137
+ fields?: LogEntryDetailsFieldGQL[] | null;
138
+ metadata?: Record<string, any> | null;
139
+ }
140
+
141
+ // One typed field-def value on a registry-driven operation's log
142
+ export interface LogEntryDetailsFieldGQL {
143
+ key: string;
144
+ fieldType: string | null;
145
+ textValue: string | null;
146
+ numberValue: number | null;
147
+ booleanValue: boolean | null;
148
+ dateValue: string | null;
149
+ datetimeValue: string | null;
150
+ unit: string | null;
151
+ }
152
+
153
+ // One typed field-def value sent when editing a registry-driven log
154
+ export interface LogEntryDetailsFieldInput {
155
+ key: string;
156
+ textValue?: string | null;
157
+ numberValue?: number | null;
158
+ booleanValue?: boolean | null;
159
+ dateValue?: string | null;
160
+ datetimeValue?: string | null;
161
+ unit?: string | null;
162
+ clear?: boolean | null;
163
+ }
164
+
165
+ // Details for registry-driven operations; type/activity are registry keys
166
+ export interface LogEntryDetailsGQL {
167
+ __typename: 'LogEntryDetails';
168
+
169
+ id: string;
170
+ type: string | null;
171
+ activity: string;
172
+ notes: string;
173
+
174
+ item: string | null;
175
+ quantity: number | null;
176
+ unit: string | null;
177
+ price: number | null;
178
+ values: LabelAndValue[] | null;
179
+ fields: LogEntryDetailsFieldGQL[] | null;
180
+
181
+ otherParty: string | null;
182
+ referenceNumber: string | null;
183
+ fieldLocation: string | null;
184
+ voided: boolean | null;
185
+ }
186
+
187
+ // Log taxonomy carried by the existing organization bootstrap (registry rows)
188
+ export interface LogTaxonomyGroupGQL {
189
+ key: string;
190
+ label: string | null;
191
+ ordinal: number | null;
192
+ requiredFields: string[] | null;
193
+ orRequiredFields: string[] | null;
194
+ }
195
+
196
+ export interface LogTaxonomyActivityGQL {
197
+ systemOnly?: boolean | null;
198
+ key: string;
199
+ groupKey: string | null;
200
+ agentText: string | null;
201
+ ordinal: number | null;
202
+ requiredFields: string[] | null;
203
+ orRequiredFields: string[] | null;
204
+ }
205
+
206
+ export interface LogTaxonomyFieldDefGQL {
207
+ key: string;
208
+ fieldType: string;
209
+ required: boolean | null;
210
+ ordinal: number | null;
211
+ agentHint: string | null;
212
+ options: string[] | null;
213
+ allowedUnits: string[] | null;
214
+ includedActivityKeys?: string[] | null;
215
+ excludedActivityKeys?: string[] | null;
216
+ groupKey: string | null;
217
+ activityKey: string | null;
218
+ }
219
+
220
+ export interface LogTaxonomyGQL {
221
+ operation: string;
222
+ groups: LogTaxonomyGroupGQL[];
223
+ activities: LogTaxonomyActivityGQL[];
224
+ fieldDefs: LogTaxonomyFieldDefGQL[];
225
+ }
226
+
227
+ /**
228
+ * GQL data interfaces
229
+ */
230
+
231
+ export interface LogEntryGQL {
232
+ __typename: string;
233
+ __deleted?: boolean;
234
+
235
+ id: string;
236
+ cursor?: string | null;
237
+ accountId: string;
238
+ organizationId: string;
239
+ childOrgId: string | null;
240
+ childOrgName: string | null;
241
+ inboundContactId: string | null;
242
+ inboundContactName: string | null;
243
+ inboundContactEmail?: string | null;
244
+ inboundContactPhone?: string | null;
245
+ fieldDocId: string | null;
246
+ fieldDocSubmissionId: string | null;
247
+ siteId: string | null;
248
+ siteName?: string | null;
249
+ location: string | null;
250
+ accountPersonName?: string | null;
251
+ details: LogEntryDetailsGQL;
252
+ summary: string;
253
+ source?: RequestSourceEnum | null;
254
+ confidence?: number | null;
255
+ originalMessage?: string | null;
256
+ flagColor?: string | null;
257
+ translation: LogTranslationBundleGQL | null;
258
+
259
+ account: any;
260
+ files: StorageGQL[];
261
+
262
+ date: string; // ISO date string
263
+ createdAt: string; // ISO date string
264
+ updatedAt: string; // ISO date string
265
+ }
266
+
267
+ export interface LogEntryInsertObj {
268
+ id?: number | bigint; // Only for edits
269
+ accountId: number | bigint | null;
270
+ organizationId: number | bigint;
271
+ childOrgId?: number | bigint | null;
272
+ inboundContactId?: number | bigint | null;
273
+ emailId?: number | bigint | null;
274
+ fieldDocId?: number | bigint | null;
275
+ fieldDocSubmissionId?: number | bigint | null;
276
+ siteId?: number | bigint | null;
277
+ summary: string;
278
+ source?: RequestSourceEnum | null;
279
+ confidence?: number | null;
280
+ originalMessage?: string | null;
281
+ appliedMemories?: AppliedMemoriesSnapshot | null;
282
+ details: any;
283
+ date: Date;
284
+ }
285
+
286
+ export interface LogEntryData {
287
+ revisionNumber?: number;
288
+ __table: 'logs';
289
+ id: number | bigint;
290
+ accountId: number | bigint;
291
+ organizationId: number | bigint;
292
+ childOrgId?: number | bigint | null;
293
+ inboundContactId?: number | bigint | null;
294
+ emailId?: number | bigint | null;
295
+ inboundContact?: {
296
+ id: number | bigint;
297
+ personName?: string | null;
298
+ } | null;
299
+ childOrg?: {
300
+ id: number | bigint;
301
+ name: string;
302
+ operation?: OrganizationOperationEnum | null;
303
+ } | null;
304
+ fieldDocId?: number | bigint | null;
305
+ fieldDocSubmissionId?: number | bigint | null;
306
+ siteId?: number | bigint | null;
307
+ summary: string;
308
+ source?: RequestSourceEnum | null;
309
+ confidence?: number | null;
310
+ originalMessage?: string | null;
311
+ translation?: LogTranslationBundle | null;
312
+ location?: {
313
+ name: string;
314
+ } | null;
315
+ distance?: number; // For vector search
316
+ details: LogEntryDetailsData;
317
+ date: Date;
318
+ createdAt: Date;
319
+ updatedAt: Date;
320
+
321
+ // This is for outputs, but will never be set for inserts
322
+ account?: AccountObj;
323
+ }
324
+
325
+ /**
326
+ * Filters for search for client-side
327
+ */
328
+
329
+ export interface FilterLogEntriesArgs {
330
+ accountId?: string | null; // Account ID to filter logs by account
331
+ siteId?: string | number | bigint | null; // Site ID to filter logs by site
332
+ preset?: 'WEEKS_5' | null;
333
+ types?: string[] | null;
334
+ activities?: string[] | null;
335
+ startDate?: string | null; // CalDate, with dashes (YYYY-MM-DD)
336
+ endDate?: string | null; // CalDate, with dashes (YYYY-MM-DD)
337
+ query?: string | null;
338
+ }
@@ -0,0 +1,85 @@
1
+ import type { LogEntryGQL, LogTaxonomyGQL } from './log.d.ts';
2
+
3
+ // Custom registry fields always use field:KEY, even when KEY matches an envelope field.
4
+ export type LogDisplayFieldKey =
5
+ | 'date'
6
+ | 'logType'
7
+ | 'activity'
8
+ | 'interactionType'
9
+ | 'childOrgName'
10
+ | 'item'
11
+ | 'quantity'
12
+ | 'price'
13
+ | 'values'
14
+ | 'otherParty'
15
+ | 'referenceNumber'
16
+ | 'voided'
17
+ | 'location'
18
+ | `field:${string}`;
19
+
20
+ export type LogDisplayLayout = 'metadata' | 'purchaseInvoice' | 'saleInvoice' | 'receipt';
21
+
22
+ export interface LogDisplayFieldDefinition {
23
+ labelKey?: string | null;
24
+ formatter?: 'auto' | 'temperature' | 'currency' | null;
25
+ unitField?: LogDisplayFieldKey | null;
26
+ hidden?: boolean;
27
+ span?: 'half' | 'full';
28
+ empty?: 'hide' | 'show';
29
+ }
30
+
31
+ export interface LogDisplayDefinition {
32
+ layout?: LogDisplayLayout;
33
+ order?: readonly (LogDisplayFieldKey | '*')[];
34
+ fields?: Partial<Record<LogDisplayFieldKey, LogDisplayFieldDefinition>>;
35
+ }
36
+
37
+ export interface LogDisplayScope extends LogDisplayDefinition {
38
+ // Ordered, non-recursive shared profiles; missing names are configuration errors.
39
+ profiles?: readonly string[];
40
+ }
41
+
42
+ export interface LogOperationDisplay {
43
+ defaults?: LogDisplayScope;
44
+ groups?: Readonly<Record<string, LogDisplayScope>>;
45
+ activities?: Readonly<Record<string, LogDisplayScope>>;
46
+ }
47
+
48
+ export interface LogDisplayRegistry {
49
+ defaults: LogDisplayDefinition;
50
+ shared: Readonly<Record<string, LogDisplayDefinition>>;
51
+ operations: Readonly<Record<string, LogOperationDisplay>>;
52
+ }
53
+
54
+ export interface ResolvedLogDisplayDefinition {
55
+ layout: LogDisplayLayout;
56
+ order: readonly (LogDisplayFieldKey | '*')[];
57
+ fields: Partial<Record<LogDisplayFieldKey, LogDisplayFieldDefinition>>;
58
+ }
59
+
60
+ export interface LogDisplayContext {
61
+ operation?: string | null;
62
+ groupKey?: string | null;
63
+ activityKey?: string | null;
64
+ taxonomy?: LogTaxonomyGQL | null;
65
+ }
66
+
67
+ export interface LogDisplayRow {
68
+ key: LogDisplayFieldKey;
69
+ label: string;
70
+ value: string;
71
+ span: 'half' | 'full';
72
+ badgeGroupKey?: string;
73
+ }
74
+
75
+ export interface LogEntryDisplay {
76
+ layout: LogDisplayLayout;
77
+ rows: LogDisplayRow[];
78
+ }
79
+
80
+ export interface LogDisplayInput {
81
+ logEntry: LogEntryGQL;
82
+ operation?: string | null;
83
+ taxonomy?: LogTaxonomyGQL | null;
84
+ timeZone: string | null;
85
+ }