@cratis/screenplay-language 4.171.0 → 4.172.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 (69) hide show
  1. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
  2. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
  3. package/dist/bundles/compiler/Generation/BoundedRegexSamples.js +1 -0
  4. package/dist/bundles/compiler/Generation/FiniteGenerationRules.js +1 -0
  5. package/dist/bundles/compiler/Generation/FinitePatternContainment.js +1 -0
  6. package/dist/bundles/compiler/Generation/GenerationAssessmentCache.js +2 -0
  7. package/dist/bundles/compiler/Generation/GenerationAssessmentCache.js.map +1 -0
  8. package/dist/bundles/compiler/Generation/GenerationChecksum.js +2 -0
  9. package/dist/bundles/compiler/Generation/GenerationChecksum.js.map +1 -0
  10. package/dist/bundles/compiler/Generation/GenerationPattern.js +2 -0
  11. package/dist/bundles/compiler/Generation/GenerationPattern.js.map +1 -0
  12. package/dist/bundles/compiler/Generation/GenerationPatternAssessment.js +2 -0
  13. package/dist/bundles/compiler/Generation/GenerationPatternAssessment.js.map +1 -0
  14. package/dist/bundles/compiler/Generation/GenerationPatternParser.js +2 -0
  15. package/dist/bundles/compiler/Generation/GenerationPatternParser.js.map +1 -0
  16. package/dist/bundles/compiler/Generation/GenerationPatternToken.js +2 -0
  17. package/dist/bundles/compiler/Generation/GenerationPatternToken.js.map +1 -0
  18. package/dist/bundles/compiler/Generation/GenerationRuleProof.js +1 -0
  19. package/dist/bundles/compiler/Generation/InvalidGenerationPattern.js +2 -0
  20. package/dist/bundles/compiler/Generation/InvalidGenerationPattern.js.map +1 -0
  21. package/dist/bundles/compiler/Generation/RegexCharacters.js +2 -0
  22. package/dist/bundles/compiler/Generation/RegexCharacters.js.map +1 -0
  23. package/dist/bundles/compiler/Generation/RegexExpression.js +2 -0
  24. package/dist/bundles/compiler/Generation/RegexExpression.js.map +1 -0
  25. package/dist/bundles/compiler/Generation/RegexFragmentR.js +1 -0
  26. package/dist/bundles/compiler/Generation/RuleConsistency.js +1 -0
  27. package/dist/bundles/compiler/Generation/index.js +1 -0
  28. package/dist/bundles/compiler/Parsing/CommandParser.js +1 -1
  29. package/dist/bundles/compiler/Parsing/CommandParser.js.map +1 -1
  30. package/dist/bundles/compiler/Parsing/GenerationBodyParser.js +2 -0
  31. package/dist/bundles/compiler/Parsing/GenerationBodyParser.js.map +1 -0
  32. package/dist/bundles/compiler/Parsing/GenerationParser.js +1 -1
  33. package/dist/bundles/compiler/Parsing/GenerationParser.js.map +1 -1
  34. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js +1 -1
  35. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js.map +1 -1
  36. package/dist/bundles/compiler/Syntax/SyntaxCollections.js +1 -1
  37. package/dist/bundles/compiler/Syntax/SyntaxCollections.js.map +1 -1
  38. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js +1 -1
  39. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js.map +1 -1
  40. package/dist/bundles/compiler/Syntax/SyntaxJson.js +1 -1
  41. package/dist/bundles/compiler/Syntax/SyntaxJson.js.map +1 -1
  42. package/dist/bundles/completion-items.js +1 -1
  43. package/dist/bundles/completion-items.js.map +1 -1
  44. package/dist/bundles/completion-planner.js +2 -2
  45. package/dist/bundles/completion-planner.js.map +1 -1
  46. package/dist/bundles/diagnostic-codes.js +1 -1
  47. package/dist/bundles/diagnostic-codes.js.map +1 -1
  48. package/dist/bundles/generation-completions.js +1 -1
  49. package/dist/bundles/generation-completions.js.map +1 -1
  50. package/dist/bundles/hover-content.js +1 -1
  51. package/dist/bundles/hover-content.js.map +1 -1
  52. package/dist/bundles/keyword-docs.js +1 -1
  53. package/dist/bundles/keyword-docs.js.map +1 -1
  54. package/dist/bundles/language.js +1 -1
  55. package/dist/bundles/language.js.map +1 -1
  56. package/dist/bundles/tokens.js +1 -1
  57. package/dist/bundles/tokens.js.map +1 -1
  58. package/dist/bundles/validation.js +1 -1
  59. package/dist/bundles/validation.js.map +1 -1
  60. package/dist/completion-items.d.ts.map +1 -1
  61. package/dist/completion-planner.d.ts.map +1 -1
  62. package/dist/diagnostic-codes.d.ts +2 -0
  63. package/dist/diagnostic-codes.d.ts.map +1 -1
  64. package/dist/generation-completions.d.ts.map +1 -1
  65. package/dist/hover-content.d.ts.map +1 -1
  66. package/dist/keyword-docs.d.ts.map +1 -1
  67. package/dist/language.d.ts.map +1 -1
  68. package/dist/tokens.d.ts.map +1 -1
  69. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{isExactNumberToken as e,parseExactNumber as t}from"./ExactNumber.js";import{InvalidSyntaxJson as n}from"./InvalidSyntaxJson.js";import{legacySourceOptions as r,validatedSourceOptions as i}from"./SourceOptions.js";import{validateSyntaxInvariants as a}from"./SyntaxInvariants.js";import{syntaxMemberNames as o,validateClosedSyntaxMembers as s,validateSyntaxMembers as c}from"./SyntaxMemberContracts.js";import{isLegacyOmittedMember as l}from"./LegacyWireProjection.js";const isNode=e=>typeof e==`object`&&!!e&&typeof e.kind==`string`,isObject=e=>typeof e==`object`&&!!e,u=/* @__PURE__ */ new Set([`kind`,`location`,`targetLocation`,`referenceLocation`,`referenceLength`,`nameWasEscaped`,`declaredTriggers`,`directiveLocations`]),d=/* @__PURE__ */ new Set([`location`,`targetLocation`,`usesLocation`]),f=/* @__PURE__ */ new Set([`ApplicationSyntax`,`ProjectionSyntax`,`CaptureSyntax`,`SpecificationSyntax`]);function toSyntaxJson(e){let t=snapshot(e);return validateNumbers(t,`legacy`,0),write(t)}function snapshot(e){let t=/* @__PURE__ */ new WeakMap,n=[];function detach(e){return isObject(e)?t.has(e)?t.get(e):Array.isArray(e)?detachArray(e):detachObject(e):e}function detachArray(e){let r=dataArray();t.set(e,r);let i=e.length;for(let t=i-1;t>=0;t--)n.push(()=>{r[t]=detach(Object.hasOwn(e,t)?e[t]:void 0)});return r}function detachObject(e){let r=Object.create(null);t.set(e,r);let i=Object.keys(e);!i.includes(`kind`)&&`kind`in e&&i.unshift(`kind`);for(let t=i.length-1;t>=0;t--)n.push(()=>{let a=i[t],o=e[a];a===`sourceOptions`&&n.push(()=>preserveRejectedSourceOptions(r,a,o)),r[a]=detach(o)});return r}let r=detach(e);for(;n.length>0;)n.pop()();return r}function preserveRejectedSourceOptions(e,t,n){isObject(n)&&hasExoticShape(n)&&(e[t]=Object.assign(Object.create(null),{numericMode:`invalid`}))}function hasExoticShape(e){return Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null||Reflect.ownKeys(e).length!==Object.keys(e).length}function dataArray(){let e=[];return Object.defineProperty(e,"toJSON",{value:void 0}),e}const p={ApplicationSyntax:[`identity`],EventSyntax:[`origin`],ImportSyntax:[`origin`],SliceSyntax:[`direction`],ReactionSyntax:[`from`],ReducerSyntax:[`from`],ProducesSyntax:[`stream`],ConceptAttributeSyntax:[`scope`,`specialCategory`],ConceptSyntax:[`description`,`valueNumbers`,`generation`],PolicySyntax:[`description`],FileConstraintSyntax:[`description`],UniqueEventConstraintSyntax:[`description`],UniquePropertyConstraintSyntax:[`description`],ProjectionSyntax:[`description`],ScreenSyntax:[`description`],FormSyntax:[`description`],SpecificationSyntax:[`description`,`whenRedelivered`],SpecificationErrorSyntax:[`caseValue`],SpecificationExampleSyntax:[`stream`,`noStream`],SpecificationRedeliverySyntax:[`stream`,`noStream`]},m={ModuleSyntax:[`dependsOn`],FeatureSyntax:[`dependsOn`],SpecificationSyntax:[`parameters`,`cases`],InvokesSyntax:[`onRefused`]},h={EventSyntax:{visibility:`Private`},ImportSyntax:{visibility:`Private`},ConceptAttributeSyntax:{criminal:!1},PropertySyntax:{isSubject:!1},SpecificationSyntax:{thenNoEvents:!1}},ownEntry=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0,isEmptyArray=e=>Array.isArray(e)&&e.length===0;function isNullOmitted(e,t,n){return n==null?ownEntry(p,e)?.includes(t)===!0||t===`inlineProperty`||t===`documentation`&&e!==`EventSyntax`:!1}function isEmptyOmitted(e,t,n){return isEmptyArray(n)?ownEntry(m,e)?.includes(t)===!0||t===`examples`||t===`purposes`:!1}function isDefaultOmitted(e,t,n){if(t===`sourceOptions`)return n?.numericMode===`legacy`;let r=ownEntry(h,e);return r!==void 0&&Object.hasOwn(r,t)&&n===r[t]}function isOmittedByDefault(e,t,n){return isNullOmitted(e,t,n)||isEmptyOmitted(e,t,n)||isDefaultOmitted(e,t,n)}function write(e,t=`legacy`,n=!1){return Array.isArray(e)?writeArray(e,t,n):isNode(e)?writeNode(e,t,n):e===void 0?null:isObject(e)?writeRecord(e,t,n):e}function writeArray(e,t,n){let r=dataArray();for(let i=0;i<e.length;i++)r.push(write(e[i],t,n));return r}function validateClosedImplementationShapes(e){if((e.kind===`ImplementationSyntax`||e.kind===`ImplementationHintSyntax`)&&s(e,u),e.kind!==`ValidationRuleSyntax`)return;let t=e;t.implementation!=null&&(t.file!=null&&s(t.file,u),t.code!=null&&s(t.code,u))}function structuralMembers(e){let t={...e};return e.kind===`ApplicationSyntax`&&t.eventSources===void 0&&(t.eventSources=[]),e.kind===`CommandSyntax`&&t.stream===void 0&&(t.stream=null),e.kind===`CommandSyntax`&&t.streamCandidates===void 0&&(t.streamCandidates=[]),t}function projectedMemberNames(e,t,n,r){let i=n===`exact`?o(e.kind):void 0,isProjected=t=>(i===void 0||i.has(t))&&!isHiddenByLegacy(e,t,n,r)&&!isAlwaysOmitted(e,t);return Object.keys(t).filter(isProjected).sort(ordinal)}function isHiddenByLegacy(e,t,n,r){return n===`legacy`&&!r&&l(e,t)}function isAlwaysOmitted(e,t){return u.has(t)||e.kind===`OperationSyntax`&&t===`usesLocation`}function writeNode(e,t,n){f.has(e.kind)&&(t=i(e.sourceOptions??r).numericMode),a(e),validateClosedImplementationShapes(e);let o=Object.create(null);o.kind=e.kind;let s=structuralMembers(e);for(let r of projectedMemberNames(e,s,t,n)){let i=s[r];isOmittedByDefault(e.kind,r,i)||(o[r]=write(i,t,n))}return o}function writeRecord(e,t,n){let r=Object.create(null);if(e.literalType===`ExactNumber`)return r.literalType=`ExactNumber`,r.value=e.value,r;for(let i of Object.keys(e))i!==`toJSON`&&e[i]!==void 0&&(r[i]=write(e[i],t,n));return r}function validateNumbers(e,t,n){if(assertSupportedDepth(t,n),Array.isArray(e))for(let r=0;r<e.length;r++)validateNumbers(e[r],t,n+1);else isObject(e)&&validateNodeNumbers(e,t,n)}function validateNodeNumbers(e,t,n){t=resolveNumericMode(e,t,n),assertCompleteSourceRoot(e,t,n),t===`exact`&&isNode(e)&&c(e),validateRawNumericText(e,t),e.kind===`LiteralExpressionSyntax`&&Object.hasOwn(e,`value`)&&validateLiteralValue(e.value,t),validateNumberMembers(e,t,n)}function assertSupportedDepth(e,t){if(t>96&&e===`exact`)throw new n(`Syntax nesting exceeds the supported depth of 96.`)}function assertCompleteSourceRoot(e,t,r){if(isIncompleteExactRoot(e,t,r))throw new n(`Exact syntax requires a complete source root.`)}function isIncompleteExactRoot(e,t,n){return n===0&&t===`exact`&&!f.has(e.kind)}function resolveNumericMode(e,t,a){if(!f.has(e.kind)&&!Object.hasOwn(e,`sourceOptions`))return t;let o=Object.hasOwn(e,`sourceOptions`)?i(e.sourceOptions):r;if(a>0&&t!==o.numericMode)throw new n(`Conflicting source numeric options.`);return o.numericMode}function validateRawNumericText(t,r){if(t.kind===`RawExpressionSyntax`&&r===`exact`&&typeof t.text==`string`&&e(t.text))throw new n(`An exact numeric operand must be an explicit ExactNumber, not opaque numeric text.`)}function isUnsupportedExactPrimitive(e){return typeof e==`number`||e!==null&&![`string`,`boolean`,`object`].includes(typeof e)}function validateLiteralValue(e,t){if(t===`exact`&&isUnsupportedExactPrimitive(e))throw new n(`Exact source requires supported primitive values or an explicit ExactNumber literal.`);isObject(e)&&validateObjectLiteral(e,t)}function validateObjectLiteral(e,t){if(e.literalType===`ExactNumber`)validateExactNumberLiteral(e,t);else if(t===`exact`)throw new n(`Exact source refuses old or plain object literal insertion.`)}function isWellFormedExactNumber(e){return typeof e.value==`string`&&t(e.value)?.value===e.value&&Object.keys(e).length===2}function validateExactNumberLiteral(e,t){if(t!==`exact`||!isWellFormedExactNumber(e))throw new n(`Malformed or incompatible ExactNumber literal.`)}function validateNumberMembers(e,t,n){let r=t===`exact`&&isNode(e)?o(e.kind):void 0;for(let[i,a]of Object.entries(e))isTraversedMember(r,i,a)&&validateNumbers(a,t,n+1)}function isTraversedMember(e,t,n){return(e===void 0||e.has(t)||isNode(n)&&f.has(n.kind))&&!d.has(t)}function ordinal(e,t){return e<t?-1:+(e>t)}export{toSyntaxJson};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{isExactNumberToken as e,parseExactNumber as t}from"./ExactNumber.js";import{InvalidSyntaxJson as n}from"./InvalidSyntaxJson.js";import{legacySourceOptions as r,validatedSourceOptions as i}from"./SourceOptions.js";import{validateSyntaxInvariants as a}from"./SyntaxInvariants.js";import{syntaxMemberNames as o,validateClosedSyntaxMembers as s,validateSyntaxMembers as c}from"./SyntaxMemberContracts.js";import{isLegacyOmittedMember as l}from"./LegacyWireProjection.js";const isNode=e=>typeof e==`object`&&!!e&&typeof e.kind==`string`,isObject=e=>typeof e==`object`&&!!e,u=/* @__PURE__ */ new Set([`kind`,`location`,`targetLocation`,`referenceLocation`,`referenceLength`,`nameWasEscaped`,`declaredTriggers`,`directiveLocations`]),d=/* @__PURE__ */ new Set([`location`,`targetLocation`,`usesLocation`]),f=/* @__PURE__ */ new Set([`ApplicationSyntax`,`ProjectionSyntax`,`CaptureSyntax`,`SpecificationSyntax`]);function toSyntaxJson(e){let t=snapshot(e);return validateNumbers(t,`legacy`,0),write(t)}function snapshot(e){let t=/* @__PURE__ */ new WeakMap,n=[];function detach(e){return isObject(e)?t.has(e)?t.get(e):Array.isArray(e)?detachArray(e):detachObject(e):e}function detachArray(e){let r=dataArray();t.set(e,r);let i=e.length;for(let t=i-1;t>=0;t--)n.push(()=>{r[t]=detach(Object.hasOwn(e,t)?e[t]:void 0)});return r}function detachObject(e){let r=Object.create(null);t.set(e,r);let i=Object.keys(e);!i.includes(`kind`)&&`kind`in e&&i.unshift(`kind`);for(let t=i.length-1;t>=0;t--)n.push(()=>{let a=i[t],o=e[a];a===`sourceOptions`&&n.push(()=>preserveRejectedSourceOptions(r,a,o)),r[a]=detach(o)});return r}let r=detach(e);for(;n.length>0;)n.pop()();return r}function preserveRejectedSourceOptions(e,t,n){isObject(n)&&hasExoticShape(n)&&(e[t]=Object.assign(Object.create(null),{numericMode:`invalid`}))}function hasExoticShape(e){return Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null||Reflect.ownKeys(e).length!==Object.keys(e).length}function dataArray(){let e=[];return Object.defineProperty(e,"toJSON",{value:void 0}),e}const p={ApplicationSyntax:[`identity`],EventSyntax:[`origin`],ImportSyntax:[`origin`],SliceSyntax:[`direction`],ReactionSyntax:[`from`],ReducerSyntax:[`from`],ProducesSyntax:[`stream`],ConceptAttributeSyntax:[`scope`,`specialCategory`],ConceptSyntax:[`description`,`valueNumbers`,`generation`],GenerationSyntax:[`file`,`code`],PolicySyntax:[`description`],FileConstraintSyntax:[`description`],UniqueEventConstraintSyntax:[`description`],UniquePropertyConstraintSyntax:[`description`],ProjectionSyntax:[`description`],ScreenSyntax:[`description`],FormSyntax:[`description`],SpecificationSyntax:[`description`,`whenRedelivered`],SpecificationErrorSyntax:[`caseValue`],SpecificationExampleSyntax:[`stream`,`noStream`],SpecificationRedeliverySyntax:[`stream`,`noStream`]},m={ModuleSyntax:[`dependsOn`],FeatureSyntax:[`dependsOn`],SpecificationSyntax:[`parameters`,`cases`],InvokesSyntax:[`onRefused`]},h={EventSyntax:{visibility:`Private`},ImportSyntax:{visibility:`Private`},ConceptAttributeSyntax:{criminal:!1},PropertySyntax:{isSubject:!1},SpecificationSyntax:{thenNoEvents:!1}},ownEntry=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0,isEmptyArray=e=>Array.isArray(e)&&e.length===0;function isNullOmitted(e,t,n){return n==null?ownEntry(p,e)?.includes(t)===!0||t===`inlineProperty`||t===`documentation`&&e!==`EventSyntax`:!1}function isEmptyOmitted(e,t,n){return isEmptyArray(n)?ownEntry(m,e)?.includes(t)===!0||t===`examples`||t===`purposes`:!1}function isDefaultOmitted(e,t,n){if(t===`sourceOptions`)return n?.numericMode===`legacy`;let r=ownEntry(h,e);return r!==void 0&&Object.hasOwn(r,t)&&n===r[t]}function isOmittedByDefault(e,t,n){return isNullOmitted(e,t,n)||isEmptyOmitted(e,t,n)||isDefaultOmitted(e,t,n)}function write(e,t=`legacy`,n=!1){return Array.isArray(e)?writeArray(e,t,n):isNode(e)?writeNode(e,t,n):e===void 0?null:isObject(e)?writeRecord(e,t,n):e}function writeArray(e,t,n){let r=dataArray();for(let i=0;i<e.length;i++)r.push(write(e[i],t,n));return r}function validateClosedImplementationShapes(e){if((e.kind===`ImplementationSyntax`||e.kind===`ImplementationHintSyntax`)&&s(e,u),e.kind!==`ValidationRuleSyntax`)return;let t=e;t.implementation!=null&&(t.file!=null&&s(t.file,u),t.code!=null&&s(t.code,u))}function structuralMembers(e){let t={...e};return e.kind===`ApplicationSyntax`&&t.eventSources===void 0&&(t.eventSources=[]),e.kind===`CommandSyntax`&&t.stream===void 0&&(t.stream=null),e.kind===`CommandSyntax`&&t.streamCandidates===void 0&&(t.streamCandidates=[]),t}function projectedMemberNames(e,t,n,r){let i=n===`exact`?o(e.kind):void 0,isProjected=t=>(i===void 0||i.has(t))&&!isHiddenByLegacy(e,t,n,r)&&!isAlwaysOmitted(e,t);return Object.keys(t).filter(isProjected).sort(ordinal)}function isHiddenByLegacy(e,t,n,r){return n===`legacy`&&!r&&l(e,t)}function isAlwaysOmitted(e,t){return u.has(t)||e.kind===`OperationSyntax`&&t===`usesLocation`}function writeNode(e,t,n){f.has(e.kind)&&(t=i(e.sourceOptions??r).numericMode),a(e),validateClosedImplementationShapes(e);let o=Object.create(null);o.kind=e.kind;let s=structuralMembers(e);for(let r of projectedMemberNames(e,s,t,n)){let i=s[r];isOmittedByDefault(e.kind,r,i)||(o[r]=write(i,t,n))}return o}function writeRecord(e,t,n){let r=Object.create(null);if(e.literalType===`ExactNumber`)return r.literalType=`ExactNumber`,r.value=e.value,r;for(let i of Object.keys(e))i!==`toJSON`&&e[i]!==void 0&&(r[i]=write(e[i],t,n));return r}function validateNumbers(e,t,n){if(assertSupportedDepth(t,n),Array.isArray(e))for(let r=0;r<e.length;r++)validateNumbers(e[r],t,n+1);else isObject(e)&&validateNodeNumbers(e,t,n)}function validateNodeNumbers(e,t,n){t=resolveNumericMode(e,t,n),assertCompleteSourceRoot(e,t,n),t===`exact`&&isNode(e)&&c(e),validateRawNumericText(e,t),e.kind===`LiteralExpressionSyntax`&&Object.hasOwn(e,`value`)&&validateLiteralValue(e.value,t),validateNumberMembers(e,t,n)}function assertSupportedDepth(e,t){if(t>96&&e===`exact`)throw new n(`Syntax nesting exceeds the supported depth of 96.`)}function assertCompleteSourceRoot(e,t,r){if(isIncompleteExactRoot(e,t,r))throw new n(`Exact syntax requires a complete source root.`)}function isIncompleteExactRoot(e,t,n){return n===0&&t===`exact`&&!f.has(e.kind)}function resolveNumericMode(e,t,a){if(!f.has(e.kind)&&!Object.hasOwn(e,`sourceOptions`))return t;let o=Object.hasOwn(e,`sourceOptions`)?i(e.sourceOptions):r;if(a>0&&t!==o.numericMode)throw new n(`Conflicting source numeric options.`);return o.numericMode}function validateRawNumericText(t,r){if(t.kind===`RawExpressionSyntax`&&r===`exact`&&typeof t.text==`string`&&e(t.text))throw new n(`An exact numeric operand must be an explicit ExactNumber, not opaque numeric text.`)}function isUnsupportedExactPrimitive(e){return typeof e==`number`||e!==null&&![`string`,`boolean`,`object`].includes(typeof e)}function validateLiteralValue(e,t){if(t===`exact`&&isUnsupportedExactPrimitive(e))throw new n(`Exact source requires supported primitive values or an explicit ExactNumber literal.`);isObject(e)&&validateObjectLiteral(e,t)}function validateObjectLiteral(e,t){if(e.literalType===`ExactNumber`)validateExactNumberLiteral(e,t);else if(t===`exact`)throw new n(`Exact source refuses old or plain object literal insertion.`)}function isWellFormedExactNumber(e){return typeof e.value==`string`&&t(e.value)?.value===e.value&&Object.keys(e).length===2}function validateExactNumberLiteral(e,t){if(t!==`exact`||!isWellFormedExactNumber(e))throw new n(`Malformed or incompatible ExactNumber literal.`)}function validateNumberMembers(e,t,n){let r=t===`exact`&&isNode(e)?o(e.kind):void 0;for(let[i,a]of Object.entries(e))isTraversedMember(r,i,a)&&validateNumbers(a,t,n+1)}function isTraversedMember(e,t,n){return(e===void 0||e.has(t)||isNode(n)&&f.has(n.kind))&&!d.has(t)}function ordinal(e,t){return e<t?-1:+(e>t)}export{toSyntaxJson};
