@cratis/screenplay-language 5.1.0 → 5.2.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.
@@ -0,0 +1,2 @@
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{eventDeclarations as e}from"../Syntax/EventDeclarations.js";const t=/* @__PURE__ */ new WeakMap;function foldedSources(e,n,r){let i=t.get(e);return i===void 0&&(i=foldedEvents(e),t.set(e,i)),i.get(n)?.get(r)??[]}function foldedEvents(e){let t,allEvents=()=>t??=declaredEvents(e);return new Map(e.slices.map(({slice:t})=>[t,publishedEvents(t,e,allEvents)]))}function publishedEvents(e,t,n){let r=/* @__PURE__ */ new Map;for(let i of e.projections){let a=publishedEvent(i,e,t);if(a===null)continue;let o=r.get(a)??[];r.set(a,o);for(let r of i.blocks)o.push(...blockEvents(r,e,t,n))}return r}function publishedEvent(e,t,n){return e.readModel===null||n.resolve(e.readModel,t,e=>e.readModels)!==null?null:n.event(e.readModel,t)}function blockEvents(e,t,n,r){return e.kind===`FromSyntax`?e.events.map(e=>n.event(e.event,t)).filter(isEvent):e.kind===`EverySyntax`||e.kind===`AllSyntax`?r():[]}function declaredEvents(t){return t.slices.flatMap(n=>e(n.slice).map(e=>t.event(e.name,n.slice))).filter(isEvent)}function isEvent(e){return e!==null}export{foldedSources};
2
+ //# sourceMappingURL=FoldedEventSources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FoldedEventSources.js","names":["foldedEventsByPass","index","declarations","slice","event","declared","published","projection","target","folded","block","allEvents","owner","spec","eventDeclarations"],"sources":["../../../../../../Compiler/Parsing/FoldedEventSources.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { EventSyntax } from '../Syntax/Declarations';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { ProjectionBlockSyntax, ProjectionSyntax } from '../Syntax/Projections';\nimport { SliceSyntax } from '../Syntax/Structure';\nimport { RefusalDeclarations } from './RefusalDeclarations';\n\ntype FoldedEvents = ReadonlyMap<SliceSyntax, ReadonlyMap<EventSyntax, readonly EventSyntax[]>>;\n\n// An outbound event projection publishes the facts it folds, so those facts' event-source types are the event's.\n// Indexed once per validation pass (one RefusalDeclarations), per declaring slice, rather than resolved again for every lookup.\nconst foldedEventsByPass = new WeakMap<RefusalDeclarations, FoldedEvents>();\n\nexport function foldedSources(declarations: RefusalDeclarations, slice: SliceSyntax, event: EventSyntax): readonly EventSyntax[] {\n let index = foldedEventsByPass.get(declarations);\n if (index === undefined) {\n index = foldedEvents(declarations);\n foldedEventsByPass.set(declarations, index);\n }\n return index.get(slice)?.get(event) ?? [];\n}\n\nfunction foldedEvents(declarations: RefusalDeclarations): FoldedEvents {\n let declared: readonly EventSyntax[] | undefined;\n const allEvents = () => declared ??= declaredEvents(declarations);\n return new Map<SliceSyntax, ReadonlyMap<EventSyntax, readonly EventSyntax[]>>(declarations.slices.map(({ slice }) => [slice, publishedEvents(slice, declarations, allEvents)]));\n}\n\nfunction publishedEvents(slice: SliceSyntax, declarations: RefusalDeclarations, allEvents: () => readonly EventSyntax[]): ReadonlyMap<EventSyntax, readonly EventSyntax[]> {\n const published = new Map<EventSyntax, EventSyntax[]>();\n for (const projection of slice.projections) {\n const target = publishedEvent(projection, slice, declarations);\n if (target === null) continue;\n const folded = published.get(target) ?? [];\n published.set(target, folded);\n for (const block of projection.blocks) folded.push(...blockEvents(block, slice, declarations, allEvents));\n }\n return published;\n}\n\nfunction publishedEvent(projection: ProjectionSyntax, slice: SliceSyntax, declarations: RefusalDeclarations): EventSyntax | null {\n if (projection.readModel === null || declarations.resolve(projection.readModel, slice, owner => owner.readModels) !== null) return null;\n return declarations.event(projection.readModel, slice);\n}\n\nfunction blockEvents(block: ProjectionBlockSyntax, slice: SliceSyntax, declarations: RefusalDeclarations, allEvents: () => readonly EventSyntax[]): readonly EventSyntax[] {\n if (block.kind === 'FromSyntax') return block.events.map(spec => declarations.event(spec.event, slice)).filter(isEvent);\n return block.kind === 'EverySyntax' || block.kind === 'AllSyntax' ? allEvents() : [];\n}\n\nfunction declaredEvents(declarations: RefusalDeclarations): readonly EventSyntax[] {\n return declarations.slices.flatMap(owner => eventDeclarations(owner.slice).map(event => declarations.event(event.name, owner.slice))).filter(isEvent);\n}\n\nfunction isEvent(event: EventSyntax | null): event is EventSyntax {\n return event !== null;\n}\n"],"mappings":"wHAaA,MAAMA,kBAAqB,IAAI,QAE/B,SAAgB,cAAc,EAAmC,EAAoB,EAA4C,CAC7H,IAAIC,EAAQD,EAAmB,IAAIE,CAAY,EAK/C,OAJID,IAAU,IAAA,KACV,EAAQ,aAAaC,CAAY,EACjCF,EAAmB,IAAIE,EAAcD,CAAK,GAEvCA,EAAM,IAAIE,CAAK,CAAC,EAAE,IAAIC,CAAK,GAAK,CAAC,CAC5C,CAEA,SAAS,aAAa,EAAiD,CACnE,IAAIC,EACE,cAAkB,IAAa,eAAeH,CAAY,EAChE,OAAO,IAAI,IAAmEA,EAAa,OAAO,KAAK,CAAE,WAAY,CAACC,EAAO,gBAAgBA,EAAOD,EAAc,SAAS,CAAC,CAAC,CAAC,CAClL,CAEA,SAAS,gBAAgB,EAAoB,EAAmC,EAA2F,CACvK,IAAMI,kBAAY,IAAI,IACtB,IAAK,IAAMC,KAAcJ,EAAM,YAAa,CACxC,IAAMK,EAAS,eAAeD,EAAYJ,EAAOD,CAAY,EAC7D,GAAIM,IAAW,KAAM,SACrB,IAAMC,EAASH,EAAU,IAAIE,CAAM,GAAK,CAAC,EACzCF,EAAU,IAAIE,EAAQC,CAAM,EAC5B,IAAK,IAAMC,KAASH,EAAW,OAAQE,EAAO,KAAK,GAAG,YAAYC,EAAOP,EAAOD,EAAcS,CAAS,CAAC,CAC5G,CACA,OAAOL,CACX,CAEA,SAAS,eAAe,EAA8B,EAAoB,EAAuD,CAE7H,OADIC,EAAW,YAAc,MAAQL,EAAa,QAAQK,EAAW,UAAWJ,EAAO,GAASS,EAAM,UAAU,IAAM,KAAa,KAC5HV,EAAa,MAAMK,EAAW,UAAWJ,CAAK,CACzD,CAEA,SAAS,YAAY,EAA8B,EAAoB,EAAmC,EAAiE,CAEvK,OADIO,EAAM,OAAS,aAAqBA,EAAM,OAAO,IAAI,GAAQR,EAAa,MAAMW,EAAK,MAAOV,CAAK,CAAC,CAAC,CAAC,OAAO,OAAO,EAC/GO,EAAM,OAAS,eAAiBA,EAAM,OAAS,YAAcC,EAAU,EAAI,CAAC,CACvF,CAEA,SAAS,eAAe,EAA2D,CAC/E,OAAOT,EAAa,OAAO,QAAQ,GAASY,EAAkBF,EAAM,KAAK,CAAC,CAAC,IAAI,GAASV,EAAa,MAAME,EAAM,KAAMQ,EAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,OAAO,CACxJ,CAEA,SAAS,QAAQ,EAAiD,CAC9D,OAAOR,IAAU,IACrB"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{AuthoringProductionResolver as t}from"../Syntax/AuthoringProductionResolver.js";import{diagnosticText as n}from"../Diagnostics/DiagnosticArgument.js";import{EventSourceCatalog as r}from"../Syntax/EventSourceCatalog.js";import{specificationExamples as i}from"./SpecificationCommandExamples.js";import{compatibleValue as a}from"./ResponseValidator.js";import{commandDestinationType as o}from"./CommandDestinationTypes.js";import{RefusalDeclarations as s}from"./RefusalDeclarations.js";const c=/* @__PURE__ */ new Set([`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`]);function validateSpecificationCases(t,o,l){let u=new s(t),d=i(t),knownType=e=>c.has(e)||u.concepts.has(e)||u.types.has(e),f=new Map([...u.types].map(([e,t])=>[e,new Map(t.properties.map(e=>[e.name,e]))])),p=l===void 0?u.slices:[{scope:[],slice:{kind:`SliceSyntax`,type:`StateChange`,name:``,description:null,location:t.location,events:[],commands:[],queries:[],projections:[],captures:[],reactions:[],constraints:[],readModels:[],screens:[],specifications:l}}];for(let{slice:i,scope:s}of p){let c=/* @__PURE__ */ new Map;for(let e of i.specifications){let t=(e.cases?.length??0)===0?[e.name]:e.cases.map(t=>`${e.name}_${t.name}`);for(let e of t)c.set(e,(c.get(e)??0)+1);(e.cases?.length??0)>0&&c.set(e.name,(c.get(e.name)??0)+1)}for(let p of i.specifications){for(let t of p.cases??[])(c.get(`${p.name}_${t.name}`)??0)>1&&o.error(e.SpecificationCaseNameCollision,`Case '${t.name}' derives specification '${p.name}_${t.name}', which collides in this ${l===void 0?`slice`:`document`}.`,t.location);for(let t of p.parameters??[]){l===void 0&&!knownType(t.type.name)&&o.error(e.IncompatibleSpecificationParameterType,`Parameter '${t.name}' has unknown type '${t.type.name}'.`,t.type.location);for(let r of p.cases??[])for(let i of r.values.filter(e=>e.property===t.name))a(i.source,t.type,u.concepts,f)||o.error(e.InvalidSpecificationCaseValue,`Case '${r.name}' parameter '${t.name}' requires a concrete value of type '${t.type.name}'.`,i.source.location,{...n(`case`,r.name),...n(`parameter`,t.name),...n(`type`,t.type.name)})}let check=(t,n,r)=>{if(t?.kind!==`CaseValueExpressionSyntax`||n===void 0)return;let i=p.parameters?.find(e=>e.name===t.parameter);if(i===void 0||(i.type.isOptional&&!n.isOptional&&o.error(e.OptionalSpecificationParameterTarget,`Optional parameter '${i.name}' cannot supply required target '${r}'.`,t.location),l!==void 0&&(!knownType(i.type.name)||!knownType(n.name))))return;let a=u.concepts.get(i.type.name),s=u.concepts.get(n.name);(!(i.type.name===n.name||a?.type!==`Enum`&&a?.type===n.name||s?.type!==`Enum`&&s?.type===i.type.name)||i.type.isCollection!==n.isCollection)&&o.error(e.IncompatibleSpecificationParameterType,`Parameter '${i.name}' type '${i.type.name}' is incompatible with target '${r}' type '${n.name}'.`,t.location)},assignments=(e,t)=>{for(let n of e)check(n.source,u.property(t,n.property)?.type,n.property)},m=d.command(p.when,s);if(m!==null){let e=u.resolve(m.commandType,i,e=>e.commands)?.node.properties??null;assignments(m.values,e),assignments(m.generatedValues??[],e),check(m.for,e?.find(e=>e.isIdentifier)?.type,`for`)}if(m!==null&&p.thenReturns!=null){let e=u.resolve(m.commandType,i,e=>e.commands)?.node,t=e?.response;if(p.thenReturns.kind===`ScalarSpecificationReturnSyntax`&&t?.kind===`ScalarCommandResponseSyntax`&&check(p.thenReturns.value,e?.properties.find(e=>e.name===t.source.property)?.type,`value`),p.thenReturns.kind===`RecordSpecificationReturnSyntax`&&t?.kind===`RecordCommandResponseSyntax`)for(let n of p.thenReturns.fields){let r=t.fields.find(e=>e.name===n.property);check(n.source,r?.type??e?.properties.find(e=>e.name===r?.source.property)?.type,n.property)}}for(let e of[...p.given,...p.thenEvents,...p.whenAppended===null?[]:[p.whenAppended]]){let n=d.eventStep(e,`given`,s).effective;assignments(n.values,u.event(n.eventType,i)?.properties??null);let a=n.stream==null?null:new r(t).resolve(n.stream.eventSource,n.stream.stream),o=a?.kind===`unique`?a.sources[0]:void 0,c=a?.kind===`unique`?a.streams[0]:void 0;check(n.for,n.stream!=null&&o===void 0?void 0:o?.identifier??eventDestinationType(n.eventType,i,t,u),`for`),n.stream?.streamId!=null&&check(n.stream.streamId.source,c?.streamId??void 0,`streamId`);for(let e of n.stream?.streamIdParts??[])check(e.source,c?.streamIdParts.find(t=>t.name===e.property)?.type,e.property)}for(let e of[...p.givenReadModels,...p.thenReadModels]){let t=d.readModel(e,s);assignments(t.properties,u.resolve(t.name,i,e=>e.readModels)?.node.properties??null)}if(p.whenTrigger!=null){let e=(t.declaredTriggers??[]).find(e=>e.name===p.whenTrigger.trigger);for(let t of p.whenTrigger.values)check(t.source,e?.data.find(e=>e.name===t.property)?.type,t.property)}for(let e of p.thenErrors)check(e.caseValue??null,{kind:`TypeRefSyntax`,name:`String`,isOptional:!1,isCollection:!1,location:e.location},`message`);for(let e of p.thenAbsentReadModels??[]){let t=u.resolve(e.name,i,e=>e.readModels)?.node,n=u.slices.flatMap(({slice:e})=>e.queries.filter(n=>n.by!==null&&u.resolve(n.returnType.name,e,e=>e.readModels)?.node===t));check(e.key,t!==void 0&&n.length===1?n[0].by.type:void 0,`for`)}for(let e of[...p.thenQueries??[],...p.whenQuery===null?[]:[p.whenQuery]]){let t=u.resolve(e.query,i,e=>e.queries),n=t===null?[]:[...t.node.by===null?[]:[t.node.by],...t.node.filters].map(e=>({...e,kind:`PropertySyntax`,isIdentifier:!1}));assignments(e.arguments,n);let r=t===null?null:u.resolve(t.node.returnType.name,t.slice,e=>e.readModels)?.node.properties??null,a=e.kind===`SpecificationQuerySyntax`?e.results:p.thenResults;for(let e of a)assignments(e.properties,r)}}}}function uniqueDestinationType(e){let t=new Map(e.map(e=>[JSON.stringify([e.name,e.isOptional,e.isCollection]),e]));return t.size===1?[...t.values()][0]:void 0}function eventDestinationType(e,n,r,i){let a=new t(r),s=i.event(e,n);if(s===null)return;let commandTypes=(e,t=i.slices)=>t.flatMap(({slice:t})=>t.commands.flatMap(n=>n.produces.filter(n=>a.isEventProduction(n,t)&&i.event(n.event,t)===e).map(e=>o(n,e,r,{resolver:a,slice:t})).filter(e=>e!==null))),producerTypes=(e,t)=>{if(t.has(e))return[];t.add(e);let n=commandTypes(e);for(let{slice:a}of i.slices){for(let o of a.reactions.flatMap(e=>e.triggers)){let s=o.source.kind===`NamedTriggerSourceSyntax`?o.source.name:void 0,c=s===void 0?null:i.event(s,a);for(let l of o.produces.filter(t=>i.event(t.event,a)===e))if(l.for?.kind===`PathExpressionSyntax`){let e=l.for.path,t=i.property(c?.properties??null,e)?.type??(s===void 0?void 0:(r.declaredTriggers??[]).find(e=>e.name===s)?.data.find(t=>t.name===e)?.type);t!==void 0&&n.push(t)}else l.for?.kind===`LiteralExpressionSyntax`?n.push({kind:`TypeRefSyntax`,name:`String`,isOptional:!1,isCollection:!1,location:l.location}):l.for===null&&c!==null&&n.push(...producerTypes(c,t))}a.captures.flatMap(e=>[...e.appends,...e.children.flatMap(e=>e.appends),...e.nested.flatMap(e=>e.appends)]).some(t=>i.event(t.event,a)===e)&&n.push(uniqueDestinationType(commandTypes(e))??{kind:`TypeRefSyntax`,name:`String`,isOptional:!1,isCollection:!1,location:e.location})}return n};return uniqueDestinationType(commandTypes(s,i.slices.filter(e=>e.slice===n)))??uniqueDestinationType(commandTypes(s))??uniqueDestinationType(producerTypes(s,/* @__PURE__ */ new Set))}export{validateSpecificationCases};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{AuthoringProductionResolver as t}from"../Syntax/AuthoringProductionResolver.js";import{diagnosticText as n}from"../Diagnostics/DiagnosticArgument.js";import{EventSourceCatalog as r}from"../Syntax/EventSourceCatalog.js";import{specificationExamples as i}from"./SpecificationCommandExamples.js";import{compatibleValue as a}from"./ResponseValidator.js";import{commandDestinationType as o}from"./CommandDestinationTypes.js";import{RefusalDeclarations as s}from"./RefusalDeclarations.js";import{foldedSources as c}from"./FoldedEventSources.js";const l=/* @__PURE__ */ new Set([`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`]);function validateSpecificationCases(t,o,c){let u=new s(t),d=i(t),f=eventDestinationTypes(t,u),knownType=e=>l.has(e)||u.concepts.has(e)||u.types.has(e),p=new Map([...u.types].map(([e,t])=>[e,new Map(t.properties.map(e=>[e.name,e]))])),m=c===void 0?u.slices:[{scope:[],slice:{kind:`SliceSyntax`,type:`StateChange`,name:``,description:null,location:t.location,events:[],commands:[],queries:[],projections:[],captures:[],reactions:[],constraints:[],readModels:[],screens:[],specifications:c}}];for(let{slice:i,scope:s}of m){let l=/* @__PURE__ */ new Map;for(let e of i.specifications){let t=(e.cases?.length??0)===0?[e.name]:e.cases.map(t=>`${e.name}_${t.name}`);for(let e of t)l.set(e,(l.get(e)??0)+1);(e.cases?.length??0)>0&&l.set(e.name,(l.get(e.name)??0)+1)}for(let m of i.specifications){for(let t of m.cases??[])(l.get(`${m.name}_${t.name}`)??0)>1&&o.error(e.SpecificationCaseNameCollision,`Case '${t.name}' derives specification '${m.name}_${t.name}', which collides in this ${c===void 0?`slice`:`document`}.`,t.location);for(let t of m.parameters??[]){c===void 0&&!knownType(t.type.name)&&o.error(e.IncompatibleSpecificationParameterType,`Parameter '${t.name}' has unknown type '${t.type.name}'.`,t.type.location);for(let r of m.cases??[])for(let i of r.values.filter(e=>e.property===t.name))a(i.source,t.type,u.concepts,p)||o.error(e.InvalidSpecificationCaseValue,`Case '${r.name}' parameter '${t.name}' requires a concrete value of type '${t.type.name}'.`,i.source.location,{...n(`case`,r.name),...n(`parameter`,t.name),...n(`type`,t.type.name)})}let check=(t,n,r)=>{if(t?.kind!==`CaseValueExpressionSyntax`||n===void 0)return;let i=m.parameters?.find(e=>e.name===t.parameter);if(i===void 0||(i.type.isOptional&&!n.isOptional&&o.error(e.OptionalSpecificationParameterTarget,`Optional parameter '${i.name}' cannot supply required target '${r}'.`,t.location),c!==void 0&&(!knownType(i.type.name)||!knownType(n.name))))return;let a=u.concepts.get(i.type.name),s=u.concepts.get(n.name);(!(i.type.name===n.name||a?.type!==`Enum`&&a?.type===n.name||s?.type!==`Enum`&&s?.type===i.type.name)||i.type.isCollection!==n.isCollection)&&o.error(e.IncompatibleSpecificationParameterType,`Parameter '${i.name}' type '${i.type.name}' is incompatible with target '${r}' type '${n.name}'.`,t.location)},assignments=(e,t)=>{for(let n of e)check(n.source,u.property(t,n.property)?.type,n.property)},h=d.command(m.when,s);if(h!==null){let e=u.resolve(h.commandType,i,e=>e.commands)?.node.properties??null;assignments(h.values,e),assignments(h.generatedValues??[],e),check(h.for,e?.find(e=>e.isIdentifier)?.type,`for`)}if(h!==null&&m.thenReturns!=null){let e=u.resolve(h.commandType,i,e=>e.commands)?.node,t=e?.response;if(m.thenReturns.kind===`ScalarSpecificationReturnSyntax`&&t?.kind===`ScalarCommandResponseSyntax`&&check(m.thenReturns.value,e?.properties.find(e=>e.name===t.source.property)?.type,`value`),m.thenReturns.kind===`RecordSpecificationReturnSyntax`&&t?.kind===`RecordCommandResponseSyntax`)for(let n of m.thenReturns.fields){let r=t.fields.find(e=>e.name===n.property);check(n.source,r?.type??e?.properties.find(e=>e.name===r?.source.property)?.type,n.property)}}for(let e of[...m.given,...m.thenEvents,...m.whenAppended===null?[]:[m.whenAppended]]){let n=d.eventStep(e,`given`,s).effective;assignments(n.values,u.event(n.eventType,i)?.properties??null);let a=n.stream==null?null:new r(t).resolve(n.stream.eventSource,n.stream.stream),o=a?.kind===`unique`?a.sources[0]:void 0,c=a?.kind===`unique`?a.streams[0]:void 0;check(n.for,n.stream!=null&&o===void 0?void 0:o?.identifier??f(n.eventType,i),`for`),n.stream?.streamId!=null&&check(n.stream.streamId.source,c?.streamId??void 0,`streamId`);for(let e of n.stream?.streamIdParts??[])check(e.source,c?.streamIdParts.find(t=>t.name===e.property)?.type,e.property)}for(let e of[...m.givenReadModels,...m.thenReadModels]){let t=d.readModel(e,s);assignments(t.properties,u.resolve(t.name,i,e=>e.readModels)?.node.properties??null)}if(m.whenTrigger!=null){let e=(t.declaredTriggers??[]).find(e=>e.name===m.whenTrigger.trigger);for(let t of m.whenTrigger.values)check(t.source,e?.data.find(e=>e.name===t.property)?.type,t.property)}for(let e of m.thenErrors)check(e.caseValue??null,{kind:`TypeRefSyntax`,name:`String`,isOptional:!1,isCollection:!1,location:e.location},`message`);for(let e of m.thenAbsentReadModels??[]){let t=u.resolve(e.name,i,e=>e.readModels)?.node,n=u.slices.flatMap(({slice:e})=>e.queries.filter(n=>n.by!==null&&u.resolve(n.returnType.name,e,e=>e.readModels)?.node===t));check(e.key,t!==void 0&&n.length===1?n[0].by.type:void 0,`for`)}for(let e of[...m.thenQueries??[],...m.whenQuery===null?[]:[m.whenQuery]]){let t=u.resolve(e.query,i,e=>e.queries),n=t===null?[]:[...t.node.by===null?[]:[t.node.by],...t.node.filters].map(e=>({...e,kind:`PropertySyntax`,isIdentifier:!1}));assignments(e.arguments,n);let r=t===null?null:u.resolve(t.node.returnType.name,t.slice,e=>e.readModels)?.node.properties??null,a=e.kind===`SpecificationQuerySyntax`?e.results:m.thenResults;for(let e of a)assignments(e.properties,r)}}}}function uniqueDestinationType(e){let t=new Map(e.map(e=>[JSON.stringify([e.name,e.isOptional,e.isCollection]),e]));return t.size===1?[...t.values()][0]:void 0}function eventDestinationTypes(e,t){let n=/* @__PURE__ */ new Map;return(r,i)=>{let a=t.event(r,i);if(a===null)return;let o=n.get(i);return o===void 0&&n.set(i,o=/* @__PURE__ */ new Map),o.has(a)||o.set(a,producedDestinationType(a,i,e,t)),o.get(a)}}function producedDestinationType(e,n,r,i){let a=new t(r),commandTypes=(e,t=i.slices)=>t.flatMap(({slice:t})=>t.commands.flatMap(n=>n.produces.filter(n=>a.isEventProduction(n,t)&&i.event(n.event,t)===e).map(e=>o(n,e,r,{resolver:a,slice:t})).filter(e=>e!==null))),producerTypes=(e,t)=>{if(t.has(e))return[];t.add(e);let n=commandTypes(e);for(let{slice:a}of i.slices){for(let o of a.reactions.flatMap(e=>e.triggers)){let s=o.source.kind===`NamedTriggerSourceSyntax`?o.source.name:void 0,c=s===void 0?null:i.event(s,a);for(let l of o.produces.filter(t=>i.event(t.event,a)===e))if(l.for?.kind===`PathExpressionSyntax`){let e=l.for.path,t=i.property(c?.properties??null,e)?.type??(s===void 0?void 0:(r.declaredTriggers??[]).find(e=>e.name===s)?.data.find(t=>t.name===e)?.type);t!==void 0&&n.push(t)}else l.for?.kind===`LiteralExpressionSyntax`?n.push({kind:`TypeRefSyntax`,name:`String`,isOptional:!1,isCollection:!1,location:l.location}):l.for===null&&c!==null&&n.push(...producerTypes(c,t))}a.captures.flatMap(e=>[...e.appends,...e.children.flatMap(e=>e.appends),...e.nested.flatMap(e=>e.appends)]).some(t=>i.event(t.event,a)===e)&&n.push(uniqueDestinationType(commandTypes(e))??{kind:`TypeRefSyntax`,name:`String`,isOptional:!1,isCollection:!1,location:e.location}),n.push(...c(i,a,e).flatMap(e=>producerTypes(e,t)))}return n};return uniqueDestinationType(commandTypes(e,i.slices.filter(e=>e.slice===n)))??uniqueDestinationType(commandTypes(e))??uniqueDestinationType(producerTypes(e,/* @__PURE__ */ new Set))}export{validateSpecificationCases};
2
2
  //# sourceMappingURL=SpecificationCaseValidator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SpecificationCaseValidator.js","names":["primitives","declarations","RefusalDeclarations","application","examples","specificationExamples","name","composites","type","property","owners","standaloneSpecifications","names","specification","slice","expandedNames","row","context","DiagnosticCodes","parameter","assignment","value","compatibleValue","diagnosticText","expression","target","sourceConcept","targetConcept","values","properties","command","scope","declaration","response","field","authored","event","route","EventSourceCatalog","source","stream","part","model","trigger","error","absent","keyed","owner","query","parameters","results","result","distinct","types","resolver","AuthoringProductionResolver","reference","local","produced","commandDestinationType","visited","reaction","sourceName","path","declared","capture","child","nested","append"],"sources":["../../../../../../Compiler/Parsing/SpecificationCaseValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { EventSyntax, PropertySyntax, TypeRefSyntax } from '../Syntax/Declarations';\nimport { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { EventSourceCatalog } from '../Syntax/EventSourceCatalog';\nimport { EventSourceResolutionKind } from '../Syntax/EventSources';\nimport { SpecificationSyntax } from '../Syntax/Specifications';\nimport { commandDestinationType } from './CommandDestinationTypes';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { ApplicationSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\nimport { RefusalDeclarations } from './RefusalDeclarations';\nimport { compatibleValue } from './ResponseValidator';\nimport { specificationExamples } from './SpecificationCommandExamples';\n\nconst primitives = new Set(['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime']);\n\nexport function validateSpecificationCases(application: ApplicationSyntax, context: ParserContext, standaloneSpecifications?: readonly SpecificationSyntax[]): void {\n const declarations = new RefusalDeclarations(application);\n const examples = specificationExamples(application);\n const knownType = (name: string) => primitives.has(name) || declarations.concepts.has(name) || declarations.types.has(name);\n const composites = new Map([...declarations.types].map(([name, type]) => [name, new Map(type.properties.map(property => [property.name, property]))]));\n const owners = standaloneSpecifications === undefined ? declarations.slices : [{ scope: [], slice: {\n kind: 'SliceSyntax' as const, type: 'StateChange' as const, name: '', description: null, location: application.location,\n events: [], commands: [], queries: [], projections: [], captures: [], reactions: [], constraints: [], readModels: [], screens: [], specifications: standaloneSpecifications,\n } }];\n for (const { slice, scope } of owners) {\n const names = new Map<string, number>();\n for (const specification of slice.specifications) {\n const expandedNames = (specification.cases?.length ?? 0) === 0 ? [specification.name] : specification.cases!.map(row => `${specification.name}_${row.name}`);\n for (const name of expandedNames) names.set(name, (names.get(name) ?? 0) + 1);\n if ((specification.cases?.length ?? 0) > 0) names.set(specification.name, (names.get(specification.name) ?? 0) + 1);\n }\n for (const specification of slice.specifications) {\n for (const row of specification.cases ?? []) {\n if ((names.get(`${specification.name}_${row.name}`) ?? 0) > 1) context.error(DiagnosticCodes.SpecificationCaseNameCollision, `Case '${row.name}' derives specification '${specification.name}_${row.name}', which collides in this ${standaloneSpecifications === undefined ? 'slice' : 'document'}.`, row.location);\n }\n for (const parameter of specification.parameters ?? []) {\n if (standaloneSpecifications === undefined && !knownType(parameter.type.name)) context.error(DiagnosticCodes.IncompatibleSpecificationParameterType, `Parameter '${parameter.name}' has unknown type '${parameter.type.name}'.`, parameter.type.location);\n for (const row of specification.cases ?? []) {\n for (const assignment of row.values.filter(value => value.property === parameter.name)) {\n if (!compatibleValue(assignment.source, parameter.type, declarations.concepts, composites)) context.error(DiagnosticCodes.InvalidSpecificationCaseValue, `Case '${row.name}' parameter '${parameter.name}' requires a concrete value of type '${parameter.type.name}'.`, assignment.source.location, { ...diagnosticText('case', row.name), ...diagnosticText('parameter', parameter.name), ...diagnosticText('type', parameter.type.name) });\n }\n }\n }\n const check = (expression: ExpressionSyntax | null, target: TypeRefSyntax | undefined, property: string) => {\n if (expression?.kind !== 'CaseValueExpressionSyntax' || target === undefined) return;\n const parameter = specification.parameters?.find(parameter => parameter.name === expression.parameter);\n if (parameter === undefined) return;\n if (parameter.type.isOptional && !target.isOptional) context.error(DiagnosticCodes.OptionalSpecificationParameterTarget, `Optional parameter '${parameter.name}' cannot supply required target '${property}'.`, expression.location);\n if (standaloneSpecifications !== undefined && (!knownType(parameter.type.name) || !knownType(target.name))) return;\n const sourceConcept = declarations.concepts.get(parameter.type.name);\n const targetConcept = declarations.concepts.get(target.name);\n const compatible = parameter.type.name === target.name || sourceConcept?.type !== 'Enum' && sourceConcept?.type === target.name || targetConcept?.type !== 'Enum' && targetConcept?.type === parameter.type.name;\n if (!compatible || parameter.type.isCollection !== target.isCollection) context.error(DiagnosticCodes.IncompatibleSpecificationParameterType, `Parameter '${parameter.name}' type '${parameter.type.name}' is incompatible with target '${property}' type '${target.name}'.`, expression.location);\n };\n const assignments = (values: readonly PropertyMappingSyntax[], properties: readonly PropertySyntax[] | null) => {\n for (const value of values) check(value.source, declarations.property(properties, value.property)?.type, value.property);\n };\n const command = examples.command(specification.when, scope);\n if (command !== null) {\n const properties = declarations.resolve(command.commandType, slice, slice => slice.commands)?.node.properties ?? null;\n assignments(command.values, properties);\n assignments(command.generatedValues ?? [], properties);\n check(command.for, properties?.find(property => property.isIdentifier)?.type, 'for');\n }\n if (command !== null && specification.thenReturns != null) {\n const declaration = declarations.resolve(command.commandType, slice, slice => slice.commands)?.node;\n const response = declaration?.response;\n if (specification.thenReturns.kind === 'ScalarSpecificationReturnSyntax' && response?.kind === 'ScalarCommandResponseSyntax') check(specification.thenReturns.value, declaration?.properties.find(property => property.name === response.source.property)?.type, 'value');\n if (specification.thenReturns.kind === 'RecordSpecificationReturnSyntax' && response?.kind === 'RecordCommandResponseSyntax') {\n for (const value of specification.thenReturns.fields) {\n const field = response.fields.find(field => field.name === value.property);\n check(value.source, field?.type ?? declaration?.properties.find(property => property.name === field?.source.property)?.type, value.property);\n }\n }\n }\n for (const authored of [...specification.given, ...specification.thenEvents, ...(specification.whenAppended === null ? [] : [specification.whenAppended])]) {\n const event = examples.eventStep(authored, 'given', scope).effective as typeof authored;\n assignments(event.values, declarations.event(event.eventType, slice)?.properties ?? null);\n const route = event.stream == null ? null : new EventSourceCatalog(application).resolve(event.stream.eventSource, event.stream.stream);\n const source = route?.kind === EventSourceResolutionKind.Unique ? route.sources[0] : undefined;\n const stream = route?.kind === EventSourceResolutionKind.Unique ? route.streams[0] : undefined;\n check(event.for, event.stream != null && source === undefined ? undefined : source?.identifier ?? eventDestinationType(event.eventType, slice, application, declarations), 'for');\n if (event.stream?.streamId != null) check(event.stream.streamId.source, stream?.streamId ?? undefined, 'streamId');\n for (const part of event.stream?.streamIdParts ?? []) check(part.source, stream?.streamIdParts.find(declaration => declaration.name === part.property)?.type, part.property);\n }\n for (const authored of [...specification.givenReadModels, ...specification.thenReadModels]) {\n const model = examples.readModel(authored, scope);\n assignments(model.properties, declarations.resolve(model.name, slice, slice => slice.readModels)?.node.properties ?? null);\n }\n if (specification.whenTrigger != null) {\n const trigger = (application.declaredTriggers ?? []).find(trigger => trigger.name === specification.whenTrigger!.trigger);\n for (const value of specification.whenTrigger.values) check(value.source, trigger?.data.find(property => property.name === value.property)?.type, value.property);\n }\n for (const error of specification.thenErrors) check(error.caseValue ?? null, { kind: 'TypeRefSyntax', name: 'String', isOptional: false, isCollection: false, location: error.location }, 'message');\n for (const absent of specification.thenAbsentReadModels ?? []) {\n const model = declarations.resolve(absent.name, slice, slice => slice.readModels)?.node;\n const keyed = declarations.slices.flatMap(({ slice: owner }) => owner.queries.filter(query => query.by !== null && declarations.resolve(query.returnType.name, owner, slice => slice.readModels)?.node === model));\n check(absent.key, model !== undefined && keyed.length === 1 ? keyed[0].by!.type : undefined, 'for');\n }\n for (const query of [...(specification.thenQueries ?? []), ...(specification.whenQuery === null ? [] : [specification.whenQuery])]) {\n const declaration = declarations.resolve(query.query, slice, slice => slice.queries);\n const parameters = declaration === null ? [] : [...(declaration.node.by === null ? [] : [declaration.node.by]), ...declaration.node.filters].map(parameter => ({ ...parameter, kind: 'PropertySyntax' as const, isIdentifier: false }));\n assignments(query.arguments, parameters);\n const properties = declaration === null ? null : declarations.resolve(declaration.node.returnType.name, declaration.slice, slice => slice.readModels)?.node.properties ?? null;\n const results = query.kind === 'SpecificationQuerySyntax' ? query.results : specification.thenResults;\n for (const result of results) assignments(result.properties, properties);\n }\n }\n }\n}\n\nfunction uniqueDestinationType(types: readonly TypeRefSyntax[]): TypeRefSyntax | undefined {\n const distinct = new Map(types.map(type => [JSON.stringify([type.name, type.isOptional, type.isCollection]), type]));\n return distinct.size === 1 ? [...distinct.values()][0] : undefined;\n}\n\nfunction eventDestinationType(reference: string, local: SliceSyntax, application: ApplicationSyntax, declarations: RefusalDeclarations): TypeRefSyntax | undefined {\n const resolver = new AuthoringProductionResolver(application);\n const event = declarations.event(reference, local);\n if (event === null) return undefined;\n const commandTypes = (event: EventSyntax, owners = declarations.slices): TypeRefSyntax[] => owners.flatMap(({ slice }) => slice.commands.flatMap(command => command.produces\n .filter(produced => resolver.isEventProduction(produced, slice) && declarations.event(produced.event, slice) === event)\n .map(produced => commandDestinationType(command, produced, application, { resolver, slice })).filter((type): type is TypeRefSyntax => type !== null)));\n const producerTypes = (event: EventSyntax, visited: Set<EventSyntax>): TypeRefSyntax[] => {\n if (visited.has(event)) return [];\n visited.add(event);\n const types = commandTypes(event);\n for (const { slice } of declarations.slices) {\n for (const trigger of slice.reactions.flatMap(reaction => reaction.triggers)) {\n const sourceName = trigger.source.kind === 'NamedTriggerSourceSyntax' ? trigger.source.name : undefined;\n const source = sourceName === undefined ? null : declarations.event(sourceName, slice);\n for (const produced of trigger.produces.filter(produced => declarations.event(produced.event, slice) === event)) {\n if (produced.for?.kind === 'PathExpressionSyntax') {\n const path = produced.for.path;\n const type = declarations.property(source?.properties ?? null, path)?.type ?? (sourceName === undefined ? undefined\n : (application.declaredTriggers ?? []).find(declared => declared.name === sourceName)?.data.find(property => property.name === path)?.type);\n if (type !== undefined) types.push(type);\n } else if (produced.for?.kind === 'LiteralExpressionSyntax') types.push({ kind: 'TypeRefSyntax', name: 'String', isOptional: false, isCollection: false, location: produced.location });\n else if (produced.for === null && source !== null) types.push(...producerTypes(source, visited));\n }\n }\n if (slice.captures.flatMap(capture => [...capture.appends, ...capture.children.flatMap(child => child.appends), ...capture.nested.flatMap(nested => nested.appends)]).some(append => declarations.event(append.event, slice) === event))\n types.push(uniqueDestinationType(commandTypes(event)) ?? { kind: 'TypeRefSyntax', name: 'String', isOptional: false, isCollection: false, location: event.location });\n }\n return types;\n };\n return uniqueDestinationType(commandTypes(event, declarations.slices.filter(owner => owner.slice === local))) ?? uniqueDestinationType(commandTypes(event)) ?? uniqueDestinationType(producerTypes(event, new Set()));\n}\n"],"mappings":"mmBAkBA,MAAMA,kBAAa,IAAI,IAAI,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,UAAU,CAAC,EAE3F,SAAgB,2BAA2B,EAAgC,EAAwB,EAAiE,CAChK,IAAMC,EAAe,IAAIC,EAAoBC,CAAW,EAClDC,EAAWC,EAAsBF,CAAW,EAC5C,UAAa,GAAiBH,EAAW,IAAIM,CAAI,GAAKL,EAAa,SAAS,IAAIK,CAAI,GAAKL,EAAa,MAAM,IAAIK,CAAI,EACpHC,EAAa,IAAI,IAAI,CAAC,GAAGN,EAAa,KAAK,CAAC,CAAC,KAAK,CAACK,EAAME,KAAU,CAACF,EAAM,IAAI,IAAIE,EAAK,WAAW,IAAI,GAAY,CAACC,EAAS,KAAMA,CAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAC/IC,EAASC,IAA6B,IAAA,GAAYV,EAAa,OAAS,CAAC,CAAE,MAAO,CAAC,EAAG,MAAO,CAC/F,KAAM,cAAwB,KAAM,cAAwB,KAAM,GAAI,YAAa,K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,MAAMmE,EAAO,MAAOtD,CAAK,IAAMsB,CAAK,GAClOiB,EAAM,KAAK,sBAAsB,aAAajB,CAAK,CAAC,GAAK,CAAE,KAAM,gBAAiB,KAAM,SAAU,WAAY,GAAO,aAAc,GAAO,SAAUA,EAAM,QAAS,CAAC,CAC5K,CACA,OAAOiB,CACX,EACA,OAAO,sBAAsB,aAAajB,EAAOnC,EAAa,OAAO,OAAO,GAAS8C,EAAM,QAAUU,CAAK,CAAC,CAAC,GAAK,sBAAsB,aAAarB,CAAK,CAAC,GAAK,sBAAsB,cAAcA,kBAAO,IAAI,GAAK,CAAC,CACxN"}
