@cratis/screenplay-language 5.4.0 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{validateHandlerContracts as t}from"./CommandHandlerValidator.js";import{misplacedRuleHintForCommand as n}from"./MisplacedRuleHint.js";import{parseCondition as r}from"./ConditionParser.js";import{parseCommandStream as i}from"./EventSourceParser.js";import{pattern as a}from"../Text/patterns.js";import{sourceStreamPattern as o}from"../Text/SourceStreamNames.js";import{stringBodyPattern as s,unescapeString as c}from"../Text/StringLiteral.js";import{combineAuthorize as l,parseAuthorize as u}from"./AuthorizeParser.js";import{parseCommandResponse as d,scalarResponsePattern as f}from"./CommandResponseParser.js";import{parseDescription as p}from"./DescriptionParser.js";import{parseDocumentation as m}from"./DocumentationParser.js";import{isCode as h,isFile as g,parseCode as _,parseFile as v,parseHandler as y,parseImplementationWrapper as b}from"./ImplementationParser.js";import{parseMappingSource as x}from"./ExpressionParser.js";import{firstWord as S}from"./LineText.js";import{ParserContext as C}from"./ParserContext.js";import{matchSubject as w,validateMatchOperand as T}from"./MatchOperandValidation.js";import{isReactionIdentityLine as E,misplacedReactionIdentity as ee}from"./ReactionIdentityParser.js";import{commandReadSources as te}from"./CommandReadSources.js";import{dependencySources as D}from"../Syntax/DependencySources.js";import{captureConcurrency as O}from"./DependencySourceParser.js";import{parseReads as k}from"./ReadsParser.js";import{parseProduces as A}from"./ProducesParser.js";import{reportInvalidModifierOrder as j,reportLegacyOptionalSuffix as M,tryParseProperty as N}from"./PropertyLineParser.js";import{locationOf as P}from"./SourceLine.js";import{isFileDirectiveAmongProperties as F}from"./FileReferences.js";const ne=a(`^command\\s+([A-Za-z_]\\w*)$`),I=o(`^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$`),L=a(`^calendar\\s+(?:"|from\\s+\\$context\\.)`),R=a(`^calendar\\s+(?:"(${s})"|from\\s+\\$context\\.([A-Za-z_][A-Za-z0-9_]*(?:\\.[A-Za-z_][A-Za-z0-9_]*)*))$`),z=a(`\\bseverity\\s+(\\S+)$`),B=a(`\\bmessage\\s+(?:"(${s})"|(\\$strings\\.\\S*))$`),V=a(`^([\\w.]+)\\s+(.+)$`),H=a(`^(?:(not empty|matches|not contains|contains|starts with|ends with|max|min|rule)(?:\\s+|$)|(length ==|decimals <=|all >=|all >|>=|<=|==|!=|>|<)\\s*)(.*)$`),U=o(`^[A-Za-z_]\\w*$`),W=a(`^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)`),G={max:`Max`,min:`Min`,">":`GreaterThan`,">=":`GreaterThanOrEqual`,"<":`LessThan`,"<=":`LessThanOrEqual`,"==":`Equal`,"!=":`NotEqual`,"length ==":`Length`,"decimals <=":`DecimalPlaces`,matches:`Matches`,contains:`Contains`,"not contains":`NotContains`,"starts with":`StartsWith`,"ends with":`EndsWith`,"all >":`AllGreaterThan`,"all >=":`AllGreaterThanOrEqual`},K={information:`Information`,warning:`Warning`,error:`Error`},q=/* @__PURE__ */ new Set([`reads`,`concurrency`]),J=/* @__PURE__ */ new Set([`description`,`documentation`,`handler`,`concurrency`]);function parseCommand(e,t){let n=/* @__PURE__ */ new Set,r=new C(e.reader.fork(),e.path,e.languages);return r.sourceOptions=e.sourceOptions,r.streamCandidates=e.streamCandidates,parseCommandBody(r,t,void 0,n),parseCommandBody(e,t,n)}function parseCommandBody(r,a,o,s){let h=ne.exec(a.content)?.[1]??``;h===``&&r.error(e.InvalidCommandDeclaration,`Invalid command declaration '${a.content}' - expected 'command <Name>'`,P(a));let g=[],_=[],v,b=[],x=[],C=[],w=[],T,M=null,F=null,z=null,B=!1,V=null,H=[],U=null,G=[],K=null;for(let t=r.peekChild(a.indent);t!==void 0;t=r.peekChild(a.indent)){r.reader.takeSignificant();let a=S(t.content),s=N(t);if(a===`calendar`&&L.test(t.content)){let n=R.exec(t.content);K!==null||n===null?r.error(e.InvalidCommandCalendar,`A command declares at most one 'calendar "<id>"' or 'calendar from $context.<member>'.`,P(t)):K={kind:`CommandCalendarSyntax`,id:n[1]===void 0?null:c(n[1]),contextMember:n[2]??null,location:P(t)}}else if(s!==void 0&&(J.has(a)||a===`validate`&&t.content!==`validate csharp`))v=addProperty(r,g,s,h,t,v);else if(a===`returns`){let e=f.exec(t.content);e!==null&&!e[1].startsWith(`@`)&&s!==void 0?o===void 0?(g.push(s),_.push({line:t,candidate:s,response:null})):o.has(s.type.name)?_.push({line:t,candidate:null,response:d(r,t)}):v=addProperty(r,g,s,h,t,v):s===void 0?j(r,t)?r.skipBlock(t.indent):_.push({line:t,candidate:null,response:d(r,t)}):v=addProperty(r,g,s,h,t,v)}else if(a===`stream`&&I.test(t.content)&&s!==void 0&&r.streamCandidates?.hasSource(s.type.name.split(`.`)[0])===!0){let[n,a]=s.type.name.split(`.`),o=r.streamCandidates.hasPropertyType(s.type.name)&&r.streamCandidates.hasUniqueStream(n,a),c=i(r,t,s,o);(U!==null||G.length>0)&&r.error(e.InvalidCommandStream,`A command declares at most one stream route.`,P(t)),o||U!==null?G.push(c):U=c}else if(a===`runs`&&E(t))ee(r,t);else if(a===`description`)M=p(r,t,M,`Command '${h}'`);else if(a===`documentation`)F=m(r,t,F,`Command '${h}'`);else if(a===`authorize`){let e=u(r,t);if(!B){let t=z;z=l(z,e,r),B=t!==null&&z===null}}else if(a===`validate`){let e=parseValidate(r,t,`command`,h);e!==void 0&&b.push(e)}else if(a===`produces`){let e=A(r,t,!0);e!==void 0&&x.push(e)}else if(a===`handler`)V=y(r,t),H.push({handler:V,location:P(t)});else if(q.has(a)){let n=a===`reads`?k(r,t):void 0;n!==void 0&&w.push(n),a===`concurrency`&&T===void 0&&(T=O(r,t));let i=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(t.content);i!==null&&C.push({readModel:i[1],alias:i[2]??null}),W.test(t.content)&&r.error(e.OptionalReadsNotSupported,`Optional reads are not yet supported (see #308).`,P(t)),r.skipOpaqueBlock(t.indent)}else s===void 0?(j(r,t),r.error(e.UnknownCommandDirective,`Unexpected '${t.content}' in command body${n(t.content)}`,P(t)),r.skipBlock(t.indent)):v=addProperty(r,g,s,h,t,v)}let Y=new Set(_.flatMap(e=>e.candidate===null?[]:[e.candidate])),X=new Set(g.filter(e=>!Y.has(e)).map(e=>e.name));_.some(e=>e.candidate!==null&&!X.has(e.candidate.type.name)&&e.candidate.type.name!==`returns`)&&X.add(`returns`);for(let e of X)s?.add(e);let Z=null,Q=/* @__PURE__ */ new Set;for(let t of _){let n=t.response;if(t.candidate!==null){if(!X.has(t.candidate.type.name))continue;Q.add(t.candidate),n={kind:`ScalarCommandResponseSyntax`,source:{kind:`PropertyResponseSourceSyntax`,property:t.candidate.type.name,location:t.candidate.type.location},location:P(t.line)}}n!==null&&(Z===null?Z=n:r.error(e.InvalidCommandResponse,`A command declares at most one unconditional response.`,P(t.line)))}t(H,V,x.length>0,r);let $={kind:`CommandSyntax`,name:h,description:M,documentation:F,authorize:z,properties:g.filter(e=>!Q.has(e)),validations:b,produces:x,handler:V,response:Z,stream:U,streamCandidates:G,...K===null?{}:{calendar:K},location:P(a)};return te.set($,C),D.set($,{reads:w,concurrency:T}),$}function addProperty(t,n,r,i,a,o){return M(t,r.type,a),r.isIdentifier&&o!==void 0&&(t.error(e.DuplicateCommandIdentifier,`Command '${i}' already marks '${o.name}' as identifier - only one property can be the identifier`,r.location),r={...r,isIdentifier:!1}),n.push(r),o??(r.isIdentifier?r:void 0)}function parseValidationFile(e,t,n){let r=v(e,n);return r===void 0?void 0:{kind:`FileValidateSyntax`,file:r,location:P(t)}}function hasValidationOperand(e){let t=V.exec(e.content);return t!==null&&startsWithRuleOperand(t[2])}function startsWithRuleOperand(e){return S(e)===`not`&&S(e.substring(3).trimStart())===`empty`||S(e)===`checksum`||H.test(e)}function isDeclarativePredicate(e){return startsWithRuleOperand(e)&&S(e)!==`rule`}function isValidationFileBody(e,t,n){if(!F(n)||hasValidationOperand(n))return!1;let r=e.reader.fork();r.takeSignificant();let i=r.peekSignificant();return i===void 0||i.indent<=t.indent}function parseValidate(t,n,i,a){if(n.content===`validate`){let o=t.peekChild(n.indent);if(o!==void 0&&isValidationFileBody(t,n,o))return t.reader.takeSignificant(),parseValidationFile(t,n,o);if(o!==void 0&&o.content.startsWith("```")){t.reader.takeSignificant();let e=_(t.valueContext,o);return e===null&&t.skipFencedBody(),{kind:`CodeValidateSyntax`,code:e,location:P(n)}}let s=[],l=[],u;for(let o=t.peekChild(n.indent);o!==void 0;o=t.peekChild(n.indent)){if(t.reader.takeSignificant(),i===`concept`){if(t.sourceOptions.numericMode===`legacy`&&o.content.startsWith("```")){t.skipFencedBody();continue}if(u!==void 0&&o.indent<=u&&(u=void 0),u!==void 0||S(o.content)===`implementation`){t.error(e.InvalidValidationRule,`Invalid validation rule '${o.content}'`,P(o)),u??=o.indent;continue}}if(S(o.content)===`require`){let e=r(i===`concept`?t.valueContext:t,o.content.substring(7).trim(),P(o),!1,t),n=null,a=`Error`,s=!1;for(let e=t.peekChild(o.indent);e!==void 0;e=t.peekChild(o.indent)){t.reader.takeSignificant();let r=B.exec(e.content);r!==null&&r.index===0?n=r[1]===void 0?r[2]:c(r[1]):S(e.content)===`severity`?(s||(a=K[e.content.substring(8).trim()]??`Error`),s=!0):t.skipOpaqueBlock(e.indent)}e!==null&&l.push({kind:`RequirementSyntax`,condition:e,message:n,severity:a,location:P(o)});continue}let n=parseValidationRule(t,i===`concept`?{...o,content:`value ${o.content}`}:o,i,a);n!==void 0&&s.push(n)}return{kind:`DeclarativeValidateSyntax`,rules:s,requirements:l,location:P(n)}}if(i===`concept`&&S(n.content.substring(8).trimStart())===`checksum`){let e=parseValidationRule(t,{...n,content:`value ${n.content.substring(8).trimStart()}`},i,a);return e===void 0?void 0:{kind:`DeclarativeValidateSyntax`,rules:[e],requirements:[],location:P(n)}}if(n.content===`validate csharp`){let e=_(t.valueContext,{...n,content:`csharp`});return e===null&&t.skipOpaqueBlock(n.indent),{kind:`CodeValidateSyntax`,code:e,location:P(n)}}t.error(e.InvalidValidateDeclaration,`Invalid validate declaration '${n.content}' - expected 'validate' or 'validate csharp'`,P(n)),t.skipBlock(n.indent)}function parseValidationRule(t,n,r,i){let a=S(V.exec(n.content)?.[2]??``)===`checksum`,o=r===`concept`&&!a?t.valueContext:t,{content:s,message:c}=splitMessage(n.content),l=splitSeverity(o,n,s);if(l===void 0)return;let u=V.exec(l.content);if(u===null){o.error(e.InvalidValidationRule,`Invalid validation rule '${n.content}'`,P(n));return}let d=parseRule(o,u[2],n);if(d===void 0)return;d.kind===`Matches`&&d.value!==null&&T(t,d.value,P(n),n.raw,w(t,r,i,u[1]));let f=d.kind===`Rule`?parseRuleImplementation(t,n,r===`command`):{file:null,code:null,implementation:null};return{kind:`ValidationRuleSyntax`,property:u[1],rule:d.kind,value:d.value,message:c,severity:l.severity,...f,location:P(n)}}function parseRuleImplementation(t,n,r){let i=t.peekChild(n.indent);if(i===void 0)return{file:null,code:null,implementation:null};t.reader.takeSignificant();let a=r&&S(i.content)===`implementation`,o=a?b(t,i):{file:g(i)?v(t,i):null,code:!g(i)&&h(t,i)?_(t,i):null,implementation:null};!a&&o.file===null&&o.code===null&&(t.error(e.UnknownRuleImplementationDirective,`Unexpected '${i.content}' in rule implementation - expected 'file <path>' or an inline code block`,P(i)),t.skipBlock(i.indent));for(let i=t.peekChild(n.indent);i!==void 0&&(a||r&&S(i.content)===`implementation`);i=t.peekChild(n.indent))t.reader.takeSignificant(),t.error(a&&S(i.content)===`implementation`?e.InvalidImplementationBlock:e.ConflictingImplementationSources,`A named rule has one implementation wrapper and cannot mix wrapped and direct sources.`,P(i)),h(t,i)?_(t,i):t.skipBlock(i.indent);return o}function splitMessage(e){let t=B.exec(e);if(t===null)return{content:e,message:null};let n=t[1]===void 0?t[2]:c(t[1]);return{content:e.substring(0,t.index).trimEnd(),message:n}}function splitSeverity(t,n,r){let i=z.exec(r);if(i===null)return{content:r,severity:`Error`};let a=K[i[1]];if(a===void 0)t.error(e.InvalidValidationSeverity,`Unknown validation severity '${i[1]}' - expected information, warning or error`,P(n));else return{content:r.substring(0,i.index).trimEnd(),severity:a}}function parseRule(t,n,r){if(n===`not empty`)return{kind:`NotEmpty`,value:null};if(S(n)===`checksum`){let i=n.substring(8).trim();if(i!==`luhn`&&i!==`mod11`&&i!==`mod97`){t.error(e.InvalidGenerationArgument,`Checksum validation requires luhn, mod11 or mod97.`,P(r));return}return{kind:`Checksum`,value:{kind:`LiteralExpressionSyntax`,value:i,location:P(r)}}}let i=H.exec(n);if(i===null){t.error(e.InvalidValidationRule,`Invalid validation rule '${r.content}'`,P(r));return}let a=i[1]??i[2];if(a===`rule`){let n=i[3].trim();if(!U.test(n)){t.error(e.InvalidRuleName,`Invalid rule name '${n}' in '${r.content}' - expected 'rule <Name>' with an identifier`,P(r));return}return{kind:`Rule`,value:{kind:`PathExpressionSyntax`,path:n,location:P(r)}}}return{kind:G[a],value:x(i[3],P(r),t)}}export{isDeclarativePredicate,parseCommand,parseValidate};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{validateHandlerContracts as t}from"./CommandHandlerValidator.js";import{misplacedRuleHintForCommand as n}from"./MisplacedRuleHint.js";import{parseCondition as r}from"./ConditionParser.js";import{parseClockOperand as i}from"./ClockOperandParser.js";import{parseCommandStream as a}from"./EventSourceParser.js";import{pattern as o}from"../Text/patterns.js";import{sourceStreamPattern as s}from"../Text/SourceStreamNames.js";import{stringBodyPattern as c,unescapeString as l}from"../Text/StringLiteral.js";import{combineAuthorize as u,parseAuthorize as d}from"./AuthorizeParser.js";import{parseCommandResponse as f,scalarResponsePattern as p}from"./CommandResponseParser.js";import{parseDescription as m}from"./DescriptionParser.js";import{parseDocumentation as h}from"./DocumentationParser.js";import{isCode as g,isFile as _,parseCode as v,parseFile as y,parseHandler as b,parseImplementationWrapper as x}from"./ImplementationParser.js";import{parseMappingSource as S}from"./ExpressionParser.js";import{firstWord as C}from"./LineText.js";import{ParserContext as w}from"./ParserContext.js";import{matchSubject as T,validateMatchOperand as E}from"./MatchOperandValidation.js";import{isReactionIdentityLine as D,misplacedReactionIdentity as O}from"./ReactionIdentityParser.js";import{commandReadSources as k}from"./CommandReadSources.js";import{dependencySources as ee}from"../Syntax/DependencySources.js";import{captureConcurrency as A}from"./DependencySourceParser.js";import{parseReads as j}from"./ReadsParser.js";import{parseProduces as M}from"./ProducesParser.js";import{reportInvalidModifierOrder as N,reportLegacyOptionalSuffix as P,tryParseProperty as F}from"./PropertyLineParser.js";import{locationOf as I}from"./SourceLine.js";import{isFileDirectiveAmongProperties as L}from"./FileReferences.js";const R=o(`^command\\s+([A-Za-z_]\\w*)$`),z=s(`^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$`),B=o(`^calendar\\s+(?:"|from\\s+\\$context\\.)`),V=o(`^calendar\\s+(?:"(${c})"|from\\s+\\$context\\.([A-Za-z_][A-Za-z0-9_]*(?:\\.[A-Za-z_][A-Za-z0-9_]*)*))$`),H=o(`\\bseverity\\s+(\\S+)$`),U=o(`\\bmessage\\s+(?:"(${c})"|(\\$strings\\.\\S*))$`),W=o(`^([\\w.]+)\\s+(.+)$`),G=o(`^(?:(not empty|matches|not contains|contains|starts with|ends with|max|min|rule)(?:\\s+|$)|(length ==|decimals <=|all >=|all >|>=|<=|==|!=|>|<)\\s*)(.*)$`),K=s(`^[A-Za-z_]\\w*$`),q=o(`^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)`),J={max:`Max`,min:`Min`,">":`GreaterThan`,">=":`GreaterThanOrEqual`,"<":`LessThan`,"<=":`LessThanOrEqual`,"==":`Equal`,"!=":`NotEqual`,"length ==":`Length`,"decimals <=":`DecimalPlaces`,matches:`Matches`,contains:`Contains`,"not contains":`NotContains`,"starts with":`StartsWith`,"ends with":`EndsWith`,"all >":`AllGreaterThan`,"all >=":`AllGreaterThanOrEqual`},Y={information:`Information`,warning:`Warning`,error:`Error`},te=/* @__PURE__ */ new Set([`reads`,`concurrency`]),ne=/* @__PURE__ */ new Set([`description`,`documentation`,`handler`,`concurrency`]);function parseCommand(e,t){let n=/* @__PURE__ */ new Set,r=new w(e.reader.fork(),e.path,e.languages);return r.sourceOptions=e.sourceOptions,r.streamCandidates=e.streamCandidates,parseCommandBody(r,t,void 0,n),parseCommandBody(e,t,n)}function parseCommandBody(r,i,o,s){let c=R.exec(i.content)?.[1]??``;c===``&&r.error(e.InvalidCommandDeclaration,`Invalid command declaration '${i.content}' - expected 'command <Name>'`,I(i));let g=[],_=[],v,y=[],x=[],S=[],w=[],T,E=null,P=null,L=null,H=!1,U=null,W=[],G=null,K=[],J=null;for(let t=r.peekChild(i.indent);t!==void 0;t=r.peekChild(i.indent)){r.reader.takeSignificant();let i=C(t.content),s=F(t);if(i===`calendar`&&B.test(t.content)){let n=V.exec(t.content);J!==null||n===null?r.error(e.InvalidCommandCalendar,`A command declares at most one 'calendar "<id>"' or 'calendar from $context.<member>'.`,I(t)):J={kind:`CommandCalendarSyntax`,id:n[1]===void 0?null:l(n[1]),contextMember:n[2]??null,location:I(t)}}else if(s!==void 0&&(ne.has(i)||i===`validate`&&t.content!==`validate csharp`))v=addProperty(r,g,s,c,t,v);else if(i===`returns`){let e=p.exec(t.content);e!==null&&!e[1].startsWith(`@`)&&s!==void 0?o===void 0?(g.push(s),_.push({line:t,candidate:s,response:null})):o.has(s.type.name)?_.push({line:t,candidate:null,response:f(r,t)}):v=addProperty(r,g,s,c,t,v):s===void 0?N(r,t)?r.skipBlock(t.indent):_.push({line:t,candidate:null,response:f(r,t)}):v=addProperty(r,g,s,c,t,v)}else if(i===`stream`&&z.test(t.content)&&s!==void 0&&r.streamCandidates?.hasSource(s.type.name.split(`.`)[0])===!0){let[n,i]=s.type.name.split(`.`),o=r.streamCandidates.hasPropertyType(s.type.name)&&r.streamCandidates.hasUniqueStream(n,i),c=a(r,t,s,o);(G!==null||K.length>0)&&r.error(e.InvalidCommandStream,`A command declares at most one stream route.`,I(t)),o||G!==null?K.push(c):G=c}else if(i===`runs`&&D(t))O(r,t);else if(i===`description`)E=m(r,t,E,`Command '${c}'`);else if(i===`documentation`)P=h(r,t,P,`Command '${c}'`);else if(i===`authorize`){let e=d(r,t);if(!H){let t=L;L=u(L,e,r),H=t!==null&&L===null}}else if(i===`validate`){let e=parseValidate(r,t,`command`,c);e!==void 0&&y.push(e)}else if(i===`produces`){let e=M(r,t,!0);e!==void 0&&x.push(e)}else if(i===`handler`)U=b(r,t),W.push({handler:U,location:I(t)});else if(te.has(i)){let n=i===`reads`?j(r,t):void 0;n!==void 0&&w.push(n),i===`concurrency`&&T===void 0&&(T=A(r,t));let a=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(t.content);a!==null&&S.push({readModel:a[1],alias:a[2]??null}),q.test(t.content)&&r.error(e.OptionalReadsNotSupported,`Optional reads are not yet supported (see #308).`,I(t)),r.skipOpaqueBlock(t.indent)}else s===void 0?(N(r,t),r.error(e.UnknownCommandDirective,`Unexpected '${t.content}' in command body${n(t.content)}`,I(t)),r.skipBlock(t.indent)):v=addProperty(r,g,s,c,t,v)}let Y=new Set(_.flatMap(e=>e.candidate===null?[]:[e.candidate])),X=new Set(g.filter(e=>!Y.has(e)).map(e=>e.name));_.some(e=>e.candidate!==null&&!X.has(e.candidate.type.name)&&e.candidate.type.name!==`returns`)&&X.add(`returns`);for(let e of X)s?.add(e);let Z=null,Q=/* @__PURE__ */ new Set;for(let t of _){let n=t.response;if(t.candidate!==null){if(!X.has(t.candidate.type.name))continue;Q.add(t.candidate),n={kind:`ScalarCommandResponseSyntax`,source:{kind:`PropertyResponseSourceSyntax`,property:t.candidate.type.name,location:t.candidate.type.location},location:I(t.line)}}n!==null&&(Z===null?Z=n:r.error(e.InvalidCommandResponse,`A command declares at most one unconditional response.`,I(t.line)))}t(W,U,x.length>0,r);let $={kind:`CommandSyntax`,name:c,description:E,documentation:P,authorize:L,properties:g.filter(e=>!Q.has(e)),validations:y,produces:x,handler:U,response:Z,stream:G,streamCandidates:K,...J===null?{}:{calendar:J},location:I(i)};return k.set($,S),ee.set($,{reads:w,concurrency:T}),$}function addProperty(t,n,r,i,a,o){return P(t,r.type,a),r.isIdentifier&&o!==void 0&&(t.error(e.DuplicateCommandIdentifier,`Command '${i}' already marks '${o.name}' as identifier - only one property can be the identifier`,r.location),r={...r,isIdentifier:!1}),n.push(r),o??(r.isIdentifier?r:void 0)}function parseValidationFile(e,t,n){let r=y(e,n);return r===void 0?void 0:{kind:`FileValidateSyntax`,file:r,location:I(t)}}function hasValidationOperand(e){let t=W.exec(e.content);return t!==null&&startsWithRuleOperand(t[2])}function startsWithRuleOperand(e){return C(e)===`not`&&C(e.substring(3).trimStart())===`empty`||C(e)===`checksum`||G.test(e)}function isDeclarativePredicate(e){return startsWithRuleOperand(e)&&C(e)!==`rule`}function isValidationFileBody(e,t,n){if(!L(n)||hasValidationOperand(n))return!1;let r=e.reader.fork();r.takeSignificant();let i=r.peekSignificant();return i===void 0||i.indent<=t.indent}function parseValidate(t,n,i,a){if(n.content===`validate`){let o=t.peekChild(n.indent);if(o!==void 0&&isValidationFileBody(t,n,o))return t.reader.takeSignificant(),parseValidationFile(t,n,o);if(o!==void 0&&o.content.startsWith("```")){t.reader.takeSignificant();let e=v(t.valueContext,o);return e===null&&t.skipFencedBody(),{kind:`CodeValidateSyntax`,code:e,location:I(n)}}let s=[],c=[],u;for(let o=t.peekChild(n.indent);o!==void 0;o=t.peekChild(n.indent)){if(t.reader.takeSignificant(),i===`concept`){if(t.sourceOptions.numericMode===`legacy`&&o.content.startsWith("```")){t.skipFencedBody();continue}if(u!==void 0&&o.indent<=u&&(u=void 0),u!==void 0||C(o.content)===`implementation`){t.error(e.InvalidValidationRule,`Invalid validation rule '${o.content}'`,I(o)),u??=o.indent;continue}}if(C(o.content)===`require`){let e=r(i===`concept`?t.valueContext:t,o.content.substring(7).trim(),I(o),!1,t),n=null,a=`Error`,s=!1;for(let e=t.peekChild(o.indent);e!==void 0;e=t.peekChild(o.indent)){t.reader.takeSignificant();let r=U.exec(e.content);r!==null&&r.index===0?n=r[1]===void 0?r[2]:l(r[1]):C(e.content)===`severity`?(s||(a=Y[e.content.substring(8).trim()]??`Error`),s=!0):t.skipOpaqueBlock(e.indent)}e!==null&&c.push({kind:`RequirementSyntax`,condition:e,message:n,severity:a,location:I(o)});continue}let n=parseValidationRule(t,i===`concept`?{...o,content:`value ${o.content}`}:o,i,a);n!==void 0&&s.push(n)}return{kind:`DeclarativeValidateSyntax`,rules:s,requirements:c,location:I(n)}}if(i===`concept`&&C(n.content.substring(8).trimStart())===`checksum`){let e=parseValidationRule(t,{...n,content:`value ${n.content.substring(8).trimStart()}`},i,a);return e===void 0?void 0:{kind:`DeclarativeValidateSyntax`,rules:[e],requirements:[],location:I(n)}}if(n.content===`validate csharp`){let e=v(t.valueContext,{...n,content:`csharp`});return e===null&&t.skipOpaqueBlock(n.indent),{kind:`CodeValidateSyntax`,code:e,location:I(n)}}t.error(e.InvalidValidateDeclaration,`Invalid validate declaration '${n.content}' - expected 'validate' or 'validate csharp'`,I(n)),t.skipBlock(n.indent)}function parseValidationRule(t,n,r,i){let a=C(W.exec(n.content)?.[2]??``)===`checksum`,o=r===`concept`&&!a?t.valueContext:t,{content:s,message:c}=splitMessage(n.content),l=splitSeverity(o,n,s);if(l===void 0)return;let u=W.exec(l.content);if(u===null){o.error(e.InvalidValidationRule,`Invalid validation rule '${n.content}'`,I(n));return}let d=parseRule(o,u[2],n,r===`command`);if(d===void 0)return;d.kind===`Matches`&&d.value!==null&&E(t,d.value,I(n),n.raw,T(t,r,i,u[1]));let f=d.kind===`Rule`?parseRuleImplementation(t,n,r===`command`):{file:null,code:null,implementation:null};return{kind:`ValidationRuleSyntax`,property:u[1],rule:d.kind,value:d.value,message:c,severity:l.severity,...f,location:I(n)}}function parseRuleImplementation(t,n,r){let i=t.peekChild(n.indent);if(i===void 0)return{file:null,code:null,implementation:null};t.reader.takeSignificant();let a=r&&C(i.content)===`implementation`,o=a?x(t,i):{file:_(i)?y(t,i):null,code:!_(i)&&g(t,i)?v(t,i):null,implementation:null};!a&&o.file===null&&o.code===null&&(t.error(e.UnknownRuleImplementationDirective,`Unexpected '${i.content}' in rule implementation - expected 'file <path>' or an inline code block`,I(i)),t.skipBlock(i.indent));for(let i=t.peekChild(n.indent);i!==void 0&&(a||r&&C(i.content)===`implementation`);i=t.peekChild(n.indent))t.reader.takeSignificant(),t.error(a&&C(i.content)===`implementation`?e.InvalidImplementationBlock:e.ConflictingImplementationSources,`A named rule has one implementation wrapper and cannot mix wrapped and direct sources.`,I(i)),g(t,i)?v(t,i):t.skipBlock(i.indent);return o}function splitMessage(e){let t=U.exec(e);if(t===null)return{content:e,message:null};let n=t[1]===void 0?t[2]:l(t[1]);return{content:e.substring(0,t.index).trimEnd(),message:n}}function splitSeverity(t,n,r){let i=H.exec(r);if(i===null)return{content:r,severity:`Error`};let a=Y[i[1]];if(a===void 0)t.error(e.InvalidValidationSeverity,`Unknown validation severity '${i[1]}' - expected information, warning or error`,I(n));else return{content:r.substring(0,i.index).trimEnd(),severity:a}}const X=/* @__PURE__ */ new Set([`>`,`>=`,`<`,`<=`,`==`,`!=`]);function parseClockComparisonValue(t,n,r){let a=n.split(/\s+/).filter(e=>e.length>0),o=i(t,a,0,I(r));if(o===null)return S(n,I(r),t);if(o.expression!==null){if(o.position===a.length)return o.expression;t.error(e.InvalidValidationRule,`Invalid validation rule '${r.content}'`,I(r))}}function parseRule(t,n,r,i){if(n===`not empty`)return{kind:`NotEmpty`,value:null};if(C(n)===`checksum`){let i=n.substring(8).trim();if(i!==`luhn`&&i!==`mod11`&&i!==`mod97`){t.error(e.InvalidGenerationArgument,`Checksum validation requires luhn, mod11 or mod97.`,I(r));return}return{kind:`Checksum`,value:{kind:`LiteralExpressionSyntax`,value:i,location:I(r)}}}let a=G.exec(n);if(a===null)t.error(e.InvalidValidationRule,`Invalid validation rule '${r.content}'`,I(r));else{if((a[1]??a[2])===`rule`){let n=a[3].trim();if(!K.test(n)){t.error(e.InvalidRuleName,`Invalid rule name '${n}' in '${r.content}' - expected 'rule <Name>' with an identifier`,I(r));return}return{kind:`Rule`,value:{kind:`PathExpressionSyntax`,path:n,location:I(r)}}}return parseOperandRule(t,a,r,i)}}function parseOperandRule(e,t,n,r){let i=t[1]??t[2],a=r&&X.has(i)?parseClockComparisonValue(e,t[3],n):S(t[3],I(n),e);return a===void 0?void 0:{kind:J[i],value:a}}export{isDeclarativePredicate,parseCommand,parseValidate};
2
2
  //# sourceMappingURL=CommandParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommandParser.js","names":["header","pattern","routeHeader","sourceStreamPattern","calendarPrefix","calendarPattern","stringBodyPattern","severityPattern","messagePattern","rulePattern","operandPattern","ruleNamePattern","optionalReads","operandKinds","severities","opaqueDirectives","propertyShapedDirectives","names","lookahead","ParserContext","context","line","name","DiagnosticCodes","locationOf","properties","responses","identifier","validations","produces","reads","referenceReads","concurrency","description","documentation","authorize","authorizationDepthExceeded","handler","handlers","stream","streamCandidates","calendar","child","keyword","firstWord","asProperty","tryParseProperty","match","unescapeString","scalar","scalarResponsePattern","responseNames","parseCommandResponse","reportInvalidModifierOrder","source","streamName","ambiguous","route","parseCommandStream","isReactionIdentityLine","misplacedReactionIdentity","parseDescription","parseDocumentation","next","parseAuthorize","previous","combineAuthorize","validate","production","parseProduces","parseHandler","reference","parseReads","captureConcurrency","read","misplacedRuleHintForCommand","candidates","entry","property","discoveredNames","response","removed","parsed","validateHandlerContracts","syntax","commandReadSources","dependencySources","reportLegacyOptionalSuffix","commandName","file","parseFile","body","rule","isFileDirectiveAmongProperties","fence","code","parseCode","rules","requirements","wrapperIndent","owner","condition","parseCondition","message","severity","hasSeverity","directive","matched","ownerName","checksum","valueContext","withSeverity","validateMatchOperand","matchSubject","wrapped","commandOwner","parseImplementationWrapper","isFile","isCode","extra","content","text","algorithm","operand","operator","parseMappingSource"],"sources":["../../../../../../Compiler/Parsing/CommandParser.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 { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { validateHandlerContracts } from './CommandHandlerValidator';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { RequirementSyntax } from '../Syntax/Conditions';\nimport { misplacedRuleHintForCommand } from './MisplacedRuleHint';\nimport { parseCondition } from './ConditionParser';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { CommandSyntax, ValidateSyntax, ValidationRuleKind, ValidationRuleSyntax, ValidationSeverity } from '../Syntax/Commands';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { CommandCalendarSyntax } from '../Syntax/Calendar';\nimport { CommandStreamSyntax } from '../Syntax/EventSources';\nimport { parseCommandStream } from './EventSourceParser';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { ProducesSyntax } from '../Syntax/Reactions';\nimport { CommandResponseSyntax } from '../Syntax/Responses';\nimport { pattern } from '../Text/patterns';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { combineAuthorize, parseAuthorize } from './AuthorizeParser';\nimport { parseCommandResponse, scalarResponsePattern } from './CommandResponseParser';\nimport { parseDescription } from './DescriptionParser';\nimport { parseDocumentation } from './DocumentationParser';\nimport { isCode, isFile, parseCode, parseFile, parseHandler, parseImplementationWrapper } from './ImplementationParser';\nimport { CodeBlockSyntax, FileReferenceSyntax, HandlerSyntax, ImplementationSyntax } from '../Syntax/Implementations';\nimport { parseMappingSource } from './ExpressionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { matchSubject, validateMatchOperand } from './MatchOperandValidation';\nimport { isReactionIdentityLine, misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { commandReadSources } from './CommandReadSources';\nimport { dependencySources, ReadsSyntax, ConcurrencySyntax } from '../Syntax/DependencySources';\nimport { captureConcurrency } from './DependencySourceParser';\nimport { parseReads } from './ReadsParser';\nimport { parseProduces } from './ProducesParser';\nimport { reportInvalidModifierOrder, reportLegacyOptionalSuffix, tryParseProperty } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { isFileDirectiveAmongProperties } from './FileReferences';\n\nconst header = pattern('^command\\\\s+([A-Za-z_]\\\\w*)$');\nconst routeHeader = sourceStreamPattern('^stream\\\\s+[A-Za-z_]\\\\w*\\\\.[A-Za-z_]\\\\w*$');\nconst calendarPrefix = pattern('^calendar\\\\s+(?:\"|from\\\\s+\\\\$context\\\\.)');\nconst calendarPattern = pattern(`^calendar\\\\s+(?:\"(${stringBodyPattern})\"|from\\\\s+\\\\$context\\\\.([A-Za-z_][A-Za-z0-9_]*(?:\\\\.[A-Za-z_][A-Za-z0-9_]*)*))$`);\nconst severityPattern = pattern('\\\\bseverity\\\\s+(\\\\S+)$');\nconst messagePattern = pattern(`\\\\bmessage\\\\s+(?:\"(${stringBodyPattern})\"|(\\\\$strings\\\\.\\\\S*))$`);\nconst rulePattern = pattern('^([\\\\w.]+)\\\\s+(.+)$');\nconst operandPattern = pattern('^(?:(not empty|matches|not contains|contains|starts with|ends with|max|min|rule)(?:\\\\s+|$)|(length ==|decimals <=|all >=|all >|>=|<=|==|!=|>|<)\\\\s*)(.*)$');\nconst ruleNamePattern = sourceStreamPattern('^[A-Za-z_]\\\\w*$');\nconst optionalReads = pattern('^reads\\\\s+[A-Z]\\\\w*\\\\s+optional(?:\\\\s|$)');\n\n// Every operand the pattern matches has a kind, so an operand never goes unrecognized here.\nconst operandKinds: Record<string, ValidationRuleKind> = {\n max: 'Max',\n min: 'Min',\n '>': 'GreaterThan',\n '>=': 'GreaterThanOrEqual',\n '<': 'LessThan',\n '<=': 'LessThanOrEqual',\n '==': 'Equal',\n '!=': 'NotEqual',\n 'length ==': 'Length',\n 'decimals <=': 'DecimalPlaces',\n matches: 'Matches',\n contains: 'Contains',\n 'not contains': 'NotContains',\n 'starts with': 'StartsWith',\n 'ends with': 'EndsWith',\n 'all >': 'AllGreaterThan',\n 'all >=': 'AllGreaterThanOrEqual',\n};\n\nconst severities: Record<string, ValidationSeverity> = { information: 'Information', warning: 'Warning', error: 'Error' };\n\n// Command directives this compiler does not model. They are skipped whole.\nconst opaqueDirectives = new Set(['reads', 'concurrency']);\n\n// The bare directives cannot take a type reference, so a line with property shape is a property whatever\n// keyword it starts with - 'description String' declares a property called description.\nconst propertyShapedDirectives = new Set(['description', 'documentation', 'handler', 'concurrency']);\n\nexport function parseCommand(context: ParserContext, line: SourceLine): CommandSyntax {\n // Properties are leaves, not indentation owners. Resolve ambiguous returns spelling\n // before the committed pass decides whether its deeper lines belong to a response.\n const names = new Set<string>();\n const lookahead = new ParserContext(context.reader.fork(), context.path, context.languages);\n lookahead.sourceOptions = context.sourceOptions;\n lookahead.streamCandidates = context.streamCandidates;\n parseCommandBody(lookahead, line, undefined, names);\n return parseCommandBody(context, line, names);\n}\n\nfunction parseCommandBody(context: ParserContext, line: SourceLine, responseNames?: ReadonlySet<string>, discoveredNames?: Set<string>): CommandSyntax {\n const name = header.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidCommandDeclaration, `Invalid command declaration '${line.content}' - expected 'command <Name>'`, locationOf(line));\n }\n const properties: PropertySyntax[] = [];\n const responses: { line: SourceLine; candidate: PropertySyntax | null; response: CommandResponseSyntax | null }[] = [];\n let identifier: PropertySyntax | undefined;\n const validations: ValidateSyntax[] = [];\n const produces: ProducesSyntax[] = [];\n const reads: { readModel: string; alias: string | null }[] = [];\n const referenceReads: ReadsSyntax[] = [];\n let concurrency: ConcurrencySyntax | undefined;\n let description: string | null = null;\n let documentation: string | null = null;\n let authorize: AuthorizeSyntax | null = null;\n let authorizationDepthExceeded = false;\n let handler: HandlerSyntax | null = null;\n const handlers: { handler: HandlerSyntax | null; location: SourceLocation }[] = [];\n let stream: CommandStreamSyntax | null = null;\n const streamCandidates: CommandStreamSyntax[] = [];\n let calendar: CommandCalendarSyntax | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n const asProperty = tryParseProperty(child);\n if (keyword === 'calendar' && calendarPrefix.test(child.content)) {\n const match = calendarPattern.exec(child.content);\n if (calendar !== null || match === null) {\n context.error(DiagnosticCodes.InvalidCommandCalendar, 'A command declares at most one \\'calendar \"<id>\"\\' or \\'calendar from $context.<member>\\'.', locationOf(child));\n } else {\n calendar = { kind: 'CommandCalendarSyntax', id: match[1] === undefined ? null : unescapeString(match[1]), contextMember: match[2] ?? null, location: locationOf(child) };\n }\n } else if (asProperty !== undefined && (propertyShapedDirectives.has(keyword) || (keyword === 'validate' && child.content !== 'validate csharp'))) {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n } else if (keyword === 'returns') {\n const scalar = scalarResponsePattern.exec(child.content);\n if (scalar !== null && !scalar[1].startsWith('@') && asProperty !== undefined) {\n if (responseNames === undefined) {\n properties.push(asProperty);\n responses.push({ line: child, candidate: asProperty, response: null });\n } else if (responseNames.has(asProperty.type.name)) {\n responses.push({ line: child, candidate: null, response: parseCommandResponse(context, child) });\n } else {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n }\n } else if (asProperty !== undefined) {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n } else if (reportInvalidModifierOrder(context, child)) {\n context.skipBlock(child.indent);\n } else {\n responses.push({ line: child, candidate: null, response: parseCommandResponse(context, child) });\n }\n } else if (keyword === 'stream' && routeHeader.test(child.content) && asProperty !== undefined && context.streamCandidates?.hasSource(asProperty.type.name.split('.')[0]) === true) {\n const [source, streamName] = asProperty.type.name.split('.');\n const ambiguous = context.streamCandidates.hasPropertyType(asProperty.type.name) && context.streamCandidates.hasUniqueStream(source, streamName);\n const route = parseCommandStream(context, child, asProperty, ambiguous);\n if (stream !== null || streamCandidates.length > 0) context.error(DiagnosticCodes.InvalidCommandStream, 'A command declares at most one stream route.', locationOf(child));\n if (ambiguous || stream !== null) streamCandidates.push(route);\n else stream = route;\n } else if (keyword === 'runs' && isReactionIdentityLine(child)) {\n misplacedReactionIdentity(context, child);\n } else if (keyword === 'description') {\n description = parseDescription(context, child, description, `Command '${name}'`);\n } else if (keyword === 'documentation') {\n documentation = parseDocumentation(context, child, documentation, `Command '${name}'`);\n } else if (keyword === 'authorize') {\n const next = parseAuthorize(context, child);\n if (!authorizationDepthExceeded) {\n const previous = authorize;\n authorize = combineAuthorize(authorize, next, context);\n authorizationDepthExceeded = previous !== null && authorize === null;\n }\n } else if (keyword === 'validate') {\n const validate = parseValidate(context, child, 'command', name);\n if (validate !== undefined) {\n validations.push(validate);\n }\n } else if (keyword === 'produces') {\n const production = parseProduces(context, child, true);\n if (production !== undefined) produces.push(production);\n } else if (keyword === 'handler') {\n handler = parseHandler(context, child);\n handlers.push({ handler, location: locationOf(child) });\n } else if (opaqueDirectives.has(keyword)) {\n const reference = keyword === 'reads' ? parseReads(context, child) : undefined;\n if (reference !== undefined) referenceReads.push(reference);\n if (keyword === 'concurrency' && concurrency === undefined) concurrency = captureConcurrency(context, child);\n const read = /^reads\\s+([A-Z]\\w*)(?:\\s+as\\s+([a-z_]\\w*))?(?:\\s+by\\s+([a-z_]\\w*))?$/.exec(child.content);\n if (read !== null) reads.push({ readModel: read[1], alias: read[2] ?? null });\n if (optionalReads.test(child.content)) {\n context.error(DiagnosticCodes.OptionalReadsNotSupported, 'Optional reads are not yet supported (see #308).', locationOf(child));\n }\n context.skipOpaqueBlock(child.indent);\n } else if (asProperty !== undefined) {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n } else {\n reportInvalidModifierOrder(context, child);\n context.error(DiagnosticCodes.UnknownCommandDirective, `Unexpected '${child.content}' in command body${misplacedRuleHintForCommand(child.content)}`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n const candidates = new Set(responses.flatMap(entry => entry.candidate === null ? [] : [entry.candidate]));\n const names = new Set(properties.filter(property => !candidates.has(property)).map(property => property.name));\n if (responses.some(entry => entry.candidate !== null && !names.has(entry.candidate.type.name) && entry.candidate.type.name !== 'returns')) names.add('returns');\n for (const name of names) discoveredNames?.add(name);\n let response: CommandResponseSyntax | null = null;\n const removed = new Set<PropertySyntax>();\n for (const entry of responses) {\n let parsed = entry.response;\n if (entry.candidate !== null) {\n if (!names.has(entry.candidate.type.name)) continue;\n removed.add(entry.candidate);\n parsed = { kind: 'ScalarCommandResponseSyntax', source: { kind: 'PropertyResponseSourceSyntax', property: entry.candidate.type.name, location: entry.candidate.type.location }, location: locationOf(entry.line) };\n }\n if (parsed === null) continue;\n if (response !== null) {\n context.error(DiagnosticCodes.InvalidCommandResponse, 'A command declares at most one unconditional response.', locationOf(entry.line));\n } else {\n response = parsed;\n }\n }\n validateHandlerContracts(handlers, handler, produces.length > 0, context);\n const syntax: CommandSyntax = { kind: 'CommandSyntax', name, description, documentation, authorize, properties: properties.filter(property => !removed.has(property)), validations, produces, handler, response, stream, streamCandidates, ...(calendar === null ? {} : { calendar }), location: locationOf(line) };\n commandReadSources.set(syntax, reads);\n dependencySources.set(syntax, { reads: referenceReads, concurrency });\n return syntax;\n}\n\nfunction addProperty(context: ParserContext, properties: PropertySyntax[], property: PropertySyntax, commandName: string, line: SourceLine, identifier: PropertySyntax | undefined): PropertySyntax | undefined {\n reportLegacyOptionalSuffix(context, property.type, line);\n if (property.isIdentifier && identifier !== undefined) {\n context.error(DiagnosticCodes.DuplicateCommandIdentifier, `Command '${commandName}' already marks '${identifier.name}' as identifier - only one property can be the identifier`, property.location);\n property = { ...property, isIdentifier: false };\n }\n properties.push(property);\n return identifier ?? (property.isIdentifier ? property : undefined);\n}\n\nfunction parseValidationFile(context: ParserContext, header: SourceLine, body: SourceLine): ValidateSyntax | undefined {\n const file = parseFile(context, body);\n return file === undefined ? undefined : { kind: 'FileValidateSyntax', file, location: locationOf(header) };\n}\n\nfunction hasValidationOperand(line: SourceLine): boolean {\n const match = rulePattern.exec(line.content);\n if (match === null) return false;\n return startsWithRuleOperand(match[2]);\n}\n\nfunction startsWithRuleOperand(rule: string): boolean {\n return (firstWord(rule) === 'not' && firstWord(rule.substring('not'.length).trimStart()) === 'empty') ||\n firstWord(rule) === 'checksum' || operandPattern.test(rule);\n}\n\n/** Recognizes a declarative predicate, with any message or severity suffix; a named 'rule <Name>' is not one. */\nexport function isDeclarativePredicate(rule: string): boolean {\n return startsWithRuleOperand(rule) && firstWord(rule) !== 'rule';\n}\n\nfunction isValidationFileBody(context: ParserContext, header: SourceLine, body: SourceLine): boolean {\n if (!isFileDirectiveAmongProperties(body) || hasValidationOperand(body)) return false;\n const lookahead = context.reader.fork();\n lookahead.takeSignificant();\n const next = lookahead.peekSignificant();\n return next === undefined || next.indent <= header.indent;\n}\n\n// Reads a 'validate' block: declarative rules, or code - which is recognized but not modeled.\nexport function parseValidate(context: ParserContext, line: SourceLine, owner: 'command' | 'concept', ownerName: string): ValidateSyntax | undefined {\n if (line.content === 'validate') {\n const fence = context.peekChild(line.indent);\n if (fence !== undefined && isValidationFileBody(context, line, fence)) {\n context.reader.takeSignificant();\n return parseValidationFile(context, line, fence);\n }\n if (fence !== undefined && fence.content.startsWith('```')) {\n context.reader.takeSignificant();\n const code = parseCode(context.valueContext, fence);\n if (code === null) context.skipFencedBody();\n return { kind: 'CodeValidateSyntax', code, location: locationOf(line) };\n }\n const rules: ValidationRuleSyntax[] = [];\n const requirements: RequirementSyntax[] = [];\n let wrapperIndent: number | undefined;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (owner === 'concept') {\n if (context.sourceOptions.numericMode === 'legacy' && child.content.startsWith('```')) { context.skipFencedBody(); continue; }\n if (wrapperIndent !== undefined && child.indent <= wrapperIndent) wrapperIndent = undefined;\n if (wrapperIndent !== undefined || firstWord(child.content) === 'implementation') {\n context.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${child.content}'`, locationOf(child));\n wrapperIndent ??= child.indent;\n continue;\n }\n }\n if (firstWord(child.content) === 'require') {\n // Keep legacy operand enrichment quiet, but never discard the depth refusal.\n const condition = parseCondition(owner === 'concept' ? context.valueContext : context, child.content.substring('require'.length).trim(), locationOf(child), false, context);\n let message: string | null = null;\n let severity: ValidationSeverity = 'Error';\n let hasSeverity = false;\n for (let directive = context.peekChild(child.indent); directive !== undefined; directive = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n const matched = messagePattern.exec(directive.content);\n if (matched !== null && matched.index === 0) message = matched[1] !== undefined ? unescapeString(matched[1]) : matched[2];\n else if (firstWord(directive.content) === 'severity') {\n if (!hasSeverity) severity = severities[directive.content.substring('severity'.length).trim()] ?? 'Error';\n hasSeverity = true;\n } else context.skipOpaqueBlock(directive.indent);\n }\n if (condition !== null) requirements.push({ kind: 'RequirementSyntax', condition, message, severity, location: locationOf(child) });\n continue;\n }\n const rule = parseValidationRule(context, owner === 'concept' ? { ...child, content: `value ${child.content}` } : child, owner, ownerName);\n if (rule !== undefined) {\n rules.push(rule);\n }\n }\n return { kind: 'DeclarativeValidateSyntax', rules, requirements, location: locationOf(line) };\n }\n if (owner === 'concept' && firstWord(line.content.substring('validate'.length).trimStart()) === 'checksum') {\n const ruleLine = { ...line, content: `value ${line.content.substring('validate'.length).trimStart()}` };\n const rule = parseValidationRule(context, ruleLine, owner, ownerName);\n return rule === undefined ? undefined : { kind: 'DeclarativeValidateSyntax', rules: [rule], requirements: [], location: locationOf(line) };\n }\n if (line.content === 'validate csharp') {\n const code = parseCode(context.valueContext, { ...line, content: 'csharp' });\n if (code === null) context.skipOpaqueBlock(line.indent);\n return { kind: 'CodeValidateSyntax', code, location: locationOf(line) };\n }\n context.error(DiagnosticCodes.InvalidValidateDeclaration, `Invalid validate declaration '${line.content}' - expected 'validate' or 'validate csharp'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n}\n\nfunction parseValidationRule(context: ParserContext, line: SourceLine, owner: 'command' | 'concept', ownerName: string): ValidationRuleSyntax | undefined {\n // Checksum is a new declaration, not enrichment of a formerly opaque Legacy rule.\n const checksum = firstWord(rulePattern.exec(line.content)?.[2] ?? '') === 'checksum';\n const valueContext = owner === 'concept' && !checksum ? context.valueContext : context;\n const { content: withSeverity, message } = splitMessage(line.content);\n const severity = splitSeverity(valueContext, line, withSeverity);\n if (severity === undefined) {\n return undefined;\n }\n const match = rulePattern.exec(severity.content);\n if (match === null) {\n valueContext.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${line.content}'`, locationOf(line));\n return undefined;\n }\n const parsed = parseRule(valueContext, match[2], line);\n if (parsed === undefined) {\n return undefined;\n }\n if (parsed.kind === 'Matches' && parsed.value !== null) validateMatchOperand(context, parsed.value, locationOf(line), line.raw, matchSubject(context, owner, ownerName, match[1]));\n const source = parsed.kind === 'Rule' ? parseRuleImplementation(context, line, owner === 'command') : { file: null, code: null, implementation: null };\n return {\n kind: 'ValidationRuleSyntax',\n property: match[1],\n rule: parsed.kind,\n value: parsed.value,\n message,\n severity: severity.severity,\n ...source,\n location: locationOf(line),\n };\n}\n\nfunction parseRuleImplementation(context: ParserContext, rule: SourceLine, commandOwner: boolean): { file: FileReferenceSyntax | null; code: CodeBlockSyntax | null; implementation: ImplementationSyntax | null } {\n const body = context.peekChild(rule.indent);\n if (body === undefined) return { file: null, code: null, implementation: null };\n context.reader.takeSignificant();\n const wrapped = commandOwner && firstWord(body.content) === 'implementation';\n const source = wrapped ? parseImplementationWrapper(context, body) : {\n file: isFile(body) ? parseFile(context, body) : null,\n code: !isFile(body) && isCode(context, body) ? parseCode(context, body) : null,\n implementation: null,\n };\n if (!wrapped && source.file === null && source.code === null) {\n context.error(DiagnosticCodes.UnknownRuleImplementationDirective, `Unexpected '${body.content}' in rule implementation - expected 'file <path>' or an inline code block`, locationOf(body));\n context.skipBlock(body.indent);\n }\n for (let extra = context.peekChild(rule.indent); extra !== undefined && (wrapped || (commandOwner && firstWord(extra.content) === 'implementation')); extra = context.peekChild(rule.indent)) {\n context.reader.takeSignificant();\n context.error(wrapped && firstWord(extra.content) === 'implementation' ? DiagnosticCodes.InvalidImplementationBlock : DiagnosticCodes.ConflictingImplementationSources,\n 'A named rule has one implementation wrapper and cannot mix wrapped and direct sources.', locationOf(extra));\n if (isCode(context, extra)) parseCode(context, extra);\n else context.skipBlock(extra.indent);\n }\n return source;\n}\n\nfunction splitMessage(content: string): { content: string; message: string | null } {\n const match = messagePattern.exec(content);\n if (match === null) {\n return { content, message: null };\n }\n const message = match[1] !== undefined ? unescapeString(match[1]) : match[2];\n return { content: content.substring(0, match.index).trimEnd(), message };\n}\n\nfunction splitSeverity(context: ParserContext, line: SourceLine, text: string): { content: string; severity: ValidationSeverity } | undefined {\n const match = severityPattern.exec(text);\n if (match === null) {\n return { content: text, severity: 'Error' };\n }\n const severity = severities[match[1]];\n if (severity === undefined) {\n context.error(DiagnosticCodes.InvalidValidationSeverity, `Unknown validation severity '${match[1]}' - expected information, warning or error`, locationOf(line));\n return undefined;\n }\n return { content: text.substring(0, match.index).trimEnd(), severity };\n}\n\nfunction parseRule(context: ParserContext, rule: string, line: SourceLine): { kind: ValidationRuleKind; value: ExpressionSyntax | null } | undefined {\n if (rule === 'not empty') {\n return { kind: 'NotEmpty', value: null };\n }\n if (firstWord(rule) === 'checksum') {\n const algorithm = rule.substring('checksum'.length).trim();\n if (algorithm !== 'luhn' && algorithm !== 'mod11' && algorithm !== 'mod97') {\n context.error(DiagnosticCodes.InvalidGenerationArgument, 'Checksum validation requires luhn, mod11 or mod97.', locationOf(line));\n return undefined;\n }\n return { kind: 'Checksum', value: { kind: 'LiteralExpressionSyntax', value: algorithm, location: locationOf(line) } };\n }\n const operand = operandPattern.exec(rule);\n if (operand === null) {\n context.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${line.content}'`, locationOf(line));\n return undefined;\n }\n const operator = operand[1] ?? operand[2];\n if (operator === 'rule') {\n const name = operand[3].trim();\n if (!ruleNamePattern.test(name)) {\n context.error(DiagnosticCodes.InvalidRuleName, `Invalid rule name '${name}' in '${line.content}' - expected 'rule <Name>' with an identifier`, locationOf(line));\n return undefined;\n }\n return { kind: 'Rule', value: { kind: 'PathExpressionSyntax', path: name, location: locationOf(line) } };\n }\n return { kind: operandKinds[operator], value: parseMappingSource(operand[3], locationOf(line), context) };\n}\n"],"mappings":"A,60DAyCA,MAAMA,GAASC,EAAQ,8BAA8B,EAC/CC,EAAcC,EAAoB,2CAA2C,EAC7EC,EAAiBH,EAAQ,0CAA0C,EACnEI,EAAkBJ,EAAQ,qBAAqBK,EAAkB,iFAAiF,EAClJC,EAAkBN,EAAQ,wBAAwB,EAClDO,EAAiBP,EAAQ,sBAAsBK,EAAkB,yBAAyB,EAC1FG,EAAcR,EAAQ,qBAAqB,EAC3CS,EAAiBT,EAAQ,2JAA2J,EACpLU,EAAkBR,EAAoB,iBAAiB,EACvDS,EAAgBX,EAAQ,0CAA0C,EAGlEY,EAAmD,CACrD,IAAK,MACL,IAAK,MACL,IAAK,cACL,KAAM,qBACN,IAAK,WACL,KAAM,kBACN,KAAM,QACN,KAAM,WACN,YAAa,SACb,cAAe,gBACf,QAAS,UACT,SAAU,WACV,eAAgB,cAChB,cAAe,aACf,YAAa,WACb,QAAS,iBACT,SAAU,uBACd,EAEMC,EAAiD,CAAE,YAAa,cAAe,QAAS,UAAW,MAAO,OAAQ,EAGlHC,kBAAmB,IAAI,IAAI,CAAC,QAAS,aAAa,CAAC,EAInDC,kBAA2B,IAAI,IAAI,CAAC,cAAe,gBAAiB,UAAW,aAAa,CAAC,EAEnG,SAAgB,aAAa,EAAwB,EAAiC,CAGlF,IAAMC,kBAAQ,IAAI,IACZC,EAAY,IAAIC,EAAcC,EAAQ,OAAO,KAAK,EAAGA,EAAQ,KAAM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EAAQ,GACvC,GAAIC,IAAa,OAAQ,CACrB,IAAMtG,EAAOqG,EAAQ,EAAE,CAAC,KAAK,EAC7B,GAAI,CAAChH,EAAgB,KAAKW,CAAI,EAAG,CAC7BF,EAAQ,MAAMG,EAAgB,gBAAiB,sBAAsBD,EAAK,QAAQD,EAAK,QAAQ,+CAAgDG,EAAWH,CAAI,CAAC,EAC/J,MACJ,CACA,MAAO,CAAE,KAAM,OAAQ,MAAO,CAAE,KAAM,uBAAwB,KAAMC,EAAM,SAAUE,EAAWH,CAAI,CAAE,CAAE,CAC3G,CACA,MAAO,CAAE,KAAMR,EAAa+G,GAAW,MAAOC,EAAmBF,EAAQ,GAAInG,EAAWH,CAAI,EAAGD,CAAO,CAAE,CAC5G,C"}