2
2
  //# sourceMappingURL=SyntaxJson.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SyntaxJson.js","names":["value","omitted","skippedNumberMembers","sourceRoots","detached","node","copies","pending","items","length","index","copy","names","name","member","omittedWhenNull","omittedWhenEmpty","omittedWhenDefault","table","kind","defaults","owningMode","complete","validateClosedSyntaxMembers","rule","structural","known","syntaxMemberNames","isLegacyOmittedMember","validatedSourceOptions","legacySourceOptions","validateSyntaxInvariants","result","memberValue","record","depth","validateSyntaxMembers","InvalidSyntaxJson","options","isExactNumberToken","literal","parseExactNumber","left","right"],"sources":["../../../../../../Compiler/Syntax/SyntaxJson.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { SyntaxNode } from './SyntaxNode';\nimport { InvalidSyntaxJson } from './InvalidSyntaxJson';\nimport { isExactNumberToken, parseExactNumber } from './ExactNumber';\nimport { validateSyntaxInvariants } from './SyntaxInvariants';\nimport { syntaxMemberNames, validateClosedSyntaxMembers, validateSyntaxMembers } from './SyntaxMemberContracts';\nimport { ValidationRuleSyntax } from './Commands';\nimport { isLegacyOmittedMember } from './LegacyWireProjection';\nimport { legacySourceOptions, validatedSourceOptions } from './SourceOptions';\n\n// Returned record objects have null prototypes.\nexport type SyntaxJsonValue = string | number | boolean | null | SyntaxJsonValue[] | { [member: string]: SyntaxJsonValue };\n\nconst isNode = (value: unknown): value is SyntaxNode =>\n typeof value === 'object' && value !== null && typeof (value as { kind?: unknown }).kind === 'string';\nconst isObject = (value: unknown): value is object => typeof value === 'object' && value !== null;\nconst omitted = new Set(['kind', 'location', 'targetLocation', 'referenceLocation', 'referenceLength', 'nameWasEscaped', 'declaredTriggers', 'directiveLocations']);\nconst skippedNumberMembers = new Set(['location', 'targetLocation', 'usesLocation']);\nconst sourceRoots = new Set(['ApplicationSyntax', 'ProjectionSyntax', 'CaptureSyntax', 'SpecificationSyntax']);\n\n// The canonical JSON form of a syntax tree, the same form the C# SyntaxJson writes: 'kind' first, then the\n// members in ordinal order, with source locations left out. Because a node only carries the members this\n// compiler models, the result is the C# form narrowed to those members.\nexport function toSyntaxJson(node: SyntaxNode): SyntaxJsonValue {\n const detached = snapshot(node);\n validateNumbers(detached, 'legacy', 0);\n return write(detached);\n}\n\n// The enriched internal tree written completely, Legacy members included. Not a wire form: it exists so the\n// walker and other tree consumers can be held to every node the parser builds.\nexport function toCompleteSyntaxJson(node: SyntaxNode): SyntaxJsonValue {\n const detached = snapshot(node);\n validateNumbers(detached, 'legacy', 0);\n return write(detached, 'legacy', true);\n}\n\n// Read caller-owned properties only once, before validation. Both validation and projection see the same\n// detached data; accessors, proxies and shared references cannot change it between passes.\nfunction snapshot(value: unknown): unknown {\n const copies = new WeakMap<object, unknown>();\n const pending: (() => void)[] = [];\n // Schedule depth-first reads without consuming the call stack, including for ignored metadata.\n function detach(value: unknown): unknown {\n if (!isObject(value)) return value;\n if (copies.has(value)) return copies.get(value);\n return Array.isArray(value) ? detachArray(value) : detachObject(value);\n }\n function detachArray(value: unknown[]): unknown {\n const items = dataArray<unknown>();\n copies.set(value, items);\n const length = value.length;\n for (let index = length - 1; index >= 0; index--) pending.push(() => {\n items[index] = detach(Object.hasOwn(value, index) ? value[index] : undefined);\n });\n return items;\n }\n function detachObject(value: object): unknown {\n const copy = Object.create(null) as Record<string, unknown>;\n copies.set(value, copy);\n const names = Object.keys(value);\n // Node identity also accepts inherited, hidden and class-getter kinds; read it just once.\n if (!names.includes('kind') && 'kind' in value) names.unshift('kind');\n for (let index = names.length - 1; index >= 0; index--) pending.push(() => {\n const name = names[index];\n const member = (value as Record<string, unknown>)[name];\n if (name === 'sourceOptions') pending.push(() => preserveRejectedSourceOptions(copy, name, member));\n copy[name] = detach(member);\n });\n return copy;\n }\n const detached = detach(value);\n while (pending.length > 0) pending.pop()!();\n return detached;\n}\n\n// Source option contracts also reject exotic prototypes and hidden/symbol members. Preserve\n// that rejected shape as data rather than sanitizing it into an apparently valid option record.\nfunction preserveRejectedSourceOptions(copy: Record<string, unknown>, name: string, member: unknown): void {\n if (isObject(member) && hasExoticShape(member)) {\n copy[name] = Object.assign(Object.create(null), { numericMode: 'invalid' });\n }\n}\n\nfunction hasExoticShape(member: object): boolean {\n return (Object.getPrototypeOf(member) !== Object.prototype && Object.getPrototypeOf(member) !== null) || Reflect.ownKeys(member).length !== Object.keys(member).length;\n}\n\nfunction dataArray<T>(): T[] {\n const items: T[] = [];\n // JSON.stringify consults inherited toJSON even on plain arrays. Shadow that hook without changing\n // their indexed JSON bytes or normal Array prototype (including for existing tree consumers).\n Object.defineProperty(items, 'toJSON', { value: undefined });\n return items;\n}\n\n// Members omitted from the wire form when null (or undefined), by node kind.\nconst omittedWhenNull: Record<string, readonly string[]> = {\n ApplicationSyntax: ['identity'],\n EventSyntax: ['origin'],\n ImportSyntax: ['origin'],\n SliceSyntax: ['direction'],\n ReactionSyntax: ['from'],\n ReducerSyntax: ['from'],\n ProducesSyntax: ['stream'],\n ConceptAttributeSyntax: ['scope', 'specialCategory'],\n ConceptSyntax: ['description', 'valueNumbers', 'generation'],\n PolicySyntax: ['description'],\n FileConstraintSyntax: ['description'],\n UniqueEventConstraintSyntax: ['description'],\n UniquePropertyConstraintSyntax: ['description'],\n ProjectionSyntax: ['description'],\n ScreenSyntax: ['description'],\n FormSyntax: ['description'],\n SpecificationSyntax: ['description', 'whenRedelivered'],\n SpecificationErrorSyntax: ['caseValue'],\n SpecificationExampleSyntax: ['stream', 'noStream'],\n SpecificationRedeliverySyntax: ['stream', 'noStream']\n};\n\n// Members omitted from the wire form when empty arrays, by node kind.\nconst omittedWhenEmpty: Record<string, readonly string[]> = {\n ModuleSyntax: ['dependsOn'],\n FeatureSyntax: ['dependsOn'],\n SpecificationSyntax: ['parameters', 'cases'],\n InvokesSyntax: ['onRefused']\n};\n\n// Members omitted when they hold their default value, by node kind.\nconst omittedWhenDefault: Record<string, Record<string, unknown>> = {\n EventSyntax: { visibility: 'Private' },\n ImportSyntax: { visibility: 'Private' },\n ConceptAttributeSyntax: { criminal: false },\n PropertySyntax: { isSubject: false },\n SpecificationSyntax: { thenNoEvents: false }\n};\n\nconst ownEntry = <T>(table: Record<string, T>, kind: string): T | undefined => Object.hasOwn(table, kind) ? table[kind] : undefined;\nconst isEmptyArray = (value: unknown): boolean => Array.isArray(value) && value.length === 0;\n\nfunction isNullOmitted(kind: string, member: string, value: unknown): boolean {\n if (value != null) return false;\n return ownEntry(omittedWhenNull, kind)?.includes(member) === true\n || member === 'inlineProperty'\n || (member === 'documentation' && kind !== 'EventSyntax');\n}\n\nfunction isEmptyOmitted(kind: string, member: string, value: unknown): boolean {\n if (!isEmptyArray(value)) return false;\n return ownEntry(omittedWhenEmpty, kind)?.includes(member) === true || member === 'examples' || member === 'purposes';\n}\n\nfunction isDefaultOmitted(kind: string, member: string, value: unknown): boolean {\n if (member === 'sourceOptions') return (value as { numericMode?: string } | undefined)?.numericMode === 'legacy';\n const defaults = ownEntry(omittedWhenDefault, kind);\n return defaults !== undefined && Object.hasOwn(defaults, member) && value === defaults[member];\n}\n\nfunction isOmittedByDefault(kind: string, member: string, value: unknown): boolean {\n return isNullOmitted(kind, member, value) || isEmptyOmitted(kind, member, value) || isDefaultOmitted(kind, member, value);\n}\n\nfunction write(value: unknown, owningMode = 'legacy', complete = false): SyntaxJsonValue {\n if (Array.isArray(value)) return writeArray(value, owningMode, complete);\n if (isNode(value)) return writeNode(value, owningMode, complete);\n if (value === undefined) return null;\n if (!isObject(value)) return value as SyntaxJsonValue;\n return writeRecord(value as Record<string, unknown>, owningMode, complete);\n}\n\nfunction writeArray(value: unknown[], owningMode: string, complete: boolean): SyntaxJsonValue {\n // A fresh plain array: never map (Symbol.species) or serialize through a caller-supplied hook.\n const items = dataArray<SyntaxJsonValue>();\n for (let index = 0; index < value.length; index++) items.push(write(value[index], owningMode, complete));\n return items;\n}\n\nfunction validateClosedImplementationShapes(value: SyntaxNode): void {\n // #307 shapes are closed in both modes, before any projection can hide unknown members.\n if (value.kind === 'ImplementationSyntax' || value.kind === 'ImplementationHintSyntax') validateClosedSyntaxMembers(value, omitted);\n if (value.kind !== 'ValidationRuleSyntax') return;\n const rule = value as ValidationRuleSyntax;\n if (rule.implementation == null) return;\n if (rule.file != null) validateClosedSyntaxMembers(rule.file, omitted);\n if (rule.code != null) validateClosedSyntaxMembers(rule.code, omitted);\n}\n\nfunction structuralMembers(value: SyntaxNode): Record<string, unknown> {\n const structural = { ...value } as unknown as Record<string, unknown>;\n if (value.kind === 'ApplicationSyntax' && structural.eventSources === undefined) structural.eventSources = [];\n if (value.kind === 'CommandSyntax' && structural.stream === undefined) structural.stream = null;\n if (value.kind === 'CommandSyntax' && structural.streamCandidates === undefined) structural.streamCandidates = [];\n return structural;\n}\n\nfunction projectedMemberNames(value: SyntaxNode, structural: Record<string, unknown>, owningMode: string, complete: boolean): string[] {\n const known = owningMode === 'exact' ? syntaxMemberNames(value.kind) : undefined;\n const isProjected = (member: string) =>\n (known === undefined || known.has(member)) && !isHiddenByLegacy(value, member, owningMode, complete) && !isAlwaysOmitted(value, member);\n return Object.keys(structural).filter(isProjected).sort(ordinal);\n}\n\nfunction isHiddenByLegacy(value: SyntaxNode, member: string, owningMode: string, complete: boolean): boolean {\n return owningMode === 'legacy' && !complete && isLegacyOmittedMember(value, member);\n}\n\nfunction isAlwaysOmitted(value: SyntaxNode, member: string): boolean {\n return omitted.has(member) || (value.kind === 'OperationSyntax' && member === 'usesLocation');\n}\n\nfunction writeNode(value: SyntaxNode, owningMode: string, complete: boolean): SyntaxJsonValue {\n if (sourceRoots.has(value.kind)) owningMode = validatedSourceOptions((value as unknown as { sourceOptions?: unknown }).sourceOptions ?? legacySourceOptions).numericMode;\n validateSyntaxInvariants(value);\n validateClosedImplementationShapes(value);\n const result = Object.create(null) as Record<string, SyntaxJsonValue>;\n result.kind = value.kind;\n const structural = structuralMembers(value);\n for (const member of projectedMemberNames(value, structural, owningMode, complete)) {\n const memberValue = structural[member];\n if (isOmittedByDefault(value.kind, member, memberValue)) continue;\n result[member] = write(memberValue, owningMode, complete);\n }\n return result;\n}\n\nfunction writeRecord(record: Record<string, unknown>, owningMode: string, complete: boolean): SyntaxJsonValue {\n // The ordered ExactNumber form, whatever the input key order; other objects are copied without any toJSON hook.\n const copy = Object.create(null) as Record<string, SyntaxJsonValue>;\n if (record.literalType === 'ExactNumber') {\n copy.literalType = 'ExactNumber';\n copy.value = record.value as string;\n return copy;\n }\n for (const name of Object.keys(record)) if (name !== 'toJSON' && record[name] !== undefined) copy[name] = write(record[name], owningMode, complete);\n return copy;\n}\n\nfunction validateNumbers(value: unknown, owningMode: string, depth: number): void {\n assertSupportedDepth(owningMode, depth);\n if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index++) validateNumbers(value[index], owningMode, depth + 1);\n return;\n }\n if (!isObject(value)) return;\n validateNodeNumbers(value as Record<string, unknown>, owningMode, depth);\n}\n\nfunction validateNodeNumbers(node: Record<string, unknown>, owningMode: string, depth: number): void {\n owningMode = resolveNumericMode(node, owningMode, depth);\n assertCompleteSourceRoot(node, owningMode, depth);\n if (owningMode === 'exact' && isNode(node)) validateSyntaxMembers(node);\n validateRawNumericText(node, owningMode);\n if (node.kind === 'LiteralExpressionSyntax' && Object.hasOwn(node, 'value')) validateLiteralValue(node.value, owningMode);\n validateNumberMembers(node, owningMode, depth);\n}\n\nfunction assertSupportedDepth(owningMode: string, depth: number): void {\n if (depth > 96 && owningMode === 'exact') throw new InvalidSyntaxJson('Syntax nesting exceeds the supported depth of 96.');\n}\n\nfunction assertCompleteSourceRoot(node: Record<string, unknown>, owningMode: string, depth: number): void {\n if (isIncompleteExactRoot(node, owningMode, depth)) throw new InvalidSyntaxJson('Exact syntax requires a complete source root.');\n}\n\nfunction isIncompleteExactRoot(node: Record<string, unknown>, owningMode: string, depth: number): boolean {\n return depth === 0 && owningMode === 'exact' && !sourceRoots.has(node.kind as string);\n}\n\nfunction resolveNumericMode(node: Record<string, unknown>, owningMode: string, depth: number): string {\n if (!sourceRoots.has(node.kind as string) && !Object.hasOwn(node, 'sourceOptions')) return owningMode;\n // Omission is Legacy on every complete source root, never inheritance from its container.\n const options = Object.hasOwn(node, 'sourceOptions') ? validatedSourceOptions(node.sourceOptions) : legacySourceOptions;\n if (depth > 0 && owningMode !== options.numericMode) throw new InvalidSyntaxJson('Conflicting source numeric options.');\n return options.numericMode;\n}\n\nfunction validateRawNumericText(node: Record<string, unknown>, owningMode: string): void {\n if (node.kind !== 'RawExpressionSyntax' || owningMode !== 'exact') return;\n if (typeof node.text === 'string' && isExactNumberToken(node.text)) throw new InvalidSyntaxJson('An exact numeric operand must be an explicit ExactNumber, not opaque numeric text.');\n}\n\nfunction isUnsupportedExactPrimitive(value: unknown): boolean {\n return typeof value === 'number' || (value !== null && !['string', 'boolean', 'object'].includes(typeof value));\n}\n\nfunction validateLiteralValue(value: unknown, owningMode: string): void {\n if (owningMode === 'exact' && isUnsupportedExactPrimitive(value)) throw new InvalidSyntaxJson('Exact source requires supported primitive values or an explicit ExactNumber literal.');\n if (!isObject(value)) return;\n validateObjectLiteral(value as { literalType?: unknown; value?: unknown }, owningMode);\n}\n\nfunction validateObjectLiteral(literal: { literalType?: unknown; value?: unknown }, owningMode: string): void {\n if (literal.literalType === 'ExactNumber') validateExactNumberLiteral(literal, owningMode);\n else if (owningMode === 'exact') throw new InvalidSyntaxJson('Exact source refuses old or plain object literal insertion.');\n}\n\nfunction isWellFormedExactNumber(literal: { value?: unknown }): boolean {\n return typeof literal.value === 'string' && parseExactNumber(literal.value)?.value === literal.value && Object.keys(literal).length === 2;\n}\n\nfunction validateExactNumberLiteral(literal: { value?: unknown }, owningMode: string): void {\n if (owningMode !== 'exact' || !isWellFormedExactNumber(literal)) throw new InvalidSyntaxJson('Malformed or incompatible ExactNumber literal.');\n}\n\nfunction validateNumberMembers(node: Record<string, unknown>, owningMode: string, depth: number): void {\n const known = owningMode === 'exact' && isNode(node) ? syntaxMemberNames(node.kind) : undefined;\n for (const [name, member] of Object.entries(node)) if (isTraversedMember(known, name, member)) validateNumbers(member, owningMode, depth + 1);\n}\n\nfunction isTraversedMember(known: ReadonlySet<string> | undefined, name: string, member: unknown): boolean {\n return (known === undefined || known.has(name) || (isNode(member) && sourceRoots.has(member.kind))) && !skippedNumberMembers.has(name);\n}\n\nfunction ordinal(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n"],"mappings":"+gBAeA,MAAM,OAAU,GACZ,OAAOA,GAAU,YAAYA,GAAkB,OAAQA,EAA6B,MAAS,SAC3F,SAAY,GAAoC,OAAOA,GAAU,YAAYA,EAC7EC,kBAAU,IAAI,IAAI,CAAC,OAAQ,WAAY,iBAAkB,oBAAqB,kBAAmB,iBAAkB,mBAAoB,oBAAoB,CAAC,EAC5JC,kBAAuB,IAAI,IAAI,CAAC,WAAY,iBAAkB,cAAc,CAAC,EAC7EC,kBAAc,IAAI,IAAI,CAAC,oBAAqB,mBAAoB,gBAAiB,qBAAqB,CAAC,EAK7G,SAAgB,aAAa,EAAmC,CAC5D,IAAMC,EAAW,SAASC,CAAI,EAE9B,OADA,gBAAgBD,EAAU,SAAU,CAAC,EAC9B,MAAMA,CAAQ,CACzB,CAYA,SAAS,SAA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ACtC"}
