@cratis/screenplay-language 4.230.0 → 4.232.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":"keyword-docs.js","names":["handlerIntentDocs","keywordDocs","specificationKeywordDocs","attributeDocs","contextVariableDocs","\"$identity\"","\"$env\"","\"$secrets\"","\"$strings\"","eventContextPaths","path","specialCategoryDocs"],"sources":["../../keyword-docs.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 { eventContextPaths } from './event-context';\n\n// These words are contextual beneath a handler, never global property keywords.\nexport const handlerIntentDocs = {\n implementation: 'Handler-only intent with ordered hints and at most one file or tagged fence. No payload means pending. Handler execution is unsupported; this is not confirmation.',\n hint: 'One nonblank quoted implementation hint. Order and decoded text are retained; hints do not execute or confirm code.',\n};\n\nexport const keywordDocs: Record<string, string> = {\n parameter: 'A typed value declared by a specification table, or an argument of a named behavior. Table types are required; every case supplies each parameter exactly once.',\n case: 'One named concrete row of a specification table, expanded as <Specification>_<Case>. Use case.<parameter> for a whole step value.',\n example: 'One typed, possibly partial fixture: `example <Name> : <EventOrCommandOrReadModel>`. Use its name in a matching specification step; assignments override example values without changing matching or supplying defaults. Event examples may carry stream or no stream; a step replaces that route as a whole.',\n domain: 'The domain the file belongs to — optional, at most one per file, before everything else.',\n import: 'Imports a type from another module by its qualified name — `import Module.Type` — making it available by its short name; or, quoted, other `.play` files by path or glob — `import \"Orders/**/*.play\"`, relative to this file\\'s folder. Written inside a module or feature, a file import places the imported files there: their top level is that module\\'s or feature\\'s body. `import Module.Event from \"origin\"` is instead public contract metadata with an opaque origin; executable binding refuses it with PLAY0268.',\n concept: 'A formalized value type wrapping a primitive. Bare pii and secret markers travel with every usage, with optional concept notes and qualifiers.',\n type: 'A composite value type — a named shape built from several properties, referenced by events, commands and other types the same way a concept is.',\n reason: 'A free-text concept note, not a lawful basis. Written as pii reason \"...\" or secret reason \"...\"; migration preserves it verbatim.',\n optional: 'Allows a value to be absent. Write it after the type: `note String optional` or `lines InvoiceLine[] optional`. The collection itself may be absent; its items keep their declared type.',\n identifier: 'Marks the command property a runtime resolves the event source id from. At most one per command; without it a new Uuid is generated.',\n policy: 'A named authorization rule referenced by commands and queries. Multiple policies AND together.',\n purpose: 'A report-only processing declaration (GDPR Art. 30), referenced on modules, features and slices. Coverage is their union, not an authorization gate. Generated declarations are not legal advice.',\n basis: 'One declared Art. 6(1) basis: consent, contract, legalObligation, vitalInterests, publicTask or legitimateInterests; an optional quoted reference may follow.',\n interest: 'The legitimate-interest statement for basis legitimateInterests (Art. 13(1)(d)).',\n condition: 'One Art. 9(2) processing condition, optionally followed by a quoted reference.',\n subjects: 'Comma-separated categories of data subjects, as open identifiers.',\n retention: 'Declared retention period or criteria, not enforced by the model or Chronicle.',\n recipient: 'A quoted recipient category; repeatable on a purpose.',\n transfer: 'A declared destination followed by safeguard and quoted safeguards; repeatable.',\n safeguard: 'The declared safeguard accompanying a third-country transfer.',\n erasure: 'An erasure exception under Art. 17(3); Chronicle crypto-shredding remains per subject, not per purpose.',\n exception: 'One declared Art. 17(3) exception: expression, legalObligation, publicTask, publicHealth, archiving or legalClaims.',\n persona: 'A named role interacting with the application, with an optional description and its associated policies.',\n identity: 'Declares typed additional caller details from a claim, a keyed single-result query, inline code or a file. Authoring metadata only; executable use of `$identity.<detail>` reports PLAY0268 until admitted (#600).',\n authentication: 'Declares the identity providers of the application — at most one block per file.',\n provider: 'A named identity provider within `authentication`, with free-form `name value` settings.',\n description: 'A human-readable description, including the rule or case a specification witnesses, as a quoted single line or a fenced ```text block for multiple lines.',\n depends: 'Declares `depends on <Name>` on a module or feature. This opts only that container into checking counted explicit references against its own declarations; it does not change executable bytes.',\n module: 'The top-level namespace — maps to a bounded context.',\n layout: 'A reusable screen template with named slots.',\n template: 'Names a template to fill or assign: `template <Name>` for an own template, `template blueprint <Blueprint> <Name> [version \"<range>\"]` for a template a blueprint package ships.',\n blueprint: 'In `template blueprint <Blueprint> <Name>`, the blueprint package the template comes from. A `ui profile` should list it under `packages`. In `ui profile` `sample data`, `active blueprint <id>` selects a sample data pack a blueprint ships, resolved by the build against its packages.',\n version: 'In `template blueprint ... version \"<range>\"`, the semver range of the blueprint the reference accepts, such as `^1.4`.',\n scopes: 'Where a template may be used: `application`, `module`, `feature`, `subfeature` or `slice`. `slice` can be followed by the kinds `statechange` and `stateview`, such as `scopes slice statechange|stateview`.',\n category: 'The group a template picker lists a layout or template under. Every layout and template needs one.',\n feature: 'A vertical slice grouping. Features nest arbitrarily deep.',\n slice: 'The atomic unit of behavior, aligned with Event Modeling. Has a type and a name.',\n public: 'Marks an event as a public contract. An event with from \"origin\" is also public. Origin is opaque, not a path or declaration reference. Public events and origins are admitted by executable semantic model (ESM) v9.',\n direction: 'Declare direction inbound or direction outbound once inside a Translate slice. Admitted by executable semantic model (ESM) v9; a Translate slice that uses public events must declare it (PLAY0614).',\n inbound: 'Inbound Translate direction metadata. No transport or delivery guarantee is implied.',\n outbound: 'Outbound Translate direction metadata. No transport or delivery guarantee is implied.',\n event: 'An immutable, past-tense fact. Declare it in a slice or inline with `produces event <Name>` in a command. Inline properties are typed mappings; inline tags belong to the event type.',\n documentation: 'Authoring-only reasoning on a module, feature, slice, command, event, read model or reaction in one nonempty fenced ```markdown block. It does not change executable model bytes.',\n id: 'Preserves the previous persisted event name after a rename. Leave absent on new events; repeating the current name is redundant.',\n command: 'An imperative intent. Declares authorization, validation, and what events it produces — declaratively, or via a full handler.',\n query: 'A read-side entry point mapping to a return type, with an optional description, parameters and performer. The by key and every supplied filter value satisfy their concept rules after authorization; violations reject with Validation, not an empty result.',\n observable: 'Qualifies a query return type as a live read — `query <Name> => observable <ReadModel>` keeps pushing as the read model changes, instead of answering once.',\n performer: 'The code that performs a query — a `file <Path>` reference or an inline `csharp`/`sql` block. The query\\'s counterpart to a command handler.',\n from: 'On a reaction or reducer, `from Source[.Stream]` observes only matching routed facts. It does not filter stream ids. Admitted by ESM v10. On a query parameter, fills it from the query context instead of the caller, as in `filter tenantId TenantId from $context.tenant`.',\n projection: 'Declares how events project into a read model, using the embedded Projection Declaration Language (PDL).',\n capture: 'Converts external data into events, using the embedded Change Data Capture Language (CDL).',\n protected: 'Application-root `command reads protected` admits eligible command reads (ESM v25). Required absence rejects with Validation before derive/provide and requirements; a matching intervening fact yields Conflict/DecisionStateChanged without facts. Without the preamble, legacy reads retain their existing refusals. Targets must separately admit the version.',\n batches: 'Application-root `reaction batches atomic` opts into ESM v22 atomic direct and refusal-branch batches. Invoked commands remain separate transactions.',\n atomic: 'All productions in one reaction trigger occurrence or selected refusal branch are adopted together or not at all. Absence retains legacy per-fact semantics.',\n reaction: 'Behavior that runs when something happens. Lives inside Automation slices. A trigger with no body states intent on its own — `file`/code is optional realization metadata.',\n runs: '`runs as system [role \"Role\" and role \"Role\"]` declares the identity for every returned or invoked command of a reaction, not imperative pipeline calls. Admitted by released ESM v10; claims are unknown for this identity. Clock and application triggers have no Stage realization yet.',\n trigger: 'Declares a kind of occurrence a reaction can respond to, and the values it hands the reaction. What makes one occur belongs to whoever provides it, never to the compiler.',\n where: 'Narrows which occurrences actually run the reaction.',\n contains: 'Ordinal UTF-16 text comparison: the value holds the literal operand anywhere. In validation, `not contains` negates it; absent optional values pass. An empty operand always occurs.',\n starts: 'Use `starts with \"text\"` for an ordinal UTF-16 literal prefix validation rule or condition.',\n ends: 'Use `ends with \"text\"` for an ordinal UTF-16 literal suffix validation rule. An absent optional value passes.',\n every: 'Runs a reaction on an interval — `every 15 minutes`, `every 1 day`.',\n refused: 'Ordered invocation refusal branch, executable from ESM v19: first match wins and stops remaining invocations of this trigger. Bare `on refused` covers validation and constraints, not authorization. Other reactions and cascades continue; contract errors, concurrency and Unsupported never match.',\n acknowledge: 'A refusal branch acknowledges alone without facts, or produces events instead. Executable from ESM v19; handling stops remaining invocations of this trigger.',\n validation: 'In `on refused by validation`, selects error-severity property, concept and require refusals. Executable from ESM v19.',\n authorization: 'In `on refused by authorization`, explicitly selects unauthorized results, never Unsupported. Executable from ESM v19; bare refusal excludes authorization.',\n redelivered: '`when redelivered <Event> to <Reaction>` selects exactly one effective given occurrence by optional for, stated values and stream or no stream, delivering that event again to one named reaction without appending it again. Executable from ESM v17.',\n invokes: 'A command a reaction hands on. A command is asked for, not produced — it may still be rejected.',\n screen: 'A UI declaration. Supports intent, structure, and layout-with-code levels, or a full file reference.',\n constraint: 'A server-side rule enforced in the Chronicle kernel before events are committed.',\n authorize: 'References the policies that must all pass for the construct to execute.',\n validate: 'Declarative validation rules, or `validate` followed by ```csharp for imperative rules — on commands and concepts.',\n checksum: 'String-concept validation: exact trailing luhn/mod11 digit or two mod97 digits over preceding ASCII digits. Also applies to supplied and stored values; generation does not silently add validation.',\n luhn: 'Luhn check digit, with standard parity from the right. Generation appends it; validate checksum luhn checks the arithmetic.',\n mod11: 'Check digit (11 - weighted sum modulo 11) modulo 11, weights 2..7 cycling from the right. Output 10 is excluded from generation support.',\n mod97: 'ISO 7064 MOD 97-10, two zero-padded trailing digits. Validation checks the exact computed suffix, not only congruence.',\n produces: 'References a declared event with `produces <Name>`, or declares one inline with `produces event <Name>`. An inline omitted `for` uses the command identifier only when all destinations are the same source; legacy plain omission allocates an identity.',\n reads: 'Declares a view consulted by a command or reaction trigger: `reads <View> [as <alias>] [by <value>]`. A reaction `by` names a value taken by its trigger; clock triggers cannot use `by`. A child by block supplies composite key parts by name, using part = source, but is refused for protected command reads (PLAY0781 ByParts). Repeated views require unique aliases. With `command reads protected`, command reads bind only over finite event-log projections keyed by event-source identity with removal handlers and required scalar non-generated input keys. Omitted `by` uses the command identifier. Single-level read/alias.property paths are admitted in validate require operands and produces mappings only. Reaction reads remain unadmitted.',\n as: 'Names an instance of a view in a command or reaction trigger reads declaration, for example `reads Account as source by sourceId`.',\n handler: 'A fully imperative command implementation — a `file <Path>` reference or an inline `csharp` block, instead of `produces`.',\n when: 'Guards a produced event or a capture append with a condition. In a labeled screen action, `when item.<field> == <literal> execute <Command>` selects the first matching command. Inside on click, double click or select, block-form `when <condition>` selects one whole action list at gesture time.',\n rule: 'Names a predicate. Bare, it states that a constraint exists without expressing what it computes — nothing resolves the name. Optionally followed by an indented `file <Path>` reference or inline `csharp` block giving it a body.',\n require: 'A policy condition: `authenticated`, `role \"...\"`, or `claim \"...\" matches ...`. Unary `not` negates a condition or group; precedence is not, and, or.',\n authenticated: 'Requires an authenticated caller.',\n role: 'Requires the caller to have the given role.',\n claim: 'Requires a claim on the caller to match a subject or value.',\n subject: 'In policy `matches subject`, the identifier of the thing acted on, not the caller. The caller is `$context.causedBy.subject`.',\n data: 'Binds a read model to a screen through a query.',\n action: 'Makes a command available on a screen. `action \"Label\"` declares one button with ordered `when … execute` alternatives over the nearest data item or selected row. No subject hides it; commands still enforce authorization and validation.',\n otherwise: 'The final fallback of a guarded action: `otherwise hidden` or `otherwise execute <Command>`. In an item interaction, bare `otherwise` opens a fallback action list. No subject runs nothing, including fallback; authorization never falls through.',\n hidden: 'Hides a guarded action when no condition matches. Without a subject the action is always hidden, even with an execute fallback.',\n execute: 'Executes a command. A guarded screen action selects it by the first matching condition; explicit `with … from` bindings precede same-name item fields, its declared form and renderer input.',\n navigate: 'Navigates to a screen, optionally passing a parameter with `by`.',\n section: 'A named structural section of a screen.',\n table: 'A table widget over a read model or child collection.',\n summary: 'A summary widget showing labeled fields.',\n column: 'A table column bound to a property.',\n field: 'A summary field bound to a property.',\n title: 'The display title of a screen or section.',\n label: 'The display label of an action, column, or field.',\n unique: 'A uniqueness constraint — `unique <property> on <EventType>` or `unique event <EventType>`.',\n concurrency: 'The concurrency scope enforced when the command appends events — dimensions: `eventSource`, `sourceType`, `streamType`, `streamId`, `events`.',\n eventSource: 'Concurrency dimension — scope the check to the event source id of the command.',\n sourceType: 'Concurrency dimension — scope the check to an event source type.',\n streamType: 'Concurrency dimension — scope the check to an event stream type.',\n streamId: 'Concurrency dimension — scope the check to an event stream id.',\n tag: 'Attaches a tag to appended events — a static identifier or string, or a `$context.` expression resolved at append time.',\n seed: 'Declares events to seed into the event store per event source id — multiple blocks accumulate.',\n for: 'Names the event source of a production or seed group. Inside `produces event`, omission uses the command identifier unless another production targets a different source.',\n readmodel: 'Declares a read model — its name and properties — in a slice, or, in a specification, read model state: `given readmodel` establishes it, `then readmodel` asserts it, `then no readmodel <View> for <key>` asserts keyed absence.',\n reducer: 'Builds a read model from events with imperative code — `reducer <Name> => <ReadModel>` with an `on <EventType>` rule per event. Use it when a projection cannot express the transition.',\n specification: 'Given/when/then acceptance criteria for a slice: prior events and state, the command, query or appended event under test, and the events, state, results, errors or denials that follow.',\n dialog: 'A dialog opened over the shell, or with `dialog template` a reusable dialog shape.',\n form: 'A form bound to a command — `form <Name> for <Command>` with a `field` per input.',\n contribute: 'Contributes entries to a slot of the shell — `contribute to Navigation` with `navigate to`, `label` and `order`.',\n button: 'A toolbar button that invokes a State Change slice — `button <id> title \"…\" slice <Module>.<Feature>.<Slice> [emphasis primary|secondary|quiet] [icon <name>]`. The slice names the command and the dialog it opens.',\n navigation: 'A navigation region of the shell — `navigation topbar` or `navigation sidebar`. A layout declares the application\\'s regions with a `logo` and `item` lines; a module adds `inherits`, `extends` or `overrides` to change what it shows.',\n theme: 'A named theme and the component packages it is compatible with.',\n sample: 'Sample data — `sample data <Name>` declares a pack of demo rows per `shape` that a design surface or preview shows instead of a backend. Design and preview time only; it never reaches backend or production output. The application picks its active pack once, in the `ui profile`.',\n active: 'The active sample data pack of the whole application, chosen once in the `ui profile` `sample data` block — one declared in the document, or `blueprint <id>` for one a blueprint ships.',\n bind: 'Binds one read model to a sample data pack — `bind <ReadModel> to <pack>` — a rare override of the active pack for that read model only.',\n maps: 'Maps a sample data shape to the read model it supplies rows for — `shape <Shape> maps to <ReadModel>` — where the names differ.',\n row: 'One row of a sample data shape: `<field> = <literal>` lines, each field a property of the read model.',\n locale: 'The BCP 47 locale tag of a sample data pack, such as `nb-NO`.',\n shape: 'In sample data, the shape a set of rows is for; it matches the read model of the same name or the one a `ui profile` maps it to.',\n root: 'In a `ui profile`, `root template [blueprint <Blueprint>] <Name> [version \"<range>\"]` names the template the whole application is drawn in, with `option <name> <value>` lines for what the shell exposes.',\n appearance: 'In a `ui profile`, the `appearance` block holds `color scheme light|dark|system` and `accent \"<#hex>\"`.',\n accent: 'In a `ui profile` `appearance` block, `accent \"<#hex>\"` is the accent colour of the application.',\n scheme: 'In a `ui profile` `appearance` block, `color scheme light|dark|system` is the colour scheme of the application.',\n screens: 'In a `ui profile`, `new screens use template [blueprint <Blueprint>] <Name>` is the template a new screen starts from.',\n ui: 'A UI profile — `ui profile <Name>` binds a target platform and size to a layout, theme and packages.',\n behavior: 'A named interaction wiring of `on <interaction>` handlers, attached to a screen, form or dialog with `uses`.',\n system: 'An application-scoped external system that operations use.',\n eventsource: 'An application-owned event source with nested streams.',\n operation: 'A reusable operation intent that uses one external system.',\n no: 'A keyed absence assertion: `then no readmodel <View> for <key>`.',\n arguments: 'The values supplied to a query asserted by `then query`.',\n result: 'One expected result - `then result [exactly]` after `when query`, or a `result` block inside `then query`. Repeat it to assert several results in authored order.',\n clock: 'The instant a specification happens at - `given clock \"2026-10-05T08:00:00Z\"` fixes when everything occurs, including every generated pattern date segment at that same UTC instant. Without given clock, generation fixtures check date digit widths only, never the wall clock. `when clock \"<instant>\"` is the clock reaching it, as the action.',\n exactly: 'Requires every property to match, rather than only the ones asserted - on `then readmodel`, `then query` and `then result`.',\n file: 'Delegates the implementation to an external file; the Screenplay contract stays visible.',\n key: 'Trailing modifier on a required top-level read-model property. Explicit keys replace inference. Several scalar key properties identify one instance by named parts. Supply every part in a single-instance query by block and in projection key blocks; list queries can use equality filters.',\n stream: 'On a command event production, replaces the whole command route for that event. Other productions keep the command route. Admitted by ESM v10.',\n by: 'Introduces one identifying parameter or a block of at least two named key parts. Reads use part = source; queries use part Type.',\n via: 'Connects screen data to the query that supplies it.',\n filter: 'An optional query filter parameter.',\n on: 'The event a constraint applies to, the day a schedule narrows to, or a widget interaction such as `on row-click`.',\n message: 'The validation message reported when the rule fails.',\n matches: 'Searches text using the portable flagless JavaScript match dialect, or `email`. Use ^ and $ for the whole input. Exact Studio text-rule lookarounds warn with PLAY0787 and lower to ordinal rules; other lookarounds, backreferences and refused constructs report PLAY0699; patterns have at most 1000 source code units and 3000 expanded nodes, including optional, loop and alternative choice points.',\n all: 'Applies a comparison to every element of a collection.',\n max: 'Maximum length or value.',\n min: 'Minimum length or value.',\n length: 'Constrains the exact length of a value.',\n today: 'The current date.',\n empty: 'Used with `not empty` — text needs a non-whitespace character; null, empty and whitespace-only text fail. Unicode White_Space is U+0009–U+000D, U+0020, U+0085, U+00A0, U+1680, U+2000–U+200A, U+2028, U+2029, U+202F, U+205F and U+3000 (not U+FEFF). Collections need at least one element. Applies to concept and command rules in every ESM version; no trimming. Identity text is unchanged: whitespace is a value.',\n not: 'Negates a validation condition, as in `not empty`.',\n and: 'Both conditions must hold.',\n or: 'Either condition may hold.',\n csharp: 'An inline C# block whose opening fence is ```csharp.',\n sql: 'An inline SQL block between triple backticks — a query performer written against a relational store.',\n typescript: 'An inline TypeScript block between triple backticks.',\n react: 'An inline React/TSX block; receives the surrounding data contract as `Props`.',\n html: 'An inline static HTML block.',\n StateChange: 'Slice type — a command → events flow; something that changes the system.',\n StateView: 'Slice type — a query + projection + screen; something that reads the system.',\n Automation: 'Slice type — a reaction or reducer; something that runs when something happens.',\n Translate: 'Slice type — a capture; converts external data into events.',\n Uuid: 'Primitive type — a universally unique identifier. ESM v28 admits == and != between Uuid values (or concepts over Uuid) in command require and produces when; two concepts must be the same concept, and a literal must be canonical lowercase hyphenated. Ordering, optional operands, validation rules, concept rules and reaction where stay refused.',\n String: 'Primitive type — a string of characters.',\n Int: 'Primitive type — an integer number.',\n Decimal: 'Primitive type — a decimal number.',\n Bool: 'Primitive type — true or false.',\n Date: 'Primitive type — a calendar date without a time zone. ESM v26 admits all six comparisons in command require, produces when and command/property rules. Conditions use required same-primitive command properties or a literal; rules use literals only. Canonical literals use yyyy-MM-dd. Concept rules, reaction where, read paths, context and today stay refused.',\n DateTime: 'Primitive type — a date and time. ESM v26 command comparisons order UTC instants at tick precision, including equality across offsets. Compared input requires an explicit offset or Z before any rule runs; literals canonicalize to UTC with seven fractional digits and Z. Targets without tick precision refuse comparisons; client validators omit date ordering. Other equality stays ordinal.',\n Enum: 'An enumeration concept with named members. Members may all declare unique int32 numbers (draft = 1) or all omit them (zero-based positions). Never renumber or reuse a published number. Non-positional numbers select executable model (ESM) v12; consumers must explicitly admit v12. Specifications still name members.',\n};\n\n// What the words of a specification's steps mean there - where 'trigger', 'capture' and 'query' name what the\n// scenario exercises rather than declare one.\nexport const specificationKeywordDocs: Record<string, string> = {\n parameter: 'Declares a required typed case value: `parameter <name> <Type>`. Every case assigns it once. `optional` permits literal null but supplies no default.',\n case: 'One named complete row of a specification table. `case.<parameter>` substitutes a whole value after example overrides; each row runs as `<Specification>_<Case>`.',\n caller: '`given caller` states an explicit identity; `given caller as <Persona>` synthesizes an authenticated deterministic witness of the persona, with no body. Leftmost buildable policy alternatives are significant.',\n clock: keywordDocs.clock,\n redelivered: keywordDocs.redelivered,\n trigger: '`when trigger <Trigger>` - an application trigger fires, as the action, with the values on the lines beneath it.',\n capture: '`given capture <Capture>` - a record the capture\\'s source held before; `when capture <Capture>` - the record it sees now, as the action. The fields go on the lines beneath.',\n query: '`when query <Query>` performs the query with arguments beneath it; assert returned rows with `then result` or genuine absence with `then no result`. From ESM v18, one actionless query with `then error` asserts exactly Validation and no other outcome. This also works with `then query` and an arguments block, without a result block.',\n events: '`then no events` - asserts the action appended no events, also after `when append`, where it means no reaction appended anything. Executable from ESM v17. Cannot accompany event, event-order, error or denial expectations.',\n result: '`then result [exactly]` - one result the query performed by `when query` returns, in order; `then no result` - it returns nothing.',\n};\n\nexport const attributeDocs: Record<string, string> = {\n pii: 'personal data (GDPR Art. 4(1)); renders Chronicle [PII]. Bare suffix marker; @pii is deprecated (PLAY0565). Selects executable model (ESM) v13; consumers must explicitly admit it. Cannot classify identity or enum concepts. An event with personal values and an explicit subject mark refuses binding (PLAY0268) until lineage is admitted.',\n personal: 'Alias of pii: personal data (GDPR Art. 4(1)); renders Chronicle [PII]. No diagnostic; canonical printing writes pii. Selects executable model (ESM) v13, like pii.',\n secret: 'Operational secret, not personal data: encrypted at rest without erasure and withheld from causation. Provider mapping: [Encrypted] + [NotAudited], or [PII] only with pii. Selects executable model (ESM) v13; reference outcomes are unchanged. Cannot classify identity (PLAY0515) or enum concepts. Explicit scope is omitted next to pii. An event combining secret scope subject with an explicit subject mark refuses binding (PLAY0268).',\n sensitive: 'Deprecated spelling of secret (PLAY0565); repair to bare secret. Operational secret, not GDPR Art. 9 special-category data.',\n};\n\nexport const contextVariableDocs: Record<string, string> = {\n '$context.occurred': 'When the command or query was received.',\n '$context.tenant': 'The tenant the command or query is executing for.',\n '$context.command': 'The command being handled, shaped by its `command` declaration.',\n '$context.arguments': 'The arguments of the query being performed.',\n '$context.causedBy': 'The identity that caused the command or query — `subject`, `name`, `userName`.',\n '$context.causedBy.subject': 'The subject of the identity that caused the command or query.',\n '$context.causedBy.name': 'The display name of the identity that caused the command or query.',\n '$context.causedBy.userName': 'The user name of the identity that caused the command or query.',\n '$context.causation': 'What caused the command or query — `type`, `occurred`, `properties`.',\n '$context.causation.type': 'What caused the command or query — a command, a reactor, a schedule.',\n '$identity': 'The caller — token built-ins `id`, `name`, `userName`, `isAuthenticated`, `roles`, `claims`, plus declared identity details. Built-ins are equivalent to `$context.identity`; details are authoring-only until admitted (#600).',\n '$identity.id': 'The identifier of the caller from the auth token; equivalent to `$context.identity.id`.',\n '$identity.name': 'The display name of the caller; equivalent to `$context.identity.name`.',\n '$identity.userName': 'The user name of the caller; equivalent to `$context.identity.userName`.',\n '$identity.isAuthenticated': 'Whether the caller is authenticated.',\n '$identity.roles': 'The roles the caller holds.',\n '$identity.claims': 'The claims the caller carries — `$identity.claims.<name>` reads one.',\n '$context.identity': 'The caller a decision is made about — `id`, `name`, `userName`, `isAuthenticated`, `roles`, `claims`.',\n '$context.identity.id': 'The identifier of the caller from the auth token.',\n '$context.identity.name': 'The display name of the caller.',\n '$context.identity.userName': 'The user name of the caller.',\n '$context.identity.isAuthenticated': 'Whether the caller is authenticated.',\n '$context.identity.roles': 'The roles the caller holds.',\n '$context.identity.claims': 'The claims the caller carries — `$context.identity.claims.<name>` reads one.',\n '$env': 'An environment variable, e.g. `$env.SERVICE_NAME`.',\n '$secrets': 'An encrypted secret resolved at runtime, e.g. `$secrets.azureAdClientId` — stays symbolic in the compiled tree.',\n '$strings': 'A localized string resolved from the `.strings` file of the active locale, e.g. `$strings.invoices.title`.',\n // Every $eventContext path the event-context catalog lists, for projections.\n ...Object.fromEntries(eventContextPaths.map((path) => [`$eventContext.${path.path}`, path.description])),\n};\n\n// One-sentence descriptions of the `pii special` categories (GDPR Art. 9(1)) and `pii criminal` (Art. 10).\n// The same sentences appear in Documentation/screenplay/concepts.md.\nexport const specialCategoryDocs: Record<string, string> = {\n racialOrEthnicOrigin: 'Data revealing a person\\'s racial or ethnic origin (GDPR Art. 9(1)).',\n politicalOpinions: 'Data revealing a person\\'s political opinions (GDPR Art. 9(1)).',\n religiousOrPhilosophicalBeliefs: 'Data revealing a person\\'s religious or philosophical beliefs (GDPR Art. 9(1)).',\n tradeUnionMembership: 'Data revealing whether a person belongs to a trade union (GDPR Art. 9(1)).',\n genetic: 'Data about inherited or acquired genetic characteristics that gives unique information about a person\\'s physiology or health (GDPR Art. 9(1), Art. 4(13)).',\n biometric: 'Data from technical processing of physical, physiological or behavioral characteristics, special only when processed to uniquely identify a person (GDPR Art. 9(1), Art. 4(14)).',\n health: 'Data about a person\\'s physical or mental health, including health care services, that reveals their health status (GDPR Art. 9(1), Art. 4(15)).',\n sexLifeOrSexualOrientation: 'Data concerning a person\\'s sex life or sexual orientation (GDPR Art. 9(1)).'\n};\n"],"mappings":"2IAMA,MAAaA,EAAoB,CAC7B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CACvD,oBAAqB,0CACrB,kBAAmB,oDACnB,mBAAoB,kEACpB,qBAAsB,8CACtB,oBAAqB,iFACrB,4BAA6B,gEAC7B,yBAA0B,qEAC1B,6BAA8B,kEAC9B,qBAAsB,uEACtB,0BAA2B,uEAC3BC,UAAa,kOACb,eAAgB,0FAChB,iBAAkB,0EAClB,qBAAsB,2EACtB,4BAA6B,uCAC7B,kBAAmB,8BACnB,mBAAoB,uEACpB,oBAAqB,wGACrB,uBAAwB,oDACxB,yBAA0B,kCAC1B,6BAA8B,+BAC9B,oCAAqC,uCACrC,0BAA2B,8BAC3B,2BAA4B,+EAC5BC,KAAQ,qDACRC,SAAY,kHACZC,SAAY,6GAEZ,GAAG,OAAO,YAAYC,EAAkB,IAAK,GAAS,CAAC,iBAAiBC,EAAK,OAAQA,EAAK,WAAW,CAAC,CAAC,CAC3G,EAIaC,EAA8C,CACvD,qBAAsB,sEACtB,kBAAmB,iEACnB,gCAAiC,iFACjC,qBAAsB,6EACtB,QAAS,6JACT,UAAW,mLACX,OAAQ,kJACR,2BAA4B,6EAChC"}
1
+ {"version":3,"file":"keyword-docs.js","names":["handlerIntentDocs","keywordDocs","specificationKeywordDocs","attributeDocs","contextVariableDocs","\"$identity\"","\"$env\"","\"$secrets\"","\"$strings\"","eventContextPaths","path","specialCategoryDocs"],"sources":["../../keyword-docs.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 { eventContextPaths } from './event-context';\n\n// These words are contextual beneath a handler, never global property keywords.\nexport const handlerIntentDocs = {\n implementation: 'Handler-only intent with ordered hints and at most one file or tagged fence. No payload means pending. Handler execution is unsupported; this is not confirmation.',\n hint: 'One nonblank quoted implementation hint. Order and decoded text are retained; hints do not execute or confirm code.',\n};\n\nexport const keywordDocs: Record<string, string> = {\n parameter: 'A typed value declared by a specification table, or an argument of a named behavior. Table types are required; every case supplies each parameter exactly once.',\n case: 'One named concrete row of a specification table, expanded as <Specification>_<Case>. Use case.<parameter> for a whole step value.',\n example: 'One typed, possibly partial fixture: `example <Name> : <EventOrCommandOrReadModel>`. Use its name in a matching specification step; assignments override example values without changing matching or supplying defaults. Event examples may carry stream or no stream; a step replaces that route as a whole.',\n domain: 'The domain the file belongs to — optional, at most one per file, before everything else.',\n import: 'Imports a type from another module by its qualified name — `import Module.Type` — making it available by its short name; or, quoted, other `.play` files by path or glob — `import \"Orders/**/*.play\"`, relative to this file\\'s folder. Written inside a module or feature, a file import places the imported files there: their top level is that module\\'s or feature\\'s body. `import Module.Event from \"origin\"` is instead public contract metadata with an opaque origin; executable binding refuses it with PLAY0268.',\n concept: 'A formalized value type wrapping a primitive. Bare pii and secret markers travel with every usage, with optional concept notes and qualifiers.',\n type: 'A composite value type — a named shape built from several properties, referenced by events, commands and other types the same way a concept is.',\n reason: 'A free-text concept note, not a lawful basis. Written as pii reason \"...\" or secret reason \"...\"; migration preserves it verbatim.',\n optional: 'Allows a value to be absent. Write it after the type: `note String optional` or `lines InvoiceLine[] optional`. The collection itself may be absent; its items keep their declared type.',\n identifier: 'Marks the command property a runtime resolves the event source id from. At most one per command; without it a new Uuid is generated.',\n policy: 'A named authorization rule referenced by commands and queries. Multiple policies AND together.',\n purpose: 'A report-only processing declaration (GDPR Art. 30), referenced on modules, features and slices. Coverage is their union, not an authorization gate. Generated declarations are not legal advice.',\n basis: 'One declared Art. 6(1) basis: consent, contract, legalObligation, vitalInterests, publicTask or legitimateInterests; an optional quoted reference may follow.',\n interest: 'The legitimate-interest statement for basis legitimateInterests (Art. 13(1)(d)).',\n condition: 'One Art. 9(2) processing condition, optionally followed by a quoted reference.',\n subjects: 'Comma-separated categories of data subjects, as open identifiers.',\n retention: 'Declared retention period or criteria, not enforced by the model or Chronicle.',\n recipient: 'A quoted recipient category; repeatable on a purpose.',\n transfer: 'A declared destination followed by safeguard and quoted safeguards; repeatable.',\n safeguard: 'The declared safeguard accompanying a third-country transfer.',\n erasure: 'An erasure exception under Art. 17(3); Chronicle crypto-shredding remains per subject, not per purpose.',\n exception: 'One declared Art. 17(3) exception: expression, legalObligation, publicTask, publicHealth, archiving or legalClaims.',\n persona: 'A named role interacting with the application, with an optional description and its associated policies.',\n identity: 'Declares typed additional caller details from a claim, a keyed single-result query, inline code or a file. Authoring metadata only; executable use of `$identity.<detail>` reports PLAY0268 until admitted (#600).',\n authentication: 'Declares the identity providers of the application — at most one block per file.',\n provider: 'A named identity provider within `authentication`, with free-form `name value` settings.',\n description: 'A human-readable description, including the rule or case a specification witnesses, as a quoted single line or a fenced ```text block for multiple lines.',\n depends: 'Declares `depends on <Name>` on a module or feature. This opts only that container into checking counted explicit references against its own declarations; it does not change executable bytes.',\n module: 'The top-level namespace — maps to a bounded context.',\n layout: 'A reusable screen template with named slots.',\n template: 'Names a template to fill or assign: `template <Name>` for an own template, `template blueprint <Blueprint> <Name> [version \"<range>\"]` for a template a blueprint package ships.',\n blueprint: 'In `template blueprint <Blueprint> <Name>`, the blueprint package the template comes from. A `ui profile` should list it under `packages`. In `ui profile` `sample data`, `active blueprint <id>` selects a sample data pack a blueprint ships, resolved by the build against its packages.',\n version: 'In `template blueprint ... version \"<range>\"`, the semver range of the blueprint the reference accepts, such as `^1.4`.',\n scopes: 'Where a template may be used: `application`, `module`, `feature`, `subfeature` or `slice`. `slice` can be followed by the kinds `statechange` and `stateview`, such as `scopes slice statechange|stateview`.',\n category: 'The group a template picker lists a layout or template under. Every layout and template needs one.',\n feature: 'A vertical slice grouping. Features nest arbitrarily deep.',\n slice: 'The atomic unit of behavior, aligned with Event Modeling. Has a type and a name.',\n public: 'Marks an event as a public contract. An event with from \"origin\" is also public. Origin is opaque, not a path or declaration reference. Public events and origins are admitted by executable semantic model (ESM) v9.',\n direction: 'Declare direction inbound or direction outbound once inside a Translate slice. Admitted by executable semantic model (ESM) v9; a Translate slice that uses public events must declare it (PLAY0614).',\n inbound: 'Inbound Translate direction metadata. No transport or delivery guarantee is implied.',\n outbound: 'Outbound Translate direction metadata. No transport or delivery guarantee is implied.',\n event: 'An immutable, past-tense fact. Declare it in a slice or inline with `produces event <Name>` in a command. Inline properties are typed mappings; inline tags belong to the event type.',\n documentation: 'Authoring-only reasoning on a module, feature, slice, command, event, read model or reaction in one nonempty fenced ```markdown block. It does not change executable model bytes.',\n id: 'Preserves the previous persisted event name after a rename. Leave absent on new events; repeating the current name is redundant.',\n command: 'An imperative intent. Declares authorization, validation, and what events it produces — declaratively, or via a full handler.',\n query: 'A read-side entry point mapping to a return type, with an optional description, parameters and performer. The by key and every supplied filter value satisfy their concept rules after authorization; violations reject with Validation, not an empty result.',\n observable: 'Qualifies a query return type as a live read — `query <Name> => observable <ReadModel>` keeps pushing as the read model changes, instead of answering once.',\n performer: 'The code that performs a query — a `file <Path>` reference or an inline `csharp`/`sql` block. The query\\'s counterpart to a command handler.',\n from: 'On a reaction or reducer, `from Source[.Stream]` observes only matching routed facts. It does not filter stream ids. Admitted by ESM v10. On a query parameter, fills it from the query context instead of the caller, as in `filter tenantId TenantId from $context.tenant`.',\n projection: 'Declares how events project into a read model, using the embedded Projection Declaration Language (PDL).',\n capture: 'Converts external data into events, using the embedded Change Data Capture Language (CDL).',\n protected: 'Application-root `command reads protected` admits eligible command reads (ESM v25). Required absence rejects with Validation before derive/provide and requirements; a matching intervening fact yields Conflict/DecisionStateChanged without facts. Without the preamble, legacy reads retain their existing refusals. Targets must separately admit the version.',\n batches: 'Application-root `reaction batches atomic` opts into ESM v22 atomic direct and refusal-branch batches. Invoked commands remain separate transactions.',\n atomic: 'All productions in one reaction trigger occurrence or selected refusal branch are adopted together or not at all. Absence retains legacy per-fact semantics.',\n reaction: 'Behavior that runs when something happens. Lives inside Automation slices. A trigger with no body states intent on its own — `file`/code is optional realization metadata.',\n runs: '`runs as system [role \"Role\" and role \"Role\"]` declares the identity for every returned or invoked command of a reaction, not imperative pipeline calls. Admitted by released ESM v10; claims are unknown for this identity. Clock and application triggers have no Stage realization yet.',\n trigger: 'Declares a kind of occurrence a reaction can respond to, and the values it hands the reaction. What makes one occur belongs to whoever provides it, never to the compiler.',\n where: 'Narrows which occurrences actually run the reaction.',\n contains: 'Ordinal UTF-16 text comparison: the value holds the literal operand anywhere. In validation, `not contains` negates it; absent optional values pass. An empty operand always occurs.',\n starts: 'Use `starts with \"text\"` for an ordinal UTF-16 literal prefix validation rule or condition.',\n ends: 'Use `ends with \"text\"` for an ordinal UTF-16 literal suffix validation rule. An absent optional value passes.',\n every: 'Runs a reaction on an interval — `every 15 minutes`, `every 1 day`.',\n refused: 'Ordered invocation refusal branch, executable from ESM v19: first match wins and stops remaining invocations of this trigger. Bare `on refused` covers validation and constraints, not authorization. Other reactions and cascades continue; contract errors, concurrency and Unsupported never match.',\n acknowledge: 'A refusal branch acknowledges alone without facts, or produces events instead. Executable from ESM v19; handling stops remaining invocations of this trigger.',\n validation: 'In `on refused by validation`, selects error-severity property, concept and require refusals. Executable from ESM v19.',\n authorization: 'In `on refused by authorization`, explicitly selects unauthorized results, never Unsupported. Executable from ESM v19; bare refusal excludes authorization.',\n redelivered: '`when redelivered <Event> to <Reaction>` selects exactly one effective given occurrence by optional for, stated values and stream or no stream, delivering that event again to one named reaction without appending it again. Executable from ESM v17.',\n invokes: 'A command a reaction hands on. A command is asked for, not produced — it may still be rejected.',\n screen: 'A UI declaration. Supports intent, structure, and layout-with-code levels, or a full file reference.',\n constraint: 'A server-side rule enforced in the Chronicle kernel before events are committed.',\n authorize: 'References the policies that must all pass for the construct to execute.',\n validate: 'Declarative validation rules, or `validate` followed by ```csharp for imperative rules — on commands and concepts.',\n checksum: 'String-concept validation: exact trailing luhn/mod11 digit or two mod97 digits over preceding ASCII digits. Also applies to supplied and stored values; generation does not silently add validation.',\n luhn: 'Luhn check digit, with standard parity from the right. Generation appends it; validate checksum luhn checks the arithmetic.',\n mod11: 'Check digit (11 - weighted sum modulo 11) modulo 11, weights 2..7 cycling from the right. Output 10 is excluded from generation support.',\n mod97: 'ISO 7064 MOD 97-10, two zero-padded trailing digits. Validation checks the exact computed suffix, not only congruence.',\n produces: 'References a declared event with `produces <Name>`, or declares one inline with `produces event <Name>`. An inline omitted `for` uses the command identifier only when all destinations are the same source; legacy plain omission allocates an identity.',\n reads: 'Declares a view consulted by a command or reaction trigger: `reads <View> [as <alias>] [by <value>]`. A reaction `by` names a value taken by its trigger; clock triggers cannot use `by`. A child by block supplies composite key parts by name, using part = source, but is refused for protected command reads (PLAY0781 ByParts). Repeated views require unique aliases. With `command reads protected`, command reads bind only over finite event-log projections keyed by event-source identity with removal handlers and required scalar non-generated input keys. Omitted `by` uses the command identifier. Single-level read/alias.property paths are admitted in validate require operands and produces mappings only. Reaction reads remain unadmitted.',\n as: 'Names an instance of a view in a command or reaction trigger reads declaration, for example `reads Account as source by sourceId`.',\n handler: 'A fully imperative command implementation — a `file <Path>` reference or an inline `csharp` block, instead of `produces`.',\n when: 'Guards a produced event or a capture append with a condition. In a labeled screen action, `when item.<field> == <literal> execute <Command>` selects the first matching command. Inside on click, double click or select, block-form `when <condition>` selects one whole action list at gesture time.',\n rule: 'Names a predicate. Bare, it states that a constraint exists without expressing what it computes — nothing resolves the name. Optionally followed by an indented `file <Path>` reference or inline `csharp` block giving it a body.',\n require: 'A policy condition: `authenticated`, `anonymous`, `role \"...\"`, or `claim \"...\" matches ...`. Unary `not` negates a condition or group; precedence is not, and, or.',\n authenticated: 'Requires an authenticated caller.',\n anonymous: 'Admits every caller, including one without an identity (ESM v31). Stands alone in `require` and is the whole authorization of what it gates; its specifications may omit `given caller`.',\n role: 'Requires the caller to have the given role.',\n claim: 'Requires a claim on the caller to match a subject or value.',\n subject: 'In policy `matches subject`, the identifier of the thing acted on, not the caller. The caller is `$context.causedBy.subject`.',\n data: 'Binds a read model to a screen through a query.',\n action: 'Makes a command available on a screen. `action \"Label\"` declares one button with ordered `when … execute` alternatives over the nearest data item or selected row. No subject hides it; commands still enforce authorization and validation.',\n otherwise: 'The final fallback of a guarded action: `otherwise hidden` or `otherwise execute <Command>`. In an item interaction, bare `otherwise` opens a fallback action list. No subject runs nothing, including fallback; authorization never falls through.',\n hidden: 'Hides a guarded action when no condition matches. Without a subject the action is always hidden, even with an execute fallback.',\n execute: 'Executes a command. A guarded screen action selects it by the first matching condition; explicit `with … from` bindings precede same-name item fields, its declared form and renderer input.',\n navigate: 'Navigates to a screen, optionally passing a parameter with `by`.',\n section: 'A named structural section of a screen.',\n table: 'A table widget over a read model or child collection.',\n summary: 'A summary widget showing labeled fields.',\n column: 'A table column bound to a property.',\n field: 'A summary field bound to a property.',\n title: 'The display title of a screen or section.',\n label: 'The display label of an action, column, or field.',\n unique: 'A uniqueness constraint — `unique <property> on <EventType>` or `unique event <EventType>`.',\n concurrency: 'The concurrency scope enforced when the command appends events — dimensions: `eventSource`, `sourceType`, `streamType`, `streamId`, `events`.',\n eventSource: 'Concurrency dimension — scope the check to the event source id of the command.',\n sourceType: 'Concurrency dimension — scope the check to an event source type.',\n streamType: 'Concurrency dimension — scope the check to an event stream type.',\n streamId: 'Concurrency dimension — scope the check to an event stream id.',\n tag: 'Attaches a tag to appended events — a static identifier or string, or a `$context.` expression resolved at append time.',\n seed: 'Declares events to seed into the event store per event source id — multiple blocks accumulate.',\n for: 'Names the event source of a production or seed group. Inside `produces event`, omission uses the command identifier unless another production targets a different source.',\n readmodel: 'Declares a read model — its name and properties — in a slice, or, in a specification, read model state: `given readmodel` establishes it, `then readmodel` asserts it, `then no readmodel <View> for <key>` asserts keyed absence.',\n reducer: 'Builds a read model from events with imperative code — `reducer <Name> => <ReadModel>` with an `on <EventType>` rule per event. Use it when a projection cannot express the transition.',\n specification: 'Given/when/then acceptance criteria for a slice: prior events and state, the command, query or appended event under test, and the events, state, results, errors or denials that follow.',\n dialog: 'A dialog opened over the shell, or with `dialog template` a reusable dialog shape.',\n form: 'A form bound to a command — `form <Name> for <Command>` with a `field` per input.',\n contribute: 'Contributes entries to a slot of the shell — `contribute to Navigation` with `navigate to`, `label` and `order`.',\n button: 'A toolbar button that invokes a State Change slice — `button <id> title \"…\" slice <Module>.<Feature>.<Slice> [emphasis primary|secondary|quiet] [icon <name>]`. The slice names the command and the dialog it opens.',\n navigation: 'A navigation region of the shell — `navigation topbar` or `navigation sidebar`. A layout declares the application\\'s regions with a `logo` and `item` lines; a module adds `inherits`, `extends` or `overrides` to change what it shows.',\n theme: 'A named theme and the component packages it is compatible with.',\n sample: 'Sample data — `sample data <Name>` declares a pack of demo rows per `shape` that a design surface or preview shows instead of a backend. Design and preview time only; it never reaches backend or production output. The application picks its active pack once, in the `ui profile`.',\n active: 'The active sample data pack of the whole application, chosen once in the `ui profile` `sample data` block — one declared in the document, or `blueprint <id>` for one a blueprint ships.',\n bind: 'Binds one read model to a sample data pack — `bind <ReadModel> to <pack>` — a rare override of the active pack for that read model only.',\n maps: 'Maps a sample data shape to the read model it supplies rows for — `shape <Shape> maps to <ReadModel>` — where the names differ.',\n row: 'One row of a sample data shape: `<field> = <literal>` lines, each field a property of the read model.',\n locale: 'The BCP 47 locale tag of a sample data pack, such as `nb-NO`.',\n shape: 'In sample data, the shape a set of rows is for; it matches the read model of the same name or the one a `ui profile` maps it to.',\n root: 'In a `ui profile`, `root template [blueprint <Blueprint>] <Name> [version \"<range>\"]` names the template the whole application is drawn in, with `option <name> <value>` lines for what the shell exposes.',\n appearance: 'In a `ui profile`, the `appearance` block holds `color scheme light|dark|system` and `accent \"<#hex>\"`.',\n accent: 'In a `ui profile` `appearance` block, `accent \"<#hex>\"` is the accent colour of the application.',\n scheme: 'In a `ui profile` `appearance` block, `color scheme light|dark|system` is the colour scheme of the application.',\n screens: 'In a `ui profile`, `new screens use template [blueprint <Blueprint>] <Name>` is the template a new screen starts from.',\n ui: 'A UI profile — `ui profile <Name>` binds a target platform and size to a layout, theme and packages.',\n behavior: 'A named interaction wiring of `on <interaction>` handlers, attached to a screen, form or dialog with `uses`.',\n system: 'An application-scoped external system that operations use.',\n eventsource: 'An application-owned event source with nested streams.',\n operation: 'A reusable operation intent that uses one external system.',\n no: 'A keyed absence assertion: `then no readmodel <View> for <key>`.',\n arguments: 'The values supplied to a query asserted by `then query`.',\n result: 'One expected result - `then result [exactly]` after `when query`, or a `result` block inside `then query`. Repeat it to assert several results in authored order.',\n clock: 'The instant a specification happens at - `given clock \"2026-10-05T08:00:00Z\"` fixes when everything occurs, including every generated pattern date segment at that same UTC instant. Without given clock, generation fixtures check date digit widths only, never the wall clock. `when clock \"<instant>\"` is the clock reaching it, as the action.',\n exactly: 'Requires every property to match, rather than only the ones asserted - on `then readmodel`, `then query` and `then result`.',\n file: 'Delegates the implementation to an external file; the Screenplay contract stays visible.',\n key: 'Trailing modifier on a required top-level read-model property. Explicit keys replace inference. Several scalar key properties identify one instance by named parts. Supply every part in a single-instance query by block and in projection key blocks; list queries can use equality filters.',\n stream: 'On a command event production, replaces the whole command route for that event. Other productions keep the command route. Admitted by ESM v10.',\n by: 'Introduces one identifying parameter or a block of at least two named key parts. Reads use part = source; queries use part Type.',\n via: 'Connects screen data to the query that supplies it.',\n filter: 'An optional query filter parameter.',\n on: 'The event a constraint applies to, the day a schedule narrows to, or a widget interaction such as `on row-click`.',\n message: 'The validation message reported when the rule fails.',\n matches: 'Searches text using the portable flagless JavaScript match dialect, or `email`. Use ^ and $ for the whole input. Exact Studio text-rule lookarounds warn with PLAY0787 and lower to ordinal rules; other lookarounds, backreferences and refused constructs report PLAY0699; patterns have at most 1000 source code units and 3000 expanded nodes, including optional, loop and alternative choice points.',\n all: 'Applies a comparison to every element of a collection.',\n max: 'Maximum length or value.',\n min: 'Minimum length or value.',\n length: 'Constrains the exact length of a value.',\n today: 'The current date.',\n empty: 'Used with `not empty` — text needs a non-whitespace character; null, empty and whitespace-only text fail. Unicode White_Space is U+0009–U+000D, U+0020, U+0085, U+00A0, U+1680, U+2000–U+200A, U+2028, U+2029, U+202F, U+205F and U+3000 (not U+FEFF). Collections need at least one element. Applies to concept and command rules in every ESM version; no trimming. Identity text is unchanged: whitespace is a value.',\n not: 'Negates a validation condition, as in `not empty`.',\n and: 'Both conditions must hold.',\n or: 'Either condition may hold.',\n csharp: 'An inline C# block whose opening fence is ```csharp.',\n sql: 'An inline SQL block between triple backticks — a query performer written against a relational store.',\n typescript: 'An inline TypeScript block between triple backticks.',\n react: 'An inline React/TSX block; receives the surrounding data contract as `Props`.',\n html: 'An inline static HTML block.',\n StateChange: 'Slice type — a command → events flow; something that changes the system.',\n StateView: 'Slice type — a query + projection + screen; something that reads the system.',\n Automation: 'Slice type — a reaction or reducer; something that runs when something happens.',\n Translate: 'Slice type — a capture; converts external data into events.',\n Uuid: 'Primitive type — a universally unique identifier. ESM v28 admits == and != between Uuid values (or concepts over Uuid) in command require and produces when; two concepts must be the same concept, and a literal must be canonical lowercase hyphenated. Ordering, optional operands, validation rules, concept rules and reaction where stay refused.',\n String: 'Primitive type — a string of characters.',\n Int: 'Primitive type — an integer number.',\n Decimal: 'Primitive type — a decimal number.',\n Bool: 'Primitive type — true or false.',\n Date: 'Primitive type — a calendar date without a time zone. ESM v26 admits all six comparisons in command require, produces when and command/property rules. Conditions use required same-primitive command properties or a literal; rules use literals only. Canonical literals use yyyy-MM-dd. Concept rules, reaction where, read paths, context and today stay refused.',\n DateTime: 'Primitive type — a date and time. ESM v26 command comparisons order UTC instants at tick precision, including equality across offsets. Compared input requires an explicit offset or Z before any rule runs; literals canonicalize to UTC with seven fractional digits and Z. Targets without tick precision refuse comparisons; client validators omit date ordering. Other equality stays ordinal.',\n Enum: 'An enumeration concept with named members. Members may all declare unique int32 numbers (draft = 1) or all omit them (zero-based positions). Never renumber or reuse a published number. Non-positional numbers select executable model (ESM) v12; consumers must explicitly admit v12. Specifications still name members.',\n};\n\n// What the words of a specification's steps mean there - where 'trigger', 'capture' and 'query' name what the\n// scenario exercises rather than declare one.\nexport const specificationKeywordDocs: Record<string, string> = {\n parameter: 'Declares a required typed case value: `parameter <name> <Type>`. Every case assigns it once. `optional` permits literal null but supplies no default.',\n case: 'One named complete row of a specification table. `case.<parameter>` substitutes a whole value after example overrides; each row runs as `<Specification>_<Case>`.',\n caller: '`given caller` states an explicit identity; `given caller as <Persona>` synthesizes an authenticated deterministic witness of the persona, with no body. Leftmost buildable policy alternatives are significant.',\n clock: keywordDocs.clock,\n redelivered: keywordDocs.redelivered,\n trigger: '`when trigger <Trigger>` - an application trigger fires, as the action, with the values on the lines beneath it.',\n capture: '`given capture <Capture>` - a record the capture\\'s source held before; `when capture <Capture>` - the record it sees now, as the action. The fields go on the lines beneath.',\n query: '`when query <Query>` performs the query with arguments beneath it; assert returned rows with `then result` or genuine absence with `then no result`. From ESM v18, one actionless query with `then error` asserts exactly Validation and no other outcome. This also works with `then query` and an arguments block, without a result block.',\n events: '`then no events` - asserts the action appended no events, also after `when append`, where it means no reaction appended anything. Executable from ESM v17. Cannot accompany event, event-order, error or denial expectations.',\n result: '`then result [exactly]` - one result the query performed by `when query` returns, in order; `then no result` - it returns nothing.',\n};\n\nexport const attributeDocs: Record<string, string> = {\n pii: 'personal data (GDPR Art. 4(1)); renders Chronicle [PII]. Bare suffix marker; @pii is deprecated (PLAY0565). Selects executable model (ESM) v13; consumers must explicitly admit it. Cannot classify identity or enum concepts. An event with personal values and an explicit subject mark refuses binding (PLAY0268) until lineage is admitted.',\n personal: 'Alias of pii: personal data (GDPR Art. 4(1)); renders Chronicle [PII]. No diagnostic; canonical printing writes pii. Selects executable model (ESM) v13, like pii.',\n secret: 'Operational secret, not personal data: encrypted at rest without erasure and withheld from causation. Provider mapping: [Encrypted] + [NotAudited], or [PII] only with pii. Selects executable model (ESM) v13; reference outcomes are unchanged. Cannot classify identity (PLAY0515) or enum concepts. Explicit scope is omitted next to pii. An event combining secret scope subject with an explicit subject mark refuses binding (PLAY0268).',\n sensitive: 'Deprecated spelling of secret (PLAY0565); repair to bare secret. Operational secret, not GDPR Art. 9 special-category data.',\n};\n\nexport const contextVariableDocs: Record<string, string> = {\n '$context.occurred': 'When the command or query was received.',\n '$context.tenant': 'The tenant the command or query is executing for.',\n '$context.command': 'The command being handled, shaped by its `command` declaration.',\n '$context.arguments': 'The arguments of the query being performed.',\n '$context.causedBy': 'The identity that caused the command or query — `subject`, `name`, `userName`.',\n '$context.causedBy.subject': 'The subject of the identity that caused the command or query.',\n '$context.causedBy.name': 'The display name of the identity that caused the command or query.',\n '$context.causedBy.userName': 'The user name of the identity that caused the command or query.',\n '$context.causation': 'What caused the command or query — `type`, `occurred`, `properties`.',\n '$context.causation.type': 'What caused the command or query — a command, a reactor, a schedule.',\n '$identity': 'The caller — token built-ins `id`, `name`, `userName`, `isAuthenticated`, `roles`, `claims`, plus declared identity details. Built-ins are equivalent to `$context.identity`; details are authoring-only until admitted (#600).',\n '$identity.id': 'The identifier of the caller from the auth token; equivalent to `$context.identity.id`.',\n '$identity.name': 'The display name of the caller; equivalent to `$context.identity.name`.',\n '$identity.userName': 'The user name of the caller; equivalent to `$context.identity.userName`.',\n '$identity.isAuthenticated': 'Whether the caller is authenticated.',\n '$identity.roles': 'The roles the caller holds.',\n '$identity.claims': 'The claims the caller carries — `$identity.claims.<name>` reads one.',\n '$context.identity': 'The caller a decision is made about — `id`, `name`, `userName`, `isAuthenticated`, `roles`, `claims`.',\n '$context.identity.id': 'The identifier of the caller from the auth token.',\n '$context.identity.name': 'The display name of the caller.',\n '$context.identity.userName': 'The user name of the caller.',\n '$context.identity.isAuthenticated': 'Whether the caller is authenticated.',\n '$context.identity.roles': 'The roles the caller holds.',\n '$context.identity.claims': 'The claims the caller carries — `$context.identity.claims.<name>` reads one.',\n '$env': 'An environment variable, e.g. `$env.SERVICE_NAME`.',\n '$secrets': 'An encrypted secret resolved at runtime, e.g. `$secrets.azureAdClientId` — stays symbolic in the compiled tree.',\n '$strings': 'A localized string resolved from the `.strings` file of the active locale, e.g. `$strings.invoices.title`.',\n // Every $eventContext path the event-context catalog lists, for projections.\n ...Object.fromEntries(eventContextPaths.map((path) => [`$eventContext.${path.path}`, path.description])),\n};\n\n// One-sentence descriptions of the `pii special` categories (GDPR Art. 9(1)) and `pii criminal` (Art. 10).\n// The same sentences appear in Documentation/screenplay/concepts.md.\nexport const specialCategoryDocs: Record<string, string> = {\n racialOrEthnicOrigin: 'Data revealing a person\\'s racial or ethnic origin (GDPR Art. 9(1)).',\n politicalOpinions: 'Data revealing a person\\'s political opinions (GDPR Art. 9(1)).',\n religiousOrPhilosophicalBeliefs: 'Data revealing a person\\'s religious or philosophical beliefs (GDPR Art. 9(1)).',\n tradeUnionMembership: 'Data revealing whether a person belongs to a trade union (GDPR Art. 9(1)).',\n genetic: 'Data about inherited or acquired genetic characteristics that gives unique information about a person\\'s physiology or health (GDPR Art. 9(1), Art. 4(13)).',\n biometric: 'Data from technical processing of physical, physiological or behavioral characteristics, special only when processed to uniquely identify a person (GDPR Art. 9(1), Art. 4(14)).',\n health: 'Data about a person\\'s physical or mental health, including health care services, that reveals their health status (GDPR Art. 9(1), Art. 4(15)).',\n sexLifeOrSexualOrientation: 'Data concerning a person\\'s sex life or sexual orientation (GDPR Art. 9(1)).'\n};\n"],"mappings":"2IAMA,MAAaA,EAAoB,CAC7B,eAAgB,qKAChB,KAAM,qHACV,EAEaC,EAAsC,CAC/C,UAAW,kKACX,KAAM,oIACN,QAAS,gTACT,OAAQ,2FACR,OAAQ,ggBACR,QAAS,iJACT,KAAM,kJACN,OAAQ,qIACR,SAAU,2LACV,WAAY,uIACZ,OAAQ,iGACR,QAAS,oMACT,MAAO,gKACP,SAAU,mFACV,UAAW,iFACX,SAAU,oEACV,UAAW,iFACX,UAAW,wDACX,SAAU,kFACV,UAAW,gEACX,QAAS,0GACT,UAAW,sHACX,QAAS,2GACT,SAAU,qNACV,eAAgB,mFAChB,SAAU,2FACV,YAAa,4JACb,QAAS,kMACT,OAAQ,uDACR,OAAQ,+CACR,SAAU,mLACV,UAAW,8RACX,QAAS,0HACT,OAAQ,+MACR,SAAU,qGACV,QAAS,6DACT,MAAO,mFACP,OAAQ,wNACR,UAAW,uMACX,QAAS,uFACT,SAAU,wFACV,MAAO,wLACP,cAAe,oLACf,GAAI,mIACJ,QAAS,gI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iFACjC,qBAAsB,6EACtB,QAAS,6JACT,UAAW,mLACX,OAAQ,kJACR,2BAA4B,6EAChC"}
@@ -1,2 +1,2 @@
1
- const e=`screenplay`,t={id:e,extensions:[`.play`],aliases:[`Screenplay`,`screenplay`,`play`],mimetypes:[`text/x-screenplay`]},n=/* @__PURE__ */ `domain.import.concept.type.policy.purpose.persona.authentication.identity.module.layout.theme.ui.sample.feature.slice.event.public.system.eventsource.operation.command.query.projection.capture.reaction.runs.reducer.readmodel.trigger.screen.dialog.form.contribute.navigation.constraint.specification.case.parameter.example.seed.behavior.exposure.instance`.split(`.`),r=/* @__PURE__ */ `protected.batches.atomic.depends.direction.inbound.outbound.description.documentation.template.profile.require.authenticated.role.claim.subject.authorize.validate.produces.reads.as.handler.performer.observable.identifier.reason.from.when.given.then.arguments.result.clock.exactly.error.message.not.empty.rule.matches.all.max.min.length.today.true.false.and.or.by.filter.data.via.component.context.property.literal.icons.packages.active.bind.maps.row.locale.shape.outlet.display.scopes.blueprint.version.statechange.stateview.reexposes.operations.items.toolbar.button.emphasis.primary.secondary.quiet.item.topbar.sidebar.inherits.extends.overrides.logo.image.icon.target.slot.presentation.exposes.mode.oneWay.twoWay.null.propagate.clear.preserve.expected.action.navigate.to.label.section.table.summary.title.column.field.on.unique.file.concurrency.eventSource.sourceType.streamType.streamId.tag.for.readmodel.no.when.every.at.where.invokes.contains.starts.ends.with.provider.uses.parameter.order.open.close.refresh.set.notify.confirm.raise.interval.success.failure.click.double.select.submit.change.load.unload.enter.leave.info.warning`.split(`.`),i=[`csharp`,`typescript`,`react`,`html`,`sql`],a=[`command`,`arguments`,`tenant`,`causedBy`,`causation`,`occurred`,`identity`],o=[`subject`,`name`,`userName`],s=[`id`,`name`,`userName`,`isAuthenticated`,`roles`,`claims`],c=[`StateChange`,`StateView`,`Automation`,`Translate`],l=[`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`],u=[`pii`,`personal`,`secret`],d=/^\s*(?:module|feature|slice\s+\w+|type|command(?!\s+reads\s+protected\b)|event|readmodel|reducer|projection|capture|reaction(?!\s+batches\b)|screen|dialog|form|contribute|specification|case|constraint|persona|policy|behavior|layout|theme|ui\s+profile|trigger|authentication|identity|seed|system|eventsource|operation|screen\s+template|dialog\s+template|produces\s+event|generate\s+rule|validate|handler|on)\b[^=]*$/,f={comments:{lineComment:`//`},brackets:[[`(`,`)`],[`[`,`]`]],autoClosingPairs:[{open:`(`,close:`)`},{open:`[`,close:`]`},{open:`"`,close:`"`}],surroundingPairs:[{open:`(`,close:`)`},{open:`[`,close:`]`},{open:`"`,close:`"`}],folding:{offSide:!0},onEnterRules:[{beforeText:d,action:{indentAction:1}}],indentationRules:{increaseIndentPattern:/^\s*(module|feature|slice|policy|persona|authentication|identity|provider|event|command(?!\s+reads\s+protected\b)|query|type|screen|projection|capture|reaction(?!\s+batches\b)|trigger|constraint|specification|layout|template|generate\s+rule|validate|produces|handler|implementation(?=\s*$)|performer|rule|section|action|otherwise(?=\s*$|\s+execute\b)|concurrency|seed|for|when|then|arguments|result|every|at|invokes|on)\b.*$/,decreaseIndentPattern:/(?!)/}};export{d as blockHeaderPattern,o as causedByProperties,r as clauseKeywords,i as codeBlockTags,u as conceptAttributes,n as constructKeywords,a as contextRoots,s as identityProperties,f as languageConfiguration,t as languageExtensionPoint,e as languageId,l as primitiveTypes,c as sliceTypes};
1
+ const e=`screenplay`,t={id:e,extensions:[`.play`],aliases:[`Screenplay`,`screenplay`,`play`],mimetypes:[`text/x-screenplay`]},n=/* @__PURE__ */ `domain.import.concept.type.policy.purpose.persona.authentication.identity.module.layout.theme.ui.sample.feature.slice.event.public.system.eventsource.operation.command.query.projection.capture.reaction.runs.reducer.readmodel.trigger.screen.dialog.form.contribute.navigation.constraint.specification.case.parameter.example.seed.behavior.exposure.instance`.split(`.`),r=/* @__PURE__ */ `protected.batches.atomic.depends.direction.inbound.outbound.description.documentation.template.profile.require.authenticated.anonymous.role.claim.subject.authorize.validate.produces.reads.as.handler.performer.observable.identifier.reason.from.when.given.then.arguments.result.clock.exactly.error.message.not.empty.rule.matches.all.max.min.length.today.true.false.and.or.by.filter.data.via.component.context.property.literal.icons.packages.active.bind.maps.row.locale.shape.outlet.display.scopes.blueprint.version.statechange.stateview.reexposes.operations.items.toolbar.button.emphasis.primary.secondary.quiet.item.topbar.sidebar.inherits.extends.overrides.logo.image.icon.target.slot.presentation.exposes.mode.oneWay.twoWay.null.propagate.clear.preserve.expected.action.navigate.to.label.section.table.summary.title.column.field.on.unique.file.concurrency.eventSource.sourceType.streamType.streamId.tag.for.readmodel.no.when.every.at.where.invokes.contains.starts.ends.with.provider.uses.parameter.order.open.close.refresh.set.notify.confirm.raise.interval.success.failure.click.double.select.submit.change.load.unload.enter.leave.info.warning`.split(`.`),i=[`csharp`,`typescript`,`react`,`html`,`sql`],a=[`command`,`arguments`,`tenant`,`causedBy`,`causation`,`occurred`,`identity`],o=[`subject`,`name`,`userName`],s=[`id`,`name`,`userName`,`isAuthenticated`,`roles`,`claims`],c=[`StateChange`,`StateView`,`Automation`,`Translate`],l=[`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`],u=[`pii`,`personal`,`secret`],d=/^\s*(?:module|feature|slice\s+\w+|type|command(?!\s+reads\s+protected\b)|event|readmodel|reducer|projection|capture|reaction(?!\s+batches\b)|screen|dialog|form|contribute|specification|case|constraint|persona|policy|behavior|layout|theme|ui\s+profile|trigger|authentication|identity|seed|system|eventsource|operation|screen\s+template|dialog\s+template|produces\s+event|generate\s+rule|validate|handler|on)\b[^=]*$/,f={comments:{lineComment:`//`},brackets:[[`(`,`)`],[`[`,`]`]],autoClosingPairs:[{open:`(`,close:`)`},{open:`[`,close:`]`},{open:`"`,close:`"`}],surroundingPairs:[{open:`(`,close:`)`},{open:`[`,close:`]`},{open:`"`,close:`"`}],folding:{offSide:!0},onEnterRules:[{beforeText:d,action:{indentAction:1}}],indentationRules:{increaseIndentPattern:/^\s*(module|feature|slice|policy|persona|authentication|identity|provider|event|command(?!\s+reads\s+protected\b)|query|type|screen|projection|capture|reaction(?!\s+batches\b)|trigger|constraint|specification|layout|template|generate\s+rule|validate|produces|handler|implementation(?=\s*$)|performer|rule|section|action|otherwise(?=\s*$|\s+execute\b)|concurrency|seed|for|when|then|arguments|result|every|at|invokes|on)\b.*$/,decreaseIndentPattern:/(?!)/}};export{d as blockHeaderPattern,o as causedByProperties,r as clauseKeywords,i as codeBlockTags,u as conceptAttributes,n as constructKeywords,a as contextRoots,s as identityProperties,f as languageConfiguration,t as languageExtensionPoint,e as languageId,l as primitiveTypes,c as sliceTypes};
2
2
  //# sourceMappingURL=language.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"language.js","names":["languageId","languageExtensionPoint","constructKeywords","clauseKeywords","codeBlockTags","contextRoots","causedByProperties","identityProperties","sliceTypes","primitiveTypes","conceptAttributes","blockHeaderPattern","languageConfiguration"],"sources":["../../language.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 type { languages } from 'monaco-editor';\n\nexport type Monaco = typeof import('monaco-editor');\n\nexport const languageId = 'screenplay';\n\nexport const languageExtensionPoint: languages.ILanguageExtensionPoint = {\n id: languageId,\n extensions: ['.play'],\n aliases: ['Screenplay', 'screenplay', 'play'],\n mimetypes: ['text/x-screenplay'],\n};\n\n// Every word the parser dispatches on at the top level, inside a module, or inside a slice.\n// `for_LanguageService.when_comparing_keywords_against_the_parsers` derives that set from\n// ScreenplayParser and SliceParser and fails when this list has drifted from it, so a construct\n// added to the compiler cannot silently lose its highlighting and completion.\nexport const constructKeywords = [\n 'domain',\n 'import',\n 'concept',\n 'type',\n 'policy',\n 'purpose',\n 'persona',\n 'authentication',\n 'identity',\n 'module',\n 'layout',\n 'theme',\n 'ui',\n 'sample',\n 'feature',\n 'slice',\n 'event',\n 'public',\n 'system',\n 'eventsource',\n 'operation',\n 'command',\n 'query',\n 'projection',\n 'capture',\n 'reaction',\n 'runs',\n 'reducer',\n 'readmodel',\n 'trigger',\n 'screen',\n 'dialog',\n 'form',\n 'contribute',\n 'navigation',\n 'constraint',\n 'specification',\n 'case',\n 'parameter',\n 'example',\n 'seed',\n 'behavior',\n 'exposure',\n 'instance',\n];\n\n// Type modifiers are contextual, never excluded from property or declaration names.\nexport const typeModifierKeywords = ['optional'];\n\nexport const clauseKeywords = [\n 'protected',\n 'batches',\n 'atomic',\n 'depends',\n 'direction',\n 'inbound',\n 'outbound',\n 'description',\n 'documentation',\n 'template',\n 'profile',\n 'require',\n 'authenticated',\n 'role',\n 'claim',\n 'subject',\n 'authorize',\n 'validate',\n 'produces',\n 'reads', // A clause in command bodies and reaction trigger bodies; @reads remains a value.\n 'as',\n 'handler',\n 'performer',\n 'observable',\n 'identifier',\n 'reason',\n 'from',\n 'when',\n 'given',\n 'then',\n 'arguments',\n 'result',\n 'clock', // A specification step - 'given clock' and 'when clock' state an instant.\n 'exactly',\n 'error',\n 'message',\n 'not', // Unary policy negation, as well as 'not empty' validation.\n 'empty',\n 'rule',\n 'matches',\n 'all',\n 'max',\n 'min',\n 'length',\n 'today',\n 'true',\n 'false',\n 'and',\n 'or',\n 'by',\n 'filter',\n 'data',\n 'via',\n 'component',\n 'context',\n 'property',\n 'literal',\n 'icons',\n 'packages',\n 'active',\n 'bind',\n 'maps',\n 'row',\n 'locale',\n 'shape',\n 'outlet',\n 'display',\n 'scopes',\n 'blueprint', // 'template blueprint <Blueprint> <Name> [version \"<range>\"]' names a template a blueprint package ships.\n 'version',\n 'statechange', // Slice kinds a template's 'scopes slice ...' narrows to.\n 'stateview',\n 'reexposes',\n 'operations',\n 'items',\n 'toolbar',\n 'button',\n 'emphasis',\n 'primary',\n 'secondary',\n 'quiet',\n 'item',\n 'topbar',\n 'sidebar',\n 'inherits',\n 'extends',\n 'overrides',\n 'logo',\n 'image',\n 'icon',\n 'target',\n 'slot',\n 'presentation',\n 'exposes',\n 'mode',\n 'oneWay',\n 'twoWay',\n 'null',\n 'propagate',\n 'clear',\n 'preserve',\n 'expected',\n 'action',\n 'navigate',\n 'to',\n 'label',\n 'section',\n 'table',\n 'summary',\n 'title',\n 'column',\n 'field',\n 'on',\n 'unique',\n 'file',\n 'concurrency',\n 'eventSource',\n 'sourceType',\n 'streamType',\n 'streamId',\n 'tag',\n 'for',\n 'readmodel',\n 'no',\n 'when',\n 'every',\n 'at',\n 'where',\n 'invokes',\n 'contains',\n 'starts',\n 'ends',\n 'with',\n 'provider',\n // Interaction: the words a behavior body uses. The built-in interaction kinds ('click', 'submit', and\n // friends) are only reserved inside an `on` clause, so they are clause words rather than constructs -\n // an identifier of the same name elsewhere in a document remains an identifier.\n 'uses',\n 'parameter',\n 'order',\n 'open',\n 'close',\n 'refresh',\n 'set',\n 'notify',\n 'confirm',\n 'raise',\n 'interval',\n 'success',\n 'failure',\n 'click',\n 'double',\n 'select',\n 'submit',\n 'change',\n 'load',\n 'unload',\n 'enter',\n 'leave',\n 'info',\n 'warning',\n];\n\nexport const codeBlockTags = ['csharp', 'typescript', 'react', 'html', 'sql'];\n\n// The roots a `$context.` path can start with — the members of CommandContext and QueryContext.\nexport const contextRoots = [\n 'command',\n 'arguments',\n 'tenant',\n 'causedBy',\n 'causation',\n 'occurred',\n 'identity',\n];\n\nexport const causedByProperties = ['subject', 'name', 'userName'];\n\n// The properties a `$identity.` or `$context.identity.` path can name — the members of Identity. Everything after\n// `claims.` is the name of a claim rather than a member, so it is never checked.\nexport const identityProperties = ['id', 'name', 'userName', 'isAuthenticated', 'roles', 'claims'];\n\nexport const sliceTypes = ['StateChange', 'StateView', 'Automation', 'Translate'];\n\nexport const primitiveTypes = ['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime'];\n\nexport const conceptAttributes = ['pii', 'personal', 'secret'];\n\n// The lines that open a block with a body of their own. A line that is complete as written - a `domain`, a\n// `concept` or `query` with nothing under it, a `produces` of an existing event - is not one.\nexport const blockHeaderPattern = /^\\s*(?:module|feature|slice\\s+\\w+|type|command(?!\\s+reads\\s+protected\\b)|event|readmodel|reducer|projection|capture|reaction(?!\\s+batches\\b)|screen|dialog|form|contribute|specification|case|constraint|persona|policy|behavior|layout|theme|ui\\s+profile|trigger|authentication|identity|seed|system|eventsource|operation|screen\\s+template|dialog\\s+template|produces\\s+event|generate\\s+rule|validate|handler|on)\\b[^=]*$/;\n\nexport const languageConfiguration: languages.LanguageConfiguration = {\n comments: {\n lineComment: '//',\n },\n brackets: [\n ['(', ')'],\n ['[', ']'],\n ],\n autoClosingPairs: [\n { open: '(', close: ')' },\n { open: '[', close: ']' },\n { open: '\"', close: '\"' },\n ],\n surroundingPairs: [\n { open: '(', close: ')' },\n { open: '[', close: ']' },\n { open: '\"', close: '\"' },\n ],\n folding: {\n offSide: true,\n },\n // A header that opens a block puts the cursor one level in on Enter, so what is typed - or suggested - starts at\n // the block's own indentation. IndentAction.Indent is 1.\n onEnterRules: [\n { beforeText: blockHeaderPattern, action: { indentAction: 1 as languages.IndentAction } },\n ],\n indentationRules: {\n increaseIndentPattern:\n /^\\s*(module|feature|slice|policy|persona|authentication|identity|provider|event|command(?!\\s+reads\\s+protected\\b)|query|type|screen|projection|capture|reaction(?!\\s+batches\\b)|trigger|constraint|specification|layout|template|generate\\s+rule|validate|produces|handler|implementation(?=\\s*$)|performer|rule|section|action|otherwise(?=\\s*$|\\s+execute\\b)|concurrency|seed|for|when|then|arguments|result|every|at|invokes|on)\\b.*$/,\n // Dedents are always explicit in an offside language — never auto-dedent.\n decreaseIndentPattern: /(?!)/,\n },\n};\n"],"mappings":"AAOA,MAAaA,EAAa,aAEbC,EAA4D,CACrE,GAAID,EACJ,WAAY,CAAC,OAAO,EACpB,QAAS,CAAC,aAAc,aAAc,MAAM,EAC5C,UAAW,CAAC,mBAAmB,CACnC,EAMaE,EAAoB,6XA6CjC,EAKaC,EAAiB,0oCAkK9B,EAEaC,EAAgB,CAAC,SAAU,aAAc,QAAS,OAAQ,KAAK,EAG/DC,EAAe,CACxB,UACA,YACA,SACA,WACA,YACA,WACA,UACJ,EAEaC,EAAqB,CAAC,UAAW,OAAQ,UAAU,EAInDC,EAAqB,CAAC,KAAM,OAAQ,WAAY,kBAAmB,QAAS,QAAQ,EAEpFC,EAAa,CAAC,cAAe,YAAa,aAAc,WAAW,EAEnEC,EAAiB,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,UAAU,EAEhFC,EAAoB,CAAC,MAAO,WAAY,QAAQ,EAIhDC,EAAqB,iaAErBC,EAAyD,CAClE,SAAU,CACN,YAAa,IACjB,EACA,SAAU,CACN,CAAC,IAAK,GAAG,EACT,CAAC,IAAK,GAAG,CACb,EACA,iBAAkB,CACd,CAAE,KAAM,IAAK,MAAO,GAAI,EACxB,CAAE,KAAM,IAAK,MAAO,GAAI,EACxB,CAAE,KAAM,IAAK,MAAO,GAAI,CAC5B,EACA,iBAAkB,CACd,CAAE,KAAM,IAAK,MAAO,GAAI,EACxB,CAAE,KAAM,IAAK,MAAO,GAAI,EACxB,CAAE,KAAM,IAAK,MAAO,GAAI,CAC5B,EACA,QAAS,CACL,QAAS,EACb,EAGA,aAAc,CACV,CAAE,WAAYD,EAAoB,OAAQ,CAAE,aAAc,CAA4B,CAAE,CAC5F,EACA,iBAAkB,CACd,sBACI,2aAEJ,sBAAuB,MAC3B,CACJ"}
