@cratis/screenplay-language 4.76.1 → 4.78.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.
- package/dist/bundles/chunk-2E5TT2R2.js +16 -0
- package/dist/bundles/chunk-2E5TT2R2.js.map +7 -0
- package/dist/bundles/index.js +1 -1
- package/dist/bundles/sub-languages/projection/index.js +1 -1
- package/package.json +1 -1
- package/dist/bundles/chunk-X5DNGVII.js +0 -16
- package/dist/bundles/chunk-X5DNGVII.js.map +0 -7
package/dist/bundles/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as Wn,A as ft,B as yt,C as P,D as E,E as An,F as En,G as Ln,H as Pn,I as B,J as gt,K as U,L as qn,M as W,N as ke,O as Nn,P as Ce,Q as Rn,R as te,S as Mn,T as On,U as jn,V as zn,Y as Fn,Z as Se,_ as Bn,a as N,aa as Vn,b as lt,ba as _n,c as ae,ca as Un,d as xe,da as De,e as X,f as kn,g as Cn,h as Te,i as G,j as Sn,k as Dn,l as mt,m as we,n as D,o as ut,p as ee,q as se,r as pt,s as dt,t as ht,u as I,v as k,w as In,x as L,y as F,z as V}from"./chunk-X5DNGVII.js";import{a as p}from"./chunk-AYDF3IFZ.js";var bt=/[\p{L}\p{Mn}\p{Nd}\p{Pc}]/u,$t=p(e=>`\\u${e.toString(16).padStart(4,"0")}`,"escape");function Hn(){let e="";for(let n=0;n<=65535;n++){if(!bt.test(String.fromCharCode(n)))continue;let t=n;for(;n<65535&&bt.test(String.fromCharCode(n+1));)n++;e+=$t(t)+(n>t?`-${$t(n)}`:"")}return e}p(Hn,"ranges");var Z=Hn();var xt=new Set(["operation","system","eventsource"]),Ie={csharp:"csharp",typescript:"typescript",react:"typescript",html:"html",sql:"sql"};function vt(e){return`subLanguage_${e}`}p(vt,"subLanguageState");function Gn(e){let n=[...ae.filter(t=>!xt.has(t)),...e.map(t=>t.keyword)];return[new RegExp(`^\\s*(?:${n.join("|")})\\b`),{token:"@rematch",next:"@pop"}]}p(Gn,"subLanguageExitRule");var Zn=[[/\/\/.*$/,"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 Tt(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_][${Z}]*)(?=\\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"}]],...X.map(t=>[new RegExp(`^\\s*\\x60\\x60\\x60${t}\\s*$`),{token:"string.quote",next:`@codeBlock.${Ie[t]}`,nextEmbedded:Ie[t]}]),...X.map(t=>[new RegExp(`\\b${t}\\b(?=\\s*$)`),{token:"keyword.tag",next:`@codeBlockPending.${Ie[t]}`}]),...e.map(t=>[new RegExp(`\\b${t.keyword}\\b`),{token:"keyword",next:`@${vt(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*)([${Z}.]+)(\\s+)(rule)(\\s+)([A-Za-z_][${Z}]*)(?=\\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:Zn,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[vt(t.keyword)]=[Gn(e),...t.tokens,{include:"@common"},[/[A-Z]\w*/,"type.identifier"],[/[a-z_]\w*/,"identifier"]];return{defaultToken:"",tokenPostfix:".play",ignoreCase:!1,keywords:[...ae.filter(t=>!xt.has(t)),...xe,...X],sliceTypes:Te,primitiveTypes:G,tokenizer:n}}p(Tt,"createTokensProvider");var Ae=[{label:"on",insertText:"on ${1|click,select,submit,change,load,unload,enter,leave|}\n ${2:execute command}",documentation:"Wires what happens on an interaction - a click, a submit, entering or leaving the screen."},{label:"uses",insertText:"uses ${1:Behavior}",documentation:"Attaches a named behavior declared at the top level."}],Ee=[{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:'import "\u2026"',insertText:'import "${1:*/*.play}"',documentation:"Imports `.play` files into this module \u2014 their top level is the module's body."},{label:"feature",insertText:"feature ${1:Name}\n ",documentation:"Groups related slices into a vertical feature."},{label:"screen",insertText:"screen ${1:Name}\n data ${2:ReadModel} via query ${3:QueryName}",documentation:"Declares a module-level UI screen."},{label:"screen template",insertText:"screen template ${1:Name}\n fits slot ${2:content}\n\n ${3:slot}",documentation:"Declares a reusable screen shape that fits a slot of the shell."},{label:"dialog template",insertText:"dialog template ${1:Name}\n ${2:body}\n ${3:actions}",documentation:"Declares a reusable dialog shape that opens 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 slot of the shell, such as navigation."},...Ae],Le=[{label:"description",insertText:'description "${1:what this feature is for}"',documentation:"A human-readable description."},{label:"authorize",insertText:"authorize ${1:PolicyName}",documentation:"Policies that must pass for everything in the feature."},{label:'import "\u2026"',insertText:'import "${1:*.play}"',documentation:"Imports `.play` files into this feature \u2014 their top level is the feature's body."},{label:"feature",insertText:"feature ${1:Name}\n ",documentation:"Declares a nested sub-feature."},{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."},{label:"contribute",insertText:'contribute to ${1:Navigation}\n navigate to ${2:Screen}\n label "${3:Label}"',documentation:"Contributes an entry to a slot of the shell, such as navigation."},...Ae],wt=[{label:"description",insertText:'description "${1:what one instance holds}"',documentation:"A human-readable description."},{label:"file",insertText:"file ${1:Path}",documentation:"Names the file this read model is realized by."},{label:"property",insertText:"${1:property} ${2:Type}",documentation:"A property of the read model \u2014 a name and a type reference."}],kt=[{label:"description",insertText:'description "${1:what the reducer does}"',documentation:"A human-readable description."},{label:"on",insertText:"on ${1:EventType}\n ```csharp\n ${2}\n ```",documentation:"A rule applied when the event occurs, in code or from a file."}],Ct=[{label:"populate via query",insertText:"populate via query ${1:Query} by ${2:parameter}",documentation:"Fills the form from a query before it is shown."},{label:"populate from item",insertText:"populate from item",documentation:"Fills the form from the item the screen was opened for."},{label:"field",insertText:'field ${1:property} label "${2:Label}"',documentation:"A form field bound to a command property."},...Ae],St=[{label:"navigate to",insertText:"navigate to ${1:Screen}",documentation:"The screen the entry opens."},{label:"label",insertText:'label "${1:Label}"',documentation:"The text of the entry."},{label:"order",insertText:"order ${1:10}",documentation:"Where the entry sits among the others; lower comes first."}],Dt=[{label:"description",insertText:'description "${1:what the behavior does}"',documentation:"A human-readable description."},{label:"parameter",insertText:"parameter ${1:name} ${2:Type}",documentation:"A value the behavior is given where it is attached."},{label:"order",insertText:"order ${1:10}",documentation:"The order behaviors attached to the same element run in."},{label:"on",insertText:"on ${1|click,select,submit,change,load,unload,enter,leave|}\n ${2:execute command}",documentation:"Wires what happens on an interaction."}],j=p((e,n,t)=>({label:e,insertText:n,documentation:t}),"step"),Qn=[j("execute","execute ${1:command}","Runs a command."),j("navigate to","navigate to ${1:Screen}","Opens a screen."),j("open","open ${1:Dialog}","Opens a dialog."),j("close","close","Closes the dialog."),j("refresh","refresh ${1:query}","Reloads a query."),j("set","set ${1:name} ${2:value}","Sets a value."),j("notify",'notify ${1|info,warning,error|} "${2:message}"',"Shows a notification."),j("confirm","confirm ${1:message}\n on success\n ${2:execute command}","Asks before continuing."),j("raise","raise ${1:Trigger}","Raises a trigger.")],It=[j("on success",'on success\n ${1:notify info "Done"}',"What happens when it succeeds."),j("on failure",'on failure\n ${1:notify error "Failed"}',"What happens when it fails."),...Qn],At=[{label:"description",insertText:'description "${1:who they are}"',documentation:"A human-readable description."},{label:"policy",insertText:"policy ${1:PolicyName}",documentation:"A policy this persona holds."}],Et=[{label:"provider",insertText:"provider ${1:Name}",documentation:"An identity provider."},{label:"provider (named)",insertText:"provider ${1:Kind} name ${2:Name}",documentation:"An identity provider of a kind, under its own name."}],Lt=[{label:"for",insertText:'for ${1:"event-source-id"}\n ${2:EventType}\n ${3:property} = ${4:value}',documentation:"Events to seed for one event source id."}],Pt=[{label:"compatible with",insertText:"compatible with ${1:Package}",documentation:"A component package the theme is compatible with."}],qt=[{label:"target platform",insertText:"target platform ${1:web}",documentation:"The platforms the profile is for."},{label:"target size",insertText:"target size ${1|compact,regular|}",documentation:"The screen sizes the profile is for."},{label:"packages",insertText:"packages\n ${1:Package}",documentation:"The component packages the profile uses."},{label:"layout",insertText:"layout ${1:Layout}",documentation:"The layout of the profile."},{label:"theme",insertText:"theme ${1:Theme}",documentation:"The theme of the profile."}],Pe=[{label:"slot",insertText:"${1:slot}",documentation:"A named slot of the shell."},{label:"slot contributes",insertText:"${1:slot} contributes ${2:Name}",documentation:"A slot other declarations contribute to, such as `navigation contributes Navigation`."},{label:"arrangement",insertText:`arrangement flow
|
|
1
|
+
import{$ as Wn,A as ft,B as yt,C as P,D as E,E as An,F as En,G as Ln,H as Pn,I as B,J as gt,K as U,L as qn,M as W,N as ke,O as Nn,P as Ce,Q as Rn,R as te,S as Mn,T as On,U as jn,V as zn,Y as Fn,Z as Se,_ as Bn,a as N,aa as Vn,b as lt,ba as _n,c as ae,ca as Un,d as xe,da as De,e as X,f as kn,g as Cn,h as Te,i as G,j as Sn,k as Dn,l as mt,m as we,n as D,o as ut,p as ee,q as se,r as pt,s as dt,t as ht,u as I,v as k,w as In,x as L,y as F,z as V}from"./chunk-2E5TT2R2.js";import{a as p}from"./chunk-AYDF3IFZ.js";var bt=/[\p{L}\p{Mn}\p{Nd}\p{Pc}]/u,$t=p(e=>`\\u${e.toString(16).padStart(4,"0")}`,"escape");function Hn(){let e="";for(let n=0;n<=65535;n++){if(!bt.test(String.fromCharCode(n)))continue;let t=n;for(;n<65535&&bt.test(String.fromCharCode(n+1));)n++;e+=$t(t)+(n>t?`-${$t(n)}`:"")}return e}p(Hn,"ranges");var Z=Hn();var xt=new Set(["operation","system","eventsource"]),Ie={csharp:"csharp",typescript:"typescript",react:"typescript",html:"html",sql:"sql"};function vt(e){return`subLanguage_${e}`}p(vt,"subLanguageState");function Gn(e){let n=[...ae.filter(t=>!xt.has(t)),...e.map(t=>t.keyword)];return[new RegExp(`^\\s*(?:${n.join("|")})\\b`),{token:"@rematch",next:"@pop"}]}p(Gn,"subLanguageExitRule");var Zn=[[/\/\/.*$/,"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 Tt(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_][${Z}]*)(?=\\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"}]],...X.map(t=>[new RegExp(`^\\s*\\x60\\x60\\x60${t}\\s*$`),{token:"string.quote",next:`@codeBlock.${Ie[t]}`,nextEmbedded:Ie[t]}]),...X.map(t=>[new RegExp(`\\b${t}\\b(?=\\s*$)`),{token:"keyword.tag",next:`@codeBlockPending.${Ie[t]}`}]),...e.map(t=>[new RegExp(`\\b${t.keyword}\\b`),{token:"keyword",next:`@${vt(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*)([${Z}.]+)(\\s+)(rule)(\\s+)([A-Za-z_][${Z}]*)(?=\\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:Zn,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[vt(t.keyword)]=[Gn(e),...t.tokens,{include:"@common"},[/[A-Z]\w*/,"type.identifier"],[/[a-z_]\w*/,"identifier"]];return{defaultToken:"",tokenPostfix:".play",ignoreCase:!1,keywords:[...ae.filter(t=>!xt.has(t)),...xe,...X],sliceTypes:Te,primitiveTypes:G,tokenizer:n}}p(Tt,"createTokensProvider");var Ae=[{label:"on",insertText:"on ${1|click,select,submit,change,load,unload,enter,leave|}\n ${2:execute command}",documentation:"Wires what happens on an interaction - a click, a submit, entering or leaving the screen."},{label:"uses",insertText:"uses ${1:Behavior}",documentation:"Attaches a named behavior declared at the top level."}],Ee=[{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:'import "\u2026"',insertText:'import "${1:*/*.play}"',documentation:"Imports `.play` files into this module \u2014 their top level is the module's body."},{label:"feature",insertText:"feature ${1:Name}\n ",documentation:"Groups related slices into a vertical feature."},{label:"screen",insertText:"screen ${1:Name}\n data ${2:ReadModel} via query ${3:QueryName}",documentation:"Declares a module-level UI screen."},{label:"screen template",insertText:"screen template ${1:Name}\n fits slot ${2:content}\n\n ${3:slot}",documentation:"Declares a reusable screen shape that fits a slot of the shell."},{label:"dialog template",insertText:"dialog template ${1:Name}\n ${2:body}\n ${3:actions}",documentation:"Declares a reusable dialog shape that opens 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 slot of the shell, such as navigation."},...Ae],Le=[{label:"description",insertText:'description "${1:what this feature is for}"',documentation:"A human-readable description."},{label:"authorize",insertText:"authorize ${1:PolicyName}",documentation:"Policies that must pass for everything in the feature."},{label:'import "\u2026"',insertText:'import "${1:*.play}"',documentation:"Imports `.play` files into this feature \u2014 their top level is the feature's body."},{label:"feature",insertText:"feature ${1:Name}\n ",documentation:"Declares a nested sub-feature."},{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."},{label:"contribute",insertText:'contribute to ${1:Navigation}\n navigate to ${2:Screen}\n label "${3:Label}"',documentation:"Contributes an entry to a slot of the shell, such as navigation."},...Ae],wt=[{label:"description",insertText:'description "${1:what one instance holds}"',documentation:"A human-readable description."},{label:"file",insertText:"file ${1:Path}",documentation:"Names the file this read model is realized by."},{label:"property",insertText:"${1:property} ${2:Type}",documentation:"A property of the read model \u2014 a name and a type reference."}],kt=[{label:"description",insertText:'description "${1:what the reducer does}"',documentation:"A human-readable description."},{label:"on",insertText:"on ${1:EventType}\n ```csharp\n ${2}\n ```",documentation:"A rule applied when the event occurs, in code or from a file."}],Ct=[{label:"populate via query",insertText:"populate via query ${1:Query} by ${2:parameter}",documentation:"Fills the form from a query before it is shown."},{label:"populate from item",insertText:"populate from item",documentation:"Fills the form from the item the screen was opened for."},{label:"field",insertText:'field ${1:property} label "${2:Label}"',documentation:"A form field bound to a command property."},...Ae],St=[{label:"navigate to",insertText:"navigate to ${1:Screen}",documentation:"The screen the entry opens."},{label:"label",insertText:'label "${1:Label}"',documentation:"The text of the entry."},{label:"order",insertText:"order ${1:10}",documentation:"Where the entry sits among the others; lower comes first."}],Dt=[{label:"description",insertText:'description "${1:what the behavior does}"',documentation:"A human-readable description."},{label:"parameter",insertText:"parameter ${1:name} ${2:Type}",documentation:"A value the behavior is given where it is attached."},{label:"order",insertText:"order ${1:10}",documentation:"The order behaviors attached to the same element run in."},{label:"on",insertText:"on ${1|click,select,submit,change,load,unload,enter,leave|}\n ${2:execute command}",documentation:"Wires what happens on an interaction."}],j=p((e,n,t)=>({label:e,insertText:n,documentation:t}),"step"),Qn=[j("execute","execute ${1:command}","Runs a command."),j("navigate to","navigate to ${1:Screen}","Opens a screen."),j("open","open ${1:Dialog}","Opens a dialog."),j("close","close","Closes the dialog."),j("refresh","refresh ${1:query}","Reloads a query."),j("set","set ${1:name} ${2:value}","Sets a value."),j("notify",'notify ${1|info,warning,error|} "${2:message}"',"Shows a notification."),j("confirm","confirm ${1:message}\n on success\n ${2:execute command}","Asks before continuing."),j("raise","raise ${1:Trigger}","Raises a trigger.")],It=[j("on success",'on success\n ${1:notify info "Done"}',"What happens when it succeeds."),j("on failure",'on failure\n ${1:notify error "Failed"}',"What happens when it fails."),...Qn],At=[{label:"description",insertText:'description "${1:who they are}"',documentation:"A human-readable description."},{label:"policy",insertText:"policy ${1:PolicyName}",documentation:"A policy this persona holds."}],Et=[{label:"provider",insertText:"provider ${1:Name}",documentation:"An identity provider."},{label:"provider (named)",insertText:"provider ${1:Kind} name ${2:Name}",documentation:"An identity provider of a kind, under its own name."}],Lt=[{label:"for",insertText:'for ${1:"event-source-id"}\n ${2:EventType}\n ${3:property} = ${4:value}',documentation:"Events to seed for one event source id."}],Pt=[{label:"compatible with",insertText:"compatible with ${1:Package}",documentation:"A component package the theme is compatible with."}],qt=[{label:"target platform",insertText:"target platform ${1:web}",documentation:"The platforms the profile is for."},{label:"target size",insertText:"target size ${1|compact,regular|}",documentation:"The screen sizes the profile is for."},{label:"packages",insertText:"packages\n ${1:Package}",documentation:"The component packages the profile uses."},{label:"layout",insertText:"layout ${1:Layout}",documentation:"The layout of the profile."},{label:"theme",insertText:"theme ${1:Theme}",documentation:"The theme of the profile."}],Pe=[{label:"slot",insertText:"${1:slot}",documentation:"A named slot of the shell."},{label:"slot contributes",insertText:"${1:slot} contributes ${2:Name}",documentation:"A slot other declarations contribute to, such as `navigation contributes Navigation`."},{label:"arrangement",insertText:`arrangement flow
|
|
2
2
|
column
|
|
3
3
|
\${1:slot}`,documentation:"How the slots are placed."}],ce=[{label:"fits slot",insertText:"fits slot ${1:content}",documentation:"The slot of the shell the template fits."},...Pe,{label:"on",insertText:"on ${1|enter,leave,load,unload|}\n ${2:refresh query}",documentation:"Wires what happens on an interaction."}];var le=[{label:"optional",insertText:"optional",documentation:"Allows the complete value, including a collection, to be absent."}],R=p(e=>`\`\`\`${e}
|
|
4
4
|
\${1}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{T as ne,U as re,V as ie,W as q,X as oe,ea as se,x as te}from"../../chunk-X5DNGVII.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{T as ne,U as re,V as ie,W as q,X as oe,ea as se,x as te}from"../../chunk-2E5TT2R2.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