1
+ {"version":3,"file":"CommandParser.js","names":["header","pattern","routeHeader","sourceStreamPattern","calendarPrefix","calendarPattern","stringBodyPattern","severityPattern","messagePattern","rulePattern","operandPattern","ruleNamePattern","optionalReads","operandKinds","severities","opaqueDirectives","propertyShapedDirectives","names","lookahead","ParserContext","context","line","name","DiagnosticCodes","locationOf","properties","responses","identifier","validations","produces","reads","referenceReads","concurrency","description","documentation","authorize","authorizationDepthExceeded","handler","handlers","stream","streamCandidates","calendar","child","keyword","firstWord","asProperty","tryParseProperty","match","unescapeString","scalar","scalarResponsePattern","responseNames","parseCommandResponse","reportInvalidModifierOrder","source","streamName","ambiguous","route","parseCommandStream","isReactionIdentityLine","misplacedReactionIdentity","parseDescription","parseDocumentation","next","parseAuthorize","previous","combineAuthorize","validate","production","parseProduces","parseHandler","reference","parseReads","captureConcurrency","read","misplacedRuleHintForCommand","candidates","entry","property","discoveredNames","response","removed","parsed","validateHandlerContracts","syntax","commandReadSources","dependencySources","reportLegacyOptionalSuffix","commandName","file","parseFile","body","rule","isFileDirectiveAmongProperties","fence","code","parseCode","rules","requirements","wrapperIndent","owner","condition","parseCondition","message","severity","hasSeverity","directive","matched","ownerName","checksum","valueContext","withSeverity","validateMatchOperand","matchSubject","wrapped","commandOwner","parseImplementationWrapper","isFile","isCode","extra","content","text","clockComparisons","tokens","token","clock","parseClockOperand","parseMappingSource","algorithm","operand","clockOperands","operator","value"],"sources":["../../../../../../Compiler/Parsing/CommandParser.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 { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { validateHandlerContracts } from './CommandHandlerValidator';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { RequirementSyntax } from '../Syntax/Conditions';\nimport { misplacedRuleHintForCommand } from './MisplacedRuleHint';\nimport { parseCondition } from './ConditionParser';\nimport { parseClockOperand } from './ClockOperandParser';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { CommandSyntax, ValidateSyntax, ValidationRuleKind, ValidationRuleSyntax, ValidationSeverity } from '../Syntax/Commands';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { CommandCalendarSyntax } from '../Syntax/Calendar';\nimport { CommandStreamSyntax } from '../Syntax/EventSources';\nimport { parseCommandStream } from './EventSourceParser';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { ProducesSyntax } from '../Syntax/Reactions';\nimport { CommandResponseSyntax } from '../Syntax/Responses';\nimport { pattern } from '../Text/patterns';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { combineAuthorize, parseAuthorize } from './AuthorizeParser';\nimport { parseCommandResponse, scalarResponsePattern } from './CommandResponseParser';\nimport { parseDescription } from './DescriptionParser';\nimport { parseDocumentation } from './DocumentationParser';\nimport { isCode, isFile, parseCode, parseFile, parseHandler, parseImplementationWrapper } from './ImplementationParser';\nimport { CodeBlockSyntax, FileReferenceSyntax, HandlerSyntax, ImplementationSyntax } from '../Syntax/Implementations';\nimport { parseMappingSource } from './ExpressionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { matchSubject, validateMatchOperand } from './MatchOperandValidation';\nimport { isReactionIdentityLine, misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { commandReadSources } from './CommandReadSources';\nimport { dependencySources, ReadsSyntax, ConcurrencySyntax } from '../Syntax/DependencySources';\nimport { captureConcurrency } from './DependencySourceParser';\nimport { parseReads } from './ReadsParser';\nimport { parseProduces } from './ProducesParser';\nimport { reportInvalidModifierOrder, reportLegacyOptionalSuffix, tryParseProperty } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { isFileDirectiveAmongProperties } from './FileReferences';\n\nconst header = pattern('^command\\\\s+([A-Za-z_]\\\\w*)$');\nconst routeHeader = sourceStreamPattern('^stream\\\\s+[A-Za-z_]\\\\w*\\\\.[A-Za-z_]\\\\w*$');\nconst calendarPrefix = pattern('^calendar\\\\s+(?:\"|from\\\\s+\\\\$context\\\\.)');\nconst calendarPattern = pattern(`^calendar\\\\s+(?:\"(${stringBodyPattern})\"|from\\\\s+\\\\$context\\\\.([A-Za-z_][A-Za-z0-9_]*(?:\\\\.[A-Za-z_][A-Za-z0-9_]*)*))$`);\nconst severityPattern = pattern('\\\\bseverity\\\\s+(\\\\S+)$');\nconst messagePattern = pattern(`\\\\bmessage\\\\s+(?:\"(${stringBodyPattern})\"|(\\\\$strings\\\\.\\\\S*))$`);\nconst rulePattern = pattern('^([\\\\w.]+)\\\\s+(.+)$');\nconst operandPattern = pattern('^(?:(not empty|matches|not contains|contains|starts with|ends with|max|min|rule)(?:\\\\s+|$)|(length ==|decimals <=|all >=|all >|>=|<=|==|!=|>|<)\\\\s*)(.*)$');\nconst ruleNamePattern = sourceStreamPattern('^[A-Za-z_]\\\\w*$');\nconst optionalReads = pattern('^reads\\\\s+[A-Z]\\\\w*\\\\s+optional(?:\\\\s|$)');\n\n// Every operand the pattern matches has a kind, so an operand never goes unrecognized here.\nconst operandKinds: Record<string, ValidationRuleKind> = {\n max: 'Max',\n min: 'Min',\n '>': 'GreaterThan',\n '>=': 'GreaterThanOrEqual',\n '<': 'LessThan',\n '<=': 'LessThanOrEqual',\n '==': 'Equal',\n '!=': 'NotEqual',\n 'length ==': 'Length',\n 'decimals <=': 'DecimalPlaces',\n matches: 'Matches',\n contains: 'Contains',\n 'not contains': 'NotContains',\n 'starts with': 'StartsWith',\n 'ends with': 'EndsWith',\n 'all >': 'AllGreaterThan',\n 'all >=': 'AllGreaterThanOrEqual',\n};\n\nconst severities: Record<string, ValidationSeverity> = { information: 'Information', warning: 'Warning', error: 'Error' };\n\n// Command directives this compiler does not model. They are skipped whole.\nconst opaqueDirectives = new Set(['reads', 'concurrency']);\n\n// The bare directives cannot take a type reference, so a line with property shape is a property whatever\n// keyword it starts with - 'description String' declares a property called description.\nconst propertyShapedDirectives = new Set(['description', 'documentation', 'handler', 'concurrency']);\n\nexport function parseCommand(context: ParserContext, line: SourceLine): CommandSyntax {\n // Properties are leaves, not indentation owners. Resolve ambiguous returns spelling\n // before the committed pass decides whether its deeper lines belong to a response.\n const names = new Set<string>();\n const lookahead = new ParserContext(context.reader.fork(), context.path, context.languages);\n lookahead.sourceOptions = context.sourceOptions;\n lookahead.streamCandidates = context.streamCandidates;\n parseCommandBody(lookahead, line, undefined, names);\n return parseCommandBody(context, line, names);\n}\n\nfunction parseCommandBody(context: ParserContext, line: SourceLine, responseNames?: ReadonlySet<string>, discoveredNames?: Set<string>): CommandSyntax {\n const name = header.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidCommandDeclaration, `Invalid command declaration '${line.content}' - expected 'command <Name>'`, locationOf(line));\n }\n const properties: PropertySyntax[] = [];\n const responses: { line: SourceLine; candidate: PropertySyntax | null; response: CommandResponseSyntax | null }[] = [];\n let identifier: PropertySyntax | undefined;\n const validations: ValidateSyntax[] = [];\n const produces: ProducesSyntax[] = [];\n const reads: { readModel: string; alias: string | null }[] = [];\n const referenceReads: ReadsSyntax[] = [];\n let concurrency: ConcurrencySyntax | undefined;\n let description: string | null = null;\n let documentation: string | null = null;\n let authorize: AuthorizeSyntax | null = null;\n let authorizationDepthExceeded = false;\n let handler: HandlerSyntax | null = null;\n const handlers: { handler: HandlerSyntax | null; location: SourceLocation }[] = [];\n let stream: CommandStreamSyntax | null = null;\n const streamCandidates: CommandStreamSyntax[] = [];\n let calendar: CommandCalendarSyntax | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n const asProperty = tryParseProperty(child);\n if (keyword === 'calendar' && calendarPrefix.test(child.content)) {\n const match = calendarPattern.exec(child.content);\n if (calendar !== null || match === null) {\n context.error(DiagnosticCodes.InvalidCommandCalendar, 'A command declares at most one \\'calendar \"<id>\"\\' or \\'calendar from $context.<member>\\'.', locationOf(child));\n } else {\n calendar = { kind: 'CommandCalendarSyntax', id: match[1] === undefined ? null : unescapeString(match[1]), contextMember: match[2] ?? null, location: locationOf(child) };\n }\n } else if (asProperty !== undefined && (propertyShapedDirectives.has(keyword) || (keyword === 'validate' && child.content !== 'validate csharp'))) {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n } else if (keyword === 'returns') {\n const scalar = scalarResponsePattern.exec(child.content);\n if (scalar !== null && !scalar[1].startsWith('@') && asProperty !== undefined) {\n if (responseNames === undefined) {\n properties.push(asProperty);\n responses.push({ line: child, candidate: asProperty, response: null });\n } else if (responseNames.has(asProperty.type.name)) {\n responses.push({ line: child, candidate: null, response: parseCommandResponse(context, child) });\n } else {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n }\n } else if (asProperty !== undefined) {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n } else if (reportInvalidModifierOrder(context, child)) {\n context.skipBlock(child.indent);\n } else {\n responses.push({ line: child, candidate: null, response: parseCommandResponse(context, child) });\n }\n } else if (keyword === 'stream' && routeHeader.test(child.content) && asProperty !== undefined && context.streamCandidates?.hasSource(asProperty.type.name.split('.')[0]) === true) {\n const [source, streamName] = asProperty.type.name.split('.');\n const ambiguous = context.streamCandidates.hasPropertyType(asProperty.type.name) && context.streamCandidates.hasUniqueStream(source, streamName);\n const route = parseCommandStream(context, child, asProperty, ambiguous);\n if (stream !== null || streamCandidates.length > 0) context.error(DiagnosticCodes.InvalidCommandStream, 'A command declares at most one stream route.', locationOf(child));\n if (ambiguous || stream !== null) streamCandidates.push(route);\n else stream = route;\n } else if (keyword === 'runs' && isReactionIdentityLine(child)) {\n misplacedReactionIdentity(context, child);\n } else if (keyword === 'description') {\n description = parseDescription(context, child, description, `Command '${name}'`);\n } else if (keyword === 'documentation') {\n documentation = parseDocumentation(context, child, documentation, `Command '${name}'`);\n } else if (keyword === 'authorize') {\n const next = parseAuthorize(context, child);\n if (!authorizationDepthExceeded) {\n const previous = authorize;\n authorize = combineAuthorize(authorize, next, context);\n authorizationDepthExceeded = previous !== null && authorize === null;\n }\n } else if (keyword === 'validate') {\n const validate = parseValidate(context, child, 'command', name);\n if (validate !== undefined) {\n validations.push(validate);\n }\n } else if (keyword === 'produces') {\n const production = parseProduces(context, child, true);\n if (production !== undefined) produces.push(production);\n } else if (keyword === 'handler') {\n handler = parseHandler(context, child);\n handlers.push({ handler, location: locationOf(child) });\n } else if (opaqueDirectives.has(keyword)) {\n const reference = keyword === 'reads' ? parseReads(context, child) : undefined;\n if (reference !== undefined) referenceReads.push(reference);\n if (keyword === 'concurrency' && concurrency === undefined) concurrency = captureConcurrency(context, child);\n const read = /^reads\\s+([A-Z]\\w*)(?:\\s+as\\s+([a-z_]\\w*))?(?:\\s+by\\s+([a-z_]\\w*))?$/.exec(child.content);\n if (read !== null) reads.push({ readModel: read[1], alias: read[2] ?? null });\n if (optionalReads.test(child.content)) {\n context.error(DiagnosticCodes.OptionalReadsNotSupported, 'Optional reads are not yet supported (see #308).', locationOf(child));\n }\n context.skipOpaqueBlock(child.indent);\n } else if (asProperty !== undefined) {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n } else {\n reportInvalidModifierOrder(context, child);\n context.error(DiagnosticCodes.UnknownCommandDirective, `Unexpected '${child.content}' in command body${misplacedRuleHintForCommand(child.content)}`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n const candidates = new Set(responses.flatMap(entry => entry.candidate === null ? [] : [entry.candidate]));\n const names = new Set(properties.filter(property => !candidates.has(property)).map(property => property.name));\n if (responses.some(entry => entry.candidate !== null && !names.has(entry.candidate.type.name) && entry.candidate.type.name !== 'returns')) names.add('returns');\n for (const name of names) discoveredNames?.add(name);\n let response: CommandResponseSyntax | null = null;\n const removed = new Set<PropertySyntax>();\n for (const entry of responses) {\n let parsed = entry.response;\n if (entry.candidate !== null) {\n if (!names.has(entry.candidate.type.name)) continue;\n removed.add(entry.candidate);\n parsed = { kind: 'ScalarCommandResponseSyntax', source: { kind: 'PropertyResponseSourceSyntax', property: entry.candidate.type.name, location: entry.candidate.type.location }, location: locationOf(entry.line) };\n }\n if (parsed === null) continue;\n if (response !== null) {\n context.error(DiagnosticCodes.InvalidCommandResponse, 'A command declares at most one unconditional response.', locationOf(entry.line));\n } else {\n response = parsed;\n }\n }\n validateHandlerContracts(handlers, handler, produces.length > 0, context);\n const syntax: CommandSyntax = { kind: 'CommandSyntax', name, description, documentation, authorize, properties: properties.filter(property => !removed.has(property)), validations, produces, handler, response, stream, streamCandidates, ...(calendar === null ? {} : { calendar }), location: locationOf(line) };\n commandReadSources.set(syntax, reads);\n dependencySources.set(syntax, { reads: referenceReads, concurrency });\n return syntax;\n}\n\nfunction addProperty(context: ParserContext, properties: PropertySyntax[], property: PropertySyntax, commandName: string, line: SourceLine, identifier: PropertySyntax | undefined): PropertySyntax | undefined {\n reportLegacyOptionalSuffix(context, property.type, line);\n if (property.isIdentifier && identifier !== undefined) {\n context.error(DiagnosticCodes.DuplicateCommandIdentifier, `Command '${commandName}' already marks '${identifier.name}' as identifier - only one property can be the identifier`, property.location);\n property = { ...property, isIdentifier: false };\n }\n properties.push(property);\n return identifier ?? (property.isIdentifier ? property : undefined);\n}\n\nfunction parseValidationFile(context: ParserContext, header: SourceLine, body: SourceLine): ValidateSyntax | undefined {\n const file = parseFile(context, body);\n return file === undefined ? undefined : { kind: 'FileValidateSyntax', file, location: locationOf(header) };\n}\n\nfunction hasValidationOperand(line: SourceLine): boolean {\n const match = rulePattern.exec(line.content);\n if (match === null) return false;\n return startsWithRuleOperand(match[2]);\n}\n\nfunction startsWithRuleOperand(rule: string): boolean {\n return (firstWord(rule) === 'not' && firstWord(rule.substring('not'.length).trimStart()) === 'empty') ||\n firstWord(rule) === 'checksum' || operandPattern.test(rule);\n}\n\n/** Recognizes a declarative predicate, with any message or severity suffix; a named 'rule <Name>' is not one. */\nexport function isDeclarativePredicate(rule: string): boolean {\n return startsWithRuleOperand(rule) && firstWord(rule) !== 'rule';\n}\n\nfunction isValidationFileBody(context: ParserContext, header: SourceLine, body: SourceLine): boolean {\n if (!isFileDirectiveAmongProperties(body) || hasValidationOperand(body)) return false;\n const lookahead = context.reader.fork();\n lookahead.takeSignificant();\n const next = lookahead.peekSignificant();\n return next === undefined || next.indent <= header.indent;\n}\n\n// Reads a 'validate' block: declarative rules, or code - which is recognized but not modeled.\nexport function parseValidate(context: ParserContext, line: SourceLine, owner: 'command' | 'concept', ownerName: string): ValidateSyntax | undefined {\n if (line.content === 'validate') {\n const fence = context.peekChild(line.indent);\n if (fence !== undefined && isValidationFileBody(context, line, fence)) {\n context.reader.takeSignificant();\n return parseValidationFile(context, line, fence);\n }\n if (fence !== undefined && fence.content.startsWith('```')) {\n context.reader.takeSignificant();\n const code = parseCode(context.valueContext, fence);\n if (code === null) context.skipFencedBody();\n return { kind: 'CodeValidateSyntax', code, location: locationOf(line) };\n }\n const rules: ValidationRuleSyntax[] = [];\n const requirements: RequirementSyntax[] = [];\n let wrapperIndent: number | undefined;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (owner === 'concept') {\n if (context.sourceOptions.numericMode === 'legacy' && child.content.startsWith('```')) { context.skipFencedBody(); continue; }\n if (wrapperIndent !== undefined && child.indent <= wrapperIndent) wrapperIndent = undefined;\n if (wrapperIndent !== undefined || firstWord(child.content) === 'implementation') {\n context.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${child.content}'`, locationOf(child));\n wrapperIndent ??= child.indent;\n continue;\n }\n }\n if (firstWord(child.content) === 'require') {\n // Keep legacy operand enrichment quiet, but never discard the depth refusal.\n const condition = parseCondition(owner === 'concept' ? context.valueContext : context, child.content.substring('require'.length).trim(), locationOf(child), false, context);\n let message: string | null = null;\n let severity: ValidationSeverity = 'Error';\n let hasSeverity = false;\n for (let directive = context.peekChild(child.indent); directive !== undefined; directive = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n const matched = messagePattern.exec(directive.content);\n if (matched !== null && matched.index === 0) message = matched[1] !== undefined ? unescapeString(matched[1]) : matched[2];\n else if (firstWord(directive.content) === 'severity') {\n if (!hasSeverity) severity = severities[directive.content.substring('severity'.length).trim()] ?? 'Error';\n hasSeverity = true;\n } else context.skipOpaqueBlock(directive.indent);\n }\n if (condition !== null) requirements.push({ kind: 'RequirementSyntax', condition, message, severity, location: locationOf(child) });\n continue;\n }\n const rule = parseValidationRule(context, owner === 'concept' ? { ...child, content: `value ${child.content}` } : child, owner, ownerName);\n if (rule !== undefined) {\n rules.push(rule);\n }\n }\n return { kind: 'DeclarativeValidateSyntax', rules, requirements, location: locationOf(line) };\n }\n if (owner === 'concept' && firstWord(line.content.substring('validate'.length).trimStart()) === 'checksum') {\n const ruleLine = { ...line, content: `value ${line.content.substring('validate'.length).trimStart()}` };\n const rule = parseValidationRule(context, ruleLine, owner, ownerName);\n return rule === undefined ? undefined : { kind: 'DeclarativeValidateSyntax', rules: [rule], requirements: [], location: locationOf(line) };\n }\n if (line.content === 'validate csharp') {\n const code = parseCode(context.valueContext, { ...line, content: 'csharp' });\n if (code === null) context.skipOpaqueBlock(line.indent);\n return { kind: 'CodeValidateSyntax', code, location: locationOf(line) };\n }\n context.error(DiagnosticCodes.InvalidValidateDeclaration, `Invalid validate declaration '${line.content}' - expected 'validate' or 'validate csharp'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n}\n\nfunction parseValidationRule(context: ParserContext, line: SourceLine, owner: 'command' | 'concept', ownerName: string): ValidationRuleSyntax | undefined {\n // Checksum is a new declaration, not enrichment of a formerly opaque Legacy rule.\n const checksum = firstWord(rulePattern.exec(line.content)?.[2] ?? '') === 'checksum';\n const valueContext = owner === 'concept' && !checksum ? context.valueContext : context;\n const { content: withSeverity, message } = splitMessage(line.content);\n const severity = splitSeverity(valueContext, line, withSeverity);\n if (severity === undefined) {\n return undefined;\n }\n const match = rulePattern.exec(severity.content);\n if (match === null) {\n valueContext.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${line.content}'`, locationOf(line));\n return undefined;\n }\n const parsed = parseRule(valueContext, match[2], line, owner === 'command');\n if (parsed === undefined) {\n return undefined;\n }\n if (parsed.kind === 'Matches' && parsed.value !== null) validateMatchOperand(context, parsed.value, locationOf(line), line.raw, matchSubject(context, owner, ownerName, match[1]));\n const source = parsed.kind === 'Rule' ? parseRuleImplementation(context, line, owner === 'command') : { file: null, code: null, implementation: null };\n return {\n kind: 'ValidationRuleSyntax',\n property: match[1],\n rule: parsed.kind,\n value: parsed.value,\n message,\n severity: severity.severity,\n ...source,\n location: locationOf(line),\n };\n}\n\nfunction parseRuleImplementation(context: ParserContext, rule: SourceLine, commandOwner: boolean): { file: FileReferenceSyntax | null; code: CodeBlockSyntax | null; implementation: ImplementationSyntax | null } {\n const body = context.peekChild(rule.indent);\n if (body === undefined) return { file: null, code: null, implementation: null };\n context.reader.takeSignificant();\n const wrapped = commandOwner && firstWord(body.content) === 'implementation';\n const source = wrapped ? parseImplementationWrapper(context, body) : {\n file: isFile(body) ? parseFile(context, body) : null,\n code: !isFile(body) && isCode(context, body) ? parseCode(context, body) : null,\n implementation: null,\n };\n if (!wrapped && source.file === null && source.code === null) {\n context.error(DiagnosticCodes.UnknownRuleImplementationDirective, `Unexpected '${body.content}' in rule implementation - expected 'file <path>' or an inline code block`, locationOf(body));\n context.skipBlock(body.indent);\n }\n for (let extra = context.peekChild(rule.indent); extra !== undefined && (wrapped || (commandOwner && firstWord(extra.content) === 'implementation')); extra = context.peekChild(rule.indent)) {\n context.reader.takeSignificant();\n context.error(wrapped && firstWord(extra.content) === 'implementation' ? DiagnosticCodes.InvalidImplementationBlock : DiagnosticCodes.ConflictingImplementationSources,\n 'A named rule has one implementation wrapper and cannot mix wrapped and direct sources.', locationOf(extra));\n if (isCode(context, extra)) parseCode(context, extra);\n else context.skipBlock(extra.indent);\n }\n return source;\n}\n\nfunction splitMessage(content: string): { content: string; message: string | null } {\n const match = messagePattern.exec(content);\n if (match === null) {\n return { content, message: null };\n }\n const message = match[1] !== undefined ? unescapeString(match[1]) : match[2];\n return { content: content.substring(0, match.index).trimEnd(), message };\n}\n\nfunction splitSeverity(context: ParserContext, line: SourceLine, text: string): { content: string; severity: ValidationSeverity } | undefined {\n const match = severityPattern.exec(text);\n if (match === null) {\n return { content: text, severity: 'Error' };\n }\n const severity = severities[match[1]];\n if (severity === undefined) {\n context.error(DiagnosticCodes.InvalidValidationSeverity, `Unknown validation severity '${match[1]}' - expected information, warning or error`, locationOf(line));\n return undefined;\n }\n return { content: text.substring(0, match.index).trimEnd(), severity };\n}\n\nconst clockComparisons = new Set(['>', '>=', '<', '<=', '==', '!=']);\n\n// The right operand of a comparison rule: a clock offset or 'date of' one (decisions 0106 and 0107), otherwise an ordinary value.\n// Bare 'today' and 'now' stay paths, so a command property of that name still wins in the binder.\nfunction parseClockComparisonValue(context: ParserContext, text: string, line: SourceLine): ExpressionSyntax | null | undefined {\n const tokens = text.split(/\\s+/).filter(token => token.length > 0);\n const clock = parseClockOperand(context, tokens, 0, locationOf(line));\n if (clock === null) return parseMappingSource(text, locationOf(line), context);\n if (clock.expression === null) return undefined;\n if (clock.position === tokens.length) return clock.expression;\n context.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${line.content}'`, locationOf(line));\n return undefined;\n}\n\n// Only a command property rule may compare with a clock operand (decision 0107, item 1); a concept rule keeps its ordinary value.\nfunction parseRule(context: ParserContext, rule: string, line: SourceLine, clockOperands: boolean): { kind: ValidationRuleKind; value: ExpressionSyntax | null } | undefined {\n if (rule === 'not empty') {\n return { kind: 'NotEmpty', value: null };\n }\n if (firstWord(rule) === 'checksum') {\n const algorithm = rule.substring('checksum'.length).trim();\n if (algorithm !== 'luhn' && algorithm !== 'mod11' && algorithm !== 'mod97') {\n context.error(DiagnosticCodes.InvalidGenerationArgument, 'Checksum validation requires luhn, mod11 or mod97.', locationOf(line));\n return undefined;\n }\n return { kind: 'Checksum', value: { kind: 'LiteralExpressionSyntax', value: algorithm, location: locationOf(line) } };\n }\n const operand = operandPattern.exec(rule);\n if (operand === null) {\n context.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${line.content}'`, locationOf(line));\n return undefined;\n }\n const operator = operand[1] ?? operand[2];\n if (operator === 'rule') {\n const name = operand[3].trim();\n if (!ruleNamePattern.test(name)) {\n context.error(DiagnosticCodes.InvalidRuleName, `Invalid rule name '${name}' in '${line.content}' - expected 'rule <Name>' with an identifier`, locationOf(line));\n return undefined;\n }\n return { kind: 'Rule', value: { kind: 'PathExpressionSyntax', path: name, location: locationOf(line) } };\n }\n return parseOperandRule(context, operand, line, clockOperands);\n}\n\nfunction parseOperandRule(context: ParserContext, operand: RegExpExecArray, line: SourceLine, clockOperands: boolean): { kind: ValidationRuleKind; value: ExpressionSyntax | null } | undefined {\n const operator = operand[1] ?? operand[2];\n const value = clockOperands && clockComparisons.has(operator)\n ? parseClockComparisonValue(context, operand[3], line)\n : parseMappingSource(operand[3], locationOf(line), context);\n return value === undefined ? undefined : { kind: operandKinds[operator], value };\n}\n"],"mappings":"A,w4DA0CA,MAAMA,EAASC,EAAQ,8BAA8B,EAC/CC,EAAcC,EAAoB,2CAA2C,EAC7EC,EAAiBH,EAAQ,0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,4BAA4BF,EAAK,QAAQ,GAAIG,EAAWH,CAAI,CAAC,MAItH,KADiB4G,EAAQ,IAAMA,EAAQ,MACtB,OAAQ,CACrB,IAAM3G,EAAO2G,EAAQ,EAAE,CAAC,KAAK,EAC7B,GAAI,CAACtH,EAAgB,KAAKW,CAAI,EAAG,CAC7BF,EAAQ,MAAMG,EAAgB,gBAAiB,sBAAsBD,EAAK,QAAQD,EAAK,QAAQ,+CAAgDG,EAAWH,CAAI,CAAC,EAC/J,MACJ,CACA,MAAO,CAAE,KAAM,OAAQ,MAAO,CAAE,KAAM,uBAAwB,KAAMC,EAAM,SAAUE,EAAWH,CAAI,CAAE,CAAE,CAC3G,CACA,OAAO,iBAAiBD,EAAS6G,EAAS5G,EAAM6G,CAAa,CAD7D,CAEJ,CAEA,SAAS,iBAAiB,EAAwB,EAA0B,EAAkB,EAAkG,CAC5L,IAAMC,EAAWF,EAAQ,IAAMA,EAAQ,GACjCG,EAAQF,GAAiBR,EAAiB,IAAIS,CAAQ,EACtD,0BAA0B/G,EAAS6G,EAAQ,GAAI5G,CAAI,EACnD0G,EAAmBE,EAAQ,GAAIzG,EAAWH,CAAI,EAAGD,CAAO,EAC9D,OAAOgH,IAAU,IAAA,GAAY,IAAA,GAAY,CAAE,KAAMvH,EAAasH,GAAW,OAAM,CACnF,C"}
@@ -1,2 +1,2 @@
1
- import"../_virtual/_virtual/_rolldown/runtime.js";import{validateIdentity as e}from"./Parsing/IdentityValidator.js";import{validateApplicationHandlers as t}from"./Parsing/CommandHandlerValidator.js";import{recordStructuralInteractions as n}from"./Parsing/StructuralInteractionSites.js";import{validateSpecificationCases as r}from"./Parsing/SpecificationCaseValidator.js";import{expandSpecificationExamples as i,validateSpecificationExampleTypes as a}from"./Parsing/SpecificationCommandExamples.js";import{productionDestinationDiagnostics as o}from"./Diagnostics/ProductionDestinationDiagnostics.js";import{validateConstraintProperties as s}from"./Parsing/ConstraintPropertyValidator.js";import{validateDependencyDeclarations as c}from"./Dependencies/DeclaredDependencyTargets.js";import{DeclaredDependencies as l}from"./Dependencies/DeclaredDependencies.js";import{documentPlacement as u}from"./Files/PlayPlacement.js";import{discoverImports as d}from"./Parsing/ImportDiscovery.js";import{interactionAncestry as f}from"./Parsing/InteractionAlternatives.js";import{validateResponses as p}from"./Parsing/ResponseValidator.js";import{validatePublicEventUsage as m}from"./Parsing/PublicEventUsageValidator.js";import{sourceContext as h}from"./Parsing/SourceOptionsParser.js";import{validateInlineEvents as g}from"./Parsing/InlineEventValidator.js";import{validateOperations as _}from"./Parsing/OperationValidator.js";import{CommandStreamCandidates as v}from"./Parsing/CommandStreamCandidates.js";import{validateEventSources as y}from"./Parsing/EventSourceValidator.js";import{validateProjectionTargets as b}from"./Parsing/ProjectionTargetValidator.js";import{validateIdentifierCompliance as x}from"./Parsing/IdentifierComplianceValidator.js";import{validateEventSubjects as S}from"./Parsing/EventSubjectValidator.js";import{validateReadModelKeys as C}from"./Parsing/ReadModelKeyValidator.js";import{validateReadModelMemberTypes as w}from"./Parsing/ReadModelMemberTypeValidator.js";import{validateReactionRefusals as T}from"./Parsing/ReactionRefusalValidator.js";import{validateSpecificationRedelivery as E}from"./Parsing/SpecificationRedeliveryValidator.js";import{validateGuardedActions as D}from"./Parsing/GuardedActionValidator.js";import{validatePersonaCallers as O}from"./Parsing/PersonaCallerValidator.js";import{validatePurposes as k}from"./Parsing/PurposeValidator.js";import{parseApplication as A}from"./Parsing/ScreenplayParser.js";import{splitLines as j}from"./Parsing/SourceLineSplitter.js";import"./Parsing/ProjectionParser.js";import"./Parsing/CaptureParser.js";import"./Parsing/SpecificationParser.js";import"./Parsing/SpecificationExampleParser.js";import{timelineOrderDiagnostics as M}from"./Files/TimelineOrder.js";function parseForAuthoring(d,N,P=u,F=!0,I,L){let R=j(d,!1,N),z=h(R,N,L);z.scope=P,z.interactionAncestors=f(R),z.streamCandidates=I??v.capture([R],P,L);let B=A(z,R,P);if(n(B,z),F){t(B,z),e(B,z),k(B,z),g(B,z),s(B,z),_(B,z),m(B,z),r(B,z),a(B,z,!0);let n=i(B);p(n,z),y(B,z),b(B,z),x(n,z),S(B,z),C(B,z),w(B,z),T(B,z),E(B,z),D(B,z),O(B,z),B=c(B,z),l.validate(B,z);for(let e of o(B))z.information(e.code,e.message,e.location);for(let e of M(B))z.information(e.code,e.message,e.location)}return{value:B,diagnostics:z.diagnostics,triggerData:z.triggerData,inputUses:z.inputUses,continuationValues:z.continuationValues,guardedInteractions:z.guardedInteractions,interactionBehaviors:z.interactionBehaviors,interactionUses:z.interactionUses,success:!z.diagnostics.some(e=>e.severity===`error`)}}function discoverImports(e,t,n){let r=j(e,!1,t);return d(h(r,t,n))}export{discoverImports,parseForAuthoring};
1
+ import"../_virtual/_virtual/_rolldown/runtime.js";import{validateIdentity as e}from"./Parsing/IdentityValidator.js";import{validateApplicationHandlers as t}from"./Parsing/CommandHandlerValidator.js";import{recordStructuralInteractions as n}from"./Parsing/StructuralInteractionSites.js";import{validateSpecificationCases as r}from"./Parsing/SpecificationCaseValidator.js";import{expandSpecificationExamples as i,validateSpecificationExampleTypes as a}from"./Parsing/SpecificationCommandExamples.js";import{productionDestinationDiagnostics as o}from"./Diagnostics/ProductionDestinationDiagnostics.js";import{validateConstraintProperties as s}from"./Parsing/ConstraintPropertyValidator.js";import{validateDependencyDeclarations as c}from"./Dependencies/DeclaredDependencyTargets.js";import{DeclaredDependencies as l}from"./Dependencies/DeclaredDependencies.js";import{documentPlacement as u}from"./Files/PlayPlacement.js";import{discoverImports as d}from"./Parsing/ImportDiscovery.js";import{interactionAncestry as f}from"./Parsing/InteractionAlternatives.js";import{validateResponses as p}from"./Parsing/ResponseValidator.js";import{validatePublicEventUsage as m}from"./Parsing/PublicEventUsageValidator.js";import{sourceContext as h}from"./Parsing/SourceOptionsParser.js";import{validateInlineEvents as g}from"./Parsing/InlineEventValidator.js";import{validateOperations as _}from"./Parsing/OperationValidator.js";import{CommandStreamCandidates as v}from"./Parsing/CommandStreamCandidates.js";import{validateEventSources as y}from"./Parsing/EventSourceValidator.js";import{validateProjectionTargets as b}from"./Parsing/ProjectionTargetValidator.js";import{validateIdentifierCompliance as x}from"./Parsing/IdentifierComplianceValidator.js";import{validateEventSubjects as S}from"./Parsing/EventSubjectValidator.js";import{validateReadModelKeys as C}from"./Parsing/ReadModelKeyValidator.js";import{validateReadModelMemberTypes as w}from"./Parsing/ReadModelMemberTypeValidator.js";import{validateReactionRefusals as T}from"./Parsing/ReactionRefusalValidator.js";import{validateSpecificationRedelivery as E}from"./Parsing/SpecificationRedeliveryValidator.js";import{validateGuardedActions as D}from"./Parsing/GuardedActionValidator.js";import{validatePersonaCallers as O}from"./Parsing/PersonaCallerValidator.js";import{validatePurposes as k}from"./Parsing/PurposeValidator.js";import{parseApplication as A}from"./Parsing/ScreenplayParser.js";import{splitLines as j}from"./Parsing/SourceLineSplitter.js";import"./Parsing/ProjectionParser.js";import"./Parsing/CaptureParser.js";import"./Parsing/SpecificationParser.js";import"./Parsing/SpecificationExampleParser.js";import{timelineOrderDiagnostics as M}from"./Files/TimelineOrder.js";function parse(e,t,n=u){let{value:r,diagnostics:i,success:a}=parseForAuthoring(e,t,n);return{value:r,diagnostics:i,success:a}}function parseForAuthoring(d,N,P=u,F=!0,I,L){let R=j(d,!1,N),z=h(R,N,L);z.scope=P,z.interactionAncestors=f(R),z.streamCandidates=I??v.capture([R],P,L);let B=A(z,R,P);if(n(B,z),F){t(B,z),e(B,z),k(B,z),g(B,z),s(B,z),_(B,z),m(B,z),r(B,z),a(B,z,!0);let n=i(B);p(n,z),y(B,z),b(B,z),x(n,z),S(B,z),C(B,z),w(B,z),T(B,z),E(B,z),D(B,z),O(B,z),B=c(B,z),l.validate(B,z);for(let e of o(B))z.information(e.code,e.message,e.location);for(let e of M(B))z.information(e.code,e.message,e.location)}return{value:B,diagnostics:z.diagnostics,triggerData:z.triggerData,inputUses:z.inputUses,continuationValues:z.continuationValues,guardedInteractions:z.guardedInteractions,interactionBehaviors:z.interactionBehaviors,interactionUses:z.interactionUses,success:!z.diagnostics.some(e=>e.severity===`error`)}}function discoverImports(e,t,n){let r=j(e,!1,t);return d(h(r,t,n))}export{discoverImports,parse,parseForAuthoring};
2
2
  //# sourceMappingURL=ScreenplayCompiler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ScreenplayCompiler.js","names":["discoverImportsIn","discoverImports$1","documentPlacement","lines","splitLines","source","path","context","sourceContext","languages","placement","interactionAncestry","streamCandidates","CommandStreamCandidates","value","parseApplication","recordStructuralInteractions","validateResponseContracts","validateApplicationHandlers","validateIdentity","validatePurposes","validateInlineEvents","validateConstraintProperties","validateOperations","validatePublicEventUsage","validateSpecificationCases","validateSpecificationExampleTypes","effective","expandSpecificationExamples","validateResponses","validateEventSources","validateProjectionTargets","validateIdentifierCompliance","validateEventSubjects","validateReadModelKeys","validateReadModelMemberTypes","validateReactionRefusals","validateSpecificationRedelivery","validateGuardedActions","validatePersonaCallers","validateDependencyDeclarations","DeclaredDependencies","diagnostic","productionDestinationDiagnostics","timelineOrderDiagnostics"],"sources":["../../../../../Compiler/ScreenplayCompiler.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 { validateIdentity } from './Parsing/IdentityValidator';\nimport { validateApplicationHandlers } from './Parsing/CommandHandlerValidator';\nimport { recordStructuralInteractions } from './Parsing/StructuralInteractionSites';\nimport { Diagnostic } from './Diagnostics/Diagnostic';\nimport { validateSpecificationCases } from './Parsing/SpecificationCaseValidator';\nimport { expandSpecificationExamples, validateSpecificationExampleTypes } from './Parsing/SpecificationCommandExamples';\nimport { productionDestinationDiagnostics } from './Diagnostics/ProductionDestinationDiagnostics';\nimport { validateConstraintProperties } from './Parsing/ConstraintPropertyValidator';\nimport { validateDependencyDeclarations } from './Dependencies/DeclaredDependencyTargets';\nimport { DeclaredDependencies } from './Dependencies/DeclaredDependencies';\nimport { documentPlacement, PlayPlacement } from './Files/PlayPlacement';\nimport { DiscoveredImport, discoverImports as discoverImportsIn } from './Parsing/ImportDiscovery';\nimport { ContinuationValueUse } from './Parsing/ContinuationValueUse';\nimport { InputUse } from './Parsing/InputUses';\nimport { GuardedInteractionBinding, interactionAncestry } from './Parsing/InteractionAlternatives';\nimport { validateResponses } from './Parsing/ResponseValidator';\nimport { validatePublicEventUsage } from './Parsing/PublicEventUsageValidator';\nimport { sourceContext } from './Parsing/SourceOptionsParser';\nimport { validateInlineEvents } from './Parsing/InlineEventValidator';\nimport { validateOperations } from './Parsing/OperationValidator';\nimport { CommandStreamCandidates } from './Parsing/CommandStreamCandidates';\nimport { validateEventSources } from './Parsing/EventSourceValidator';\nimport { validateProjectionTargets } from './Parsing/ProjectionTargetValidator';\nimport { validateIdentifierCompliance } from './Parsing/IdentifierComplianceValidator';\nimport { validateEventSubjects } from './Parsing/EventSubjectValidator';\nimport { validateReadModelKeys } from './Parsing/ReadModelKeyValidator';\nimport { validateReadModelMemberTypes } from './Parsing/ReadModelMemberTypeValidator';\nimport { validateReactionRefusals } from './Parsing/ReactionRefusalValidator';\nimport { validateSpecificationRedelivery } from './Parsing/SpecificationRedeliveryValidator';\nimport { validateGuardedActions } from './Parsing/GuardedActionValidator';\nimport { validatePersonaCallers } from './Parsing/PersonaCallerValidator';\nimport { validatePurposes } from './Parsing/PurposeValidator';\nimport { parseApplication } from './Parsing/ScreenplayParser';\nimport { splitLines } from './Parsing/SourceLineSplitter';\nimport { PropertySyntax } from './Syntax/Declarations';\nimport { ApplicationSyntax } from './Syntax/Structure';\nimport { ApplicationSyntaxVisitor } from './Syntax/Visitors';\nimport { ProjectionSyntax } from './Syntax/Projections';\nimport { CaptureSyntax } from './Syntax/Captures';\nimport { SpecificationExampleSyntax, SpecificationSyntax } from './Syntax/Specifications';\nimport { SyntaxNode } from './Syntax/SyntaxNode';\nimport { ParserContext } from './Parsing/ParserContext';\nimport { parseProjection } from './Parsing/ProjectionParser';\nimport { parseCapture } from './Parsing/CaptureParser';\nimport { parseSpecification } from './Parsing/SpecificationParser';\nimport { parseExample } from './Parsing/SpecificationExampleParser';\nimport { firstWord } from './Parsing/LineText';\nimport { SourceLine, locationOf } from './Parsing/SourceLine';\nimport { DiagnosticCodes } from './Diagnostics/DiagnosticCodes';\nimport { timelineOrderDiagnostics } from './Files/TimelineOrder';\n\n// What compiling produced: the syntax tree, and the diagnostics found on the way. A tree is always\n// produced, so a document with errors still shows everything that could be read.\nexport interface CompilationResult<T> {\n readonly value: T;\n readonly diagnostics: readonly Diagnostic[];\n readonly success: boolean;\n}\n\n// Parses one .play document - the TypeScript counterpart of the C# ScreenplayCompiler.Parse. The path, when\n// given, is carried on every source location so a folder of documents can be merged and still point back\n// at the file each node came from. A placement says the document's top level belongs to the module or\n// feature an import placed it in: that module and feature are in the tree, marked as placements, holding what\n// the document declares at its top level.\nexport function parse(source: string, path?: string, placement: PlayPlacement = documentPlacement): CompilationResult<ApplicationSyntax> {\n const { value, diagnostics, success } = parseForAuthoring(source, path, placement);\n return { value, diagnostics, success };\n}\n\n// Additive authoring view: do not widen TypeRefSyntax or the cross-compiler SyntaxJson projection.\nexport function parseForAuthoring(source: string, path?: string, placement: PlayPlacement = documentPlacement, validateResponseContracts = true, streamCandidates?: CommandStreamCandidates, languages?: ReadonlySet<string>): CompilationResult<ApplicationSyntax> & { readonly triggerData: readonly PropertySyntax[]; readonly inputUses: readonly InputUse[]; readonly continuationValues: readonly ContinuationValueUse[]; readonly guardedInteractions: readonly GuardedInteractionBinding[]; readonly interactionBehaviors: ParserContext['interactionBehaviors']; readonly interactionUses: ParserContext['interactionUses'] } {\n const lines = splitLines(source, false, path);\n const context = sourceContext(lines, path, languages);\n context.scope = placement;\n context.interactionAncestors = interactionAncestry(lines);\n context.streamCandidates = streamCandidates ?? CommandStreamCandidates.capture([lines], placement, languages);\n let value = parseApplication(context, lines, placement);\n recordStructuralInteractions(value, context);\n // Folder assembly validates declaration-dependent contracts once against the merged inventory.\n if (validateResponseContracts) {\n validateApplicationHandlers(value, context);\n validateIdentity(value, context);\n validatePurposes(value, context);\n validateInlineEvents(value, context);\n validateConstraintProperties(value, context);\n validateOperations(value, context);\n validatePublicEventUsage(value, context);\n validateSpecificationCases(value, context);\n validateSpecificationExampleTypes(value, context, true);\n const effective = expandSpecificationExamples(value);\n validateResponses(effective, context);\n validateEventSources(value, context);\n validateProjectionTargets(value, context);\n validateIdentifierCompliance(effective, context);\n validateEventSubjects(value, context);\n validateReadModelKeys(value, context);\n validateReadModelMemberTypes(value, context);\n validateReactionRefusals(value, context);\n validateSpecificationRedelivery(value, context);\n validateGuardedActions(value, context);\n validatePersonaCallers(value, context);\n value = validateDependencyDeclarations(value, context);\n DeclaredDependencies.validate(value, context);\n for (const diagnostic of productionDestinationDiagnostics(value)) context.information(diagnostic.code, diagnostic.message, diagnostic.location);\n for (const diagnostic of timelineOrderDiagnostics(value)) context.information(diagnostic.code, diagnostic.message, diagnostic.location);\n }\n return {\n value,\n diagnostics: context.diagnostics,\n triggerData: context.triggerData,\n inputUses: context.inputUses,\n continuationValues: context.continuationValues,\n guardedInteractions: context.guardedInteractions,\n interactionBehaviors: context.interactionBehaviors,\n interactionUses: context.interactionUses,\n success: !context.diagnostics.some(diagnostic => diagnostic.severity === 'error'),\n };\n}\n\n/** Checks public boundaries on programmatically authored or decoded assembled syntax. */\nexport function publicEventDiagnostics(application: ApplicationSyntax): readonly Diagnostic[] {\n const context = sourceContext([], application.location.path);\n validatePublicEventUsage(application, context);\n return context.diagnostics;\n}\n\n// Parses a document and hands its syntax tree to a visitor - the counterpart of the C#\n// ScreenplayCompiler.Compile<T>(source, visitor). The visitor runs even when there are errors, over\n// everything that could be read.\nexport function compile<T>(source: string, visitor: ApplicationSyntaxVisitor<T>, path?: string): CompilationResult<T> {\n const parsed = parse(source, path);\n return { value: visitor.visit(parsed.value), diagnostics: parsed.diagnostics, success: parsed.success };\n}\n\n// Finds the files a document imports and where in it each import is written - each import with the module\n// and feature names around it, outermost first. Diagnostics are not collected; parsing the document reports them.\nexport function discoverImports(source: string, path?: string, languages?: ReadonlySet<string>): DiscoveredImport[] {\n const lines = splitLines(source, false, path);\n return discoverImportsIn(sourceContext(lines, path, languages));\n}\n\n// Additive entry points preserve the caller's registry; none can select numeric mode externally.\nexport function parseWithLanguages(source: string, languages: ReadonlySet<string>, path?: string, placement: PlayPlacement = documentPlacement): CompilationResult<ApplicationSyntax> {\n const { value, diagnostics, success } = parseForAuthoring(source, path, placement, true, undefined, languages);\n return { value, diagnostics, success };\n}\n\nexport function parseProjectionSource(source: string, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly ProjectionSyntax[]> {\n return parseSourceFamily(source, 'projection', parseProjection, path, languages);\n}\n\nexport function parseCaptureSource(source: string, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly CaptureSyntax[]> {\n return parseSourceFamily(source, 'capture', parseCapture, path, languages);\n}\n\nexport function parseSpecificationSource(source: string, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly SpecificationSyntax[]> {\n return parseSourceFamily(source, 'specification', parseSpecification, path, languages);\n}\n\nfunction parseSourceFamily<T extends SyntaxNode>(source: string, keyword: string, read: (context: ParserContext, line: SourceLine) => T, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly T[]> {\n const context = sourceContext(splitLines(source, true, path), path, languages, true);\n const value: T[] = [];\n const examples: SpecificationExampleSyntax[] = [];\n for (let line = context.reader.peekSignificant(); line !== undefined; line = context.reader.peekSignificant()) {\n context.reader.takeSignificant();\n if (keyword === 'specification' && firstWord(line.content) === 'example') examples.push(parseExample(context, line));\n else if (line.content.startsWith(keyword)) value.push(read(context, line));\n else {\n context.error(DiagnosticCodes.UnknownTopLevelConstruct, `Expected '${keyword}', got '${line.content}'`, locationOf(line));\n context.skipOpaqueBlock(line.indent);\n }\n }\n if (context.sourceOptions.numericMode === 'exact' && value.length === 0 && context.diagnostics.length === 0) {\n const code = keyword === 'projection' ? DiagnosticCodes.ProjectionDocumentWithoutProjection : keyword === 'capture' ? DiagnosticCodes.CaptureDocumentWithoutCapture : DiagnosticCodes.SpecificationDocumentWithoutSpecification;\n context.error(code, `Document must contain at least one ${keyword}`, context.start);\n }\n const roots = keyword === 'specification' && examples.length > 0 ? value.map(node => ({ ...node, examples })) : value;\n if (keyword === 'specification') {\n const application = parseApplication(sourceContext([], path, languages), [], documentPlacement);\n validateSpecificationCases({ ...application, examples }, context, roots as unknown as SpecificationSyntax[]);\n }\n return { value: roots, diagnostics: context.diagnostics, success: !context.diagnostics.some(diagnostic => diagnostic.severity === 'error') };\n}\n"],"mappings":"A,yqFAyEA,SAAgB,kBAAkB,EAAgB,EAAe,EAA2BE,EAAmB,EAA4B,GAAM,EAA4C,EAA0a,CACnmB,IAAMC,EAAQC,EAAWC,EAAQ,GAAOC,CAAI,EACtCC,EAAUC,EAAcL,EAAOG,EAAMG,CAAS,EACpD,EAAQ,MAAQC,EAChB,EAAQ,qBAAuBC,EAAoBR,CAAK,EACxD,EAAQ,iBAAmBS,GAAoBC,EAAwB,QAAQ,CAACV,CAAK,EAAGO,EAAWD,CAAS,EAC5G,IAAIK,EAAQC,EAAiBR,EAASJ,EAAOO,CAAS,EAGtD,GAFAM,EAA6BF,EAAOP,CAAO,EAEvCU,EAA2B,CAC3BC,EAA4BJ,EAAOP,CAAO,EAC1CY,EAAiBL,EAAOP,CAAO,EAC/Ba,EAAiBN,EAAOP,CAAO,EAC/Bc,EAAqBP,EAAOP,CAAO,EACnCe,EAA6BR,EAAOP,CAAO,EAC3CgB,EAAmBT,EAAOP,CAAO,EACjCiB,EAAyBV,EAAOP,CAAO,EACvCkB,EAA2BX,EAAOP,CAAO,EACzCmB,EAAkCZ,EAAOP,EAAS,EAAI,EACtD,IAAMoB,EAAYC,EAA4Bd,CAAK,EACnDe,EAAkBF,EAAWpB,CAAO,EACpCuB,EAAqBhB,EAAOP,CAAO,EACnCwB,EAA0BjB,EAAOP,CAAO,EACxCyB,EAA6BL,EAAWpB,CAAO,EAC/C0B,EAAsBnB,EAAOP,CAAO,EACpC2B,EAAsBpB,EAAOP,CAAO,EACpC4B,EAA6BrB,EAAOP,CAAO,EAC3C6B,EAAyBtB,EAAOP,CAAO,EACvC8B,EAAgCvB,EAAOP,CAAO,EAC9C+B,EAAuBxB,EAAOP,CAAO,EACrCgC,EAAuBzB,EAAOP,CAAO,EACrC,EAAQiC,EAA+B1B,EAAOP,CAAO,EACrDkC,EAAqB,SAAS3B,EAAOP,CAAO,EAC5C,IAAK,IAAMmC,KAAcC,EAAiC7B,CAAK,EAAGP,EAAQ,YAAYmC,EAAW,KAAMA,EAAW,QAASA,EAAW,QAAQ,EAC9I,IAAK,IAAMA,KAAcE,EAAyB9B,CAAK,EAAGP,EAAQ,YAAYmC,EAAW,KAAMA,EAAW,QAASA,EAAW,QAAQ,CAC1I,CACA,MAAO,CACH,QACA,YAAanC,EAAQ,YACrB,YAAaA,EAAQ,YACrB,UAAWA,EAAQ,UACnB,mBAAoBA,EAAQ,mBAC5B,oBAAqBA,EAAQ,oBAC7B,qBAAsBA,EAAQ,qBAC9B,gBAAiBA,EAAQ,gBACzB,QAAS,CAACA,EAAQ,YAAY,KAAK,GAAcmC,EAAW,WAAa,OAAO,CACpF,CACJ,CAmBA,SAAgB,gBAAgB,EAAgB,EAAe,EAAqD,CAChH,IAAMvC,EAAQC,EAAWC,EAAQ,GAAOC,CAAI,EAC5C,OAAON,EAAkBQ,EAAcL,EAAOG,EAAMG,CAAS,CAAC,CAClE,C"}
