@jsb188/mday 1.1.8 → 1.1.10

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 (45) hide show
  1. package/package.json +39 -20
  2. package/src/constants/dataTable.ts +22 -0
  3. package/src/constants/email.ts +28 -0
  4. package/src/constants/inboundContact.ts +8 -0
  5. package/src/constants/integration.ts +14 -0
  6. package/src/constants/log-activityTexts.ts +54 -28
  7. package/src/constants/log.ts +82 -38
  8. package/src/constants/organization.ts +11 -2
  9. package/src/constants/product.ts +9 -33
  10. package/src/constants/report.ts +29 -10
  11. package/src/constants/sheet.ts +20 -0
  12. package/src/constants/square.ts +16 -0
  13. package/src/constants/storage.ts +12 -0
  14. package/src/schemas/editLogEntry.ts +90 -44
  15. package/src/schemas/inboundContact.ts +72 -0
  16. package/src/schemas/logsQuery.ts +7 -272
  17. package/src/schemas/organization.ts +11 -174
  18. package/src/schemas/productsQuery.ts +2 -94
  19. package/src/schemas/reportsQuery.ts +8 -95
  20. package/src/types/account.d.ts +78 -0
  21. package/src/types/dataTable.d.ts +447 -0
  22. package/src/types/email.d.ts +71 -0
  23. package/src/types/inboundContact.d.ts +56 -0
  24. package/src/types/integration.d.ts +42 -0
  25. package/src/types/log.d.ts +289 -178
  26. package/src/types/organization.d.ts +106 -50
  27. package/src/types/product.d.ts +7 -96
  28. package/src/types/report.d.ts +239 -152
  29. package/src/types/sheet.d.ts +298 -0
  30. package/src/types/storage.d.ts +161 -0
  31. package/src/types/workflow.d.ts +174 -0
  32. package/src/utils/dataTable.ts +834 -0
  33. package/src/utils/email.ts +113 -0
  34. package/src/utils/log.ts +30 -628
  35. package/src/utils/organization.ts +227 -44
  36. package/src/utils/product-calEvent.ts +7 -60
  37. package/src/utils/report.ts +158 -0
  38. package/src/utils/sheet.ts +170 -0
  39. package/src/utils/square.ts +22 -0
  40. package/src/utils/table-route.ts +146 -0
  41. package/src/utils/workflow.ts +212 -0
  42. package/tsconfig.json +12 -0
  43. package/src/schemas/childOrganizationsQuery.ts +0 -44
  44. package/src/types/action.d.ts +0 -42
  45. package/src/utils/route-helpers.ts +0 -583
@@ -1,203 +1,290 @@
1
- import { REPORT_SORT_OPTS, REPORT_TYPES, REPORT_ROW_PRESETS } from '../constants/report';
2
- import type { StorageData, StorageGQL } from '@jsb188/app/types/storage.d';
1
+ import {
2
+ REPORT_FREQUENCY_ENUMS,
3
+ REPORT_ROW_PRESETS,
4
+ REPORT_SORT_OPTS,
5
+ REPORT_STATUS_ENUMS,
6
+ } from "../constants/report.ts";
7
+ import type {
8
+ OrganizationData,
9
+ OrganizationSiteData,
10
+ } from "./organization.d.ts";
11
+ import type { StorageData, StorageGQL } from "./storage.d.ts";
3
12
 
4
13
  /**
5
14
  * Enums
6
15
  */
7
16
 
8
- type ReportTypeEnum = typeof REPORT_TYPES[number];
9
- type ReportRowPresetEnum = typeof REPORT_ROW_PRESETS[number];
10
- type ReportsSortEnum = typeof REPORT_SORT_OPTS[number];
17
+ export type ReportRowPresetEnum = typeof REPORT_ROW_PRESETS[number];
18
+ export type ReportsSortEnum = typeof REPORT_SORT_OPTS[number];
19
+ export type ReportFrequencyEnum = typeof REPORT_FREQUENCY_ENUMS[number];
20
+ export type ReportSubmissionStatusEnum = typeof REPORT_STATUS_ENUMS[number];
11
21
 
