@case-framework/survey-assistant 0.2.3 → 0.4.0
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/README.md +12 -4
- package/dist/{authoring-references-ChDTVnms.mjs → authoring-references-yyYC4Ydi.mjs} +2 -2
- package/dist/{authoring-references-ChDTVnms.mjs.map → authoring-references-yyYC4Ydi.mjs.map} +1 -1
- package/dist/capabilities-default.d.mts +1 -1
- package/dist/capabilities-default.mjs +1 -1
- package/dist/{constants-BK1-g6pR.d.mts → constants-k1b_evIb.d.mts} +7 -4
- package/dist/constants-k1b_evIb.d.mts.map +1 -0
- package/dist/{controller-proxy-DY36XFV3.mjs → controller-proxy-jWIPOZAv.mjs} +18 -8
- package/dist/controller-proxy-jWIPOZAv.mjs.map +1 -0
- package/dist/{controller-proxy-CIDRd8Wu.d.mts → controller-proxy-quQjtA7j.d.mts} +5 -2
- package/dist/controller-proxy-quQjtA7j.d.mts.map +1 -0
- package/dist/{engine-CWTuN3o2.mjs → engine-BvfUx_Jx.mjs} +85 -12
- package/dist/engine-BvfUx_Jx.mjs.map +1 -0
- package/dist/engine.d.mts +2 -2
- package/dist/engine.mjs +3 -3
- package/dist/{form-authoring-DCd9XfXf.mjs → form-authoring-BQh40yDb.mjs} +2 -2
- package/dist/{form-authoring-DCd9XfXf.mjs.map → form-authoring-BQh40yDb.mjs.map} +1 -1
- package/dist/index-8x1Eqlnz.d.mts +741 -0
- package/dist/index-8x1Eqlnz.d.mts.map +1 -0
- package/dist/{index-SPHf3OoJ.d.mts → index-BDp6S7r9.d.mts} +14 -5
- package/dist/index-BDp6S7r9.d.mts.map +1 -0
- package/dist/{index-Bp5W_oPa.d.mts → index-biZnRl-h.d.mts} +26 -24
- package/dist/index-biZnRl-h.d.mts.map +1 -0
- package/dist/{index-CPOQgkTN.d.mts → index-r8HVcn5b.d.mts} +9 -4
- package/dist/index-r8HVcn5b.d.mts.map +1 -0
- package/dist/lifecycle-DWv5CiSu.d.mts +523 -0
- package/dist/lifecycle-DWv5CiSu.d.mts.map +1 -0
- package/dist/{memory-thread-repository-acbz6HZJ.mjs → memory-thread-repository-xBZOog_q.mjs} +49 -21
- package/dist/memory-thread-repository-xBZOog_q.mjs.map +1 -0
- package/dist/{protocol-DATvkr1S.mjs → protocol-DJUP4gc0.mjs} +10 -4
- package/dist/protocol-DJUP4gc0.mjs.map +1 -0
- package/dist/protocol.d.mts +2 -1
- package/dist/protocol.mjs +1 -1
- package/dist/{react-3kSE6WtS.mjs → react-CY6N7lVi.mjs} +30 -8
- package/dist/react-CY6N7lVi.mjs.map +1 -0
- package/dist/react-integration.d.mts +1 -1
- package/dist/react-integration.mjs +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.mjs +2 -2
- package/dist/{request-context-BEjnaaFr.mjs → request-context-DixY5DYu.mjs} +3 -3
- package/dist/request-context-DixY5DYu.mjs.map +1 -0
- package/dist/server-agent.d.mts +26 -24
- package/dist/server-agent.d.mts.map +1 -1
- package/dist/server-agent.mjs +7 -6
- package/dist/server-agent.mjs.map +1 -1
- package/dist/server-runtime.d.mts +341 -8
- package/dist/server-runtime.d.mts.map +1 -1
- package/dist/server-runtime.mjs +321 -23
- package/dist/server-runtime.mjs.map +1 -1
- package/dist/server-tasks.d.mts +1 -1
- package/dist/server-tasks.mjs +8 -6
- package/dist/server-tasks.mjs.map +1 -1
- package/dist/server-tools.d.mts +1 -1
- package/dist/server-tools.mjs +1 -1
- package/dist/server.d.mts +8 -8
- package/dist/server.d.mts.map +1 -1
- package/dist/server.mjs +3 -3
- package/dist/storage-postgres.d.mts +1 -1
- package/dist/{tasks-DIZgr4nD.d.mts → tasks-BWmTMXoK.d.mts} +3 -3
- package/dist/{tasks-DIZgr4nD.d.mts.map → tasks-BWmTMXoK.d.mts.map} +1 -1
- package/dist/{thread-documents-C3kf0Vds.d.mts → thread-documents-Dvo6XS7o.d.mts} +1 -1
- package/dist/{thread-documents-C3kf0Vds.d.mts.map → thread-documents-Dvo6XS7o.d.mts.map} +1 -1
- package/dist/{thread-handlers-DZ1WsorO.d.mts → thread-handlers-D8gkLfU6.d.mts} +15 -7
- package/dist/{thread-handlers-DZ1WsorO.d.mts.map → thread-handlers-D8gkLfU6.d.mts.map} +1 -1
- package/dist/{tools-GDd5_GUh.mjs → tools-TXI8bfzZ.mjs} +28 -9
- package/dist/tools-TXI8bfzZ.mjs.map +1 -0
- package/dist/ui.css +2 -2
- package/dist/ui.d.mts +94 -10
- package/dist/ui.d.mts.map +1 -1
- package/dist/ui.mjs +561 -203
- package/dist/ui.mjs.map +1 -1
- package/docs/integration.md +84 -63
- package/package.json +25 -19
- package/dist/constants-BK1-g6pR.d.mts.map +0 -1
- package/dist/controller-proxy-CIDRd8Wu.d.mts.map +0 -1
- package/dist/controller-proxy-DY36XFV3.mjs.map +0 -1
- package/dist/engine-CWTuN3o2.mjs.map +0 -1
- package/dist/index-Bp5W_oPa.d.mts.map +0 -1
- package/dist/index-CPOQgkTN.d.mts.map +0 -1
- package/dist/index-EDL1V168.d.mts +0 -1257
- package/dist/index-EDL1V168.d.mts.map +0 -1
- package/dist/index-SPHf3OoJ.d.mts.map +0 -1
- package/dist/memory-thread-repository-acbz6HZJ.mjs.map +0 -1
- package/dist/protocol-DATvkr1S.mjs.map +0 -1
- package/dist/react-3kSE6WtS.mjs.map +0 -1
- package/dist/request-context-BEjnaaFr.mjs.map +0 -1
- package/dist/tools-GDd5_GUh.mjs.map +0 -1
package/dist/engine.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { n as hashString, r as stableStringify, t as buildCapabilityDigest } from "./digest-Dyjch_sC.mjs";
|
|
2
|
-
import { $ as getRawSurveyItems, A as FormFieldGroupDetails, At as
|
|
3
|
-
export { AssistantCapabilityReference, AssistantItemCapabilityAdapter, AssistantItemCreationResolution, AssistantItemInspection, BuildSurveyAssistantTaskContextOptions, ChoiceOptionDetails, CreateSurveyAssistantEngineContextOptions, DEFAULT_LIMIT, ExpressionMutation, FormAuthoringMode, FormFieldDetails, FormFieldGroupDetails, ItemConfigDetails, ItemSummary, MAX_LIMIT, MAX_SURVEY_ASSISTANT_OPERATIONS_PER_PROPOSAL, MAX_SURVEY_ASSISTANT_OPERATIONS_PER_TURN_DRAFT, ResponseSlotTypeLookup, SurveyAssistantCapabilityMismatchError, SurveyAssistantCapabilitySet, SurveyAssistantEngineContext, SurveyAssistantInspectionFocus, SurveyAssistantInspectionIndex, SurveyAssistantInspectionItemNode, SurveyAssistantInspectionKeyEntry, SurveyAssistantInspectionOutlineNode, SurveyAssistantResponseSlotTypes, SurveyAssistantTaskPurpose, SurveyAssistantTaskResultCache, SurveyAssistantTaskResultCacheOptions, SurveyAuditCategory, SurveyAuditFinding, SurveyAuditReport, SurveyAuditSeverity, SurveyFocusItemNode, SurveyInspectionIndex, SurveyKeyIndexEntry, SurveyOutlineNode, SurveyQualityReviewPrinciple, TranslationEntry, TurnSurveyDraft, applyValidatedSurveyOperationsToDraft, assertSurveyAssistantCapabilities, auditSurvey, buildCapabilityDigest, buildConfigSearchText, buildEmbeddedFormDetails, buildExpressionMutationPatches, buildItemConfigDetails, buildItemTranslationEntries, buildSurveyAssistantTaskContext, buildSurveyDocumentVersion, buildSurveyTranslations, choiceOptionDetailsSchema, clampLimit, createSurveyAssistantCapabilities, createSurveyAssistantEngineContext, createSurveyChangeSet, createUnsupportedItemCapability, deriveResponseSlotTypes, expressionMutationSchema, expressionSchema, findDirectChildrenByFullKey, formFieldDetailsSchema, formFieldGroupDetailsSchema, formFieldGroupLayoutSchema, formSelectOptionDetailsSchema, getDeterministicCreateItemTypes, getFormAuthoringMode, getKeyIndexEntries, getRawSurvey, getRawSurveyItems, hasSingleFormField, hashString, inferExpressionReturnType, inspectAssistantItem, isCompatibleSimpleFieldUpsert, isValidSimpleFormConfig, itemConfigDetailsSchema, itemMatchesQuery, itemSummarySchema, mapKeyIndexById, mapOutlineById, mapRawItemsById, normalizeFormAuthoringConfig, normalizeSurveyChangeOperations, normalizeText, parseCursor, resolveAssistantCapabilityReference, resolveAssistantItemCreation, resolveItemSummary, sliceWithCursor, stableStringify, summarizeFocusItemNode, summarizeItemById, summarizeKeyIndexEntries, summarizeKeyIndexEntry, summarizeOutlineNode, summarizeRawItem, transitionFormAuthoringMode, translationEntrySchema, unique, validateExpression, validateSurveyOperations };
|
|
2
|
+
import { $ as getRawSurveyItems, A as FormFieldGroupDetails, At as SurveyAssistantInspectionIndex, B as buildEmbeddedFormDetails, Bt as AssistantItemInspection, C as buildSurveyDocumentVersion, Ct as deriveSurveyExpressionResponseSlots, D as ChoiceOptionDetails, Dt as CreateSurveyAssistantEngineContextOptions, E as normalizeSurveyChangeOperations, Et as validateExpression, F as SurveyInspectionIndex, Ft as createSurveyAssistantEngineContext, G as clampLimit, Gt as createUnsupportedItemCapability, H as buildItemTranslationEntries, Ht as SurveyAssistantCapabilitySet, I as SurveyKeyIndexEntry, It as deriveResponseSlotTypes, J as formFieldGroupDetailsSchema, Jt as resolveAssistantCapabilityReference, K as findDirectChildrenByFullKey, Kt as getDeterministicCreateItemTypes, L as SurveyOutlineNode, Lt as AssistantCapabilityReference, M as ItemSummary, Mt as SurveyAssistantInspectionKeyEntry, N as MAX_LIMIT, Nt as SurveyAssistantInspectionOutlineNode, O as DEFAULT_LIMIT, Ot as SurveyAssistantEngineContext, P as SurveyFocusItemNode, Pt as SurveyAssistantResponseSlotTypes, Q as getRawSurvey, R as TranslationEntry, Rt as AssistantItemCapabilityAdapter, S as applyValidatedSurveyOperationsToDraft, St as analyzeSurveyAssistantExpressionReferences, T as validateSurveyOperations, Tt as inferExpressionReturnType, U as buildSurveyTranslations, Ut as assertSurveyAssistantCapabilities, V as buildItemConfigDetails, Vt as SurveyAssistantCapabilityMismatchError, W as choiceOptionDetailsSchema, Wt as createSurveyAssistantCapabilities, X as formSelectOptionDetailsSchema, Y as formFieldGroupLayoutSchema, Yt as resolveAssistantItemCreation, Z as getKeyIndexEntries, _ as SurveyAssistantTaskPurpose, _t as unique, a as SurveyQualityReviewPrinciple, at as mapRawItemsById, b as MAX_SURVEY_ASSISTANT_OPERATIONS_PER_PROPOSAL, bt as expressionMutationSchema, c as getFormAuthoringMode, ct as resolveItemSummary, d as isValidSimpleFormConfig, dt as summarizeItemById, et as itemConfigDetailsSchema, f as normalizeFormAuthoringConfig, ft as summarizeKeyIndexEntries, g as BuildSurveyAssistantTaskContextOptions, gt as translationEntrySchema, h as SurveyAssistantTaskResultCacheOptions, ht as summarizeRawItem, i as SurveyAuditSeverity, it as mapOutlineById, j as ItemConfigDetails, jt as SurveyAssistantInspectionItemNode, k as FormFieldDetails, kt as SurveyAssistantInspectionFocus, l as hasSingleFormField, lt as sliceWithCursor, m as SurveyAssistantTaskResultCache, mt as summarizeOutlineNode, n as SurveyAuditFinding, nt as itemSummarySchema, o as auditSurvey, ot as normalizeText, p as transitionFormAuthoringMode, pt as summarizeKeyIndexEntry, q as formFieldDetailsSchema, qt as inspectAssistantItem, r as SurveyAuditReport, rt as mapKeyIndexById, s as FormAuthoringMode, st as parseCursor, t as SurveyAuditCategory, tt as itemMatchesQuery, u as isCompatibleSimpleFieldUpsert, ut as summarizeFocusItemNode, v as buildSurveyAssistantTaskContext, vt as ExpressionMutation, w as createSurveyChangeSet, wt as ResponseSlotTypeLookup, x as MAX_SURVEY_ASSISTANT_OPERATIONS_PER_TURN_DRAFT, xt as expressionSchema, y as TurnSurveyDraft, yt as buildExpressionMutationPatches, z as buildConfigSearchText, zt as AssistantItemCreationResolution } from "./index-r8HVcn5b.mjs";
|
|
3
|
+
export { AssistantCapabilityReference, AssistantItemCapabilityAdapter, AssistantItemCreationResolution, AssistantItemInspection, BuildSurveyAssistantTaskContextOptions, ChoiceOptionDetails, CreateSurveyAssistantEngineContextOptions, DEFAULT_LIMIT, ExpressionMutation, FormAuthoringMode, FormFieldDetails, FormFieldGroupDetails, ItemConfigDetails, ItemSummary, MAX_LIMIT, MAX_SURVEY_ASSISTANT_OPERATIONS_PER_PROPOSAL, MAX_SURVEY_ASSISTANT_OPERATIONS_PER_TURN_DRAFT, ResponseSlotTypeLookup, SurveyAssistantCapabilityMismatchError, SurveyAssistantCapabilitySet, SurveyAssistantEngineContext, SurveyAssistantInspectionFocus, SurveyAssistantInspectionIndex, SurveyAssistantInspectionItemNode, SurveyAssistantInspectionKeyEntry, SurveyAssistantInspectionOutlineNode, SurveyAssistantResponseSlotTypes, SurveyAssistantTaskPurpose, SurveyAssistantTaskResultCache, SurveyAssistantTaskResultCacheOptions, SurveyAuditCategory, SurveyAuditFinding, SurveyAuditReport, SurveyAuditSeverity, SurveyFocusItemNode, SurveyInspectionIndex, SurveyKeyIndexEntry, SurveyOutlineNode, SurveyQualityReviewPrinciple, TranslationEntry, TurnSurveyDraft, analyzeSurveyAssistantExpressionReferences, applyValidatedSurveyOperationsToDraft, assertSurveyAssistantCapabilities, auditSurvey, buildCapabilityDigest, buildConfigSearchText, buildEmbeddedFormDetails, buildExpressionMutationPatches, buildItemConfigDetails, buildItemTranslationEntries, buildSurveyAssistantTaskContext, buildSurveyDocumentVersion, buildSurveyTranslations, choiceOptionDetailsSchema, clampLimit, createSurveyAssistantCapabilities, createSurveyAssistantEngineContext, createSurveyChangeSet, createUnsupportedItemCapability, deriveResponseSlotTypes, deriveSurveyExpressionResponseSlots, expressionMutationSchema, expressionSchema, findDirectChildrenByFullKey, formFieldDetailsSchema, formFieldGroupDetailsSchema, formFieldGroupLayoutSchema, formSelectOptionDetailsSchema, getDeterministicCreateItemTypes, getFormAuthoringMode, getKeyIndexEntries, getRawSurvey, getRawSurveyItems, hasSingleFormField, hashString, inferExpressionReturnType, inspectAssistantItem, isCompatibleSimpleFieldUpsert, isValidSimpleFormConfig, itemConfigDetailsSchema, itemMatchesQuery, itemSummarySchema, mapKeyIndexById, mapOutlineById, mapRawItemsById, normalizeFormAuthoringConfig, normalizeSurveyChangeOperations, normalizeText, parseCursor, resolveAssistantCapabilityReference, resolveAssistantItemCreation, resolveItemSummary, sliceWithCursor, stableStringify, summarizeFocusItemNode, summarizeItemById, summarizeKeyIndexEntries, summarizeKeyIndexEntry, summarizeOutlineNode, summarizeRawItem, transitionFormAuthoringMode, translationEntrySchema, unique, validateExpression, validateSurveyOperations };
|
package/dist/engine.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { buildCapabilityDigest, hashString, stableStringify } from "./digest.mjs";
|
|
2
|
-
import { a as normalizeFormAuthoringConfig, c as assertSurveyAssistantCapabilities, d as getDeterministicCreateItemTypes, f as inspectAssistantItem, i as isValidSimpleFormConfig, l as createSurveyAssistantCapabilities, m as resolveAssistantItemCreation, n as hasSingleFormField, o as transitionFormAuthoringMode, p as resolveAssistantCapabilityReference, r as isCompatibleSimpleFieldUpsert, s as SurveyAssistantCapabilityMismatchError, t as getFormAuthoringMode, u as createUnsupportedItemCapability } from "./form-authoring-
|
|
3
|
-
import { $ as
|
|
4
|
-
export { DEFAULT_LIMIT, MAX_LIMIT, MAX_SURVEY_ASSISTANT_OPERATIONS_PER_PROPOSAL, MAX_SURVEY_ASSISTANT_OPERATIONS_PER_TURN_DRAFT, SurveyAssistantCapabilityMismatchError, SurveyAssistantTaskResultCache, TurnSurveyDraft, applyValidatedSurveyOperationsToDraft, assertSurveyAssistantCapabilities, auditSurvey, buildCapabilityDigest, buildConfigSearchText, buildEmbeddedFormDetails, buildExpressionMutationPatches, buildItemConfigDetails, buildItemTranslationEntries, buildSurveyAssistantTaskContext, buildSurveyDocumentVersion, buildSurveyTranslations, choiceOptionDetailsSchema, clampLimit, createSurveyAssistantCapabilities, createSurveyAssistantEngineContext, createSurveyChangeSet, createUnsupportedItemCapability, deriveResponseSlotTypes, expressionMutationSchema, expressionSchema, findDirectChildrenByFullKey, formFieldDetailsSchema, formFieldGroupDetailsSchema, formFieldGroupLayoutSchema, formSelectOptionDetailsSchema, getDeterministicCreateItemTypes, getFormAuthoringMode, getKeyIndexEntries, getRawSurvey, getRawSurveyItems, hasSingleFormField, hashString, inferExpressionReturnType, inspectAssistantItem, isCompatibleSimpleFieldUpsert, isValidSimpleFormConfig, itemConfigDetailsSchema, itemMatchesQuery, itemSummarySchema, mapKeyIndexById, mapOutlineById, mapRawItemsById, normalizeFormAuthoringConfig, normalizeSurveyChangeOperations, normalizeText, parseCursor, resolveAssistantCapabilityReference, resolveAssistantItemCreation, resolveItemSummary, sliceWithCursor, stableStringify, summarizeFocusItemNode, summarizeItemById, summarizeKeyIndexEntries, summarizeKeyIndexEntry, summarizeOutlineNode, summarizeRawItem, transitionFormAuthoringMode, translationEntrySchema, unique, validateExpression, validateSurveyOperations };
|
|
2
|
+
import { a as normalizeFormAuthoringConfig, c as assertSurveyAssistantCapabilities, d as getDeterministicCreateItemTypes, f as inspectAssistantItem, i as isValidSimpleFormConfig, l as createSurveyAssistantCapabilities, m as resolveAssistantItemCreation, n as hasSingleFormField, o as transitionFormAuthoringMode, p as resolveAssistantCapabilityReference, r as isCompatibleSimpleFieldUpsert, s as SurveyAssistantCapabilityMismatchError, t as getFormAuthoringMode, u as createUnsupportedItemCapability } from "./form-authoring-BQh40yDb.mjs";
|
|
3
|
+
import { $ as validateExpression, A as getRawSurvey, B as resolveItemSummary, C as clampLimit, D as formFieldGroupLayoutSchema, E as formFieldGroupDetailsSchema, F as mapKeyIndexById, G as summarizeKeyIndexEntry, H as summarizeFocusItemNode, I as mapOutlineById, J as translationEntrySchema, K as summarizeOutlineNode, L as mapRawItemsById, M as itemConfigDetailsSchema, N as itemMatchesQuery, O as formSelectOptionDetailsSchema, P as itemSummarySchema, Q as inferExpressionReturnType, R as normalizeText, S as choiceOptionDetailsSchema, T as formFieldDetailsSchema, U as summarizeItemById, V as sliceWithCursor, W as summarizeKeyIndexEntries, X as analyzeSurveyAssistantExpressionReferences, Y as unique, Z as deriveSurveyExpressionResponseSlots, _ as buildConfigSearchText, a as MAX_SURVEY_ASSISTANT_OPERATIONS_PER_PROPOSAL, b as buildItemTranslationEntries, c as buildSurveyDocumentVersion, d as normalizeSurveyChangeOperations, et as createSurveyAssistantEngineContext, f as buildExpressionMutationPatches, g as MAX_LIMIT, h as DEFAULT_LIMIT, i as auditSurvey, j as getRawSurveyItems, k as getKeyIndexEntries, l as createSurveyChangeSet, m as expressionSchema, n as buildSurveyAssistantTaskContext, o as MAX_SURVEY_ASSISTANT_OPERATIONS_PER_TURN_DRAFT, p as expressionMutationSchema, q as summarizeRawItem, r as TurnSurveyDraft, s as applyValidatedSurveyOperationsToDraft, t as SurveyAssistantTaskResultCache, tt as deriveResponseSlotTypes, u as validateSurveyOperations, v as buildEmbeddedFormDetails, w as findDirectChildrenByFullKey, x as buildSurveyTranslations, y as buildItemConfigDetails, z as parseCursor } from "./engine-BvfUx_Jx.mjs";
|
|
4
|
+
export { DEFAULT_LIMIT, MAX_LIMIT, MAX_SURVEY_ASSISTANT_OPERATIONS_PER_PROPOSAL, MAX_SURVEY_ASSISTANT_OPERATIONS_PER_TURN_DRAFT, SurveyAssistantCapabilityMismatchError, SurveyAssistantTaskResultCache, TurnSurveyDraft, analyzeSurveyAssistantExpressionReferences, applyValidatedSurveyOperationsToDraft, assertSurveyAssistantCapabilities, auditSurvey, buildCapabilityDigest, buildConfigSearchText, buildEmbeddedFormDetails, buildExpressionMutationPatches, buildItemConfigDetails, buildItemTranslationEntries, buildSurveyAssistantTaskContext, buildSurveyDocumentVersion, buildSurveyTranslations, choiceOptionDetailsSchema, clampLimit, createSurveyAssistantCapabilities, createSurveyAssistantEngineContext, createSurveyChangeSet, createUnsupportedItemCapability, deriveResponseSlotTypes, deriveSurveyExpressionResponseSlots, expressionMutationSchema, expressionSchema, findDirectChildrenByFullKey, formFieldDetailsSchema, formFieldGroupDetailsSchema, formFieldGroupLayoutSchema, formSelectOptionDetailsSchema, getDeterministicCreateItemTypes, getFormAuthoringMode, getKeyIndexEntries, getRawSurvey, getRawSurveyItems, hasSingleFormField, hashString, inferExpressionReturnType, inspectAssistantItem, isCompatibleSimpleFieldUpsert, isValidSimpleFormConfig, itemConfigDetailsSchema, itemMatchesQuery, itemSummarySchema, mapKeyIndexById, mapOutlineById, mapRawItemsById, normalizeFormAuthoringConfig, normalizeSurveyChangeOperations, normalizeText, parseCursor, resolveAssistantCapabilityReference, resolveAssistantItemCreation, resolveItemSummary, sliceWithCursor, stableStringify, summarizeFocusItemNode, summarizeItemById, summarizeKeyIndexEntries, summarizeKeyIndexEntry, summarizeOutlineNode, summarizeRawItem, transitionFormAuthoringMode, translationEntrySchema, unique, validateExpression, validateSurveyOperations };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { q as assistantItemTypeManifestSchema } from "./protocol-
|
|
1
|
+
import { q as assistantItemTypeManifestSchema } from "./protocol-DJUP4gc0.mjs";
|
|
2
2
|
import { buildCapabilityDigest, stableStringify } from "./digest.mjs";
|
|
3
3
|
//#region src/engine/capabilities.ts
|
|
4
4
|
const resolveAssistantCapabilityReference = ({ capabilities, itemType, topic }) => capabilities?.byItemType.get(itemType)?.references?.find((reference) => reference.topic === topic);
|
|
@@ -152,4 +152,4 @@ const transitionFormAuthoringMode = ({ config, fieldGroups, preserveSimpleMode =
|
|
|
152
152
|
//#endregion
|
|
153
153
|
export { normalizeFormAuthoringConfig as a, assertSurveyAssistantCapabilities as c, getDeterministicCreateItemTypes as d, inspectAssistantItem as f, isValidSimpleFormConfig as i, createSurveyAssistantCapabilities as l, resolveAssistantItemCreation as m, hasSingleFormField as n, transitionFormAuthoringMode as o, resolveAssistantCapabilityReference as p, isCompatibleSimpleFieldUpsert as r, SurveyAssistantCapabilityMismatchError as s, getFormAuthoringMode as t, createUnsupportedItemCapability as u };
|
|
154
154
|
|
|
155
|
-
//# sourceMappingURL=form-authoring-
|
|
155
|
+
//# sourceMappingURL=form-authoring-BQh40yDb.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-authoring-DCd9XfXf.mjs","names":[],"sources":["../src/engine/capabilities.ts","../src/engine/form-authoring.ts"],"sourcesContent":["import type { RawSurveyItem, ValueType } from \"@case-framework/survey-core\";\nimport type {\n AssistantItemTypeManifest,\n JsonValue,\n SurveyAssistantCapabilityManifest,\n SurveyOperation,\n SurveyValidationIssue,\n} from \"../protocol\";\nimport { assistantItemTypeManifestSchema } from \"../protocol\";\nimport { buildCapabilityDigest, stableStringify } from \"../protocol/digest\";\n\nexport interface AssistantCapabilityReference {\n topic: string;\n title?: string;\n markdown: string;\n}\n\nexport interface AssistantItemInspection {\n summary: string;\n details?: JsonValue;\n}\n\nexport interface AssistantItemCapabilityAdapter {\n manifest: AssistantItemTypeManifest;\n references?: AssistantCapabilityReference[];\n normalizeCreate?: (item: RawSurveyItem) => RawSurveyItem;\n validateItem?: (item: RawSurveyItem) => SurveyValidationIssue[];\n supportsOperation?: (operation: SurveyOperation) => boolean;\n deriveResponseSlots?: (item: RawSurveyItem) => Record<string, ValueType>;\n inspectItem?: (item: RawSurveyItem) => AssistantItemInspection;\n}\n\nexport interface SurveyAssistantCapabilitySet {\n manifest: SurveyAssistantCapabilityManifest;\n byItemType: ReadonlyMap<string, AssistantItemCapabilityAdapter>;\n}\n\nexport const resolveAssistantCapabilityReference = ({\n capabilities,\n itemType,\n topic,\n}: {\n capabilities: SurveyAssistantCapabilitySet | undefined;\n itemType: string;\n topic: string;\n}): AssistantCapabilityReference | undefined =>\n capabilities?.byItemType\n .get(itemType)\n ?.references?.find((reference) => reference.topic === topic);\n\nexport const inspectAssistantItem = ({\n capabilities,\n item,\n}: {\n capabilities: SurveyAssistantCapabilitySet | undefined;\n item: RawSurveyItem;\n}): AssistantItemInspection | undefined =>\n capabilities?.byItemType.get(item.itemType)?.inspectItem?.(item);\n\nexport type AssistantItemCreationResolution =\n | { kind: \"deterministic\" }\n | {\n kind: \"ui-intent\";\n intent: { kind: \"open-create-item\"; itemType: string; parentItemId?: string };\n }\n | { kind: \"unsupported\"; reason: string };\n\nexport const createSurveyAssistantCapabilities = (\n capabilities: readonly AssistantItemCapabilityAdapter[],\n): SurveyAssistantCapabilitySet => {\n const byItemType = new Map<string, AssistantItemCapabilityAdapter>();\n const normalizedManifests: AssistantItemTypeManifest[] = [];\n\n for (const capability of capabilities) {\n const manifest = assistantItemTypeManifestSchema.parse(capability.manifest);\n const itemType = manifest.itemType;\n if (byItemType.has(itemType)) {\n throw new Error(`Duplicate survey assistant capability for item type \"${itemType}\".`);\n }\n if (\n manifest.create === \"deterministic\" &&\n !manifest.supportedOperations.includes(\"create-item\")\n ) {\n throw new Error(\n `Deterministically creatable item type \"${itemType}\" must support \"create-item\".`,\n );\n }\n const declaredReferenceTopics = new Set(manifest.referenceTopics ?? []);\n for (const reference of capability.references ?? []) {\n if (!declaredReferenceTopics.has(reference.topic)) {\n throw new Error(\n `Capability reference \"${reference.topic}\" for item type \"${itemType}\" is missing from manifest.referenceTopics.`,\n );\n }\n }\n byItemType.set(itemType, capability);\n normalizedManifests.push(\n assistantItemTypeManifestSchema.parse(JSON.parse(JSON.stringify(manifest))),\n );\n }\n\n const itemTypes = normalizedManifests.sort((left, right) =>\n left.itemType.localeCompare(right.itemType),\n );\n const manifestWithoutDigest = { itemTypes };\n\n return {\n manifest: {\n ...manifestWithoutDigest,\n digest: buildCapabilityDigest(manifestWithoutDigest),\n },\n byItemType,\n };\n};\n\nexport const getDeterministicCreateItemTypes = (\n manifest: SurveyAssistantCapabilityManifest,\n): string[] =>\n manifest.itemTypes\n .filter((entry) => entry.create === \"deterministic\")\n .map((entry) => entry.itemType);\n\nexport const resolveAssistantItemCreation = ({\n itemType,\n manifest,\n parentItemId,\n}: {\n itemType: string;\n manifest: SurveyAssistantCapabilityManifest;\n parentItemId?: string;\n}): AssistantItemCreationResolution => {\n const capability = manifest.itemTypes.find((entry) => entry.itemType === itemType);\n if (capability?.create === \"deterministic\") {\n return { kind: \"deterministic\" };\n }\n if (capability?.create === \"interactive-only\") {\n return {\n kind: \"ui-intent\",\n intent: { kind: \"open-create-item\", itemType, parentItemId },\n };\n }\n return {\n kind: \"unsupported\",\n reason: capability\n ? `Item type \"${itemType}\" does not support assistant creation.`\n : `Item type \"${itemType}\" is not installed.`,\n };\n};\n\nexport const createUnsupportedItemCapability = ({\n displayName,\n itemType,\n}: {\n displayName: string;\n itemType: string;\n}): AssistantItemCapabilityAdapter => ({\n manifest: {\n itemType,\n capabilityVersion: \"unsupported-v1\",\n displayName,\n create: \"unsupported\",\n supportedOperations: [],\n contentSurfaces: [],\n },\n});\n\nexport class SurveyAssistantCapabilityMismatchError extends Error {\n readonly code = \"survey-assistant-capability-mismatch\";\n\n constructor(message = \"Survey assistant capabilities changed; start a fresh turn and retry.\") {\n super(message);\n this.name = \"SurveyAssistantCapabilityMismatchError\";\n }\n}\n\nexport const assertSurveyAssistantCapabilities = ({\n manifest,\n trustedCapabilities,\n versionDigest,\n}: {\n manifest: SurveyAssistantCapabilityManifest;\n trustedCapabilities?: SurveyAssistantCapabilitySet;\n versionDigest: string;\n}): void => {\n const { digest: claimedDigest, ...manifestWithoutDigest } = manifest;\n const computedDigest = buildCapabilityDigest(manifestWithoutDigest);\n if (claimedDigest !== computedDigest || versionDigest !== claimedDigest) {\n throw new SurveyAssistantCapabilityMismatchError();\n }\n\n if (trustedCapabilities) {\n const withoutContextualPresets = ({\n creationPresets: _creationPresets,\n ...capability\n }: AssistantItemTypeManifest): Omit<AssistantItemTypeManifest, \"creationPresets\"> => capability;\n const claimedBaseCapabilities = manifest.itemTypes.map(withoutContextualPresets);\n const trustedBaseCapabilities =\n trustedCapabilities.manifest.itemTypes.map(withoutContextualPresets);\n\n // Creation presets are editor-registry context for the model. They do not\n // grant operations or install executable adapters, so the server validates\n // the stable capability contract while retaining its own trusted adapters.\n if (stableStringify(claimedBaseCapabilities) !== stableStringify(trustedBaseCapabilities)) {\n throw new SurveyAssistantCapabilityMismatchError(\n \"The editor and server use different survey assistant capabilities; refresh and retry.\",\n );\n }\n }\n};\n","export type FormAuthoringMode = \"simple\" | \"custom\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst SIMPLE_FORM_FIELD_TYPES = new Set([\n \"input\",\n \"textarea\",\n \"number\",\n \"slider\",\n \"select\",\n \"datepicker\",\n \"switch\",\n]);\n\nexport const getFormAuthoringMode = (config: unknown): FormAuthoringMode =>\n isRecord(config) && config.authoringMode === \"simple\" ? \"simple\" : \"custom\";\n\nexport const hasSingleFormField = (config: unknown): boolean => {\n if (!isRecord(config) || !Array.isArray(config.fieldGroups) || config.fieldGroups.length !== 1) {\n return false;\n }\n\n const [group] = config.fieldGroups;\n if (!isRecord(group) || !Array.isArray(group.fields) || group.fields.length !== 1) {\n return false;\n }\n const layout = isRecord(group.layout) ? group.layout : undefined;\n if (\n group.hasDisplayCondition === true ||\n (layout &&\n [\"base\", \"xs\", \"sm\", \"md\", \"xl\"].some(\n (breakpoint) => layout[breakpoint] !== undefined && layout[breakpoint] !== 1,\n ))\n ) {\n return false;\n }\n\n const [field] = group.fields;\n return (\n isRecord(field) &&\n typeof field.id === \"string\" &&\n field.id.length > 0 &&\n typeof field.key === \"string\" &&\n field.key.length > 0 &&\n typeof field.type === \"string\" &&\n SIMPLE_FORM_FIELD_TYPES.has(field.type) &&\n isRecord(field.controller) &&\n field.controller.type === field.type\n );\n};\n\nexport const isValidSimpleFormConfig = (config: unknown): boolean =>\n getFormAuthoringMode(config) !== \"simple\" || hasSingleFormField(config);\n\n/**\n * Canonicalizes the editor-facing mode without modifying groups, fields, or translations.\n * Missing modes and malformed simple forms become custom; valid simple forms stay simple.\n */\nexport const normalizeFormAuthoringConfig = (\n config: unknown,\n): Record<string, unknown> | undefined => {\n if (!isRecord(config)) {\n return undefined;\n }\n\n return {\n ...config,\n authoringMode:\n config.authoringMode === \"simple\" && hasSingleFormField(config) ? \"simple\" : \"custom\",\n };\n};\n\n/**\n * Returns true only for an in-place edit of the existing sole field that the\n * simple editor can still represent. Adding, moving, retyping, or exposing\n * hidden field configuration is structural and must promote the form.\n */\nexport const isCompatibleSimpleFieldUpsert = ({\n config,\n field,\n groupId,\n index,\n}: {\n config: unknown;\n field: Record<string, unknown> & { id: string; key: string; type: string };\n groupId: string;\n index?: number;\n}): boolean => {\n if (\n getFormAuthoringMode(config) !== \"simple\" ||\n !isRecord(config) ||\n !Array.isArray(config.fieldGroups) ||\n config.fieldGroups.length !== 1 ||\n (index ?? 0) > 0\n ) {\n return false;\n }\n\n const [group] = config.fieldGroups;\n if (!isRecord(group) || group.id !== groupId || !Array.isArray(group.fields)) {\n return false;\n }\n const [existingField] = group.fields;\n if (!isRecord(existingField) || group.fields.length !== 1) {\n return false;\n }\n\n const controller = isRecord(field.controller) ? field.controller : undefined;\n const validationsUnchanged =\n field.validations === undefined ||\n JSON.stringify(field.validations) === JSON.stringify(existingField.validations);\n const simpleEditableKeys = new Set([\n \"id\",\n \"key\",\n \"type\",\n \"controller\",\n \"required\",\n \"validations\",\n ]);\n const hiddenConfigUnchanged = Object.keys(field)\n .filter((key) => !simpleEditableKeys.has(key))\n .every((key) => JSON.stringify(field[key]) === JSON.stringify(existingField[key]));\n\n return (\n existingField.id === field.id &&\n existingField.key === field.key &&\n existingField.type === field.type &&\n controller?.type === field.type &&\n validationsUnchanged &&\n hiddenConfigUnchanged\n );\n};\n\n/**\n * Structural form operations are a one-way transition out of simple mode unless the caller has\n * proved that the same sole field remains compatible with the simple editor.\n */\nexport const transitionFormAuthoringMode = ({\n config,\n fieldGroups,\n preserveSimpleMode = false,\n}: {\n config: Record<string, unknown>;\n fieldGroups: Record<string, unknown>[];\n preserveSimpleMode?: boolean;\n}): Record<string, unknown> => {\n const nextConfig = { ...config, fieldGroups };\n if (getFormAuthoringMode(config) !== \"simple\") {\n return { ...nextConfig, authoringMode: \"custom\" };\n }\n\n return {\n ...nextConfig,\n authoringMode: preserveSimpleMode && hasSingleFormField(nextConfig) ? \"simple\" : \"custom\",\n };\n};\n"],"mappings":";;;AAqCA,MAAa,uCAAuC,EAClD,cACA,UACA,YAMA,cAAc,WACX,IAAI,SAAS,EACZ,YAAY,MAAM,cAAc,UAAU,UAAU,MA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AM,OAAO,WAAW,EACtD,QAAO;CAGT,MAAM,aAAa,SAAS,MAAM,WAAW,GAAG,MAAM,aAAa,KAAA;CACnE,MAAM,uBACJ,MAAM,gBAAgB,KAAA,KACtB,KAAK,UAAU,MAAM,YAAY,KAAK,KAAK,UAAU,cAAc,YAAY;CACjF,MAAM,qBAAqB,IAAI,IAAI;EACjC;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CACF,MAAM,wBAAwB,OAAO,KAAK,MAAM,CAC7C,QAAQ,QAAQ,CAAC,mBAAmB,IAAI,IAAI,CAAC,CAC7C,OAAO,QAAQ,KAAK,UAAU,MAAM,KAAK,KAAK,KAAK,UAAU,cAAc,KAAK,CAAC;AAEpF,QACE,cAAc,OAAO,MAAM,MAC3B,cAAc,QAAQ,MAAM,OAC5B,cAAc,SAAS,MAAM,QAC7B,YAAY,SAAS,MAAM,QAC3B,wBACA;;;;;;AAQJ,MAAa,+BAA+B,EAC1C,QACA,aACA,qBAAqB,YAKQ;CAC7B,MAAM,aAAa;EAAE,GAAG;EAAQ;EAAa;AAC7C,KAAI,qBAAqB,OAAO,KAAK,SACnC,QAAO;EAAE,GAAG;EAAY,eAAe;EAAU;AAGnD,QAAO;EACL,GAAG;EACH,eAAe,sBAAsB,mBAAmB,WAAW,GAAG,WAAW;EAClF"}
|
|
1
|
+
{"version":3,"file":"form-authoring-BQh40yDb.mjs","names":[],"sources":["../src/engine/capabilities.ts","../src/engine/form-authoring.ts"],"sourcesContent":["import type { RawSurveyItem, ValueType } from \"@case-framework/survey-core\";\nimport type {\n AssistantItemTypeManifest,\n JsonValue,\n SurveyAssistantCapabilityManifest,\n SurveyOperation,\n SurveyValidationIssue,\n} from \"../protocol\";\nimport { assistantItemTypeManifestSchema } from \"../protocol\";\nimport { buildCapabilityDigest, stableStringify } from \"../protocol/digest\";\n\nexport interface AssistantCapabilityReference {\n topic: string;\n title?: string;\n markdown: string;\n}\n\nexport interface AssistantItemInspection {\n summary: string;\n details?: JsonValue;\n}\n\nexport interface AssistantItemCapabilityAdapter {\n manifest: AssistantItemTypeManifest;\n references?: AssistantCapabilityReference[];\n normalizeCreate?: (item: RawSurveyItem) => RawSurveyItem;\n validateItem?: (item: RawSurveyItem) => SurveyValidationIssue[];\n supportsOperation?: (operation: SurveyOperation) => boolean;\n deriveResponseSlots?: (item: RawSurveyItem) => Record<string, ValueType>;\n inspectItem?: (item: RawSurveyItem) => AssistantItemInspection;\n}\n\nexport interface SurveyAssistantCapabilitySet {\n manifest: SurveyAssistantCapabilityManifest;\n byItemType: ReadonlyMap<string, AssistantItemCapabilityAdapter>;\n}\n\nexport const resolveAssistantCapabilityReference = ({\n capabilities,\n itemType,\n topic,\n}: {\n capabilities: SurveyAssistantCapabilitySet | undefined;\n itemType: string;\n topic: string;\n}): AssistantCapabilityReference | undefined =>\n capabilities?.byItemType\n .get(itemType)\n ?.references?.find((reference) => reference.topic === topic);\n\nexport const inspectAssistantItem = ({\n capabilities,\n item,\n}: {\n capabilities: SurveyAssistantCapabilitySet | undefined;\n item: RawSurveyItem;\n}): AssistantItemInspection | undefined =>\n capabilities?.byItemType.get(item.itemType)?.inspectItem?.(item);\n\nexport type AssistantItemCreationResolution =\n | { kind: \"deterministic\" }\n | {\n kind: \"ui-intent\";\n intent: { kind: \"open-create-item\"; itemType: string; parentItemId?: string };\n }\n | { kind: \"unsupported\"; reason: string };\n\nexport const createSurveyAssistantCapabilities = (\n capabilities: readonly AssistantItemCapabilityAdapter[],\n): SurveyAssistantCapabilitySet => {\n const byItemType = new Map<string, AssistantItemCapabilityAdapter>();\n const normalizedManifests: AssistantItemTypeManifest[] = [];\n\n for (const capability of capabilities) {\n const manifest = assistantItemTypeManifestSchema.parse(capability.manifest);\n const itemType = manifest.itemType;\n if (byItemType.has(itemType)) {\n throw new Error(`Duplicate survey assistant capability for item type \"${itemType}\".`);\n }\n if (\n manifest.create === \"deterministic\" &&\n !manifest.supportedOperations.includes(\"create-item\")\n ) {\n throw new Error(\n `Deterministically creatable item type \"${itemType}\" must support \"create-item\".`,\n );\n }\n const declaredReferenceTopics = new Set(manifest.referenceTopics ?? []);\n for (const reference of capability.references ?? []) {\n if (!declaredReferenceTopics.has(reference.topic)) {\n throw new Error(\n `Capability reference \"${reference.topic}\" for item type \"${itemType}\" is missing from manifest.referenceTopics.`,\n );\n }\n }\n byItemType.set(itemType, capability);\n normalizedManifests.push(\n assistantItemTypeManifestSchema.parse(JSON.parse(JSON.stringify(manifest))),\n );\n }\n\n const itemTypes = normalizedManifests.sort((left, right) =>\n left.itemType.localeCompare(right.itemType),\n );\n const manifestWithoutDigest = { itemTypes };\n\n return {\n manifest: {\n ...manifestWithoutDigest,\n digest: buildCapabilityDigest(manifestWithoutDigest),\n },\n byItemType,\n };\n};\n\nexport const getDeterministicCreateItemTypes = (\n manifest: SurveyAssistantCapabilityManifest,\n): string[] =>\n manifest.itemTypes\n .filter((entry) => entry.create === \"deterministic\")\n .map((entry) => entry.itemType);\n\nexport const resolveAssistantItemCreation = ({\n itemType,\n manifest,\n parentItemId,\n}: {\n itemType: string;\n manifest: SurveyAssistantCapabilityManifest;\n parentItemId?: string;\n}): AssistantItemCreationResolution => {\n const capability = manifest.itemTypes.find((entry) => entry.itemType === itemType);\n if (capability?.create === \"deterministic\") {\n return { kind: \"deterministic\" };\n }\n if (capability?.create === \"interactive-only\") {\n return {\n kind: \"ui-intent\",\n intent: { kind: \"open-create-item\", itemType, parentItemId },\n };\n }\n return {\n kind: \"unsupported\",\n reason: capability\n ? `Item type \"${itemType}\" does not support assistant creation.`\n : `Item type \"${itemType}\" is not installed.`,\n };\n};\n\nexport const createUnsupportedItemCapability = ({\n displayName,\n itemType,\n}: {\n displayName: string;\n itemType: string;\n}): AssistantItemCapabilityAdapter => ({\n manifest: {\n itemType,\n capabilityVersion: \"unsupported-v1\",\n displayName,\n create: \"unsupported\",\n supportedOperations: [],\n contentSurfaces: [],\n },\n});\n\nexport class SurveyAssistantCapabilityMismatchError extends Error {\n readonly code = \"survey-assistant-capability-mismatch\";\n\n constructor(message = \"Survey assistant capabilities changed; start a fresh turn and retry.\") {\n super(message);\n this.name = \"SurveyAssistantCapabilityMismatchError\";\n }\n}\n\nexport const assertSurveyAssistantCapabilities = ({\n manifest,\n trustedCapabilities,\n versionDigest,\n}: {\n manifest: SurveyAssistantCapabilityManifest;\n trustedCapabilities?: SurveyAssistantCapabilitySet;\n versionDigest: string;\n}): void => {\n const { digest: claimedDigest, ...manifestWithoutDigest } = manifest;\n const computedDigest = buildCapabilityDigest(manifestWithoutDigest);\n if (claimedDigest !== computedDigest || versionDigest !== claimedDigest) {\n throw new SurveyAssistantCapabilityMismatchError();\n }\n\n if (trustedCapabilities) {\n const withoutContextualPresets = ({\n creationPresets: _creationPresets,\n ...capability\n }: AssistantItemTypeManifest): Omit<AssistantItemTypeManifest, \"creationPresets\"> => capability;\n const claimedBaseCapabilities = manifest.itemTypes.map(withoutContextualPresets);\n const trustedBaseCapabilities =\n trustedCapabilities.manifest.itemTypes.map(withoutContextualPresets);\n\n // Creation presets are editor-registry context for the model. They do not\n // grant operations or install executable adapters, so the server validates\n // the stable capability contract while retaining its own trusted adapters.\n if (stableStringify(claimedBaseCapabilities) !== stableStringify(trustedBaseCapabilities)) {\n throw new SurveyAssistantCapabilityMismatchError(\n \"The editor and server use different survey assistant capabilities; refresh and retry.\",\n );\n }\n }\n};\n","export type FormAuthoringMode = \"simple\" | \"custom\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst SIMPLE_FORM_FIELD_TYPES = new Set([\n \"input\",\n \"textarea\",\n \"number\",\n \"slider\",\n \"select\",\n \"datepicker\",\n \"switch\",\n]);\n\nexport const getFormAuthoringMode = (config: unknown): FormAuthoringMode =>\n isRecord(config) && config.authoringMode === \"simple\" ? \"simple\" : \"custom\";\n\nexport const hasSingleFormField = (config: unknown): boolean => {\n if (!isRecord(config) || !Array.isArray(config.fieldGroups) || config.fieldGroups.length !== 1) {\n return false;\n }\n\n const [group] = config.fieldGroups;\n if (!isRecord(group) || !Array.isArray(group.fields) || group.fields.length !== 1) {\n return false;\n }\n const layout = isRecord(group.layout) ? group.layout : undefined;\n if (\n group.hasDisplayCondition === true ||\n (layout &&\n [\"base\", \"xs\", \"sm\", \"md\", \"xl\"].some(\n (breakpoint) => layout[breakpoint] !== undefined && layout[breakpoint] !== 1,\n ))\n ) {\n return false;\n }\n\n const [field] = group.fields;\n return (\n isRecord(field) &&\n typeof field.id === \"string\" &&\n field.id.length > 0 &&\n typeof field.key === \"string\" &&\n field.key.length > 0 &&\n typeof field.type === \"string\" &&\n SIMPLE_FORM_FIELD_TYPES.has(field.type) &&\n isRecord(field.controller) &&\n field.controller.type === field.type\n );\n};\n\nexport const isValidSimpleFormConfig = (config: unknown): boolean =>\n getFormAuthoringMode(config) !== \"simple\" || hasSingleFormField(config);\n\n/**\n * Canonicalizes the editor-facing mode without modifying groups, fields, or translations.\n * Missing modes and malformed simple forms become custom; valid simple forms stay simple.\n */\nexport const normalizeFormAuthoringConfig = (\n config: unknown,\n): Record<string, unknown> | undefined => {\n if (!isRecord(config)) {\n return undefined;\n }\n\n return {\n ...config,\n authoringMode:\n config.authoringMode === \"simple\" && hasSingleFormField(config) ? \"simple\" : \"custom\",\n };\n};\n\n/**\n * Returns true only for an in-place edit of the existing sole field that the\n * simple editor can still represent. Adding, moving, retyping, or exposing\n * hidden field configuration is structural and must promote the form.\n */\nexport const isCompatibleSimpleFieldUpsert = ({\n config,\n field,\n groupId,\n index,\n}: {\n config: unknown;\n field: Record<string, unknown> & { id: string; key: string; type: string };\n groupId: string;\n index?: number;\n}): boolean => {\n if (\n getFormAuthoringMode(config) !== \"simple\" ||\n !isRecord(config) ||\n !Array.isArray(config.fieldGroups) ||\n config.fieldGroups.length !== 1 ||\n (index ?? 0) > 0\n ) {\n return false;\n }\n\n const [group] = config.fieldGroups;\n if (!isRecord(group) || group.id !== groupId || !Array.isArray(group.fields)) {\n return false;\n }\n const [existingField] = group.fields;\n if (!isRecord(existingField) || group.fields.length !== 1) {\n return false;\n }\n\n const controller = isRecord(field.controller) ? field.controller : undefined;\n const validationsUnchanged =\n field.validations === undefined ||\n JSON.stringify(field.validations) === JSON.stringify(existingField.validations);\n const simpleEditableKeys = new Set([\n \"id\",\n \"key\",\n \"type\",\n \"controller\",\n \"required\",\n \"validations\",\n ]);\n const hiddenConfigUnchanged = Object.keys(field)\n .filter((key) => !simpleEditableKeys.has(key))\n .every((key) => JSON.stringify(field[key]) === JSON.stringify(existingField[key]));\n\n return (\n existingField.id === field.id &&\n existingField.key === field.key &&\n existingField.type === field.type &&\n controller?.type === field.type &&\n validationsUnchanged &&\n hiddenConfigUnchanged\n );\n};\n\n/**\n * Structural form operations are a one-way transition out of simple mode unless the caller has\n * proved that the same sole field remains compatible with the simple editor.\n */\nexport const transitionFormAuthoringMode = ({\n config,\n fieldGroups,\n preserveSimpleMode = false,\n}: {\n config: Record<string, unknown>;\n fieldGroups: Record<string, unknown>[];\n preserveSimpleMode?: boolean;\n}): Record<string, unknown> => {\n const nextConfig = { ...config, fieldGroups };\n if (getFormAuthoringMode(config) !== \"simple\") {\n return { ...nextConfig, authoringMode: \"custom\" };\n }\n\n return {\n ...nextConfig,\n authoringMode: preserveSimpleMode && hasSingleFormField(nextConfig) ? \"simple\" : \"custom\",\n };\n};\n"],"mappings":";;;AAqCA,MAAa,uCAAuC,EAClD,cACA,UACA,YAMA,cAAc,WACX,IAAI,SAAS,EACZ,YAAY,MAAM,cAAc,UAAU,UAAU,MAAM;AAEhE,MAAa,wBAAwB,EACnC,cACA,WAKA,cAAc,WAAW,IAAI,KAAK,SAAS,EAAE,cAAc,KAAK;AAUlE,MAAa,qCACX,iBACiC;CACjC,MAAM,6BAAa,IAAI,KAA6C;CACpE,MAAM,sBAAmD,EAAE;AAE3D,MAAK,MAAM,cAAc,cAAc;EACrC,MAAM,WAAW,gCAAgC,MAAM,WAAW,SAAS;EAC3E,MAAM,WAAW,SAAS;AAC1B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