asma-core-helpers 0.17.0 → 0.19.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.
@@ -1 +1 @@
1
- {"version":3,"file":"applyOperation.d.ts","sourceRoot":"","sources":["../../src/collaboration/applyOperation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAiB,mBAAmB,EAAc,MAAM,uBAAuB,CAAA;AAE3F;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IACzC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB,YAAY,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAK5D;CACJ;AAED,qBAAa,qBAAsB,SAAQ,kBAAkB;IACzD,YAAY,IAAI,EAAE,MAAM,EAEvB;CACJ;AAED,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC1D,YAAY,OAAO,EAAE,MAAM,EAE1B;CACJ;AAkGD,eAAO,MAAM,cAAc,aAAc,mBAAmB,MAAM,UAAU,KAAG,mBAG9E,CAAA"}
1
+ {"version":3,"file":"applyOperation.d.ts","sourceRoot":"","sources":["../../src/collaboration/applyOperation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAiB,mBAAmB,EAAc,MAAM,uBAAuB,CAAA;AAE3F;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IACzC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB,YAAY,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAK5D;CACJ;AAED,qBAAa,qBAAsB,SAAQ,kBAAkB;IACzD,YAAY,IAAI,EAAE,MAAM,EAEvB;CACJ;AAED,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC1D,YAAY,OAAO,EAAE,MAAM,EAE1B;CACJ;AA6HD,eAAO,MAAM,cAAc,aAAc,mBAAmB,MAAM,UAAU,KAAG,mBAG9E,CAAA"}
@@ -41,13 +41,34 @@ export class OperationConflictError extends CollaborationError {
41
41
  const targetKey = (target) => target.kind === 'question'
42
42
  ? `question:${target.questionId}`
43
43
  : `gridColumn:${target.gridQuestionId}:${target.columnQuestionId}`;
44
- /** Sets a key, or removes it when the op carried an explicit unset. */
44
+ /**
45
+ * Sets a key, or removes it when the op carried an explicit unset.
46
+ *
47
+ * `field` may be a dotted path (`scale.from`). The per-type configuration in the document is nested
48
+ * — `question.scale.{from, to, …}`, `question.numberFormat.{…}` — while an op value is a scalar, so
49
+ * without a path those groups are unauthorable. Intermediate objects are created on write and
50
+ * **removed again when their last key is unset**, because DOC-LAW-2 forbids storing an empty
51
+ * collection: leaving `{ scale: {} }` behind would change `document_hash` for a document that
52
+ * carries no scale at all.
53
+ */
45
54
  const writeField = (record, field, value) => {
55
+ const [head, ...rest] = field.split('.');
56
+ if (head === undefined || head === '')
57
+ return record;
46
58
  const next = { ...record };
47
- if (value === null || value === undefined)
48
- delete next[field];
59
+ if (rest.length === 0) {
60
+ if (value === null || value === undefined)
61
+ delete next[head];
62
+ else
63
+ next[head] = value;
64
+ return next;
65
+ }
66
+ const child = next[head];
67
+ const nested = writeField((typeof child === 'object' && child !== null && !Array.isArray(child) ? child : {}), rest.join('.'), value);
68
+ if (Object.keys(nested).length === 0)
69
+ delete next[head];
49
70
  else
50
- next[field] = value;
71
+ next[head] = nested;
51
72
  return next;
52
73
  };
53
74
  /** Inserts `id` at `index`, clamped into range. Absent index appends. */
@@ -153,7 +174,7 @@ const reduce = (doc, op) => {
153
174
  }
154
175
  return {
155
176
  ...doc,
156
- questionsById: { ...(doc.questionsById ?? {}), [op.questionId]: { kind: op.kind } },
177
+ questionsById: { ...(doc.questionsById ?? {}), [op.questionId]: { type: op.questionType } },
157
178
  questionOrder: insertAt(doc.questionOrder, op.questionId, op.atIndex),
158
179
  };
159
180
  }
@@ -210,6 +231,38 @@ const reduce = (doc, op) => {
210
231
  },
211
232
  };
212
233
  }