1
+ {"version":3,"file":"language.js","names":["languageId","languageExtensionPoint","constructKeywords","clauseKeywords","codeBlockTags","contextRoots","causedByProperties","identityProperties","sliceTypes","primitiveTypes","conceptAttributes","blockHeaderPattern","languageConfiguration"],"sources":["../../language.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 type { languages } from 'monaco-editor';\n\nexport type Monaco = typeof import('monaco-editor');\n\nexport const languageId = 'screenplay';\n\nexport const languageExtensionPoint: languages.ILanguageExtensionPoint = {\n id: languageId,\n extensions: ['.play'],\n aliases: ['Screenplay', 'screenplay', 'play'],\n mimetypes: ['text/x-screenplay'],\n};\n\n// Every word the parser dispatches on at the top level, inside a module, or inside a slice.\n// `for_LanguageService.when_comparing_keywords_against_the_parsers` derives that set from\n// ScreenplayParser and SliceParser and fails when this list has drifted from it, so a construct\n// added to the compiler cannot silently lose its highlighting and completion.\nexport const constructKeywords = [\n 'domain',\n 'import',\n 'concept',\n 'type',\n 'policy',\n 'purpose',\n 'persona',\n 'authentication',\n 'identity',\n 'module',\n 'layout',\n 'theme',\n 'ui',\n 'sample',\n 'feature',\n 'slice',\n 'event',\n 'public',\n 'system',\n 'eventsource',\n 'operation',\n 'command',\n 'query',\n 'projection',\n 'capture',\n 'reaction',\n 'runs',\n 'reducer',\n 'readmodel',\n 'trigger',\n 'screen',\n 'dialog',\n 'form',\n 'contribute',\n 'navigation',\n 'constraint',\n 'specification',\n 'case',\n 'parameter',\n 'example',\n 'seed',\n 'behavior',\n 'exposure',\n 'instance',\n];\n\n// Type modifiers are contextual, never excluded from property or declaration names.\nexport const typeModifierKeywords = ['optional'];\n\nexport const clauseKeywords = [\n 'protected',\n 'batches',\n 'atomic',\n 'depends',\n 'direction',\n 'inbound',\n 'outbound',\n 'description',\n 'documentation',\n 'template',\n 'profile',\n 'require',\n 'authenticated',\n 'anonymous',\n 'role',\n 'claim',\n 'subject',\n 'authorize',\n 'validate',\n 'produces',\n 'reads', // A clause in command bodies and reaction trigger bodies; @reads remains a value.\n 'as',\n 'handler',\n 'performer',\n 'observable',\n 'identifier',\n 'reason',\n 'from',\n 'when',\n 'given',\n 'then',\n 'arguments',\n 'result',\n 'clock', // A specification step - 'given clock' and 'when clock' state an instant.\n 'exactly',\n 'error',\n 'message',\n 'not', // Unary policy negation, as well as 'not empty' validation.\n 'empty',\n 'rule',\n 'matches',\n 'all',\n 'max',\n 'min',\n 'length',\n 'today',\n 'true',\n 'false',\n 'and',\n 'or',\n 'by',\n 'filter',\n 'data',\n 'via',\n 'component',\n 'context',\n 'property',\n 'literal',\n 'icons',\n 'packages',\n 'active',\n 'bind',\n 'maps',\n 'row',\n 'locale',\n 'shape',\n 'outlet',\n 'display',\n 'scopes',\n 'blueprint', // 'template blueprint <Blueprint> <Name> [version \"<range>\"]' names a template a blueprint package ships.\n 'version',\n 'statechange', // Slice kinds a template's 'scopes slice ...' narrows to.\n 'stateview',\n 'reexposes',\n 'operations',\n 'items',\n 'toolbar',\n 'button',\n 'emphasis',\n 'primary',\n 'secondary',\n 'quiet',\n 'item',\n 'topbar',\n 'sidebar',\n 'inherits',\n 'extends',\n 'overrides',\n 'logo',\n 'image',\n 'icon',\n 'target',\n 'slot',\n 'presentation',\n 'exposes',\n 'mode',\n 'oneWay',\n 'twoWay',\n 'null',\n 'propagate',\n 'clear',\n 'preserve',\n 'expected',\n 'action',\n 'navigate',\n 'to',\n 'label',\n 'section',\n 'table',\n 'summary',\n 'title',\n 'column',\n 'field',\n 'on',\n 'unique',\n 'file',\n 'concurrency',\n 'eventSource',\n 'sourceType',\n 'streamType',\n 'streamId',\n 'tag',\n 'for',\n 'readmodel',\n 'no',\n 'when',\n 'every',\n 'at',\n 'where',\n 'invokes',\n 'contains',\n 'starts',\n 'ends',\n 'with',\n 'provider',\n // Interaction: the words a behavior body uses. The built-in interaction kinds ('click', 'submit', and\n // friends) are only reserved inside an `on` clause, so they are clause words rather than constructs -\n // an identifier of the same name elsewhere in a document remains an identifier.\n 'uses',\n 'parameter',\n 'order',\n 'open',\n 'close',\n 'refresh',\n 'set',\n 'notify',\n 'confirm',\n 'raise',\n 'interval',\n 'success',\n 'failure',\n 'click',\n 'double',\n 'select',\n 'submit',\n 'change',\n 'load',\n 'unload',\n 'enter',\n 'leave',\n 'info',\n 'warning',\n];\n\nexport const codeBlockTags = ['csharp', 'typescript', 'react', 'html', 'sql'];\n\n// The roots a `$context.` path can start with — the members of CommandContext and QueryContext.\nexport const contextRoots = [\n 'command',\n 'arguments',\n 'tenant',\n 'causedBy',\n 'causation',\n 'occurred',\n 'identity',\n];\n\nexport const causedByProperties = ['subject', 'name', 'userName'];\n\n// The properties a `$identity.` or `$context.identity.` path can name — the members of Identity. Everything after\n// `claims.` is the name of a claim rather than a member, so it is never checked.\nexport const identityProperties = ['id', 'name', 'userName', 'isAuthenticated', 'roles', 'claims'];\n\nexport const sliceTypes = ['StateChange', 'StateView', 'Automation', 'Translate'];\n\nexport const primitiveTypes = ['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime'];\n\nexport const conceptAttributes = ['pii', 'personal', 'secret'];\n\n// The lines that open a block with a body of their own. A line that is complete as written - a `domain`, a\n// `concept` or `query` with nothing under it, a `produces` of an existing event - is not one.\nexport const blockHeaderPattern = /^\\s*(?:module|feature|slice\\s+\\w+|type|command(?!\\s+reads\\s+protected\\b)|event|readmodel|reducer|projection|capture|reaction(?!\\s+batches\\b)|screen|dialog|form|contribute|specification|case|constraint|persona|policy|behavior|layout|theme|ui\\s+profile|trigger|authentication|identity|seed|system|eventsource|operation|screen\\s+template|dialog\\s+template|produces\\s+event|generate\\s+rule|validate|handler|on)\\b[^=]*$/;\n\nexport const languageConfiguration: languages.LanguageConfiguration = {\n comments: {\n lineComment: '//',\n },\n brackets: [\n ['(', ')'],\n ['[', ']'],\n ],\n autoClosingPairs: [\n { open: '(', close: ')' },\n { open: '[', close: ']' },\n { open: '\"', close: '\"' },\n ],\n surroundingPairs: [\n { open: '(', close: ')' },\n { open: '[', close: ']' },\n { open: '\"', close: '\"' },\n ],\n folding: {\n offSide: true,\n },\n // A header that opens a block puts the cursor one level in on Enter, so what is typed - or suggested - starts at\n // the block's own indentation. IndentAction.Indent is 1.\n onEnterRules: [\n { beforeText: blockHeaderPattern, action: { indentAction: 1 as languages.IndentAction } },\n ],\n indentationRules: {\n increaseIndentPattern:\n /^\\s*(module|feature|slice|policy|persona|authentication|identity|provider|event|command(?!\\s+reads\\s+protected\\b)|query|type|screen|projection|capture|reaction(?!\\s+batches\\b)|trigger|constraint|specification|layout|template|generate\\s+rule|validate|produces|handler|implementation(?=\\s*$)|performer|rule|section|action|otherwise(?=\\s*$|\\s+execute\\b)|concurrency|seed|for|when|then|arguments|result|every|at|invokes|on)\\b.*$/,\n // Dedents are always explicit in an offside language — never auto-dedent.\n decreaseIndentPattern: /(?!)/,\n },\n};\n"],"mappings":"AAOA,MAAaA,EAAa,aAEbC,EAA4D,CACrE,GAAID,EACJ,WAAY,CAAC,OAAO,EACpB,QAAS,CAAC,aAAc,aAAc,MAAM,EAC5C,UAAW,CAAC,mBAAmB,CACnC,EAMaE,EAAoB,6XA6CjC,EAKaC,EAAiB,opCAmK9B,EAEaC,EAAgB,CAAC,SAAU,aAAc,QAAS,OAAQ,KAAK,EAG/DC,EAAe,CACxB,UACA,YACA,SACA,WACA,YACA,WACA,UACJ,EAEaC,EAAqB,CAAC,UAAW,OAAQ,UAAU,EAInDC,EAAqB,CAAC,KAAM,OAAQ,WAAY,kBAAmB,QAAS,QAAQ,EAEpFC,EAAa,CAAC,cAAe,YAAa,aAAc,WAAW,EAEnEC,EAAiB,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,UAAU,EAEhFC,EAAoB,CAAC,MAAO,WAAY,QAAQ,EAIhDC,EAAqB,iaAErBC,EAAyD,CAClE,SAAU,CACN,YAAa,IACjB,EACA,SAAU,CACN,CAAC,IAAK,GAAG,EACT,CAAC,IAAK,GAAG,CACb,EACA,iBAAkB,CACd,CAAE,KAAM,IAAK,MAAO,GAAI,EACxB,CAAE,KAAM,IAAK,MAAO,GAAI,EACxB,CAAE,KAAM,IAAK,MAAO,GAAI,CAC5B,EACA,iBAAkB,CACd,CAAE,KAAM,IAAK,MAAO,GAAI,EACxB,CAAE,KAAM,IAAK,MAAO,GAAI,EACxB,CAAE,KAAM,IAAK,MAAO,GAAI,CAC5B,EACA,QAAS,CACL,QAAS,EACb,EAGA,aAAc,CACV,CAAE,WAAYD,EAAoB,OAAQ,CAAE,aAAc,CAA4B,CAAE,CAC5F,EACA,iBAAkB,CACd,sBACI,2aAEJ,sBAAuB,MAC3B,CACJ"}
@@ -1,7 +1,7 @@
1
1
  import"./_virtual/_virtual/_rolldown/runtime.js";import{fenceMap as e,indentOf as t,nearestEnclosingLine as n,withoutComment as r}from"./document-context.js";import{exampleValueFor as i}from"./example-values.js";function lastIndexWhere(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n],n))return n;return-1}const upperCamelWords=e=>e.match(/[A-Z][a-z0-9]*/g)??[e];function pastTense(e){return/[^aeiou]y$/i.test(e)?`${e.slice(0,-1)}ied`:/e$/i.test(e)?`${e}d`:`${e}ed`}function likelyEventName(e,t){let[n,...r]=upperCamelWords(e),i=r.join(``);return t.events.find(e=>i.length>0&&e.name.startsWith(i))?.name??`${i}${pastTense(n)}`}function indentUnit(e){let n=e.map(t).filter(e=>e>0);return n.length===0?4:Math.min(...n)}function producesBlock(e,t,n,r){let i=likelyEventName(e.name,t),a=t.events.find(e=>e.name===i),o=` `.repeat(n+r),s=e.properties.filter(e=>!e.isIdentifier);if(a){let t=a.properties.filter(e=>s.some(t=>t.name===e.name)),n=e.properties.find(e=>e.isIdentifier);return[`produces ${i}`,...n?[`${o}for ${n.name}`]:[],...t.map(e=>`${o}${e.name} = ${e.name}`)].join(`
2
2
  `)}return[`produces event ${i}`,...s.map(e=>`${o}${e.name} ${e.type} = ${e.name}`)].join(`
3
3
  `)}function newCommandBlock(e,t,n,r){let i=upperCamelWords(e).slice(1).join(``),a=likelyEventName(e,t),o=t.events.find(e=>e.name===a),s=i.length>0&&t.concepts.some(e=>e.name===`${i}Id`)?`${i[0].toLowerCase()}${i.slice(1)}Id`:void 0,c=s?[`${s} ${i}Id identifier`]:[],l=` `.repeat(n+r),u=(o?.properties??[]).filter(e=>e.name!==s),d=u.map(e=>`${` `.repeat(n)}${e.name} ${e.type}`),f=o?[`${` `.repeat(n)}produces ${a}`,...s?[`${l}for ${s}`]:[],...u.map(e=>`${l}${e.name} = ${e.name}`)]:[`${` `.repeat(n)}produces event ${a}`];return[...c.map((e,t)=>t===0?e:`${` `.repeat(n)}${e}`),...d,...f].join(`
4
- `).trimStart()}function assignments(e,t,n){return e.map(e=>`${` `.repeat(n)}${e.name} = ${i(e.type,t)}`)}function sliceCommand(e,n,r,i){let a=-1;for(let i=r-1;i>=0;i--)if(!n[i]&&/^\s*slice\s/.test(e[i])&&t(e[i])<t(e[r])){a=i;break}if(a<0)return;let o,s=!1;for(let r=a+1;r<e.length;r++){if(e[r].trim().length===0||n[r])continue;if(t(e[r])<=t(e[a]))break;let i=e[r].trim().match(/^command\s+(\w+)\s*$/);i?(o=i[1],s=!1):o&&/^authorize\b/.test(e[r].trim())&&(s=!0)}let c=i.commands.find(e=>e.name===o);return c?{symbol:c,authorized:s}:void 0}function specificationBlock(e,t,n,r,a){let o=r+a,s=likelyEventName(e.name,n),c=e.properties.find(e=>e.isIdentifier),l=e.properties.filter(e=>!e.isIdentifier);return[...t?[`given caller`,`${` `.repeat(o)}authenticated`]:[],...t?[`${` `.repeat(r)}when ${e.name}`]:[`when ${e.name}`],...assignments(e.properties,n,o),`${` `.repeat(r)}then ${s}`,...c?[`${` `.repeat(o)}for ${i(c.type,n)}`]:[],...assignments(l,n,o)].join(`
4
+ `).trimStart()}function assignments(e,t,n){return e.map(e=>`${` `.repeat(n)}${e.name} = ${i(e.type,t)}`)}function sliceCommand(e,n,r,i){let a=-1;for(let i=r-1;i>=0;i--)if(!n[i]&&/^\s*slice\s/.test(e[i])&&t(e[i])<t(e[r])){a=i;break}if(a<0)return;let o,s=!1;for(let r=a+1;r<e.length;r++){if(e[r].trim().length===0||n[r])continue;if(t(e[r])<=t(e[a]))break;let i=e[r].trim().match(/^command\s+(\w+)\s*$/);i?(o=i[1],s=!1):o&&/^authorize\b/.test(e[r].trim())&&(s=!anonymousPolicies(e).has(e[r].trim().replace(/^authorize\s+/,``)))}let c=i.commands.find(e=>e.name===o);return c?{symbol:c,authorized:s}:void 0}function anonymousPolicies(e){let t=/* @__PURE__ */ new Set,n;for(let r of e){let e=r.match(/^policy\s+(\w+)\s*$/);e?n=e[1]:(!/^\s/.test(r)&&r.trim().length>0&&(n=void 0),n&&/^\s+require\s+anonymous\s*$/.test(r)&&t.add(n))}return t}function specificationBlock(e,t,n,r,a){let o=r+a,s=likelyEventName(e.name,n),c=e.properties.find(e=>e.isIdentifier),l=e.properties.filter(e=>!e.isIdentifier);return[...t?[`given caller`,`${` `.repeat(o)}authenticated`]:[],...t?[`${` `.repeat(r)}when ${e.name}`]:[`when ${e.name}`],...assignments(e.properties,n,o),`${` `.repeat(r)}then ${s}`,...c?[`${` `.repeat(o)}for ${i(c.type,n)}`]:[],...assignments(l,n,o)].join(`
5
5
  `)}function structureCompletion(i,a,o,s,c){if(o.trim().length>0||s.trim().length>0)return null;let l=e(i);if(l[a])return null;let u=lastIndexWhere(i.slice(0,a),e=>r(e).trim().length>0);if(u<0||l[u])return null;let d=indentUnit(i),f=i[u].trim(),p=/^(?:command\s+\w+|specification\s+\w+|form\s+\w+\s+for\s+[\w.]+)\s*$/.test(f),m=p?Math.max(o.length,t(i[u])+d):o.length||t(i[u]),h=p?f:n(i,l,a,m);if(!h)return null;let g=p?t(i[u]):m-Math.max(1,d),_=` `.repeat(Math.max(0,m-o.length)),wrap=e=>e?{text:`${_}${e}`}:null,v=h.match(/^command\s+(\w+)\s*$/);if(v){let e=c.commands.find(e=>e.name===v[1]),n=lastIndexWhere(i,(e,n)=>n<a&&e.trim()===h&&t(e)<m);return i.slice(n+1,a).filter(e=>e.trim().length>0).some(e=>/^\s*(produces|handler)\b/.test(e))?null:!e||e.properties.length===0?wrap(newCommandBlock(v[1],c,m,d)):wrap(producesBlock(e,c,m,d))}if(/^specification\s+\w+\s*$/.test(h)&&g>=0){let e=sliceCommand(i,l,u,c);return e?wrap(specificationBlock(e.symbol,e.authorized,c,m,d)):null}let y=h.match(/^form\s+\w+\s+for\s+(?:\w+\.)*(\w+)\s*$/);if(y){let e=c.commands.find(e=>e.name===y[1]);return e?wrap(e.properties.map((e,t)=>`${t===0?``:` `.repeat(m)}field ${e.name}`).join(`
6
6
  `)):null}return null}export{structureCompletion};
