@cratis/screenplay-language 4.75.0 → 4.76.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,4 +1,4 @@
1
- import{$ as Tn,A as P,B as L,C as cn,D as ln,E as mn,F as un,G as F,H as st,I as H,J as pn,K as B,L as xe,M as dn,N as we,O as hn,P as ee,Q as fn,R as yn,S as gn,T as bn,W as $n,X as Te,Y as vn,Z as xn,_ as wn,a as N,aa as kn,b as et,ba as ke,c as re,d as be,e as J,f as on,g as rn,h as $e,i as U,j as an,k as tt,l as ve,m as S,n as nt,o as X,p as ie,q as ot,r as rt,s as it,t as D,u as k,v as sn,w as E,x as z,y as V,z as at}from"./chunk-ZVFXYPUI.js";import{a as d}from"./chunk-AYDF3IFZ.js";var ct=/[\p{L}\p{Mn}\p{Nd}\p{Pc}]/u,lt=d(e=>`\\u${e.toString(16).padStart(4,"0")}`,"escape");function Cn(){let e="";for(let n=0;n<=65535;n++){if(!ct.test(String.fromCharCode(n)))continue;let t=n;for(;n<65535&&ct.test(String.fromCharCode(n+1));)n++;e+=lt(t)+(n>t?`-${lt(n)}`:"")}return e}d(Cn,"ranges");var G=Cn();var ut=new Set(["operation","system","eventsource"]),Ce={csharp:"csharp",typescript:"typescript",react:"typescript",html:"html",sql:"sql"};function mt(e){return`subLanguage_${e}`}d(mt,"subLanguageState");function Sn(e){let n=[...re.filter(t=>!ut.has(t)),...e.map(t=>t.keyword)];return[new RegExp(`^\\s*(?:${n.join("|")})\\b`),{token:"@rematch",next:"@pop"}]}d(Sn,"subLanguageExitRule");var Dn=[[/\/\/.*$/,"comment"],[/^(numbers)([ \t]+)(exact)(?=[ \t]*(?:(?:\/\/|#).*)?$)/,["keyword","white","keyword"]],[/\$(?:context|eventContext|eventSourceId|causedBy)(?:\.\w+)*/,"variable.predefined"],[/\$(?:env|secrets|strings)\.[\w.]+/,"variable.predefined"],[/\$\.[\w.]*/,"variable.predefined"],[/"(?:[^"\\]|\\.)*"/,"string"],[/"(?:[^"\\]|\\.)*$/,"string.invalid"],[/\d+(?:ms|s|m|h|d)\b/,"number"],[/-?\d+\.\d+/,"number.float"],[/-?\d+/,"number"],[/=>|==|!=|>=|<=|[><=:?]/,"operator"],[/[[\](),.]/,"delimiter"],[/\s+/,"white"]];function pt(e){let n={root:[[/^(eventsource)(\s+)([A-Za-z_]\w*)(?=\s*(?:\/\/.*)?$)/,["keyword","white","type.identifier"]],[/^(system)(\s+)([A-Z]\w*)(?=\s*(?:\/\/.*)?$)/,["keyword","white","type.identifier"]],[/^(\s*)(produces\s+operation)(\s+)([A-Z]\w*)(?=\s*(?:\/\/.*)?$)/,["white","keyword","white",{token:"type.identifier",next:"@operationBody.$1"}]],[/^(\s*)(given\s+operation)(\s+)([\w.]+)(\s+)(fails)(?=\s*(?:\/\/.*)?$)/,["white","keyword","white","type.identifier","white","keyword"]],[/^(\s*)(then\s+(?:operation|compensated))(\s+)([\w.]+)(?=\s*(?:\/\/.*)?$)/,["white","keyword","white","type.identifier"]],[new RegExp(`^(\\s*)(command)(\\s+)([A-Za-z_][${G}]*)(?=\\s*(?://.*)?$)`),["white","keyword","white",{token:"type.identifier",next:"@commandBody.$1"}]],[/^(\s*)(handler)(?=\s*(?:\/\/.*)?$)/,["white",{token:"keyword",next:"@handlerBody.$1"}]],[/^(\s*@?[a-z_]\w*\s+)([\w.]+(?:\[\])?(?:\?|\s+optional)?)(\s+)(generated)(\s+identifier|)(?=\s*(?:\/\/.*)?$)/,["identifier","type.identifier","white","keyword","keyword"]],[/^(\s*)(generated)(\s+)([a-z_]\w*)(\s*=(?!=|>))/,["white","keyword","white","identifier","operator"]],[/^(\s*)(then)(\s+)(returns)\b/,["white","keyword","white","keyword"]],[/^(\s*)(returns)(?=\s*(?:\/\/.*)?$|\s+@\w+\s*(?:\/\/.*)?$)/,["white","keyword"]],[/^(\s*(?:by|filter)\s+[a-z_]\w*\s+)([\w.]+(?:\[\])?)(\s+)(optional)\b(?=\s*(?:from\b|\/\/|$))/,["identifier","type.identifier","white","keyword"]],[/^(?!\s*(?:by|filter)\s+)(\s*@?[a-z_]\w*\s+)([\w.]+(?:\[\])?)(\s+)(optional)\b(?=\s*(?:identifier\b|from\b|=(?!=|>)|\/\/|$))/,["identifier","type.identifier","white","keyword"]],[/^(\s*query\s+[A-Za-z_]\w*\s*=>\s*(?!observable\s+optional\s*(?:\/\/.*)?$)(?:observable\s+)?)([\w.]+(?:\[\])?)(\s+)(optional)\b(?=\s*(?:\/\/.*)?$)/,["keyword","type.identifier","white","keyword"]],[/^(\s*)(given|when)(\s+)(clock|capture|trigger|query)\b/,["white","keyword","white","keyword"]],[/^(\s*)(then)(\s+)(result|no\s+result)\b/,["white","keyword","white","keyword"]],[/^(\s*)(import)(\s+)("[^"\\]*")/,["white","keyword","white","string.link"]],[/^(\s*)((?:produces\s+)?event)(\s+)([A-Za-z_]\w*)(\s+)(generation)(\s+)(\d+)(?=\s*(?:\/\/.*)?$)/,["white","keyword","white","type.identifier","white","keyword","white",{token:"number",next:"@eventBody.$1"}]],[/^(\s*)((?:produces\s+)?event)(\s+)([A-Za-z_]\w*)(?=\s*(?:\/\/.*)?$)/,["white","keyword","white",{token:"type.identifier",next:"@eventBody.$1"}]],...J.map(t=>[new RegExp(`^\\s*\\x60\\x60\\x60${t}\\s*$`),{token:"string.quote",next:`@codeBlock.${Ce[t]}`,nextEmbedded:Ce[t]}]),...J.map(t=>[new RegExp(`\\b${t}\\b(?=\\s*$)`),{token:"keyword.tag",next:`@codeBlockPending.${Ce[t]}`}]),...e.map(t=>[new RegExp(`\\b${t.keyword}\\b`),{token:"keyword",next:`@${mt(t.keyword)}`}]),[/\bdescription\b(?=\s*$)/,{token:"keyword",next:"@descriptionBlockPending"}],[/\brow-click\b/,"keyword"],[/^\s*@[a-z_]\w*/,"identifier"],[/@\w+/,"annotation"],[/[A-Z]\w*/,{cases:{"@sliceTypes":"keyword.type","@primitiveTypes":"type","@default":"type.identifier"}}],[/[a-z_]\w*/,{cases:{"@keywords":"keyword","@default":"identifier"}}],{include:"@common"}],commandBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[/^(\s*)(validate)(?=\s*(?:\/\/.*)?$)/,["white",{token:"keyword",next:"@commandValidation.$1"}]],{include:"@root"}],commandValidation:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[new RegExp(`^(\\s*)([${G}.]+)(\\s+)(rule)(\\s+)([A-Za-z_][${G}]*)(?=\\s*(?:severity\\s+\\w+|message\\s+.*|//.*|$))`),["white","identifier","white","keyword","white",{token:"type.identifier",next:"@namedRuleBody.$1"}]],{include:"@root"}],namedRuleBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[/^(\s*)(implementation)(?=\s*(?:\/\/.*)?$)/,["white",{token:"keyword",next:"@implementationBody.$1"}]],{include:"@root"}],operationBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[/^(\s*)(execute|compensate)(?=\s*(?:\/\/.*)?$)/,["white",{token:"keyword",next:"@operationPhase.$1"}]],[/^(\s*)(uses)(\s+)([A-Z]\w*)(?=\s*(?:\/\/.*)?$)/,["white","keyword","white","type.identifier"]],[/^(\s*)(@?[a-z_]\w*)(\s+)([\w.]+(?:\[\])?(?:\?|\s+optional)?)(?=\s*(?:=(?!=|>)|\/\/|$))/,["white","identifier","white","type.identifier"]],{include:"@root"}],operationPhase:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[/^(\s*)(implementation)(?=\s*(?:\/\/.*)?$)/,["white",{token:"keyword",next:"@implementationBody.$1"}]],{include:"@root"}],handlerBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[/^(\s*)(implementation)(?=\s*(?:\/\/.*)?$)/,["white",{token:"keyword",next:"@implementationBody.$1"}]],{include:"@root"}],implementationBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[/^(\s*)(hint)(?=\s+")/,["white","keyword"]],{include:"@root"}],eventBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[/^(\s*)(id)(?=\s+")/,["white","keyword"]],[/^(\s*)(documentation)(?=\s*(?:\/\/.*)?$)/,["white",{token:"keyword",next:"@descriptionBlockPending"}]],{include:"@root"}],common:Dn,codeBlockPending:[[/^\s*```\s*$/,{token:"string.quote",switchTo:"@codeBlock.$S2",nextEmbedded:"$S2"}],[/^\s*[^\s`].*$/,{token:"@rematch",next:"@pop"}],[/\s+/,"white"]],codeBlock:[[/^\s*```\s*$/,{token:"string.quote",next:"@pop",nextEmbedded:"@pop"}],[/[^`]+/,""],[/`/,""]],descriptionBlockPending:[[/\/\/.*$/,"comment"],[/^\s*```(?:text|markdown)?\s*$/,{token:"string.quote",switchTo:"@descriptionBlock"}],[/^\s*[^\s`].*$/,{token:"@rematch",next:"@pop"}],[/\s+/,"white"]],descriptionBlock:[[/^\s*```\s*$/,{token:"string.quote",next:"@pop"}],[/.+/,"string"]]};for(let t of e)n[mt(t.keyword)]=[Sn(e),...t.tokens,{include:"@common"},[/[A-Z]\w*/,"type.identifier"],[/[a-z_]\w*/,"identifier"]];return{defaultToken:"",tokenPostfix:".play",ignoreCase:!1,keywords:[...re.filter(t=>!ut.has(t)),...be,...J],sliceTypes:$e,primitiveTypes:U,tokenizer:n}}d(pt,"createTokensProvider");var ae=[{label:"optional",insertText:"optional",documentation:"Allows the complete value, including a collection, to be absent."}],R=d(e=>`\`\`\`${e}
1
+ import{$ as Tn,A as P,B as L,C as cn,D as ln,E as mn,F as un,G as F,H as st,I as H,J as pn,K as B,L as xe,M as dn,N as we,O as hn,P as ee,Q as fn,R as yn,S as gn,T as bn,W as $n,X as Te,Y as vn,Z as xn,_ as wn,a as N,aa as kn,b as et,ba as ke,c as re,d as be,e as J,f as on,g as rn,h as $e,i as U,j as an,k as tt,l as ve,m as S,n as nt,o as X,p as ie,q as ot,r as rt,s as it,t as D,u as k,v as sn,w as E,x as z,y as V,z as at}from"./chunk-TGHEJ4MY.js";import{a as d}from"./chunk-AYDF3IFZ.js";var ct=/[\p{L}\p{Mn}\p{Nd}\p{Pc}]/u,lt=d(e=>`\\u${e.toString(16).padStart(4,"0")}`,"escape");function Cn(){let e="";for(let n=0;n<=65535;n++){if(!ct.test(String.fromCharCode(n)))continue;let t=n;for(;n<65535&&ct.test(String.fromCharCode(n+1));)n++;e+=lt(t)+(n>t?`-${lt(n)}`:"")}return e}d(Cn,"ranges");var G=Cn();var ut=new Set(["operation","system","eventsource"]),Ce={csharp:"csharp",typescript:"typescript",react:"typescript",html:"html",sql:"sql"};function mt(e){return`subLanguage_${e}`}d(mt,"subLanguageState");function Sn(e){let n=[...re.filter(t=>!ut.has(t)),...e.map(t=>t.keyword)];return[new RegExp(`^\\s*(?:${n.join("|")})\\b`),{token:"@rematch",next:"@pop"}]}d(Sn,"subLanguageExitRule");var Dn=[[/\/\/.*$/,"comment"],[/^(numbers)([ \t]+)(exact)(?=[ \t]*(?:(?:\/\/|#).*)?$)/,["keyword","white","keyword"]],[/\$(?:context|eventContext|eventSourceId|causedBy)(?:\.\w+)*/,"variable.predefined"],[/\$(?:env|secrets|strings)\.[\w.]+/,"variable.predefined"],[/\$\.[\w.]*/,"variable.predefined"],[/"(?:[^"\\]|\\.)*"/,"string"],[/"(?:[^"\\]|\\.)*$/,"string.invalid"],[/\d+(?:ms|s|m|h|d)\b/,"number"],[/-?\d+\.\d+/,"number.float"],[/-?\d+/,"number"],[/=>|==|!=|>=|<=|[><=:?]/,"operator"],[/[[\](),.]/,"delimiter"],[/\s+/,"white"]];function pt(e){let n={root:[[/^(eventsource)(\s+)([A-Za-z_]\w*)(?=\s*(?:\/\/.*)?$)/,["keyword","white","type.identifier"]],[/^(system)(\s+)([A-Z]\w*)(?=\s*(?:\/\/.*)?$)/,["keyword","white","type.identifier"]],[/^(\s*)(produces\s+operation)(\s+)([A-Z]\w*)(?=\s*(?:\/\/.*)?$)/,["white","keyword","white",{token:"type.identifier",next:"@operationBody.$1"}]],[/^(\s*)(given\s+operation)(\s+)([\w.]+)(\s+)(fails)(?=\s*(?:\/\/.*)?$)/,["white","keyword","white","type.identifier","white","keyword"]],[/^(\s*)(then\s+(?:operation|compensated))(\s+)([\w.]+)(?=\s*(?:\/\/.*)?$)/,["white","keyword","white","type.identifier"]],[new RegExp(`^(\\s*)(command)(\\s+)([A-Za-z_][${G}]*)(?=\\s*(?://.*)?$)`),["white","keyword","white",{token:"type.identifier",next:"@commandBody.$1"}]],[/^(\s*)(handler)(?=\s*(?:\/\/.*)?$)/,["white",{token:"keyword",next:"@handlerBody.$1"}]],[/^(\s*@?[a-z_]\w*\s+)([\w.]+(?:\[\])?(?:\?|\s+optional)?)(\s+)(generated)(\s+identifier|)(?=\s*(?:\/\/.*)?$)/,["identifier","type.identifier","white","keyword","keyword"]],[/^(\s*)(generated)(\s+)([a-z_]\w*)(\s*=(?!=|>))/,["white","keyword","white","identifier","operator"]],[/^(\s*)(then)(\s+)(returns)\b/,["white","keyword","white","keyword"]],[/^(\s*)(returns)(?=\s*(?:\/\/.*)?$|\s+@\w+\s*(?:\/\/.*)?$)/,["white","keyword"]],[/^(\s*(?:by|filter)\s+[a-z_]\w*\s+)([\w.]+(?:\[\])?)(\s+)(optional)\b(?=\s*(?:from\b|\/\/|$))/,["identifier","type.identifier","white","keyword"]],[/^(?!\s*(?:by|filter)\s+)(\s*@?[a-z_]\w*\s+)([\w.]+(?:\[\])?)(\s+)(optional)\b(?=\s*(?:identifier\b|from\b|=(?!=|>)|\/\/|$))/,["identifier","type.identifier","white","keyword"]],[/^(\s*query\s+[A-Za-z_]\w*\s*=>\s*(?!observable\s+optional\s*(?:\/\/.*)?$)(?:observable\s+)?)([\w.]+(?:\[\])?)(\s+)(optional)\b(?=\s*(?:\/\/.*)?$)/,["keyword","type.identifier","white","keyword"]],[/^(\s*)(given|when)(\s+)(clock|capture|trigger|query)\b/,["white","keyword","white","keyword"]],[/^(\s*)(then)(\s+)(result|no\s+result)\b/,["white","keyword","white","keyword"]],[/^(\s*)(import)(\s+)("[^"\\]*")/,["white","keyword","white","string.link"]],[/^(\s*)((?:produces\s+)?event)(\s+)([A-Za-z_]\w*)(\s+)(generation)(\s+)(\d+)(?=\s*(?:\/\/.*)?$)/,["white","keyword","white","type.identifier","white","keyword","white",{token:"number",next:"@eventBody.$1"}]],[/^(\s*)((?:produces\s+)?event)(\s+)([A-Za-z_]\w*)(?=\s*(?:\/\/.*)?$)/,["white","keyword","white",{token:"type.identifier",next:"@eventBody.$1"}]],...J.map(t=>[new RegExp(`^\\s*\\x60\\x60\\x60${t}\\s*$`),{token:"string.quote",next:`@codeBlock.${Ce[t]}`,nextEmbedded:Ce[t]}]),...J.map(t=>[new RegExp(`\\b${t}\\b(?=\\s*$)`),{token:"keyword.tag",next:`@codeBlockPending.${Ce[t]}`}]),...e.map(t=>[new RegExp(`\\b${t.keyword}\\b`),{token:"keyword",next:`@${mt(t.keyword)}`}]),[/\bdescription\b(?=\s*$)/,{token:"keyword",next:"@descriptionBlockPending"}],[/\brow-click\b/,"keyword"],[/^\s*@[a-z_]\w*/,"identifier"],[/@\w+/,"annotation"],[/[A-Z]\w*/,{cases:{"@sliceTypes":"keyword.type","@primitiveTypes":"type","@default":"type.identifier"}}],[/[a-z_]\w*/,{cases:{"@keywords":"keyword","@default":"identifier"}}],{include:"@common"}],commandBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[/^(\s*)(validate)(?=\s*(?:\/\/.*)?$)/,["white",{token:"keyword",next:"@commandValidation.$1"}]],{include:"@root"}],commandValidation:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[new RegExp(`^(\\s*)([${G}.]+)(\\s+)(rule)(\\s+)([A-Za-z_][${G}]*)(?=\\s*(?:severity\\s+\\w+|message\\s+.*|//.*|$))`),["white","identifier","white","keyword","white",{token:"type.identifier",next:"@namedRuleBody.$1"}]],{include:"@root"}],namedRuleBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[/^(\s*)(implementation)(?=\s*(?:\/\/.*)?$)/,["white",{token:"keyword",next:"@implementationBody.$1"}]],{include:"@root"}],operationBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[/^(\s*)(execute|compensate)(?=\s*(?:\/\/.*)?$)/,["white",{token:"keyword",next:"@operationPhase.$1"}]],[/^(\s*)(uses)(\s+)([A-Z]\w*)(?=\s*(?:\/\/.*)?$)/,["white","keyword","white","type.identifier"]],[/^(\s*)(@?[a-z_]\w*)(\s+)([\w.]+(?:\[\])?(?:\?|\s+optional)?)(?=\s*(?:=(?!=|>)|\/\/|$))/,["white","identifier","white","type.identifier"]],{include:"@root"}],operationPhase:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[/^(\s*)(implementation)(?=\s*(?:\/\/.*)?$)/,["white",{token:"keyword",next:"@implementationBody.$1"}]],{include:"@root"}],handlerBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[/^(\s*)(implementation)(?=\s*(?:\/\/.*)?$)/,["white",{token:"keyword",next:"@implementationBody.$1"}]],{include:"@root"}],implementationBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[/^(\s*)(hint)(?=\s+")/,["white","keyword"]],{include:"@root"}],eventBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:"@rematch",next:"@pop"}],[/^(\s*)(id)(?=\s+")/,["white","keyword"]],[/^(\s*)(documentation)(?=\s*(?:\/\/.*)?$)/,["white",{token:"keyword",next:"@descriptionBlockPending"}]],{include:"@root"}],common:Dn,codeBlockPending:[[/^\s*```\s*$/,{token:"string.quote",switchTo:"@codeBlock.$S2",nextEmbedded:"$S2"}],[/^\s*[^\s`].*$/,{token:"@rematch",next:"@pop"}],[/\s+/,"white"]],codeBlock:[[/^\s*```\s*$/,{token:"string.quote",next:"@pop",nextEmbedded:"@pop"}],[/[^`]+/,""],[/`/,""]],descriptionBlockPending:[[/\/\/.*$/,"comment"],[/^\s*```(?:text|markdown)?\s*$/,{token:"string.quote",switchTo:"@descriptionBlock"}],[/^\s*[^\s`].*$/,{token:"@rematch",next:"@pop"}],[/\s+/,"white"]],descriptionBlock:[[/^\s*```\s*$/,{token:"string.quote",next:"@pop"}],[/.+/,"string"]]};for(let t of e)n[mt(t.keyword)]=[Sn(e),...t.tokens,{include:"@common"},[/[A-Z]\w*/,"type.identifier"],[/[a-z_]\w*/,"identifier"]];return{defaultToken:"",tokenPostfix:".play",ignoreCase:!1,keywords:[...re.filter(t=>!ut.has(t)),...be,...J],sliceTypes:$e,primitiveTypes:U,tokenizer:n}}d(pt,"createTokensProvider");var ae=[{label:"optional",insertText:"optional",documentation:"Allows the complete value, including a collection, to be absent."}],R=d(e=>`\`\`\`${e}
2
2
  \${1}
3
3
  \`\`\``,"fenced"),dt=[{label:"eventsource",insertText:"eventsource ${1:Name}\n identifier ${2:Type}\n stream ${3:Name}",documentation:"Application-owned source with nested streams; not admitted by any supported executable model (ESM) version yet (PLAY0268)."},{label:"system",insertText:'system ${1:Name}\n description "${2:external system}"',documentation:"Application-scoped external system; not admitted by any supported executable model (ESM) version yet."},{label:"import",insertText:"import ${1:Module}.${2:Type}",documentation:"Imports a type from another module by its qualified name."},{label:'import "\u2026"',insertText:'import "${1:**/*.play}"',documentation:"Imports other `.play` files by path or glob, relative to this file's folder, as whole documents of the application."},{label:"concept",insertText:"concept ${1:Name} : ${2|Uuid,String,Int,Decimal,Bool,Date,DateTime|}",documentation:"Declares a formalized value type wrapping a primitive."},{label:"concept (enum)",insertText:"concept ${1:Name} : Enum\n ${2:value}",documentation:"Declares an enumeration concept with a fixed set of values."},{label:"concept (@pii with reason)",insertText:'concept ${1:Name} : ${2|String,Uuid,Int,Decimal,Bool,Date,DateTime|} @pii\n pii reason "${3:why this is personal data, its purpose and lawful basis}"',documentation:"Declares a personal-data concept together with the reason it is personal data."},{label:"type",insertText:"type ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares a composite value type \u2014 a named shape built from several properties."},{label:"policy",insertText:"policy ${1:Name}\n require ${2:authenticated}",documentation:"Declares a named authorization rule for commands and queries."},{label:"module",insertText:"module ${1:Name}\n ",documentation:"Declares the top-level namespace \u2014 maps to a bounded context."},{label:"domain",insertText:"domain ${1:Name}",documentation:"The domain the file belongs to \u2014 optional, at most one per file, before everything else."},{label:"persona",insertText:'persona ${1:Name}\n description "${2:who they are}"',documentation:"A named role interacting with the application, with the policies it holds."},{label:"authentication",insertText:"authentication\n provider ${1:Name}\n ${2:setting} ${3:value}",documentation:"Declares the identity providers of the application \u2014 at most one block per file."},{label:"seed",insertText:"seed\n for ${1:EventSourceId}\n ${2:EventType}",documentation:"Declares events to seed into the event store per event source id."},{label:"layout",insertText:"layout ${1:Name}\n ${2:slot}",documentation:"Declares the application shell with named slots."},{label:"theme",insertText:"theme ${1:Name}\n compatible with ${2:Package}",documentation:"Declares a theme and the component packages it is compatible with."},{label:"ui profile",insertText:"ui profile ${1:Name}\n target platform ${2:web}\n layout ${3:Layout}\n theme ${4:Theme}",documentation:"Binds a target platform and size to a layout, theme and component packages."},{label:"behavior",insertText:"behavior ${1:Name}\n on ${2:click}\n ${3:execute command}",documentation:"A named interaction wiring, attached to a screen, form or dialog with `uses`."},{label:"trigger",insertText:"trigger ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares an integration signal a reaction can run on."}],Q=[{label:"uses",insertText:"uses ${1:System}",documentation:"Exactly one application-scoped external system."},{label:"description",insertText:'description "${1:intent}"',documentation:"Describes operation intent, without requiring code."},{label:"input",insertText:"${1:input} ${2:Type}",documentation:"Typed operation input; no identifier or generated modifier."},{label:"execute",insertText:'execute\n description "${1:effect}"',documentation:"Optional execution intent; not admitted by any supported executable model (ESM) version yet."},{label:"compensate",insertText:'compensate\n description "${1:undo intent}"',documentation:"Optional compensation intent; not admitted by any supported executable model (ESM) version yet."}],te=[{label:"hint",insertText:'hint "${1:implementation guidance}"',documentation:"Ordered authoring guidance; not an executable implementation role."},{label:"file",insertText:"file ${1:Path}",documentation:"Selects the phase\u2019s sole source attachment."},...["csharp","typescript","react","html","sql"].map(e=>({label:e,insertText:R(e),documentation:"Selects the phase\u2019s sole inline source; not admitted by any supported executable model (ESM) version yet."}))],se=[{label:"description",insertText:'description "${1:phase intent}"',documentation:"A description-only phase is valid, pending intent."},{label:"implementation",insertText:'implementation\n hint "${1:guidance}"',documentation:"Hints with optional source; phase owns File/Code, wrapper owns hints only."},...te.filter(e=>e.label!=="hint")],ht=[{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"pii reason",insertText:'pii reason "${1:why this is personal data, its purpose and lawful basis}"',documentation:"Records why the `@pii` marker applies \u2014 purpose, lawful basis, whose subject it lives under."},{label:"sensitive reason",insertText:'sensitive reason "${1:why this value is sensitive}"',documentation:"Records why the `@sensitive` marker applies."},{label:"validate",insertText:'validate\n ${1:not empty} message "${2:message}"',documentation:"Validation rules that travel with the value everywhere it appears."}],ft=[{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"description",insertText:'description "${1:what this shape represents}"',documentation:"A human-readable description of the type."},{label:"property",insertText:"${1:property} ${2:Type}",documentation:"A property of the type \u2014 a name and a type reference."}],yt=[{label:'import "\u2026"',insertText:'import "${1:*/*.play}"',documentation:"Imports `.play` files into this module \u2014 their top level is the module's body, so they hold features and module members without restating the module."},{label:"layout",insertText:"layout ${1:Name}\n template\n ${2:slot}",documentation:"Declares a reusable screen template with named slots."},{label:"feature",insertText:"feature ${1:Name}\n ",documentation:"Groups related slices into a vertical feature."},{label:"description",insertText:'description "${1:what this module is for}"',documentation:"A human-readable description."},{label:"authorize",insertText:"authorize ${1:PolicyName}",documentation:"Policies that must pass for everything in the module."},{label:"screen",insertText:"screen ${1:Name}\n data ${2:ReadModel} via query ${3:QueryName}",documentation:"Declares a module-level UI screen."},{label:"dialog",insertText:"dialog ${1:Name}\n ${2:body}",documentation:"Declares a dialog opened over the shell."},{label:"form",insertText:'form ${1:Name} for ${2:Command}\n field ${3:property} label "${4:Label}"',documentation:"Declares a form bound to a command."},{label:"contribute",insertText:'contribute to ${1:Navigation}\n navigate to ${2:Screen}\n label "${3:Label}"',documentation:"Contributes an entry to a named slot of the shell, such as navigation."}],gt=[{label:'import "\u2026"',insertText:'import "${1:*.play}"',documentation:"Imports `.play` files into this feature \u2014 their top level is the feature's body, so they hold slices and nested features without restating where they belong."},{label:"feature",insertText:"feature ${1:Name}\n ",documentation:"Declares a nested sub-feature."},{label:"contribute",insertText:'contribute to ${1:Navigation}\n navigate to ${2:Screen}\n label "${3:Label}"',documentation:"Contributes an entry to a named slot of the shell, such as navigation."},{label:"slice StateChange",insertText:"slice StateChange ${1:Name}\n ",documentation:"A command \u2192 events flow; something that changes the system."},{label:"slice StateView",insertText:"slice StateView ${1:Name}\n ",documentation:"A query + projection + screen; something that reads the system."},{label:"slice Automation",insertText:"slice Automation ${1:Name}\n ",documentation:"A reaction or reducer; something that runs when something happens."},{label:"slice Translate",insertText:"slice Translate ${1:Name}\n ",documentation:"A capture; converts external data into events."}],bt=[{label:"operation",insertText:"operation ${1:Name}\n uses ${2:System}\n ${3:input} ${4:Type}",documentation:"Reusable slice-owned operation intent; not admitted by any supported executable model (ESM) version yet."},{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"event",insertText:"event ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares an event type \u2014 an immutable, past-tense fact."},{label:"event generation",insertText:"event ${1:Name} generation ${2:2}\n ${3:property} ${4:Type}",documentation:"Declares a complete numbered event generation; start at 1 and do not skip a number."},{label:"command",insertText:"command ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares a command \u2014 an imperative intent that produces events."},{label:"query",insertText:"query ${1:Name} => ${2:ReadModel}",documentation:"Declares a read-side entry point mapping to a return type."},{label:"query observable",insertText:"query ${1:Name} => observable ${2:ReadModel}",documentation:"Declares a live read \u2014 the query keeps pushing as the read model changes, instead of answering once."},{label:"readmodel",insertText:"readmodel ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares the shape of a read model \u2014 its properties \u2014 that a projection, reducer or query fills and returns."},{label:"reducer",insertText:"reducer ${1:Name} => ${2:ReadModel}\n on ${3:EventType}\n ```csharp\n ${4}\n ```",documentation:"Declares a reducer building a read model from events with imperative code, for what a projection cannot express."},{label:"specification",insertText:"specification ${1:Name}\n given ${2:EventType}\n when ${3:Command}\n then ${4:EventType}",documentation:"Given/when/then acceptance criteria for the slice."},{label:"projection",insertText:"projection ${1:Name} => ${2:ReadModel}\n from ${3:EventType}",documentation:"Declares how events project into a read model (PDL)."},{label:"capture",insertText:"capture ${1:Name}\n source ${2:api}",documentation:"Declares a change data capture converting external data into events (CDL)."},{label:"reaction",insertText:"reaction ${1:Name}\n when ${2:Trigger}",documentation:"Declares behavior that runs when something happens."},{label:"screen",insertText:"screen ${1:Name}\n data ${2:ReadModel} via query ${3:QueryName}",documentation:"Declares a UI screen."},{label:"constraint",insertText:"constraint ${1:Name}\n unique ${2:property} on ${3:EventType}",documentation:"Declares a server-side rule enforced before events are committed."}],$t=[{label:"produces operation",insertText:"produces operation ${1:Name}\n uses ${2:System}\n ${3:input} ${4:Type} = ${5:source}",documentation:"Declares ordered operation intent; not admitted by any supported executable model (ESM) version yet (PLAY0268)."},{label:"returns property",insertText:"returns @${1:property}",documentation:"Scalar response from a direct command property, only on acceptance. Executable as ESM v7."},{label:"returns block",insertText:"returns\n ${1:field} = ${2:property}",documentation:"Unnamed record response with inferred or explicit field types, only on acceptance. Executable as ESM v7."},{label:"produces event",insertText:"produces event ${1:Name}\n ${2:property} ${3:Type} = ${4:source}",documentation:"Declares a slice-owned generation-1 event and maps its properties. An omitted for uses the command identifier."},{label:"identifier property",insertText:"${1:property} ${2:Type} identifier",documentation:"Marks the property a runtime resolves the event source id from. At most one per command."},{label:"authorize",insertText:"authorize ${1:PolicyName}",documentation:"References the policies that must pass for the command to execute."},{label:"reads",insertText:"reads ${1:View} by ${2:property}",documentation:"Declares a view the command consults. Executable binding is not yet supported."},{label:"reads as",insertText:"reads ${1:View} as ${2:alias} by ${3:property}",documentation:"Names one instance of a view; every instance needs a unique alias when reading the same view more than once."},{label:"validate",insertText:'validate\n ${1:property} not empty message "${2:message}"',documentation:"Declarative validation rules with messages."},{label:"validate csharp",insertText:`validate
4
4
  ${R("csharp")}`,documentation:"Imperative validation in C#, yielding the message of every rule the artifact breaks."},{label:"produces",insertText:"produces ${1:EventType}\n ${2:property} = ${3:source}",documentation:"Declares the event the command emits, with property mappings."},{label:"produces when",insertText:"produces when ${1:condition}\n ${2:EventType}\n ${3:property} = ${4:source}",documentation:"Conditionally emits an event when the condition holds."},{label:"handler",insertText:`handler
@@ -1,4 +1,4 @@
1
- import{R as ne,S as re,T as ie,U as q,V as oe,ca as se,w as te}from"../../chunk-ZVFXYPUI.js";import{a as C}from"../../chunk-AYDF3IFZ.js";var E="pdl",ce=["projection","sequence","all","every","on","from","key","parent","join","automap","no","children","nested","identified","by","add","subtract","remove","via","with","default","increment","decrement","count","set","unset","clear","events","id","exclude","variant","enters"],pe=["$eventSourceId","$causedBy","$eventContext"],me=["=","+=","-=","=>","."],ae={comments:{lineComment:"#"},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"},{open:"`",close:"`"}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"},{open:"`",close:"`"}],indentationRules:{increaseIndentPattern:/^.*(:|\bon\b|\ball\b|\bevery\b|\bchildren\b|\bnested\b|\bparent\b|\bvariant\b)\s*$/,decreaseIndentPattern:/^.*\}.*$/},folding:{offSide:!0,markers:{start:/^\s*(projection|all|every|on|children|nested|parent|variant)/,end:/^\s*$/}},wordPattern:/@?[a-zA-Z_$][\w$-]*/},de={defaultToken:"",tokenPostfix:".pdl",keywords:ce,builtins:pe,operators:me,symbols:/[=><!~?:&|+\-*/^%]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,tokenizer:{root:[{include:"@whitespace"},[/`/,{token:"string.template",next:"@templateString"}],[/@[a-zA-Z_$][\w$]*/,"identifier.escape"],[/[A-Z][a-zA-Z_$][\w$]*/,{cases:{"@keywords":"invalid","@default":"identifier"}}],[/[a-z_$][\w$]*/,{cases:{"@keywords":"keyword","@builtins":"variable.predefined","@default":"identifier"}}],[/[{}()[\]]/,"@brackets"],[/=>/,"operator.arrow"],[/@symbols/,{cases:{"@operators":"operator","@default":""}}],[/\d*\.\d+([eE][-+]?\d+)?/,"number.float"],[/0[xX][0-9a-fA-F]+/,"number.hex"],[/\d+/,"number"],[/[;,.]/,"delimiter"],[/"([^"\\]|\\.)*$/,"string.invalid"],[/"/,{token:"string.quote",next:"@string"}]],whitespace:[[/[ \t\r\n]+/,""],[/#.*$/,"comment"]],templateString:[[/\$\{/,{token:"delimiter.bracket",next:"@templateExpression"}],[/[^\\`$]+/,"string.template"],[/@escapes/,"string.template.escape"],[/\\./,"string.template.escape.invalid"],[/`/,{token:"string.template",next:"@pop"}]],templateExpression:[[/\}/,{token:"delimiter.bracket",next:"@pop"}],{include:"@root"}],string:[[/[^\\"]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"/,{token:"string.quote",next:"@pop"}]]}};var le=/\$eventContext\.((?:\w+\.)*)(\w*)$/,D=class{static{C(this,"CompletionProvider")}readModels=[];eventSchemas={};eventSequences=[];setReadModels(e){this.readModels=e||[]}setEventSequences(e){this.eventSequences=e||[]}setReadModelSchemas(e){this.readModels=e.map(t=>({identifier:this.getSchemaName(t)||"",displayName:this.getSchemaName(t)||"",schema:t}))}setEventSchemas(e){if(!e){this.eventSchemas={};return}if(Array.isArray(e)){let t={};e.forEach((n,r)=>{if(!n)return;let i=this.getSchemaName(n)||`Event${r+1}`;t[i]=n}),this.eventSchemas=t;return}this.eventSchemas=e}provideCompletionItems(e,t){let n=this.buildContext(e,t),r=[],i=this.getActiveReadModelSchema(e);return n.lineNumber===1?this.addProjectionLineCompletions(r,n):this.isAfterKeyword(n,"sequence")?this.addEventSequenceCompletions(r,n):this.isAfterKeyword(n,"from")||this.isAfterKeyword(n,"every")?this.addEventTypeCompletions(r,n):/\benters\s+on\s+\w*$/.test(n.textBeforeCursor)?this.addEventTypeCompletions(r,n):/\benters\s+\w*$/.test(n.textBeforeCursor)?r.push({label:"on",kind:14,insertText:"on ",documentation:"Declares the event that activates this variant.",detail:"enters on <EventType>",range:this.getRangeForWord(n)}):this.isAfterKeyword(n,"variant")?this.addVariantNameCompletions(r,n):this.isAfterKeyword(n,"key")?this.addKeyCompletions(r,n,i):this.isAfterKeyword(n,"parent")?this.addParentCompletions(r,n):this.isAfterKeyword(n,"children")?this.addChildrenCompletions(r,n,i):this.isAfterKeyword(n,"join")?this.addJoinCompletions(r,n,i):this.isAfterKeyword(n,"with")?this.addEventTypeCompletions(r,n):this.isAfterNumericOperationKeyword(n)?this.addNumericPropertyCompletions(r,n,i):this.isAfterAddOrSubtractBy(n)?this.addAssignmentValueCompletions(r,n,e,t):this.isInAssignment(n)?this.addAssignmentValueCompletions(r,n,e,t):this.isPropertyDotAccess(n)?this.addPropertyMemberCompletions(r,n):(this.isStartOfLine(n)||this.isAfterIndent(n))&&this.addStatementCompletions(r,n,i),{suggestions:r}}buildContext(e,t){let n=e.getLineContent(t.lineNumber),r=n.substring(0,t.column-1),i=n.substring(t.column-1),l=e.getWordAtPosition(t)?.word||"",f=this.getIndentLevel(r);return{lineContent:n,textBeforeCursor:r,textAfterCursor:i,currentWord:l,indentLevel:f,lineNumber:t.lineNumber}}getIndentLevel(e){let t=e.match(/^(\s*)/);return t?Math.floor(t[1].length/2):0}isStartOfLine(e){return e.textBeforeCursor.trim()===""}isAfterIndent(e){return/^\s+$/.test(e.textBeforeCursor)}isAfterKeyword(e,t){return new RegExp(`\\b${t}\\s+\\w*$`).test(e.textBeforeCursor)}isAfterNumericOperationKeyword(e){let t=/\b(count|increment|decrement)\s+\w*$/,n=/\b(add|subtract)\s+\w*$/;return t.test(e.textBeforeCursor)?!0:n.test(e.textBeforeCursor)?!this.isAfterAddOrSubtractBy(e):!1}isAfterAddOrSubtractBy(e){return/\b(add|subtract)\s+\w+\s+by\s+\w*$/.test(e.textBeforeCursor)}isInAssignment(e){return/\w+\s*=\s*\w*$/.test(e.textBeforeCursor)}isPropertyDotAccess(e){return/(\w+|\$\w+)\.(\w*)$/.test(e.textBeforeCursor)||le.test(e.textBeforeCursor)}addProjectionLineCompletions(e,t){let n=t.textBeforeCursor.trim();(n===""||"projection".startsWith(n))&&e.push({label:"projection",kind:14,insertText:"projection ",documentation:"Define a projection that transforms events into a read model",detail:"projection <ProjectionName>",range:this.getRangeForWord(t)});let r=n.match(/^projection\s+[\w.]+\s*=>\s*([\w.]*)$/);if(r){let i=r[1]||"";this.readModels.forEach(s=>{if(!i||s.displayName.toLowerCase().startsWith(i.toLowerCase())){let l=`${s.displayName} (${s.identifier})`;e.push({label:l,kind:6,insertText:s.displayName,filterText:`${s.displayName} ${s.identifier}`,documentation:`Read model: ${s.displayName} (${s.identifier})`,detail:s.identifier,range:this.getRangeForWord(t)})}});return}if(n.startsWith("projection ")&&!n.includes("=>")){let i=n.substring(11);this.readModels.forEach(s=>{if(!i||s.displayName.toLowerCase().startsWith(i.toLowerCase())){let l=`${s.displayName} (${s.identifier})`;e.push({label:l,kind:6,insertText:`${s.displayName} => ${s.displayName}`,filterText:`${s.displayName} ${s.identifier}`,documentation:`Read model: ${s.displayName} (${s.identifier})`,detail:s.identifier,range:this.getRangeForWord(t)})}})}}addEventTypeCompletions(e,t){Object.keys(this.eventSchemas).forEach(n=>{if(!t.currentWord||n.startsWith(t.currentWord)){let r=this.eventSchemas[n];e.push({label:n,kind:6,insertText:n,documentation:this.getSchemaDescription(r)||`Event type: ${n}`,detail:"Event Type",range:this.getRangeForWord(t)})}})}addEventSequenceCompletions(e,t){this.eventSequences.forEach(n=>{(!t.currentWord||n.startsWith(t.currentWord))&&e.push({label:n,kind:13,insertText:n,documentation:`Event sequence: ${n}`,detail:"Event Sequence",range:this.getRangeForWord(t)})})}addKeyCompletions(e,t,n){n?.definitions&&Object.keys(n.definitions).forEach(r=>{n.definitions[r].type==="object"&&e.push({label:r,kind:6,insertText:r,documentation:`Composite key type: ${r}`,detail:"Composite Key Type",range:this.getRangeForWord(t)})}),this.addExpressionCompletions(e,t)}addParentCompletions(e,t){this.addExpressionCompletions(e,t)}addNumericPropertyCompletions(e,t,n){n?.properties&&Object.entries(n.properties).forEach(([i,s])=>{(s.type==="integer"||s.type==="number")&&(!t.currentWord||i.startsWith(t.currentWord))&&e.push({label:i,kind:9,insertText:i,documentation:`Numeric property: ${i}`,detail:this.getPropertyTypeDescription(s),range:this.getRangeForWord(t)})});let r=t.textBeforeCursor.match(/\b(add|subtract)\s+(\w*)$/);if(r){let i=r[2]||"";n?.properties&&Object.entries(n.properties).forEach(([s,l])=>{(l.type==="integer"||l.type==="number")&&(!i||s.startsWith(i))&&e.push({label:s,kind:9,insertText:`${s} by `,documentation:`Numeric property: ${s}`,detail:this.getPropertyTypeDescription(l),range:this.getRangeForWord(t)})})}}addChildrenCompletions(e,t,n){n?.properties&&Object.entries(n.properties).forEach(([r,i])=>{(i.type==="array"||i.items)&&e.push({label:r,kind:9,insertText:`${r} id `,documentation:`Collection property: ${r}`,detail:this.getPropertyTypeDescription(i),range:this.getRangeForWord(t)})})}addJoinCompletions(e,t,n){let r=t.textBeforeCursor.trim();r==="join"||!r.includes(" ")?n?.properties&&Object.entries(n.properties).forEach(([i,s])=>{(s.type==="array"||s.items)&&e.push({label:i,kind:9,insertText:`${i} on `,documentation:`Join on collection: ${i}`,range:this.getRangeForWord(t)})}):r.match(/join\s+\w+\s+on\s+/)&&n?.properties&&Object.keys(n.properties).forEach(i=>{e.push({label:i,kind:9,insertText:i,documentation:`Property: ${i}`,range:this.getRangeForWord(t)})})}addVariantNameCompletions(e,t){this.readModels.forEach(n=>{(!t.currentWord||n.displayName.toLowerCase().startsWith(t.currentWord.toLowerCase()))&&e.push({label:n.displayName,kind:6,insertText:n.displayName,documentation:`Read model: ${n.displayName} (${n.identifier})`,detail:n.identifier,range:this.getRangeForWord(t)})})}addStatementCompletions(e,t,n){[{label:"sequence",insertText:"sequence ",documentation:"Specify which event sequence to use for this projection",detail:"sequence <event-sequence-id>"},{label:"variant",insertText:"variant ",documentation:"Declare one of several mutually exclusive named read models sharing this projection's identity",detail:"variant <Name>"},{label:"enters on",insertText:"enters on ",documentation:"Declare the event that activates a variant",detail:"enters on <EventType>"},{label:"from",insertText:"from ",documentation:"Handle specific event types",detail:"from <EventType>"},{label:"all",insertText:"all",documentation:"Subscribe to all event types in the system \u2014 mappings run for every event system-wide, regardless of explicit from blocks",detail:"all"},{label:"every",insertText:"every",documentation:"Handle all events for automatic mapping (only events explicitly subscribed to via from blocks)",detail:"every"},{label:"key",insertText:"key ",documentation:"Define the projection key",detail:"key <expression>"},{label:"parent",insertText:"parent ",documentation:"Define parent relationship",detail:"parent <expression>"},{label:"join",insertText:"join ",documentation:"Join with child collection",detail:"join <collection> on <property>"},{label:"children",insertText:"children ",documentation:"Define child collection operations",detail:"children <collection> identified by <expression>"},{label:"remove with",insertText:"remove with ",documentation:"Remove items based on event",detail:"remove with <EventType>"},{label:"remove via",insertText:"remove via join on ",documentation:"Remove items via join",detail:"remove via join on <EventType>"},{label:"no automap",insertText:"no automap",documentation:"Disable automatic property mapping",detail:"no automap"},{label:"clear",insertText:"clear ",documentation:"Remove the value a property holds",detail:"clear <property>"},{label:"increment",insertText:"increment ",documentation:"Increment a numeric property",detail:"increment <property>"},{label:"decrement",insertText:"decrement ",documentation:"Decrement a numeric property",detail:"decrement <property>"},{label:"count",insertText:"count ",documentation:"Count occurrences",detail:"count <property>"},{label:"add",insertText:"add ",documentation:"Add value to property",detail:"add <property> by <expression>"},{label:"subtract",insertText:"subtract ",documentation:"Subtract value from property",detail:"subtract <property> by <expression>"},{label:"exclude children",insertText:"exclude children",documentation:"Exclude child collections from automap",detail:"exclude children"}].forEach(i=>{(!t.currentWord||i.label.startsWith(t.currentWord))&&e.push({label:i.label,kind:14,insertText:i.insertText,documentation:i.documentation,detail:i.detail,range:this.getRangeForWord(t)})}),n?.properties&&Object.entries(n.properties).forEach(([i,s])=>{(!t.currentWord||i.startsWith(t.currentWord))&&e.push({label:i,kind:9,insertText:`${i} = `,documentation:`Assign value to property: ${i}`,detail:this.getPropertyTypeDescription(s),range:this.getRangeForWord(t)})})}addAssignmentValueCompletions(e,t,n,r){let i=this.getCurrentEventType(n,r.lineNumber);if(i&&this.eventSchemas[i]){let s=this.eventSchemas[i];s.properties&&Object.entries(s.properties).forEach(([l,f])=>{e.push({label:l,kind:9,insertText:l,documentation:`Event property: ${l}`,detail:this.getPropertyTypeDescription(f),range:this.getRangeForWord(t)})})}this.addExpressionCompletions(e,t)}addExpressionCompletions(e,t){[{label:"$eventSourceId",insertText:"$eventSourceId",documentation:"The identifier of the event source (aggregate/entity)",detail:"Event Source Expression"},{label:"$causedBy",insertText:"$causedBy",documentation:"The identity that caused the event. Chronicle cannot yet evaluate this short form (Cratis/Chronicle#4119) - prefer $eventContext.causedBy.<property>.",detail:"Identity Expression"},{label:"$eventContext",insertText:"$eventContext.",documentation:`Metadata about the event: ${ne.map(r=>r.name).join(", ")}`,detail:"Event Context Expression"}].forEach(r=>{(!t.currentWord||r.label.startsWith(t.currentWord)||r.label.startsWith("$"+t.currentWord))&&e.push({label:r.label,kind:14,insertText:r.insertText,documentation:r.documentation,detail:r.detail,range:this.getRangeForWord(t)})})}addPropertyMemberCompletions(e,t){let n=t.textBeforeCursor.match(le);if(n){let c=n[1].split(".").filter(u=>u.length>0);this.addEventContextMemberCompletions(e,t,c,n[2]);return}let r=t.textBeforeCursor.match(/(\w+|\$\w+)\.(\w*)$/);if(!r)return;let[,i,s]=r,l=t.textBeforeCursor.match(/\$causedBy\.((?:\w+\.)*)(\w*)$/);if(l){let c=l[1].split(".").filter(u=>u.length>0);this.addEventContextMemberCompletions(e,t,["causedBy",...c],l[2]);return}let f=this.eventSchemas[i];f?.properties&&Object.entries(f.properties).forEach(([c,u])=>{(!s||c.startsWith(s))&&e.push({label:c,kind:9,insertText:c,documentation:`Event property: ${c}`,detail:this.getPropertyTypeDescription(u),range:this.getRangeForWord(t)})})}addEventContextMemberCompletions(e,t,n,r){(re(n)??[]).filter(s=>!r||s.name.startsWith(r)).forEach(s=>{e.push({label:s.name,kind:s.kind==="function"?1:9,insertText:s.name,documentation:s.description,detail:s.type,range:this.getRangeForWord(t)})})}getCurrentEventType(e,t){for(let n=t;n>=1;n--){let r=e.getLineContent(n).trim(),i=r.match(/^from\s+([\w-]+)/);if(i)return i[1];if(r.match(/^every$/))return null}return null}getActiveReadModelSchema(e){let n=e.getLineContent(1).trim().match(/^projection\s+[\w.]+\s*=>\s*([\w.]+)/);if(!n)return;let r=n[1];return this.resolveReadModelInfo(r)?.schema}resolveReadModelInfo(e){return this.readModels.find(t=>t.identifier===e||t.displayName===e)||null}getSchemaName(e){if(e.name)return e.name;if(e.title)return e.title;if(typeof e.$id=="string"){let t=e.$id.split("/");return t[t.length-1]||e.$id}}getSchemaDescription(e){return e.description||void 0}getPropertyTypeDescription(e){return e.type==="array"&&e.items?`${e.items.type||e.items.$id?.split("/").pop()||"unknown"}[]`:e.type||e.$ref?.split("/").pop()||"unknown"}getRangeForWord(e){let t=e.textBeforeCursor.length-e.currentWord.length+1,n=t+e.currentWord.length;return{startLineNumber:e.lineNumber,startColumn:Math.max(1,t),endLineNumber:e.lineNumber,endColumn:Math.max(1,n)}}};var A=class{static{C(this,"Validator")}readModels=[];eventSchemas={};draftReadModel=null;setReadModels(e){this.readModels=e||[]}setDraftReadModel(e){this.draftReadModel=e}setReadModelSchemas(e){this.readModels=e.map(t=>({identifier:this.getSchemaName(t)||"",displayName:this.getSchemaName(t)||"",schema:t}))}setEventSchemas(e){if(!e){this.eventSchemas={};return}if(Array.isArray(e)){let t={};e.forEach((n,r)=>{if(!n)return;let i=this.getSchemaName(n)||`Event${r+1}`;t[i]=n}),this.eventSchemas=t;return}this.eventSchemas=e}validate(e){let t=[],n=e.getValue();if(!n.trim())return t;let r=n.replace(/\r\n/g,`
1
+ import{R as ne,S as re,T as ie,U as q,V as oe,ca as se,w as te}from"../../chunk-TGHEJ4MY.js";import{a as C}from"../../chunk-AYDF3IFZ.js";var E="pdl",ce=["projection","sequence","all","every","on","from","key","parent","join","automap","no","children","nested","identified","by","add","subtract","remove","via","with","default","increment","decrement","count","set","unset","clear","events","id","exclude","variant","enters"],pe=["$eventSourceId","$causedBy","$eventContext"],me=["=","+=","-=","=>","."],ae={comments:{lineComment:"#"},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"},{open:"`",close:"`"}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"},{open:"`",close:"`"}],indentationRules:{increaseIndentPattern:/^.*(:|\bon\b|\ball\b|\bevery\b|\bchildren\b|\bnested\b|\bparent\b|\bvariant\b)\s*$/,decreaseIndentPattern:/^.*\}.*$/},folding:{offSide:!0,markers:{start:/^\s*(projection|all|every|on|children|nested|parent|variant)/,end:/^\s*$/}},wordPattern:/@?[a-zA-Z_$][\w$-]*/},de={defaultToken:"",tokenPostfix:".pdl",keywords:ce,builtins:pe,operators:me,symbols:/[=><!~?:&|+\-*/^%]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,tokenizer:{root:[{include:"@whitespace"},[/`/,{token:"string.template",next:"@templateString"}],[/@[a-zA-Z_$][\w$]*/,"identifier.escape"],[/[A-Z][a-zA-Z_$][\w$]*/,{cases:{"@keywords":"invalid","@default":"identifier"}}],[/[a-z_$][\w$]*/,{cases:{"@keywords":"keyword","@builtins":"variable.predefined","@default":"identifier"}}],[/[{}()[\]]/,"@brackets"],[/=>/,"operator.arrow"],[/@symbols/,{cases:{"@operators":"operator","@default":""}}],[/\d*\.\d+([eE][-+]?\d+)?/,"number.float"],[/0[xX][0-9a-fA-F]+/,"number.hex"],[/\d+/,"number"],[/[;,.]/,"delimiter"],[/"([^"\\]|\\.)*$/,"string.invalid"],[/"/,{token:"string.quote",next:"@string"}]],whitespace:[[/[ \t\r\n]+/,""],[/#.*$/,"comment"]],templateString:[[/\$\{/,{token:"delimiter.bracket",next:"@templateExpression"}],[/[^\\`$]+/,"string.template"],[/@escapes/,"string.template.escape"],[/\\./,"string.template.escape.invalid"],[/`/,{token:"string.template",next:"@pop"}]],templateExpression:[[/\}/,{token:"delimiter.bracket",next:"@pop"}],{include:"@root"}],string:[[/[^\\"]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"/,{token:"string.quote",next:"@pop"}]]}};var le=/\$eventContext\.((?:\w+\.)*)(\w*)$/,D=class{static{C(this,"CompletionProvider")}readModels=[];eventSchemas={};eventSequences=[];setReadModels(e){this.readModels=e||[]}setEventSequences(e){this.eventSequences=e||[]}setReadModelSchemas(e){this.readModels=e.map(t=>({identifier:this.getSchemaName(t)||"",displayName:this.getSchemaName(t)||"",schema:t}))}setEventSchemas(e){if(!e){this.eventSchemas={};return}if(Array.isArray(e)){let t={};e.forEach((n,r)=>{if(!n)return;let i=this.getSchemaName(n)||`Event${r+1}`;t[i]=n}),this.eventSchemas=t;return}this.eventSchemas=e}provideCompletionItems(e,t){let n=this.buildContext(e,t),r=[],i=this.getActiveReadModelSchema(e);return n.lineNumber===1?this.addProjectionLineCompletions(r,n):this.isAfterKeyword(n,"sequence")?this.addEventSequenceCompletions(r,n):this.isAfterKeyword(n,"from")||this.isAfterKeyword(n,"every")?this.addEventTypeCompletions(r,n):/\benters\s+on\s+\w*$/.test(n.textBeforeCursor)?this.addEventTypeCompletions(r,n):/\benters\s+\w*$/.test(n.textBeforeCursor)?r.push({label:"on",kind:14,insertText:"on ",documentation:"Declares the event that activates this variant.",detail:"enters on <EventType>",range:this.getRangeForWord(n)}):this.isAfterKeyword(n,"variant")?this.addVariantNameCompletions(r,n):this.isAfterKeyword(n,"key")?this.addKeyCompletions(r,n,i):this.isAfterKeyword(n,"parent")?this.addParentCompletions(r,n):this.isAfterKeyword(n,"children")?this.addChildrenCompletions(r,n,i):this.isAfterKeyword(n,"join")?this.addJoinCompletions(r,n,i):this.isAfterKeyword(n,"with")?this.addEventTypeCompletions(r,n):this.isAfterNumericOperationKeyword(n)?this.addNumericPropertyCompletions(r,n,i):this.isAfterAddOrSubtractBy(n)?this.addAssignmentValueCompletions(r,n,e,t):this.isInAssignment(n)?this.addAssignmentValueCompletions(r,n,e,t):this.isPropertyDotAccess(n)?this.addPropertyMemberCompletions(r,n):(this.isStartOfLine(n)||this.isAfterIndent(n))&&this.addStatementCompletions(r,n,i),{suggestions:r}}buildContext(e,t){let n=e.getLineContent(t.lineNumber),r=n.substring(0,t.column-1),i=n.substring(t.column-1),l=e.getWordAtPosition(t)?.word||"",f=this.getIndentLevel(r);return{lineContent:n,textBeforeCursor:r,textAfterCursor:i,currentWord:l,indentLevel:f,lineNumber:t.lineNumber}}getIndentLevel(e){let t=e.match(/^(\s*)/);return t?Math.floor(t[1].length/2):0}isStartOfLine(e){return e.textBeforeCursor.trim()===""}isAfterIndent(e){return/^\s+$/.test(e.textBeforeCursor)}isAfterKeyword(e,t){return new RegExp(`\\b${t}\\s+\\w*$`).test(e.textBeforeCursor)}isAfterNumericOperationKeyword(e){let t=/\b(count|increment|decrement)\s+\w*$/,n=/\b(add|subtract)\s+\w*$/;return t.test(e.textBeforeCursor)?!0:n.test(e.textBeforeCursor)?!this.isAfterAddOrSubtractBy(e):!1}isAfterAddOrSubtractBy(e){return/\b(add|subtract)\s+\w+\s+by\s+\w*$/.test(e.textBeforeCursor)}isInAssignment(e){return/\w+\s*=\s*\w*$/.test(e.textBeforeCursor)}isPropertyDotAccess(e){return/(\w+|\$\w+)\.(\w*)$/.test(e.textBeforeCursor)||le.test(e.textBeforeCursor)}addProjectionLineCompletions(e,t){let n=t.textBeforeCursor.trim();(n===""||"projection".startsWith(n))&&e.push({label:"projection",kind:14,insertText:"projection ",documentation:"Define a projection that transforms events into a read model",detail:"projection <ProjectionName>",range:this.getRangeForWord(t)});let r=n.match(/^projection\s+[\w.]+\s*=>\s*([\w.]*)$/);if(r){let i=r[1]||"";this.readModels.forEach(s=>{if(!i||s.displayName.toLowerCase().startsWith(i.toLowerCase())){let l=`${s.displayName} (${s.identifier})`;e.push({label:l,kind:6,insertText:s.displayName,filterText:`${s.displayName} ${s.identifier}`,documentation:`Read model: ${s.displayName} (${s.identifier})`,detail:s.identifier,range:this.getRangeForWord(t)})}});return}if(n.startsWith("projection ")&&!n.includes("=>")){let i=n.substring(11);this.readModels.forEach(s=>{if(!i||s.displayName.toLowerCase().startsWith(i.toLowerCase())){let l=`${s.displayName} (${s.identifier})`;e.push({label:l,kind:6,insertText:`${s.displayName} => ${s.displayName}`,filterText:`${s.displayName} ${s.identifier}`,documentation:`Read model: ${s.displayName} (${s.identifier})`,detail:s.identifier,range:this.getRangeForWord(t)})}})}}addEventTypeCompletions(e,t){Object.keys(this.eventSchemas).forEach(n=>{if(!t.currentWord||n.startsWith(t.currentWord)){let r=this.eventSchemas[n];e.push({label:n,kind:6,insertText:n,documentation:this.getSchemaDescription(r)||`Event type: ${n}`,detail:"Event Type",range:this.getRangeForWord(t)})}})}addEventSequenceCompletions(e,t){this.eventSequences.forEach(n=>{(!t.currentWord||n.startsWith(t.currentWord))&&e.push({label:n,kind:13,insertText:n,documentation:`Event sequence: ${n}`,detail:"Event Sequence",range:this.getRangeForWord(t)})})}addKeyCompletions(e,t,n){n?.definitions&&Object.keys(n.definitions).forEach(r=>{n.definitions[r].type==="object"&&e.push({label:r,kind:6,insertText:r,documentation:`Composite key type: ${r}`,detail:"Composite Key Type",range:this.getRangeForWord(t)})}),this.addExpressionCompletions(e,t)}addParentCompletions(e,t){this.addExpressionCompletions(e,t)}addNumericPropertyCompletions(e,t,n){n?.properties&&Object.entries(n.properties).forEach(([i,s])=>{(s.type==="integer"||s.type==="number")&&(!t.currentWord||i.startsWith(t.currentWord))&&e.push({label:i,kind:9,insertText:i,documentation:`Numeric property: ${i}`,detail:this.getPropertyTypeDescription(s),range:this.getRangeForWord(t)})});let r=t.textBeforeCursor.match(/\b(add|subtract)\s+(\w*)$/);if(r){let i=r[2]||"";n?.properties&&Object.entries(n.properties).forEach(([s,l])=>{(l.type==="integer"||l.type==="number")&&(!i||s.startsWith(i))&&e.push({label:s,kind:9,insertText:`${s} by `,documentation:`Numeric property: ${s}`,detail:this.getPropertyTypeDescription(l),range:this.getRangeForWord(t)})})}}addChildrenCompletions(e,t,n){n?.properties&&Object.entries(n.properties).forEach(([r,i])=>{(i.type==="array"||i.items)&&e.push({label:r,kind:9,insertText:`${r} id `,documentation:`Collection property: ${r}`,detail:this.getPropertyTypeDescription(i),range:this.getRangeForWord(t)})})}addJoinCompletions(e,t,n){let r=t.textBeforeCursor.trim();r==="join"||!r.includes(" ")?n?.properties&&Object.entries(n.properties).forEach(([i,s])=>{(s.type==="array"||s.items)&&e.push({label:i,kind:9,insertText:`${i} on `,documentation:`Join on collection: ${i}`,range:this.getRangeForWord(t)})}):r.match(/join\s+\w+\s+on\s+/)&&n?.properties&&Object.keys(n.properties).forEach(i=>{e.push({label:i,kind:9,insertText:i,documentation:`Property: ${i}`,range:this.getRangeForWord(t)})})}addVariantNameCompletions(e,t){this.readModels.forEach(n=>{(!t.currentWord||n.displayName.toLowerCase().startsWith(t.currentWord.toLowerCase()))&&e.push({label:n.displayName,kind:6,insertText:n.displayName,documentation:`Read model: ${n.displayName} (${n.identifier})`,detail:n.identifier,range:this.getRangeForWord(t)})})}addStatementCompletions(e,t,n){[{label:"sequence",insertText:"sequence ",documentation:"Specify which event sequence to use for this projection",detail:"sequence <event-sequence-id>"},{label:"variant",insertText:"variant ",documentation:"Declare one of several mutually exclusive named read models sharing this projection's identity",detail:"variant <Name>"},{label:"enters on",insertText:"enters on ",documentation:"Declare the event that activates a variant",detail:"enters on <EventType>"},{label:"from",insertText:"from ",documentation:"Handle specific event types",detail:"from <EventType>"},{label:"all",insertText:"all",documentation:"Subscribe to all event types in the system \u2014 mappings run for every event system-wide, regardless of explicit from blocks",detail:"all"},{label:"every",insertText:"every",documentation:"Handle all events for automatic mapping (only events explicitly subscribed to via from blocks)",detail:"every"},{label:"key",insertText:"key ",documentation:"Define the projection key",detail:"key <expression>"},{label:"parent",insertText:"parent ",documentation:"Define parent relationship",detail:"parent <expression>"},{label:"join",insertText:"join ",documentation:"Join with child collection",detail:"join <collection> on <property>"},{label:"children",insertText:"children ",documentation:"Define child collection operations",detail:"children <collection> identified by <expression>"},{label:"remove with",insertText:"remove with ",documentation:"Remove items based on event",detail:"remove with <EventType>"},{label:"remove via",insertText:"remove via join on ",documentation:"Remove items via join",detail:"remove via join on <EventType>"},{label:"no automap",insertText:"no automap",documentation:"Disable automatic property mapping",detail:"no automap"},{label:"clear",insertText:"clear ",documentation:"Remove the value a property holds",detail:"clear <property>"},{label:"increment",insertText:"increment ",documentation:"Increment a numeric property",detail:"increment <property>"},{label:"decrement",insertText:"decrement ",documentation:"Decrement a numeric property",detail:"decrement <property>"},{label:"count",insertText:"count ",documentation:"Count occurrences",detail:"count <property>"},{label:"add",insertText:"add ",documentation:"Add value to property",detail:"add <property> by <expression>"},{label:"subtract",insertText:"subtract ",documentation:"Subtract value from property",detail:"subtract <property> by <expression>"},{label:"exclude children",insertText:"exclude children",documentation:"Exclude child collections from automap",detail:"exclude children"}].forEach(i=>{(!t.currentWord||i.label.startsWith(t.currentWord))&&e.push({label:i.label,kind:14,insertText:i.insertText,documentation:i.documentation,detail:i.detail,range:this.getRangeForWord(t)})}),n?.properties&&Object.entries(n.properties).forEach(([i,s])=>{(!t.currentWord||i.startsWith(t.currentWord))&&e.push({label:i,kind:9,insertText:`${i} = `,documentation:`Assign value to property: ${i}`,detail:this.getPropertyTypeDescription(s),range:this.getRangeForWord(t)})})}addAssignmentValueCompletions(e,t,n,r){let i=this.getCurrentEventType(n,r.lineNumber);if(i&&this.eventSchemas[i]){let s=this.eventSchemas[i];s.properties&&Object.entries(s.properties).forEach(([l,f])=>{e.push({label:l,kind:9,insertText:l,documentation:`Event property: ${l}`,detail:this.getPropertyTypeDescription(f),range:this.getRangeForWord(t)})})}this.addExpressionCompletions(e,t)}addExpressionCompletions(e,t){[{label:"$eventSourceId",insertText:"$eventSourceId",documentation:"The identifier of the event source (aggregate/entity)",detail:"Event Source Expression"},{label:"$causedBy",insertText:"$causedBy",documentation:"The identity that caused the event. Chronicle cannot yet evaluate this short form (Cratis/Chronicle#4119) - prefer $eventContext.causedBy.<property>.",detail:"Identity Expression"},{label:"$eventContext",insertText:"$eventContext.",documentation:`Metadata about the event: ${ne.map(r=>r.name).join(", ")}`,detail:"Event Context Expression"}].forEach(r=>{(!t.currentWord||r.label.startsWith(t.currentWord)||r.label.startsWith("$"+t.currentWord))&&e.push({label:r.label,kind:14,insertText:r.insertText,documentation:r.documentation,detail:r.detail,range:this.getRangeForWord(t)})})}addPropertyMemberCompletions(e,t){let n=t.textBeforeCursor.match(le);if(n){let c=n[1].split(".").filter(u=>u.length>0);this.addEventContextMemberCompletions(e,t,c,n[2]);return}let r=t.textBeforeCursor.match(/(\w+|\$\w+)\.(\w*)$/);if(!r)return;let[,i,s]=r,l=t.textBeforeCursor.match(/\$causedBy\.((?:\w+\.)*)(\w*)$/);if(l){let c=l[1].split(".").filter(u=>u.length>0);this.addEventContextMemberCompletions(e,t,["causedBy",...c],l[2]);return}let f=this.eventSchemas[i];f?.properties&&Object.entries(f.properties).forEach(([c,u])=>{(!s||c.startsWith(s))&&e.push({label:c,kind:9,insertText:c,documentation:`Event property: ${c}`,detail:this.getPropertyTypeDescription(u),range:this.getRangeForWord(t)})})}addEventContextMemberCompletions(e,t,n,r){(re(n)??[]).filter(s=>!r||s.name.startsWith(r)).forEach(s=>{e.push({label:s.name,kind:s.kind==="function"?1:9,insertText:s.name,documentation:s.description,detail:s.type,range:this.getRangeForWord(t)})})}getCurrentEventType(e,t){for(let n=t;n>=1;n--){let r=e.getLineContent(n).trim(),i=r.match(/^from\s+([\w-]+)/);if(i)return i[1];if(r.match(/^every$/))return null}return null}getActiveReadModelSchema(e){let n=e.getLineContent(1).trim().match(/^projection\s+[\w.]+\s*=>\s*([\w.]+)/);if(!n)return;let r=n[1];return this.resolveReadModelInfo(r)?.schema}resolveReadModelInfo(e){return this.readModels.find(t=>t.identifier===e||t.displayName===e)||null}getSchemaName(e){if(e.name)return e.name;if(e.title)return e.title;if(typeof e.$id=="string"){let t=e.$id.split("/");return t[t.length-1]||e.$id}}getSchemaDescription(e){return e.description||void 0}getPropertyTypeDescription(e){return e.type==="array"&&e.items?`${e.items.type||e.items.$id?.split("/").pop()||"unknown"}[]`:e.type||e.$ref?.split("/").pop()||"unknown"}getRangeForWord(e){let t=e.textBeforeCursor.length-e.currentWord.length+1,n=t+e.currentWord.length;return{startLineNumber:e.lineNumber,startColumn:Math.max(1,t),endLineNumber:e.lineNumber,endColumn:Math.max(1,n)}}};var A=class{static{C(this,"Validator")}readModels=[];eventSchemas={};draftReadModel=null;setReadModels(e){this.readModels=e||[]}setDraftReadModel(e){this.draftReadModel=e}setReadModelSchemas(e){this.readModels=e.map(t=>({identifier:this.getSchemaName(t)||"",displayName:this.getSchemaName(t)||"",schema:t}))}setEventSchemas(e){if(!e){this.eventSchemas={};return}if(Array.isArray(e)){let t={};e.forEach((n,r)=>{if(!n)return;let i=this.getSchemaName(n)||`Event${r+1}`;t[i]=n}),this.eventSchemas=t;return}this.eventSchemas=e}validate(e){let t=[],n=e.getValue();if(!n.trim())return t;let r=n.replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
3
  `).split(`
4
4
  `),i=0,s="";for(let m=0;m<r.length;m++){let p=r[m].trim();if(p&&!p.startsWith("#")){i=m,s=p;break}}if(!s)return t;let l=s.match(/^projection\s+([\w.]+)\s*=>\s*([\w.]+)\s*$/),f=!l&&s.match(/^projection\s+([\w.]+)\s*$/);if(!l&&!f){let m=i+1;return t.push(this.createError(m,1,s.length+1,'Projection definition must start with "projection <ProjectionName>" or "projection <ProjectionName> => <ReadModelIdentifier>"')),t}let c,u=null;if(l){u=l[2];let m=this.resolveReadModelIdentifier(u)!==null,p=this.isDraftReadModel(u),v=this.getReadModelStartColumn(s,u);if(!m&&!p){let S=i+1,N=v;t.push(this.createError(S,N,N+u.length,`Read model '${u}' not found`))}else if(p){let S=i+1,N=v;t.push(this.createInfo(S,N,N+u.length,`Read model '${u}' is a draft (not yet saved)`))}let R=this.isDraftReadModel(u),w=R?null:this.resolveReadModelInfo(u);c=R?this.draftReadModel.schema:w?.schema}let g=[c],M=[0],x=0,b=[new Map];for(let m=1;m<r.length;m++){let p=m+1,v=r[m],R=v.trim();if(!R||R.startsWith("#"))continue;let w=v.search(/\S/);for(;w<x&&M.length>1;){let o=M.pop();o!==void 0&&w<o&&(g.pop(),b.pop())}x=w;let S=b[b.length-1],N=R.match(/^from\s+([\w-]+)/);if(N){let o=N[1],a=v.indexOf(o)+1;Object.keys(this.eventSchemas).length>0&&!this.eventSchemas[o]&&t.push(this.createError(p,a,a+o.length,`Event type '${o}' not found`)),S.has(o)?t.push(this.createError(p,a,a+o.length,`Duplicate event type '${o}' - event types can only be used once at each level`)):S.set(o,{lineNumber:p,col:a})}let _=R.match(/^variant\s+([\w.]+)\s*$/);if(_){let[,o]=_,a=v.indexOf(o)+1,y=this.isDraftReadModel(o);!(this.resolveReadModelIdentifier(o)!==null)&&!y?t.push(this.createError(p,a,a+o.length,`Read model '${o}' not found`)):y&&t.push(this.createInfo(p,a,a+o.length,`Read model '${o}' is a draft (not yet saved)`));let F=y?this.draftReadModel.schema:this.resolveReadModelInfo(o)?.schema;g.push(F),M.push(w),b.push(new Map)}let z=R.match(/^enters\s+on\s+([\w-]+)/);if(z){let o=z[1],a=v.indexOf(o)+1;Object.keys(this.eventSchemas).length>0&&!this.eventSchemas[o]&&t.push(this.createError(p,a,a+o.length,`Event type '${o}' not found`)),S.has(o)?t.push(this.createError(p,a,a+o.length,`Duplicate event type '${o}' - event types can only be used once at each level`)):S.set(o,{lineNumber:p,col:a})}let U=R.match(/^events\s+([\w-]+)/);if(U){let o=U[1],a=v.indexOf(o)+1;Object.keys(this.eventSchemas).length>0&&!this.eventSchemas[o]&&t.push(this.createError(p,a,a+o.length,`Event type '${o}' not found`)),S.has(o)?t.push(this.createError(p,a,a+o.length,`Duplicate event type '${o}' - event types can only be used once at each level`)):S.set(o,{lineNumber:p,col:a})}let V=R.match(/^remove\s+(?:with|via\s+join\s+on)\s+([\w-]+)/);if(V){let o=V[1],a=v.indexOf(o)+1;Object.keys(this.eventSchemas).length>0&&!this.eventSchemas[o]&&t.push(this.createError(p,a,a+o.length,`Event type '${o}' not found`)),S.has(o)?t.push(this.createError(p,a,a+o.length,`Duplicate event type '${o}' - event types can only be used once at each level`)):S.set(o,{lineNumber:p,col:a})}let Z=R.match(/^(\w+)\s*=\s*(.+)$/);if(Z){let o=g[g.length-1];if(o?.properties){let[,a]=Z;if(!o.properties[a]){let y=v.indexOf(a)+1,h=this.getSchemaName(o)||"current schema";t.push(this.createWarning(p,y,y+a.length,`Property '${a}' not found in ${h}`))}}}let X=R.match(/^(?:increment|decrement|count)\s+(\w+)$/);if(X){let o=g[g.length-1];if(o?.properties){let[,a]=X;if(!o.properties[a]){let y=v.indexOf(a)+1,h=this.getSchemaName(o)||"current schema";t.push(this.createWarning(p,y,y+a.length,`Property '${a}' not found in ${h}`))}}}let Y=R.match(/^(?:add|subtract)\s+(\w+)\s+by\s+/);if(Y){let o=g[g.length-1];if(o?.properties){let[,a]=Y;if(!o.properties[a]){let y=v.indexOf(a)+1,h=this.getSchemaName(o)||"current schema";t.push(this.createWarning(p,y,y+a.length,`Property '${a}' not found in ${h}`))}}}let G=R.match(/^children\s+(\w+)\s+identified\s+by\s+/);if(G){let o=g[g.length-1];if(o?.properties){let[,a]=G,y=o.properties[a];if(y)if(y.type!=="array"&&!y.items){let h=v.indexOf(a)+1;t.push(this.createWarning(p,h,h+a.length,`Property '${a}' is not a collection (array) type`))}else{let h=y.items;h&&(g.push(h),M.push(w),b.push(new Map))}else{let h=v.indexOf(a)+1,F=this.getSchemaName(o)||"current schema";t.push(this.createWarning(p,h,h+a.length,`Collection property '${a}' not found in ${F}`))}}}let Q=R.match(/^join\s+(\w+)\s+on\s+(\w+)/);if(Q&&c?.properties){let[,o,a]=Q,y=c.properties[o];if(y){if(y.type!=="array"&&!y.items){let h=v.indexOf(o)+1;t.push(this.createWarning(p,h,h+o.length,`Property '${o}' is not a collection (array) type`))}}else{let h=v.indexOf(o)+1;t.push(this.createWarning(p,h,h+o.length,`Collection property '${o}' not found in read model '${u}'`))}if(!c.properties[a]){let h=v.indexOf(a,v.indexOf("on"))+1;t.push(this.createWarning(p,h,h+a.length,`Property '${a}' not found in read model '${u}'`))}b.push(new Map),M.push(w)}let ee=R.match(/^key\s+(\w+)\s*$/);if(ee&&c){let[,o]=ee,a=c.definitions&&c.definitions[o],y=c.properties&&c.properties[o];if(!a&&!y&&!this.isBuiltInExpression(o)){let h=v.indexOf(o)+1;t.push(this.createWarning(p,h,h+o.length,`Composite key type '${o}' not found in read model schema`))}}}for(let m of se(r,te(r)))t.push({severity:m.severity==="error"?8:4,startLineNumber:m.line+1,endLineNumber:m.line+1,startColumn:m.startColumn,endColumn:m.endColumn,message:m.message,code:m.code});return t}resolveReadModelInfo(e){return this.readModels.find(t=>t.identifier===e||t.displayName===e)||null}getReadModelStartColumn(e,t){let n=e.match(/^\s*projection\s+[\w.]+\s*=>\s*/);if(!n){let r=e.lastIndexOf(t);return(r>=0?r:0)+1}return n[0].length+1}resolveReadModelIdentifier(e){return this.isDraftReadModel(e)?this.draftReadModel.identifier:this.resolveReadModelInfo(e)?.identifier??null}isDraftReadModel(e){return!!this.draftReadModel&&(this.draftReadModel.identifier===e||this.draftReadModel.displayName===e)}isBuiltInExpression(e){return e.startsWith("$")||["true","false","null"].includes(e)}createError(e,t,n,r){return{severity:8,startLineNumber:e,startColumn:t,endLineNumber:e,endColumn:n,message:r}}createWarning(e,t,n,r){return{severity:4,startLineNumber:e,startColumn:t,endLineNumber:e,endColumn:n,message:r}}createInfo(e,t,n,r){return{severity:2,startLineNumber:e,startColumn:t,endLineNumber:e,endColumn:n,message:r}}getSchemaName(e){if(e.name)return e.name;if(e.title)return e.title;if(typeof e.$id=="string"){let t=e.$id.split("/");return t[t.length-1]||e.$id}}};var W=class{static{C(this,"HoverProvider")}readModels=[];eventSchemas={};draftReadModel=null;setReadModels(e){this.readModels=e||[]}setReadModelSchemas(e){this.readModels=e.map(t=>({identifier:this.getSchemaName(t)||"",displayName:this.getSchemaName(t)||"",schema:t}))}setEventSchemas(e){if(!e){this.eventSchemas={};return}if(Array.isArray(e)){let t={};e.forEach((n,r)=>{if(!n)return;let i=this.getSchemaName(n)||`Event${r+1}`;t[i]=n}),this.eventSchemas=t;return}this.eventSchemas=e}setDraftReadModel(e){this.draftReadModel=e}provideHover(e,t){let n=e.getWordAtPosition(t);if(!n)return null;let r=n.word,i=e.getLineContent(t.lineNumber);if(this.getProjectionNameAtPosition(i,t.column))return{contents:[{value:"The name of the projection"}],range:{startLineNumber:t.lineNumber,startColumn:n.startColumn,endLineNumber:t.lineNumber,endColumn:n.endColumn}};let l=this.getEventContextInfo(i,n.startColumn);if(l)return{contents:[{value:l}],range:{startLineNumber:t.lineNumber,startColumn:n.startColumn,endLineNumber:t.lineNumber,endColumn:n.endColumn}};let f=this.getKeywordInfo(r);if(f)return{contents:[{value:f}],range:{startLineNumber:t.lineNumber,startColumn:n.startColumn,endLineNumber:t.lineNumber,endColumn:n.endColumn}};let c=this.getExpressionInfo(r);if(c)return{contents:[{value:c}],range:{startLineNumber:t.lineNumber,startColumn:n.startColumn,endLineNumber:t.lineNumber,endColumn:n.endColumn}};if(this.eventSchemas[r]){let M=this.eventSchemas[r],x=this.getSchemaDescription(M),b=this.getSchemaProperties(M),m=`**Event Type:** \`${r}\`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/screenplay-language",
3
- "version": "4.75.0",
3
+ "version": "4.76.0",
4
4
  "description": "Monaco language service for the Cratis Screenplay DSL — syntax highlighting, IntelliSense, hover and diagnostics for .play files",
5
5
  "keywords": [
6
6
  "cratis",