1
+ {"version":3,"file":"ScreenplayCompiler.js","names":["discoverImportsIn","discoverImports$1","documentPlacement","source","path","placement","lines","splitLines","context","sourceContext","languages","interactionAncestry","streamCandidates","CommandStreamCandidates","value","parseApplication","recordStructuralInteractions","validateResponseContracts","validateApplicationHandlers","validateIdentity","validatePurposes","validateInlineEvents","validateConstraintProperties","validateOperations","validatePublicEventUsage","validateSpecificationCases","validateSpecificationExampleTypes","effective","expandSpecificationExamples","validateResponses","validateEventSources","validateProjectionTargets","validateIdentifierCompliance","validateEventSubjects","validateReadModelKeys","validateReadModelMemberTypes","validateReactionRefusals","validateSpecificationRedelivery","validateGuardedActions","validatePersonaCallers","validateDependencyDeclarations","DeclaredDependencies","diagnostic","productionDestinationDiagnostics","timelineOrderDiagnostics"],"sources":["../../../../../Compiler/ScreenplayCompiler.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 { validateIdentity } from './Parsing/IdentityValidator';\nimport { validateApplicationHandlers } from './Parsing/CommandHandlerValidator';\nimport { recordStructuralInteractions } from './Parsing/StructuralInteractionSites';\nimport { Diagnostic } from './Diagnostics/Diagnostic';\nimport { validateSpecificationCases } from './Parsing/SpecificationCaseValidator';\nimport { expandSpecificationExamples, validateSpecificationExampleTypes } from './Parsing/SpecificationCommandExamples';\nimport { productionDestinationDiagnostics } from './Diagnostics/ProductionDestinationDiagnostics';\nimport { validateConstraintProperties } from './Parsing/ConstraintPropertyValidator';\nimport { validateDependencyDeclarations } from './Dependencies/DeclaredDependencyTargets';\nimport { DeclaredDependencies } from './Dependencies/DeclaredDependencies';\nimport { documentPlacement, PlayPlacement } from './Files/PlayPlacement';\nimport { DiscoveredImport, discoverImports as discoverImportsIn } from './Parsing/ImportDiscovery';\nimport { ContinuationValueUse } from './Parsing/ContinuationValueUse';\nimport { InputUse } from './Parsing/InputUses';\nimport { GuardedInteractionBinding, interactionAncestry } from './Parsing/InteractionAlternatives';\nimport { validateResponses } from './Parsing/ResponseValidator';\nimport { validatePublicEventUsage } from './Parsing/PublicEventUsageValidator';\nimport { sourceContext } from './Parsing/SourceOptionsParser';\nimport { validateInlineEvents } from './Parsing/InlineEventValidator';\nimport { validateOperations } from './Parsing/OperationValidator';\nimport { CommandStreamCandidates } from './Parsing/CommandStreamCandidates';\nimport { validateEventSources } from './Parsing/EventSourceValidator';\nimport { validateProjectionTargets } from './Parsing/ProjectionTargetValidator';\nimport { validateIdentifierCompliance } from './Parsing/IdentifierComplianceValidator';\nimport { validateEventSubjects } from './Parsing/EventSubjectValidator';\nimport { validateReadModelKeys } from './Parsing/ReadModelKeyValidator';\nimport { validateReadModelMemberTypes } from './Parsing/ReadModelMemberTypeValidator';\nimport { validateReactionRefusals } from './Parsing/ReactionRefusalValidator';\nimport { validateSpecificationRedelivery } from './Parsing/SpecificationRedeliveryValidator';\nimport { validateGuardedActions } from './Parsing/GuardedActionValidator';\nimport { validatePersonaCallers } from './Parsing/PersonaCallerValidator';\nimport { validatePurposes } from './Parsing/PurposeValidator';\nimport { parseApplication } from './Parsing/ScreenplayParser';\nimport { splitLines } from './Parsing/SourceLineSplitter';\nimport { PropertySyntax } from './Syntax/Declarations';\nimport { ApplicationSyntax } from './Syntax/Structure';\nimport { ApplicationSyntaxVisitor } from './Syntax/Visitors';\nimport { ProjectionSyntax } from './Syntax/Projections';\nimport { CaptureSyntax } from './Syntax/Captures';\nimport { SpecificationExampleSyntax, SpecificationSyntax } from './Syntax/Specifications';\nimport { SyntaxNode } from './Syntax/SyntaxNode';\nimport { ParserContext } from './Parsing/ParserContext';\nimport { parseProjection } from './Parsing/ProjectionParser';\nimport { parseCapture } from './Parsing/CaptureParser';\nimport { parseSpecification } from './Parsing/SpecificationParser';\nimport { parseExample } from './Parsing/SpecificationExampleParser';\nimport { firstWord } from './Parsing/LineText';\nimport { SourceLine, locationOf } from './Parsing/SourceLine';\nimport { DiagnosticCodes } from './Diagnostics/DiagnosticCodes';\nimport { timelineOrderDiagnostics } from './Files/TimelineOrder';\n\n// What compiling produced: the syntax tree, and the diagnostics found on the way. A tree is always\n// produced, so a document with errors still shows everything that could be read.\nexport interface CompilationResult<T> {\n readonly value: T;\n readonly diagnostics: readonly Diagnostic[];\n readonly success: boolean;\n}\n\n// Parses one .play document - the TypeScript counterpart of the C# ScreenplayCompiler.Parse. The path, when\n// given, is carried on every source location so a folder of documents can be merged and still point back\n// at the file each node came from. A placement says the document's top level belongs to the module or\n// feature an import placed it in: that module and feature are in the tree, marked as placements, holding what\n// the document declares at its top level.\nexport function parse(source: string, path?: string, placement: PlayPlacement = documentPlacement): CompilationResult<ApplicationSyntax> {\n const { value, diagnostics, success } = parseForAuthoring(source, path, placement);\n return { value, diagnostics, success };\n}\n\n// Additive authoring view: do not widen TypeRefSyntax or the cross-compiler SyntaxJson projection.\nexport function parseForAuthoring(source: string, path?: string, placement: PlayPlacement = documentPlacement, validateResponseContracts = true, streamCandidates?: CommandStreamCandidates, languages?: ReadonlySet<string>): CompilationResult<ApplicationSyntax> & { readonly triggerData: readonly PropertySyntax[]; readonly inputUses: readonly InputUse[]; readonly continuationValues: readonly ContinuationValueUse[]; readonly guardedInteractions: readonly GuardedInteractionBinding[]; readonly interactionBehaviors: ParserContext['interactionBehaviors']; readonly interactionUses: ParserContext['interactionUses'] } {\n const lines = splitLines(source, false, path);\n const context = sourceContext(lines, path, languages);\n context.scope = placement;\n context.interactionAncestors = interactionAncestry(lines);\n context.streamCandidates = streamCandidates ?? CommandStreamCandidates.capture([lines], placement, languages);\n let value = parseApplication(context, lines, placement);\n recordStructuralInteractions(value, context);\n // Folder assembly validates declaration-dependent contracts once against the merged inventory.\n if (validateResponseContracts) {\n validateApplicationHandlers(value, context);\n validateIdentity(value, context);\n validatePurposes(value, context);\n validateInlineEvents(value, context);\n validateConstraintProperties(value, context);\n validateOperations(value, context);\n validatePublicEventUsage(value, context);\n validateSpecificationCases(value, context);\n validateSpecificationExampleTypes(value, context, true);\n const effective = expandSpecificationExamples(value);\n validateResponses(effective, context);\n validateEventSources(value, context);\n validateProjectionTargets(value, context);\n validateIdentifierCompliance(effective, context);\n validateEventSubjects(value, context);\n validateReadModelKeys(value, context);\n validateReadModelMemberTypes(value, context);\n validateReactionRefusals(value, context);\n validateSpecificationRedelivery(value, context);\n validateGuardedActions(value, context);\n validatePersonaCallers(value, context);\n value = validateDependencyDeclarations(value, context);\n DeclaredDependencies.validate(value, context);\n for (const diagnostic of productionDestinationDiagnostics(value)) context.information(diagnostic.code, diagnostic.message, diagnostic.location);\n for (const diagnostic of timelineOrderDiagnostics(value)) context.information(diagnostic.code, diagnostic.message, diagnostic.location);\n }\n return {\n value,\n diagnostics: context.diagnostics,\n triggerData: context.triggerData,\n inputUses: context.inputUses,\n continuationValues: context.continuationValues,\n guardedInteractions: context.guardedInteractions,\n interactionBehaviors: context.interactionBehaviors,\n interactionUses: context.interactionUses,\n success: !context.diagnostics.some(diagnostic => diagnostic.severity === 'error'),\n };\n}\n\n/** Checks public boundaries on programmatically authored or decoded assembled syntax. */\nexport function publicEventDiagnostics(application: ApplicationSyntax): readonly Diagnostic[] {\n const context = sourceContext([], application.location.path);\n validatePublicEventUsage(application, context);\n return context.diagnostics;\n}\n\n// Parses a document and hands its syntax tree to a visitor - the counterpart of the C#\n// ScreenplayCompiler.Compile<T>(source, visitor). The visitor runs even when there are errors, over\n// everything that could be read.\nexport function compile<T>(source: string, visitor: ApplicationSyntaxVisitor<T>, path?: string): CompilationResult<T> {\n const parsed = parse(source, path);\n return { value: visitor.visit(parsed.value), diagnostics: parsed.diagnostics, success: parsed.success };\n}\n\n// Finds the files a document imports and where in it each import is written - each import with the module\n// and feature names around it, outermost first. Diagnostics are not collected; parsing the document reports them.\nexport function discoverImports(source: string, path?: string, languages?: ReadonlySet<string>): DiscoveredImport[] {\n const lines = splitLines(source, false, path);\n return discoverImportsIn(sourceContext(lines, path, languages));\n}\n\n// Additive entry points preserve the caller's registry; none can select numeric mode externally.\nexport function parseWithLanguages(source: string, languages: ReadonlySet<string>, path?: string, placement: PlayPlacement = documentPlacement): CompilationResult<ApplicationSyntax> {\n const { value, diagnostics, success } = parseForAuthoring(source, path, placement, true, undefined, languages);\n return { value, diagnostics, success };\n}\n\nexport function parseProjectionSource(source: string, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly ProjectionSyntax[]> {\n return parseSourceFamily(source, 'projection', parseProjection, path, languages);\n}\n\nexport function parseCaptureSource(source: string, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly CaptureSyntax[]> {\n return parseSourceFamily(source, 'capture', parseCapture, path, languages);\n}\n\nexport function parseSpecificationSource(source: string, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly SpecificationSyntax[]> {\n return parseSourceFamily(source, 'specification', parseSpecification, path, languages);\n}\n\nfunction parseSourceFamily<T extends SyntaxNode>(source: string, keyword: string, read: (context: ParserContext, line: SourceLine) => T, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly T[]> {\n const context = sourceContext(splitLines(source, true, path), path, languages, true);\n const value: T[] = [];\n const examples: SpecificationExampleSyntax[] = [];\n for (let line = context.reader.peekSignificant(); line !== undefined; line = context.reader.peekSignificant()) {\n context.reader.takeSignificant();\n if (keyword === 'specification' && firstWord(line.content) === 'example') examples.push(parseExample(context, line));\n else if (line.content.startsWith(keyword)) value.push(read(context, line));\n else {\n context.error(DiagnosticCodes.UnknownTopLevelConstruct, `Expected '${keyword}', got '${line.content}'`, locationOf(line));\n context.skipOpaqueBlock(line.indent);\n }\n }\n if (context.sourceOptions.numericMode === 'exact' && value.length === 0 && context.diagnostics.length === 0) {\n const code = keyword === 'projection' ? DiagnosticCodes.ProjectionDocumentWithoutProjection : keyword === 'capture' ? DiagnosticCodes.CaptureDocumentWithoutCapture : DiagnosticCodes.SpecificationDocumentWithoutSpecification;\n context.error(code, `Document must contain at least one ${keyword}`, context.start);\n }\n const roots = keyword === 'specification' && examples.length > 0 ? value.map(node => ({ ...node, examples })) : value;\n if (keyword === 'specification') {\n const application = parseApplication(sourceContext([], path, languages), [], documentPlacement);\n validateSpecificationCases({ ...application, examples }, context, roots as unknown as SpecificationSyntax[]);\n }\n return { value: roots, diagnostics: context.diagnostics, success: !context.diagnostics.some(diagnostic => diagnostic.severity === 'error') };\n}\n"],"mappings":"A,yqFAmEA,SAAgB,MAAM,EAAgB,EAAe,EAA2BE,EAAyD,CACrI,GAAM,CAAE,QAAO,cAAa,WAAY,kBAAkBC,EAAQC,EAAMC,CAAS,EACjF,MAAO,CAAE,QAAO,cAAa,SAAQ,CACzC,CAGA,SAAgB,kBAAkB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,EAAyB9B,CAAK,EAAGN,EAAQ,YAAYkC,EAAW,KAAMA,EAAW,QAASA,EAAW,QAAQ,CAC1I,CACA,MAAO,CACH,QACA,YAAalC,EAAQ,YACrB,YAAaA,EAAQ,YACrB,UAAWA,EAAQ,UACnB,mBAAoBA,EAAQ,mBAC5B,oBAAqBA,EAAQ,oBAC7B,qBAAsBA,EAAQ,qBAC9B,gBAAiBA,EAAQ,gBACzB,QAAS,CAACA,EAAQ,YAAY,KAAK,GAAckC,EAAW,WAAa,OAAO,CACpF,CACJ,CAmBA,SAAgB,gBAAgB,EAAgB,EAAe,EAAqD,CAChH,IAAMpC,EAAQC,EAAWJ,EAAQ,GAAOC,CAAI,EAC5C,OAAOJ,EAAkBS,EAAcH,EAAOF,EAAMM,CAAS,CAAC,CAClE,C"}
@@ -1 +1 @@
1
- import{DiagnosticCodes as e}from"./Diagnostics/DiagnosticCodes.js";import"./Parsing/checkPortableMatchPattern.js";import{unescapeString as t}from"./Text/StringLiteral.js";import{pattern as n}from"./Text/patterns.js";import{sourceLocation as r}from"./Diagnostics/SourceLocation.js";import{eventDeclarations as i}from"./Syntax/EventDeclarations.js";import{operationDeclarations as a}from"./Syntax/Operations.js";import{AuthoringProductionResolver as o}from"./Syntax/AuthoringProductionResolver.js";import{dependencySourcesOf as s}from"./Syntax/DependencySources.js";import{ScreenplaySyntaxWalker as c}from"./Syntax/ScreenplaySyntaxWalker.js";import{isExactNumberToken as l,parseExactNumber as u}from"./Syntax/ExactNumber.js";import{diagnosticKeyword as d,diagnosticText as f}from"./Diagnostics/DiagnosticArgument.js";import{EventSourceCatalog as p}from"./Syntax/EventSourceCatalog.js";import{implicitDestination as m,requiresExplicitDestinations as h}from"./Syntax/ProductionDestinations.js";import{InvalidExactNumber as g,canonicalExactText as _,exactIsIntegral as v}from"./Syntax/ExactMathFacts.js";import{responseCommandResolver as y}from"./Parsing/ResponseCommandResolver.js";import{synthesizePersonaCaller as b}from"./Syntax/PersonaCallers.js";import"./Syntax/SpecificationCaseOrigin.js";import{applyQuickFixEdits as x,isQuickFixDiagnostic as S,legacyOptionalTypeLength as C,prepareQuickFixes as w}from"./Authoring/QuickFixes.js";import{DeclaredDependencyTargets as T}from"./Dependencies/DeclaredDependencyTargets.js";import{describePlacement as E,documentPlacement as D,isDocumentPlacement as O,isWithinOrSame as k,samePlacement as A}from"./Files/PlayPlacement.js";import"./Syntax/InvalidSyntaxJson.js";import"./Syntax/SourceOptions.js";import"./Completeness/ModelCompleteness.js";import{eventBodyReservedWords as j}from"./Text/ReservedWords.js";import{sliceTypes as M}from"./Syntax/Structure.js";import{consumedEvents as N,eventsSourceKind as P,fromSetting as F,isEventsSource as I}from"./Syntax/CaptureEventsSource.js";import{hasWildcard as L,matchesPlayPattern as R,normalizePlayPath as z,resolvePlayPattern as B,staticFolderOf as V}from"./Files/PlayGlob.js";import"./Dependencies/index.js";import{dependencyKinds as H}from"./Dependencies/DependencyKind.js";import{InvalidDependencyQuery as U}from"./Dependencies/InvalidDependencyQuery.js";import{SliceReferenceCollector as W,buildingReadModelReferences as G,referenceClassifications as K,sliceReferences as q}from"./Dependencies/SliceReferences.js";import{stronglyConnectedGroups as J}from"./Dependencies/StronglyConnectedGroups.js";import{DependencyGraph as Y}from"./Dependencies/DependencyGraph.js";import{streamIdFailureMessage as X,tryFormatInteger as Z,tryFormatText as Q,tryFormatUuidText as $}from"./Syntax/StreamIdFormatter.js";import"./Syntax/index.js";import{discoverImports as ee,parseForAuthoring as te}from"./ScreenplayCompiler.js";import"./ScreenActionSubjects.js";import{EventSourceReadConfidence as ne}from"./Syntax/EventSourceReadConfidence.js";import"./Parsing/SpecificationCommandExamples.js";import{inMemoryDocumentSource as re}from"./Files/PlayDocumentSource.js";import{isSourceStreamName as ie,isSourceStreamTypeName as ae,sourceStreamPattern as oe}from"./Text/SourceStreamNames.js";import"./Files/AuthoredOrder.js";import"./Files/OrderingRoot.js";import"./Syntax/SyntaxJson.js";import"./Files/TimelineOrder.js";import{mergeDocuments as se}from"./Files/PlayFolderMerge.js";import{assembleApplication as ce,compileApplication as le,parsePlacedDocuments as ue}from"./Files/PlayApplicationAssembly.js";import{resolveImports as de}from"./Files/PlayImports.js";export{o as AuthoringProductionResolver,T as DeclaredDependencyTargets,Y as DependencyGraph,e as DiagnosticCodes,p as EventSourceCatalog,ne as EventSourceReadConfidence,U as InvalidDependencyQuery,g as InvalidExactNumber,c as ScreenplaySyntaxWalker,W as SliceReferenceCollector,x as applyQuickFixEdits,ce as assembleApplication,G as buildingReadModelReferences,_ as canonicalExactText,le as compileApplication,N as consumedEvents,H as dependencyKinds,s as dependencySourcesOf,E as describePlacement,d as diagnosticKeyword,f as diagnosticText,ee as discoverImports,D as documentPlacement,j as eventBodyReservedWords,i as eventDeclarations,P as eventsSourceKind,v as exactIsIntegral,F as fromSetting,L as hasWildcard,m as implicitDestination,re as inMemoryDocumentSource,O as isDocumentPlacement,I as isEventsSource,l as isExactNumberToken,S as isQuickFixDiagnostic,ie as isSourceStreamName,ae as isSourceStreamTypeName,k as isWithinOrSame,C as legacyOptionalTypeLength,R as matchesPlayPattern,se as mergeDocuments,z as normalizePlayPath,a as operationDeclarations,u as parseExactNumber,te as parseForAuthoring,ue as parsePlacedDocuments,n as pattern,w as prepareQuickFixes,K as referenceClassifications,h as requiresExplicitDestinations,de as resolveImports,B as resolvePlayPattern,y as responseCommandResolver,A as samePlacement,q as sliceReferences,M as sliceTypes,r as sourceLocation,oe as sourceStreamPattern,V as staticFolderOf,X as streamIdFailureMessage,J as stronglyConnectedGroups,b as synthesizePersonaCaller,Z as tryFormatInteger,Q as tryFormatText,$ as tryFormatUuidText,t as unescapeString};
1
+ import{DiagnosticCodes as e}from"./Diagnostics/DiagnosticCodes.js";import"./Parsing/checkPortableMatchPattern.js";import{unescapeString as t}from"./Text/StringLiteral.js";import{pattern as n}from"./Text/patterns.js";import{sourceLocation as r}from"./Diagnostics/SourceLocation.js";import{eventDeclarations as i}from"./Syntax/EventDeclarations.js";import{operationDeclarations as a}from"./Syntax/Operations.js";import{AuthoringProductionResolver as o}from"./Syntax/AuthoringProductionResolver.js";import{dependencySourcesOf as s}from"./Syntax/DependencySources.js";import{ScreenplaySyntaxWalker as c}from"./Syntax/ScreenplaySyntaxWalker.js";import{isExactNumberToken as l,parseExactNumber as u}from"./Syntax/ExactNumber.js";import{diagnosticKeyword as d,diagnosticText as f}from"./Diagnostics/DiagnosticArgument.js";import{EventSourceCatalog as p}from"./Syntax/EventSourceCatalog.js";import{implicitDestination as m,requiresExplicitDestinations as h}from"./Syntax/ProductionDestinations.js";import{InvalidExactNumber as g,canonicalExactText as _,exactIsIntegral as v}from"./Syntax/ExactMathFacts.js";import{responseCommandResolver as y}from"./Parsing/ResponseCommandResolver.js";import{synthesizePersonaCaller as b}from"./Syntax/PersonaCallers.js";import"./Syntax/SpecificationCaseOrigin.js";import{applyQuickFixEdits as x,isQuickFixDiagnostic as S,legacyOptionalTypeLength as C,prepareQuickFixes as w}from"./Authoring/QuickFixes.js";import{DeclaredDependencyTargets as T}from"./Dependencies/DeclaredDependencyTargets.js";import{describePlacement as E,documentPlacement as D,isDocumentPlacement as O,isWithinOrSame as k,samePlacement as A}from"./Files/PlayPlacement.js";import"./Syntax/InvalidSyntaxJson.js";import"./Syntax/SourceOptions.js";import"./Completeness/ModelCompleteness.js";import{eventBodyReservedWords as j}from"./Text/ReservedWords.js";import{sliceTypes as M}from"./Syntax/Structure.js";import{consumedEvents as N,eventsSourceKind as P,fromSetting as F,isEventsSource as I}from"./Syntax/CaptureEventsSource.js";import{hasWildcard as L,matchesPlayPattern as R,normalizePlayPath as z,resolvePlayPattern as B,staticFolderOf as V}from"./Files/PlayGlob.js";import"./Dependencies/index.js";import{dependencyKinds as H}from"./Dependencies/DependencyKind.js";import{InvalidDependencyQuery as U}from"./Dependencies/InvalidDependencyQuery.js";import{SliceReferenceCollector as W,buildingReadModelReferences as G,referenceClassifications as K,sliceReferences as q}from"./Dependencies/SliceReferences.js";import{stronglyConnectedGroups as J}from"./Dependencies/StronglyConnectedGroups.js";import{DependencyGraph as Y}from"./Dependencies/DependencyGraph.js";import{streamIdFailureMessage as X,tryFormatInteger as Z,tryFormatText as Q,tryFormatUuidText as $}from"./Syntax/StreamIdFormatter.js";import"./Syntax/index.js";import{discoverImports as ee,parse as te,parseForAuthoring as ne}from"./ScreenplayCompiler.js";import"./ScreenActionSubjects.js";import{EventSourceReadConfidence as re}from"./Syntax/EventSourceReadConfidence.js";import"./Parsing/SpecificationCommandExamples.js";import{inMemoryDocumentSource as ie}from"./Files/PlayDocumentSource.js";import{isSourceStreamName as ae,isSourceStreamTypeName as oe,sourceStreamPattern as se}from"./Text/SourceStreamNames.js";import"./Files/AuthoredOrder.js";import"./Files/OrderingRoot.js";import"./Syntax/SyntaxJson.js";import"./Files/TimelineOrder.js";import{mergeDocuments as ce}from"./Files/PlayFolderMerge.js";import{assembleApplication as le,compileApplication as ue,parsePlacedDocuments as de}from"./Files/PlayApplicationAssembly.js";import{resolveImports as fe}from"./Files/PlayImports.js";export{o as AuthoringProductionResolver,T as DeclaredDependencyTargets,Y as DependencyGraph,e as DiagnosticCodes,p as EventSourceCatalog,re as EventSourceReadConfidence,U as InvalidDependencyQuery,g as InvalidExactNumber,c as ScreenplaySyntaxWalker,W as SliceReferenceCollector,x as applyQuickFixEdits,le as assembleApplication,G as buildingReadModelReferences,_ as canonicalExactText,ue as compileApplication,N as consumedEvents,H as dependencyKinds,s as dependencySourcesOf,E as describePlacement,d as diagnosticKeyword,f as diagnosticText,ee as discoverImports,D as documentPlacement,j as eventBodyReservedWords,i as eventDeclarations,P as eventsSourceKind,v as exactIsIntegral,F as fromSetting,L as hasWildcard,m as implicitDestination,ie as inMemoryDocumentSource,O as isDocumentPlacement,I as isEventsSource,l as isExactNumberToken,S as isQuickFixDiagnostic,ae as isSourceStreamName,oe as isSourceStreamTypeName,k as isWithinOrSame,C as legacyOptionalTypeLength,R as matchesPlayPattern,ce as mergeDocuments,z as normalizePlayPath,a as operationDeclarations,te as parse,u as parseExactNumber,ne as parseForAuthoring,de as parsePlacedDocuments,n as pattern,w as prepareQuickFixes,K as referenceClassifications,h as requiresExplicitDestinations,fe as resolveImports,B as resolvePlayPattern,y as responseCommandResolver,A as samePlacement,q as sliceReferences,M as sliceTypes,r as sourceLocation,se as sourceStreamPattern,V as staticFolderOf,X as streamIdFailureMessage,J as stronglyConnectedGroups,b as synthesizePersonaCaller,Z as tryFormatInteger,Q as tryFormatText,$ as tryFormatUuidText,t as unescapeString};