1
+ {"version":3,"file":"SyntaxJson.js","names":["value","omitted","skippedNumberMembers","sourceRoots","detached","node","copies","pending","items","length","index","copy","names","name","member","omittedWhenNull","omittedWhenEmpty","omittedWhenDefault","table","kind","defaults","owningMode","complete","validateClosedSyntaxMembers","rule","structural","known","syntaxMemberNames","isLegacyOmittedMember","validatedSourceOptions","legacySourceOptions","validateSyntaxInvariants","result","memberValue","record","depth","validateSyntaxMembers","InvalidSyntaxJson","options","isExactNumberToken","literal","parseExactNumber","left","right"],"sources":["../../../../../../Compiler/Syntax/SyntaxJson.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { SyntaxNode } from './SyntaxNode';\nimport { InvalidSyntaxJson } from './InvalidSyntaxJson';\nimport { isExactNumberToken, parseExactNumber } from './ExactNumber';\nimport { validateSyntaxInvariants } from './SyntaxInvariants';\nimport { syntaxMemberNames, validateClosedSyntaxMembers, validateSyntaxMembers } from './SyntaxMemberContracts';\nimport { ValidationRuleSyntax } from './Commands';\nimport { isLegacyOmittedMember } from './LegacyWireProjection';\nimport { legacySourceOptions, validatedSourceOptions } from './SourceOptions';\n\n// Returned record objects have null prototypes.\nexport type SyntaxJsonValue = string | number | boolean | null | SyntaxJsonValue[] | { [member: string]: SyntaxJsonValue };\n\nconst isNode = (value: unknown): value is SyntaxNode =>\n typeof value === 'object' && value !== null && typeof (value as { kind?: unknown }).kind === 'string';\nconst isObject = (value: unknown): value is object => typeof value === 'object' && value !== null;\nconst omitted = new Set(['kind', 'location', 'targetLocation', 'referenceLocation', 'referenceLength', 'nameWasEscaped', 'declaredTriggers', 'directiveLocations']);\nconst skippedNumberMembers = new Set(['location', 'targetLocation', 'usesLocation']);\nconst sourceRoots = new Set(['ApplicationSyntax', 'ProjectionSyntax', 'CaptureSyntax', 'SpecificationSyntax']);\n\n// The canonical JSON form of a syntax tree, the same form the C# SyntaxJson writes: 'kind' first, then the\n// members in ordinal order, with source locations left out. Because a node only carries the members this\n// compiler models, the result is the C# form narrowed to those members.\nexport function toSyntaxJson(node: SyntaxNode): SyntaxJsonValue {\n const detached = snapshot(node);\n validateNumbers(detached, 'legacy', 0);\n return write(detached);\n}\n\n// The enriched internal tree written completely, Legacy members included. Not a wire form: it exists so the\n// walker and other tree consumers can be held to every node the parser builds.\nexport function toCompleteSyntaxJson(node: SyntaxNode): SyntaxJsonValue {\n const detached = snapshot(node);\n validateNumbers(detached, 'legacy', 0);\n return write(detached, 'legacy', true);\n}\n\n// Read caller-owned properties only once, before validation. Both validation and projection see the same\n// detached data; accessors, proxies and shared references cannot change it between passes.\nfunction snapshot(value: unknown): unknown {\n const copies = new WeakMap<object, unknown>();\n const pending: (() => void)[] = [];\n // Schedule depth-first reads without consuming the call stack, including for ignored metadata.\n function detach(value: unknown): unknown {\n if (!isObject(value)) return value;\n if (copies.has(value)) return copies.get(value);\n return Array.isArray(value) ? detachArray(value) : detachObject(value);\n }\n function detachArray(value: unknown[]): unknown {\n const items = dataArray<unknown>();\n copies.set(value, items);\n const length = value.length;\n for (let index = length - 1; index >= 0; index--) pending.push(() => {\n items[index] = detach(Object.hasOwn(value, index) ? value[index] : undefined);\n });\n return items;\n }\n function detachObject(value: object): unknown {\n const copy = Object.create(null) as Record<string, unknown>;\n copies.set(value, copy);\n const names = Object.keys(value);\n // Node identity also accepts inherited, hidden and class-getter kinds; read it just once.\n if (!names.includes('kind') && 'kind' in value) names.unshift('kind');\n for (let index = names.length - 1; index >= 0; index--) pending.push(() => {\n const name = names[index];\n const member = (value as Record<string, unknown>)[name];\n if (name === 'sourceOptions') pending.push(() => preserveRejectedSourceOptions(copy, name, member));\n copy[name] = detach(member);\n });\n return copy;\n }\n const detached = detach(value);\n while (pending.length > 0) pending.pop()!();\n return detached;\n}\n\n// Source option contracts also reject exotic prototypes and hidden/symbol members. Preserve\n// that rejected shape as data rather than sanitizing it into an apparently valid option record.\nfunction preserveRejectedSourceOptions(copy: Record<string, unknown>, name: string, member: unknown): void {\n if (isObject(member) && hasExoticShape(member)) {\n copy[name] = Object.assign(Object.create(null), { numericMode: 'invalid' });\n }\n}\n\nfunction hasExoticShape(member: object): boolean {\n return (Object.getPrototypeOf(member) !== Object.prototype && Object.getPrototypeOf(member) !== null) || Reflect.ownKeys(member).length !== Object.keys(member).length;\n}\n\nfunction dataArray<T>(): T[] {\n const items: T[] = [];\n // JSON.stringify consults inherited toJSON even on plain arrays. Shadow that hook without changing\n // their indexed JSON bytes or normal Array prototype (including for existing tree consumers).\n Object.defineProperty(items, 'toJSON', { value: undefined });\n return items;\n}\n\n// Members omitted from the wire form when null (or undefined), by node kind.\nconst omittedWhenNull: Record<string, readonly string[]> = {\n ApplicationSyntax: ['identity'],\n EventSyntax: ['origin'],\n ImportSyntax: ['origin'],\n SliceSyntax: ['direction'],\n ReactionSyntax: ['from'],\n ReducerSyntax: ['from'],\n ProducesSyntax: ['stream'],\n ConceptAttributeSyntax: ['scope', 'specialCategory'],\n ConceptSyntax: ['description', 'valueNumbers', 'generation'],\n GenerationSyntax: ['file', 'code'],\n PolicySyntax: ['description'],\n FileConstraintSyntax: ['description'],\n UniqueEventConstraintSyntax: ['description'],\n UniquePropertyConstraintSyntax: ['description'],\n ProjectionSyntax: ['description'],\n ScreenSyntax: ['description'],\n FormSyntax: ['description'],\n SpecificationSyntax: ['description', 'whenRedelivered'],\n SpecificationErrorSyntax: ['caseValue'],\n SpecificationExampleSyntax: ['stream', 'noStream'],\n SpecificationRedeliverySyntax: ['stream', 'noStream']\n};\n\n// Members omitted from the wire form when empty arrays, by node kind.\nconst omittedWhenEmpty: Record<string, readonly string[]> = {\n ModuleSyntax: ['dependsOn'],\n FeatureSyntax: ['dependsOn'],\n SpecificationSyntax: ['parameters', 'cases'],\n InvokesSyntax: ['onRefused']\n};\n\n// Members omitted when they hold their default value, by node kind.\nconst omittedWhenDefault: Record<string, Record<string, unknown>> = {\n EventSyntax: { visibility: 'Private' },\n ImportSyntax: { visibility: 'Private' },\n ConceptAttributeSyntax: { criminal: false },\n PropertySyntax: { isSubject: false },\n SpecificationSyntax: { thenNoEvents: false }\n};\n\nconst ownEntry = <T>(table: Record<string, T>, kind: string): T | undefined => Object.hasOwn(table, kind) ? table[kind] : undefined;\nconst isEmptyArray = (value: unknown): boolean => Array.isArray(value) && value.length === 0;\n\nfunction isNullOmitted(kind: string, member: string, value: unknown): boolean {\n if (value != null) return false;\n return ownEntry(omittedWhenNull, kind)?.includes(member) === true\n || member === 'inlineProperty'\n || (member === 'documentation' && kind !== 'EventSyntax');\n}\n\nfunction isEmptyOmitted(kind: string, member: string, value: unknown): boolean {\n if (!isEmptyArray(value)) return false;\n return ownEntry(omittedWhenEmpty, kind)?.includes(member) === true || member === 'examples' || member === 'purposes';\n}\n\nfunction isDefaultOmitted(kind: string, member: string, value: unknown): boolean {\n if (member === 'sourceOptions') return (value as { numericMode?: string } | undefined)?.numericMode === 'legacy';\n const defaults = ownEntry(omittedWhenDefault, kind);\n return defaults !== undefined && Object.hasOwn(defaults, member) && value === defaults[member];\n}\n\nfunction isOmittedByDefault(kind: string, member: string, value: unknown): boolean {\n return isNullOmitted(kind, member, value) || isEmptyOmitted(kind, member, value) || isDefaultOmitted(kind, member, value);\n}\n\nfunction write(value: unknown, owningMode = 'legacy', complete = false): SyntaxJsonValue {\n if (Array.isArray(value)) return writeArray(value, owningMode, complete);\n if (isNode(value)) return writeNode(value, owningMode, complete);\n if (value === undefined) return null;\n if (!isObject(value)) return value as SyntaxJsonValue;\n return writeRecord(value as Record<string, unknown>, owningMode, complete);\n}\n\nfunction writeArray(value: unknown[], owningMode: string, complete: boolean): SyntaxJsonValue {\n // A fresh plain array: never map (Symbol.species) or serialize through a caller-supplied hook.\n const items = dataArray<SyntaxJsonValue>();\n for (let index = 0; index < value.length; index++) items.push(write(value[index], owningMode, complete));\n return items;\n}\n\nfunction validateClosedImplementationShapes(value: SyntaxNode): void {\n // #307 shapes are closed in both modes, before any projection can hide unknown members.\n if (value.kind === 'ImplementationSyntax' || value.kind === 'ImplementationHintSyntax') validateClosedSyntaxMembers(value, omitted);\n if (value.kind !== 'ValidationRuleSyntax') return;\n const rule = value as ValidationRuleSyntax;\n if (rule.implementation == null) return;\n if (rule.file != null) validateClosedSyntaxMembers(rule.file, omitted);\n if (rule.code != null) validateClosedSyntaxMembers(rule.code, omitted);\n}\n\nfunction structuralMembers(value: SyntaxNode): Record<string, unknown> {\n const structural = { ...value } as unknown as Record<string, unknown>;\n if (value.kind === 'ApplicationSyntax' && structural.eventSources === undefined) structural.eventSources = [];\n if (value.kind === 'CommandSyntax' && structural.stream === undefined) structural.stream = null;\n if (value.kind === 'CommandSyntax' && structural.streamCandidates === undefined) structural.streamCandidates = [];\n return structural;\n}\n\nfunction projectedMemberNames(value: SyntaxNode, structural: Record<string, unknown>, owningMode: string, complete: boolean): string[] {\n const known = owningMode === 'exact' ? syntaxMemberNames(value.kind) : undefined;\n const isProjected = (member: string) =>\n (known === undefined || known.has(member)) && !isHiddenByLegacy(value, member, owningMode, complete) && !isAlwaysOmitted(value, member);\n return Object.keys(structural).filter(isProjected).sort(ordinal);\n}\n\nfunction isHiddenByLegacy(value: SyntaxNode, member: string, owningMode: string, complete: boolean): boolean {\n return owningMode === 'legacy' && !complete && isLegacyOmittedMember(value, member);\n}\n\nfunction isAlwaysOmitted(value: SyntaxNode, member: string): boolean {\n return omitted.has(member) || (value.kind === 'OperationSyntax' && member === 'usesLocation');\n}\n\nfunction writeNode(value: SyntaxNode, owningMode: string, complete: boolean): SyntaxJsonValue {\n if (sourceRoots.has(value.kind)) owningMode = validatedSourceOptions((value as unknown as { sourceOptions?: unknown }).sourceOptions ?? legacySourceOptions).numericMode;\n validateSyntaxInvariants(value);\n validateClosedImplementationShapes(value);\n const result = Object.create(null) as Record<string, SyntaxJsonValue>;\n result.kind = value.kind;\n const structural = structuralMembers(value);\n for (const member of projectedMemberNames(value, structural, owningMode, complete)) {\n const memberValue = structural[member];\n if (isOmittedByDefault(value.kind, member, memberValue)) continue;\n result[member] = write(memberValue, owningMode, complete);\n }\n return result;\n}\n\nfunction writeRecord(record: Record<string, unknown>, owningMode: string, complete: boolean): SyntaxJsonValue {\n // The ordered ExactNumber form, whatever the input key order; other objects are copied without any toJSON hook.\n const copy = Object.create(null) as Record<string, SyntaxJsonValue>;\n if (record.literalType === 'ExactNumber') {\n copy.literalType = 'ExactNumber';\n copy.value = record.value as string;\n return copy;\n }\n for (const name of Object.keys(record)) if (name !== 'toJSON' && record[name] !== undefined) copy[name] = write(record[name], owningMode, complete);\n return copy;\n}\n\nfunction validateNumbers(value: unknown, owningMode: string, depth: number): void {\n assertSupportedDepth(owningMode, depth);\n if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index++) validateNumbers(value[index], owningMode, depth + 1);\n return;\n }\n if (!isObject(value)) return;\n validateNodeNumbers(value as Record<string, unknown>, owningMode, depth);\n}\n\nfunction validateNodeNumbers(node: Record<string, unknown>, owningMode: string, depth: number): void {\n owningMode = resolveNumericMode(node, owningMode, depth);\n assertCompleteSourceRoot(node, owningMode, depth);\n if (owningMode === 'exact' && isNode(node)) validateSyntaxMembers(node);\n validateRawNumericText(node, owningMode);\n if (node.kind === 'LiteralExpressionSyntax' && Object.hasOwn(node, 'value')) validateLiteralValue(node.value, owningMode);\n validateNumberMembers(node, owningMode, depth);\n}\n\nfunction assertSupportedDepth(owningMode: string, depth: number): void {\n if (depth > 96 && owningMode === 'exact') throw new InvalidSyntaxJson('Syntax nesting exceeds the supported depth of 96.');\n}\n\nfunction assertCompleteSourceRoot(node: Record<string, unknown>, owningMode: string, depth: number): void {\n if (isIncompleteExactRoot(node, owningMode, depth)) throw new InvalidSyntaxJson('Exact syntax requires a complete source root.');\n}\n\nfunction isIncompleteExactRoot(node: Record<string, unknown>, owningMode: string, depth: number): boolean {\n return depth === 0 && owningMode === 'exact' && !sourceRoots.has(node.kind as string);\n}\n\nfunction resolveNumericMode(node: Record<string, unknown>, owningMode: string, depth: number): string {\n if (!sourceRoots.has(node.kind as string) && !Object.hasOwn(node, 'sourceOptions')) return owningMode;\n // Omission is Legacy on every complete source root, never inheritance from its container.\n const options = Object.hasOwn(node, 'sourceOptions') ? validatedSourceOptions(node.sourceOptions) : legacySourceOptions;\n if (depth > 0 && owningMode !== options.numericMode) throw new InvalidSyntaxJson('Conflicting source numeric options.');\n return options.numericMode;\n}\n\nfunction validateRawNumericText(node: Record<string, unknown>, owningMode: string): void {\n if (node.kind !== 'RawExpressionSyntax' || owningMode !== 'exact') return;\n if (typeof node.text === 'string' && isExactNumberToken(node.text)) throw new InvalidSyntaxJson('An exact numeric operand must be an explicit ExactNumber, not opaque numeric text.');\n}\n\nfunction isUnsupportedExactPrimitive(value: unknown): boolean {\n return typeof value === 'number' || (value !== null && !['string', 'boolean', 'object'].includes(typeof value));\n}\n\nfunction validateLiteralValue(value: unknown, owningMode: string): void {\n if (owningMode === 'exact' && isUnsupportedExactPrimitive(value)) throw new InvalidSyntaxJson('Exact source requires supported primitive values or an explicit ExactNumber literal.');\n if (!isObject(value)) return;\n validateObjectLiteral(value as { literalType?: unknown; value?: unknown }, owningMode);\n}\n\nfunction validateObjectLiteral(literal: { literalType?: unknown; value?: unknown }, owningMode: string): void {\n if (literal.literalType === 'ExactNumber') validateExactNumberLiteral(literal, owningMode);\n else if (owningMode === 'exact') throw new InvalidSyntaxJson('Exact source refuses old or plain object literal insertion.');\n}\n\nfunction isWellFormedExactNumber(literal: { value?: unknown }): boolean {\n return typeof literal.value === 'string' && parseExactNumber(literal.value)?.value === literal.value && Object.keys(literal).length === 2;\n}\n\nfunction validateExactNumberLiteral(literal: { value?: unknown }, owningMode: string): void {\n if (owningMode !== 'exact' || !isWellFormedExactNumber(literal)) throw new InvalidSyntaxJson('Malformed or incompatible ExactNumber literal.');\n}\n\nfunction validateNumberMembers(node: Record<string, unknown>, owningMode: string, depth: number): void {\n const known = owningMode === 'exact' && isNode(node) ? syntaxMemberNames(node.kind) : undefined;\n for (const [name, member] of Object.entries(node)) if (isTraversedMember(known, name, member)) validateNumbers(member, owningMode, depth + 1);\n}\n\nfunction isTraversedMember(known: ReadonlySet<string> | undefined, name: string, member: unknown): boolean {\n return (known === undefined || known.has(name) || (isNode(member) && sourceRoots.has(member.kind))) && !skippedNumberMembers.has(name);\n}\n\nfunction ordinal(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n"],"mappings":"+gBAeA,MAAM,OAAU,GACZ,OAAOA,GAAU,YAAYA,GAAkB,OAAQA,EAA6B,MAAS,SAC3F,SAAY,GAAoC,OAAOA,GAAU,YAAYA,EAC7EC,kBAAU,IAAI,IAAI,CAAC,OAAQ,WAAY,iBAAkB,oBAAqB,kBAAmB,iBAAkB,mBAAoB,oBAAoB,CAAC,EAC5JC,kBAAuB,IAAI,IAAI,CAAC,WAAY,iBAAkB,cAAc,CAAC,EAC7EC,kBAAc,IAAI,IAAI,CAAC,oBAAqB,mBAAoB,gBAAiB,qBAAqB,CAAC,EAK7G,SAAgB,aAAa,EAAmC,CAC5D,IAAMC,EAAW,SAASC,CAAI,EAE9B,OADA,gBAAgBD,EAAU,SAAU,CAAC,EAC9B,MAAMA,CAAQ,CACzB,CAYA,SAAS,SAAS,EAAyB,CACvC,IAAME,kBAAS,IAAI,QACbC,EAA0B,CAAC,EAEjC,SAAS,OAAO,EAAyB,CAGrC,OAFK,SAASP,CAAK,EACfM,EAAO,IAAIN,CAAK,EAAUM,EAAO,IAAIN,CAAK,EACvC,MAAM,QAAQA,CAAK,EAAI,YAAYA,CAAK,EAAI,aAAaA,CAAK,EAFxCA,CAGjC,CACA,SAAS,YAAY,EAA2B,CAC5C,IAAMQ,EAAQ,UAAmB,EACjCF,EAAO,IAAIN,EAAOQ,CAAK,EACvB,IAAMC,EAAST,EAAM,OACrB,IAAK,IAAIU,EAAQD,EAAS,EAAGC,GAAS,EAAG,IAASH,EAAQ,SAAW,CACjE,EAAMG,GAAS,OAAO,OAAO,OAAOV,EAAOU,CAAK,EAAIV,EAAMU,GAAS,IAAA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AAYC,EAAiBD,EAAQ,KAAK,CAAC,EAAE,QAAUA,EAAQ,OAAS,OAAO,KAAKA,CAAO,CAAC,CAAC,SAAW,CAC5I,CAEA,SAAS,2BAA2B,EAA8B,EAA0B,CACxF,GAAInB,IAAe,SAAW,CAAC,wBAAwBmB,CAAO,EAAG,MAAM,IAAIH,EAAkB,gDAAgD,CACjJ,CAEA,SAAS,sBAAsB,EAA+B,EAAoB,EAAqB,CACnG,IAAMX,EAAQL,IAAe,SAAW,OAAOhB,CAAI,EAAIsB,EAAkBtB,EAAK,IAAI,EAAI,IAAA,GACtF,IAAK,GAAM,CAACQ,EAAMC,KAAW,OAAO,QAAQT,CAAI,EAAO,kBAAkBqB,EAAOb,EAAMC,CAAM,GAAG,gBAAgBA,EAAQO,EAAYc,EAAQ,CAAC,CAChJ,CAEA,SAAS,kBAAkB,EAAwC,EAAc,EAA0B,CACvG,OAAQT,IAAU,IAAA,IAAaA,EAAM,IAAIb,CAAI,GAAM,OAAOC,CAAM,GAAKX,EAAY,IAAIW,EAAO,IAAI,IAAO,CAACZ,EAAqB,IAAIW,CAAI,CACzI,CAEA,SAAS,QAAQ,EAAc,EAAuB,CAClD,OAAO6B,EAAOC,EAAQ,GAAK,IAAOA,EACtC"}
@@ -4,7 +4,7 @@ import"./_virtual/_virtual/_rolldown/runtime.js";import{identityProperties as e}
4
4
  \${2:EventType}`,documentation:`Declares events to seed into the event store per event source id.`},{label:`layout`,insertText:"layout ${1:Name}\n ${2:slot}",documentation:`Declares the application shell with named slots.`},{label:`theme`,insertText:"theme ${1:Name}\n compatible with ${2:Package}",documentation:`Declares a theme and the component packages it is compatible with.`},{label:`ui profile`,insertText:"ui profile ${1:Name}\n target platform ${2:web}\n layout ${3:Layout}\n theme ${4:Theme}",documentation:`Binds a target platform and size to a layout, theme and component packages.`},{label:`behavior`,insertText:"behavior ${1:Name}\n on ${2:click}\n ${3:execute command}",documentation:"A named interaction wiring, attached to a screen, form or dialog with `uses`."},{label:`trigger`,insertText:"trigger ${1:Name}\n ${2:property} ${3:Type}",documentation:`Declares an integration signal a reaction can run on.`}],c=[{label:`uses`,insertText:"uses ${1:System}",documentation:`Exactly one application-scoped external system.`},{label:`description`,insertText:'description "${1:intent}"',documentation:`Describes operation intent, without requiring code.`},{label:`input`,insertText:"${1:input} ${2:Type}",documentation:`Typed operation input; no identifier or generated modifier.`},{label:`execute`,insertText:`execute
