asma-core-helpers 0.30.0 → 0.31.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.
Files changed (31) hide show
  1. package/lib/collaboration/applyOperation.d.ts +33 -1
  2. package/lib/collaboration/applyOperation.d.ts.map +1 -1
  3. package/lib/collaboration/applyOperation.js +633 -9
  4. package/lib/collaboration/applyOperation.js.map +1 -1
  5. package/lib/collaboration/operations.d.ts +109 -2
  6. package/lib/collaboration/operations.d.ts.map +1 -1
  7. package/lib/collaboration/operations.js +7 -0
  8. package/lib/collaboration/operations.js.map +1 -1
  9. package/lib/collaboration/schemas.d.ts +163 -0
  10. package/lib/collaboration/schemas.d.ts.map +1 -1
  11. package/lib/collaboration/schemas.js +173 -3
  12. package/lib/collaboration/schemas.js.map +1 -1
  13. package/lib/collaboration/templateDocument.d.ts +176 -0
  14. package/lib/collaboration/templateDocument.d.ts.map +1 -1
  15. package/lib/collaboration/templateDocument.js +9 -0
  16. package/lib/collaboration/templateDocument.js.map +1 -1
  17. package/lib/collaboration/testHelpers/documentGenerator.js +78 -1
  18. package/lib/collaboration/testHelpers/documentGenerator.js.map +1 -1
  19. package/lib/collaboration/typeContracts.d.ts +53 -0
  20. package/lib/collaboration/typeContracts.d.ts.map +1 -0
  21. package/lib/collaboration/typeContracts.js +2 -0
  22. package/lib/collaboration/typeContracts.js.map +1 -0
  23. package/package.json +1 -1
  24. package/src/collaboration/applyOperation.ts +736 -9
  25. package/src/collaboration/operations.ts +97 -0
  26. package/src/collaboration/schemas.ts +191 -1
  27. package/src/collaboration/templateDocument.ts +167 -1
  28. package/src/collaboration/testHelpers/documentGenerator.ts +77 -1
  29. package/src/collaboration/typeContracts.ts +57 -0
  30. package/src/collaboration/typedAuthoring.test.ts +641 -0
  31. package/src/collaboration/typedAuthoringHardening.test.ts +408 -0
@@ -1,5 +1,5 @@
1
1
  import type { TemplateOp } from './operations.js';
2
- import type { QnrTemplateDocument } from './templateDocument.js';
2
+ import type { KnownActionKind, QnrTemplateDocument } from './templateDocument.js';
3
3
  /**
4
4
  * The authoring reducer. Pure: takes a document and an op, returns a new document with
5
5
  * `revision` bumped by one. The frontend applies it locally before the op leaves the
@@ -35,5 +35,37 @@ export declare class UnknownOperationError extends CollaborationError {
35
35
  export declare class OperationConflictError extends CollaborationError {
36
36
  constructor(message: string);
37
37
  }
38
+ /**
39
+ * The action, if it is a KNOWN one — `kind` inside the closed vocabulary.
40
+ *
41
+ * A legacy record with an unknown `kind` is not "known but unrecognised": the typed ops refuse it
42
+ * outright rather than half-applying rules written for a different shape, which is what keeps old
43
+ * documents replaying byte-identically.
44
+ */
45
+ /**
46
+ * Why `field` may not be written as an ordinary tab field edit, or `undefined` if it may.
47
+ *
48
+ * `layout.placementsByQuestionId` is reserved for `tab.setLayout`. Unlike the grid's filter list this
49
+ * one is not even expressible as an `OpValue` — a placement is an object — so the realistic misuse is a
50
+ * write to an ANCESTOR (`layout`, or the placements map cleared wholesale), which would drop every other
51
+ * question's placement in one edit. Both directions of overlap are refused; `label` and any other
52
+ * authored scalar stay ordinary field edits.
53
+ */
54
+ export declare const tabFieldPathRefusal: (field: string) => string | undefined;
55
+ /**
56
+ * Why `field` may not be written on a KNOWN action, or `undefined` if it may.
57
+ *
58
+ * Applies to known kinds only: a legacy record keeps taking any field, buffers included, because that
59
+ * is what makes an already-stored action replay byte-identically (ADR-0008 DEC-006).
60
+ */
61
+ export declare const knownActionFieldRefusal: (kind: KnownActionKind, field: string) => string | undefined;
62
+ /**
63
+ * Why `value` may not be written to a permitted known-action field, or `undefined` if it may.
64
+ *
65
+ * The whitelist alone would still let `actionType: 'DELETE'` or a numeric `label` through, turning a
66
+ * typed record into a malformed one that every downstream reader has to re-check. `null` is the explicit
67
+ * unset the op layer carries, so it is legal for both.
68
+ */
69
+ export declare const knownActionValueRefusal: (field: string, value: unknown) => string | undefined;
38
70
  export declare const applyOperation: (document: QnrTemplateDocument, op: TemplateOp) => QnrTemplateDocument;
39
71
  //# sourceMappingURL=applyOperation.d.ts.map
@@ -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,EAQR,mBAAmB,EAEtB,MAAM,uBAAuB,CAAA;AAM9B;;;;;;;;;;;;;;;;GAgBG;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;AA8gBD,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,EAGR,eAAe,EAUf,mBAAmB,EAEtB,MAAM,uBAAuB,CAAA;AAmB9B;;;;;;;;;;;;;;;;GAgBG;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,qB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