7
7
  //# sourceMappingURL=structure-completions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"structure-completions.js","names":["index","lines","matches","name","verb","subject","command","noun","symbols","event","indented","indentOf","indent","eventName","declared","inner","unit","sources","property","mappings","source","identifier","identity","concept","identityLine","properties","propertyLines","outcome","line","exampleValueFor","sliceIndex","headerIndex","fences","authorized","symbol","candidate","textBefore","textAfter","fenceMap","lineIndex","previous","withoutComment","previousLine","opensEmptyBlock","header","nearestEnclosingLine","headerIndent","pad","block","headerLine","found","form"],"sources":["../../structure-completions.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 { fenceMap, indentOf, nearestEnclosingLine, withoutComment } from './document-context';\nimport { exampleValueFor } from './example-values';\nimport { CommandSymbol, DocumentSymbols, PropertySymbol } from './symbols';\n\n// A multi-line suggestion shown as ghost text at the cursor. The text starts at the cursor and\n// continues on following lines with absolute indentation, so inserting it needs no further work.\nexport interface StructureCompletion {\n text: string;\n}\n\nfunction lastIndexWhere(lines: string[], matches: (line: string, index: number) => boolean): number {\n for (let index = lines.length - 1; index >= 0; index--) if (matches(lines[index], index)) return index;\n return -1;\n}\n\nconst upperCamelWords = (name: string) => name.match(/[A-Z][a-z0-9]*/g) ?? [name];\n\nfunction pastTense(verb: string): string {\n if (/[^aeiou]y$/i.test(verb)) return `${verb.slice(0, -1)}ied`;\n return /e$/i.test(verb) ? `${verb}d` : `${verb}ed`;\n}\n\n// The event a command most likely produces: a declared event that names its subject, else the\n// subject followed by the past tense of the command's verb - AddProduct becomes ProductAdded.\nfunction likelyEventName(command: string, symbols: DocumentSymbols): string {\n const [verb, ...subject] = upperCamelWords(command);\n const noun = subject.join('');\n const declared = symbols.events.find(event => noun.length > 0 && event.name.startsWith(noun));\n return declared?.name ?? `${noun}${pastTense(verb)}`;\n}\n\n\n// The indentation of one level in the document, learned from its first indented line.\nfunction indentUnit(lines: string[]): number {\n const indented = lines.map(indentOf).filter(indent => indent > 0);\n return indented.length === 0 ? 4 : Math.min(...indented);\n}\n\nfunction producesBlock(command: CommandSymbol, symbols: DocumentSymbols, indent: number, unit: number): string {\n const eventName = likelyEventName(command.name, symbols);\n const declared = symbols.events.find(event => event.name === eventName);\n const inner = ' '.repeat(indent + unit);\n const sources = command.properties.filter(property => !property.isIdentifier);\n if (declared) {\n const mappings = declared.properties.filter(property => sources.some(source => source.name === property.name));\n const identifier = command.properties.find(property => property.isIdentifier);\n return [`produces ${eventName}`, ...(identifier ? [`${inner}for ${identifier.name}`] : []), ...mappings.map(property => `${inner}${property.name} = ${property.name}`)].join('\\n');\n }\n return [`produces event ${eventName}`, ...sources.map(property => `${inner}${property.name} ${property.type} = ${property.name}`)].join('\\n');\n}\n\n// What a command that has nothing yet most likely needs: the identity of the thing it acts on when a\n// concept for it is declared, the properties of the event it will most likely produce, and the production.\nfunction newCommandBlock(command: string, symbols: DocumentSymbols, indent: number, unit: number): string {\n const noun = upperCamelWords(command).slice(1).join('');\n const eventName = likelyEventName(command, symbols);\n const declared = symbols.events.find(event => event.name === eventName);\n const identity = noun.length > 0 && symbols.concepts.some(concept => concept.name === `${noun}Id`) ? `${noun[0].toLowerCase()}${noun.slice(1)}Id` : undefined;\n const identityLine = identity ? [`${identity} ${noun}Id identifier`] : [];\n const inner = ' '.repeat(indent + unit);\n const properties = (declared?.properties ?? []).filter(property => property.name !== identity);\n const propertyLines = properties.map(property => `${' '.repeat(indent)}${property.name} ${property.type}`);\n const outcome = declared\n ? [`${' '.repeat(indent)}produces ${eventName}`, ...(identity ? [`${inner}for ${identity}`] : []), ...properties.map(property => `${inner}${property.name} = ${property.name}`)]\n : [`${' '.repeat(indent)}produces event ${eventName}`];\n const lines = [...identityLine.map((line, index) => (index === 0 ? line : `${' '.repeat(indent)}${line}`)), ...propertyLines, ...outcome];\n return lines.join('\\n').trimStart();\n}\n\nfunction assignments(properties: PropertySymbol[], symbols: DocumentSymbols, indent: number): string[] {\n return properties.map(property => `${' '.repeat(indent)}${property.name} = ${exampleValueFor(property.type, symbols)}`);\n}\n\n// The command the slice enclosing a line declares, with whether it carries an authorize clause.\nfunction sliceCommand(lines: string[], fences: boolean[], headerIndex: number, symbols: DocumentSymbols) {\n let sliceIndex = -1;\n for (let index = headerIndex - 1; index >= 0; index--) {\n if (!fences[index] && /^\\s*slice\\s/.test(lines[index]) && indentOf(lines[index]) < indentOf(lines[headerIndex])) { sliceIndex = index; break; }\n }\n if (sliceIndex < 0) return undefined;\n let name: string | undefined;\n let authorized = false;\n for (let index = sliceIndex + 1; index < lines.length; index++) {\n if (lines[index].trim().length === 0 || fences[index]) continue;\n if (indentOf(lines[index]) <= indentOf(lines[sliceIndex])) break;\n const command = lines[index].trim().match(/^command\\s+(\\w+)\\s*$/);\n if (command) { name = command[1]; authorized = false; continue; }\n if (name && /^authorize\\b/.test(lines[index].trim())) authorized = true;\n }\n const symbol = symbols.commands.find(candidate => candidate.name === name);\n return symbol ? { symbol, authorized } : undefined;\n}\n\nfunction specificationBlock(command: CommandSymbol, authorized: boolean, symbols: DocumentSymbols, indent: number, unit: number): string {\n const inner = indent + unit;\n const eventName = likelyEventName(command.name, symbols);\n const identifier = command.properties.find(property => property.isIdentifier);\n const sources = command.properties.filter(property => !property.isIdentifier);\n return [\n ...(authorized ? [`given caller`, `${' '.repeat(inner)}authenticated`] : []),\n ...(authorized ? [`${' '.repeat(indent)}when ${command.name}`] : [`when ${command.name}`]),\n ...assignments(command.properties, symbols, inner),\n `${' '.repeat(indent)}then ${eventName}`,\n ...(identifier ? [`${' '.repeat(inner)}for ${exampleValueFor(identifier.type, symbols)}`] : []),\n ...assignments(sources, symbols, inner),\n ].join('\\n');\n}\n\n// Suggests the structure a block most obviously needs next - the production of a command, the\n// skeleton of a specification, the fields of a form - when the cursor rests on an empty line directly\n// inside a block that has no content yet. Returns null when nothing is obviously missing.\nexport function structureCompletion(lines: string[], lineIndex: number, textBefore: string, textAfter: string, symbols: DocumentSymbols): StructureCompletion | null {\n if (textBefore.trim().length > 0 || textAfter.trim().length > 0) return null;\n const fences = fenceMap(lines);\n if (fences[lineIndex]) return null;\n const previous = lastIndexWhere(lines.slice(0, lineIndex), line => withoutComment(line).trim().length > 0);\n if (previous < 0 || fences[previous]) return null;\n const unit = indentUnit(lines);\n const previousLine = lines[previous].trim();\n const opensEmptyBlock = /^(?:command\\s+\\w+|specification\\s+\\w+|form\\s+\\w+\\s+for\\s+[\\w.]+)\\s*$/.test(previousLine);\n // An empty block's body starts one level in; otherwise the cursor continues the lines above it.\n const indent = opensEmptyBlock ? Math.max(textBefore.length, indentOf(lines[previous]) + unit) : textBefore.length || indentOf(lines[previous]);\n const header = opensEmptyBlock ? previousLine : nearestEnclosingLine(lines, fences, lineIndex, indent);\n if (!header) return null;\n const headerIndent = opensEmptyBlock ? indentOf(lines[previous]) : indent - Math.max(1, unit);\n const pad = ' '.repeat(Math.max(0, indent - textBefore.length));\n const wrap = (block: string | undefined) => (block ? { text: `${pad}${block}` } : null);\n\n const command = header.match(/^command\\s+(\\w+)\\s*$/);\n if (command) {\n const symbol = symbols.commands.find(candidate => candidate.name === command[1]);\n const headerLine = lastIndexWhere(lines, (line, index) => index < lineIndex && line.trim() === header && indentOf(line) < indent);\n const body = lines.slice(headerLine + 1, lineIndex).filter(line => line.trim().length > 0);\n const hasOutcome = body.some(line => /^\\s*(produces|handler)\\b/.test(line));\n if (hasOutcome) return null;\n if (!symbol || symbol.properties.length === 0) return wrap(newCommandBlock(command[1], symbols, indent, unit));\n return wrap(producesBlock(symbol, symbols, indent, unit));\n }\n\n if (/^specification\\s+\\w+\\s*$/.test(header) && headerIndent >= 0) {\n const found = sliceCommand(lines, fences, previous, symbols);\n return found ? wrap(specificationBlock(found.symbol, found.authorized, symbols, indent, unit)) : null;\n }\n\n const form = header.match(/^form\\s+\\w+\\s+for\\s+(?:\\w+\\.)*(\\w+)\\s*$/);\n if (form) {\n const symbol = symbols.commands.find(candidate => candidate.name === form[1]);\n return symbol ? wrap(symbol.properties.map((property, index) => `${index === 0 ? '' : ' '.repeat(indent)}field ${property.name}`).join('\\n')) : null;\n }\n return null;\n}\n"],"mappings":"oNAaA,SAAS,eAAe,EAAiB,EAA2D,CAChG,IAAK,IAAIA,EAAQC,EAAM,OAAS,EAAGD,GAAS,EAAG,IAAS,GAAIE,EAAQD,EAAMD,GAAQA,CAAK,EAAG,OAAOA,EACjG,MAAO,EACX,CAEA,MAAM,gBAAmB,GAAiBG,EAAK,MAAM,iBAAiB,GAAK,CAACA,CAAI,EAEhF,SAAS,UAAU,EAAsB,CAErC,MADI,cAAc,KAAKC,CAAI,EAAU,GAAGA,EAAK,MAAM,EAAG,EAAE,EAAE,KACnD,MAAM,KAAKA,CAAI,EAAI,GAAGA,EAAK,GAAK,GAAGA,EAAK,GACnD,CAIA,SAAS,gBAAgB,EAAiB,EAAkC,CACxE,GAAM,CAACA,EAAM,GAAGC,GAAW,gBAAgBC,CAAO,EAC5CC,EAAOF,EAAQ,KAAK,EAAE,EAE5B,OADiBG,EAAQ,OAAO,KAAK,GAASD,EAAK,OAAS,GAAKE,EAAM,KAAK,WAAWF,CAAI,CAC7E,CAAC,EAAE,MAAQ,GAAGA,IAAO,UAAUH,CAAI,GACrD,CAIA,SAAS,WAAW,EAAyB,CACzC,IAAMM,EAAWT,EAAM,IAAIU,CAAQ,CAAC,CAAC,OAAO,GAAUC,EAAS,CAAC,EAChE,OAAOF,EAAS,SAAW,EAAI,EAAI,KAAK,IAAI,GAAGA,CAAQ,CAC3D,CAEA,SAAS,cAAc,EAAwB,EAA0B,EAAgB,EAAsB,CAC3G,IAAMG,EAAY,gBAAgBP,EAAQ,KAAME,CAAO,EACjDM,EAAWN,EAAQ,OAAO,KAAK,GAASC,EAAM,OAASI,CAAS,EAChEE,EAAQ,IAAI,OAAOH,EAASI,CAAI,EAChCC,EAAUX,EAAQ,WAAW,OAAO,GAAY,CAACY,EAAS,YAAY,EAC5E,GAAIJ,EAAU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1B,EAASI,EAAQI,CAAI,CAAC,CAC5D,CAEA,GAAI,2BAA2B,KAAK4B,CAAM,GAAKE,GAAgB,EAAG,CAC9D,IAAMI,EAAQ,aAAajD,EAAO+B,EAAQQ,EAAUhC,CAAO,EAC3D,OAAO0C,EAAQ,KAAK,mBAAmBA,EAAM,OAAQA,EAAM,WAAY1C,EAASI,EAAQI,CAAI,CAAC,EAAI,IACrG,CAEA,IAAMmC,EAAOP,EAAO,MAAM,yCAAyC,EACnE,GAAIO,EAAM,CACN,IAAMjB,EAAS1B,EAAQ,SAAS,KAAK,GAAa2B,EAAU,OAASgB,EAAK,EAAE,EAC5E,OAAOjB,EAAS,KAAKA,EAAO,WAAW,KAAK,EAAU,IAAU,GAAGlC,IAAU,EAAI,GAAK,IAAI,OAAOY,CAAM,EAAE,QAAQM,EAAS,MAAM,CAAC,CAAC,KAAK;CAAI,CAAC,EAAI,IACpJ,CACA,OAAO,IACX"}