234
+ case 'alternative.updateField': {
235
+ const alternative = doc.alternativesById?.[op.alternativeId];
236
+ if (!alternative) {
237
+ throw new OperationConflictError(`Unknown alternative "${op.alternativeId}"`);
238
+ }
239
+ // The question is checked too: an alternative id that exists but hangs off a different
240
+ // question means the two clients disagree about the structure, not just the value, and
241
+ // writing the field anyway would hide that behind a successful edit.
242
+ if (!doc.alternativeOrderByQuestionId?.[op.questionId]?.includes(op.alternativeId)) {
243
+ throw new OperationConflictError(`Alternative "${op.alternativeId}" does not belong to question "${op.questionId}"`);
244
+ }
245
+ return {
246
+ ...doc,
247
+ alternativesById: {
248
+ ...doc.alternativesById,
249
+ [op.alternativeId]: writeField(alternative, op.field, op.value),
250
+ },
251
+ };
252
+ }
253
+ case 'alternative.move': {
254
+ const order = doc.alternativeOrderByQuestionId?.[op.questionId];
255
+ if (!order?.includes(op.alternativeId)) {
256
+ throw new OperationConflictError(`Alternative "${op.alternativeId}" does not belong to question "${op.questionId}"`);
257
+ }
258
+ return {
259
+ ...doc,
260
+ alternativeOrderByQuestionId: {
261
+ ...doc.alternativeOrderByQuestionId,
262
+ [op.questionId]: moveInOrder(order, op.alternativeId, op.toIndex),
263
+ },
264
+ };
265
+ }
213
266
  case 'alternative.delete': {
214
267
  const order = doc.alternativeOrderByQuestionId?.[op.questionId] ?? [];
215
268
  const remaining = order.filter((id) => id !== op.alternativeId);
@@ -1 +1 @@
1
- {"version":3,"file":"applyOperation.js","sourceRoot":"","sources":["../../src/collaboration/applyOperation.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AAEH;;;;;;GA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CAAC,QAAQ,CAAC;gBAC1F,gBAAgB,EAAE,KAAK;aAC1B,CAAC,CAAA;QACN,CAAC;QAED,SAAS,CAAC;YACN,kFAAkF;YAClF,MAAM,SAAS,GAAU,EAAE,CAAA;YAC3B,MAAM,IAAI,qBAAqB,CAAE,SAA+B,EAAE,IAAI,IAAI,WAAW,CAAC,CAAA;QAC1F,CAAC;IACL,CAAC;AACL,CAAC,CAAA"}
@@ -18,6 +18,7 @@
18
18
  * @see asma-modules/_docs/editor/qnrs/cross/2026-07-12-20-20-architecture-qnr-v2-model-collaboration-sync.md:422 (shared contracts package)
19
19
  * @see asma-modules/_docs/editor/qnrs/cross/2026-07-12-21-40-plan-qnr-stage2-new-model-editor-and-sync.md:690 (FILE-001)
20
20
  */
21
+ export * from './questionTypes.js';
21
22
  export * from './templateDocument.js';
22
23
  export * from './operations.js';
23
24
  export * from './applyOperation.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/collaboration/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/collaboration/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA"}
@@ -18,6 +18,7 @@
18
18
  * @see asma-modules/_docs/editor/qnrs/cross/2026-07-12-20-20-architecture-qnr-v2-model-collaboration-sync.md:422 (shared contracts package)
19
19
  * @see asma-modules/_docs/editor/qnrs/cross/2026-07-12-21-40-plan-qnr-stage2-new-model-editor-and-sync.md:690 (FILE-001)
20
20
  */
21
+ export * from './questionTypes.js';
21
22
  export * from './templateDocument.js';
22
23
  export * from './operations.js';
23
24
  export * from './applyOperation.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/collaboration/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/collaboration/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import type { AltId, BindingId, BindingTarget, DocScalar, FilterId, NodeId, QuestionId } from './templateDocument.js';
2
+ import type { QuestionType } from './questionTypes.js';
2
3
  /**
3
4
  * The authoring op vocabulary. `entity.action`, stable-id targets only, append-only —
4
5
  * a new op is a new member, never a changed one.
@@ -18,7 +19,7 @@ export type TemplateOp = {
18
19
  } | {
19
20
  type: 'question.create';
20
21
  questionId: QuestionId;
21
- kind: string;
22
+ questionType: QuestionType;
22
23
  atIndex?: number;
23
24
  } | {
24
25
  type: 'question.updateField';
@@ -38,6 +39,23 @@ export type TemplateOp = {
38
39
  alternativeId: AltId;
39
40
  label?: string;
40
41
  atIndex?: number;
42
+ }
43
+ /**
44
+ * Renaming is its own operation rather than delete-then-create because an alternative's id is
45
+ * referenced by every answer that selected it — recreating it under a new id is how the legacy
46
+ * data ended up with ~11,000 answers pointing at options that no longer exist.
47
+ */
48
+ | {
49
+ type: 'alternative.updateField';
50
+ questionId: QuestionId;
51
+ alternativeId: AltId;
52
+ field: string;
53
+ value: OpValue;
54
+ } | {
55
+ type: 'alternative.move';
56
+ questionId: QuestionId;
57
+ alternativeId: AltId;
58
+ toIndex: number;
41
59
  } | {
42
60
  type: 'alternative.delete';
43
61
  questionId: QuestionId;
@@ -80,10 +98,5 @@ export type TemplateOp = {
80
98
  filterId: FilterId;
81
99
  };
82
100
  export type TemplateOpType = TemplateOp['type'];
83
- /**
84
- * The op types this reducer implements. The vocabulary in the architecture doc is
85
- * larger (grid rows, tabs, actions, layout, visibility/highlight rules); those slot
86
- * into the same registry without changing the envelope.
87
- */
88
- export declare const IMPLEMENTED_OP_TYPES: readonly ["template.updateMeta", "question.create", "question.updateField", "question.move", "question.delete", "alternative.create", "alternative.delete", "mappingNode.create", "mappingNode.delete", "mappingBinding.create", "mappingBinding.update", "mappingBinding.delete", "mappingFilter.set", "mappingFilter.delete"];
101
+ export declare const IMPLEMENTED_OP_TYPES: readonly TemplateOpType[];
89
102
  //# sourceMappingURL=operations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/collaboration/operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAErH;;;;;;;;;;GAUG;AAEH,mDAAmD;AACnD,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,IAAI,CAAA;AAEtC,MAAM,MAAM,UAAU,GAChB;IAAE,IAAI,EAAE,qBAAqB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE,GACzF;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,UAAU,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACnF;IAAE,IAAI,EAAE,sBAAsB,CAAC;IAAC,UAAU,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACvF;IAAE,IA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AC;QAAC,MAAM,CAAC,EAAE,aAAa,CAAA;KAAE,CAAA;CACvE,GACD;IAAE,IAAI,EAAE,uBAAuB,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,GACvD;IACI,IAAI,EAAE,mBAAmB,CAAA;IACzB,QAAQ,EAAE,QAAQ,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,SAAS,CAAA;CACpB,GACD;IAAE,IAAI,EAAE,sBAAsB,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAA;AAE1D,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;AA+B/C,eAAO,MAAM,oBAAoB,EAAoC,SAAS,cAAc,EAAE,CAAA"}
@@ -2,21 +2,29 @@
2
2
  * The op types this reducer implements. The vocabulary in the architecture doc is
3
3
  * larger (grid rows, tabs, actions, layout, visibility/highlight rules); those slot
4
4
  * into the same registry without changing the envelope.
5
+ *
6
+ * Declared as a total `Record` over the union rather than a bare list, so **omitting an op is a
7
+ * compile error**. `satisfies readonly TemplateOpType[]` only rejected entries that are not op types;
8
+ * it could not notice a missing one, and this list is what downstream validators are built against —
9
+ * an op absent here is an op the server rejects at runtime with nothing red anywhere first.
5
10
  */
6
- export const IMPLEMENTED_OP_TYPES = [
7
- 'template.updateMeta',
8
- 'question.create',
9
- 'question.updateField',
10
- 'question.move',
11
- 'question.delete',
12
- 'alternative.create',
13
- 'alternative.delete',
14
- 'mappingNode.create',
15
- 'mappingNode.delete',
16
- 'mappingBinding.create',
17
- 'mappingBinding.update',
18
- 'mappingBinding.delete',
19
- 'mappingFilter.set',
20
- 'mappingFilter.delete',
21
- ];
11
+ const OP_TYPE_COVERAGE = {
12
+ 'template.updateMeta': true,
13
+ 'question.create': true,
14
+ 'question.updateField': true,
15
+ 'question.move': true,
16
+ 'question.delete': true,
17
+ 'alternative.create': true,
18
+ 'alternative.updateField': true,
19
+ 'alternative.move': true,
20
+ 'alternative.delete': true,
21
+ 'mappingNode.create': true,
22
+ 'mappingNode.delete': true,
23
+ 'mappingBinding.create': true,
24
+ 'mappingBinding.update': true,
25
+ 'mappingBinding.delete': true,
26
+ 'mappingFilter.set': true,
27
+ 'mappingFilter.delete': true,
28
+ };
29
+ export const IMPLEMENTED_OP_TYPES = Object.keys(OP_TYPE_COVERAGE);
22
30
  //# sourceMappingURL=operations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/collaboration/operations.ts"],"names":[],"mappings":"AAoDA;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,qBAAqB;IACrB,iBAAiB;IACjB,sBAAsB;IACtB,eAAe;IACf,iBAAiB;IACjB,oBAAoB;IACpB,oBAAoB;IACpB,oBAAoB;IACpB,oBAAoB;IACpB,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,mBAAmB;IACnB,sBAAsB;CACoB,CAAA"}
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/collaboration/operations.ts"],"names":[],"mappings":"AA8DA;;;;;;;;;GASG;AACH,MAAM,gBAAgB,GAAiC;IACnD,qBAAqB,EAAE,IAAI;IAC3B,iBAAiB,EAAE,IAAI;IACvB,sBAAsB,EAAE,IAAI;IAC5B,eAAe,EAAE,IAAI;IACrB,iBAAiB,EAAE,IAAI;IACvB,oBAAoB,EAAE,IAAI;IAC1B,yBAAyB,EAAE,IAAI;IAC/B,kBAAkB,EAAE,IAAI;IACxB,oBAAoB,EAAE,IAAI;IAC1B,oBAAoB,EAAE,IAAI;IAC1B,oBAAoB,EAAE,IAAI;IAC1B,uBAAuB,EAAE,IAAI;IAC7B,uBAAuB,EAAE,IAAI;IAC7B,uBAAuB,EAAE,IAAI;IAC7B,mBAAmB,EAAE,IAAI;IACzB,sBAAsB,EAAE,IAAI;CAC/B,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAA8B,CAAA"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The question-type register — the one place that says what a question can be.
3
+ *
4
+ * `QnrQuestion.type` is this union rather than `string` on purpose: the value is part of the stored
5
+ * document and therefore part of `document_hash`, so a typo cannot be corrected later without a
6
+ * document migration across every stored version. A closed union makes an unknown type a build
7
+ * error on both sides instead of a row nobody can render.
8
+ *
9
+ * **The values are the legacy `QUESTION_TYPE` values verbatim, with exactly one rename**
10
+ * (`CompositeQuestion` → `QuestionGrid`, OQ-V2-17). That is deliberate backward compatibility: 18 of
11
+ * 19 types need no translation at all, so the import mapper and the reverse projection carry a
12
+ * one-row table rather than a whole vocabulary, and the legacy wire keeps receiving the names it
13
+ * always did.
14
+ *
15
+ * Transcribed from `asma-modules/editor/shared/types/questions/fields/Question.constants.ts`
16
+ * (`QUESTION_TYPE`), which stays canonical for the **legacy** contract. It cannot be imported here:
17
+ * it lives in the polyrepo root, outside both service repos' build contexts.
18
+ *
19
+ * @see asma-modules/_docs/editor/qnrs/cross/2026-07-12-21-20-analysis-qnr-template-field-inventory.md:365 — M-062 `q.type` → `question.type` (19-value enum)
20
+ * @see asma-modules/_docs/editor/qnrs/cross/2026-07-12-21-20-analysis-qnr-template-field-inventory.md:417 — M-098 `q.subtype`
21
+ * @see asma-modules/_docs/editor/qnrs/cross/2026-07-12-21-40-plan-qnr-stage2-new-model-editor-and-sync.md — OQ-V2-17 (CompositeQuestion → QuestionGrid)
22
+ */
23
+ /** The legacy discriminator values, exactly as `templates.properties` stores them. */
24
+ export declare const LEGACY_QUESTION_TYPES: readonly ['BooleanQuestion', 'Chart', 'CheckBoxes', 'CompositeQuestion', 'DateField', 'DocumentUpload', 'Dropdown', 'Emoticons', 'ExpressionQuestion', 'FormatNumber', 'LinearScale', 'Link', 'RadioButtons', 'Readonly', 'Space', 'TextLong', 'TextShort', 'Title', 'Widget'];
25
+ export type LegacyQuestionType = (typeof LEGACY_QUESTION_TYPES)[number];
26
+ /** What a v2 document stores in `question.type`. */
27
+ export declare const QUESTION_TYPES: readonly ['BooleanQuestion', 'Chart', 'CheckBoxes', 'DateField', 'DocumentUpload', 'Dropdown', 'Emoticons', 'ExpressionQuestion', 'FormatNumber', 'LinearScale', 'Link', 'QuestionGrid', 'RadioButtons', 'Readonly', 'Space', 'TextLong', 'TextShort', 'Title', 'Widget'];
28
+ export type QuestionType = (typeof QUESTION_TYPES)[number];
29
+ /**
30
+ * Only TextShort and TextLong carry one, and this is its whole vocabulary
31
+ * (`TextShortSubtype` in the legacy register). Typed rather than left open because an unrecognized
32
+ * subtype silently changes how an answer validates.
33
+ */
34
+ export type QuestionSubtype = 'ORDINARY' | 'EMAIL';
35
+ /**
36
+ * Written out in full rather than derived from the two arrays, so that `Record` makes TypeScript
37
+ * prove the table covers every legacy value — a derived table would need a cast, and the cast is
38
+ * exactly where a missing entry would hide.
39
+ */
40
+ export declare const LEGACY_TO_V2_QUESTION_TYPE: Record<LegacyQuestionType, QuestionType>;
41
+ export declare const isQuestionType: (value: unknown) => value is QuestionType;
42
+ /**
43
+ * Legacy → v2. Returns `undefined` for anything not in the register instead of passing the value
44
+ * through: an unmapped type reaching a document would be a question no editor can render, and the
45
+ * import has a report to record it in.
46
+ */
47
+ export declare const toV2QuestionType: (legacy: string) => QuestionType | undefined;
48
+ /** v2 → legacy, for the projection that writes back to the legacy wire. Total by construction. */
49
+ export declare const toLegacyQuestionType: (type: QuestionType) => LegacyQuestionType;
50
+ //# sourceMappingURL=questionTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"questionTypes.d.ts","sourceRoot":"","sources":["../../src/collaboration/questionTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,sFAAsF;AACtF,eAAO,MAAM,qBAAqB,YAC9B,iBAAiB,EACjB,OAAO,EACP,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,MAAM,EACN,cAAc,EACd,UAAU,EACV,OAAO,EACP,UAAU,EACV,WAAW,EACX,OAAO,EACP,QAAQ,CACF,CAAA;AAEV,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEvE,oDAAoD;AACpD,eAAO,MAAM,cAAc,YACvB,iBAAiB,EACjB,OAAO,EACP,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,MAAM,EACN,cAAc,EACd,cAAc,EACd,UAAU,EACV,OAAO,EACP,UAAU,EACV,WAAW,EACX,OAAO,EACP,QAAQ,CACF,CAAA;AAEV,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAE1D;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,OAAO,CAAA;AAElD;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,kBAAkB,EAAE,YAAY,CAsB/E,CAAA;AAMD,eAAO,MAAM,cAAc,UAAW,OAAO,KAAG,KAAK,IAAI,YAC6B,CAAA;AAEtF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,WAAY,MAAM,KAAG,YAAY,GAAG,SACL,CAAA;AAE5D,kGAAkG;AAClG,eAAO,MAAM,oBAAoB,SAAU,YAAY,KAAG,kBAAsD,CAAA"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * The question-type register — the one place that says what a question can be.
3
+ *
4
+ * `QnrQuestion.type` is this union rather than `string` on purpose: the value is part of the stored
5
+ * document and therefore part of `document_hash`, so a typo cannot be corrected later without a
6
+ * document migration across every stored version. A closed union makes an unknown type a build
7
+ * error on both sides instead of a row nobody can render.
8
+ *
9
+ * **The values are the legacy `QUESTION_TYPE` values verbatim, with exactly one rename**
10
+ * (`CompositeQuestion` → `QuestionGrid`, OQ-V2-17). That is deliberate backward compatibility: 18 of
11
+ * 19 types need no translation at all, so the import mapper and the reverse projection carry a
12
+ * one-row table rather than a whole vocabulary, and the legacy wire keeps receiving the names it
13
+ * always did.
14
+ *
15
+ * Transcribed from `asma-modules/editor/shared/types/questions/fields/Question.constants.ts`
16
+ * (`QUESTION_TYPE`), which stays canonical for the **legacy** contract. It cannot be imported here:
17
+ * it lives in the polyrepo root, outside both service repos' build contexts.
18
+ *
19
+ * @see asma-modules/_docs/editor/qnrs/cross/2026-07-12-21-20-analysis-qnr-template-field-inventory.md:365 — M-062 `q.type` → `question.type` (19-value enum)
20
+ * @see asma-modules/_docs/editor/qnrs/cross/2026-07-12-21-20-analysis-qnr-template-field-inventory.md:417 — M-098 `q.subtype`
21
+ * @see asma-modules/_docs/editor/qnrs/cross/2026-07-12-21-40-plan-qnr-stage2-new-model-editor-and-sync.md — OQ-V2-17 (CompositeQuestion → QuestionGrid)
22
+ */
23
+ /** The legacy discriminator values, exactly as `templates.properties` stores them. */
24
+ export const LEGACY_QUESTION_TYPES = [
25
+ 'BooleanQuestion',
26
+ 'Chart',
27
+ 'CheckBoxes',
28
+ 'CompositeQuestion',
29
+ 'DateField',
30
+ 'DocumentUpload',
31
+ 'Dropdown',
32
+ 'Emoticons',
33
+ 'ExpressionQuestion',
34
+ 'FormatNumber',
35
+ 'LinearScale',
36
+ 'Link',
37
+ 'RadioButtons',
38
+ 'Readonly',
39
+ 'Space',
40
+ 'TextLong',
41
+ 'TextShort',
42
+ 'Title',
43
+ 'Widget',
44
+ ];
45
+ /** What a v2 document stores in `question.type`. */
46
+ export const QUESTION_TYPES = [
47
+ 'BooleanQuestion',
48
+ 'Chart',
49
+ 'CheckBoxes',
50
+ 'DateField',
51
+ 'DocumentUpload',
52
+ 'Dropdown',
53
+ 'Emoticons',
54
+ 'ExpressionQuestion',
55
+ 'FormatNumber',
56
+ 'LinearScale',
57
+ 'Link',
58
+ 'QuestionGrid',
59
+ 'RadioButtons',
60
+ 'Readonly',
61
+ 'Space',
62
+ 'TextLong',
63
+ 'TextShort',
64
+ 'Title',
65
+ 'Widget',
66
+ ];
67
+ /**
68
+ * Written out in full rather than derived from the two arrays, so that `Record` makes TypeScript
69
+ * prove the table covers every legacy value — a derived table would need a cast, and the cast is
70
+ * exactly where a missing entry would hide.
71
+ */
72
+ export const LEGACY_TO_V2_QUESTION_TYPE = {
73
+ BooleanQuestion: 'BooleanQuestion',
74
+ Chart: 'Chart',
75
+ CheckBoxes: 'CheckBoxes',
76
+ // The one rename in the whole register (OQ-V2-17): a "composite question" is a grid of
77
+ // questions, and the legacy name says nothing about that.
78
+ CompositeQuestion: 'QuestionGrid',
79
+ DateField: 'DateField',
80
+ DocumentUpload: 'DocumentUpload',
81
+ Dropdown: 'Dropdown',
82
+ Emoticons: 'Emoticons',
83
+ ExpressionQuestion: 'ExpressionQuestion',
84
+ FormatNumber: 'FormatNumber',
85
+ LinearScale: 'LinearScale',
86
+ Link: 'Link',
87
+ RadioButtons: 'RadioButtons',
88
+ Readonly: 'Readonly',
89
+ Space: 'Space',
90
+ TextLong: 'TextLong',
91
+ TextShort: 'TextShort',
92
+ Title: 'Title',
93
+ Widget: 'Widget',
94
+ };
95
+ const V2_TO_LEGACY_QUESTION_TYPE = Object.fromEntries(Object.entries(LEGACY_TO_V2_QUESTION_TYPE).map(([legacy, v2]) => [v2, legacy]));
96
+ export const isQuestionType = (value) => typeof value === 'string' && QUESTION_TYPES.includes(value);
97
+ /**
98
+ * Legacy → v2. Returns `undefined` for anything not in the register instead of passing the value
99
+ * through: an unmapped type reaching a document would be a question no editor can render, and the
100
+ * import has a report to record it in.
101
+ */
102
+ export const toV2QuestionType = (legacy) => LEGACY_TO_V2_QUESTION_TYPE[legacy];
103
+ /** v2 → legacy, for the projection that writes back to the legacy wire. Total by construction. */
104
+ export const toLegacyQuestionType = (type) => V2_TO_LEGACY_QUESTION_TYPE[type];
105
+ //# sourceMappingURL=questionTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"questionTypes.js","sourceRoot":"","sources":["../../src/collaboration/questionTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,sFAAsF;AACtF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACjC,iBAAiB;IACjB,OAAO;IACP,YAAY;IACZ,mBAAmB;IACnB,WAAW;IACX,gBAAgB;IAChB,UAAU;IACV,WAAW;IACX,oBAAoB;IACpB,cAAc;IACd,aAAa;IACb,MAAM;IACN,cAAc;IACd,UAAU;IACV,OAAO;IACP,UAAU;IACV,WAAW;IACX,OAAO;IACP,QAAQ;CACF,CAAA;AAIV,oDAAoD;AACpD,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,iBAAiB;IACjB,OAAO;IACP,YAAY;IACZ,WAAW;IACX,gBAAgB;IAChB,UAAU;IACV,WAAW;IACX,oBAAoB;IACpB,cAAc;IACd,aAAa;IACb,MAAM;IACN,cAAc;IACd,cAAc;IACd,UAAU;IACV,OAAO;IACP,UAAU;IACV,WAAW;IACX,OAAO;IACP,QAAQ;CACF,CAAA;AAWV;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAA6C;IAChF,eAAe,EAAE,iBAAiB;IAClC,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,YAAY;IACxB,uFAAuF;IACvF,0DAA0D;IAC1D,iBAAiB,EAAE,cAAc;IACjC,SAAS,EAAE,WAAW;IACtB,cAAc,EAAE,gBAAgB;IAChC,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW;IACtB,kBAAkB,EAAE,oBAAoB;IACxC,YAAY,EAAE,cAAc;IAC5B,WAAW,EAAE,aAAa;IAC1B,IAAI,EAAE,MAAM;IACZ,YAAY,EAAE,cAAc;IAC5B,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW;IACtB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;CACnB,CAAA;AAED,MAAM,0BAA0B,GAAG,MAAM,CAAC,WAAW,CACjD,MAAM,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CACrC,CAAA;AAE7C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAc,EAAyB,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ,IAAK,cAAoC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAEtF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAA4B,EAAE,CACzE,0BAA0B,CAAC,MAA4B,CAAC,CAAA;AAE5D,kGAAkG;AAClG,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAkB,EAAsB,EAAE,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAA"}
@@ -11,6 +11,7 @@
11
11
  * @see _docs/editor/qnrs/cross/2026-07-12-20-20-architecture-qnr-v2-model-collaboration-sync.md:193 (DOC-LAW-1)
12
12
  * @see _docs/editor/qnrs/cross/2026-07-12-20-20-architecture-qnr-v2-model-collaboration-sync.md:214 (§2.2a mapping graph)
13
13
  */
14
+ import type { QuestionSubtype, QuestionType } from './questionTypes.js';
14
15
  export type QuestionId = string;
15
16
  export type RowId = string;
16
17
  export type AltId = string;
@@ -22,8 +23,15 @@ export type FilterId = string;
22
23
  export type MappingId = string;
23
24
  /** A scalar a document may carry. Deliberately not `any`: DOC-LAW-2 bans `null`. */
24
25
  export type DocScalar = string | number | boolean;
26
+ /**
27
+ * `type` is the question's own discriminator (M-062), a closed union rather than a string — see
28
+ * `questionTypes.ts` for why the value cannot be loose. Not to be confused with the other `kind`
29
+ * slots in this file: `QnrAction.kind` and `BindingTarget.kind` discriminate *structure*, not the
30
+ * question a user authored.
31
+ */
25
32
  export type QnrQuestion = {
26
- kind: string;
33
+ type: QuestionType;
34
+ subtype?: QuestionSubtype;
27
35
  label?: string;
28
36
  required?: boolean;
29
37
  defaultValue?: DocScalar;
@@ -1 +1 @@
1
- {"version":3,"file":"templateDocument.d.ts","sourceRoot":"","sources":["../../src/collaboration/templateDocument.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAA;AAC/B,MAAM,MAAM,KAAK,GAAG,MAAM,CAAA;AAC1B,MAAM,MAAM,KAAK,GAAG,MAAM,CAAA;AAC1B,MAAM,MAAM,KAAK,GAAG,MAAM,CAAA;AAC1B,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAA;AAC7B,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA;AAC3B,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAC9B,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAA;AAC7B,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAE9B,oFAAoF;AACpF,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAEjD,MAAM,MAAM,WAAW,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE,SAAS,CAAA;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAA;AAC1F,MAAM,MAAM,UAAU,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,GAAG,EAAE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C,UAAkB,EAAuB,EAAE,CAAC,CAAC;IAC/E,UAAU;IACV,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,EAAE;CACpB,CAAC,CAAA"}
1
+ {"version":3,"file":"templateDocument.js","sourceRoot":"","sources":["../../src/collaboration/templateDocument.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA0FH;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,UAAkB,EAAuB,EAAE,CAAC,CAAC;IAC/E,UAAU;IACV,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,EAAE;CACpB,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asma-core-helpers",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "Core helper utilities for ASMA applications",
5
5
  "files": [
6
6
  "lib/**/*",
@@ -24,15 +24,16 @@ const doc0 = emptyTemplateDocument('tpl-1')
24
24
 
25
25
  const apply = (ops: TemplateOp[], from = doc0) => ops.reduce((doc, op) => applyOperation(doc, op), from)
26
26
 
27
+
27
28
  const threeQuestions = apply([
28
- { type: 'question.create', questionId: 'q-1', kind: 'text' },
29
- { type: 'question.create', questionId: 'q-2', kind: 'text' },
30
- { type: 'question.create', questionId: 'q-3', kind: 'text', atIndex: 0 },
29
+ { type: 'question.create', questionId: 'q-1', questionType: 'TextShort' },
30
+ { type: 'question.create', questionId: 'q-2', questionType: 'TextShort' },
31
+ { type: 'question.create', questionId: 'q-3', questionType: 'TextShort', atIndex: 0 },
31
32
  ])
32
33
 
33
34
  describe('applyOperation', () => {
34
35
  it('bumps the revision by one and leaves its input untouched', () => {
35
- const next = applyOperation(doc0, { type: 'question.create', questionId: 'q-1', kind: 'text' })
36
+ const next = applyOperation(doc0, { type: 'question.create', questionId: 'q-1', questionType: 'TextShort' })
36
37
 
37
38
  assert.equal(next.revision, 1)
38
39
  assert.equal(doc0.revision, 0)
@@ -45,7 +46,7 @@ describe('applyOperation', () => {
45
46
  const clamped = applyOperation(threeQuestions, {
46
47
  type: 'question.create',
47
48
  questionId: 'q-4',
48
- kind: 'text',
49
+ questionType: 'TextShort',
49
50
  atIndex: 99,
50
51
  })
51
52
 
@@ -60,7 +61,7 @@ describe('applyOperation', () => {
60
61
 
61
62
  it('drops the bindings that targeted a deleted question, keeping the shared node', () => {
62
63
  const bound = apply([
63
- { type: 'question.create', questionId: 'q-1', kind: 'text' },
64
+ { type: 'question.create', questionId: 'q-1', questionType: 'TextShort' },
64
65
  { type: 'mappingNode.create', nodeId: 'n-1', entityId: 'Actor' },
65
66
  {
66
67
  type: 'mappingBinding.create',
@@ -80,7 +81,7 @@ describe('applyOperation', () => {
80
81
 
81
82
  it('removes a collection that just became empty rather than storing it empty', () => {
82
83
  const withAlternative = apply([
83
- { type: 'question.create', questionId: 'q-1', kind: 'radio' },
84
+ { type: 'question.create', questionId: 'q-1', questionType: 'RadioButtons' },
84
85
  { type: 'alternative.create', questionId: 'q-1', alternativeId: 'a-1', label: 'Yes' },
85
86
  ])
86
87
  assert.deepEqual(withAlternative.alternativesById, { 'a-1': { label: 'Yes' } })
@@ -94,11 +95,162 @@ describe('applyOperation', () => {
94
95
  assert.equal(removed.alternativesById, undefined)
95
96
  })
96
97
 
98
+ it('writes a nested per-type field through a dotted path', () => {
99
+ // The per-type configuration is nested in the document (`question.scale.{from, to}`) while an
100
+ // op value is a scalar, so without path support a LinearScale's own settings cannot be
101
+ // authored at all.
102
+ const created = apply([{ type: 'question.create', questionId: 'q-1', questionType: 'LinearScale' }])
103
+
104
+ const configured = apply(
105
+ [
106
+ { type: 'question.updateField', questionId: 'q-1', field: 'scale.from', value: 1 },
107
+ { type: 'question.updateField', questionId: 'q-1', field: 'scale.toLabel', value: 'Svært godt' },
108
+ ],
109
+ created,
110
+ )
111
+
112
+ assert.deepEqual(configured.questionsById?.['q-1'], {
113
+ type: 'LinearScale',
114
+ scale: { from: 1, toLabel: 'Svært godt' },
115
+ })
116
+ })
117
+
118
+ it('removes the nested group when its last key is unset, never storing it empty', () => {
119
+ // DOC-LAW-2: an empty collection is not stored. Leaving `{ scale: {} }` behind would change
120
+ // `document_hash` for a document that carries no scale at all, so two clients that took
121
+ // different routes to the same state would disagree about the hash.
122
+ const configured = apply([
123
+ { type: 'question.create', questionId: 'q-1', questionType: 'LinearScale' },
124
+ { type: 'question.updateField', questionId: 'q-1', field: 'scale.from', value: 1 },
125
+ ])
126
+
127
+ const cleared = applyOperation(configured, {
128
+ type: 'question.updateField',
129
+ questionId: 'q-1',
130
+ field: 'scale.from',
131
+ value: null,
132
+ })
133
+
134
+ assert.deepEqual(cleared.questionsById?.['q-1'], { type: 'LinearScale' })
135
+ })
136
+
137
+ it('keeps sibling keys when one nested key is unset', () => {
138
+ const configured = apply([
139
+ { type: 'question.create', questionId: 'q-1', questionType: 'LinearScale' },
140
+ { type: 'question.updateField', questionId: 'q-1', field: 'scale.from', value: 1 },
141
+ { type: 'question.updateField', questionId: 'q-1', field: 'scale.to', value: 10 },
142
+ ])
143
+
144
+ const cleared = applyOperation(configured, {
145
+ type: 'question.updateField',
146
+ questionId: 'q-1',
147
+ field: 'scale.from',
148
+ value: null,
149
+ })
150
+
151
+ assert.deepEqual(cleared.questionsById?.['q-1'], { type: 'LinearScale', scale: { to: 10 } })
152
+ })
153
+
154
+ it('does not mutate the document a nested write was derived from', () => {
155
+ // The store keeps the confirmed base and replays pending ops onto it, so a nested write that
156
+ // reached into the previous object would corrupt the base and make the replay non-repeatable.
157
+ const before = apply([
158
+ { type: 'question.create', questionId: 'q-1', questionType: 'LinearScale' },
159
+ { type: 'question.updateField', questionId: 'q-1', field: 'scale.from', value: 1 },
160
+ ])
161
+
162
+ applyOperation(before, { type: 'question.updateField', questionId: 'q-1', field: 'scale.to', value: 10 })
163
+
164
+ assert.deepEqual(before.questionsById?.['q-1'], { type: 'LinearScale', scale: { from: 1 } })
165
+ })
166
+
167
+ it('renames an alternative in place, keeping the id every answer references', () => {
168
+ // The whole reason this op exists rather than delete-then-create: an answer stores the
169
+ // alternative id, so a rename that mints a new id orphans every answer that chose it.
170
+ const created = apply([
171
+ { type: 'question.create', questionId: 'q-1', questionType: 'RadioButtons' },
172
+ { type: 'alternative.create', questionId: 'q-1', alternativeId: 'a-1', label: 'Ja' },
173
+ ])
174
+
175
+ const renamed = applyOperation(created, {
176
+ type: 'alternative.updateField',
177
+ questionId: 'q-1',
178
+ alternativeId: 'a-1',
179
+ field: 'label',
180
+ value: 'Ja, alltid',
181
+ })
182
+
183
+ assert.deepEqual(renamed.alternativesById, { 'a-1': { label: 'Ja, alltid' } })
184
+ assert.deepEqual(renamed.alternativeOrderByQuestionId, { 'q-1': ['a-1'] })
185
+ })
186
+
187
+ it('reorders alternatives without touching their values', () => {
188
+ const created = apply([
189
+ { type: 'question.create', questionId: 'q-1', questionType: 'CheckBoxes' },
190
+ { type: 'alternative.create', questionId: 'q-1', alternativeId: 'a-1', label: 'En' },
191
+ { type: 'alternative.create', questionId: 'q-1', alternativeId: 'a-2', label: 'To' },
192
+ { type: 'alternative.create', questionId: 'q-1', alternativeId: 'a-3', label: 'Tre' },
193
+ ])
194
+
195
+ const moved = applyOperation(created, {
196
+ type: 'alternative.move',
197
+ questionId: 'q-1',
198
+ alternativeId: 'a-3',
199
+ toIndex: 0,
200
+ })
201
+
202
+ assert.deepEqual(moved.alternativeOrderByQuestionId?.['q-1'], ['a-3', 'a-1', 'a-2'])
203
+ assert.deepEqual(moved.alternativesById, created.alternativesById)
204
+ })
205
+
206
+ it('refuses to edit or move an alternative through the wrong question', () => {
207
+ // An id that exists but hangs off another question means the clients disagree about
208
+ // structure; writing the value anyway would report success and diverge the documents.
209
+ const created = apply([
210
+ { type: 'question.create', questionId: 'q-1', questionType: 'RadioButtons' },
211
+ { type: 'question.create', questionId: 'q-2', questionType: 'RadioButtons' },
212
+ { type: 'alternative.create', questionId: 'q-1', alternativeId: 'a-1', label: 'Ja' },
213
+ ])
214
+
215
+ assert.throws(
216
+ () =>
217
+ applyOperation(created, {
218
+ type: 'alternative.updateField',
219
+ questionId: 'q-2',
220
+ alternativeId: 'a-1',
221
+ field: 'label',
222
+ value: 'Nei',
223
+ }),
224
+ OperationConflictError,
225
+ )
226
+
227
+ assert.throws(
228
+ () => applyOperation(created, { type: 'alternative.move', questionId: 'q-2', alternativeId: 'a-1', toIndex: 0 }),
229
+ OperationConflictError,
230
+ )
231
+ })
232
+
233
+ it('refuses to edit an alternative that does not exist', () => {
234
+ const created = apply([{ type: 'question.create', questionId: 'q-1', questionType: 'RadioButtons' }])
235
+
236
+ assert.throws(
237
+ () =>
238
+ applyOperation(created, {
239
+ type: 'alternative.updateField',
240
+ questionId: 'q-1',
241
+ alternativeId: 'ghost',
242
+ field: 'label',
243
+ value: 'Ja',
244
+ }),
245
+ OperationConflictError,
246
+ )
247
+ })
248
+
97
249
  it('refuses a duplicate create as a conflict', () => {
98
- const once = applyOperation(doc0, { type: 'question.create', questionId: 'q-1', kind: 'text' })
250
+ const once = applyOperation(doc0, { type: 'question.create', questionId: 'q-1', questionType: 'TextShort' })
99
251
 
100
252
  assert.throws(
101
- () => applyOperation(once, { type: 'question.create', questionId: 'q-1', kind: 'text' }),
253
+ () => applyOperation(once, { type: 'question.create', questionId: 'q-1', questionType: 'TextShort' }),
102
254
  (error: unknown) => {
103
255
  assert.ok(error instanceof OperationConflictError)
104
256
  assert.equal(error.statusCode, 409)
@@ -51,11 +51,38 @@ const targetKey = (target: BindingTarget): string =>
51
51
  ? `question:${target.questionId}`
52
52
  : `gridColumn:${target.gridQuestionId}:${target.columnQuestionId}`
53
53
 
54
- /** Sets a key, or removes it when the op carried an explicit unset. */
54
+ /**
55
+ * Sets a key, or removes it when the op carried an explicit unset.
56
+ *
57
+ * `field` may be a dotted path (`scale.from`). The per-type configuration in the document is nested
58
+ * — `question.scale.{from, to, …}`, `question.numberFormat.{…}` — while an op value is a scalar, so
59
+ * without a path those groups are unauthorable. Intermediate objects are created on write and
60
+ * **removed again when their last key is unset**, because DOC-LAW-2 forbids storing an empty
61
+ * collection: leaving `{ scale: {} }` behind would change `document_hash` for a document that
62
+ * carries no scale at all.
63
+ */
55
64
  const writeField = <T extends Record<string, unknown>>(record: T, field: string, value: unknown): T => {
65
+ const [head, ...rest] = field.split('.')
66
+ if (head === undefined || head === '') return record
67
+
56
68
  const next = { ...record } as Record<string, unknown>
57
- if (value === null || value === undefined) delete next[field]
58
- else next[field] = value
69
+
70
+ if (rest.length === 0) {
71
+ if (value === null || value === undefined) delete next[head]
72
+ else next[head] = value
73
+ return next as T
74
+ }
75
+
76
+ const child = next[head]
77
+ const nested = writeField(
78
+ (typeof child === 'object' && child !== null && !Array.isArray(child) ? child : {}) as Record<string, unknown>,
79
+ rest.join('.'),
80
+ value,
81
+ )
82
+
83
+ if (Object.keys(nested).length === 0) delete next[head]
84
+ else next[head] = nested
85
+
59
86
  return next as T
60
87
  }
61
88
 
@@ -166,7 +193,7 @@ const reduce = (doc: QnrTemplateDocument, op: TemplateOp): QnrTemplateDocument =
166
193
  }
167
194
  return {
168
195
  ...doc,
169
- questionsById: { ...(doc.questionsById ?? {}), [op.questionId]: { kind: op.kind } },
196
+ questionsById: { ...(doc.questionsById ?? {}), [op.questionId]: { type: op.questionType } },
170
197
  questionOrder: insertAt(doc.questionOrder, op.questionId, op.atIndex),
171
198
  }
172
199
  }
@@ -230,6 +257,44 @@ const reduce = (doc: QnrTemplateDocument, op: TemplateOp): QnrTemplateDocument =
230
257
  }
231
258
  }
232
259
 
260
+ case 'alternative.updateField': {
261
+ const alternative = doc.alternativesById?.[op.alternativeId]
262
+ if (!alternative) {
263
+ throw new OperationConflictError(`Unknown alternative "${op.alternativeId}"`)
264
+ }
265
+ // The question is checked too: an alternative id that exists but hangs off a different
266
+ // question means the two clients disagree about the structure, not just the value, and
267
+ // writing the field anyway would hide that behind a successful edit.
268
+ if (!doc.alternativeOrderByQuestionId?.[op.questionId]?.includes(op.alternativeId)) {
269
+ throw new OperationConflictError(
270
+ `Alternative "${op.alternativeId}" does not belong to question "${op.questionId}"`,
271
+ )
272
+ }
273
+ return {
274
+ ...doc,
275
+ alternativesById: {
276
+ ...doc.alternativesById,
277
+ [op.alternativeId]: writeField(alternative, op.field, op.value),
278
+ },
279
+ }
280
+ }
281
+
282
+ case 'alternative.move': {
283
+ const order = doc.alternativeOrderByQuestionId?.[op.questionId]
284
+ if (!order?.includes(op.alternativeId)) {
285
+ throw new OperationConflictError(
286
+ `Alternative "${op.alternativeId}" does not belong to question "${op.questionId}"`,
287
+ )
288
+ }
289
+ return {
290
+ ...doc,
291
+ alternativeOrderByQuestionId: {
292
+ ...doc.alternativeOrderByQuestionId,
293
+ [op.questionId]: moveInOrder(order, op.alternativeId, op.toIndex),
294
+ },
295
+ }
296
+ }
297
+
233
298
  case 'alternative.delete': {
234
299
  const order = doc.alternativeOrderByQuestionId?.[op.questionId] ?? []
235
300
  const remaining = order.filter((id) => id !== op.alternativeId)
@@ -19,6 +19,7 @@
19
19
  * @see asma-modules/_docs/editor/qnrs/cross/2026-07-12-21-40-plan-qnr-stage2-new-model-editor-and-sync.md:690 (FILE-001)
20
20
  */
21
21
 
22
+ export * from './questionTypes.js'
22
23
  export * from './templateDocument.js'
23
24
  export * from './operations.js'
24
25
  export * from './applyOperation.js'
@@ -1,4 +1,5 @@
1
1
  import type { AltId, BindingId, BindingTarget, DocScalar, FilterId, NodeId, QuestionId } from './templateDocument.js'
2
+ import type { QuestionType } from './questionTypes.js'
2
3
 
3
4
  /**
4
5
  * The authoring op vocabulary. `entity.action`, stable-id targets only, append-only —
@@ -17,11 +18,20 @@ export type OpValue = DocScalar | null
17
18
 
18
19
  export type TemplateOp =
19
20
  | { type: 'template.updateMeta'; patch: Record<string, OpValue | Record<string, unknown>> }
20
- | { type: 'question.create'; questionId: QuestionId; kind: string; atIndex?: number }
21
+ // `questionType`, not `type`: the envelope already owns `type` for the op name, so the question's
22
+ // own type (which is what lands in the document) needs a distinct key here.
23
+ | { type: 'question.create'; questionId: QuestionId; questionType: QuestionType; atIndex?: number }
21
24
  | { type: 'question.updateField'; questionId: QuestionId; field: string; value: OpValue }
22
25
  | { type: 'question.move'; questionId: QuestionId; toIndex: number }
23
26
  | { type: 'question.delete'; questionId: QuestionId }
24
27
  | { type: 'alternative.create'; questionId: QuestionId; alternativeId: AltId; label?: string; atIndex?: number }
28
+ /**
29
+ * Renaming is its own operation rather than delete-then-create because an alternative's id is
30
+ * referenced by every answer that selected it — recreating it under a new id is how the legacy
31
+ * data ended up with ~11,000 answers pointing at options that no longer exist.
32
+ */
33
+ | { type: 'alternative.updateField'; questionId: QuestionId; alternativeId: AltId; field: string; value: OpValue }
34
+ | { type: 'alternative.move'; questionId: QuestionId; alternativeId: AltId; toIndex: number }
25
35
  | { type: 'alternative.delete'; questionId: QuestionId; alternativeId: AltId }
26
36
  | { type: 'mappingNode.create'; nodeId: NodeId; entityId: string; parentNodeId?: NodeId; relationshipId?: string }
27
37
  | { type: 'mappingNode.delete'; nodeId: NodeId }
@@ -54,20 +64,29 @@ export type TemplateOpType = TemplateOp['type']
54
64
  * The op types this reducer implements. The vocabulary in the architecture doc is
55
65
  * larger (grid rows, tabs, actions, layout, visibility/highlight rules); those slot
56
66
  * into the same registry without changing the envelope.
67
+ *
68
+ * Declared as a total `Record` over the union rather than a bare list, so **omitting an op is a
69
+ * compile error**. `satisfies readonly TemplateOpType[]` only rejected entries that are not op types;
70
+ * it could not notice a missing one, and this list is what downstream validators are built against —
71
+ * an op absent here is an op the server rejects at runtime with nothing red anywhere first.
57
72
  */
58
- export const IMPLEMENTED_OP_TYPES = [
59
- 'template.updateMeta',
60
- 'question.create',
61
- 'question.updateField',
62
- 'question.move',
63
- 'question.delete',
64
- 'alternative.create',
65
- 'alternative.delete',
66
- 'mappingNode.create',
67
- 'mappingNode.delete',
68
- 'mappingBinding.create',
69
- 'mappingBinding.update',
70
- 'mappingBinding.delete',
71
- 'mappingFilter.set',
72
- 'mappingFilter.delete',
73
- ] as const satisfies readonly TemplateOpType[]
73
+ const OP_TYPE_COVERAGE: Record<TemplateOpType, true> = {
74
+ 'template.updateMeta': true,
75
+ 'question.create': true,
76
+ 'question.updateField': true,
77
+ 'question.move': true,
78
+ 'question.delete': true,
79
+ 'alternative.create': true,
80
+ 'alternative.updateField': true,
81
+ 'alternative.move': true,
82
+ 'alternative.delete': true,
83
+ 'mappingNode.create': true,
84
+ 'mappingNode.delete': true,
85
+ 'mappingBinding.create': true,
86
+ 'mappingBinding.update': true,
87
+ 'mappingBinding.delete': true,
88
+ 'mappingFilter.set': true,
89
+ 'mappingFilter.delete': true,
90
+ }
91
+
92
+ export const IMPLEMENTED_OP_TYPES = Object.keys(OP_TYPE_COVERAGE) as readonly TemplateOpType[]
@@ -0,0 +1,69 @@
1
+ import assert from 'node:assert/strict'
2
+ import { describe, it } from 'node:test'
3
+
4
+ import {
5
+ LEGACY_QUESTION_TYPES,
6
+ LEGACY_TO_V2_QUESTION_TYPE,
7
+ type QuestionType,
8
+ QUESTION_TYPES,
9
+ isQuestionType,
10
+ toLegacyQuestionType,
11
+ toV2QuestionType,
12
+ } from './questionTypes.js'
13
+
14
+ /**
15
+ * The register is a contract between two runtimes and a stored hash, so the failure this guards is
16
+ * not "a test is red" but "a question type exists on one side only" — which shows up as a document
17
+ * nobody can render, or a projection that writes a name the legacy wire rejects.
18
+ *
19
+ * @see asma-modules/_docs/editor/qnrs/cross/2026-07-12-21-20-analysis-qnr-template-field-inventory.md:365 — M-062
20
+ */
21
+
22
+ describe('question type register', () => {
23
+ it('maps every legacy type to a v2 type', () => {
24
+ assert.equal(LEGACY_QUESTION_TYPES.length, 19)
25
+
26
+ for (const legacy of LEGACY_QUESTION_TYPES) {
27
+ const mapped = toV2QuestionType(legacy)
28
+ assert.ok(mapped !== undefined, `${legacy} has no v2 mapping`)
29
+ assert.ok(isQuestionType(mapped), `${legacy} maps to ${String(mapped)}, which is not a v2 type`)
30
+ }
31
+ })
32
+
33
+ it('round-trips every type in both directions', () => {
34
+ for (const legacy of LEGACY_QUESTION_TYPES) {
35
+ assert.equal(toLegacyQuestionType(LEGACY_TO_V2_QUESTION_TYPE[legacy]), legacy)
36
+ }
37
+
38
+ for (const type of QUESTION_TYPES) {
39
+ assert.equal(toV2QuestionType(toLegacyQuestionType(type)), type)
40
+ }
41
+ })
42
+
43
+ it('covers the whole v2 union, so no type is reachable only from legacy', () => {
44
+ const reachable = new Set<QuestionType>(Object.values(LEGACY_TO_V2_QUESTION_TYPE))
45
+
46
+ assert.equal(QUESTION_TYPES.length, 19)
47
+ assert.deepEqual([...QUESTION_TYPES].sort(), [...reachable].sort())
48
+ })
49
+
50
+ it('renames CompositeQuestion and nothing else', () => {
51
+ const renamed = LEGACY_QUESTION_TYPES.filter(
52
+ (legacy) => (LEGACY_TO_V2_QUESTION_TYPE[legacy] as string) !== (legacy as string),
53
+ )
54
+
55
+ // The whole backward-compatibility argument rests on this being exactly one entry: 18 types
56
+ // need no translation, so a mapper bug can only ever affect the grid.
57
+ assert.deepEqual(renamed, ['CompositeQuestion'])
58
+ assert.equal(toV2QuestionType('CompositeQuestion'), 'QuestionGrid')
59
+ assert.equal(toLegacyQuestionType('QuestionGrid'), 'CompositeQuestion')
60
+ })
61
+
62
+ it('refuses an unknown legacy type instead of passing it through', () => {
63
+ // Passing it through would put a type in the document that no editor can render and no
64
+ // projection can write back; the import mapper has a report to record this in.
65
+ assert.equal(toV2QuestionType('Telepathy'), undefined)
66
+ assert.equal(toV2QuestionType(''), undefined)
67
+ assert.equal(isQuestionType('CompositeQuestion'), false)
68
+ })
69
+ })
@@ -0,0 +1,126 @@
1
+ /**
2
+ * The question-type register — the one place that says what a question can be.
3
+ *
4
+ * `QnrQuestion.type` is this union rather than `string` on purpose: the value is part of the stored
5
+ * document and therefore part of `document_hash`, so a typo cannot be corrected later without a
6
+ * document migration across every stored version. A closed union makes an unknown type a build
7
+ * error on both sides instead of a row nobody can render.
8
+ *
9
+ * **The values are the legacy `QUESTION_TYPE` values verbatim, with exactly one rename**
10
+ * (`CompositeQuestion` → `QuestionGrid`, OQ-V2-17). That is deliberate backward compatibility: 18 of
11
+ * 19 types need no translation at all, so the import mapper and the reverse projection carry a
12
+ * one-row table rather than a whole vocabulary, and the legacy wire keeps receiving the names it
13
+ * always did.
14
+ *
15
+ * Transcribed from `asma-modules/editor/shared/types/questions/fields/Question.constants.ts`
16
+ * (`QUESTION_TYPE`), which stays canonical for the **legacy** contract. It cannot be imported here:
17
+ * it lives in the polyrepo root, outside both service repos' build contexts.
18
+ *
19
+ * @see asma-modules/_docs/editor/qnrs/cross/2026-07-12-21-20-analysis-qnr-template-field-inventory.md:365 — M-062 `q.type` → `question.type` (19-value enum)
20
+ * @see asma-modules/_docs/editor/qnrs/cross/2026-07-12-21-20-analysis-qnr-template-field-inventory.md:417 — M-098 `q.subtype`
21
+ * @see asma-modules/_docs/editor/qnrs/cross/2026-07-12-21-40-plan-qnr-stage2-new-model-editor-and-sync.md — OQ-V2-17 (CompositeQuestion → QuestionGrid)
22
+ */
23
+
24
+ /** The legacy discriminator values, exactly as `templates.properties` stores them. */
25
+ export const LEGACY_QUESTION_TYPES = [
26
+ 'BooleanQuestion',
27
+ 'Chart',
28
+ 'CheckBoxes',
29
+ 'CompositeQuestion',
30
+ 'DateField',
31
+ 'DocumentUpload',
32
+ 'Dropdown',
33
+ 'Emoticons',
34
+ 'ExpressionQuestion',
35
+ 'FormatNumber',
36
+ 'LinearScale',
37
+ 'Link',
38
+ 'RadioButtons',
39
+ 'Readonly',
40
+ 'Space',
41
+ 'TextLong',
42
+ 'TextShort',
43
+ 'Title',
44
+ 'Widget',
45
+ ] as const
46
+
47
+ export type LegacyQuestionType = (typeof LEGACY_QUESTION_TYPES)[number]
48
+
49
+ /** What a v2 document stores in `question.type`. */
50
+ export const QUESTION_TYPES = [
51
+ 'BooleanQuestion',
52
+ 'Chart',
53
+ 'CheckBoxes',
54
+ 'DateField',
55
+ 'DocumentUpload',
56
+ 'Dropdown',
57
+ 'Emoticons',
58
+ 'ExpressionQuestion',
59
+ 'FormatNumber',
60
+ 'LinearScale',
61
+ 'Link',
62
+ 'QuestionGrid',
63
+ 'RadioButtons',
64
+ 'Readonly',
65
+ 'Space',
66
+ 'TextLong',
67
+ 'TextShort',
68
+ 'Title',
69
+ 'Widget',
70
+ ] as const
71
+
72
+ export type QuestionType = (typeof QUESTION_TYPES)[number]
73
+
74
+ /**
75
+ * Only TextShort and TextLong carry one, and this is its whole vocabulary
76
+ * (`TextShortSubtype` in the legacy register). Typed rather than left open because an unrecognized
77
+ * subtype silently changes how an answer validates.
78
+ */
79
+ export type QuestionSubtype = 'ORDINARY' | 'EMAIL'
80
+
81
+ /**
82
+ * Written out in full rather than derived from the two arrays, so that `Record` makes TypeScript
83
+ * prove the table covers every legacy value — a derived table would need a cast, and the cast is
84
+ * exactly where a missing entry would hide.
85
+ */
86
+ export const LEGACY_TO_V2_QUESTION_TYPE: Record<LegacyQuestionType, QuestionType> = {
87
+ BooleanQuestion: 'BooleanQuestion',
88
+ Chart: 'Chart',
89
+ CheckBoxes: 'CheckBoxes',
90
+ // The one rename in the whole register (OQ-V2-17): a "composite question" is a grid of
91
+ // questions, and the legacy name says nothing about that.
92
+ CompositeQuestion: 'QuestionGrid',
93
+ DateField: 'DateField',
94
+ DocumentUpload: 'DocumentUpload',
95
+ Dropdown: 'Dropdown',
96
+ Emoticons: 'Emoticons',
97
+ ExpressionQuestion: 'ExpressionQuestion',
98
+ FormatNumber: 'FormatNumber',
99
+ LinearScale: 'LinearScale',
100
+ Link: 'Link',
101
+ RadioButtons: 'RadioButtons',
102
+ Readonly: 'Readonly',
103
+ Space: 'Space',
104
+ TextLong: 'TextLong',
105
+ TextShort: 'TextShort',
106
+ Title: 'Title',
107
+ Widget: 'Widget',
108
+ }
109
+
110
+ const V2_TO_LEGACY_QUESTION_TYPE = Object.fromEntries(
111
+ Object.entries(LEGACY_TO_V2_QUESTION_TYPE).map(([legacy, v2]) => [v2, legacy]),
112
+ ) as Record<QuestionType, LegacyQuestionType>
113
+
114
+ export const isQuestionType = (value: unknown): value is QuestionType =>
115
+ typeof value === 'string' && (QUESTION_TYPES as readonly string[]).includes(value)
116
+
117
+ /**
118
+ * Legacy → v2. Returns `undefined` for anything not in the register instead of passing the value
119
+ * through: an unmapped type reaching a document would be a question no editor can render, and the
120
+ * import has a report to record it in.
121
+ */
122
+ export const toV2QuestionType = (legacy: string): QuestionType | undefined =>
123
+ LEGACY_TO_V2_QUESTION_TYPE[legacy as LegacyQuestionType]
124
+
125
+ /** v2 → legacy, for the projection that writes back to the legacy wire. Total by construction. */
126
+ export const toLegacyQuestionType = (type: QuestionType): LegacyQuestionType => V2_TO_LEGACY_QUESTION_TYPE[type]
@@ -12,6 +12,8 @@
12
12
  * @see _docs/editor/qnrs/cross/2026-07-12-20-20-architecture-qnr-v2-model-collaboration-sync.md:214 (§2.2a mapping graph)
13
13
  */
14
14
 
15
+ import type { QuestionSubtype, QuestionType } from './questionTypes.js'
16
+
15
17
  export type QuestionId = string
16
18
  export type RowId = string
17
19
  export type AltId = string
@@ -25,8 +27,15 @@ export type MappingId = string
25
27
  /** A scalar a document may carry. Deliberately not `any`: DOC-LAW-2 bans `null`. */
26
28
  export type DocScalar = string | number | boolean
27
29
 
30
+ /**
31
+ * `type` is the question's own discriminator (M-062), a closed union rather than a string — see
32
+ * `questionTypes.ts` for why the value cannot be loose. Not to be confused with the other `kind`
33
+ * slots in this file: `QnrAction.kind` and `BindingTarget.kind` discriminate *structure*, not the
34
+ * question a user authored.
35
+ */
28
36
  export type QnrQuestion = {
29
- kind: string
37
+ type: QuestionType
38
+ subtype?: QuestionSubtype
30
39
  label?: string
31
40
  required?: boolean
32
41
  defaultValue?: DocScalar