@cratis/screenplay-language 5.4.0 → 5.5.1

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 A}from"../Syntax/DependencySources.js";import{captureConcurrency as j}from"./DependencySourceParser.js";import{parseReads as M}from"./ReadsParser.js";import{parseProduces as N}from"./ProducesParser.js";import{reportInvalidModifierOrder as P,reportLegacyOptionalSuffix as F,tryParseProperty as I}from"./PropertyLineParser.js";import{locationOf as L}from"./SourceLine.js";import{isFileDirectiveAmongProperties as R}from"./FileReferences.js";const z=o(`^command\\s+([A-Za-z_]\\w*)$`),B=s(`^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$`),V=o(`^calendar\\s+(?:"|from\\s+\\$context\\.)`),H=o(`^calendar\\s+(?:"(${c})"|from\\s+\\$context\\.([A-Za-z_][A-Za-z0-9_]*(?:\\.[A-Za-z_][A-Za-z0-9_]*)*))$`),U=o(`\\bseverity\\s+(\\S+)$`),W=o(`\\bmessage\\s+(?:"(${c})"|(\\$strings\\.\\S*))$`),G=o(`^([\\w.]+)\\s+(.+)$`),K=o(`^(?:(not empty|matches|not contains|contains|starts with|ends with|max|min|rule)(?:\\s+|$)|(length ==|decimals <=|all >=|all >|>=|<=|==|!=|>|<)\\s*)(.*)$`),q=s(`^[A-Za-z_]\\w*$`),J=o(`^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)`),Y={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`},X={information:`Information`,warning:`Warning`,error:`Error`},Z=/* @__PURE__ */ new Set([`reads`,`concurrency`]),Q=/* @__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(t,n,r,i){let a=z.exec(n.content)?.[1]??``;a===``&&t.error(e.InvalidCommandDeclaration,`Invalid command declaration '${n.content}' - expected 'command <Name>'`,L(n));let o=createCommandBodyState(a,r);for(let e=t.peekChild(n.indent);e!==void 0;e=t.peekChild(n.indent))t.reader.takeSignificant(),dispatchCommandDirective(t,e,o);return buildCommand(t,n,o,i)}function createCommandBodyState(e,t){return{name:e,responseNames:t,properties:[],responses:[],identifier:void 0,validations:[],produces:[],reads:[],referenceReads:[],concurrency:void 0,description:null,documentation:null,authorize:null,authorizationDepthExceeded:!1,handler:null,handlers:[],stream:null,streamCandidates:[],calendar:null}}const isDirective=e=>t=>t===e,$=[{matches:(e,t)=>e===`calendar`&&V.test(t.content),parse:parseCalendarDirective},{matches:(e,t,n)=>n!==void 0&&(Q.has(e)||e===`validate`&&t.content!==`validate csharp`),parse:addPropertyDirective},{matches:isDirective(`returns`),parse:parseReturnsDirective},{matches:(e,t,n,r)=>e===`stream`&&B.test(t.content)&&n!==void 0&&r.streamCandidates?.hasSource(n.type.name.split(`.`)[0])===!0,parse:parseStreamDirective},{matches:(e,t)=>e===`runs`&&D(t),parse:(e,t)=>{O(e,t)}},{matches:isDirective(`description`),parse:(e,t,n)=>{n.description=m(e,t,n.description,`Command '${n.name}'`)}},{matches:isDirective(`documentation`),parse:(e,t,n)=>{n.documentation=h(e,t,n.documentation,`Command '${n.name}'`)}},{matches:isDirective(`authorize`),parse:parseAuthorizeDirective},{matches:isDirective(`validate`),parse:parseValidateDirective},{matches:isDirective(`produces`),parse:parseProducesDirective},{matches:isDirective(`handler`),parse:(e,t,n)=>{n.handler=b(e,t),n.handlers.push({handler:n.handler,location:L(t)})}},{matches:e=>Z.has(e),parse:parseOpaqueDirective}];function dispatchCommandDirective(t,r,i){let a=C(r.content),o=I(r),s=$.find(e=>e.matches(a,r,o,t));s===void 0?o===void 0?(P(t,r),t.error(e.UnknownCommandDirective,`Unexpected '${r.content}' in command body${n(r.content)}`,L(r)),t.skipBlock(r.indent)):i.identifier=addProperty(t,i.properties,o,i.name,r,i.identifier):s.parse(t,r,i,o)}function addPropertyDirective(e,t,n,r){n.identifier=addProperty(e,n.properties,r,n.name,t,n.identifier)}function parseCalendarDirective(t,n,r){let i=H.exec(n.content);r.calendar!==null||i===null?t.error(e.InvalidCommandCalendar,`A command declares at most one 'calendar "<id>"' or 'calendar from $context.<member>'.`,L(n)):r.calendar={kind:`CommandCalendarSyntax`,id:i[1]===void 0?null:l(i[1]),contextMember:i[2]??null,location:L(n)}}function parseReturnsDirective(e,t,n,r){let i=p.exec(t.content);i!==null&&!i[1].startsWith(`@`)&&r!==void 0?parseScalarReturns(e,t,n,r):r===void 0?P(e,t)?e.skipBlock(t.indent):n.responses.push({line:t,candidate:null,response:f(e,t)}):n.identifier=addProperty(e,n.properties,r,n.name,t,n.identifier)}function parseScalarReturns(e,t,n,r){n.responseNames===void 0?(n.properties.push(r),n.responses.push({line:t,candidate:r,response:null})):n.responseNames.has(r.type.name)?n.responses.push({line:t,candidate:null,response:f(e,t)}):n.identifier=addProperty(e,n.properties,r,n.name,t,n.identifier)}function parseStreamDirective(t,n,r,i){let[o,s]=i.type.name.split(`.`),c=t.streamCandidates.hasPropertyType(i.type.name)&&t.streamCandidates.hasUniqueStream(o,s),l=a(t,n,i,c);(r.stream!==null||r.streamCandidates.length>0)&&t.error(e.InvalidCommandStream,`A command declares at most one stream route.`,L(n)),c||r.stream!==null?r.streamCandidates.push(l):r.stream=l}function parseAuthorizeDirective(e,t,n){let r=d(e,t);if(n.authorizationDepthExceeded)return;let i=n.authorize;n.authorize=u(n.authorize,r,e),n.authorizationDepthExceeded=i!==null&&n.authorize===null}function parseValidateDirective(e,t,n){let r=parseValidate(e,t,`command`,n.name);r!==void 0&&n.validations.push(r)}function parseProducesDirective(e,t,n){let r=N(e,t,!0);r!==void 0&&n.produces.push(r)}function parseOpaqueDirective(t,n,r){let i=C(n.content),a=i===`reads`?M(t,n):void 0;a!==void 0&&r.referenceReads.push(a),i===`concurrency`&&r.concurrency===void 0&&(r.concurrency=j(t,n));let o=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(n.content);o!==null&&r.reads.push({readModel:o[1],alias:o[2]??null}),J.test(n.content)&&t.error(e.OptionalReadsNotSupported,`Optional reads are not yet supported (see #308).`,L(n)),t.skipOpaqueBlock(n.indent)}function resolveResponse(t,n,r){let{properties:i,responses:a}=n,o=new Set(a.flatMap(e=>e.candidate===null?[]:[e.candidate])),s=new Set(i.filter(e=>!o.has(e)).map(e=>e.name));a.some(e=>e.candidate!==null&&!s.has(e.candidate.type.name)&&e.candidate.type.name!==`returns`)&&s.add(`returns`);for(let e of s)r?.add(e);let c=null,l=/* @__PURE__ */ new Set;for(let n of a){let r=n.response;if(n.candidate!==null){if(!s.has(n.candidate.type.name))continue;l.add(n.candidate),r={kind:`ScalarCommandResponseSyntax`,source:{kind:`PropertyResponseSourceSyntax`,property:n.candidate.type.name,location:n.candidate.type.location},location:L(n.line)}}r!==null&&(c===null?c=r:t.error(e.InvalidCommandResponse,`A command declares at most one unconditional response.`,L(n.line)))}return{response:c,removed:l}}function buildCommand(e,n,r,i){let{name:a,properties:o,validations:s,produces:c,reads:l,referenceReads:u,concurrency:d,description:f,documentation:p,authorize:m,handler:h,handlers:g,stream:_,streamCandidates:v,calendar:y}=r,{response:b,removed:x}=resolveResponse(e,r,i);t(g,h,c.length>0,e);let S={kind:`CommandSyntax`,name:a,description:f,documentation:p,authorize:m,properties:o.filter(e=>!x.has(e)),validations:s,produces:c,handler:h,response:b,stream:_,streamCandidates:v,...y===null?{}:{calendar:y},location:L(n)};return k.set(S,l),A.set(S,{reads:u,concurrency:d}),S}function addProperty(t,n,r,i,a,o){return F(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:L(t)}}function hasValidationOperand(e){let t=G.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`||K.test(e)}function isDeclarativePredicate(e){return startsWithRuleOperand(e)&&C(e)!==`rule`}function isValidationFileBody(e,t,n){if(!R(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:L(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}'`,L(o)),u??=o.indent;continue}}if(C(o.content)===`require`){let e=r(i===`concept`?t.valueContext:t,o.content.substring(7).trim(),L(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=W.exec(e.content);r!==null&&r.index===0?n=r[1]===void 0?r[2]:l(r[1]):C(e.content)===`severity`?(s||(a=X[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:L(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:L(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:L(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:L(n)}}t.error(e.InvalidValidateDeclaration,`Invalid validate declaration '${n.content}' - expected 'validate' or 'validate csharp'`,L(n)),t.skipBlock(n.indent)}function parseValidationRule(t,n,r,i){let a=C(G.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=G.exec(l.content);if(u===null){o.error(e.InvalidValidationRule,`Invalid validation rule '${n.content}'`,L(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,L(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:L(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`,L(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.`,L(i)),g(t,i)?v(t,i):t.skipBlock(i.indent);return o}function splitMessage(e){let t=W.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=U.exec(r);if(i===null)return{content:r,severity:`Error`};let a=X[i[1]];if(a===void 0)t.error(e.InvalidValidationSeverity,`Unknown validation severity '${i[1]}' - expected information, warning or error`,L(n));else return{content:r.substring(0,i.index).trimEnd(),severity:a}}const ee=/* @__PURE__ */ new Set([`>`,`>=`,`<`,`<=`,`==`,`!=`]);function parseClockComparisonValue(t,n,r){let a=n.split(/\s+/).filter(e=>e.length>0),o=i(t,a,0,L(r));if(o===null)return S(n,L(r),t);if(o.expression!==null){if(o.position===a.length)return o.expression;t.error(e.InvalidValidationRule,`Invalid validation rule '${r.content}'`,L(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.`,L(r));return}return{kind:`Checksum`,value:{kind:`LiteralExpressionSyntax`,value:i,location:L(r)}}}let a=K.exec(n);if(a===null)t.error(e.InvalidValidationRule,`Invalid validation rule '${r.content}'`,L(r));else{if((a[1]??a[2])===`rule`){let n=a[3].trim();if(!q.test(n)){t.error(e.InvalidRuleName,`Invalid rule name '${n}' in '${r.content}' - expected 'rule <Name>' with an identifier`,L(r));return}return{kind:`Rule`,value:{kind:`PathExpressionSyntax`,path:n,location:L(r)}}}return parseOperandRule(t,a,r,i)}}function parseOperandRule(e,t,n,r){let i=t[1]??t[2],a=r&&ee.has(i)?parseClockComparisonValue(e,t[3],n):S(t[3],L(n),e);return a===void 0?void 0:{kind:Y[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,KAAMA,EAAQ,SAAS,EAI1F,MAHA,GAAU,cAAgBA,EAAQ,cACl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G,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","state","responseNames","child","discoveredNames","keyword","commandDirectiveRules","property","isReactionIdentityLine","misplacedReactionIdentity","parseDescription","parseDocumentation","parseHandler","firstWord","asProperty","tryParseProperty","rule","candidate","reportInvalidModifierOrder","misplacedRuleHintForCommand","match","unescapeString","scalar","scalarResponsePattern","parseCommandResponse","source","streamName","ambiguous","route","parseCommandStream","next","parseAuthorize","previous","combineAuthorize","validate","production","parseProduces","reference","parseReads","captureConcurrency","read","candidates","responses","entry","properties","response","removed","parsed","validateHandlerContracts","handlers","handler","produces","syntax","calendar","commandReadSources","reads","dependencySources","referenceReads","reportLegacyOptionalSuffix","identifier","commandName","file","parseFile","body","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 state = createCommandBodyState(name, responseNames);\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n dispatchCommandDirective(context, child, state);\n }\n return buildCommand(context, line, state, discoveredNames);\n}\n\n// What the command body loop gathers while it reads the directives of one command.\ninterface CommandBodyState {\n readonly name: string;\n readonly responseNames: ReadonlySet<string> | undefined;\n readonly properties: PropertySyntax[];\n readonly responses: { line: SourceLine; candidate: PropertySyntax | null; response: CommandResponseSyntax | null }[];\n identifier: PropertySyntax | undefined;\n readonly validations: ValidateSyntax[];\n readonly produces: ProducesSyntax[];\n readonly reads: { readModel: string; alias: string | null }[];\n readonly referenceReads: ReadsSyntax[];\n concurrency: ConcurrencySyntax | undefined;\n description: string | null;\n documentation: string | null;\n authorize: AuthorizeSyntax | null;\n authorizationDepthExceeded: boolean;\n handler: HandlerSyntax | null;\n readonly handlers: { handler: HandlerSyntax | null; location: SourceLocation }[];\n stream: CommandStreamSyntax | null;\n readonly streamCandidates: CommandStreamSyntax[];\n calendar: CommandCalendarSyntax | null;\n}\n\n// A command body rule: whether it takes a line - by keyword and, where the keyword alone cannot decide, by the line - and what to do with it.\ninterface CommandDirectiveRule {\n readonly matches: (keyword: string, line: SourceLine, property: PropertySyntax | undefined, context: ParserContext) => boolean;\n readonly parse: (context: ParserContext, line: SourceLine, state: CommandBodyState, property: PropertySyntax | undefined) => void;\n}\n\nfunction createCommandBodyState(name: string, responseNames: ReadonlySet<string> | undefined): CommandBodyState {\n return {\n name, responseNames, properties: [], responses: [], identifier: undefined, validations: [], produces: [], reads: [], referenceReads: [],\n concurrency: undefined, description: null, documentation: null, authorize: null, authorizationDepthExceeded: false, handler: null,\n handlers: [], stream: null, streamCandidates: [], calendar: null\n };\n}\n\nconst isDirective = (name: string) => (keyword: string): boolean => keyword === name;\n\n// The command body rules in the order they are tried: the first one that takes the line handles it, so a keyword with a property shaped rule keeps it\n// ahead of its directive rule. A line no rule takes is a property, or an unexpected directive.\nconst commandDirectiveRules: readonly CommandDirectiveRule[] = [\n { matches: (keyword, line) => keyword === 'calendar' && calendarPrefix.test(line.content), parse: parseCalendarDirective },\n { matches: (keyword, line, property) => property !== undefined && (propertyShapedDirectives.has(keyword) || (keyword === 'validate' && line.content !== 'validate csharp')), parse: addPropertyDirective },\n { matches: isDirective('returns'), parse: parseReturnsDirective },\n { matches: (keyword, line, property, context) => keyword === 'stream' && routeHeader.test(line.content) && property !== undefined && context.streamCandidates?.hasSource(property.type.name.split('.')[0]) === true, parse: parseStreamDirective },\n { matches: (keyword, line) => keyword === 'runs' && isReactionIdentityLine(line), parse: (context, line) => { misplacedReactionIdentity(context, line); } },\n { matches: isDirective('description'), parse: (context, line, state) => { state.description = parseDescription(context, line, state.description, `Command '${state.name}'`); } },\n { matches: isDirective('documentation'), parse: (context, line, state) => { state.documentation = parseDocumentation(context, line, state.documentation, `Command '${state.name}'`); } },\n { matches: isDirective('authorize'), parse: parseAuthorizeDirective },\n { matches: isDirective('validate'), parse: parseValidateDirective },\n { matches: isDirective('produces'), parse: parseProducesDirective },\n { matches: isDirective('handler'), parse: (context, line, state) => { state.handler = parseHandler(context, line); state.handlers.push({ handler: state.handler, location: locationOf(line) }); } },\n { matches: keyword => opaqueDirectives.has(keyword), parse: parseOpaqueDirective }\n];\n\nfunction dispatchCommandDirective(context: ParserContext, child: SourceLine, state: CommandBodyState): void {\n const keyword = firstWord(child.content);\n const asProperty = tryParseProperty(child);\n const rule = commandDirectiveRules.find(candidate => candidate.matches(keyword, child, asProperty, context));\n if (rule !== undefined) {\n rule.parse(context, child, state, asProperty);\n } else if (asProperty !== undefined) {\n state.identifier = addProperty(context, state.properties, asProperty, state.name, child, state.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\nfunction addPropertyDirective(context: ParserContext, child: SourceLine, state: CommandBodyState, property: PropertySyntax | undefined): void {\n state.identifier = addProperty(context, state.properties, property!, state.name, child, state.identifier);\n}\n\nfunction parseCalendarDirective(context: ParserContext, child: SourceLine, state: CommandBodyState): void {\n const match = calendarPattern.exec(child.content);\n if (state.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 state.calendar = { kind: 'CommandCalendarSyntax', id: match[1] === undefined ? null : unescapeString(match[1]), contextMember: match[2] ?? null, location: locationOf(child) };\n }\n}\n\nfunction parseReturnsDirective(context: ParserContext, child: SourceLine, state: CommandBodyState, property: PropertySyntax | undefined): void {\n const scalar = scalarResponsePattern.exec(child.content);\n if (scalar !== null && !scalar[1].startsWith('@') && property !== undefined) {\n parseScalarReturns(context, child, state, property);\n } else if (property !== undefined) {\n state.identifier = addProperty(context, state.properties, property, state.name, child, state.identifier);\n } else if (reportInvalidModifierOrder(context, child)) {\n context.skipBlock(child.indent);\n } else {\n state.responses.push({ line: child, candidate: null, response: parseCommandResponse(context, child) });\n }\n}\n\nfunction parseScalarReturns(context: ParserContext, child: SourceLine, state: CommandBodyState, property: PropertySyntax): void {\n if (state.responseNames === undefined) {\n state.properties.push(property);\n state.responses.push({ line: child, candidate: property, response: null });\n } else if (state.responseNames.has(property.type.name)) {\n state.responses.push({ line: child, candidate: null, response: parseCommandResponse(context, child) });\n } else {\n state.identifier = addProperty(context, state.properties, property, state.name, child, state.identifier);\n }\n}\n\nfunction parseStreamDirective(context: ParserContext, child: SourceLine, state: CommandBodyState, property: PropertySyntax | undefined): void {\n const [source, streamName] = property!.type.name.split('.');\n const ambiguous = context.streamCandidates!.hasPropertyType(property!.type.name) && context.streamCandidates!.hasUniqueStream(source, streamName);\n const route = parseCommandStream(context, child, property!, ambiguous);\n if (state.stream !== null || state.streamCandidates.length > 0) context.error(DiagnosticCodes.InvalidCommandStream, 'A command declares at most one stream route.', locationOf(child));\n if (ambiguous || state.stream !== null) state.streamCandidates.push(route);\n else state.stream = route;\n}\n\nfunction parseAuthorizeDirective(context: ParserContext, child: SourceLine, state: CommandBodyState): void {\n const next = parseAuthorize(context, child);\n if (state.authorizationDepthExceeded) return;\n const previous = state.authorize;\n state.authorize = combineAuthorize(state.authorize, next, context);\n state.authorizationDepthExceeded = previous !== null && state.authorize === null;\n}\n\nfunction parseValidateDirective(context: ParserContext, child: SourceLine, state: CommandBodyState): void {\n const validate = parseValidate(context, child, 'command', state.name);\n if (validate !== undefined) state.validations.push(validate);\n}\n\nfunction parseProducesDirective(context: ParserContext, child: SourceLine, state: CommandBodyState): void {\n const production = parseProduces(context, child, true);\n if (production !== undefined) state.produces.push(production);\n}\n\nfunction parseOpaqueDirective(context: ParserContext, child: SourceLine, state: CommandBodyState): void {\n const keyword = firstWord(child.content);\n const reference = keyword === 'reads' ? parseReads(context, child) : undefined;\n if (reference !== undefined) state.referenceReads.push(reference);\n if (keyword === 'concurrency' && state.concurrency === undefined) state.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) state.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}\n\n// Settles which 'returns' lines are the response and which are properties named like one, and the one response a command may declare.\nfunction resolveResponse(context: ParserContext, state: CommandBodyState, discoveredNames: Set<string> | undefined): { response: CommandResponseSyntax | null; removed: Set<PropertySyntax> } {\n const { properties, responses } = state;\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 return { response, removed };\n}\n\nfunction buildCommand(context: ParserContext, line: SourceLine, state: CommandBodyState, discoveredNames: Set<string> | undefined): CommandSyntax {\n const { name, properties, validations, produces, reads, referenceReads, concurrency, description, documentation, authorize, handler, handlers, stream, streamCandidates, calendar } = state;\n const { response, removed } = resolveResponse(context, state, discoveredNames);\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,u4DA0CA,MAAMA,EAASC,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,QAA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sDC,EAAWH,CAAI,CAAC,EAC/H,MACJ,CACA,MAAO,CAAE,KAAM,WAAY,MAAO,CAAE,KAAM,0BAA2B,MAAOsG,EAAW,SAAUnG,EAAWH,CAAI,CAAE,CAAE,CACxH,CACA,IAAMuG,EAAUlH,EAAe,KAAK8B,CAAI,EACxC,GAAIoF,IAAY,KACZxG,EAAQ,MAAMG,EAAgB,sBAAuB,4BAA4BF,EAAK,QAAQ,GAAIG,EAAWH,CAAI,CAAC,MAItH,KADiBuG,EAAQ,IAAMA,EAAQ,MACtB,OAAQ,CACrB,IAAMtG,EAAOsG,EAAQ,EAAE,CAAC,KAAK,EAC7B,GAAI,CAACjH,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,EAASwG,EAASvG,EAAMwG,CAAa,CAD7D,CAEJ,CAEA,SAAS,iBAAiB,EAAwB,EAA0B,EAAkB,EAAkG,CAC5L,IAAMC,EAAWF,EAAQ,IAAMA,EAAQ,GACjCG,EAAQF,GAAiBR,GAAiB,IAAIS,CAAQ,EACtD,0BAA0B1G,EAASwG,EAAQ,GAAIvG,CAAI,EACnDqG,EAAmBE,EAAQ,GAAIpG,EAAWH,CAAI,EAAGD,CAAO,EAC9D,OAAO2G,IAAU,IAAA,GAAY,IAAA,GAAY,CAAE,KAAMlH,EAAaiH,GAAW,OAAM,CACnF,C"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{EnumerationMembers as e}from"./EnumerationMembers.js";import{misplacedRuleHintForConcept as t}from"./MisplacedRuleHint.js";import{parseGeneration as n}from"./GenerationParser.js";import{parseIdentity as r}from"./IdentityParser.js";import{parseApplicationContext as i}from"./ApplicationContextParser.js";import{misplacedReactionIdentity as a}from"./ReactionIdentityParser.js";import{DiagnosticCodes as o}from"../Diagnostics/DiagnosticCodes.js";import{recordAuthoredDocument as s}from"../Syntax/SourceOptions.js";import{describePlacement as c,documentPlacement as l,isDocumentPlacement as u}from"../Files/PlayPlacement.js";import{parseTriggerDeclaration as d}from"./TriggerDataParser.js";import{pattern as f}from"../Text/patterns.js";import{parseComplianceDirective as p,parseComplianceMarkers as m}from"./ConceptComplianceParser.js";import{parseType as h}from"./DeclarationParsers.js";import{parseValidate as g}from"./CommandParser.js";import{parseDescription as _}from"./DescriptionParser.js";import{FeatureBody as v,featureBodyExpected as y}from"./FeatureBody.js";import{isFileImport as b,parseFileImport as x}from"./FileImportParser.js";import{isFileDirective as S}from"./FileReferences.js";import{collectInputUses as ee}from"./InputUses.js";import{firstWord as C,unescapeIdentifier as w}from"./LineText.js";import{ModuleBody as te,moduleBodyExpected as T,modulePattern as E,parseModule as ne}from"./ModuleBody.js";import{parsePolicy as re}from"./PolicyParser.js";import{parsePurpose as ie}from"./PurposeParser.js";import{parseSeed as ae}from"./SeedParser.js";import{parseSystem as D}from"./OperationParser.js";import{parseStateMachine as oe}from"./StateMachineParser.js";import{parseWorkflow as se}from"./WorkflowParser.js";import{isBlankPublicEventOrigin as ce}from"../Syntax/PublicEventInvariants.js";import{stringBodyPattern as O,unescapeString as k}from"../Text/StringLiteral.js";import{parseCanvasPair as A}from"./CanvasPlacement.js";import{parseEventSource as le}from"./EventSourceParser.js";import{parseExposure as ue,parseInstance as de}from"./CompositionParser.js";import{parseExample as fe}from"./SpecificationExampleParser.js";import{parseUiProfile as pe}from"./UiProfileLegacyLayout.js";import{locationOf as j,startOf as M}from"./SourceLine.js";const N=f(`^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`),P=f(`^time\\s+zone\\s+(configurable\\s+default\\s+)?"(${O})"$`),F=f(`^import\\s+([\\w.]+)(?:\\s+from\\s+"(?<origin>${O})")?$`),I=f(`^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@?\\w+)*)$`),L=f(`^@?[a-z_]\\w*$`),R=f(`^persona\\s+([A-Za-z_]\\w*)$`),z=f(`^policy\\s+([A-Za-z_]\\w*)$`),B=f(`^goal\\s+"(${O})"$`),V=f(`^sticky\\s+note\\s+on\\s+(personas|eventsources|givencontexts|seeddata)$`),H=f(`^colour\\s+(yellow|pink|green|blue)$`),U=/^[ ]*\t/,W=[`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`],G=/* @__PURE__ */ new Set([`policy`,`authentication`,`onboarding`,`seed`,`ui`,`theme`,`trigger`,`layout`,`behavior`,`sample`]),K=/* @__PURE__ */ new Set([`slice`,`feature`,`description`,`documentation`,`authorize`,`screen`,`dialog`,`form`,`contribute`,`on`,`uses`]);function parseApplication(e,t,n=l){e.deferIdentityValidation=!0,warnOnTabIndentation(e,t);let c=n.length===1?new te(n[0]):void 0,f=n.length>1?new v(n[n.length-1]):void 0,p=c??f,m=null,g=null,_=null,y=!1,S=null,w=null,T=!1,E=!1,O=null,A=[],M=[],N=[],I=[],L=[],R=[],z=[],B=[],V=[],H=[],U=[],W=[],K=[],q=[],J=[],Y=[],X=[],Z=[],Q=!1;for(let t=e.reader.peekSignificant();t!==void 0;t=e.reader.peekSignificant()){e.reader.takeSignificant();let s=C(t.content);if(s===`command`&&/^command\s+reads(?:\s|$)/.test(t.content))E||!u(n)||!/^command\s+reads\s+protected$/.test(t.content)?e.error(o.InvalidCommandReadsDeclaration,`Declare 'command reads protected' once at the application root.`,j(t)):S=`Protected`,E=!0;else if(s===`time`&&/^time\s+zone(?:\s|$)/.test(t.content)){let r=P.exec(t.content);e.skipBlock(t.indent),T||!u(n)||r===null?e.error(o.InvalidTimeZoneDeclaration,`Declare 'time zone "<id>"' or 'time zone configurable default "<id>"' once at the application root.`,j(t)):w={kind:`TimeZoneSyntax`,id:k(r[2]),configurable:r[1]!==void 0,location:j(t)},T=!0}else if(s===`reaction`)y||!u(n)||!/^reaction\s+batches\s+atomic$/.test(t.content)?e.error(o.InvalidReactionBatchesDeclaration,`Declare 'reaction batches atomic' once at the application root.`,j(t)):_=`Atomic`,y=!0;else if(s===`runs`)a(e,t);else if(s===`domain`)e.authoredDeclarations=!0,O=parseDomain(e,t,O,Q);else if(Q||=declaresConstruct(s,t,n),e.authoredDeclarations||=s!==`import`&&declaresConstruct(s,t,n),s===`import`&&b(t.content))p===void 0?x(e,t,M):p.tryParse(e,t);else if(s===`import`){let n=F.exec(t.content);if(n===null)e.error(o.InvalidImportDeclaration,`Invalid import '${t.content}' - expected 'import <Qualified.Name> [from "<origin>"]'`,j(t));else{let r=n.groups?.origin===void 0?null:k(n.groups.origin);r!==null&&ce(r)&&e.error(o.InvalidImportDeclaration,`An import origin must be a nonblank quoted string`,j(t)),A.push({kind:`ImportSyntax`,qualifiedName:n[1],origin:r,visibility:r===null?`Private`:`Public`,location:j(t)})}}else if(s===`example`)p===void 0?J.push(fe(e,t)):p.tryParse(e,t);else if(s===`eventsource`)B.push(le(e,t));else if(s===`system`)L.push(D(e,t));else if(s===`statemachine`)R.push(oe(e,t));else if(s===`workflow`)z.push(se(e,t));else if(s===`concept`)N.push(parseConcept(e,t));else if(s===`type`)I.push(h(e,t));else if(s===`module`&&!u(n))parseModuleInPlacedFile(e,t,n,c);else if(s===`module`)V.push(ne(e,t));else if(s===`persona`)H.push(parsePersona(e,t));else if(s===`sticky`){let n=parseStickyNote(e,t);n!==null&&U.push(n)}else if(s===`seed`)q.push(ae(e.valueContext,t));else if(s===`purpose`&&p!==void 0)p.tryParse(e,t);else if(s===`purpose`)K.push(ie(e,t));else if(s===`context`)g=i(e,t,g,n);else if(s===`identity`)m=r(e,t,m);else if(s===`policy`){let n=re(e,t);W.some(e=>e.name===n.name)&&e.error(o.DuplicateDeclaration,`Duplicate declaration of policy '${n.name}' - policy names must be unique`,n.location),W.push(n)}else if(s===`exposure`)X.push(ue(e,t));else if(s===`instance`)Z.push(de(e,t));else if(s===`trigger`){let n=d(e,t),r=/^trigger\s+([A-Za-z_]\w*)$/.exec(t.content)?.[1];r!==void 0&&Y.push({name:r,data:n})}else G.has(s)?s===`behavior`||s===`layout`?ee(e,t):s===`ui`?pe(e,t):e.skipOpaqueBlock(t.indent):p?.tryParse(e,t)!==!0&&reportUnexpectedTopLevel(e,t,n)}c===void 0?f!==void 0&&V.unshift(place(n,f.build(e.start,!0),e.start)):V.unshift(c.build(e.start,!0));let $={kind:`ApplicationSyntax`,...S===null?{}:{commandReadMode:S},...w===null?{}:{timeZone:w},...g===null?{}:{context:g},..._===null?{}:{reactionProductionMode:_},...m===null?{}:{identity:m},sourceOptions:e.sourceOptions,domain:O,imports:A,concepts:N,types:I,systems:L,...R.length>0?{stateMachines:R}:{},...z.length>0?{workflows:z}:{},eventSources:B,examples:J,modules:V,personas:H,policies:W,purposes:K,seeds:q,declaredTriggers:Y,fileImports:M,...X.length>0?{exposures:X}:{},...U.length>0?{stickyNotes:U}:{},...Z.length>0?{instanceContributions:Z}:{},location:e.start};return e.authoredDeclarations&&s($),$}function declaresConstruct(e,t,n){return e===`import`?F.test(t.content):e===`module`?u(n):e===`identity`?t.content===`identity`:e===`context`?t.content===`context`:e===`purpose`||e===`example`||e===`exposure`||e===`instance`||e===`eventsource`||e===`system`||e===`statemachine`||e===`workflow`||e===`concept`||e===`type`||e===`persona`||e===`sticky`||G.has(e)}function parseModuleInPlacedFile(e,t,n,r){let i=E.exec(t.content)?.[1]??``;r!==void 0&&i===n[0]?(e.authoredDeclarations=!0,r.parseChildren(e,t)):(e.error(o.ModuleInPlacedFile,`This file is imported into ${c(n)}, so it cannot declare module '${i}' - import it at the top level of a document instead`,j(t)),e.skipBlock(t.indent))}function reportUnexpectedTopLevel(e,t,n){let r=C(t.content);if(u(n)){let n=K.has(r)?` - '${r}' belongs in a module or feature; wrap it in one, or import this file from inside one`:` - expected domain, import, concept, type, policy, persona, sticky note, authentication, onboarding, identity, context, module, seed, trigger, behavior, ui profile, theme, sample data or layout`;e.error(o.UnknownTopLevelConstruct,`Unexpected '${r}' at the top level${n}`,j(t))}else{let i=n.length===1?T:y;e.error(o.UnexpectedInPlacedFile,`Unexpected '${r}' in a file imported into ${c(n)} - expected an application declaration or ${i}`,j(t))}e.skipBlock(t.indent)}function place(e,t,n){let r=t;for(let t=e.length-2;t>=1;t--)r={kind:`FeatureSyntax`,name:e[t],description:null,authorize:null,features:[r],slices:[],fileImports:[],isPlacement:!0,location:n};return{kind:`ModuleSyntax`,name:e[0],description:null,authorize:null,features:[r],fileImports:[],isPlacement:!0,location:n}}function parseDomain(e,t,n,r){let i=N.exec(t.content);return i===null?(e.error(o.InvalidDomainDeclaration,`Invalid domain declaration '${t.content}' - expected 'domain <Qualified.Name>'`,j(t)),n):n===null?(r&&e.error(o.DomainNotFirst,`'domain' must be declared before any other construct`,j(t)),{kind:`DomainSyntax`,name:i[1],location:j(t)}):(e.error(o.DuplicateDomain,`The document already declares a domain - a document can have at most one`,j(t)),n)}function warnOnTabIndentation(e,t){let n=!1;for(let r of t)r.raw.trimStart().startsWith("```")?n=!n:!n&&U.test(r.raw)&&e.warning(o.TabIndentation,`Screenplay is indentation based - use spaces, not tabs`,M(r))}function parseConcept(r,i){let a=I.exec(i.content);if(a===null)return r.error(o.InvalidConceptDeclaration,`Invalid concept declaration '${i.content}' - expected 'concept <Name> : <Type>'`,j(i)),r.skipBlock(i.indent),{kind:`ConceptSyntax`,name:C(i.content),type:``,attributes:[],values:[],location:j(i)};let[,s,c,l]=a,u=m(r,i,s,l);c!==`Enum`&&!W.includes(c)&&r.error(o.UnknownPrimitiveType,`Unknown primitive type '${c}' - expected ${W.join(`, `)} or Enum`,j(i));let d=[],f=new e,h=null,v=!1,y=null,b=[];for(let e=r.peekChild(i.indent);e!==void 0;e=r.peekChild(i.indent)){r.reader.takeSignificant();let i=c===`Enum`?f.tryNumbered(r,e):void 0;if(i!==void 0)d.push(i);else if(C(e.content)===`description`&&(c!==`Enum`||e.content!==`description`||r.peekChild(e.indent)?.content.startsWith("```")===!0))y=_(r,e,y,`Concept '${s}'`);else if(S(e))continue;else if(C(e.content)===`validate`){c===`Enum`&&e.content===`validate`&&r.peekChild(e.indent)===void 0&&r.warning(o.ValidateReadAsEnumerationBlock,`'validate' in enumeration concept '${s}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,j(e));let t=g(r,e,`concept`,s);t!==void 0&&b.push(t)}else if(C(e.content)===`generate`&&(c!==`Enum`||e.content!==`generate`)){v&&r.error(o.DuplicateGeneration,`Concept '${s}' declares generation more than once.`,j(e));let t=n(r,e,c);v||(h=t),v=!0}else p(r,e,s,u)||(c===`Enum`&&L.test(e.content)?d.push(w(e.content)):c===`Enum`?r.error(o.InvalidEnumerationValue,`Invalid enum value '${e.content}' - expected an identifier`,j(e)):(r.error(o.UnknownConceptDirective,`Unexpected '${e.content}' in concept body - expected validate, generate, 'file <path>' or '<attribute> reason "<text>"'${t(e.content)}`,j(e)),r.skipBlock(e.indent)))}let x=f.finish(r,i,d.length);return{kind:`ConceptSyntax`,name:s,type:c,attributes:u,values:d,validations:b,description:y,...h===null?{}:{generation:h},...x===void 0?{}:{valueNumbers:x},location:j(i)}}function parsePersona(e,t){let n=R.exec(t.content)?.[1]??``;n===``&&e.error(o.InvalidPersonaDeclaration,`Invalid persona declaration '${t.content}' - expected 'persona <Name>'`,j(t));let r=null,i=[],a=[],s=null,c=null;for(let l=e.peekChild(t.indent);l!==void 0;l=e.peekChild(t.indent)){e.reader.takeSignificant();let t=C(l.content);if(t===`description`)r=_(e,l,r,`Persona '${n}'`);else if(t===`goal`){let t=B.exec(l.content);t===null?e.error(o.InvalidPersonaDeclaration,`Invalid goal '${l.content}' - expected 'goal "<text>"'`,j(l)):a.push(k(t[1]))}else if(t===`position`)s=A(e,l,`position`,`x`,`y`,s,!0)??s;else if(t===`size`)c=A(e,l,`size`,`width`,`height`,c,!1)??c;else if(t===`policy`){let t=z.exec(l.content);t===null?e.error(o.InvalidPersonaPolicyReference,`Invalid policy reference '${l.content}' - expected 'policy <Name>'`,j(l)):i.push(t[1])}else e.error(o.UnknownPersonaDirective,`Unexpected '${t}' in persona body - expected description, goal, policy, position or size`,j(l)),e.skipBlock(l.indent)}return{kind:`PersonaSyntax`,name:n,description:r,policies:i,...a.length>0?{goals:a}:{},...s===null?{}:{x:s[0],y:s[1]},...c===null?{}:{width:c[0],height:c[1]},location:j(t)}}function parseStickyNote(e,t){let n=V.exec(t.content);if(n===null)return e.error(o.InvalidPersonaDeclaration,`Invalid sticky note declaration '${t.content}' - expected 'sticky note on personas', 'sticky note on eventsources', 'sticky note on givencontexts' or 'sticky note on seeddata'`,j(t)),e.skipBlock(t.indent),null;let r=null,i=null,a=null,s=null;for(let n=e.peekChild(t.indent);n!==void 0;n=e.peekChild(t.indent)){e.reader.takeSignificant();let t=C(n.content);if(t===`description`)r=_(e,n,r,`A sticky note`);else if(t===`colour`){let t=H.exec(n.content);t===null?e.error(o.InvalidPersonaDeclaration,`Invalid colour '${n.content}' - expected 'colour yellow', 'colour pink', 'colour green' or 'colour blue'`,j(n)):i=t[1]}else t===`position`?a=A(e,n,`position`,`x`,`y`,a,!0)??a:t===`size`?s=A(e,n,`size`,`width`,`height`,s,!1)??s:(e.error(o.UnknownPersonaDirective,`Unexpected '${t}' in sticky note body - expected description, colour, position or size`,j(n)),e.skipBlock(n.indent))}return r===null||a===null?(e.error(o.InvalidPersonaDeclaration,`A sticky note needs a description (the text on it) and a position`,j(t)),null):{kind:`StickyNoteSyntax`,canvas:n[1],text:r,colour:i,x:a[0],y:a[1],width:s===null?null:s[0],height:s===null?null:s[1],location:j(t)}}export{parseApplication};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{EnumerationMembers as e}from"./EnumerationMembers.js";import{misplacedRuleHintForConcept as t}from"./MisplacedRuleHint.js";import{parseGeneration as n}from"./GenerationParser.js";import{parseIdentity as r}from"./IdentityParser.js";import{parseApplicationContext as i}from"./ApplicationContextParser.js";import{misplacedReactionIdentity as a}from"./ReactionIdentityParser.js";import{DiagnosticCodes as o}from"../Diagnostics/DiagnosticCodes.js";import{recordAuthoredDocument as s}from"../Syntax/SourceOptions.js";import{describePlacement as c,documentPlacement as l,isDocumentPlacement as u}from"../Files/PlayPlacement.js";import{parseTriggerDeclaration as d}from"./TriggerDataParser.js";import{pattern as f}from"../Text/patterns.js";import{parseComplianceDirective as p,parseComplianceMarkers as m}from"./ConceptComplianceParser.js";import{parseType as h}from"./DeclarationParsers.js";import{parseValidate as g}from"./CommandParser.js";import{parseDescription as _}from"./DescriptionParser.js";import{FeatureBody as v,featureBodyExpected as y}from"./FeatureBody.js";import{isFileImport as b,parseFileImport as x}from"./FileImportParser.js";import{isFileDirective as S}from"./FileReferences.js";import{collectInputUses as C}from"./InputUses.js";import{firstWord as w,unescapeIdentifier as T}from"./LineText.js";import{ModuleBody as E,moduleBodyExpected as D,modulePattern as O,parseModule as k}from"./ModuleBody.js";import{parsePolicy as A}from"./PolicyParser.js";import{parsePurpose as ee}from"./PurposeParser.js";import{parseSeed as te}from"./SeedParser.js";import{parseSystem as j}from"./OperationParser.js";import{parseStateMachine as M}from"./StateMachineParser.js";import{parseWorkflow as N}from"./WorkflowParser.js";import{isBlankPublicEventOrigin as ne}from"../Syntax/PublicEventInvariants.js";import{stringBodyPattern as P,unescapeString as F}from"../Text/StringLiteral.js";import{parseCanvasPair as I}from"./CanvasPlacement.js";import{parseEventSource as L}from"./EventSourceParser.js";import{parseExposure as R,parseInstance as z}from"./CompositionParser.js";import{parseExample as B}from"./SpecificationExampleParser.js";import{parseUiProfile as V}from"./UiProfileLegacyLayout.js";import{locationOf as H,startOf as U}from"./SourceLine.js";const W=f(`^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`),G=f(`^time\\s+zone\\s+(configurable\\s+default\\s+)?"(${P})"$`),K=f(`^import\\s+([\\w.]+)(?:\\s+from\\s+"(?<origin>${P})")?$`),q=f(`^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@?\\w+)*)$`),J=f(`^@?[a-z_]\\w*$`),Y=f(`^persona\\s+([A-Za-z_]\\w*)$`),X=f(`^policy\\s+([A-Za-z_]\\w*)$`),Z=f(`^goal\\s+"(${P})"$`),re=f(`^sticky\\s+note\\s+on\\s+(personas|eventsources|givencontexts|seeddata)$`),ie=f(`^colour\\s+(yellow|pink|green|blue)$`),ae=/^[ ]*\t/,Q=[`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`],$=/* @__PURE__ */ new Set([`policy`,`authentication`,`onboarding`,`seed`,`ui`,`theme`,`trigger`,`layout`,`behavior`,`sample`]),oe=/* @__PURE__ */ new Set([`slice`,`feature`,`description`,`documentation`,`authorize`,`screen`,`dialog`,`form`,`contribute`,`on`,`uses`]);function parseApplication(e,t,n=l){e.deferIdentityValidation=!0,warnOnTabIndentation(e,t);let r=createRootState(n);for(let t=e.reader.peekSignificant();t!==void 0;t=e.reader.peekSignificant())e.reader.takeSignificant(),dispatchRoot(e,t,r);return buildApplication(e,r)}function createRootState(e){let t=e.length===1?new E(e[0]):void 0,n=e.length>1?new v(e[e.length-1]):void 0;return{placement:e,moduleBody:t,featureBody:n,placedBody:t??n,identity:null,applicationContext:null,reactionProductionMode:null,sawReactionBatches:!1,commandReadMode:null,timeZone:null,sawTimeZone:!1,sawCommandReads:!1,domain:null,sawOtherConstruct:!1,imports:[],fileImports:[],concepts:[],types:[],systems:[],stateMachines:[],workflows:[],eventSources:[],modules:[],personas:[],stickyNotes:[],policies:[],purposes:[],seeds:[],examples:[],declaredTriggers:[],exposures:[],instanceContributions:[]}}const isKeyword=e=>t=>t===e,se=[{matches:(e,t)=>e===`command`&&/^command\s+reads(?:\s|$)/.test(t.content),parse:parseRootCommandReads},{matches:(e,t)=>e===`time`&&/^time\s+zone(?:\s|$)/.test(t.content),parse:parseRootTimeZone},{matches:isKeyword(`reaction`),parse:parseRootReactionBatches},{matches:isKeyword(`runs`),parse:(e,t)=>{a(e,t)}},{matches:isKeyword(`domain`),parse:parseRootDomain}],ce=[{matches:(e,t)=>e===`import`&&b(t.content),parse:parseRootFileImport},{matches:isKeyword(`import`),parse:parseRootImport},{matches:isKeyword(`example`),parse:parseRootExample},{matches:isKeyword(`eventsource`),parse:(e,t,n)=>{n.eventSources.push(L(e,t))}},{matches:isKeyword(`system`),parse:(e,t,n)=>{n.systems.push(j(e,t))}},{matches:isKeyword(`statemachine`),parse:(e,t,n)=>{n.stateMachines.push(M(e,t))}},{matches:isKeyword(`workflow`),parse:(e,t,n)=>{n.workflows.push(N(e,t))}},{matches:isKeyword(`concept`),parse:(e,t,n)=>{n.concepts.push(parseConcept(e,t))}},{matches:isKeyword(`type`),parse:(e,t,n)=>{n.types.push(h(e,t))}},{matches:(e,t,n)=>e===`module`&&!u(n.placement),parse:(e,t,n)=>parseModuleInPlacedFile(e,t,n.placement,n.moduleBody)},{matches:isKeyword(`module`),parse:(e,t,n)=>{n.modules.push(k(e,t))}},{matches:isKeyword(`persona`),parse:(e,t,n)=>{n.personas.push(parsePersona(e,t))}},{matches:isKeyword(`sticky`),parse:parseRootStickyNote},{matches:isKeyword(`seed`),parse:(e,t,n)=>{n.seeds.push(te(e.valueContext,t))}},{matches:(e,t,n)=>e===`purpose`&&n.placedBody!==void 0,parse:(e,t,n)=>{n.placedBody?.tryParse(e,t)}},{matches:isKeyword(`purpose`),parse:(e,t,n)=>{n.purposes.push(ee(e,t))}},{matches:isKeyword(`context`),parse:(e,t,n)=>{n.applicationContext=i(e,t,n.applicationContext,n.placement)}},{matches:isKeyword(`identity`),parse:(e,t,n)=>{n.identity=r(e,t,n.identity)}},{matches:isKeyword(`policy`),parse:parseRootPolicy},{matches:isKeyword(`exposure`),parse:(e,t,n)=>{n.exposures.push(R(e,t))}},{matches:isKeyword(`instance`),parse:(e,t,n)=>{n.instanceContributions.push(z(e,t))}},{matches:isKeyword(`trigger`),parse:parseRootTrigger},{matches:e=>$.has(e),parse:parseRootOpaque}];function dispatchRoot(e,t,n){let r=w(t.content),i=se.find(e=>e.matches(r,t,n));if(i!==void 0){i.parse(e,t,n);return}n.sawOtherConstruct||=declaresConstruct(r,t,n.placement),e.authoredDeclarations||=r!==`import`&&declaresConstruct(r,t,n.placement);let a=ce.find(e=>e.matches(r,t,n));a===void 0?n.placedBody?.tryParse(e,t)!==!0&&reportUnexpectedTopLevel(e,t,n.placement):a.parse(e,t,n)}function isRepeatedOrMisplaced(e,t){return e||!u(t.placement)}function parseRootCommandReads(e,t,n){isRepeatedOrMisplaced(n.sawCommandReads,n)||!/^command\s+reads\s+protected$/.test(t.content)?e.error(o.InvalidCommandReadsDeclaration,`Declare 'command reads protected' once at the application root.`,H(t)):n.commandReadMode=`Protected`,n.sawCommandReads=!0}function parseRootTimeZone(e,t,n){let r=G.exec(t.content);e.skipBlock(t.indent),isRepeatedOrMisplaced(n.sawTimeZone,n)||r===null?e.error(o.InvalidTimeZoneDeclaration,`Declare 'time zone "<id>"' or 'time zone configurable default "<id>"' once at the application root.`,H(t)):n.timeZone={kind:`TimeZoneSyntax`,id:F(r[2]),configurable:r[1]!==void 0,location:H(t)},n.sawTimeZone=!0}function parseRootReactionBatches(e,t,n){isRepeatedOrMisplaced(n.sawReactionBatches,n)||!/^reaction\s+batches\s+atomic$/.test(t.content)?e.error(o.InvalidReactionBatchesDeclaration,`Declare 'reaction batches atomic' once at the application root.`,H(t)):n.reactionProductionMode=`Atomic`,n.sawReactionBatches=!0}function parseRootDomain(e,t,n){e.authoredDeclarations=!0,n.domain=parseDomain(e,t,n.domain,n.sawOtherConstruct)}function parseRootFileImport(e,t,n){n.placedBody===void 0?x(e,t,n.fileImports):n.placedBody.tryParse(e,t)}function parseRootImport(e,t,n){let r=K.exec(t.content);if(r===null){e.error(o.InvalidImportDeclaration,`Invalid import '${t.content}' - expected 'import <Qualified.Name> [from "<origin>"]'`,H(t));return}let i=r.groups?.origin===void 0?null:F(r.groups.origin);i!==null&&ne(i)&&e.error(o.InvalidImportDeclaration,`An import origin must be a nonblank quoted string`,H(t)),n.imports.push({kind:`ImportSyntax`,qualifiedName:r[1],origin:i,visibility:i===null?`Private`:`Public`,location:H(t)})}function parseRootExample(e,t,n){n.placedBody===void 0?n.examples.push(B(e,t)):n.placedBody.tryParse(e,t)}function parseRootStickyNote(e,t,n){let r=parseStickyNote(e,t);r!==null&&n.stickyNotes.push(r)}function parseRootPolicy(e,t,n){let r=A(e,t);n.policies.some(e=>e.name===r.name)&&e.error(o.DuplicateDeclaration,`Duplicate declaration of policy '${r.name}' - policy names must be unique`,r.location),n.policies.push(r)}function parseRootTrigger(e,t,n){let r=d(e,t),i=/^trigger\s+([A-Za-z_]\w*)$/.exec(t.content)?.[1];i!==void 0&&n.declaredTriggers.push({name:i,data:r})}function parseRootOpaque(e,t){let n=w(t.content);n===`behavior`||n===`layout`?C(e,t):n===`ui`?V(e,t):e.skipOpaqueBlock(t.indent)}function presentOnly(e,t){return t===null?{}:{[e]:t}}function nonEmptyOnly(e,t){return t.length>0?{[e]:t}:{}}function buildApplication(e,t){let{placement:n,moduleBody:r,featureBody:i,modules:a}=t;r===void 0?i!==void 0&&a.unshift(place(n,i.build(e.start,!0),e.start)):a.unshift(r.build(e.start,!0));let{commandReadMode:o,timeZone:c,applicationContext:l,reactionProductionMode:u,identity:d,domain:f,imports:p,concepts:m,types:h,systems:g,stateMachines:_,workflows:v,eventSources:y,examples:b,personas:x,policies:S,purposes:C,seeds:w,declaredTriggers:T,fileImports:E,exposures:D,stickyNotes:O,instanceContributions:k}=t,A={kind:`ApplicationSyntax`,...presentOnly(`commandReadMode`,o),...presentOnly(`timeZone`,c),...presentOnly(`context`,l),...presentOnly(`reactionProductionMode`,u),...presentOnly(`identity`,d),sourceOptions:e.sourceOptions,domain:f,imports:p,concepts:m,types:h,systems:g,...nonEmptyOnly(`stateMachines`,_),...nonEmptyOnly(`workflows`,v),eventSources:y,examples:b,modules:a,personas:x,policies:S,purposes:C,seeds:w,declaredTriggers:T,fileImports:E,...nonEmptyOnly(`exposures`,D),...nonEmptyOnly(`stickyNotes`,O),...nonEmptyOnly(`instanceContributions`,k),location:e.start};return e.authoredDeclarations&&s(A),A}function declaresConstruct(e,t,n){return e===`import`?K.test(t.content):e===`module`?u(n):e===`identity`?t.content===`identity`:e===`context`?t.content===`context`:e===`purpose`||e===`example`||e===`exposure`||e===`instance`||e===`eventsource`||e===`system`||e===`statemachine`||e===`workflow`||e===`concept`||e===`type`||e===`persona`||e===`sticky`||$.has(e)}function parseModuleInPlacedFile(e,t,n,r){let i=O.exec(t.content)?.[1]??``;r!==void 0&&i===n[0]?(e.authoredDeclarations=!0,r.parseChildren(e,t)):(e.error(o.ModuleInPlacedFile,`This file is imported into ${c(n)}, so it cannot declare module '${i}' - import it at the top level of a document instead`,H(t)),e.skipBlock(t.indent))}function reportUnexpectedTopLevel(e,t,n){let r=w(t.content);if(u(n)){let n=oe.has(r)?` - '${r}' belongs in a module or feature; wrap it in one, or import this file from inside one`:` - expected domain, import, concept, type, policy, persona, sticky note, authentication, onboarding, identity, context, module, seed, trigger, behavior, ui profile, theme, sample data or layout`;e.error(o.UnknownTopLevelConstruct,`Unexpected '${r}' at the top level${n}`,H(t))}else{let i=n.length===1?D:y;e.error(o.UnexpectedInPlacedFile,`Unexpected '${r}' in a file imported into ${c(n)} - expected an application declaration or ${i}`,H(t))}e.skipBlock(t.indent)}function place(e,t,n){let r=t;for(let t=e.length-2;t>=1;t--)r={kind:`FeatureSyntax`,name:e[t],description:null,authorize:null,features:[r],slices:[],fileImports:[],isPlacement:!0,location:n};return{kind:`ModuleSyntax`,name:e[0],description:null,authorize:null,features:[r],fileImports:[],isPlacement:!0,location:n}}function parseDomain(e,t,n,r){let i=W.exec(t.content);return i===null?(e.error(o.InvalidDomainDeclaration,`Invalid domain declaration '${t.content}' - expected 'domain <Qualified.Name>'`,H(t)),n):n===null?(r&&e.error(o.DomainNotFirst,`'domain' must be declared before any other construct`,H(t)),{kind:`DomainSyntax`,name:i[1],location:H(t)}):(e.error(o.DuplicateDomain,`The document already declares a domain - a document can have at most one`,H(t)),n)}function warnOnTabIndentation(e,t){let n=!1;for(let r of t)r.raw.trimStart().startsWith("```")?n=!n:!n&&ae.test(r.raw)&&e.warning(o.TabIndentation,`Screenplay is indentation based - use spaces, not tabs`,U(r))}function parseConcept(r,i){let a=q.exec(i.content);if(a===null)return r.error(o.InvalidConceptDeclaration,`Invalid concept declaration '${i.content}' - expected 'concept <Name> : <Type>'`,H(i)),r.skipBlock(i.indent),{kind:`ConceptSyntax`,name:w(i.content),type:``,attributes:[],values:[],location:H(i)};let[,s,c,l]=a,u=m(r,i,s,l);c!==`Enum`&&!Q.includes(c)&&r.error(o.UnknownPrimitiveType,`Unknown primitive type '${c}' - expected ${Q.join(`, `)} or Enum`,H(i));let d=[],f=new e,h=null,v=!1,y=null,b=[];for(let e=r.peekChild(i.indent);e!==void 0;e=r.peekChild(i.indent)){r.reader.takeSignificant();let i=c===`Enum`?f.tryNumbered(r,e):void 0;if(i!==void 0)d.push(i);else if(w(e.content)===`description`&&(c!==`Enum`||e.content!==`description`||r.peekChild(e.indent)?.content.startsWith("```")===!0))y=_(r,e,y,`Concept '${s}'`);else if(S(e))continue;else if(w(e.content)===`validate`){c===`Enum`&&e.content===`validate`&&r.peekChild(e.indent)===void 0&&r.warning(o.ValidateReadAsEnumerationBlock,`'validate' in enumeration concept '${s}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,H(e));let t=g(r,e,`concept`,s);t!==void 0&&b.push(t)}else if(w(e.content)===`generate`&&(c!==`Enum`||e.content!==`generate`)){v&&r.error(o.DuplicateGeneration,`Concept '${s}' declares generation more than once.`,H(e));let t=n(r,e,c);v||(h=t),v=!0}else p(r,e,s,u)||(c===`Enum`&&J.test(e.content)?d.push(T(e.content)):c===`Enum`?r.error(o.InvalidEnumerationValue,`Invalid enum value '${e.content}' - expected an identifier`,H(e)):(r.error(o.UnknownConceptDirective,`Unexpected '${e.content}' in concept body - expected validate, generate, 'file <path>' or '<attribute> reason "<text>"'${t(e.content)}`,H(e)),r.skipBlock(e.indent)))}let x=f.finish(r,i,d.length);return{kind:`ConceptSyntax`,name:s,type:c,attributes:u,values:d,validations:b,description:y,...h===null?{}:{generation:h},...x===void 0?{}:{valueNumbers:x},location:H(i)}}function parsePersona(e,t){let n=Y.exec(t.content)?.[1]??``;n===``&&e.error(o.InvalidPersonaDeclaration,`Invalid persona declaration '${t.content}' - expected 'persona <Name>'`,H(t));let r=null,i=[],a=[],s=null,c=null;for(let l=e.peekChild(t.indent);l!==void 0;l=e.peekChild(t.indent)){e.reader.takeSignificant();let t=w(l.content);if(t===`description`)r=_(e,l,r,`Persona '${n}'`);else if(t===`goal`){let t=Z.exec(l.content);t===null?e.error(o.InvalidPersonaDeclaration,`Invalid goal '${l.content}' - expected 'goal "<text>"'`,H(l)):a.push(F(t[1]))}else if(t===`position`)s=I(e,l,`position`,`x`,`y`,s,!0)??s;else if(t===`size`)c=I(e,l,`size`,`width`,`height`,c,!1)??c;else if(t===`policy`){let t=X.exec(l.content);t===null?e.error(o.InvalidPersonaPolicyReference,`Invalid policy reference '${l.content}' - expected 'policy <Name>'`,H(l)):i.push(t[1])}else e.error(o.UnknownPersonaDirective,`Unexpected '${t}' in persona body - expected description, goal, policy, position or size`,H(l)),e.skipBlock(l.indent)}return{kind:`PersonaSyntax`,name:n,description:r,policies:i,...a.length>0?{goals:a}:{},...s===null?{}:{x:s[0],y:s[1]},...c===null?{}:{width:c[0],height:c[1]},location:H(t)}}function parseStickyNote(e,t){let n=re.exec(t.content);if(n===null)return e.error(o.InvalidPersonaDeclaration,`Invalid sticky note declaration '${t.content}' - expected 'sticky note on personas', 'sticky note on eventsources', 'sticky note on givencontexts' or 'sticky note on seeddata'`,H(t)),e.skipBlock(t.indent),null;let r=null,i=null,a=null,s=null;for(let n=e.peekChild(t.indent);n!==void 0;n=e.peekChild(t.indent)){e.reader.takeSignificant();let t=w(n.content);if(t===`description`)r=_(e,n,r,`A sticky note`);else if(t===`colour`){let t=ie.exec(n.content);t===null?e.error(o.InvalidPersonaDeclaration,`Invalid colour '${n.content}' - expected 'colour yellow', 'colour pink', 'colour green' or 'colour blue'`,H(n)):i=t[1]}else t===`position`?a=I(e,n,`position`,`x`,`y`,a,!0)??a:t===`size`?s=I(e,n,`size`,`width`,`height`,s,!1)??s:(e.error(o.UnknownPersonaDirective,`Unexpected '${t}' in sticky note body - expected description, colour, position or size`,H(n)),e.skipBlock(n.indent))}return r===null||a===null?(e.error(o.InvalidPersonaDeclaration,`A sticky note needs a description (the text on it) and a position`,H(t)),null):{kind:`StickyNoteSyntax`,canvas:n[1],text:r,colour:i,x:a[0],y:a[1],width:s===null?null:s[0],height:s===null?null:s[1],location:H(t)}}export{parseApplication};
2
2
  //# sourceMappingURL=ScreenplayParser.js.map