1
+ {"version":3,"file":"structure-completions.js","names":["index","lines","matches","name","verb","subject","command","noun","symbols","event","indented","indentOf","indent","eventName","declared","inner","unit","sources","property","mappings","source","identifier","identity","concept","identityLine","properties","propertyLines","outcome","line","exampleValueFor","sliceIndex","headerIndex","fences","authorized","symbol","candidate","names","policy","header","textBefore","textAfter","fenceMap","lineIndex","previous","withoutComment","previousLine","opensEmptyBlock","nearestEnclosingLine","headerIndent","pad","block","headerLine","found","form"],"sources":["../../structure-completions.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 { fenceMap, indentOf, nearestEnclosingLine, withoutComment } from './document-context';\nimport { exampleValueFor } from './example-values';\nimport { CommandSymbol, DocumentSymbols, PropertySymbol } from './symbols';\n\n// A multi-line suggestion shown as ghost text at the cursor. The text starts at the cursor and\n// continues on following lines with absolute indentation, so inserting it needs no further work.\nexport interface StructureCompletion {\n text: string;\n}\n\nfunction lastIndexWhere(lines: string[], matches: (line: string, index: number) => boolean): number {\n for (let index = lines.length - 1; index >= 0; index--) if (matches(lines[index], index)) return index;\n return -1;\n}\n\nconst upperCamelWords = (name: string) => name.match(/[A-Z][a-z0-9]*/g) ?? [name];\n\nfunction pastTense(verb: string): string {\n if (/[^aeiou]y$/i.test(verb)) return `${verb.slice(0, -1)}ied`;\n return /e$/i.test(verb) ? `${verb}d` : `${verb}ed`;\n}\n\n// The event a command most likely produces: a declared event that names its subject, else the\n// subject followed by the past tense of the command's verb - AddProduct becomes ProductAdded.\nfunction likelyEventName(command: string, symbols: DocumentSymbols): string {\n const [verb, ...subject] = upperCamelWords(command);\n const noun = subject.join('');\n const declared = symbols.events.find(event => noun.length > 0 && event.name.startsWith(noun));\n return declared?.name ?? `${noun}${pastTense(verb)}`;\n}\n\n\n// The indentation of one level in the document, learned from its first indented line.\nfunction indentUnit(lines: string[]): number {\n const indented = lines.map(indentOf).filter(indent => indent > 0);\n return indented.length === 0 ? 4 : Math.min(...indented);\n}\n\nfunction producesBlock(command: CommandSymbol, symbols: DocumentSymbols, indent: number, unit: number): string {\n const eventName = likelyEventName(command.name, symbols);\n const declared = symbols.events.find(event => event.name === eventName);\n const inner = ' '.repeat(indent + unit);\n const sources = command.properties.filter(property => !property.isIdentifier);\n if (declared) {\n const mappings = declared.properties.filter(property => sources.some(source => source.name === property.name));\n const identifier = command.properties.find(property => property.isIdentifier);\n return [`produces ${eventName}`, ...(identifier ? [`${inner}for ${identifier.name}`] : []), ...mappings.map(property => `${inner}${property.name} = ${property.name}`)].join('\\n');\n }\n return [`produces event ${eventName}`, ...sources.map(property => `${inner}${property.name} ${property.type} = ${property.name}`)].join('\\n');\n}\n\n// What a command that has nothing yet most likely needs: the identity of the thing it acts on when a\n// concept for it is declared, the properties of the event it will most likely produce, and the production.\nfunction newCommandBlock(command: string, symbols: DocumentSymbols, indent: number, unit: number): string {\n const noun = upperCamelWords(command).slice(1).join('');\n const eventName = likelyEventName(command, symbols);\n const declared = symbols.events.find(event => event.name === eventName);\n const identity = noun.length > 0 && symbols.concepts.some(concept => concept.name === `${noun}Id`) ? `${noun[0].toLowerCase()}${noun.slice(1)}Id` : undefined;\n const identityLine = identity ? [`${identity} ${noun}Id identifier`] : [];\n const inner = ' '.repeat(indent + unit);\n const properties = (declared?.properties ?? []).filter(property => property.name !== identity);\n const propertyLines = properties.map(property => `${' '.repeat(indent)}${property.name} ${property.type}`);\n const outcome = declared\n ? [`${' '.repeat(indent)}produces ${eventName}`, ...(identity ? [`${inner}for ${identity}`] : []), ...properties.map(property => `${inner}${property.name} = ${property.name}`)]\n : [`${' '.repeat(indent)}produces event ${eventName}`];\n const lines = [...identityLine.map((line, index) => (index === 0 ? line : `${' '.repeat(indent)}${line}`)), ...propertyLines, ...outcome];\n return lines.join('\\n').trimStart();\n}\n\nfunction assignments(properties: PropertySymbol[], symbols: DocumentSymbols, indent: number): string[] {\n return properties.map(property => `${' '.repeat(indent)}${property.name} = ${exampleValueFor(property.type, symbols)}`);\n}\n\n// The command the slice enclosing a line declares, with whether it carries an authorize clause.\nfunction sliceCommand(lines: string[], fences: boolean[], headerIndex: number, symbols: DocumentSymbols) {\n let sliceIndex = -1;\n for (let index = headerIndex - 1; index >= 0; index--) {\n if (!fences[index] && /^\\s*slice\\s/.test(lines[index]) && indentOf(lines[index]) < indentOf(lines[headerIndex])) { sliceIndex = index; break; }\n }\n if (sliceIndex < 0) return undefined;\n let name: string | undefined;\n let authorized = false;\n for (let index = sliceIndex + 1; index < lines.length; index++) {\n if (lines[index].trim().length === 0 || fences[index]) continue;\n if (indentOf(lines[index]) <= indentOf(lines[sliceIndex])) break;\n const command = lines[index].trim().match(/^command\\s+(\\w+)\\s*$/);\n if (command) { name = command[1]; authorized = false; continue; }\n // A command gated only by an anonymous policy runs without a caller, so its specification needs none.\n if (name && /^authorize\\b/.test(lines[index].trim())) authorized = !anonymousPolicies(lines).has(lines[index].trim().replace(/^authorize\\s+/, ''));\n }\n const symbol = symbols.commands.find(candidate => candidate.name === name);\n return symbol ? { symbol, authorized } : undefined;\n}\n\nfunction anonymousPolicies(lines: readonly string[]): Set<string> {\n const names = new Set<string>();\n let policy: string | undefined;\n for (const line of lines) {\n const header = line.match(/^policy\\s+(\\w+)\\s*$/);\n if (header) { policy = header[1]; continue; }\n if (!/^\\s/.test(line) && line.trim().length > 0) policy = undefined;\n if (policy && /^\\s+require\\s+anonymous\\s*$/.test(line)) names.add(policy);\n }\n return names;\n}\n\nfunction specificationBlock(command: CommandSymbol, authorized: boolean, symbols: DocumentSymbols, indent: number, unit: number): string {\n const inner = indent + unit;\n const eventName = likelyEventName(command.name, symbols);\n const identifier = command.properties.find(property => property.isIdentifier);\n const sources = command.properties.filter(property => !property.isIdentifier);\n return [\n ...(authorized ? [`given caller`, `${' '.repeat(inner)}authenticated`] : []),\n ...(authorized ? [`${' '.repeat(indent)}when ${command.name}`] : [`when ${command.name}`]),\n ...assignments(command.properties, symbols, inner),\n `${' '.repeat(indent)}then ${eventName}`,\n ...(identifier ? [`${' '.repeat(inner)}for ${exampleValueFor(identifier.type, symbols)}`] : []),\n ...assignments(sources, symbols, inner),\n ].join('\\n');\n}\n\n// Suggests the structure a block most obviously needs next - the production of a command, the\n// skeleton of a specification, the fields of a form - when the cursor rests on an empty line directly\n// inside a block that has no content yet. Returns null when nothing is obviously missing.\nexport function structureCompletion(lines: string[], lineIndex: number, textBefore: string, textAfter: string, symbols: DocumentSymbols): StructureCompletion | null {\n if (textBefore.trim().length > 0 || textAfter.trim().length > 0) return null;\n const fences = fenceMap(lines);\n if (fences[lineIndex]) return null;\n const previous = lastIndexWhere(lines.slice(0, lineIndex), line => withoutComment(line).trim().length > 0);\n if (previous < 0 || fences[previous]) return null;\n const unit = indentUnit(lines);\n const previousLine = lines[previous].trim();\n const opensEmptyBlock = /^(?:command\\s+\\w+|specification\\s+\\w+|form\\s+\\w+\\s+for\\s+[\\w.]+)\\s*$/.test(previousLine);\n // An empty block's body starts one level in; otherwise the cursor continues the lines above it.\n const indent = opensEmptyBlock ? Math.max(textBefore.length, indentOf(lines[previous]) + unit) : textBefore.length || indentOf(lines[previous]);\n const header = opensEmptyBlock ? previousLine : nearestEnclosingLine(lines, fences, lineIndex, indent);\n if (!header) return null;\n const headerIndent = opensEmptyBlock ? indentOf(lines[previous]) : indent - Math.max(1, unit);\n const pad = ' '.repeat(Math.max(0, indent - textBefore.length));\n const wrap = (block: string | undefined) => (block ? { text: `${pad}${block}` } : null);\n\n const command = header.match(/^command\\s+(\\w+)\\s*$/);\n if (command) {\n const symbol = symbols.commands.find(candidate => candidate.name === command[1]);\n const headerLine = lastIndexWhere(lines, (line, index) => index < lineIndex && line.trim() === header && indentOf(line) < indent);\n const body = lines.slice(headerLine + 1, lineIndex).filter(line => line.trim().length > 0);\n const hasOutcome = body.some(line => /^\\s*(produces|handler)\\b/.test(line));\n if (hasOutcome) return null;\n if (!symbol || symbol.properties.length === 0) return wrap(newCommandBlock(command[1], symbols, indent, unit));\n return wrap(producesBlock(symbol, symbols, indent, unit));\n }\n\n if (/^specification\\s+\\w+\\s*$/.test(header) && headerIndent >= 0) {\n const found = sliceCommand(lines, fences, previous, symbols);\n return found ? wrap(specificationBlock(found.symbol, found.authorized, symbols, indent, unit)) : null;\n }\n\n const form = header.match(/^form\\s+\\w+\\s+for\\s+(?:\\w+\\.)*(\\w+)\\s*$/);\n if (form) {\n const symbol = symbols.commands.find(candidate => candidate.name === form[1]);\n return symbol ? wrap(symbol.properties.map((property, index) => `${index === 0 ? '' : ' '.repeat(indent)}field ${property.name}`).join('\\n')) : null;\n }\n return null;\n}\n"],"mappings":"oNAaA,SAAS,eAAe,EAAiB,EAA2D,CAChG,IAAK,IAAIA,EAAQC,EAAM,OAAS,EAAGD,GAAS,EAAG,IAAS,GAAIE,EAAQD,EAAMD,GAAQA,CAAK,EAAG,OAAOA,EACjG,MAAO,EACX,CAEA,MAAM,gBAAmB,GAAiBG,EAAK,MAAM,iBAAiB,GAAK,CAACA,CAAI,EAEhF,SAAS,UAAU,EAAsB,CAErC,MADI,cAAc,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Q,GAAIE,EAASI,EAAQI,CAAI,CAAC,EACtG,KAAK,cAAckB,EAAQ1B,EAASI,EAAQI,CAAI,CAAC,CAC5D,CAEA,GAAI,2BAA2B,KAAKsB,CAAM,GAAKU,GAAgB,EAAG,CAC9D,IAAMI,EAAQ,aAAanD,EAAO+B,EAAQW,EAAUnC,CAAO,EAC3D,OAAO4C,EAAQ,KAAK,mBAAmBA,EAAM,OAAQA,EAAM,WAAY5C,EAASI,EAAQI,CAAI,CAAC,EAAI,IACrG,CAEA,IAAMqC,EAAOf,EAAO,MAAM,yCAAyC,EACnE,GAAIe,EAAM,CACN,IAAMnB,EAAS1B,EAAQ,SAAS,KAAK,GAAa2B,EAAU,OAASkB,EAAK,EAAE,EAC5E,OAAOnB,EAAS,KAAKA,EAAO,WAAW,KAAK,EAAU,IAAU,GAAGlC,IAAU,EAAI,GAAK,IAAI,OAAOY,CAAM,EAAE,QAAQM,EAAS,MAAM,CAAC,CAAC,KAAK;CAAI,CAAC,EAAI,IACpJ,CACA,OAAO,IACX"}
@@ -1,3 +1,3 @@
1
1
  import"./_virtual/_virtual/_rolldown/runtime.js";import{causedByProperties as e,contextRoots as t,identityProperties as n,primitiveTypes as r,sliceTypes as i}from"./language.js";import{DiagnosticCodes as a}from"./compiler/Diagnostics/DiagnosticCodes.js";import{legacyOptionalTypeLength as o}from"./compiler/Authoring/QuickFixes.js";import"./compiler/index.js";import{enclosingChain as s,fenceMap as c,indentOf as l}from"./document-context.js";import{eventAnalysisSource as u}from"./event-analysis-source.js";import{resolveEventContextPath as d}from"./event-context.js";import{responseAnalysis as f}from"./response-analysis.js";import{knownEventNames as p,knownTypeNames as m,mergeSymbols as h,propertyTypeReference as g,scanDocument as _,symbolsForBuffer as v}from"./symbols.js";import{diagnosticCodes as y}from"./diagnostic-codes.js";import{validateInlineEvents as b}from"./inline-event-validation.js";import{fileImportOn as x,isFileImportLine as S}from"./file-imports.js";function issue(e,t,n,r,i,a){return{severity:e,message:i,line:t,startColumn:n,endColumn:n+r,code:a}}function tokenIssue(e,t,n,r,i,a){return issue(e,t,n.indexOf(r)+1,r.length,i,a)}function validateDeclarations(e,t,n){let i=[],a=/* @__PURE__ */ new Set([...m(t,r),...m(n,[])]),checkProperties=(e,t)=>{for(let n of e.filter(e=>!a.has(g(e).name))){let e=g(n).name;i.push(issue(`warning`,n.line,n.sourceType.startColumn,n.sourceType.text.length,e===`optional`?`Unknown type 'optional' on '${n.name}' of ${t} — did you forget the type before 'optional'?`:`Unknown type '${e}' on '${n.name}' of ${t} — declare it with 'concept ${e} : <Primitive>' or 'type ${e}'.`,y.unknownType))}};for(let e of t.types)checkProperties(e.properties,`type '${e.name}'`);for(let e of t.events)checkProperties(e.properties,`event '${e.name}'`);for(let e of t.queries)checkProperties(e.parameters,`query '${e.name}'`);for(let n of t.commands){checkProperties(n.properties,`command '${n.name}'`);let t=n.properties.filter(e=>e.isIdentifier);for(let r of t.slice(1))i.push(tokenIssue(`error`,r.line,e[r.line],`identifier`,`Command '${n.name}' already marks '${t[0].name}' as identifier — only one property can be the identifier.`,y.duplicateCommandIdentifier))}let o=/* @__PURE__ */ new Map;for(let n of[...t.concepts,...t.types])o.get(n.name)===void 0?o.set(n.name,n.line):i.push(tokenIssue(`error`,n.line,e[n.line],n.name,`Duplicate declaration of '${n.name}' — concept and type names must be unique.`,y.duplicateDeclaration));return i}function validateLines(s,u={}){let d=c(s),m=_(s),g=u.application??h(),x=v(s,{...g,authoringPath:u.path??g.authoringPath,authoringPlacement:u.placement??g.authoringPlacement}),S=f(s,x.authoringDocuments??x.authoringSources?.filter(e=>e!==s.join(`
2
- `)),x.authoringPlacement,x.authoringPath,x.authoringPlacementResolved),C=new Set(S.eventSources.routes.map(e=>e.location.line-1)),w={...m,commands:m.commands.map(e=>({...e,properties:e.properties.filter(e=>!C.has(e.line)),produces:e.produces?.filter(e=>!S.operationProductionLines?.has(e.line)),productionHeaders:e.productionHeaders?.filter(e=>!S.operationProductionLines?.has(e))}))},T=/* @__PURE__ */ new Set([...p(w),...p(g)]),E=new Set([...w.policies,...g.policies].map(e=>e.name)),D=validateDeclarations(s,w,g);D.push(...validateProductionDestinations(s,w));let O=/* @__PURE__ */ new Set([a.UnknownGenerationStrategy,a.InvalidGenerationArgument,a.InvalidGenerationModifier,a.DuplicateGenerationModifier,a.DuplicateGeneration,a.InvalidGenerationPrimitive,a.InvalidGenerationPrefix,a.InvalidGenerationAlphabet,a.InvalidTypeIdPrefix,a.GenerationSizeOutsideRange,a.ReservedSequenceGeneration,a.LowGenerationEntropy,a.LowGeneratedIdentifierEntropy,a.RefutedGeneratedConceptRule,a.UnprovenGeneratedConceptRule,a.GenerationSupportBudgetExceeded,a.EmptyGenerationSupport]),k=/* @__PURE__ */ new Set([a.MixedEnumerationNumbering,a.DuplicateEnumerationNumber,a.EnumerationNumberOutsideInt32,a.MalformedEnumerationNumber,a.UnpinnedStoredEnumeration]),A=/* @__PURE__ */ new Set([a.LegacyOptionalSuffix,a.InvalidOptionalModifierOrder,a.OptionalReadsNotSupported]),j=/* @__PURE__ */ new Set([a.UnexpectedTokenInPolicyCondition,a.ExpectedPolicyCondition,a.UnclosedPolicyConditionGroup,a.ExpectedRoleName,a.ExpectedClaimName,a.ExpectedClaimMatches,a.ExpectedClaimMatchTarget]),M=/* @__PURE__ */ new Set([a.UnknownEvent,a.UnknownReadModelProperty,a.PiiNotSupportedOnIdentifier]),N=/* @__PURE__ */ new Set([a.EventFromLaterSlice,a.TimelineCycleGroup]),P=/* @__PURE__ */ new Set([a.UndeclaredDependency,a.UnusedDependencyDeclaration,a.InvalidDependencyTarget,a.RepeatedDependencyDeclaration,a.MutualDependencyDeclarations,a.AmbiguousReference]),F=/* @__PURE__ */ new Set([a.InvalidCommandReadsDeclaration,a.UnknownMatchPattern,a.InvalidMatchPattern,a.PatternOutsidePortableMatchDialect,a.AmbiguousMatchPattern,a.DeprecatedStudioTextRulePattern,a.MismatchedSpecificationQueryResult,a.DirectionlessTranslationReactsToOwnCapture,a.CaptureEventsFromSeveralOrigins,a.CaptureEventsKeyNotRequired,a.CaptureEventsRecordFixture,a.EventIdPinNotCarriedToRenderers,a.ResponseNameUsedOnFailure,a.InvalidEventDeclaration,a.InvalidImportDeclaration,a.InvalidSliceDeclaration,a.InvalidDescription,a.DuplicateDescription,a.EmptyDescription,a.DuplicateEventSubject,a.InvalidSubjectType,a.ProtectedSubjectType,a.InvalidSubjectOwner,a.ReadModelSubjectNotSupported,a.InvalidSubjectModifierOrder,a.UnsupportedInteractionAlternatives,a.MixedInteractionAlternatives,a.InteractionAlternativeWithoutActions,a.InlineInteractionAlternative,a.LegacyInteractionWhere,a.InvalidSpecificationParameter,a.InvalidSpecificationCase,a.DuplicateSpecificationParameter,a.DuplicateSpecificationCase,a.IncompleteSpecificationTable,a.InvalidSpecificationCaseAssignment,a.InvalidSpecificationCaseValue,a.InvalidSpecificationCaseReference,a.OptionalSpecificationParameterTarget,a.SpecificationCaseNameCollision,a.IncompatibleSpecificationParameterType,a.UnusedSpecificationParameter,a.SingularSpecificationTableExpansion,a.InvalidSpecificationCallerPersona,a.UnsynthesizablePersonaCaller,a.PersonaWithoutGate,a.GateWithoutPersona,a.AmbiguousPersonaCaller,a.InvalidDocumentation,a.ConflictingDocumentationAcrossFiles,a.InvalidAbsentReadModelStep,a.UnknownConstraintProperty,a.OmittedProductionDestination,a.InvalidSpecificationExample,a.DuplicateSpecificationAssignment,a.InvalidReactionBatchesDeclaration,a.DescribedCommandNotImplemented,a.DescribedCommandWithoutProductions,a.DescribedCommandCardinalityNotAdmitted,a.CommandHandlerRequiresAttachment,a.PendingIntentWithOtherHandler,a.DuplicateEventInProjectionScope,a.ReservedStoredName]),I=/* @__PURE__ */ new Set([a.InvalidPurposeDeclaration,a.InvalidPurposeVocabulary,a.DuplicatePurposeField,a.DuplicatePurposeDeclaration,a.UnknownPurpose,a.PurposeInterestMismatch,a.PersonalDataWithoutPurpose,a.SpecialDataWithoutCondition,a.CriminalDataWithoutAuthorization,a.PurposeWithoutBasis,a.UnusedPurpose,a.UnknownConceptDirective,a.AttributeReasonWithoutAttribute,a.DuplicateAttributeReason,a.LegacyComplianceMarker,a.DuplicateComplianceMarker,a.UnknownComplianceMarker,a.InvalidSecretScope,a.DuplicateSecretScope,a.SecretScopeIgnoredForPii,a.InvalidPersonalDataQualifier,a.DuplicateSpecialCategory]),L=/* @__PURE__ */ new Set;for(let e of u.compilerDiagnostics??S.diagnostics){let t=e.code===a.UnknownType&&(S.identityDetails??[]).some(t=>t.line===e.location.line-1),n=e.code===a.RepeatedSingularDeclarationAcrossFiles&&e.message.includes(`identity block`);if(!(e.code===a.DuplicateDeclaration&&e.message.startsWith(`Duplicate declaration of policy `))&&!t&&!n&&!O.has(e.code)&&!k.has(e.code)&&!I.has(e.code)&&!A.has(e.code)&&!j.has(e.code)&&!M.has(e.code)&&!N.has(e.code)&&!P.has(e.code)&&!F.has(e.code)&&e.code!==a.ReducerIdentityMismatch&&e.code!==a.InvalidSpecificationExampleBody&&e.code!==a.UnknownRuleImplementationDirective&&e.code!==a.InvalidValidationRule&&e.code!==a.RepeatedDeclarationAcrossFiles&&!/^PLAY049[0-9]$|^PLAY050[0-7]$|^PLAY054[7-9]$|^PLAY055[01]$|^PLAY048[2-9]$|^PLAY004[56]$|^PLAY053[0-9]$|^PLAY054[0-6]$|^PLAY034[1-8]$|^PLAY0557$|^PLAY060[7-9]$|^PLAY061[0-9]$|^PLAY0620$|^PLAY062[1-9]$|^PLAY063[0-9]$|^PLAY064[0-9]$|^PLAY065[0-2]$|^PLAY065[4-6]$|^PLAY066[0-6]$|^PLAY072[0-2]$/.test(e.code))continue;let r=e.location.line-1;if(e.code===a.OmittedProductionDestination&&D.some(t=>t.code===e.code&&t.line===r))continue;if(e.code===a.UnknownEvent){if(L.has(r))continue;L.add(r)}let i=o(s[r],e)||s[r].length-e.location.column+1;D.push(issue(e.severity,r,e.location.column,i,e.message,e.code))}let checkEvent=(e,t,n)=>{!T.has(n)&&!L.has(e)&&D.push(tokenIssue(`warning`,e,t,n,`Unknown event type '${n}' — declare it in a slice or import it.`,y.unknownEvent))},R=-1;for(let a=0;a<s.length;a++){let o=s[a],c=o.trim();if(d[a]||c.length===0)continue;let u=o.match(/^[ ]*(\t+)/);if(u&&D.push(issue(`warning`,a,u[0].length-u[1].length+1,u[1].length,`Screenplay is indentation-based — use spaces, not tabs.`,y.tabIndentation)),R>=0){if(l(o)>R&&/^(?:or\s+)?[A-Z]\w*(?:\s+or\s+[A-Z]\w*)*$/.test(c)){for(let e of c.split(/\s+/).filter(e=>e!==`or`))E.has(e)||D.push(tokenIssue(`warning`,a,o,e,`Unknown policy '${e}' — declare it with 'policy ${e}'.`,y.unknownPolicy));continue}R=-1}let f=validateImport(s,d,a);f&&D.push(f);let p=c.match(/^slice\s+(\w+)/);p&&!i.includes(p[1])&&D.push(tokenIssue(`error`,a,o,p[1],`Unknown slice type '${p[1]}' — expected ${i.join(`, `)}.`,y.unknownSliceType));let m=c.match(/^concept\s+\w+\s*:\s*(\w+)/);m&&m[1]!==`Enum`&&!r.includes(m[1])&&D.push(tokenIssue(`error`,a,o,m[1],`Unknown primitive type '${m[1]}' — expected ${r.join(`, `)} or Enum.`,y.unknownPrimitiveType));let h=c.match(/^authorize\s+(.*)$/);if(h){R=l(o);for(let e of h[1].split(/\s+/).filter(e=>e!==`or`&&e.length>0))E.has(e)||D.push(tokenIssue(`warning`,a,o,e,`Unknown policy '${e}' — declare it with 'policy ${e}'.`,y.unknownPolicy))}let g=c.match(/^on\s+([A-Z]\w*)\s*$/);g&&checkEvent(a,o,g[1]);let _=c.match(/^produces\s+([A-Z]\w*)\s*$/);if(_&&!S.operationProductionLines?.has(a)&&checkEvent(a,o,_[1]),/^produces\s+when\b/.test(c)&&!S.operationProductionLines?.has(a))for(let e=a+1;e<s.length;e++){let t=s[e];if(!(d[e]||t.trim().length===0)){if(l(t)>l(o)){let n=t.trim().match(/^([A-Z]\w*)\s*$/);n&&checkEvent(e,t,n[1])}break}}let v=c.match(/^unique\s+event\s+([A-Z]\w*)/);v&&checkEvent(a,o,v[1]);let b=c.match(/^unique\s+[a-z_]\w*\s+on\s+([A-Z]\w*)/);b&&checkEvent(a,o,b[1]);for(let e of o.match(/\$identity\.[\w.]+/g)??[]){let t=e.substring(10).split(`.`)[0],r=[...n,...(S.identityDetails??[]).map(e=>e.name)];r.includes(t)||D.push(tokenIssue(`warning`,a,o,e,`Unknown $identity property '${t}' — expected ${r.join(`, `)}.`,y.unknownContextIdentityProperty))}for(let r of o.match(/\$context\.[\w.]+/g)??[]){let i=r.substring(9).split(`.`);t.includes(i[0])?i[0]===`causedBy`&&i.length>1&&!e.includes(i[1])?D.push(tokenIssue(`warning`,a,o,r,`Unknown $context.causedBy property '${i[1]}' — expected ${e.join(`, `)}.`,y.unknownContextCausedByProperty)):i[0]===`identity`&&i.length>1&&!n.includes(i[1])&&D.push(tokenIssue(`warning`,a,o,r,`Unknown $context.identity property '${i[1]}' — expected ${n.join(`, `)}.`,y.unknownContextIdentityProperty)):D.push(tokenIssue(`warning`,a,o,r,`Unknown $context path '${i.join(`.`)}' — expected one of ${t.join(`, `)}.`,y.unknownContextPath))}}D.push(...validateEventContextPaths(s,d)),D.push(...b(s,w,g,S.operationProductionLines));let z=s.map((e,t)=>({line:e,index:t})).filter(({line:e})=>/^\s*```(?:[a-z]+)?\s*$/.test(e));if(z.length%2==1){let e=z[z.length-1];D.push(issue(`error`,e.index,1,e.line.length+1,"Unclosed inline code block — expected a closing ``` line.",y.unclosedCodeBlock))}return D}function validateProductionDestinations(e,t){let n=[];e=u(e);for(let r of t.commands){let t=r.properties.filter(e=>e.isIdentifier&&!g(e).isOptional&&!g(e).isCollection);if(t.length===1)for(let i of r.produces??[]){if(i.inline||i.conditional||i.target!==void 0)continue;let r=i.line;n.push(issue(`information`,r,l(e[r])+1,e[r].trim().length,`Plain 'produces ${i.name}' omits its destination — use 'for ${t[0].name}' to explicitly select the command's identifier.`,y.omittedProductionDestination))}}return n}function validateImport(e,t,n){let r=e[n],i=r.trim().replace(/\s*\/\/.*$/,``);if(!/^import\b/.test(i)||x(r,n))return;let a=l(r);if(a>0&&[`module`,`feature`].includes(s(e,t,n,a)[0])||S(r))return issue(`error`,n,a+1,i.length,`Invalid import '${i}' — inside a module or feature, import names files: 'import "<path or glob>"'.`,y.invalidFileImport)}const C=/^(?:(?:increment|decrement|count|clear|add|subtract|set)\s+)?@?([$\w.]+)(?=\s|=|$)/;function validateEventContextPaths(e,t){let n=[],names=e=>e.map(e=>e.name).join(`, `);for(let r=0;r<e.length;r++){let i=e[r];if(t[r])continue;for(let e of i.matchAll(/(\.)?\$eventContext((?:\.(?:\w+(?:\(\))?)?)*)/g)){let t=e[0].substring(e[1]?.length??0),i=e[2];if(i.length===0){e[1]&&n.push(issue(`error`,r,(e.index??0)+2,t.length,`'$eventContext' names no member - expected one of ${names(d(``).expected)}.`,y.missingEventContextPath));continue}let a=i.substring(1),o=d(a),s=(e.index??0)+(e[1]?.length??0)+1;switch(o.status){case`missing`:n.push(issue(`error`,r,s,t.length,`'$eventContext.${a}' names no member - expected one of ${names(o.expected)}.`,y.missingEventContextPath));break;case`unknownMember`:n.push(issue(`warning`,r,s,t.length,`Unknown event context member '${o.segment}' in '$eventContext.${a}' - expected one of ${names(o.expected)}.`,y.unknownEventContextMember));break;case`unknownSubPath`:{let e=o.expected.length===0?`no members to address`:`members ${names(o.expected)}`;n.push(issue(`warning`,r,s,t.length,`Unknown event context path '$eventContext.${a}' - '${o.member?.name}' (${o.member?.type}) has ${e}.`,y.unknownEventContextPath));break}case`belowCollection`:n.push(issue(`error`,r,s,t.length,`'$eventContext.${a}' cannot resolve - '${o.member?.name}' is a collection (${o.member?.type}) and cannot be addressed below.`,y.eventContextPathBelowCollection))}}let a=i.trim().match(C)?.[1],o=a?.match(/\.\$(\w+)/)?.[1];a&&o&&o!==`eventContext`&&n.push(tokenIssue(`warning`,r,i,a,`Dynamic dictionary key '$${o}' in '${a}' is never resolved - only '$eventContext.<path>' is, so the literal text '$${o}' becomes the key.`,y.unresolvedDynamicKeySource))}return n}export{validateEventContextPaths,validateLines};
2
+ `)),x.authoringPlacement,x.authoringPath,x.authoringPlacementResolved),C=new Set(S.eventSources.routes.map(e=>e.location.line-1)),w={...m,commands:m.commands.map(e=>({...e,properties:e.properties.filter(e=>!C.has(e.line)),produces:e.produces?.filter(e=>!S.operationProductionLines?.has(e.line)),productionHeaders:e.productionHeaders?.filter(e=>!S.operationProductionLines?.has(e))}))},T=/* @__PURE__ */ new Set([...p(w),...p(g)]),E=new Set([...w.policies,...g.policies].map(e=>e.name)),D=validateDeclarations(s,w,g);D.push(...validateProductionDestinations(s,w));let O=/* @__PURE__ */ new Set([a.UnknownGenerationStrategy,a.InvalidGenerationArgument,a.InvalidGenerationModifier,a.DuplicateGenerationModifier,a.DuplicateGeneration,a.InvalidGenerationPrimitive,a.InvalidGenerationPrefix,a.InvalidGenerationAlphabet,a.InvalidTypeIdPrefix,a.GenerationSizeOutsideRange,a.ReservedSequenceGeneration,a.LowGenerationEntropy,a.LowGeneratedIdentifierEntropy,a.RefutedGeneratedConceptRule,a.UnprovenGeneratedConceptRule,a.GenerationSupportBudgetExceeded,a.EmptyGenerationSupport]),k=/* @__PURE__ */ new Set([a.MixedEnumerationNumbering,a.DuplicateEnumerationNumber,a.EnumerationNumberOutsideInt32,a.MalformedEnumerationNumber,a.UnpinnedStoredEnumeration]),A=/* @__PURE__ */ new Set([a.LegacyOptionalSuffix,a.InvalidOptionalModifierOrder,a.OptionalReadsNotSupported]),j=/* @__PURE__ */ new Set([a.UnexpectedTokenInPolicyCondition,a.ExpectedPolicyCondition,a.UnclosedPolicyConditionGroup,a.ExpectedRoleName,a.ExpectedClaimName,a.ExpectedClaimMatches,a.ExpectedClaimMatchTarget,a.AnonymousPolicyCombined,a.NegatedAnonymousPolicy]),M=/* @__PURE__ */ new Set([a.UnknownEvent,a.UnknownReadModelProperty,a.PiiNotSupportedOnIdentifier]),N=/* @__PURE__ */ new Set([a.EventFromLaterSlice,a.TimelineCycleGroup]),P=/* @__PURE__ */ new Set([a.UndeclaredDependency,a.UnusedDependencyDeclaration,a.InvalidDependencyTarget,a.RepeatedDependencyDeclaration,a.MutualDependencyDeclarations,a.AmbiguousReference]),F=/* @__PURE__ */ new Set([a.InvalidCommandReadsDeclaration,a.UnknownMatchPattern,a.InvalidMatchPattern,a.PatternOutsidePortableMatchDialect,a.AmbiguousMatchPattern,a.DeprecatedStudioTextRulePattern,a.MismatchedSpecificationQueryResult,a.DirectionlessTranslationReactsToOwnCapture,a.CaptureEventsFromSeveralOrigins,a.CaptureEventsKeyNotRequired,a.CaptureEventsRecordFixture,a.EventIdPinNotCarriedToRenderers,a.ResponseNameUsedOnFailure,a.InvalidEventDeclaration,a.InvalidImportDeclaration,a.InvalidSliceDeclaration,a.InvalidDescription,a.DuplicateDescription,a.EmptyDescription,a.DuplicateEventSubject,a.InvalidSubjectType,a.ProtectedSubjectType,a.InvalidSubjectOwner,a.ReadModelSubjectNotSupported,a.InvalidSubjectModifierOrder,a.UnsupportedInteractionAlternatives,a.MixedInteractionAlternatives,a.InteractionAlternativeWithoutActions,a.InlineInteractionAlternative,a.LegacyInteractionWhere,a.InvalidSpecificationParameter,a.InvalidSpecificationCase,a.DuplicateSpecificationParameter,a.DuplicateSpecificationCase,a.IncompleteSpecificationTable,a.InvalidSpecificationCaseAssignment,a.InvalidSpecificationCaseValue,a.InvalidSpecificationCaseReference,a.OptionalSpecificationParameterTarget,a.SpecificationCaseNameCollision,a.IncompatibleSpecificationParameterType,a.UnusedSpecificationParameter,a.SingularSpecificationTableExpansion,a.InvalidSpecificationCallerPersona,a.UnsynthesizablePersonaCaller,a.PersonaWithoutGate,a.GateWithoutPersona,a.AmbiguousPersonaCaller,a.InvalidDocumentation,a.ConflictingDocumentationAcrossFiles,a.InvalidAbsentReadModelStep,a.UnknownConstraintProperty,a.OmittedProductionDestination,a.InvalidSpecificationExample,a.DuplicateSpecificationAssignment,a.InvalidReactionBatchesDeclaration,a.DescribedCommandNotImplemented,a.DescribedCommandWithoutProductions,a.DescribedCommandCardinalityNotAdmitted,a.CommandHandlerRequiresAttachment,a.PendingIntentWithOtherHandler,a.DuplicateEventInProjectionScope,a.ReservedStoredName]),I=/* @__PURE__ */ new Set([a.InvalidPurposeDeclaration,a.InvalidPurposeVocabulary,a.DuplicatePurposeField,a.DuplicatePurposeDeclaration,a.UnknownPurpose,a.PurposeInterestMismatch,a.PersonalDataWithoutPurpose,a.SpecialDataWithoutCondition,a.CriminalDataWithoutAuthorization,a.PurposeWithoutBasis,a.UnusedPurpose,a.UnknownConceptDirective,a.AttributeReasonWithoutAttribute,a.DuplicateAttributeReason,a.LegacyComplianceMarker,a.DuplicateComplianceMarker,a.UnknownComplianceMarker,a.InvalidSecretScope,a.DuplicateSecretScope,a.SecretScopeIgnoredForPii,a.InvalidPersonalDataQualifier,a.DuplicateSpecialCategory]),L=/* @__PURE__ */ new Set;for(let e of u.compilerDiagnostics??S.diagnostics){let t=e.code===a.UnknownType&&(S.identityDetails??[]).some(t=>t.line===e.location.line-1),n=e.code===a.RepeatedSingularDeclarationAcrossFiles&&e.message.includes(`identity block`);if(!(e.code===a.DuplicateDeclaration&&e.message.startsWith(`Duplicate declaration of policy `))&&!t&&!n&&!O.has(e.code)&&!k.has(e.code)&&!I.has(e.code)&&!A.has(e.code)&&!j.has(e.code)&&!M.has(e.code)&&!N.has(e.code)&&!P.has(e.code)&&!F.has(e.code)&&e.code!==a.ReducerIdentityMismatch&&e.code!==a.InvalidSpecificationExampleBody&&e.code!==a.UnknownRuleImplementationDirective&&e.code!==a.InvalidValidationRule&&e.code!==a.RepeatedDeclarationAcrossFiles&&!/^PLAY049[0-9]$|^PLAY050[0-7]$|^PLAY054[7-9]$|^PLAY055[01]$|^PLAY048[2-9]$|^PLAY004[56]$|^PLAY053[0-9]$|^PLAY054[0-6]$|^PLAY034[1-8]$|^PLAY0557$|^PLAY060[7-9]$|^PLAY061[0-9]$|^PLAY0620$|^PLAY062[1-9]$|^PLAY063[0-9]$|^PLAY064[0-9]$|^PLAY065[0-2]$|^PLAY065[4-6]$|^PLAY066[0-6]$|^PLAY072[0-2]$/.test(e.code))continue;let r=e.location.line-1;if(e.code===a.OmittedProductionDestination&&D.some(t=>t.code===e.code&&t.line===r))continue;if(e.code===a.UnknownEvent){if(L.has(r))continue;L.add(r)}let i=o(s[r],e)||s[r].length-e.location.column+1;D.push(issue(e.severity,r,e.location.column,i,e.message,e.code))}let checkEvent=(e,t,n)=>{!T.has(n)&&!L.has(e)&&D.push(tokenIssue(`warning`,e,t,n,`Unknown event type '${n}' — declare it in a slice or import it.`,y.unknownEvent))},R=-1;for(let a=0;a<s.length;a++){let o=s[a],c=o.trim();if(d[a]||c.length===0)continue;let u=o.match(/^[ ]*(\t+)/);if(u&&D.push(issue(`warning`,a,u[0].length-u[1].length+1,u[1].length,`Screenplay is indentation-based — use spaces, not tabs.`,y.tabIndentation)),R>=0){if(l(o)>R&&/^(?:or\s+)?[A-Z]\w*(?:\s+or\s+[A-Z]\w*)*$/.test(c)){for(let e of c.split(/\s+/).filter(e=>e!==`or`))E.has(e)||D.push(tokenIssue(`warning`,a,o,e,`Unknown policy '${e}' — declare it with 'policy ${e}'.`,y.unknownPolicy));continue}R=-1}let f=validateImport(s,d,a);f&&D.push(f);let p=c.match(/^slice\s+(\w+)/);p&&!i.includes(p[1])&&D.push(tokenIssue(`error`,a,o,p[1],`Unknown slice type '${p[1]}' — expected ${i.join(`, `)}.`,y.unknownSliceType));let m=c.match(/^concept\s+\w+\s*:\s*(\w+)/);m&&m[1]!==`Enum`&&!r.includes(m[1])&&D.push(tokenIssue(`error`,a,o,m[1],`Unknown primitive type '${m[1]}' — expected ${r.join(`, `)} or Enum.`,y.unknownPrimitiveType));let h=c.match(/^authorize\s+(.*)$/);if(h){R=l(o);for(let e of h[1].split(/\s+/).filter(e=>e!==`or`&&e.length>0))E.has(e)||D.push(tokenIssue(`warning`,a,o,e,`Unknown policy '${e}' — declare it with 'policy ${e}'.`,y.unknownPolicy))}let g=c.match(/^on\s+([A-Z]\w*)\s*$/);g&&checkEvent(a,o,g[1]);let _=c.match(/^produces\s+([A-Z]\w*)\s*$/);if(_&&!S.operationProductionLines?.has(a)&&checkEvent(a,o,_[1]),/^produces\s+when\b/.test(c)&&!S.operationProductionLines?.has(a))for(let e=a+1;e<s.length;e++){let t=s[e];if(!(d[e]||t.trim().length===0)){if(l(t)>l(o)){let n=t.trim().match(/^([A-Z]\w*)\s*$/);n&&checkEvent(e,t,n[1])}break}}let v=c.match(/^unique\s+event\s+([A-Z]\w*)/);v&&checkEvent(a,o,v[1]);let b=c.match(/^unique\s+[a-z_]\w*\s+on\s+([A-Z]\w*)/);b&&checkEvent(a,o,b[1]);for(let e of o.match(/\$identity\.[\w.]+/g)??[]){let t=e.substring(10).split(`.`)[0],r=[...n,...(S.identityDetails??[]).map(e=>e.name)];r.includes(t)||D.push(tokenIssue(`warning`,a,o,e,`Unknown $identity property '${t}' — expected ${r.join(`, `)}.`,y.unknownContextIdentityProperty))}for(let r of o.match(/\$context\.[\w.]+/g)??[]){let i=r.substring(9).split(`.`);t.includes(i[0])?i[0]===`causedBy`&&i.length>1&&!e.includes(i[1])?D.push(tokenIssue(`warning`,a,o,r,`Unknown $context.causedBy property '${i[1]}' — expected ${e.join(`, `)}.`,y.unknownContextCausedByProperty)):i[0]===`identity`&&i.length>1&&!n.includes(i[1])&&D.push(tokenIssue(`warning`,a,o,r,`Unknown $context.identity property '${i[1]}' — expected ${n.join(`, `)}.`,y.unknownContextIdentityProperty)):D.push(tokenIssue(`warning`,a,o,r,`Unknown $context path '${i.join(`.`)}' — expected one of ${t.join(`, `)}.`,y.unknownContextPath))}}D.push(...validateEventContextPaths(s,d)),D.push(...b(s,w,g,S.operationProductionLines));let z=s.map((e,t)=>({line:e,index:t})).filter(({line:e})=>/^\s*```(?:[a-z]+)?\s*$/.test(e));if(z.length%2==1){let e=z[z.length-1];D.push(issue(`error`,e.index,1,e.line.length+1,"Unclosed inline code block — expected a closing ``` line.",y.unclosedCodeBlock))}return D}function validateProductionDestinations(e,t){let n=[];e=u(e);for(let r of t.commands){let t=r.properties.filter(e=>e.isIdentifier&&!g(e).isOptional&&!g(e).isCollection);if(t.length===1)for(let i of r.produces??[]){if(i.inline||i.conditional||i.target!==void 0)continue;let r=i.line;n.push(issue(`information`,r,l(e[r])+1,e[r].trim().length,`Plain 'produces ${i.name}' omits its destination — use 'for ${t[0].name}' to explicitly select the command's identifier.`,y.omittedProductionDestination))}}return n}function validateImport(e,t,n){let r=e[n],i=r.trim().replace(/\s*\/\/.*$/,``);if(!/^import\b/.test(i)||x(r,n))return;let a=l(r);if(a>0&&[`module`,`feature`].includes(s(e,t,n,a)[0])||S(r))return issue(`error`,n,a+1,i.length,`Invalid import '${i}' — inside a module or feature, import names files: 'import "<path or glob>"'.`,y.invalidFileImport)}const C=/^(?:(?:increment|decrement|count|clear|add|subtract|set)\s+)?@?([$\w.]+)(?=\s|=|$)/;function validateEventContextPaths(e,t){let n=[],names=e=>e.map(e=>e.name).join(`, `);for(let r=0;r<e.length;r++){let i=e[r];if(t[r])continue;for(let e of i.matchAll(/(\.)?\$eventContext((?:\.(?:\w+(?:\(\))?)?)*)/g)){let t=e[0].substring(e[1]?.length??0),i=e[2];if(i.length===0){e[1]&&n.push(issue(`error`,r,(e.index??0)+2,t.length,`'$eventContext' names no member - expected one of ${names(d(``).expected)}.`,y.missingEventContextPath));continue}let a=i.substring(1),o=d(a),s=(e.index??0)+(e[1]?.length??0)+1;switch(o.status){case`missing`:n.push(issue(`error`,r,s,t.length,`'$eventContext.${a}' names no member - expected one of ${names(o.expected)}.`,y.missingEventContextPath));break;case`unknownMember`:n.push(issue(`warning`,r,s,t.length,`Unknown event context member '${o.segment}' in '$eventContext.${a}' - expected one of ${names(o.expected)}.`,y.unknownEventContextMember));break;case`unknownSubPath`:{let e=o.expected.length===0?`no members to address`:`members ${names(o.expected)}`;n.push(issue(`warning`,r,s,t.length,`Unknown event context path '$eventContext.${a}' - '${o.member?.name}' (${o.member?.type}) has ${e}.`,y.unknownEventContextPath));break}case`belowCollection`:n.push(issue(`error`,r,s,t.length,`'$eventContext.${a}' cannot resolve - '${o.member?.name}' is a collection (${o.member?.type}) and cannot be addressed below.`,y.eventContextPathBelowCollection))}}let a=i.trim().match(C)?.[1],o=a?.match(/\.\$(\w+)/)?.[1];a&&o&&o!==`eventContext`&&n.push(tokenIssue(`warning`,r,i,a,`Dynamic dictionary key '$${o}' in '${a}' is never resolved - only '$eventContext.<path>' is, so the literal text '$${o}' becomes the key.`,y.unresolvedDynamicKeySource))}return n}export{validateEventContextPaths,validateLines};
3
3
  //# sourceMappingURL=validation.js.map