12
22
  /**
13
23
  * Filters
14
24
  */
15
25
 
16
26
  export interface ReportsFilterArgs {
17
- preset?: '?' | null;
18
- reportType: ReportTypeEnum;
19
- period: string; // YYYY-MM-DD
20
- query?: string | null;
27
+ preset?: "?" | null;
28
+ reportGroupId?: string | null;
29
+ startPeriod?: string | null; // YYYY-MM-DD
30
+ endPeriod?: string | null; // YYYY-MM-DD
21
31
  }
22
32
 
23
33
  /**
24
34
  * Report; fields
25
35
  */
26
36
 
27
- interface ReportFieldsObj {
28
- __allowMultiples?: boolean; // Allow multiple copies of the same report (from 1 report template)
29
- __notAutomated?: boolean; // If true, report is not skipped during automation
30
- __prompt: string; // Server-only, this prompt used on the entire report as a whole (ie. OSP generation)
31
- gridLayoutStyle?: string;
32
- sections?: ReportFieldsSection[];
33
- rows?: ReportFieldsRow[];
34
- metadata?: ReportFieldsRow[];
35
- variables: {
36
- month?: number; // Used for MONTH presets (required for all preset="MONTH" rows)
37
- [key: string]: any;
38
- };
39
- }
40
-
41
- interface ReportFieldsSection {
42
- id?: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
43
- key: string; // Every section must have a unique string UID
44
- isGroupTitle?: boolean;
45
- sectionKey: string;
46
- sectionName: string;
47
- title: string;
48
- description: string;
49
- rows?: ReportFieldsRow[];
50
- requireFileUploads?: boolean;
51
- files?: StorageData[];
52
-
53
- __prompt_section?: string; // Server-only; full prompt for this section - this is the only prompt that allows {{variable}} regex
54
- __prompt_examples?: string; // Server-only; for examples of what the output should be
55
- __prompt_topics?: string; // Server-only; for topics this section should cover
56
- }
57
-
58
- interface ReportFieldsRow {
59
- id?: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
60
- key: string; // Key is used to map row/columns to answers
61
- preset?: ReportRowPresetEnum;
62
- className?: string;
63
- isHeader?: boolean;
64
- columns: Partial<ReportFieldsColumn>[];
65
- }
66
-
67
- type ReportRowGQL = Omit<ReportFieldsRow, 'key'> & {
68
- id: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
37
+ export interface ReportFieldsVariables {
38
+ month?: number; // Used for MONTH presets (required for all preset="MONTH" rows)
39
+ [key: string]: any;
40
+ }
41
+
42
+ export interface ReportFieldsObj {
43
+ __notAutomated?: boolean; // If true, report is not skipped during automation
44
+ __prompt?: string; // Server-only, this prompt used on the entire report as a whole (ie. OSP generation)
45
+ valueRule?: string;
46
+ gridLayoutStyle?: string;
47
+ aside?: ReportFieldsAsideBlock[];
48
+ sections?: ReportFieldsSection[];
49
+ metadata?: ReportFieldsRow[];
50
+ variables?: ReportFieldsVariables;
51
+ }
52
+
53
+ export interface ReportResolvedFieldsObj
54
+ extends Omit<ReportFieldsObj, "variables"> {
55
+ variables: ReportFieldsVariables;
56
+ }
57
+
58
+ export interface ReportFieldsSection {
59
+ id?: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
60
+ key: string; // Every section must have a unique string UID
61
+ isGroupTitle?: boolean;
62
+ title?: string;
63
+ description?: string;
64
+ rows?: ReportFieldsRow[];
65
+ requireFileUploads?: boolean;
66
+ files?: StorageData[];
67
+
68
+ __prompt_section?: string; // Server-only; full prompt for this section - this is the only prompt that allows {{variable}} regex
69
+ __prompt_examples?: string; // Server-only; for examples of what the output should be
70
+ __prompt_topics?: string; // Server-only; for topics this section should cover
71
+ }
72
+
73
+ export interface ReportFieldsAsideBlock {
74
+ title: string;
75
+ nullText?: string;
76
+ items: ReportFieldsAsideItem[];
77
+ }
78
+
79
+ export interface ReportFieldsAsideItem {
80
+ className?: string;
81
+ label: string;
82
+ text: string;
83
+ }
84
+
85
+ export interface ReportFieldsRow {
86
+ id?: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
87
+ key: string; // Key is used to map row/columns to answers
88
+ preset?: ReportRowPresetEnum;
89
+ className?: string;
90
+ isHeader?: boolean;
91
+ templateRule: string; // COPY_FROM_CONFIG
92
+ hintQuestion?: string;
93
+ hintOptions?: string[];
94
+ defaultOnlyBoolean?: boolean;
95
+ defaultPlaceholder?: string | null;
96
+ defaultCheckedShortText?: string | null;
97
+ defaultNotCheckedShortText?: string | null;
98
+ defaultCheckedText?: string | null;
99
+ defaultNotCheckedText?: string | null;
100
+ defaultWarningIfNotChecked?: string | null;
101
+ columns: ReportFieldsColumn[];
102
+ __notAutomated?: boolean; // If true, this column is not filled during automation
103
+ }
104
+
105
+ export interface ReportFieldsColumn {
106
+ id?: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
107
+ key: string; // Key is used to map column to answers
108
+ className?: string;
109
+ iconName?: string;
110
+ labelClassName?: string;
111
+ label?: string; // Typically, this is the "question" the AI Agent/human must answer
112
+ answer?: string | null; // GraphQL-facing saved answer value used for realtime updates
113
+ text?: string; // This the answer provided by the AI Agent/human
114
+ shortText?: string | null;
115
+ checkedText?: string | null;
116
+ checkedShortText?: string | null;
117
+ notCheckedText?: string | null;
118
+ notCheckedShortText?: string | null;
119
+ confirmationNeeded?: boolean;
120
+ doNotAllowNotes?: boolean; // If true, AI will NOT leave notes for this column
121
+ allowMultipleAnswers?: boolean;
122
+ allowCorrectiveActions?: boolean; // If true, AI Agents are allowed to provide corrective actions for this column if the user adds one
123
+ hint?: string; // Additional instructions or context for this column, typically only shown to AI Agents for more guidance.
124
+ onlyBoolean?: boolean;
125
+ warningIfNotChecked?: string | null;
126
+ warningNote?: string; // GraphQL-facing warning field used by mapped report data
127
+ placeholder?: string | null;
128
+ checked?: boolean | null;
129
+ options?: string[]; // If set, user provided inputs *must* be one of these options (ie. for dropdowns, radios, etc.)
130
+ __notAutomated?: boolean; // If true, this column is not filled during automation
131
+ }
132
+
133
+ export interface ReportColumnGQL extends ReportFieldsColumn {
134
+ id: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
135
+ entityId?: string | null;
136
+ referenceIds?: string[] | null;
137
+ lineNumber?: string | null;
138
+ }
139
+
140
+ export type ReportRowGQL = Omit<ReportFieldsRow, "key" | "columns"> & {
141
+ id: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
142
+ columns?: ReportColumnGQL[] | null;
69
143
  };
70
144
 
71
- interface ReportFieldsColumn {
72
- id: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
73
- key: string; // Key is used to map column to answers
74
- className?: string;
75
- labelClassName?: string;
76
- label: string;
77
- text: string;
78
- placeholder: string | null;
79
- value: string | null; // Available only in server; this value has the indexes to map answers to directly without keys
80
- checked: boolean | null;
145
+ export interface ReportGroupLayoutObj {
146
+ columns: string[];
147
+ headers: string[];
148
+ gridLayoutStyle: string;
81
149
  }
82
150
 
83
151
  /**
84
152
  * Report data
85
153
  */
86
154
 
155
+ export interface ReportGroupData {
156
+ __table: "report_groups";
157
+ id: number;
158
+ name: string;
159
+ shortName?: string | null;
160
+ layout?: Partial<ReportGroupLayoutObj> | null;
161
+ }
162
+
87
163
  export interface ReportData {
88
- __table: 'reports';
164
+ __table: "reports";
89
165
 
90
- id: number;
91
- type: ReportTypeEnum;
92
- documentName: string;
93
- title: string;
94
- description: string;
95
- order: number;
166
+ id: number;
167
+ reportGroupId: number;
168
+ reportGroup?: ReportGroupData | null;
169
+ documentName: string;
170
+ title: string;
171
+ description: string;
172
+ frequency: ReportFrequencyEnum;
173
+ order: number;
96
174
 
97
- fields: ReportFieldsObj;
98
- submission?: ReportSubmissionData | null;
175
+ fields: ReportFieldsObj;
176
+ submission?: ReportSubmissionData | null; // Present when report_submissions was joined onto the report row.
99
177
 
100
- template?: {
101
- __table: 'report_templates';
102
- id: number;
103
- fields: ReportFieldsObj;
104
- description: string | null;
105
- };
178
+ template?: {
179
+ __table: "report_templates";
180
+ id: number;
181
+ fields: ReportFieldsObj;
182
+ description: string | null;
183
+ };
184
+
185
+ site?: Pick<OrganizationSiteData, "id" | "name"> | null;
186
+ childOrg?: OrganizationData;
187
+ organization?: OrganizationData;
106
188
  }
107
189
 
108
190
  export interface ReportGQL {
109
- __deleted?: boolean;
110
-
111
- id: string;
112
- organizationId: string;
113
- documentName: string;
114
- title: string;
115
- description: string;
116
- type: ReportTypeEnum;
117
- period: string; // YYYY-MM-DD
118
- evidencesCount: number;
119
- activityAt: string | null; // ISO date string
120
-
121
- sections?: ReportSectionGQL[];
122
- rows?: ReportRowGQL[];
123
- }
124
-
125
- interface ReportSectionGQL {
126
- id: string;
127
- isGroupTitle?: boolean;
128
- sectionKey: string;
129
- sectionName: string;
130
- title: string;
131
- description: string;
132
- rows?: ReportRowGQL[];
133
- requireFileUploads?: boolean;
134
- files?: StorageGQL[];
135
- }
191
+ __deleted?: boolean;
136
192
 
137
- /**
138
- * Report submission data
139
- */
193
+ id: string;
194
+ organizationId: string;
195
+ documentName: string;
196
+ title: string;
197
+ description: string;
198
+ frequency?: ReportFrequencyEnum | null;
199
+ reportGroupId: string;
200
+ groupName: string;
201
+ groupShortName?: string | null;
202
+ period: string; // YYYY-MM-DD
203
+ summary?: string | null;
204
+ submission?: ReportSubmissionGQL | null;
205
+ gridLayoutStyle?: string | null;
140
206
 
141
- export interface ReportEvidenceGQL {
142
- __deleted?: boolean;
207
+ aside?: ReportFieldsAsideBlock[];
208
+ sections?: ReportSectionGQL[];
209
+ }
143
210
 
144
- id: string; // GraphQL Cursor
145
- reportSubmissionId: string;
146
- sectionKey: string;
147
- log: any; // LogEntryGQL
211
+ export interface ReportSectionGQL {
212
+ id: string;
213
+ isGroupTitle?: boolean;
214
+ title?: string | null;
215
+ description?: string | null;
216
+ rows?: ReportRowGQL[];
217
+ requireFileUploads?: boolean;
218
+ files?: StorageGQL[];
148
219
  }
149
220
 
150
221
  export interface ReportSubmissionGQL {
151
- __deleted?: boolean;
152
-
153
- id: string;
154
- reportId: string;
155
- organizationId: string;
156
- sectionKey: string;
157
- documentName: string;
158
- sectionName: string;
159
- title: string;
160
- period: string; // YYYY-MM-DD
161
- activityAt: string | null; // ISO date string
162
- rows: ReportRowGQL[];
163
- evidences: string[];
164
- requireFileUploads: boolean;
165
- }
222
+ __deleted?: boolean;
166
223
 
167
- export interface ReportLogRelData {
168
- __table: 'report_log_rels';
169
- reportSubmissionId: number | bigint;
170
- logId: number | bigint;
171
- sectionKey: string;
224
+ id: string;
225
+ reportSubmissionId: string;
226
+ reportId: string;
227
+ value?: string | null;
228
+ frequency: ReportFrequencyEnum;
229
+ reportSubmissionIdEnc?: string | null;
230
+ organizationId: string;
231
+ organizationIdEnc?: string | null;
232
+ location?: string | null;
233
+ childOrgId: string | null;
234
+ childOrgIdEnc?: string | null;
235
+ childOrgName: string | null;
236
+ childOrgOperation: string | null;
237
+ organizationName?: string | null;
238
+ organizationOperation?: string | null;
239
+ reportGroupId: string;
240
+ groupName: string;
241
+ groupShortName?: string | null;
242
+ period: string; // YYYY-MM-DD
243
+ status: ReportSubmissionStatusEnum | null;
244
+ activityAt: string | null; // ISO date string
245
+ createdAt: string | null; // ISO date string
246
+ updatedAt: string | null; // ISO date string
172
247
  }
173
248
 
174
249
  export interface ReportStorageRelData {
175
- __table: 'report_storage_rels';
176
- reportSubmissionId: number | bigint;
177
- storageId: number | bigint;
178
- sectionKey: string;
179
- order: number;
180
- file: StorageData;
250
+ __table: "report_storage_rels";
251
+ reportSubmissionId: number | bigint;
252
+ storageId: number | bigint;
253
+ sectionKey: string;
254
+ order: number;
255
+ file: StorageData;
181
256
  }
182
257
 
183
258
  export interface ReportSubmissionData {
184
- __table: 'report_submissions';
185
- id: number;
186
- organizationId: number;
187
- reportId: number;
188
- period: Date; // YYYY-MM-DD in database, Date object in server via ORM
189
- answers: Record<string, any>; // key-value pairs of answers
190
- logRels?: ReportLogRelData[];
191
- storageRels?: ReportStorageRelData[];
192
- activityAt: Date;
259
+ __table: "report_submissions";
260
+ id: number;
261
+ childOrgId?: number | bigint | null;
262
+ siteId?: number | bigint | null;
263
+ value?: string | null;
264
+ report?: Pick<ReportData, "id" | "frequency"> | null;
265
+ site?: Pick<OrganizationSiteData, "id" | "name"> | null;
266
+ childOrg?: OrganizationData;
267
+ organization?: OrganizationData;
268
+ organizationId: number;
269
+ reportId: number;
270
+ period: Date; // YYYY-MM-DD in database, Date object in server via ORM
271
+ answers: Record<string, any>; // key-value pairs of answers
272
+ status?: ReportSubmissionStatusEnum | null;
273
+ storageRels?: ReportStorageRelData[];
274
+ activityAt: Date;
275
+ createdAt: Date;
276
+ updatedAt: Date;
193
277
  }
194
278
 
195
279
  /**
196
- * Available reports
280
+ * Report groups
197
281
  */
198
282
 
199
- export interface ReportAvailabilityGQL {
200
- id: string;
201
- type: ReportTypeEnum;
202
- periods: string[]; // YYYY-MM-DD
283
+ export interface ReportGroupGQL {
284
+ id: string;
285
+ name: string;
286
+ shortName?: string | null;
287
+ layout?: Partial<ReportGroupLayoutObj> | null;
288
+ lastSubmissionPeriod?: string | null; // YYYY-MM-DD
289
+ lastSubmissionReportId?: string | null;
203
290
  }