@jsb188/mday 1.1.11 → 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.
- package/package.json +58 -23
- package/src/constants/agentMemory.ts +14 -45
- package/src/constants/agentNote.ts +212 -0
- package/src/constants/aiChat.ts +5 -0
- package/src/constants/billing.ts +126 -0
- package/src/constants/campaign.ts +156 -47
- package/src/constants/contact.ts +72 -0
- package/src/constants/csvExport.ts +133 -0
- package/src/constants/dataTable.ts +12 -38
- package/src/constants/dataTableFieldTypes.generated.ts +3 -7
- package/src/constants/docAccess.ts +3 -2
- package/src/constants/dt.ts +234 -0
- package/src/constants/email.ts +114 -12
- package/src/constants/fieldDoc.ts +74 -4
- package/src/constants/graphqlReactivity.ts +108 -25
- package/src/constants/log.ts +9 -0
- package/src/constants/logDisplay/README.md +88 -0
- package/src/constants/logDisplay/defaults.ts +39 -0
- package/src/constants/logDisplay/index.ts +27 -0
- package/src/constants/logDisplay/operations/arable.ts +16 -0
- package/src/constants/logDisplay/operations/farmersMarket.ts +10 -0
- package/src/constants/logDisplay/operations/foodManufacturing.ts +13 -0
- package/src/constants/logDisplay/shared/accounting.ts +13 -0
- package/src/constants/logDisplay/shared/interactions.ts +13 -0
- package/src/constants/logDisplay/shared/rackTemperatures.ts +42 -0
- package/src/constants/logTaxonomy.generated.ts +1834 -730
- package/src/constants/organization.ts +13 -14
- package/src/constants/qrCode.ts +30 -0
- package/src/constants/sheet.ts +65 -101
- package/src/constants/sms.ts +18 -0
- package/src/constants/storage.ts +33 -9
- package/src/constants/usage.ts +3 -0
- package/src/constants/workflowSteps.ts +60 -0
- package/src/schemas/editLogEntry.ts +106 -283
- package/src/schemas/inboundContact.ts +5 -5
- package/src/types/agentMemory.d.ts +38 -14
- package/src/types/agentNote.d.ts +443 -0
- package/src/types/billing.d.ts +537 -0
- package/src/types/campaign.d.ts +1043 -193
- package/src/types/contact.d.ts +15 -0
- package/src/types/csvExport.d.ts +213 -0
- package/src/types/dataAnalysis.d.ts +44 -0
- package/src/types/dataTable.d.ts +102 -309
- package/src/types/definitionElement.d.ts +35 -0
- package/src/types/dt.d.ts +257 -0
- package/src/types/email.d.ts +144 -55
- package/src/types/emailReplyReport.d.ts +76 -0
- package/src/types/fieldDoc.d.ts +579 -150
- package/src/types/fieldDocContract.d.ts +90 -0
- package/src/types/inboundContact.d.ts +8 -0
- package/src/types/log.d.ts +94 -3
- package/src/types/logDisplay.types.ts +85 -0
- package/src/types/organization.d.ts +8 -3
- package/src/types/qrCode.d.ts +96 -0
- package/src/types/richText.d.ts +81 -0
- package/src/types/sheet.d.ts +180 -463
- package/src/types/sms.d.ts +38 -0
- package/src/types/storage.d.ts +266 -27
- package/src/types/workflow.d.ts +196 -66
- package/src/utils/agentMemory.ts +15 -0
- package/src/utils/agentNote.ts +850 -0
- package/src/utils/aiChat.ts +31 -14
- package/src/utils/aiChatWork.ts +64 -0
- package/src/utils/billing.ts +37 -0
- package/src/utils/campaign.ts +642 -209
- package/src/utils/campaignAI.ts +72 -0
- package/src/utils/campaignAccess.ts +239 -0
- package/src/utils/campaignEmail.ts +601 -0
- package/src/utils/campaignEmailCompiler.ts +372 -0
- package/src/utils/campaignEmailImages.ts +60 -0
- package/src/utils/campaignEmailStyles.ts +544 -0
- package/src/utils/campaignLifecycle.ts +104 -0
- package/src/utils/campaignPreview.ts +285 -0
- package/src/utils/contact.ts +50 -0
- package/src/utils/csvExport.ts +19 -0
- package/src/utils/dataTable.ts +18 -556
- package/src/utils/dataTableFieldTypeRegistry.ts +1 -0
- package/src/utils/dataTableRelativeDate.ts +447 -0
- package/src/utils/definitionElement.ts +84 -0
- package/src/utils/email.ts +208 -1
- package/src/utils/emailReplyReport.test.ts +187 -0
- package/src/utils/emailReplyReport.ts +143 -0
- package/src/utils/fieldDoc.ts +81 -37
- package/src/utils/fieldDocAnswers.ts +128 -0
- package/src/utils/fieldDocDefaults.ts +36 -0
- package/src/utils/fieldDocProgram.ts +36 -0
- package/src/utils/fieldDocSummary.ts +30 -0
- package/src/utils/log.ts +232 -141
- package/src/utils/logDisplay.helpers.ts +177 -0
- package/src/utils/logDisplay.ts +87 -0
- package/src/utils/logStoreRead.ts +9 -13
- package/src/utils/logTaxonomy.helpers.ts +17 -0
- package/src/utils/logTaxonomyDisplay.ts +80 -124
- package/src/utils/noteDoc.ts +66 -284
- package/src/utils/organization.ts +117 -283
- package/src/utils/qrCode.helpers.ts +189 -0
- package/src/utils/qrCode.test.ts +519 -0
- package/src/utils/qrCode.ts +273 -0
- package/src/utils/richTextHTML.ts +385 -0
- package/src/utils/sheet.ts +123 -4834
- package/src/utils/sheetAxisMove.ts +77 -291
- package/src/utils/sheetBootstrap.ts +771 -1138
- package/src/utils/sheetCellLiteral.ts +101 -0
- package/src/utils/sheetCommand.ts +23 -88
- package/src/utils/sheetDesign.ts +705 -0
- package/src/utils/sheetExport.ts +17 -69
- package/src/utils/sheetFeatureReference.ts +183 -0
- package/src/utils/sheetFormulaArgs.ts +168 -0
- package/src/utils/sheetFormulaCompile.ts +475 -0
- package/src/utils/sheetFormulaConditionalAggregate.ts +254 -0
- package/src/utils/sheetFormulaCriteria.ts +656 -0
- package/src/utils/sheetFormulaDate.ts +444 -0
- package/src/utils/sheetFormulaEvaluation.ts +388 -403
- package/src/utils/sheetFormulaEvaluator.ts +589 -444
- package/src/utils/sheetFormulaFunctionHandlers.ts +403 -0
- package/src/utils/sheetFormulaLogical.ts +116 -0
- package/src/utils/sheetFormulaLookup.ts +488 -0
- package/src/utils/sheetFormulaMath.ts +48 -0
- package/src/utils/sheetFormulaParser.ts +729 -0
- package/src/utils/sheetFormulaRange.ts +330 -0
- package/src/utils/sheetFormulaReference.ts +703 -0
- package/src/utils/sheetFormulaReferenceAggregates.ts +313 -0
- package/src/utils/sheetFormulaReferenceDates.ts +237 -0
- package/src/utils/sheetFormulaReferenceLogical.ts +330 -0
- package/src/utils/sheetFormulaReferenceLookup.ts +341 -0
- package/src/utils/sheetFormulaReferenceMath.ts +95 -0
- package/src/utils/sheetFormulaReferenceRewrite.ts +220 -0
- package/src/utils/sheetFormulaReferenceText.ts +462 -0
- package/src/utils/sheetFormulaSyntax.ts +1027 -0
- package/src/utils/sheetFormulaText.ts +430 -0
- package/src/utils/sheetJournal.ts +140 -18
- package/src/utils/sheetNumberFormat.ts +68 -267
- package/src/utils/sheetPreview.ts +68 -0
- package/src/utils/sheetSequence.ts +13 -43
- package/src/utils/sheetSnapshot.ts +176 -429
- package/src/utils/sheetStructureEdit.ts +537 -907
- package/src/utils/sheetStructureReferences.ts +389 -0
- package/src/utils/storage.ts +49 -3
- package/src/utils/time.ts +12 -0
- package/src/utils/workflow.ts +199 -73
- package/src/utils/workflowLogFingerprint.ts +302 -0
- package/src/utils/workflowLogRevisionSnapshot.ts +424 -0
- package/src/utils/workflowProgress.ts +280 -0
- package/src/utils/workflowTriggers.ts +61 -0
- package/tests/agentNote.test.ts +395 -0
- package/tests/campaignAI.test.ts +119 -0
- package/tests/campaignAccess.test.ts +239 -0
- package/tests/campaignEmail.test.ts +441 -0
- package/tests/campaignLifecycle.test.ts +134 -0
- package/tests/campaignPublication.test.ts +309 -0
- package/tests/dataTableFieldTypeRegistry.test.ts +2 -1
- package/tests/dataTableRelativeDate.test.ts +412 -0
- package/tests/email.test.ts +39 -0
- package/tests/fieldDocProgram.test.ts +114 -0
- package/tests/logDisplay.fixtures.ts +67 -0
- package/tests/logDisplay.test.ts +227 -0
- package/tests/noteDoc.test.ts +37 -192
- package/tests/richTextHTML.test.ts +185 -0
- package/tests/sheetAxisMove.test.ts +49 -40
- package/tests/sheetBootstrap.test.ts +1967 -0
- package/tests/sheetFeatureReference.test.ts +22 -0
- package/tests/sheetFormulaCriteria.test.ts +269 -0
- package/tests/sheetFormulaEvaluator.test.ts +93 -200
- package/tests/sheetFormulaFunctions.test.ts +538 -0
- package/tests/sheetFormulaLanguage.test.ts +361 -0
- package/tests/sheetFormulaParity.fixtures.ts +872 -0
- package/tests/sheetFormulaParity.test.ts +188 -0
- package/tests/sheetFormulaRange.test.ts +167 -0
- package/tests/sheetFormulaReference.test.ts +78 -0
- package/tests/sheetFormulaReferenceRewrite.test.ts +117 -0
- package/tests/sheetFormulaTextDate.test.ts +512 -0
- package/tests/sheetSequence.test.ts +4 -23
- package/tests/sheetSnapshot.test.ts +134 -0
- package/tests/sheetStructureEdit.test.ts +492 -37
- package/tests/sheetStructureReferences.test.ts +589 -0
- package/tests/workflowLifecycleStatus.test.ts +60 -0
- package/tests/workflowLogFingerprint.test.ts +203 -0
- package/tests/workflowLogRevisionSnapshot.test.ts +96 -0
- package/tests/workflowProgress.test.ts +180 -0
- package/tests/workflowTriggers.test.ts +29 -0
- package/src/constants/agentDoc.ts +0 -12
- package/src/constants/logActivityGroupColors.generated.ts +0 -19
- package/src/constants/schedule.ts +0 -220
- package/src/constants/scheduleRuleTemplateSeed.ts +0 -138
- package/src/constants/scheduleRuleTemplates.generated.ts +0 -145
- package/src/constants/sheetRegionSources.generated.ts +0 -578
- package/src/schemas/fieldDocsQuery.ts +0 -12
- package/src/schemas/organization.ts +0 -68
- package/src/types/agentDoc.d.ts +0 -64
- package/src/types/noteDoc.d.ts +0 -86
- package/src/types/schedule.d.ts +0 -391
- package/src/utils/agentDoc.ts +0 -109
- package/src/utils/campaignFormEditor.ts +0 -871
- package/src/utils/dataTableRealtimeAuthority.ts +0 -209
- package/src/utils/dataTableRealtimeSelection.ts +0 -134
- package/src/utils/dataTableRowDocument.ts +0 -508
- package/src/utils/dataTableSource.ts +0 -230
- package/src/utils/schedule.ts +0 -799
- package/src/utils/scheduleEvaluation.ts +0 -1994
- package/src/utils/scheduleICS.ts +0 -246
- package/src/utils/scheduleRuleTemplates.ts +0 -188
- package/src/utils/sheetRegion.ts +0 -374
- package/src/utils/sheetRegionFilter.ts +0 -1259
- package/src/utils/sheetRegionSourceRegistry.ts +0 -594
- package/tests/schedule.test.ts +0 -693
- package/tests/scheduleEvaluation.test.ts +0 -1970
- package/tests/scheduleICS.test.ts +0 -208
- package/tests/scheduleRuleTemplates.test.ts +0 -176
- package/tests/scheduleSweepInvariants.test.ts +0 -428
- package/tests/sheetRegionFilter.test.ts +0 -1135
package/src/types/fieldDoc.d.ts
CHANGED
|
@@ -1,32 +1,47 @@
|
|
|
1
1
|
import {
|
|
2
|
+
FIELD_DOC_CATEGORIES,
|
|
2
3
|
FIELD_DOC_ELEMENT_KINDS,
|
|
3
4
|
FIELD_DOC_FREQUENCY_ENUMS,
|
|
4
|
-
|
|
5
|
+
FIELD_DOC_INSTANCE_STATUS_ENUMS,
|
|
5
6
|
FIELD_DOC_STATUS_ENUMS,
|
|
7
|
+
FIELD_DOC_SUBMISSION_FILTER_STATUS_ENUMS,
|
|
6
8
|
} from '../constants/fieldDoc.ts';
|
|
7
9
|
import type {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
DefinitionElementBaseData,
|
|
11
|
+
DefinitionElementStorageRelBaseData,
|
|
12
|
+
DefinitionSectionWithElementsObj,
|
|
13
|
+
} from './definitionElement.d.ts';
|
|
14
|
+
import type { OrganizationData, OrganizationSiteData } from './organization.d.ts';
|
|
15
|
+
import type { StorageGQL } from './storage.d.ts';
|
|
16
|
+
import type {
|
|
17
|
+
FieldDocAnswerRules,
|
|
18
|
+
FieldDocAnswers,
|
|
19
|
+
FieldDocAnswerState,
|
|
20
|
+
FieldDocAnswerType,
|
|
21
|
+
FieldDocScalarAnswerType,
|
|
22
|
+
} from './fieldDocContract.d.ts';
|
|
12
23
|
|
|
13
24
|
/**
|
|
14
25
|
* Enums
|
|
15
26
|
*/
|
|
16
27
|
|
|
17
28
|
export type FieldDocElementKindEnum = (typeof FIELD_DOC_ELEMENT_KINDS)[number];
|
|
18
|
-
export type FieldDocsSortEnum = (typeof FIELD_DOC_SORT_OPTS)[number];
|
|
19
29
|
export type FieldDocFrequencyEnum = (typeof FIELD_DOC_FREQUENCY_ENUMS)[number];
|
|
20
|
-
export type FieldDocSubmissionStatusEnum =
|
|
21
|
-
|
|
30
|
+
export type FieldDocSubmissionStatusEnum = (typeof FIELD_DOC_STATUS_ENUMS)[number];
|
|
31
|
+
export type FieldDocSubmissionFilterStatusEnum = (typeof FIELD_DOC_SUBMISSION_FILTER_STATUS_ENUMS)[number];
|
|
32
|
+
export type FieldDocInstanceStatusEnum = (typeof FIELD_DOC_INSTANCE_STATUS_ENUMS)[number];
|
|
33
|
+
export type FieldDocCategoryKey = (typeof FIELD_DOC_CATEGORIES)[number];
|
|
22
34
|
|
|
23
35
|
/**
|
|
24
36
|
* Filters
|
|
25
37
|
*/
|
|
26
38
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
// fieldDocSubmissions list filter; the list is always scoped to one owner organization
|
|
40
|
+
export interface FieldDocSubmissionsFilterArgs {
|
|
41
|
+
fieldDocProgramId?: string | null;
|
|
42
|
+
fieldDocIds?: string[] | null;
|
|
43
|
+
siteId?: string | null;
|
|
44
|
+
statuses?: FieldDocSubmissionFilterStatusEnum[] | null; // OPEN represents an ungraded submission
|
|
30
45
|
startPeriod?: string | null; // YYYY-MM-DD
|
|
31
46
|
endPeriod?: string | null; // YYYY-MM-DD
|
|
32
47
|
}
|
|
@@ -35,7 +50,8 @@ export interface FieldDocsFilterArgs {
|
|
|
35
50
|
* FieldDoc; elements (the field_doc_elements table)
|
|
36
51
|
*/
|
|
37
52
|
|
|
38
|
-
|
|
53
|
+
// Runtime values the template engine substitutes into a program layout aside (org name, timezone, etc.)
|
|
54
|
+
export interface FieldDocVariablesObj {
|
|
39
55
|
month?: number; // Used for {{month}} template expressions
|
|
40
56
|
[key: string]: any;
|
|
41
57
|
}
|
|
@@ -46,228 +62,641 @@ export interface FieldDocElementSettingsObj {
|
|
|
46
62
|
allowCorrectiveActions?: boolean; // AI Agents may record corrective actions for this question
|
|
47
63
|
allowMultipleAnswers?: boolean;
|
|
48
64
|
doNotAllowNotes?: boolean; // If true, AI/respondents will NOT leave notes for this question
|
|
65
|
+
answer?: FieldDocAnswerRules;
|
|
66
|
+
allowNotApplicable?: boolean;
|
|
67
|
+
applicableWhen?: { questionKey: string; equals: string | number | boolean };
|
|
49
68
|
}
|
|
50
69
|
|
|
51
|
-
|
|
70
|
+
// "label" is the question label, title text or section title. If "options"
|
|
71
|
+
// is set, answers must match an option unless CHOICE explicitly allows Other. A "required" question must be
|
|
72
|
+
// answered or explicitly marked not applicable for document completion.
|
|
73
|
+
export interface FieldDocElementData
|
|
74
|
+
extends DefinitionElementBaseData<FieldDocElementKindEnum, string, FieldDocElementSettingsObj, FieldDocElementStorageRelData> {
|
|
52
75
|
__table: 'field_doc_elements';
|
|
53
|
-
id: number | bigint;
|
|
54
76
|
fieldDocId: number | bigint;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
order: number;
|
|
59
|
-
label?: string | null; // Question label / title text / section title
|
|
60
|
-
description?: string | null;
|
|
61
|
-
hint?: string | null; // Additional AI answering guidance
|
|
62
|
-
options?: string[] | null; // If set, answers *must* be one of these options
|
|
63
|
-
required?: boolean; // Public web forms: submission is blocked until answered
|
|
64
|
-
settings?: FieldDocElementSettingsObj | null;
|
|
65
|
-
storageRels?: FieldDocElementStorageRelData[]; // Element images
|
|
77
|
+
hint?: string | null; // AI answering guidance; on overlaid docs, the program hint composed with the owner org's custom instructions
|
|
78
|
+
programHint?: string | null; // Overlaid docs only: the published hint before composition
|
|
79
|
+
customInstructions?: string | null; // Overlaid docs only: the owner org's custom instructions for this key
|
|
66
80
|
}
|
|
67
81
|
|
|
68
|
-
export interface FieldDocElementStorageRelData {
|
|
82
|
+
export interface FieldDocElementStorageRelData extends DefinitionElementStorageRelBaseData {
|
|
69
83
|
__table: 'field_doc_element_storage_rels';
|
|
70
84
|
fieldDocElementId: number | bigint;
|
|
71
|
-
storageId: number | bigint;
|
|
72
|
-
order: number;
|
|
73
|
-
file: StorageData;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// One hydrated top-level section with its ordered child elements
|
|
77
|
-
export interface FieldDocSectionWithElementsObj extends FieldDocElementData {
|
|
78
|
-
elements: FieldDocElementData[];
|
|
79
85
|
}
|
|
80
86
|
|
|
81
|
-
|
|
82
|
-
export interface FieldDocDefinitionObj {
|
|
83
|
-
sections: FieldDocSectionWithElementsObj[];
|
|
84
|
-
aside?: FieldDocFieldsAsideBlock[]; // From field_doc_templates.fields
|
|
85
|
-
variables: FieldDocFieldsVariables; // Runtime-injected (org name, timezone, etc.)
|
|
86
|
-
}
|
|
87
|
+
export type FieldDocSectionWithElementsObj = DefinitionSectionWithElementsObj<FieldDocElementData>;
|
|
87
88
|
|
|
88
89
|
/**
|
|
89
|
-
* FieldDoc;
|
|
90
|
+
* FieldDoc; program layout aside (field_doc_programs.layout.aside)
|
|
90
91
|
*/
|
|
91
92
|
|
|
92
|
-
export interface
|
|
93
|
-
aside?: FieldDocFieldsAsideBlock[];
|
|
94
|
-
variables?: FieldDocFieldsVariables;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export interface FieldDocFieldsAsideBlock {
|
|
93
|
+
export interface FieldDocAsideBlockObj {
|
|
98
94
|
title: string;
|
|
99
95
|
nullText?: string;
|
|
100
|
-
items:
|
|
96
|
+
items: FieldDocAsideItemObj[];
|
|
101
97
|
}
|
|
102
98
|
|
|
103
|
-
export interface
|
|
99
|
+
export interface FieldDocAsideItemObj {
|
|
104
100
|
className?: string;
|
|
105
101
|
label: string;
|
|
106
102
|
text: string;
|
|
103
|
+
// Omit the row when its resolved template text is empty.
|
|
104
|
+
hideIfEmpty?: boolean;
|
|
107
105
|
}
|
|
108
106
|
|
|
109
107
|
/**
|
|
110
|
-
* FieldDoc
|
|
108
|
+
* FieldDoc programs (field_doc_categories, field_doc_programs, field_doc_program_enrollments)
|
|
111
109
|
*/
|
|
112
110
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
// field_doc_programs.layout; every key is optional (custom programs store '{}')
|
|
112
|
+
export interface FieldDocProgramLayoutObj {
|
|
113
|
+
columns?: string[];
|
|
114
|
+
headers?: string[];
|
|
115
|
+
gridLayoutStyle?: string;
|
|
116
|
+
aside?: FieldDocAsideBlockObj[]; // Rendered per submission on the document; never sent with the program
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// A group belongs to its program; every enrolled organization sees the same groups.
|
|
120
|
+
export interface FieldDocProgramGroupData {
|
|
121
|
+
__table: 'field_doc_program_groups';
|
|
122
|
+
id: number | bigint;
|
|
123
|
+
programId: number;
|
|
124
|
+
catalogKey: string | null;
|
|
125
|
+
name: string;
|
|
126
|
+
order: number;
|
|
127
|
+
createdAt?: Date;
|
|
128
|
+
updatedAt?: Date;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// A catalog program (catalogKey set, organizationId null) or an organization's custom program (the reverse)
|
|
132
|
+
export interface FieldDocProgramData {
|
|
133
|
+
__table: 'field_doc_programs';
|
|
134
|
+
groups?: FieldDocProgramGroupData[];
|
|
135
|
+
id: number;
|
|
136
|
+
catalogKey: string | null;
|
|
137
|
+
organizationId: number | bigint | null; // Custom programs only: the owner organization
|
|
138
|
+
categoryKey: FieldDocCategoryKey;
|
|
139
|
+
name: string;
|
|
140
|
+
shortName?: string | null;
|
|
118
141
|
description?: string | null;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
142
|
+
layout?: FieldDocProgramLayoutObj | null;
|
|
143
|
+
contentHash?: string | null; // Catalog sync hash of the program's catalog content
|
|
144
|
+
retiredAt?: Date | null; // Catalog programs removed from the catalog
|
|
145
|
+
operations?: string[]; // Attached from field_doc_program_operations (catalog programs only)
|
|
146
|
+
createdAt?: Date;
|
|
147
|
+
updatedAt?: Date;
|
|
148
|
+
}
|
|
123
149
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
150
|
+
// One organization's enrollment in one program; archived enrollments are restorable until purged
|
|
151
|
+
export interface FieldDocEnrollmentData {
|
|
152
|
+
__table: 'field_doc_program_enrollments';
|
|
153
|
+
organizationId: number | bigint;
|
|
154
|
+
programId: number;
|
|
155
|
+
enrolledByAccountId?: number | bigint | null;
|
|
156
|
+
archivedAt: Date | null; // Set by unenroll; purged after TRASH_BIN_RETENTION_DAYS
|
|
157
|
+
pausedWorkflowIds: (number | bigint)[]; // Managed workflows unenroll paused; restore resumes exactly these
|
|
158
|
+
createdAt: Date;
|
|
159
|
+
updatedAt: Date;
|
|
160
|
+
program?: FieldDocProgramData; // Attached by enrollment readers
|
|
161
|
+
forms?: FieldDocFormData[]; // Program docs plus this organization's custom docs in the program; retired and draft-only included
|
|
162
|
+
}
|
|
130
163
|
|
|
131
|
-
|
|
164
|
+
// One form of an enrollment, with the editor state the program page and pickers list
|
|
165
|
+
export interface FieldDocFormData extends FieldDocData {
|
|
166
|
+
// Present only on organization-scoped enrollment reads; excluded from the shared FieldDoc GraphQL type.
|
|
167
|
+
lastSubmissionUpdatedAt?: Date | null;
|
|
168
|
+
hasDraft: boolean;
|
|
169
|
+
draftTitle: string | null; // The draft's title when a draft exists
|
|
170
|
+
publishedRevisionNumber: number | null; // Null until the form's first publication
|
|
132
171
|
}
|
|
133
172
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
173
|
+
// Per-key custom instructions of one organization for one program doc (field_doc_custom_instructions)
|
|
174
|
+
export interface FieldDocCustomInstructionData {
|
|
175
|
+
__table: 'field_doc_custom_instructions';
|
|
176
|
+
organizationId: number | bigint;
|
|
177
|
+
fieldDocId: number | bigint;
|
|
178
|
+
elementKey: string; // An element key of the doc, or FIELD_DOC_DOCUMENT_INSTRUCTIONS_KEY for the doc-level agentHint
|
|
179
|
+
instructions: string;
|
|
180
|
+
updatedByAccountId?: number | bigint | null;
|
|
181
|
+
updatedAt: Date;
|
|
138
182
|
}
|
|
139
183
|
|
|
140
184
|
/**
|
|
141
185
|
* FieldDoc data
|
|
142
186
|
*/
|
|
143
187
|
|
|
144
|
-
export interface FieldDocGroupData {
|
|
145
|
-
__table: 'field_doc_groups';
|
|
146
|
-
id: number;
|
|
147
|
-
name: string;
|
|
148
|
-
shortName?: string | null;
|
|
149
|
-
layout?: Partial<FieldDocGroupLayoutObj> | null;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
188
|
export interface FieldDocData {
|
|
153
189
|
__table: 'field_docs';
|
|
190
|
+
groupId?: number | bigint | null;
|
|
191
|
+
group?: FieldDocProgramGroupData | null;
|
|
154
192
|
|
|
155
193
|
id: number;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
194
|
+
programId: number;
|
|
195
|
+
program?: FieldDocProgramData | null; // Attached when the reader joins field_doc_programs
|
|
196
|
+
// Custom docs: the owner organization. Null for program docs. Every field_docs field list selects it (isProgramFieldDoc).
|
|
197
|
+
organizationId: number | bigint | null;
|
|
198
|
+
catalogKey?: string | null; // Program docs only
|
|
199
|
+
catalogContentHash?: string | null; // Catalog sync hash of the doc's catalog content
|
|
159
200
|
documentName: string;
|
|
160
201
|
title: string;
|
|
161
202
|
description: string;
|
|
162
|
-
agentHint?: string | null;
|
|
203
|
+
agentHint?: string | null; // On overlaid docs, the program agentHint composed with the owner org's custom instructions
|
|
204
|
+
programAgentHint?: string | null; // Overlaid docs only: the published agentHint before composition
|
|
205
|
+
agentHintCustomInstructions?: string | null; // Overlaid docs only: the owner org's doc-level custom instructions
|
|
163
206
|
frequency: FieldDocFrequencyEnum;
|
|
164
207
|
order: number;
|
|
208
|
+
publishedDefinitionRevisionId?: number | bigint | null;
|
|
209
|
+
definitionRevisionId?: number | bigint | null;
|
|
210
|
+
definitionRevisionNumber?: number;
|
|
211
|
+
retiredAt?: Date | null; // Program docs removed from the catalog; no new submissions
|
|
212
|
+
archivedAt?: Date | null; // Custom docs only; purged after TRASH_BIN_RETENTION_DAYS
|
|
165
213
|
|
|
166
214
|
elements?: FieldDocElementData[]; // Attached by attachFieldDocElements() after fetching
|
|
167
215
|
submission?: FieldDocSubmissionData | null; // Present when field_doc_submissions was joined onto the fieldDoc row.
|
|
168
216
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
description: string | null;
|
|
174
|
-
};
|
|
217
|
+
site?: Pick<OrganizationSiteData, 'id' | 'name'> | null;
|
|
218
|
+
childOrg?: OrganizationData;
|
|
219
|
+
organization?: OrganizationData;
|
|
220
|
+
}
|
|
175
221
|
|
|
222
|
+
export interface FieldDocSubmissionData {
|
|
223
|
+
__table: 'field_doc_submissions';
|
|
224
|
+
id: number;
|
|
225
|
+
childOrgId?: number | bigint | null;
|
|
226
|
+
siteId?: number | bigint | null;
|
|
227
|
+
fieldDoc?: Pick<FieldDocData, 'id' | 'frequency'> | null;
|
|
176
228
|
site?: Pick<OrganizationSiteData, 'id' | 'name'> | null;
|
|
177
229
|
childOrg?: OrganizationData;
|
|
178
230
|
organization?: OrganizationData;
|
|
231
|
+
organizationId: number;
|
|
232
|
+
fieldDocId: number;
|
|
233
|
+
period: Date; // YYYY-MM-DD in database, Date object in server via ORM
|
|
234
|
+
summary?: string | null; // At most FIELD_DOC_SUMMARY_MAX characters; every writer stores clampFieldDocSummary()
|
|
235
|
+
answers: FieldDocAnswers;
|
|
236
|
+
evidenceLogIds?: (number | bigint)[]; // Every logId cited in answers; maintained by a database trigger
|
|
237
|
+
definitionRevisionId?: number | bigint | null;
|
|
238
|
+
answerVersion?: number; // Current concurrency counter only; no answer snapshots
|
|
239
|
+
status?: FieldDocSubmissionStatusEnum | null; // The displayed grade, persisted at write time
|
|
240
|
+
// An explicit user grade takes precedence over all automatic answer grading.
|
|
241
|
+
statusOverride?: FieldDocSubmissionStatusEnum | null;
|
|
242
|
+
statusOverrideAccountId?: number | bigint | null;
|
|
243
|
+
statusOverrideAt?: Date | null;
|
|
244
|
+
// PER_INSTANCE forms only: the external job key (e.g. "dispatch:371289") and its lifecycle; null on periodic rows
|
|
245
|
+
instanceKey?: string | null;
|
|
246
|
+
instanceStatus?: FieldDocInstanceStatusEnum | null;
|
|
247
|
+
instanceClosedAt?: Date | null;
|
|
248
|
+
// The person whose action created the row; a PER_INSTANCE job is edited only by them or an org manager
|
|
249
|
+
createdByAccountId?: number | bigint | null;
|
|
250
|
+
activityAt: Date;
|
|
251
|
+
createdAt: Date;
|
|
252
|
+
updatedAt: Date;
|
|
179
253
|
}
|
|
180
254
|
|
|
181
|
-
|
|
182
|
-
|
|
255
|
+
// One submission list row: the submission joined to its pinned revision, doc, program, organizations and site (no answers)
|
|
256
|
+
export interface FieldDocSubmissionRow {
|
|
257
|
+
id: number | bigint;
|
|
258
|
+
fieldDocId: number | bigint;
|
|
259
|
+
programId: number;
|
|
260
|
+
programName: string;
|
|
261
|
+
programShortName: string | null;
|
|
262
|
+
isProgramDoc: boolean;
|
|
263
|
+
definitionRevisionId: number | bigint;
|
|
264
|
+
organizationId: number | bigint;
|
|
265
|
+
organizationName: string | null;
|
|
266
|
+
childOrgId: number | bigint | null;
|
|
267
|
+
childOrgName: string | null;
|
|
268
|
+
siteId: number | bigint | null;
|
|
269
|
+
location: string | null;
|
|
270
|
+
documentName: string; // From the pinned revision
|
|
271
|
+
title: string; // From the pinned revision
|
|
272
|
+
frequency: FieldDocFrequencyEnum; // From the pinned revision
|
|
273
|
+
period: string; // period::text (YYYY-MM-DD); never a Date, because deno-postgres binds Dates in local time
|
|
274
|
+
status: FieldDocSubmissionStatusEnum | null;
|
|
275
|
+
statusOverridden: boolean;
|
|
276
|
+
summary: string | null;
|
|
277
|
+
identifierHint: string | null;
|
|
278
|
+
instanceKey: string | null;
|
|
279
|
+
instanceStatus: FieldDocInstanceStatusEnum | null;
|
|
280
|
+
instanceClosedAt: Date | null;
|
|
281
|
+
activityAt: Date;
|
|
282
|
+
createdAt: Date;
|
|
283
|
+
updatedAt: Date;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// One submission document: the list row, the pinned raw definition with the stored answers, and the rendered aside.
|
|
287
|
+
// Org-agnostic (no custom-instruction overlay); the caller authorizes.
|
|
288
|
+
export interface FieldDocDocumentData {
|
|
289
|
+
submission: FieldDocSubmissionRow;
|
|
290
|
+
fieldDoc: FieldDocData; // The pinned revision with raw elements attached; fieldDoc.submission holds the stored answers
|
|
291
|
+
aside: FieldDocAsideBlockObj[];
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* FieldDoc GraphQL data
|
|
296
|
+
*/
|
|
297
|
+
|
|
298
|
+
// Each key is null when absent from the program layout
|
|
299
|
+
export interface FieldDocProgramLayoutGQL {
|
|
300
|
+
columns: string[] | null;
|
|
301
|
+
headers: (string | null)[] | null;
|
|
302
|
+
gridLayoutStyle: string | null;
|
|
303
|
+
}
|
|
183
304
|
|
|
305
|
+
export interface FieldDocProgramGroupGQL {
|
|
184
306
|
id: string;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
307
|
+
fieldDocProgramId: string;
|
|
308
|
+
name: string;
|
|
309
|
+
order: number;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Org-agnostic; id = programId
|
|
313
|
+
export interface FieldDocProgramGQL {
|
|
314
|
+
groups: FieldDocProgramGroupGQL[];
|
|
315
|
+
id: string;
|
|
316
|
+
isCatalog: boolean;
|
|
317
|
+
name: string;
|
|
318
|
+
shortName: string | null;
|
|
319
|
+
description: string | null;
|
|
320
|
+
categoryKey: FieldDocCategoryKey;
|
|
321
|
+
operations: string[];
|
|
322
|
+
layout: FieldDocProgramLayoutGQL;
|
|
323
|
+
retired: boolean;
|
|
324
|
+
}
|
|
197
325
|
|
|
198
|
-
|
|
199
|
-
|
|
326
|
+
// Enrollment-local activity; fieldDocId references the shared form without normalizing this value into it.
|
|
327
|
+
export interface FieldDocSubmissionUpdateGQL {
|
|
328
|
+
fieldDocId: string;
|
|
329
|
+
lastSubmissionUpdatedAt: string | null;
|
|
200
330
|
}
|
|
201
331
|
|
|
202
|
-
|
|
332
|
+
// Per organization; id = "<orgGenericId>:<programGenericId>"
|
|
333
|
+
export interface FieldDocProgramEnrollmentGQL {
|
|
203
334
|
id: string;
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
335
|
+
organizationId: string;
|
|
336
|
+
program: FieldDocProgramGQL;
|
|
337
|
+
archivedAt: string | null; // ISO date string
|
|
338
|
+
restorableUntil: string | null; // ISO date string
|
|
339
|
+
forms: FieldDocGQL[];
|
|
340
|
+
fieldDocSubmissionUpdates: FieldDocSubmissionUpdateGQL[];
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// The form; org-agnostic; id = fieldDocId
|
|
344
|
+
export interface FieldDocGQL {
|
|
345
|
+
group: FieldDocProgramGroupGQL | null;
|
|
346
|
+
order: number;
|
|
347
|
+
id: string;
|
|
348
|
+
fieldDocProgramId: string;
|
|
349
|
+
documentName: string;
|
|
350
|
+
title: string;
|
|
351
|
+
draftTitle: string | null;
|
|
352
|
+
description: string | null;
|
|
353
|
+
frequency: FieldDocFrequencyEnum;
|
|
354
|
+
isProgramDoc: boolean;
|
|
355
|
+
retired: boolean;
|
|
356
|
+
published: boolean;
|
|
357
|
+
publishedRevisionNumber: number | null;
|
|
358
|
+
hasDraft: boolean;
|
|
208
359
|
}
|
|
209
360
|
|
|
361
|
+
// id = submissionId; the one shared fragment for list rows and the document header
|
|
210
362
|
export interface FieldDocSubmissionGQL {
|
|
211
363
|
__deleted?: boolean;
|
|
212
364
|
|
|
213
365
|
id: string;
|
|
214
|
-
|
|
366
|
+
cursor: string;
|
|
367
|
+
readableId: string;
|
|
215
368
|
fieldDocId: string;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
369
|
+
fieldDocProgramId: string;
|
|
370
|
+
programName: string;
|
|
371
|
+
programShortName: string | null;
|
|
372
|
+
isProgramDoc: boolean;
|
|
373
|
+
definitionRevisionId: string;
|
|
219
374
|
organizationId: string;
|
|
220
|
-
|
|
221
|
-
location?: string | null;
|
|
375
|
+
organizationName: string | null;
|
|
222
376
|
childOrgId: string | null;
|
|
223
|
-
childOrgIdEnc?: string | null;
|
|
224
377
|
childOrgName: string | null;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
groupShortName?: string | null;
|
|
378
|
+
siteId: string | null;
|
|
379
|
+
location: string | null;
|
|
380
|
+
documentName: string;
|
|
381
|
+
title: string;
|
|
382
|
+
frequency: FieldDocFrequencyEnum;
|
|
231
383
|
period: string; // YYYY-MM-DD
|
|
232
384
|
status: FieldDocSubmissionStatusEnum | null;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
385
|
+
statusOverridden: boolean;
|
|
386
|
+
summary: string | null;
|
|
387
|
+
identifierHint: string | null;
|
|
388
|
+
instanceKey: string | null;
|
|
389
|
+
instanceStatus: FieldDocInstanceStatusEnum | null;
|
|
390
|
+
instanceClosedAt: string | null; // ISO date string
|
|
391
|
+
activityAt: string; // ISO date string
|
|
392
|
+
createdAt: string; // ISO date string
|
|
393
|
+
updatedAt: string; // ISO date string
|
|
236
394
|
}
|
|
237
395
|
|
|
238
|
-
export interface
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
396
|
+
export interface FieldDocSubmissionMetadataGQL {
|
|
397
|
+
id: string;
|
|
398
|
+
title: string;
|
|
399
|
+
description: string | null;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// id = submissionId
|
|
403
|
+
export interface FieldDocSubmissionDocumentGQL {
|
|
404
|
+
id: string;
|
|
405
|
+
submission: FieldDocSubmissionGQL;
|
|
406
|
+
description: string | null;
|
|
407
|
+
definition: FieldDocDefinitionGQL;
|
|
408
|
+
answers: FieldDocAnswerGQL[]; // One entry per answer-bearing key, UNANSWERED included
|
|
409
|
+
aside: FieldDocAsideBlockGQL[];
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
export interface FieldDocAsideBlockGQL {
|
|
413
|
+
title: string | null;
|
|
414
|
+
nullText: string | null;
|
|
415
|
+
items: FieldDocAsideItemGQL[];
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export interface FieldDocAsideItemGQL {
|
|
419
|
+
className: string | null;
|
|
420
|
+
label: string | null;
|
|
421
|
+
text: string | null;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// id = revisionId; immutable and carries no hints
|
|
425
|
+
export interface FieldDocDefinitionGQL {
|
|
426
|
+
id: string;
|
|
427
|
+
fieldDocId: string;
|
|
428
|
+
revisionNumber: number;
|
|
429
|
+
title: string;
|
|
430
|
+
description: string | null;
|
|
431
|
+
sections: FieldDocDefinitionSectionGQL[];
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// id = getFieldDocDefinitionElementId(revisionGenericId, sectionKey)
|
|
435
|
+
export interface FieldDocDefinitionSectionGQL {
|
|
436
|
+
id: string;
|
|
437
|
+
key: string;
|
|
438
|
+
title: string | null;
|
|
439
|
+
description: string | null;
|
|
440
|
+
elements: FieldDocDefinitionElementGQL[];
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// id = getFieldDocDefinitionElementId(revisionGenericId, key)
|
|
444
|
+
export interface FieldDocDefinitionElementGQL {
|
|
445
|
+
id: string;
|
|
446
|
+
key: string;
|
|
447
|
+
kind: FieldDocElementKindEnum;
|
|
448
|
+
label: string | null;
|
|
449
|
+
description: string | null;
|
|
450
|
+
options: string[] | null;
|
|
451
|
+
required: boolean;
|
|
452
|
+
allowMultipleAnswers: boolean;
|
|
453
|
+
doNotAllowNotes: boolean;
|
|
454
|
+
answerType: FieldDocAnswerType | null;
|
|
455
|
+
tableColumns: FieldDocTableColumnGQL[] | null;
|
|
456
|
+
lineNumber: string | null;
|
|
457
|
+
files?: StorageGQL[]; // Element images; the document query selects them beside the element fragment
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// id = getFieldDocAnswerId(submissionGenericId, key)
|
|
461
|
+
export interface FieldDocAnswerGQL {
|
|
462
|
+
id: string;
|
|
463
|
+
key: string;
|
|
464
|
+
text: string | null; // The formatted answer value
|
|
465
|
+
tableRows: FieldDocTableRowGQL[] | null; // Null when the answer is incompatible with the pinned columns (show text)
|
|
466
|
+
answerState: FieldDocAnswerState;
|
|
467
|
+
answerReason: string | null;
|
|
468
|
+
note: string | null;
|
|
469
|
+
warningNote: string | null;
|
|
470
|
+
referenceIds: string[];
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export interface FieldDocTableColumnGQL {
|
|
474
|
+
key: string;
|
|
475
|
+
label: string;
|
|
476
|
+
type: FieldDocScalarAnswerType;
|
|
477
|
+
required?: boolean | null;
|
|
478
|
+
options?: string[] | null;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export interface FieldDocTableRowGQL {
|
|
482
|
+
id: string;
|
|
483
|
+
cells: FieldDocTableCellGQL[];
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
export interface FieldDocTableCellGQL {
|
|
487
|
+
key: string;
|
|
488
|
+
text: string | null;
|
|
489
|
+
isCustomBooleanLabel?: boolean | null; // Authored labels remain literal, including labels spelled Yes or No
|
|
256
490
|
}
|
|
257
491
|
|
|
258
492
|
/**
|
|
259
|
-
*
|
|
493
|
+
* FieldDoc program mutations (GraphQL input shapes)
|
|
260
494
|
*/
|
|
261
495
|
|
|
496
|
+
export interface CreateFieldDocProgramInputObj {
|
|
497
|
+
organizationId: string;
|
|
498
|
+
name: string;
|
|
499
|
+
shortName?: string | null;
|
|
500
|
+
description?: string | null;
|
|
501
|
+
categoryKey: FieldDocCategoryKey;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// Custom programs only; omitted keys keep their values
|
|
505
|
+
export interface EditFieldDocProgramInputObj {
|
|
506
|
+
organizationId: string;
|
|
507
|
+
fieldDocProgramId: string;
|
|
508
|
+
name?: string | null;
|
|
509
|
+
shortName?: string | null;
|
|
510
|
+
description?: string | null;
|
|
511
|
+
categoryKey?: FieldDocCategoryKey | null;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// Null or blank instructions delete the key's instructions
|
|
515
|
+
export interface FieldDocCustomInstructionInputObj {
|
|
516
|
+
elementKey: string; // An element key, or FIELD_DOC_DOCUMENT_INSTRUCTIONS_KEY
|
|
517
|
+
instructions?: string | null;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export interface EditFieldDocCustomInstructionsInputObj {
|
|
521
|
+
organizationId: string;
|
|
522
|
+
fieldDocId: string;
|
|
523
|
+
items: FieldDocCustomInstructionInputObj[];
|
|
524
|
+
}
|
|
525
|
+
|
|
262
526
|
/**
|
|
263
|
-
* FieldDoc
|
|
527
|
+
* FieldDoc web editor (draft and publication)
|
|
264
528
|
*/
|
|
265
529
|
|
|
266
|
-
|
|
530
|
+
// DEFINITION edits a custom doc's draft or publication; CUSTOM_INSTRUCTIONS edits an organization's instructions for a program doc
|
|
531
|
+
export type FieldDocEditSessionModeEnum = 'DEFINITION' | 'CUSTOM_INSTRUCTIONS';
|
|
532
|
+
export type FieldDocEditorElementKindEnum = Exclude<FieldDocElementKindEnum, 'SECTION'>;
|
|
533
|
+
|
|
534
|
+
// One question-side element of an editor definition; the same shape as the authoring draft contract
|
|
535
|
+
export interface FieldDocEditorElementObj {
|
|
536
|
+
key: string;
|
|
537
|
+
kind: FieldDocEditorElementKindEnum;
|
|
538
|
+
label?: string | null;
|
|
539
|
+
description?: string | null;
|
|
540
|
+
hint?: string | null;
|
|
541
|
+
options?: string[] | null;
|
|
542
|
+
required: boolean;
|
|
543
|
+
settings?: FieldDocElementSettingsObj | null;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
export interface FieldDocEditorSectionObj {
|
|
547
|
+
key: string;
|
|
548
|
+
label?: string | null;
|
|
549
|
+
description?: string | null;
|
|
550
|
+
hint?: string | null;
|
|
551
|
+
elements: FieldDocEditorElementObj[];
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// The editable definition: the draft snapshot when one exists, otherwise the current publication
|
|
555
|
+
export interface FieldDocEditorDefinitionObj {
|
|
556
|
+
// Tool-authored metadata stays in the shared draft until publication; frontend patches preserve it.
|
|
557
|
+
documentName?: string;
|
|
558
|
+
frequency?: FieldDocFrequencyEnum;
|
|
559
|
+
title: string;
|
|
560
|
+
description?: string | null;
|
|
561
|
+
agentHint?: string | null;
|
|
562
|
+
sections: FieldDocEditorSectionObj[];
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// Stored in field_doc_drafts.snapshot
|
|
566
|
+
export interface FieldDocDraftSnapshotObj extends FieldDocEditorDefinitionObj {
|
|
567
|
+
schemaVersion: 1;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
export interface FieldDocDraftData {
|
|
571
|
+
__table?: 'field_doc_drafts';
|
|
572
|
+
fieldDocId: number | bigint;
|
|
573
|
+
editVersion: number | bigint; // Database-allocated token; never repeats when a draft is discarded and recreated
|
|
574
|
+
baseRevisionId: number | bigint | null; // Null until the form's first publication
|
|
575
|
+
createKey?: string | null; // Retried tool creation keeps one form; transferred to its first publication
|
|
576
|
+
snapshot: FieldDocDraftSnapshotObj;
|
|
577
|
+
updatedByAccountId?: number | bigint | null;
|
|
578
|
+
updatedAt: Date;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// id = "<orgGenericId>:<fieldDocGenericId>"
|
|
582
|
+
export interface FieldDocEditorSourceGQL {
|
|
583
|
+
group: FieldDocProgramGroupGQL | null;
|
|
584
|
+
order: number;
|
|
585
|
+
id: string;
|
|
586
|
+
fieldDocId: string;
|
|
587
|
+
organizationId: string;
|
|
588
|
+
fieldDocProgramId: string;
|
|
589
|
+
isProgramDoc: boolean;
|
|
590
|
+
documentName: string;
|
|
591
|
+
frequency: FieldDocFrequencyEnum;
|
|
592
|
+
editVersion: number; // 0 when the form has no draft
|
|
593
|
+
hasDraft: boolean;
|
|
594
|
+
draftStale: boolean; // A newer definition was published after the draft started
|
|
595
|
+
publishedRevisionNumber?: number | null;
|
|
596
|
+
draftUpdatedAt?: string | null;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// DEFINITION: the draft or publication; CUSTOM_INSTRUCTIONS: the publication with raw program hints
|
|
600
|
+
export interface FieldDocEditorGQL {
|
|
601
|
+
definition: FieldDocEditorDefinitionObj;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
export interface FieldDocCustomInstructionGQL {
|
|
605
|
+
elementKey: string; // An element key, or FIELD_DOC_DOCUMENT_INSTRUCTIONS_KEY
|
|
606
|
+
instructions: string;
|
|
607
|
+
updatedAt: string | null; // ISO date string
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// id = "<orgGenericId>:<fieldDocGenericId>"
|
|
611
|
+
export interface FieldDocEditSessionGQL {
|
|
267
612
|
id: string;
|
|
613
|
+
organizationId: string;
|
|
614
|
+
mode: FieldDocEditSessionModeEnum;
|
|
615
|
+
fieldDoc: FieldDocEditorSourceGQL;
|
|
616
|
+
editor: FieldDocEditorGQL;
|
|
617
|
+
customInstructions: FieldDocCustomInstructionGQL[];
|
|
618
|
+
manageable: boolean;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
export interface FieldDocDefinitionSectionInputObj {
|
|
622
|
+
key: string;
|
|
623
|
+
order: number;
|
|
624
|
+
label: string;
|
|
625
|
+
description?: string | null;
|
|
626
|
+
hint?: string | null;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
export interface FieldDocDefinitionQuestionInputObj {
|
|
630
|
+
key: string;
|
|
631
|
+
parentKey: string;
|
|
632
|
+
order: number;
|
|
633
|
+
kind: FieldDocEditorElementKindEnum;
|
|
634
|
+
label?: string | null;
|
|
635
|
+
description?: string | null;
|
|
636
|
+
hint?: string | null;
|
|
637
|
+
options?: string[] | null;
|
|
638
|
+
required?: boolean | null;
|
|
639
|
+
settings?: FieldDocElementSettingsObj | null;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
export type FieldDocDefinitionNodeInputObj =
|
|
643
|
+
| { section: FieldDocDefinitionSectionInputObj; question?: never }
|
|
644
|
+
| { question: FieldDocDefinitionQuestionInputObj; section?: never };
|
|
645
|
+
|
|
646
|
+
export interface FieldDocDefinitionPatchInputObj {
|
|
647
|
+
upsertNodes?: FieldDocDefinitionNodeInputObj[] | null;
|
|
648
|
+
deleteNodeKeys?: string[] | null;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
export interface FieldDocEditorMetadataPatchInputObj {
|
|
652
|
+
title?: string | null;
|
|
653
|
+
description?: string | null;
|
|
654
|
+
agentHint?: string | null;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
export interface FieldDocEditorPatchInputObj {
|
|
658
|
+
metadata?: FieldDocEditorMetadataPatchInputObj | null;
|
|
659
|
+
definition?: FieldDocDefinitionPatchInputObj | null;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
export interface EditFieldDocInputObj {
|
|
663
|
+
organizationId: string;
|
|
664
|
+
fieldDocId: string;
|
|
665
|
+
expectedEditVersion: number; // 0 creates the draft from the current publication
|
|
666
|
+
patch: FieldDocEditorPatchInputObj;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
export type FieldDocSettingsCommandInputObj =
|
|
670
|
+
| { publish: { expectedEditVersion: number }; resetDraft?: never }
|
|
671
|
+
| { resetDraft: { expectedEditVersion: number }; publish?: never };
|
|
672
|
+
|
|
673
|
+
export interface EditFieldDocSettingsInputObj {
|
|
674
|
+
organizationId: string;
|
|
675
|
+
fieldDocId: string;
|
|
676
|
+
command: FieldDocSettingsCommandInputObj;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Program grouping and form placement (independent of definition publication).
|
|
681
|
+
*/
|
|
682
|
+
export interface CreateFieldDocProgramGroupInputObj {
|
|
683
|
+
organizationId: string;
|
|
684
|
+
fieldDocProgramId: string;
|
|
268
685
|
name: string;
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
686
|
+
order?: number | null;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
export interface EditFieldDocProgramGroupInputObj {
|
|
690
|
+
organizationId: string;
|
|
691
|
+
groupId: string;
|
|
692
|
+
name?: string | null;
|
|
693
|
+
order?: number | null;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
export interface EditFieldDocPlacementInputObj {
|
|
697
|
+
organizationId: string;
|
|
698
|
+
fieldDocId: string;
|
|
699
|
+
// Omitted preserves placement; explicit null ungroups the form.
|
|
700
|
+
groupId?: string | null;
|
|
701
|
+
order?: number | null;
|
|
273
702
|
}
|