1
+ {"version":3,"file":"SpecificationCaseValidator.js","names":["primitives","declarations","RefusalDeclarations","application","examples","specificationExamples","destinationType","name","composites","type","property","owners","standaloneSpecifications","names","specification","slice","expandedNames","row","context","DiagnosticCodes","parameter","assignment","value","compatibleValue","diagnosticText","expression","target","sourceConcept","targetConcept","values","properties","command","scope","declaration","response","field","authored","event","route","EventSourceCatalog","source","stream","part","model","trigger","error","absent","keyed","owner","query","parameters","results","result","distinct","types","memo","reference","local","events","resolver","AuthoringProductionResolver","produced","commandDestinationType","visited","reaction","sourceName","path","declared","capture","child","nested","append","foldedSources"],"sources":["../../../../../../Compiler/Parsing/SpecificationCaseValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { EventSyntax, PropertySyntax, TypeRefSyntax } from '../Syntax/Declarations';\nimport { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { EventSourceCatalog } from '../Syntax/EventSourceCatalog';\nimport { EventSourceResolutionKind } from '../Syntax/EventSources';\nimport { SpecificationSyntax } from '../Syntax/Specifications';\nimport { commandDestinationType } from './CommandDestinationTypes';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { ApplicationSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\nimport { RefusalDeclarations } from './RefusalDeclarations';\nimport { compatibleValue } from './ResponseValidator';\nimport { foldedSources } from './FoldedEventSources';\nimport { specificationExamples } from './SpecificationCommandExamples';\n\nconst primitives = new Set(['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime']);\n\nexport function validateSpecificationCases(application: ApplicationSyntax, context: ParserContext, standaloneSpecifications?: readonly SpecificationSyntax[]): void {\n const declarations = new RefusalDeclarations(application);\n const examples = specificationExamples(application), destinationType = eventDestinationTypes(application, declarations);\n const knownType = (name: string) => primitives.has(name) || declarations.concepts.has(name) || declarations.types.has(name);\n const composites = new Map([...declarations.types].map(([name, type]) => [name, new Map(type.properties.map(property => [property.name, property]))]));\n const owners = standaloneSpecifications === undefined ? declarations.slices : [{ scope: [], slice: {\n kind: 'SliceSyntax' as const, type: 'StateChange' as const, name: '', description: null, location: application.location,\n events: [], commands: [], queries: [], projections: [], captures: [], reactions: [], constraints: [], readModels: [], screens: [], specifications: standaloneSpecifications,\n } }];\n for (const { slice, scope } of owners) {\n const names = new Map<string, number>();\n for (const specification of slice.specifications) {\n const expandedNames = (specification.cases?.length ?? 0) === 0 ? [specification.name] : specification.cases!.map(row => `${specification.name}_${row.name}`);\n for (const name of expandedNames) names.set(name, (names.get(name) ?? 0) + 1);\n if ((specification.cases?.length ?? 0) > 0) names.set(specification.name, (names.get(specification.name) ?? 0) + 1);\n }\n for (const specification of slice.specifications) {\n for (const row of specification.cases ?? []) {\n if ((names.get(`${specification.name}_${row.name}`) ?? 0) > 1) context.error(DiagnosticCodes.SpecificationCaseNameCollision, `Case '${row.name}' derives specification '${specification.name}_${row.name}', which collides in this ${standaloneSpecifications === undefined ? 'slice' : 'document'}.`, row.location);\n }\n for (const parameter of specification.parameters ?? []) {\n if (standaloneSpecifications === undefined && !knownType(parameter.type.name)) context.error(DiagnosticCodes.IncompatibleSpecificationParameterType, `Parameter '${parameter.name}' has unknown type '${parameter.type.name}'.`, parameter.type.location);\n for (const row of specification.cases ?? []) {\n for (const assignment of row.values.filter(value => value.property === parameter.name)) {\n if (!compatibleValue(assignment.source, parameter.type, declarations.concepts, composites)) context.error(DiagnosticCodes.InvalidSpecificationCaseValue, `Case '${row.name}' parameter '${parameter.name}' requires a concrete value of type '${parameter.type.name}'.`, assignment.source.location, { ...diagnosticText('case', row.name), ...diagnosticText('parameter', parameter.name), ...diagnosticText('type', parameter.type.name) });\n }\n }\n }\n const check = (expression: ExpressionSyntax | null, target: TypeRefSyntax | undefined, property: string) => {\n if (expression?.kind !== 'CaseValueExpressionSyntax' || target === undefined) return;\n const parameter = specification.parameters?.find(parameter => parameter.name === expression.parameter);\n if (parameter === undefined) return;\n if (parameter.type.isOptional && !target.isOptional) context.error(DiagnosticCodes.OptionalSpecificationParameterTarget, `Optional parameter '${parameter.name}' cannot supply required target '${property}'.`, expression.location);\n if (standaloneSpecifications !== undefined && (!knownType(parameter.type.name) || !knownType(target.name))) return;\n const sourceConcept = declarations.concepts.get(parameter.type.name);\n const targetConcept = declarations.concepts.get(target.name);\n const compatible = parameter.type.name === target.name || sourceConcept?.type !== 'Enum' && sourceConcept?.type === target.name || targetConcept?.type !== 'Enum' && targetConcept?.type === parameter.type.name;\n if (!compatible || parameter.type.isCollection !== target.isCollection) context.error(DiagnosticCodes.IncompatibleSpecificationParameterType, `Parameter '${parameter.name}' type '${parameter.type.name}' is incompatible with target '${property}' type '${target.name}'.`, expression.location);\n };\n const assignments = (values: readonly PropertyMappingSyntax[], properties: readonly PropertySyntax[] | null) => {\n for (const value of values) check(value.source, declarations.property(properties, value.property)?.type, value.property);\n };\n const command = examples.command(specification.when, scope);\n if (command !== null) {\n const properties = declarations.resolve(command.commandType, slice, slice => slice.commands)?.node.properties ?? null;\n assignments(command.values, properties);\n assignments(command.generatedValues ?? [], properties);\n check(command.for, properties?.find(property => property.isIdentifier)?.type, 'for');\n }\n if (command !== null && specification.thenReturns != null) {\n const declaration = declarations.resolve(command.commandType, slice, slice => slice.commands)?.node;\n const response = declaration?.response;\n if (specification.thenReturns.kind === 'ScalarSpecificationReturnSyntax' && response?.kind === 'ScalarCommandResponseSyntax') check(specification.thenReturns.value, declaration?.properties.find(property => property.name === response.source.property)?.type, 'value');\n if (specification.thenReturns.kind === 'RecordSpecificationReturnSyntax' && response?.kind === 'RecordCommandResponseSyntax') {\n for (const value of specification.thenReturns.fields) {\n const field = response.fields.find(field => field.name === value.property);\n check(value.source, field?.type ?? declaration?.properties.find(property => property.name === field?.source.property)?.type, value.property);\n }\n }\n }\n for (const authored of [...specification.given, ...specification.thenEvents, ...(specification.whenAppended === null ? [] : [specification.whenAppended])]) {\n const event = examples.eventStep(authored, 'given', scope).effective as typeof authored;\n assignments(event.values, declarations.event(event.eventType, slice)?.properties ?? null);\n const route = event.stream == null ? null : new EventSourceCatalog(application).resolve(event.stream.eventSource, event.stream.stream);\n const source = route?.kind === EventSourceResolutionKind.Unique ? route.sources[0] : undefined;\n const stream = route?.kind === EventSourceResolutionKind.Unique ? route.streams[0] : undefined;\n check(event.for, event.stream != null && source === undefined ? undefined : source?.identifier ?? destinationType(event.eventType, slice), 'for');\n if (event.stream?.streamId != null) check(event.stream.streamId.source, stream?.streamId ?? undefined, 'streamId');\n for (const part of event.stream?.streamIdParts ?? []) check(part.source, stream?.streamIdParts.find(declaration => declaration.name === part.property)?.type, part.property);\n }\n for (const authored of [...specification.givenReadModels, ...specification.thenReadModels]) {\n const model = examples.readModel(authored, scope);\n assignments(model.properties, declarations.resolve(model.name, slice, slice => slice.readModels)?.node.properties ?? null);\n }\n if (specification.whenTrigger != null) {\n const trigger = (application.declaredTriggers ?? []).find(trigger => trigger.name === specification.whenTrigger!.trigger);\n for (const value of specification.whenTrigger.values) check(value.source, trigger?.data.find(property => property.name === value.property)?.type, value.property);\n }\n for (const error of specification.thenErrors) check(error.caseValue ?? null, { kind: 'TypeRefSyntax', name: 'String', isOptional: false, isCollection: false, location: error.location }, 'message');\n for (const absent of specification.thenAbsentReadModels ?? []) {\n const model = declarations.resolve(absent.name, slice, slice => slice.readModels)?.node;\n const keyed = declarations.slices.flatMap(({ slice: owner }) => owner.queries.filter(query => query.by !== null && declarations.resolve(query.returnType.name, owner, slice => slice.readModels)?.node === model));\n check(absent.key, model !== undefined && keyed.length === 1 ? keyed[0].by!.type : undefined, 'for');\n }\n for (const query of [...(specification.thenQueries ?? []), ...(specification.whenQuery === null ? [] : [specification.whenQuery])]) {\n const declaration = declarations.resolve(query.query, slice, slice => slice.queries);\n const parameters = declaration === null ? [] : [...(declaration.node.by === null ? [] : [declaration.node.by]), ...declaration.node.filters].map(parameter => ({ ...parameter, kind: 'PropertySyntax' as const, isIdentifier: false }));\n assignments(query.arguments, parameters);\n const properties = declaration === null ? null : declarations.resolve(declaration.node.returnType.name, declaration.slice, slice => slice.readModels)?.node.properties ?? null;\n const results = query.kind === 'SpecificationQuerySyntax' ? query.results : specification.thenResults;\n for (const result of results) assignments(result.properties, properties);\n }\n }\n }\n}\n\nfunction uniqueDestinationType(types: readonly TypeRefSyntax[]): TypeRefSyntax | undefined {\n const distinct = new Map(types.map(type => [JSON.stringify([type.name, type.isOptional, type.isCollection]), type]));\n return distinct.size === 1 ? [...distinct.values()][0] : undefined;\n}\n\n// Memoized per validation pass by declaring slice and resolved event; unresolved and ambiguous (undefined) results are cached too.\nfunction eventDestinationTypes(application: ApplicationSyntax, declarations: RefusalDeclarations): (reference: string, local: SliceSyntax) => TypeRefSyntax | undefined {\n const memo = new Map<SliceSyntax, Map<EventSyntax, TypeRefSyntax | undefined>>();\n return (reference, local) => {\n const event = declarations.event(reference, local);\n if (event === null) return undefined;\n let events = memo.get(local);\n if (events === undefined) memo.set(local, events = new Map());\n if (!events.has(event)) events.set(event, producedDestinationType(event, local, application, declarations));\n return events.get(event);\n };\n}\n\nfunction producedDestinationType(event: EventSyntax, local: SliceSyntax, application: ApplicationSyntax, declarations: RefusalDeclarations): TypeRefSyntax | undefined {\n const resolver = new AuthoringProductionResolver(application);\n const commandTypes = (event: EventSyntax, owners = declarations.slices): TypeRefSyntax[] => owners.flatMap(({ slice }) => slice.commands.flatMap(command => command.produces\n .filter(produced => resolver.isEventProduction(produced, slice) && declarations.event(produced.event, slice) === event)\n .map(produced => commandDestinationType(command, produced, application, { resolver, slice })).filter((type): type is TypeRefSyntax => type !== null)));\n const producerTypes = (event: EventSyntax, visited: Set<EventSyntax>): TypeRefSyntax[] => {\n if (visited.has(event)) return [];\n visited.add(event);\n const types = commandTypes(event);\n for (const { slice } of declarations.slices) {\n for (const trigger of slice.reactions.flatMap(reaction => reaction.triggers)) {\n const sourceName = trigger.source.kind === 'NamedTriggerSourceSyntax' ? trigger.source.name : undefined;\n const source = sourceName === undefined ? null : declarations.event(sourceName, slice);\n for (const produced of trigger.produces.filter(produced => declarations.event(produced.event, slice) === event)) {\n if (produced.for?.kind === 'PathExpressionSyntax') {\n const path = produced.for.path;\n const type = declarations.property(source?.properties ?? null, path)?.type ?? (sourceName === undefined ? undefined\n : (application.declaredTriggers ?? []).find(declared => declared.name === sourceName)?.data.find(property => property.name === path)?.type);\n if (type !== undefined) types.push(type);\n } else if (produced.for?.kind === 'LiteralExpressionSyntax') types.push({ kind: 'TypeRefSyntax', name: 'String', isOptional: false, isCollection: false, location: produced.location });\n else if (produced.for === null && source !== null) types.push(...producerTypes(source, visited));\n }\n }\n if (slice.captures.flatMap(capture => [...capture.appends, ...capture.children.flatMap(child => child.appends), ...capture.nested.flatMap(nested => nested.appends)]).some(append => declarations.event(append.event, slice) === event))\n types.push(uniqueDestinationType(commandTypes(event)) ?? { kind: 'TypeRefSyntax', name: 'String', isOptional: false, isCollection: false, location: event.location });\n types.push(...foldedSources(declarations, slice, event).flatMap(source => producerTypes(source, visited)));\n }\n return types;\n };\n return uniqueDestinationType(commandTypes(event, declarations.slices.filter(owner => owner.slice === local))) ?? uniqueDestinationType(commandTypes(event)) ?? uniqueDestinationType(producerTypes(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B,EAAcvE,EAAcc,EAAOsB,CAAK,CAAC,CAAC,QAAQ,GAAU,cAAcG,EAAQuB,CAAO,CAAC,CAAC,CAC7G,CACA,OAAOT,CACX,EACA,OAAO,sBAAsB,aAAajB,EAAOpC,EAAa,OAAO,OAAO,GAAS+C,EAAM,QAAUS,CAAK,CAAC,CAAC,GAAK,sBAAsB,aAAapB,CAAK,CAAC,GAAK,sBAAsB,cAAcA,kBAAO,IAAI,GAAK,CAAC,CACxN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/screenplay-language",
3
- "version": "5.1.0",
3
+ "version": "5.2.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",