5
5
  description "\${1:effect}"`,documentation:`Optional execution intent; not admitted by any supported executable model (ESM) version yet.`},{label:`compensate`,insertText:`compensate
6
6
  description "\${1:undo intent}"`,documentation:`Optional compensation intent; not admitted by any supported executable model (ESM) version yet.`}],l=[{label:`hint`,insertText:'hint "${1:implementation guidance}"',documentation:`Ordered authoring guidance; not an executable implementation role.`},{label:`file`,insertText:"file ${1:Path}",documentation:`Selects the phase’s sole source attachment.`},...[`csharp`,`typescript`,`react`,`html`,`sql`].map(e=>({label:e,insertText:fenced(e),documentation:`Selects the phase’s sole inline source; not admitted by any supported executable model (ESM) version yet.`}))],u=[{label:`description`,insertText:'description "${1:phase intent}"',documentation:`A description-only phase is valid, pending intent.`},{label:`implementation`,insertText:`implementation
7
- hint "\${1:guidance}"`,documentation:`Hints with optional source; phase owns File/Code, wrapper owns hints only.`},...l.filter(e=>e.label!==`hint`)],d=[{label:`generate uuid`,insertText:`generate uuid`,documentation:`Random UUID v4; 122 random bits. Implicit on Uuid concepts; String UUIDs are lowercase by default.`},{label:`generate uuidv7`,insertText:`generate uuidv7`,documentation:`Time-ordered UUID v7; 74 random bits. Exposes time, not monotonic within a millisecond.`},{label:`generate ulid`,insertText:`generate ulid`,documentation:`26 uppercase Crockford base32 characters; 80 random bits. String concepts only.`},{label:`generate typeid`,insertText:'generate typeid "${1:user}"',documentation:`TypeID 0.3, lowercase UUIDv7 base32; 74 random bits. Empty prefix has no separator.`},{label:`generate nanoid`,insertText:"generate nanoid ${1:21}",documentation:`String from a distinct printable ASCII alphabet; size × log2(alphabet size) random bits. Default: 21 × 6 = 126 bits.`},{label:`generate bytes`,insertText:"generate bytes ${1:32} ${2|base64url,hex,base32|}",documentation:`Cryptographic random bytes, RFC 4648 without padding; 8 × count bits. Case applies only to hex/base32.`},{label:`generate pattern`,insertText:'generate pattern "${1:ORD-#{7}}"',documentation:`Parsed and printed, not yet executable (#616 phase 3).`},{label:`generate random`,insertText:"generate random ${1:1}..${2:9}",documentation:`Int range; parsed and printed, not yet executable (#616 phase 3).`},{label:`generate rule`,insertText:"generate rule ${1:Name}",documentation:`Implementation attachment; parsed and printed, not yet executable (#616 phase 3).`},{label:`description`,insertText:'description "${1:what this value represents}"',documentation:`Report-only authoring description; not a validation or compliance note.`},{label:`file`,insertText:"file ${1:Path}",documentation:`Names the repository relative file this declaration is realized by, so the document can be navigated back to the code.`},{label:`pii reason`,insertText:'pii reason "${1:why this value is personal data}"',documentation:`A free-text concept note, not a lawful basis.`},{label:`secret reason`,insertText:'secret reason "${1:why this value is an operational secret}"',documentation:`Records why the secret marker applies.`},{label:`secret scope`,insertText:"secret scope ${1|subject,namespace,global|}",documentation:`Explicit encryption scope; omitted scope keeps Chronicle’s Subject default.`},{label:`pii special`,insertText:"pii special ${1|racialOrEthnicOrigin,politicalOpinions,religiousOrPhilosophicalBeliefs,tradeUnionMembership,genetic,biometric,health,sexLifeOrSexualOrientation|}",documentation:`GDPR Art. 9(1) special category of personal data.`},{label:`pii criminal`,insertText:`pii criminal`,documentation:`Personal data relating to criminal convictions and offenses (GDPR Art. 10).`},{label:`validate`,insertText:'validate\n ${1:not empty} message "${2:message}"',documentation:`Validation rules that travel with the value everywhere it appears.`}],f=[{label:`file`,insertText:"file ${1:Path}",documentation:`Names the repository relative file this declaration is realized by, so the document can be navigated back to the code.`},{label:`description`,insertText:'description "${1:what this shape represents}"',documentation:`A human-readable description of the type.`},{label:`property`,insertText:"${1:property} ${2:Type}",documentation:`A property of the type — a name and a type reference.`}],p=[n,t,...i,{label:`operation`,insertText:"operation ${1:Name}\n uses ${2:System}\n ${3:input} ${4:Type}",documentation:`Reusable slice-owned operation intent; not admitted by any supported executable model (ESM) version yet.`},{label:`file`,insertText:"file ${1:Path}",documentation:`Names the repository relative file this declaration is realized by, so the document can be navigated back to the code.`},{label:`public event`,insertText:"public event ${1:Name}\n ${2:property} ${3:Type}",documentation:`Declares a public event: a contract this application publishes. Admitted by ESM v9; an outbound Translate slice produces it through a projection that targets it.`},{label:`event from`,insertText:'event ${1:Name} from "${2:origin}"\n ${3:property} ${4:Type}',documentation:`An event with an opaque origin naming the application that owns it, not a path or declaration reference. It is a public event admitted by ESM v9; consume it with a capture over source events.`},{label:`direction`,insertText:"direction ${1|inbound,outbound|}",documentation:`Translate direction, inbound or outbound, admitted by ESM v9. No transport or delivery guarantee is implied.`},{label:`event`,insertText:"event ${1:Name}\n ${2:property} ${3:Type}",documentation:`Declares an event type — an immutable, past-tense fact.`},{label:`event generation`,insertText:"event ${1:Name} generation ${2:2}\n ${3:property} ${4:Type}",documentation:`Declares a complete numbered event generation; start at 1 and do not skip a number.`},{label:`command`,insertText:"command ${1:Name}\n ${2:property} ${3:Type}",documentation:`Declares a command — an imperative intent that produces events.`},{label:`query`,insertText:"query ${1:Name} => ${2:ReadModel}",documentation:`Declares a read-side entry point mapping to a return type.`},{label:`query observable`,insertText:"query ${1:Name} => observable ${2:ReadModel}",documentation:`Declares a live read — the query keeps pushing as the read model changes, instead of answering once.`},{label:`readmodel`,insertText:"readmodel ${1:Name}\n ${2:property} ${3:Type}",documentation:`Declares the shape of a read model — its properties — that a projection, reducer or query fills and returns.`},{label:`reducer`,insertText:"reducer ${1:Name} => ${2:ReadModel}\n on ${3:EventType}\n ```csharp\n ${4}\n ```",documentation:`Declares a reducer building a read model from events with imperative code, for what a projection cannot express.`},{label:`specification`,insertText:"specification ${1:Name}\n given ${2:EventType}\n when ${3:Command}\n then ${4:EventType}",documentation:`Given/when/then acceptance criteria for the slice.`},{label:`projection`,insertText:"projection ${1:Name} => ${2:ReadModel}\n from ${3:EventType}",documentation:`Declares how events project into a read model (PDL).`},{label:`capture`,insertText:"capture ${1:Name}\n source ${2:api}",documentation:`Declares a change data capture converting external data into events (CDL).`},{label:`reaction`,insertText:"reaction ${1:Name}\n when ${2:Trigger}",documentation:`Declares behavior that runs when something happens.`},{label:`screen`,insertText:"screen ${1:Name}\n data ${2:ReadModel} via query ${3:QueryName}",documentation:`Declares a UI screen.`},{label:`constraint`,insertText:"constraint ${1:Name}\n unique ${2:property} on ${3:EventType}",documentation:`Declares a server-side rule enforced before events are committed.`}],m=[t,{label:`property`,insertText:"${1:property} ${2:Type}",documentation:`An input of the command — a name and a type reference.`},{label:`produces operation`,insertText:"produces operation ${1:Name}\n uses ${2:System}\n ${3:input} ${4:Type} = ${5:source}",documentation:`Declares ordered operation intent; not admitted by any supported executable model (ESM) version yet (PLAY0268).`},{label:`returns property`,insertText:"returns @${1:property}",documentation:`Scalar response from a direct command property, only on acceptance. Executable as ESM v7.`},{label:`returns block`,insertText:"returns\n ${1:field} = ${2:property}",documentation:`Unnamed record response with inferred or explicit field types, only on acceptance. Executable as ESM v7.`},{label:`produces event`,insertText:"produces event ${1:Name}\n ${2:property} ${3:Type} = ${4:source}",documentation:`Declares a slice-owned generation-1 event and maps its properties. An omitted for uses the command identifier.`},{label:`identifier property`,insertText:"${1:property} ${2:Type} identifier",documentation:`Marks the property a runtime resolves the event source id from. At most one per command.`},{label:`authorize`,insertText:"authorize ${1:PolicyName}",documentation:`References the policies that must pass for the command to execute.`},{label:`reads`,insertText:"reads ${1:View} by ${2:property}",documentation:`Declares a view the command consults. Executable binding is not yet supported.`},{label:`reads as`,insertText:"reads ${1:View} as ${2:alias} by ${3:property}",documentation:`Names one instance of a view; every instance needs a unique alias when reading the same view more than once.`},{label:`validate`,insertText:'validate\n ${1:property} not empty message "${2:message}"',documentation:`Declarative validation rules with messages.`},{label:`validate csharp`,insertText:`validate\n ${fenced(`csharp`)}`,documentation:`Imperative validation in C#, yielding the message of every rule the artifact breaks.`},{label:`produces`,insertText:"produces ${1:EventType}\n ${2:property} = ${3:source}",documentation:`Declares the event the command emits, with property mappings.`},{label:`produces when`,insertText:"produces when ${1:condition}\n ${2:EventType}\n ${3:property} = ${4:source}",documentation:`Conditionally emits an event when the condition holds.`},{label:`description`,insertText:'description "${1:what the command asks for}"',documentation:`A human-readable description.`},{label:`concurrency`,insertText:`concurrency
7
+ hint "\${1:guidance}"`,documentation:`Hints with optional source; phase owns File/Code, wrapper owns hints only.`},...l.filter(e=>e.label!==`hint`)],d=[{label:`generate uuid`,insertText:`generate uuid`,documentation:`Random UUID v4; 122 random bits. Implicit on Uuid concepts; String UUIDs are lowercase by default.`},{label:`generate uuidv7`,insertText:`generate uuidv7`,documentation:`Time-ordered UUID v7; 74 random bits. Exposes time, not monotonic within a millisecond.`},{label:`generate ulid`,insertText:`generate ulid`,documentation:`26 uppercase Crockford base32 characters; 80 random bits. String concepts only.`},{label:`generate typeid`,insertText:'generate typeid "${1:user}"',documentation:`TypeID 0.3, lowercase UUIDv7 base32; 74 random bits. Empty prefix has no separator.`},{label:`generate nanoid`,insertText:"generate nanoid ${1:21}",documentation:`String from a distinct printable ASCII alphabet; size × log2(alphabet size) random bits. Default: 21 × 6 = 126 bits.`},{label:`generate bytes`,insertText:"generate bytes ${1:32} ${2|base64url,hex,base32|}",documentation:`Cryptographic random bytes, RFC 4648 without padding; 8 × count bits. Case applies only to hex/base32.`},{label:`generate pattern`,insertText:'generate pattern "${1:INV-{yyyy}{MM}-#{7}}"',documentation:`ESM v21 finite ASCII pattern with bounded repeats and UTC date segments. Distinct-support entropy excludes dates and check digits; generated fixtures use given clock when present.`},{label:`generate random`,insertText:"generate random ${1:1}..${2:9}",documentation:`ESM v21 inclusive signed Int64 range; exact integral fixtures, not strings. A generated value, never an Int identifier.`},{label:`generate rule`,insertText:"generate rule ${1:Name}\n file ${2:Generator.cs}",documentation:`ESM v21 ValueGeneration attachment: exactly one direct file or tagged fence. Closed context Now and Tenant; entropy is unknown. The reference runner requires a fixture and never executes the body.`},{label:`validate checksum`,insertText:"validate checksum ${1|luhn,mod11,mod97|}",documentation:`String concepts only: validates the exact trailing check digits over preceding ASCII digits, including supplied and stored values. Generation alone does not add this rule.`},{label:`description`,insertText:'description "${1:what this value represents}"',documentation:`Report-only authoring description; not a validation or compliance note.`},{label:`file`,insertText:"file ${1:Path}",documentation:`Names the repository relative file this declaration is realized by, so the document can be navigated back to the code.`},{label:`pii reason`,insertText:'pii reason "${1:why this value is personal data}"',documentation:`A free-text concept note, not a lawful basis.`},{label:`secret reason`,insertText:'secret reason "${1:why this value is an operational secret}"',documentation:`Records why the secret marker applies.`},{label:`secret scope`,insertText:"secret scope ${1|subject,namespace,global|}",documentation:`Explicit encryption scope; omitted scope keeps Chronicle’s Subject default.`},{label:`pii special`,insertText:"pii special ${1|racialOrEthnicOrigin,politicalOpinions,religiousOrPhilosophicalBeliefs,tradeUnionMembership,genetic,biometric,health,sexLifeOrSexualOrientation|}",documentation:`GDPR Art. 9(1) special category of personal data.`},{label:`pii criminal`,insertText:`pii criminal`,documentation:`Personal data relating to criminal convictions and offenses (GDPR Art. 10).`},{label:`validate`,insertText:'validate\n ${1:not empty} message "${2:message}"',documentation:`Validation rules that travel with the value everywhere it appears.`}],f=[{label:`file`,insertText:"file ${1:Path}",documentation:`Names the repository relative file this declaration is realized by, so the document can be navigated back to the code.`},{label:`description`,insertText:'description "${1:what this shape represents}"',documentation:`A human-readable description of the type.`},{label:`property`,insertText:"${1:property} ${2:Type}",documentation:`A property of the type — a name and a type reference.`}],p=[n,t,...i,{label:`operation`,insertText:"operation ${1:Name}\n uses ${2:System}\n ${3:input} ${4:Type}",documentation:`Reusable slice-owned operation intent; not admitted by any supported executable model (ESM) version yet.`},{label:`file`,insertText:"file ${1:Path}",documentation:`Names the repository relative file this declaration is realized by, so the document can be navigated back to the code.`},{label:`public event`,insertText:"public event ${1:Name}\n ${2:property} ${3:Type}",documentation:`Declares a public event: a contract this application publishes. Admitted by ESM v9; an outbound Translate slice produces it through a projection that targets it.`},{label:`event from`,insertText:'event ${1:Name} from "${2:origin}"\n ${3:property} ${4:Type}',documentation:`An event with an opaque origin naming the application that owns it, not a path or declaration reference. It is a public event admitted by ESM v9; consume it with a capture over source events.`},{label:`direction`,insertText:"direction ${1|inbound,outbound|}",documentation:`Translate direction, inbound or outbound, admitted by ESM v9. No transport or delivery guarantee is implied.`},{label:`event`,insertText:"event ${1:Name}\n ${2:property} ${3:Type}",documentation:`Declares an event type — an immutable, past-tense fact.`},{label:`event generation`,insertText:"event ${1:Name} generation ${2:2}\n ${3:property} ${4:Type}",documentation:`Declares a complete numbered event generation; start at 1 and do not skip a number.`},{label:`command`,insertText:"command ${1:Name}\n ${2:property} ${3:Type}",documentation:`Declares a command — an imperative intent that produces events.`},{label:`query`,insertText:"query ${1:Name} => ${2:ReadModel}",documentation:`Declares a read-side entry point mapping to a return type.`},{label:`query observable`,insertText:"query ${1:Name} => observable ${2:ReadModel}",documentation:`Declares a live read — the query keeps pushing as the read model changes, instead of answering once.`},{label:`readmodel`,insertText:"readmodel ${1:Name}\n ${2:property} ${3:Type}",documentation:`Declares the shape of a read model — its properties — that a projection, reducer or query fills and returns.`},{label:`reducer`,insertText:"reducer ${1:Name} => ${2:ReadModel}\n on ${3:EventType}\n ```csharp\n ${4}\n ```",documentation:`Declares a reducer building a read model from events with imperative code, for what a projection cannot express.`},{label:`specification`,insertText:"specification ${1:Name}\n given ${2:EventType}\n when ${3:Command}\n then ${4:EventType}",documentation:`Given/when/then acceptance criteria for the slice.`},{label:`projection`,insertText:"projection ${1:Name} => ${2:ReadModel}\n from ${3:EventType}",documentation:`Declares how events project into a read model (PDL).`},{label:`capture`,insertText:"capture ${1:Name}\n source ${2:api}",documentation:`Declares a change data capture converting external data into events (CDL).`},{label:`reaction`,insertText:"reaction ${1:Name}\n when ${2:Trigger}",documentation:`Declares behavior that runs when something happens.`},{label:`screen`,insertText:"screen ${1:Name}\n data ${2:ReadModel} via query ${3:QueryName}",documentation:`Declares a UI screen.`},{label:`constraint`,insertText:"constraint ${1:Name}\n unique ${2:property} on ${3:EventType}",documentation:`Declares a server-side rule enforced before events are committed.`}],m=[t,{label:`property`,insertText:"${1:property} ${2:Type}",documentation:`An input of the command — a name and a type reference.`},{label:`produces operation`,insertText:"produces operation ${1:Name}\n uses ${2:System}\n ${3:input} ${4:Type} = ${5:source}",documentation:`Declares ordered operation intent; not admitted by any supported executable model (ESM) version yet (PLAY0268).`},{label:`returns property`,insertText:"returns @${1:property}",documentation:`Scalar response from a direct command property, only on acceptance. Executable as ESM v7.`},{label:`returns block`,insertText:"returns\n ${1:field} = ${2:property}",documentation:`Unnamed record response with inferred or explicit field types, only on acceptance. Executable as ESM v7.`},{label:`produces event`,insertText:"produces event ${1:Name}\n ${2:property} ${3:Type} = ${4:source}",documentation:`Declares a slice-owned generation-1 event and maps its properties. An omitted for uses the command identifier.`},{label:`identifier property`,insertText:"${1:property} ${2:Type} identifier",documentation:`Marks the property a runtime resolves the event source id from. At most one per command.`},{label:`authorize`,insertText:"authorize ${1:PolicyName}",documentation:`References the policies that must pass for the command to execute.`},{label:`reads`,insertText:"reads ${1:View} by ${2:property}",documentation:`Declares a view the command consults. Executable binding is not yet supported.`},{label:`reads as`,insertText:"reads ${1:View} as ${2:alias} by ${3:property}",documentation:`Names one instance of a view; every instance needs a unique alias when reading the same view more than once.`},{label:`validate`,insertText:'validate\n ${1:property} not empty message "${2:message}"',documentation:`Declarative validation rules with messages.`},{label:`validate csharp`,insertText:`validate\n ${fenced(`csharp`)}`,documentation:`Imperative validation in C#, yielding the message of every rule the artifact breaks.`},{label:`produces`,insertText:"produces ${1:EventType}\n ${2:property} = ${3:source}",documentation:`Declares the event the command emits, with property mappings.`},{label:`produces when`,insertText:"produces when ${1:condition}\n ${2:EventType}\n ${3:property} = ${4:source}",documentation:`Conditionally emits an event when the condition holds.`},{label:`description`,insertText:'description "${1:what the command asks for}"',documentation:`A human-readable description.`},{label:`concurrency`,insertText:`concurrency
8
8
  \${1|eventSource,sourceType,streamType,streamId,events|}`,documentation:`The scope of the concurrency check made when the command appends events.`},{label:`handler`,insertText:`handler
9
9
  `,documentation:`Fully imperative command implementation — file reference or inline C#, instead of produces.`}],h=[{label:`property`,insertText:"${1:property} ${2:Type}",documentation:`A property of the event — a name and a type reference.`},{label:`description`,insertText:'description "${1:what happened}"',documentation:`Authoring metadata, as one line or a text/markdown fence.`},{label:`documentation`,insertText:"documentation\n ```markdown\n ${1:Details}\n ```",documentation:`Authoring-only Markdown documentation.`},{label:`id`,insertText:'id "${1:OldName}"',documentation:`Preserves a previous persisted event name after a rename. Leave absent for new events.`},{label:`tag`,insertText:"tag ${1:audit}",documentation:`An event-type tag stamped on every occurrence.`}],g=[...h,{label:`for`,insertText:"for ${1:identifier}",documentation:`Explicitly names the command identifier used as the event source.`},{label:`property mapping`,insertText:"${1:property} ${2:Type} = ${3:source}",documentation:`Declares and maps an event property on one line.`}],_=[{label:`when`,insertText:"when ${1:condition}",documentation:`Guards the produced event with a condition.`}],v=[{label:`hint`,insertText:'hint "${1:implementation guidance}"',documentation:`Ordered nonblank guidance for a handler implementation. Not an execution guarantee.`},{label:`file`,insertText:"file ${1:Path}",documentation:`Selects one existing model-relative attachment.`},...[`csharp`,`typescript`,`react`,`html`,`sql`].map(e=>({label:e,insertText:fenced(e),documentation:`Selects one inline payload. Handler execution remains unsupported.`}))],y=[{label:`implementation`,insertText:`implementation
10
10
  hint "\${1:implementation guidance}"`,documentation:`Handler-only implementation intent with optional file or tagged fence. With no payload it is pending.`},{label:`file`,insertText:"file ${1:Path}",documentation:`Delegates the command implementation to an external C# file.`},{label:`csharp`,insertText:fenced(`csharp`),documentation:`Inline C# returning the events to append.`}],b=[{label:`description`,insertText:'description "${1:what this query is trying to accomplish}"',documentation:`What the query is for, in prose — what a generator or reviewer works from.`},{label:`by`,insertText:"by ${1:param} ${2:Type}",documentation:`Declares the identifying parameter of the query.`},{label:`by parts`,insertText:"by\n ${1:part} ${2:Type}\n ${3:part} ${4:Type}",documentation:`Declares a composite lookup. Supply every key part for a single instance.`},{label:`filter`,insertText:"filter ${1:param} ${2:Type} optional",documentation:`Declares an optional filter parameter supplied by the caller.`},{label:`filter from context`,insertText:"filter ${1:param} ${2:Type} from $context.${3|tenant,causedBy.subject,occurred|}",documentation:`Declares a parameter filled from the query context instead of the caller.`},{label:`authorize`,insertText:"authorize ${1:PolicyName}",documentation:`References the policies that must pass for the query to execute.`},{label:`performer`,insertText:`performer