@cratis/screenplay-language 4.240.6 → 4.242.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
  2. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
  3. package/dist/bundles/compiler/Files/PlayFolderMerge.js +1 -1
  4. package/dist/bundles/compiler/Files/PlayFolderMerge.js.map +1 -1
  5. package/dist/bundles/compiler/Parsing/CaptureEventFixturesValidator.js +1 -1
  6. package/dist/bundles/compiler/Parsing/CaptureEventFixturesValidator.js.map +1 -1
  7. package/dist/bundles/compiler/Parsing/CaptureParser.js +1 -1
  8. package/dist/bundles/compiler/Parsing/CaptureParser.js.map +1 -1
  9. package/dist/bundles/compiler/Parsing/ClockOperandParser.js +2 -0
  10. package/dist/bundles/compiler/Parsing/ClockOperandParser.js.map +1 -0
  11. package/dist/bundles/compiler/Parsing/CommandParser.js +1 -1
  12. package/dist/bundles/compiler/Parsing/CommandParser.js.map +1 -1
  13. package/dist/bundles/compiler/Parsing/ConditionParser.js +1 -1
  14. package/dist/bundles/compiler/Parsing/ConditionParser.js.map +1 -1
  15. package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js +1 -1
  16. package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js.map +1 -1
  17. package/dist/bundles/compiler/Parsing/ScreenplayParser.js +1 -1
  18. package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -1
  19. package/dist/bundles/compiler/Parsing/SpecificationParser.js +1 -1
  20. package/dist/bundles/compiler/Parsing/SpecificationParser.js.map +1 -1
  21. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js +1 -1
  22. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js.map +1 -1
  23. package/dist/bundles/compiler/Syntax/Structure.js.map +1 -1
  24. package/dist/bundles/compiler/Syntax/SyntaxCollections.js +1 -1
  25. package/dist/bundles/compiler/Syntax/SyntaxCollections.js.map +1 -1
  26. package/dist/bundles/compiler/Syntax/SyntaxJson.js +1 -1
  27. package/dist/bundles/compiler/Syntax/SyntaxJson.js.map +1 -1
  28. package/dist/bundles/completion-items.js +3 -3
  29. package/dist/bundles/completion-items.js.map +1 -1
  30. package/dist/bundles/diagnostic-codes.js +1 -1
  31. package/dist/bundles/diagnostic-codes.js.map +1 -1
  32. package/dist/bundles/example-analysis.js +1 -1
  33. package/dist/bundles/example-analysis.js.map +1 -1
  34. package/dist/bundles/keyword-docs.js +1 -1
  35. package/dist/bundles/keyword-docs.js.map +1 -1
  36. package/dist/bundles/language.js +1 -1
  37. package/dist/bundles/language.js.map +1 -1
  38. package/dist/bundles/response-analysis.js +2 -2
  39. package/dist/bundles/response-analysis.js.map +1 -1
  40. package/dist/bundles/sub-languages/cdl.js +1 -1
  41. package/dist/bundles/sub-languages/cdl.js.map +1 -1
  42. package/dist/bundles/tokens.js +1 -1
  43. package/dist/bundles/tokens.js.map +1 -1
  44. package/dist/bundles/validation.js +1 -1
  45. package/dist/bundles/validation.js.map +1 -1
  46. package/dist/completion-items.d.ts.map +1 -1
  47. package/dist/diagnostic-codes.d.ts +4 -0
  48. package/dist/diagnostic-codes.d.ts.map +1 -1
  49. package/dist/keyword-docs.d.ts.map +1 -1
  50. package/dist/language.d.ts.map +1 -1
  51. package/dist/sub-languages/cdl.d.ts.map +1 -1
  52. package/dist/tokens.d.ts.map +1 -1
  53. package/package.json +3 -1
@@ -1 +1 @@
1
- {"version":3,"file":"CaptureParser.js","names":["legacyPattern","pattern","parseMappingSource","pattern","source","nativePattern","headerRules","eventNameRules","appendRules","childrenRules","nestedRules","context","rules","mappingPattern","mapEntryPattern","translationPattern","stringBodyPattern","splitPattern","whenTokens","splitTarget","owner","name","line","DiagnosticCodes","locationOf","key","map","appends","children","nested","child","firstWord","match","body","settings","settingName","syntaxKind","seen","setting","location","targets","target","parseProjectionExpression","unescapeString","raw","closing","translate","text","translations","entry","translated","mappings","tags","when","tag","parseTag","mapped","diagnosticText","unescapeIdentifier","parseModeledMappingSource","value","trigger","from","to","tokens","properties","index"],"sources":["../../../../../../Compiler/Parsing/CaptureParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { CaptureAppendSyntax, CaptureChildrenSyntax, CaptureMapOperationSyntax, CaptureNestedSyntax, CaptureSourceSettingSyntax, CaptureSourceSyntax, CaptureSyntax, CaptureTranslationSyntax, CaptureWhenSyntax } from '../Syntax/Captures';\nimport { eventsSourceKind, fromSetting } from '../Syntax/CaptureEventsSource';\nimport { TagSyntax } from '../Syntax/Declarations';\nimport { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { nativePattern as pattern, pattern as legacyPattern } from '../Text/patterns';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { parseTag } from './DeclarationParsers';\nimport { parseModeledMappingSource as parseMappingSource } from './ExpressionParser';\nimport { firstWord, unescapeIdentifier } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { parseProjectionExpression } from './ProjectionExpressionParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\n// The grammar Legacy already modeled keeps its original patterns; native patterns apply to Exact documents.\nconst grammar = (source: string): { legacy: RegExp; native: RegExp } => ({ legacy: legacyPattern(source), native: pattern(source) });\nconst headerRules = grammar('^capture\\\\s+([A-Za-z_]\\\\w*)$');\nconst eventNameRules = /^[A-Za-z_][\\w.]*$/;\nconst appendRules = grammar('^append\\\\s+([A-Z]\\\\w*)$');\nconst childrenRules = grammar('^children\\\\s+([a-z_]\\\\w*)\\\\s+identified\\\\s+by\\\\s+([\\\\w.]+)$');\nconst nestedRules = grammar('^nested\\\\s+([\\\\w.]+)$');\nconst select = (context: ParserContext, rules: { legacy: RegExp; native: RegExp }): RegExp => context.sourceOptions.numericMode === 'exact' ? rules.native : rules.legacy;\nconst mappingPattern = pattern('^(@?[\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst mapEntryPattern = pattern('^([a-z_]\\\\w*)\\\\s*=\\\\s*(.+)$');\nconst translationPattern = pattern(`^\"(${stringBodyPattern})\"\\\\s*=>\\\\s*(\\\\w+)$`);\nconst splitPattern = pattern(`^split\\\\s+(\\\\S+)\\\\s+by\\\\s+\"(${stringBodyPattern})\"$`);\nconst whenTokens = new RegExp(pattern(`\"${stringBodyPattern}\"|[\\\\w.]+`).source, 'gu');\nconst splitTarget = pattern('^[\\\\w.]+$');\n\n// A structural port of the existing capture grammar. Transition operands remain authored strings, as\n// C# models them; exact numeric mode is not admitted by any supported executable model (ESM) version yet (#285).\nexport function parseCapture(context: ParserContext, line: SourceLine): CaptureSyntax {\n // The events source is new grammar, so its violations reach the owning context rather than the quiet value context.\n const owner = context;\n context = context.valueContext;\n const name = select(context, headerRules).exec(line.content)?.[1] ?? '';\n if (name === '' && context.sourceOptions.numericMode === 'exact') context.error(DiagnosticCodes.InvalidCaptureDeclaration, `Invalid capture declaration '${line.content}' - expected 'capture <Name>'`, locationOf(line));\n let source: CaptureSourceSyntax | null = null;\n let key: string | null = null;\n const map: CaptureMapOperationSyntax[] = [];\n const appends: CaptureAppendSyntax[] = [];\n const children: CaptureChildrenSyntax[] = [];\n const nested: CaptureNestedSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(child.content)) {\n case 'source': source = parseSource(context, child, owner); break;\n case 'key': key = child.content.substring('key'.length).trim(); break;\n case 'map': map.push(...parseMap(context, child)); break;\n case 'append': pushAppend(context, child, appends); break;\n case 'children': {\n const match = select(context, childrenRules).exec(child.content);\n if (match === null) { context.error(DiagnosticCodes.InvalidChildrenDeclaration, `Invalid children declaration '${child.content}' - expected 'children <collection> identified by <key>'`, locationOf(child)); context.skipOpaqueBlock(child.indent); break; }\n const body = mapAndAppends(context, child);\n if (match !== null) children.push({ kind: 'CaptureChildrenSyntax', property: match[1], identifiedBy: match[2], ...body, location: locationOf(child) });\n break;\n }\n case 'nested': {\n const match = select(context, nestedRules).exec(child.content);\n if (match === null) { context.error(DiagnosticCodes.InvalidNestedDeclaration, `Invalid nested declaration '${child.content}' - expected 'nested <Property>'`, locationOf(child)); context.skipOpaqueBlock(child.indent); break; }\n const body = mapAndAppends(context, child);\n if (match !== null) nested.push({ kind: 'CaptureNestedSyntax', property: match[1], ...body, location: locationOf(child) });\n break;\n }\n default:\n context.error(DiagnosticCodes.UnknownCaptureDirective, `Unexpected '${child.content}' in capture body`, locationOf(child));\n context.skipOpaqueBlock(child.indent);\n }\n }\n return { kind: 'CaptureSyntax', sourceOptions: context.sourceOptions, name, source, key, map, appends, children, nested, location: locationOf(line) };\n}\n\nfunction parseSource(context: ParserContext, line: SourceLine, owner: ParserContext): CaptureSourceSyntax {\n const settings: CaptureSourceSettingSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const settingName = firstWord(child.content);\n settings.push({ kind: 'CaptureSourceSettingSyntax', name: settingName, value: child.content.substring(settingName.length).trim(), location: locationOf(child) });\n }\n const syntaxKind = line.content.substring('source'.length).trim();\n if (syntaxKind === eventsSourceKind) validateEventsSource(owner, line, settings);\n return { kind: 'CaptureSourceSyntax', syntaxKind, settings, location: locationOf(line) };\n}\n\nfunction validateEventsSource(context: ParserContext, line: SourceLine, settings: readonly CaptureSourceSettingSyntax[]): void {\n if (settings.length === 0) context.error(DiagnosticCodes.InvalidCaptureEventsSource, \"'source events' needs at least one 'from <Event>' line naming a public event to consume\", locationOf(line));\n const seen = new Set<string>();\n for (const setting of settings) {\n if (setting.name !== fromSetting) context.error(DiagnosticCodes.InvalidCaptureEventsSource, `'source events' accepts only 'from <Event>' lines, got '${setting.name}'`, setting.location);\n else if (!eventNameRules.test(setting.value)) context.error(DiagnosticCodes.InvalidCaptureEventsSource, `Invalid event '${setting.value}' - expected 'from <Event>', optionally qualified with dots`, setting.location);\n else if (seen.has(setting.value)) context.error(DiagnosticCodes.InvalidCaptureEventsSource, `Event '${setting.value}' is already consumed by this 'source events'`, setting.location);\n else seen.add(setting.value);\n }\n}\n\nfunction parseMap(context: ParserContext, line: SourceLine): CaptureMapOperationSyntax[] {\n const map: CaptureMapOperationSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const location = locationOf(child);\n if (firstWord(child.content) === 'split') {\n const match = splitPattern.exec(child.content);\n if (match === null) { context.error(DiagnosticCodes.InvalidSplitDeclaration, `Invalid split operation '${child.content}' - expected 'split <property> by \"<separator>\"'`, location); context.skipOpaqueBlock(child.indent); continue; }\n const targets: string[] = [];\n for (let target = context.peekChild(child.indent); target !== undefined; target = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n if (splitTarget.test(target.content)) targets.push(target.content);\n else context.error(DiagnosticCodes.InvalidSplitTarget, `Invalid split target '${target.content}' - expected a property path`, locationOf(target));\n }\n if (match !== null) map.push({ kind: 'CaptureSplitSyntax', source: parseProjectionExpression(match[1], location, context), separator: unescapeString(match[2]), targets, location });\n continue;\n }\n const match = mapEntryPattern.exec(child.content);\n if (match === null) { context.error(DiagnosticCodes.InvalidMapEntry, `Invalid map entry '${child.content}' - expected '<property> = <source> [translate]'`, location); context.skipOpaqueBlock(child.indent); continue; }\n const raw = match[2].trim();\n const closing = raw.startsWith('`') ? raw.indexOf('`', 1) : -1;\n const translate = raw.startsWith('`') ? closing >= 0 && raw.substring(closing + 1).trim() === 'translate' : raw.endsWith(' translate');\n const text = raw.startsWith('`') && closing >= 0 && (context.sourceOptions.numericMode !== 'exact' || translate || raw.substring(closing + 1).trim() === '') ? raw.substring(0, closing + 1) : translate ? raw.substring(0, raw.length - ' translate'.length).trimEnd() : raw;\n const translations: CaptureTranslationSyntax[] = [];\n if (translate) {\n for (let entry = context.peekChild(child.indent); entry !== undefined; entry = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n const translated = translationPattern.exec(entry.content);\n if (translated !== null) translations.push({ kind: 'CaptureTranslationSyntax', from: unescapeString(translated[1]), to: translated[2], location: locationOf(entry) });\n else context.error(DiagnosticCodes.InvalidTranslation, `Invalid translation '${entry.content}' - expected '\"<source>\" => <target>'`, locationOf(entry));\n }\n }\n map.push({ kind: 'CaptureMapEntrySyntax', property: match[1], source: parseProjectionExpression(text, location, context), translations, location });\n }\n return map;\n}\n\nfunction mapAndAppends(context: ParserContext, line: SourceLine): { map: CaptureMapOperationSyntax[]; appends: CaptureAppendSyntax[] } {\n let map: CaptureMapOperationSyntax[] = [];\n const appends: CaptureAppendSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'map') map = parseMap(context, child);\n else if (firstWord(child.content) === 'append') pushAppend(context, child, appends);\n else {\n context.error(DiagnosticCodes.UnknownCaptureBlockDirective, `Unexpected '${child.content}' in ${firstWord(line.content)} block - expected 'map' or 'append <EventType>'`, locationOf(child));\n context.skipOpaqueBlock(child.indent);\n }\n }\n return { map, appends };\n}\n\nfunction pushAppend(context: ParserContext, line: SourceLine, appends: CaptureAppendSyntax[]): void {\n const match = select(context, appendRules).exec(line.content);\n if (match === null) { context.error(DiagnosticCodes.InvalidAppendDeclaration, `Invalid append declaration '${line.content}' - expected 'append <EventType>'`, locationOf(line)); context.skipOpaqueBlock(line.indent); return; }\n const mappings: PropertyMappingSyntax[] = [];\n const tags: TagSyntax[] = [];\n let when: CaptureWhenSyntax | null = null;\n const mapping = (child: SourceLine, nested = false): void => {\n const location = locationOf(child);\n if (firstWord(child.content) === 'tag') {\n const tag = parseTag(context.valueContext, child, false);\n if (tag !== undefined) tags.push(tag);\n return;\n }\n const mapped = mappingPattern.exec(child.content);\n if (mapped !== null) mappings.push({ kind: 'PropertyMappingSyntax', property: unescapeIdentifier(mapped[1]), source: parseMappingSource(mapped[2], location, context.valueContext), location });\n else context.error(nested ? DiagnosticCodes.InvalidPropertyMapping : DiagnosticCodes.UnknownAppendDirective, `Unexpected '${child.content}' in append body`, location, nested ? diagnosticText('text', child.content) : {});\n };\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'when') {\n when = parseWhen(context, child);\n for (let value = context.peekChild(child.indent); value !== undefined; value = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n mapping(value, true);\n }\n } else mapping(child);\n }\n appends.push({ kind: 'CaptureAppendSyntax', event: match[1], when, mappings, tags, location: locationOf(line) });\n}\n\nfunction parseWhen(context: ParserContext, line: SourceLine): CaptureWhenSyntax | null {\n const trigger = line.content.substring('when'.length).trim();\n const location = locationOf(line);\n const value = (syntaxKind: CaptureWhenSyntax['syntaxKind'], properties: string[] = [], from: string | null = null, to: string | null = null, expression: string | null = null): CaptureWhenSyntax => ({ kind: 'CaptureWhenSyntax', syntaxKind, properties, fromValue: from, toValue: to, expression, location });\n if (trigger === 'added') return value('Added');\n if (trigger === 'removed') return value('Removed');\n if (trigger.startsWith('`')) {\n if (!trigger.endsWith('`') || trigger.length < 2) context.error(DiagnosticCodes.UnterminatedTemplateExpression, \"Unterminated template expression in 'when' - expected a closing backtick\", location);\n return value('Expression', [], null, null, trigger);\n }\n if (trigger.length === 0) { context.error(DiagnosticCodes.WhenWithoutTrigger, \"Expected a trigger after 'when'\", location); return null; }\n const tokens: string[] = [...(trigger.match(context.sourceOptions.numericMode === 'exact' ? new RegExp(`\"${stringBodyPattern}\"|[^\\\\s]+`, 'gu') : whenTokens) ?? [])];\n const unquote = (text: string): string => text.startsWith('\"') && text.endsWith('\"') ? unescapeString(text.substring(1, text.length - 1)) : text;\n if (tokens.length === 0) { context.error(DiagnosticCodes.InvalidWhenClause, `Invalid 'when' clause '${line.content}'`, location); return null; }\n if (tokens.length === 1) return value('PropertyChanged', [unquote(tokens[0])]);\n if (tokens[1] === 'from') {\n if (tokens.length === 5 && tokens[3] === 'to') return value('ValueTransition', [unquote(tokens[0])], unquote(tokens[2]), unquote(tokens[4]));\n context.error(DiagnosticCodes.InvalidWhenTransitionClause, `Invalid 'when ... from ... to ...' clause '${line.content}'`, location); return null;\n }\n if (tokens[1] !== 'or' && tokens[1] !== 'and') { context.error(DiagnosticCodes.InvalidWhenClause, `Invalid 'when' clause '${line.content}'`, location); return null; }\n if (tokens.length % 2 === 0) { context.error(DiagnosticCodes.WhenCombinatorWithoutProperty, `Expected a property after '${tokens[1]}'`, location); return null; }\n const properties = [unquote(tokens[0])];\n for (let index = 1; index < tokens.length - 1; index += 2) {\n if (tokens[index] !== tokens[1]) { context.error(DiagnosticCodes.MixedWhenCombinators, `Cannot mix 'and' and 'or' in a single 'when' clause '${line.content}'`, location); return null; }\n properties.push(unquote(tokens[index + 1]));\n }\n return value(tokens[1] === 'or' ? 'LogicalOr' : 'LogicalAnd', properties);\n}\n"],"mappings":"0qBAmBA,MAAM,QAAW,IAAwD,CAAE,OAAQA,EAAcI,CAAM,EAAG,OAAQH,EAAQG,CAAM,CAAE,GAC5HE,EAAc,QAAQ,8BAA8B,EACpDC,EAAiB,oBACjBC,EAAc,QAAQ,yBAAyB,EAC/CC,EAAgB,QAAQ,6DAA6D,EACrFC,EAAc,QAAQ,uBAAuB,EAC7C,QAAU,EAAwB,IAAsDC,EAAQ,cAAc,cAAgB,QAAUC,EAAM,OAASA,EAAM,OAC7JC,EAAiBZ,EAAQ,mCAAmC,EAC5Da,EAAkBb,EAAQ,6BAA6B,EACvDc,EAAqBd,EAAQ,MAAMe,EAAkB,oBAAoB,EACzEC,EAAehB,EAAQ,+BAA+Be,EAAkB,IAAI,EAC5EE,EAAa,IAAI,OAAOjB,EAAQ,IAAIe,EAAkB,UAAU,CAAC,CAAC,OAAQ,IAAI,EAC9EG,EAAclB,EAAQ,WAA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,OAAO,MAAM,kBAAmB,CAAC,QAAQA,EAAO,EAAE,CAAC,CAAC,EAC7E,GAAIA,EAAO,KAAO,OAEuH,OADjIA,EAAO,SAAW,GAAKA,EAAO,KAAO,KAAa,MAAM,kBAAmB,CAAC,QAAQA,EAAO,EAAE,CAAC,EAAG,QAAQA,EAAO,EAAE,EAAG,QAAQA,EAAO,EAAE,CAAC,GAC3IrD,EAAQ,MAAMY,EAAgB,4BAA6B,8CAA8CD,EAAK,QAAQ,GAAIiB,CAAQ,EAAU,MAEhJ,GAAIyB,EAAO,KAAO,MAAQA,EAAO,KAAO,MAAgH,OAAvGrD,EAAQ,MAAMY,EAAgB,kBAAmB,0BAA0BD,EAAK,QAAQ,GAAIiB,CAAQ,EAAU,KAC/J,GAAIyB,EAAO,OAAS,GAAM,EAAyH,OAApHrD,EAAQ,MAAMY,EAAgB,8BAA+B,8BAA8ByC,EAAO,GAAG,GAAIzB,CAAQ,EAAU,KAC1J,IAAM0B,EAAa,CAAC,QAAQD,EAAO,EAAE,CAAC,EACtC,IAAK,IAAIE,EAAQ,EAAGA,EAAQF,EAAO,OAAS,EAAG,GAAS,EAAG,CACvD,GAAIA,EAAOE,KAAWF,EAAO,GAA8I,OAAxIrD,EAAQ,MAAMY,EAAgB,qBAAsB,wDAAwDD,EAAK,QAAQ,GAAIiB,CAAQ,EAAU,KAClL0B,EAAW,KAAK,QAAQD,EAAOE,EAAQ,EAAE,CAAC,CAC9C,CACA,OAAO,MAAMF,EAAO,KAAO,KAAO,YAAc,aAAcC,CAAU,CAC5E"}
1
+ {"version":3,"file":"CaptureParser.js","names":["legacyPattern","pattern","parseMappingSource","pattern","source","nativePattern","headerRules","eventNameRules","eventSourceKeyRules","appendRules","childrenRules","nestedRules","context","rules","mappingPattern","mapEntryPattern","translationPattern","stringBodyPattern","splitPattern","whenTokens","splitTarget","owner","name","line","DiagnosticCodes","locationOf","key","keyIsEventSource","map","appends","children","nested","child","firstWord","match","body","marker","settings","settingName","syntaxKind","seen","setting","location","targets","target","parseProjectionExpression","unescapeString","raw","closing","translate","text","translations","entry","translated","mappings","tags","when","tag","parseTag","mapped","diagnosticText","unescapeIdentifier","parseModeledMappingSource","value","trigger","from","to","tokens","properties","index"],"sources":["../../../../../../Compiler/Parsing/CaptureParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { CaptureAppendSyntax, CaptureChildrenSyntax, CaptureMapOperationSyntax, CaptureNestedSyntax, CaptureSourceSettingSyntax, CaptureSourceSyntax, CaptureSyntax, CaptureTranslationSyntax, CaptureWhenSyntax } from '../Syntax/Captures';\nimport { eventsSourceKind, fromSetting } from '../Syntax/CaptureEventsSource';\nimport { TagSyntax } from '../Syntax/Declarations';\nimport { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { nativePattern as pattern, pattern as legacyPattern } from '../Text/patterns';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { parseTag } from './DeclarationParsers';\nimport { parseModeledMappingSource as parseMappingSource } from './ExpressionParser';\nimport { firstWord, unescapeIdentifier } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { parseProjectionExpression } from './ProjectionExpressionParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\n// The grammar Legacy already modeled keeps its original patterns; native patterns apply to Exact documents.\nconst grammar = (source: string): { legacy: RegExp; native: RegExp } => ({ legacy: legacyPattern(source), native: pattern(source) });\nconst headerRules = grammar('^capture\\\\s+([A-Za-z_]\\\\w*)$');\nconst eventNameRules = /^[A-Za-z_][\\w.]*$/;\nconst eventSourceKeyRules = /\\s+is\\s+event\\s+source$/;\nconst appendRules = grammar('^append\\\\s+([A-Z]\\\\w*)$');\nconst childrenRules = grammar('^children\\\\s+([a-z_]\\\\w*)\\\\s+identified\\\\s+by\\\\s+([\\\\w.]+)$');\nconst nestedRules = grammar('^nested\\\\s+([\\\\w.]+)$');\nconst select = (context: ParserContext, rules: { legacy: RegExp; native: RegExp }): RegExp => context.sourceOptions.numericMode === 'exact' ? rules.native : rules.legacy;\nconst mappingPattern = pattern('^(@?[\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst mapEntryPattern = pattern('^([a-z_]\\\\w*)\\\\s*=\\\\s*(.+)$');\nconst translationPattern = pattern(`^\"(${stringBodyPattern})\"\\\\s*=>\\\\s*(\\\\w+)$`);\nconst splitPattern = pattern(`^split\\\\s+(\\\\S+)\\\\s+by\\\\s+\"(${stringBodyPattern})\"$`);\nconst whenTokens = new RegExp(pattern(`\"${stringBodyPattern}\"|[\\\\w.]+`).source, 'gu');\nconst splitTarget = pattern('^[\\\\w.]+$');\n\n// A structural port of the existing capture grammar. Transition operands remain authored strings, as\n// C# models them; exact numeric mode is not admitted by any supported executable model (ESM) version yet (#285).\nexport function parseCapture(context: ParserContext, line: SourceLine): CaptureSyntax {\n // The events source is new grammar, so its violations reach the owning context rather than the quiet value context.\n const owner = context;\n context = context.valueContext;\n const name = select(context, headerRules).exec(line.content)?.[1] ?? '';\n if (name === '' && context.sourceOptions.numericMode === 'exact') context.error(DiagnosticCodes.InvalidCaptureDeclaration, `Invalid capture declaration '${line.content}' - expected 'capture <Name>'`, locationOf(line));\n let source: CaptureSourceSyntax | null = null;\n let key: string | null = null;\n let keyIsEventSource = false;\n const map: CaptureMapOperationSyntax[] = [];\n const appends: CaptureAppendSyntax[] = [];\n const children: CaptureChildrenSyntax[] = [];\n const nested: CaptureNestedSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(child.content)) {\n case 'source': source = parseSource(context, child, owner); break;\n case 'key': [key, keyIsEventSource] = parseKey(child.content.substring('key'.length).trim(), keyIsEventSource); break;\n case 'map': map.push(...parseMap(context, child)); break;\n case 'append': pushAppend(context, child, appends); break;\n case 'children': {\n const match = select(context, childrenRules).exec(child.content);\n if (match === null) { context.error(DiagnosticCodes.InvalidChildrenDeclaration, `Invalid children declaration '${child.content}' - expected 'children <collection> identified by <key>'`, locationOf(child)); context.skipOpaqueBlock(child.indent); break; }\n const body = mapAndAppends(context, child);\n if (match !== null) children.push({ kind: 'CaptureChildrenSyntax', property: match[1], identifiedBy: match[2], ...body, location: locationOf(child) });\n break;\n }\n case 'nested': {\n const match = select(context, nestedRules).exec(child.content);\n if (match === null) { context.error(DiagnosticCodes.InvalidNestedDeclaration, `Invalid nested declaration '${child.content}' - expected 'nested <Property>'`, locationOf(child)); context.skipOpaqueBlock(child.indent); break; }\n const body = mapAndAppends(context, child);\n if (match !== null) nested.push({ kind: 'CaptureNestedSyntax', property: match[1], ...body, location: locationOf(child) });\n break;\n }\n default:\n context.error(DiagnosticCodes.UnknownCaptureDirective, `Unexpected '${child.content}' in capture body`, locationOf(child));\n context.skipOpaqueBlock(child.indent);\n }\n }\n return { kind: 'CaptureSyntax', sourceOptions: context.sourceOptions, name, source, key, ...eventSourceKeyMarker(keyIsEventSource), map, appends, children, nested, location: locationOf(line) };\n}\n\nfunction parseKey(key: string, keyIsEventSource: boolean): [string, boolean] {\n const marker = eventSourceKeyRules.exec(key);\n return marker !== null ? [key.substring(0, marker.index), true] : [key, keyIsEventSource];\n}\n\nfunction eventSourceKeyMarker(keyIsEventSource: boolean): { keyIsEventSource?: boolean } {\n return keyIsEventSource ? { keyIsEventSource } : {};\n}\n\nfunction parseSource(context: ParserContext, line: SourceLine, owner: ParserContext): CaptureSourceSyntax {\n const settings: CaptureSourceSettingSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const settingName = firstWord(child.content);\n settings.push({ kind: 'CaptureSourceSettingSyntax', name: settingName, value: child.content.substring(settingName.length).trim(), location: locationOf(child) });\n }\n const syntaxKind = line.content.substring('source'.length).trim();\n if (syntaxKind === eventsSourceKind) validateEventsSource(owner, line, settings);\n return { kind: 'CaptureSourceSyntax', syntaxKind, settings, location: locationOf(line) };\n}\n\nfunction validateEventsSource(context: ParserContext, line: SourceLine, settings: readonly CaptureSourceSettingSyntax[]): void {\n if (settings.length === 0) context.error(DiagnosticCodes.InvalidCaptureEventsSource, \"'source events' needs at least one 'from <Event>' line naming a public event to consume\", locationOf(line));\n const seen = new Set<string>();\n for (const setting of settings) {\n if (setting.name !== fromSetting) context.error(DiagnosticCodes.InvalidCaptureEventsSource, `'source events' accepts only 'from <Event>' lines, got '${setting.name}'`, setting.location);\n else if (!eventNameRules.test(setting.value)) context.error(DiagnosticCodes.InvalidCaptureEventsSource, `Invalid event '${setting.value}' - expected 'from <Event>', optionally qualified with dots`, setting.location);\n else if (seen.has(setting.value)) context.error(DiagnosticCodes.InvalidCaptureEventsSource, `Event '${setting.value}' is already consumed by this 'source events'`, setting.location);\n else seen.add(setting.value);\n }\n}\n\nfunction parseMap(context: ParserContext, line: SourceLine): CaptureMapOperationSyntax[] {\n const map: CaptureMapOperationSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const location = locationOf(child);\n if (firstWord(child.content) === 'split') {\n const match = splitPattern.exec(child.content);\n if (match === null) { context.error(DiagnosticCodes.InvalidSplitDeclaration, `Invalid split operation '${child.content}' - expected 'split <property> by \"<separator>\"'`, location); context.skipOpaqueBlock(child.indent); continue; }\n const targets: string[] = [];\n for (let target = context.peekChild(child.indent); target !== undefined; target = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n if (splitTarget.test(target.content)) targets.push(target.content);\n else context.error(DiagnosticCodes.InvalidSplitTarget, `Invalid split target '${target.content}' - expected a property path`, locationOf(target));\n }\n if (match !== null) map.push({ kind: 'CaptureSplitSyntax', source: parseProjectionExpression(match[1], location, context), separator: unescapeString(match[2]), targets, location });\n continue;\n }\n const match = mapEntryPattern.exec(child.content);\n if (match === null) { context.error(DiagnosticCodes.InvalidMapEntry, `Invalid map entry '${child.content}' - expected '<property> = <source> [translate]'`, location); context.skipOpaqueBlock(child.indent); continue; }\n const raw = match[2].trim();\n const closing = raw.startsWith('`') ? raw.indexOf('`', 1) : -1;\n const translate = raw.startsWith('`') ? closing >= 0 && raw.substring(closing + 1).trim() === 'translate' : raw.endsWith(' translate');\n const text = raw.startsWith('`') && closing >= 0 && (context.sourceOptions.numericMode !== 'exact' || translate || raw.substring(closing + 1).trim() === '') ? raw.substring(0, closing + 1) : translate ? raw.substring(0, raw.length - ' translate'.length).trimEnd() : raw;\n const translations: CaptureTranslationSyntax[] = [];\n if (translate) {\n for (let entry = context.peekChild(child.indent); entry !== undefined; entry = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n const translated = translationPattern.exec(entry.content);\n if (translated !== null) translations.push({ kind: 'CaptureTranslationSyntax', from: unescapeString(translated[1]), to: translated[2], location: locationOf(entry) });\n else context.error(DiagnosticCodes.InvalidTranslation, `Invalid translation '${entry.content}' - expected '\"<source>\" => <target>'`, locationOf(entry));\n }\n }\n map.push({ kind: 'CaptureMapEntrySyntax', property: match[1], source: parseProjectionExpression(text, location, context), translations, location });\n }\n return map;\n}\n\nfunction mapAndAppends(context: ParserContext, line: SourceLine): { map: CaptureMapOperationSyntax[]; appends: CaptureAppendSyntax[] } {\n let map: CaptureMapOperationSyntax[] = [];\n const appends: CaptureAppendSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'map') map = parseMap(context, child);\n else if (firstWord(child.content) === 'append') pushAppend(context, child, appends);\n else {\n context.error(DiagnosticCodes.UnknownCaptureBlockDirective, `Unexpected '${child.content}' in ${firstWord(line.content)} block - expected 'map' or 'append <EventType>'`, locationOf(child));\n context.skipOpaqueBlock(child.indent);\n }\n }\n return { map, appends };\n}\n\nfunction pushAppend(context: ParserContext, line: SourceLine, appends: CaptureAppendSyntax[]): void {\n const match = select(context, appendRules).exec(line.content);\n if (match === null) { context.error(DiagnosticCodes.InvalidAppendDeclaration, `Invalid append declaration '${line.content}' - expected 'append <EventType>'`, locationOf(line)); context.skipOpaqueBlock(line.indent); return; }\n const mappings: PropertyMappingSyntax[] = [];\n const tags: TagSyntax[] = [];\n let when: CaptureWhenSyntax | null = null;\n const mapping = (child: SourceLine, nested = false): void => {\n const location = locationOf(child);\n if (firstWord(child.content) === 'tag') {\n const tag = parseTag(context.valueContext, child, false);\n if (tag !== undefined) tags.push(tag);\n return;\n }\n const mapped = mappingPattern.exec(child.content);\n if (mapped !== null) mappings.push({ kind: 'PropertyMappingSyntax', property: unescapeIdentifier(mapped[1]), source: parseMappingSource(mapped[2], location, context.valueContext), location });\n else context.error(nested ? DiagnosticCodes.InvalidPropertyMapping : DiagnosticCodes.UnknownAppendDirective, `Unexpected '${child.content}' in append body`, location, nested ? diagnosticText('text', child.content) : {});\n };\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'when') {\n when = parseWhen(context, child);\n for (let value = context.peekChild(child.indent); value !== undefined; value = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n mapping(value, true);\n }\n } else mapping(child);\n }\n appends.push({ kind: 'CaptureAppendSyntax', event: match[1], when, mappings, tags, location: locationOf(line) });\n}\n\nfunction parseWhen(context: ParserContext, line: SourceLine): CaptureWhenSyntax | null {\n const trigger = line.content.substring('when'.length).trim();\n const location = locationOf(line);\n const value = (syntaxKind: CaptureWhenSyntax['syntaxKind'], properties: string[] = [], from: string | null = null, to: string | null = null, expression: string | null = null): CaptureWhenSyntax => ({ kind: 'CaptureWhenSyntax', syntaxKind, properties, fromValue: from, toValue: to, expression, location });\n if (trigger === 'added') return value('Added');\n if (trigger === 'removed') return value('Removed');\n if (trigger.startsWith('`')) {\n if (!trigger.endsWith('`') || trigger.length < 2) context.error(DiagnosticCodes.UnterminatedTemplateExpression, \"Unterminated template expression in 'when' - expected a closing backtick\", location);\n return value('Expression', [], null, null, trigger);\n }\n if (trigger.length === 0) { context.error(DiagnosticCodes.WhenWithoutTrigger, \"Expected a trigger after 'when'\", location); return null; }\n const tokens: string[] = [...(trigger.match(context.sourceOptions.numericMode === 'exact' ? new RegExp(`\"${stringBodyPattern}\"|[^\\\\s]+`, 'gu') : whenTokens) ?? [])];\n const unquote = (text: string): string => text.startsWith('\"') && text.endsWith('\"') ? unescapeString(text.substring(1, text.length - 1)) : text;\n if (tokens.length === 0) { context.error(DiagnosticCodes.InvalidWhenClause, `Invalid 'when' clause '${line.content}'`, location); return null; }\n if (tokens.length === 1) return value('PropertyChanged', [unquote(tokens[0])]);\n if (tokens[1] === 'from') {\n if (tokens.length === 5 && tokens[3] === 'to') return value('ValueTransition', [unquote(tokens[0])], unquote(tokens[2]), unquote(tokens[4]));\n context.error(DiagnosticCodes.InvalidWhenTransitionClause, `Invalid 'when ... from ... to ...' clause '${line.content}'`, location); return null;\n }\n if (tokens[1] !== 'or' && tokens[1] !== 'and') { context.error(DiagnosticCodes.InvalidWhenClause, `Invalid 'when' clause '${line.content}'`, location); return null; }\n if (tokens.length % 2 === 0) { context.error(DiagnosticCodes.WhenCombinatorWithoutProperty, `Expected a property after '${tokens[1]}'`, location); return null; }\n const properties = [unquote(tokens[0])];\n for (let index = 1; index < tokens.length - 1; index += 2) {\n if (tokens[index] !== tokens[1]) { context.error(DiagnosticCodes.MixedWhenCombinators, `Cannot mix 'and' and 'or' in a single 'when' clause '${line.content}'`, location); return null; }\n properties.push(unquote(tokens[index + 1]));\n }\n return value(tokens[1] === 'or' ? 'LogicalOr' : 'LogicalAnd', properties);\n}\n"],"mappings":"0qBAmBA,MAAM,QAAW,IAAwD,CAAE,OAAQA,EAAcI,CAAM,EAAG,OAAQH,EAAQG,CAAM,CAAE,GAC5HE,EAAc,QAAQ,8BAA8B,EACpDC,EAAiB,oBACjBC,EAAsB,0BACtBC,EAAc,QAAQ,yBAAyB,EAC/CC,EAAgB,Q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,OAAS,GAAM,EAAyH,OAApHvD,EAAQ,MAAMY,EAAgB,8BAA+B,8BAA8B2C,EAAO,GAAG,GAAIzB,CAAQ,EAAU,KAC1J,IAAM0B,EAAa,CAAC,QAAQD,EAAO,EAAE,CAAC,EACtC,IAAK,IAAIE,EAAQ,EAAGA,EAAQF,EAAO,OAAS,EAAG,GAAS,EAAG,CACvD,GAAIA,EAAOE,KAAWF,EAAO,GAA8I,OAAxIvD,EAAQ,MAAMY,EAAgB,qBAAsB,wDAAwDD,EAAK,QAAQ,GAAImB,CAAQ,EAAU,KAClL0B,EAAW,KAAK,QAAQD,EAAOE,EAAQ,EAAE,CAAC,CAC9C,CACA,OAAO,MAAMF,EAAO,KAAO,KAAO,YAAc,aAAcC,CAAU,CAC5E"}
@@ -0,0 +1,2 @@
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{parseModeledMappingSource as t}from"./ExpressionParser.js";const n=/* @__PURE__ */ new Set([`day`,`days`,`hour`,`hours`,`minute`,`minutes`]),isClock=e=>e===`today`||e===`now`,isSign=e=>e!==void 0&&/^[+-](?:[0-9]+)?$/.test(e),startsOffset=(e,t)=>isClock(e[t])&&isSign(e[t+1]),isAmount=e=>Number.isSafeInteger(e)&&e<=2147483647,isUnit=e=>e!==void 0&&n.has(e);function parseClockOperand(e,t,n,r){return t[n]===`date`&&t[n+1]===`of`?parseDateOf(e,t,n+2,r):startsOffset(t,n)?parseOffset(e,t,n,r):null}function parseDateOf(n,r,i,a){if(i>=r.length)return n.error(e.ExpectedComparisonValue,`Expected an operand after 'date of'`,a),{expression:null,text:``,position:i};let o=startsOffset(r,i)?parseOffset(n,r,i,a):{expression:t(r[i],a,n),text:r[i],position:i+1};return{expression:o.expression===null?null:{kind:`DateOfExpressionSyntax`,operand:o.expression,location:a},text:`date of ${o.text}`,position:o.position}}function readAmount(e,t,n){return n.length>1?{text:n.slice(1),position:t}:t<e.length?{text:e[t],position:t+1}:{text:``,position:t}}function parseOffset(t,n,r,i){let a=n[r++],o=n[r++],s=readAmount(n,r,o),c=s.text;r=s.position;let l=/^[0-9]+$/.test(c)?Number(c):NaN;if(!isAmount(l))return t.error(e.UnexpectedTokenInCondition,`Expected a whole number of days, hours or minutes after '${a} ${o[0]}', got '${c}'`,i),{expression:null,text:``,position:r};let u=n[r];if(!isUnit(u))return t.error(e.UnexpectedTokenInCondition,`Expected a unit (day, hour or minute) after '${a} ${o[0]} ${c}'`,i),{expression:null,text:``,position:r};let d=o[0]===`-`&&l!==0;return{expression:{kind:`ClockOffsetExpressionSyntax`,clock:a,amount:d?-l:l,unit:u,location:i},text:`${a} ${d?`-`:`+`} ${l} ${u}`,position:r+1}}export{parseClockOperand};
2
+ //# sourceMappingURL=ClockOperandParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClockOperandParser.js","names":["units","token","tokens","position","amount","unit","context","location","DiagnosticCodes","operand","parseModeledMappingSource","sign","clock","amountToken","amountText","negative"],"sources":["../../../../../../Compiler/Parsing/ClockOperandParser.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 { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { parseModeledMappingSource } from './ExpressionParser';\nimport { ParserContext } from './ParserContext';\n\ninterface Operand {\n expression: ExpressionSyntax | null;\n text: string;\n position: number;\n}\n\nconst units = new Set(['day', 'days', 'hour', 'hours', 'minute', 'minutes']);\nconst isClock = (token: string | undefined): boolean => token === 'today' || token === 'now';\nconst isSign = (token: string | undefined): boolean => token !== undefined && /^[+-](?:[0-9]+)?$/.test(token);\nconst startsOffset = (tokens: readonly string[], position: number): boolean => isClock(tokens[position]) && isSign(tokens[position + 1]);\nconst isAmount = (amount: number): boolean => Number.isSafeInteger(amount) && amount <= 2147483647;\nconst isUnit = (unit: string | undefined): boolean => unit !== undefined && units.has(unit);\n\n// Decisions 0106/0107. Bare today/now stay ordinary names; only an offset or 'date of' gets a new node.\n// null means no clock operand; a null expression means a malformed clock operand, already diagnosed.\nexport function parseClockOperand(context: ParserContext, tokens: readonly string[], position: number, location: SourceLocation): Operand | null {\n if (tokens[position] === 'date' && tokens[position + 1] === 'of') return parseDateOf(context, tokens, position + 2, location);\n return startsOffset(tokens, position) ? parseOffset(context, tokens, position, location) : null;\n}\n\nfunction parseDateOf(context: ParserContext, tokens: readonly string[], position: number, location: SourceLocation): Operand {\n if (position >= tokens.length) {\n context.error(DiagnosticCodes.ExpectedComparisonValue, \"Expected an operand after 'date of'\", location);\n return { expression: null, text: '', position };\n }\n const operand = startsOffset(tokens, position)\n ? parseOffset(context, tokens, position, location)\n : { expression: parseModeledMappingSource(tokens[position], location, context), text: tokens[position], position: position + 1 };\n return { expression: operand.expression === null ? null : { kind: 'DateOfExpressionSyntax', operand: operand.expression, location }, text: `date of ${operand.text}`, position: operand.position };\n}\n\nfunction readAmount(tokens: readonly string[], position: number, sign: string): { text: string; position: number } {\n if (sign.length > 1) return { text: sign.slice(1), position };\n return position < tokens.length ? { text: tokens[position], position: position + 1 } : { text: '', position };\n}\n\nfunction parseOffset(context: ParserContext, tokens: readonly string[], position: number, location: SourceLocation): Operand {\n const clock = tokens[position++];\n const sign = tokens[position++];\n const amountToken = readAmount(tokens, position, sign);\n const amountText = amountToken.text;\n position = amountToken.position;\n const amount = /^[0-9]+$/.test(amountText) ? Number(amountText) : Number.NaN;\n if (!isAmount(amount)) {\n context.error(DiagnosticCodes.UnexpectedTokenInCondition, `Expected a whole number of days, hours or minutes after '${clock} ${sign[0]}', got '${amountText}'`, location);\n return { expression: null, text: '', position };\n }\n const unit = tokens[position];\n if (!isUnit(unit)) {\n context.error(DiagnosticCodes.UnexpectedTokenInCondition, `Expected a unit (day, hour or minute) after '${clock} ${sign[0]} ${amountText}'`, location);\n return { expression: null, text: '', position };\n }\n const negative = sign[0] === '-' && amount !== 0;\n return {\n expression: { kind: 'ClockOffsetExpressionSyntax', clock, amount: negative ? -amount : amount, unit, location },\n text: `${clock} ${negative ? '-' : '+'} ${amount} ${unit}`, position: position + 1\n };\n}\n"],"mappings":"2LAeA,MAAMA,kBAAQ,IAAI,IAAI,CAAC,MAAO,OAAQ,OAAQ,QAAS,SAAU,SAAS,CAAC,EACrE,QAAW,GAAuCC,IAAU,SAAWA,IAAU,MACjF,OAAU,GAAuCA,IAAU,IAAA,IAAa,oBAAoB,KAAKA,CAAK,EACtG,cAAgB,EAA2B,IAA8B,QAAQC,EAAOC,EAAS,GAAK,OAAOD,EAAOC,EAAW,EAAE,EACjI,SAAY,GAA4B,OAAO,cAAcC,CAAM,GAAKA,GAAU,WAClF,OAAU,GAAsCC,IAAS,IAAA,IAAaL,EAAM,IAAIK,CAAI,EAI1F,SAAgB,kBAAkB,EAAwB,EAA2B,EAAkB,EAA0C,CAE7I,OADIH,EAAOC,KAAc,QAAUD,EAAOC,EAAW,KAAO,KAAa,YAAYG,EAASJ,EAAQC,EAAW,EAAGI,CAAQ,EACrH,aAAaL,EAAQC,CAAQ,EAAI,YAAYG,EAASJ,EAAQC,EAAUI,CAAQ,EAAI,IAC/F,CAEA,SAAS,YAAY,EAAwB,EAA2B,EAAkB,EAAmC,CACzH,GAAIJ,GAAYD,EAAO,OAEnB,OADAI,EAAQ,MAAME,EAAgB,wBAAyB,sCAAuCD,CAAQ,EAC/F,CAAE,WAAY,KAAM,KAAM,GAAI,UAAS,EAElD,IAAME,EAAU,aAAaP,EAAQC,CAAQ,EACvC,YAAYG,EAASJ,EAAQC,EAAUI,CAAQ,EAC/C,CAAE,WAAYG,EAA0BR,EAAOC,GAAWI,EAAUD,CAAO,EAAG,KAAMJ,EAAOC,GAAW,SAAUA,EAAW,CAAE,EACnI,MAAO,CAAE,WAAYM,EAAQ,aAAe,KAAO,KAAO,CAAE,KAAM,yBAA0B,QAASA,EAAQ,WAAY,UAAS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../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{pattern as r}from"../Text/patterns.js";import{locationOf as i}from"./SourceLine.js";import{dependencySources as a}from"../Syntax/DependencySources.js";import{parseMappingSource as o}from"./ExpressionParser.js";import{isPendingHandler as s,validateHandlerOccurrences as c}from"./CommandHandlerValidator.js";import{firstWord as l}from"./LineText.js";import{reportInvalidModifierOrder as u,reportLegacyOptionalSuffix as d,tryParseProperty as f}from"./PropertyLineParser.js";import{combineAuthorize as p,parseAuthorize as m}from"./AuthorizeParser.js";import{parseDescription as h}from"./DescriptionParser.js";import{parseDocumentation as g}from"./DocumentationParser.js";import{parseCondition as _}from"./ConditionParser.js";import{ParserContext as v}from"./ParserContext.js";import{isReactionIdentityLine as y,misplacedReactionIdentity as b}from"./ReactionIdentityParser.js";import{sourceStreamPattern as x}from"../Text/SourceStreamNames.js";import{parseCommandStream as S}from"./EventSourceParser.js";import{isCode as C,isFile as w,parseCode as T,parseFile as E,parseHandler as D,parseImplementationWrapper as O}from"./ImplementationParser.js";import{parseCommandResponse as k,scalarResponsePattern as A}from"./CommandResponseParser.js";import{matchSubject as j,validateMatchOperand as M}from"./MatchOperandValidation.js";import{commandReadSources as N}from"./CommandReadSources.js";import{captureConcurrency as P}from"./DependencySourceParser.js";import{parseReads as F}from"./ReadsParser.js";import{parseProduces as I}from"./ProducesParser.js";const L=r(`^command\\s+([A-Za-z_]\\w*)$`),R=x(`^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$`),z=r(`\\bseverity\\s+(\\S+)$`),B=r(`\\bmessage\\s+(?:"(${t})"|(\\$strings\\.\\S*))$`),V=r(`^([\\w.]+)\\s+(.+)$`),H=r(`^(not empty|length ==|decimals <=|all >=|all >|matches|not contains|contains|starts with|ends with|max|min|rule|>=|<=|==|!=|>|<)\\s*(.*)$`),U=x(`^[A-Za-z_]\\w*$`),W=r(`^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 v(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,o){let d=L.exec(n.content)?.[1]??``;d===``&&t.error(e.InvalidCommandDeclaration,`Invalid command declaration '${n.content}' - expected 'command <Name>'`,i(n));let _=[],v=[],x,C=[],w=[],T=[],E=[],O,j=null,M=null,z=null,B=null,V=[],H=null,U=[];for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent)){t.reader.takeSignificant();let n=l(a.content),o=f(a);if(o!==void 0&&(J.has(n)||n===`validate`&&a.content!==`validate csharp`))x=addProperty(t,_,o,d,a,x);else if(n===`returns`){let e=A.exec(a.content);e!==null&&!e[1].startsWith(`@`)&&o!==void 0?r===void 0?(_.push(o),v.push({line:a,candidate:o,response:null})):r.has(o.type.name)?v.push({line:a,candidate:null,response:k(t,a)}):x=addProperty(t,_,o,d,a,x):o===void 0?u(t,a)?t.skipBlock(a.indent):v.push({line:a,candidate:null,response:k(t,a)}):x=addProperty(t,_,o,d,a,x)}else if(n===`stream`&&R.test(a.content)&&o!==void 0&&t.streamCandidates?.hasSource(o.type.name.split(`.`)[0])===!0){let[n,r]=o.type.name.split(`.`),s=t.streamCandidates.hasPropertyType(o.type.name)&&t.streamCandidates.hasUniqueStream(n,r),c=S(t,a,o,s);(H!==null||U.length>0)&&t.error(e.InvalidCommandStream,`A command declares at most one stream route.`,i(a)),s||H!==null?U.push(c):H=c}else if(n===`runs`&&y(a))b(t,a);else if(n===`description`)j=h(t,a,j,`Command '${d}'`);else if(n===`documentation`)M=g(t,a,M,`Command '${d}'`);else if(n===`authorize`)z=p(z,m(t,a));else if(n===`validate`){let e=parseValidate(t,a,`command`,d);e!==void 0&&C.push(e)}else if(n===`produces`){let e=I(t,a,!0);e!==void 0&&w.push(e)}else if(n===`handler`)B=D(t,a),V.push({handler:B,location:i(a)});else if(q.has(n)){let r=n===`reads`?F(t,a):void 0;r!==void 0&&E.push(r),n===`concurrency`&&O===void 0&&(O=P(t,a));let o=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(a.content);o!==null&&T.push({readModel:o[1],alias:o[2]??null}),W.test(a.content)&&t.error(e.OptionalReadsNotSupported,`Optional reads are not yet supported (see #308).`,i(a)),t.skipOpaqueBlock(a.indent)}else o===void 0?(u(t,a),t.error(e.UnknownCommandDirective,`Unexpected '${a.content}' in command body`,i(a)),t.skipBlock(a.indent)):x=addProperty(t,_,o,d,a,x)}let G=new Set(v.flatMap(e=>e.candidate===null?[]:[e.candidate])),K=new Set(_.filter(e=>!G.has(e)).map(e=>e.name));v.some(e=>e.candidate!==null&&!K.has(e.candidate.type.name)&&e.candidate.type.name!==`returns`)&&K.add(`returns`);for(let e of K)o?.add(e);let Y=null,X=/* @__PURE__ */ new Set;for(let n of v){let r=n.response;if(n.candidate!==null){if(!K.has(n.candidate.type.name))continue;X.add(n.candidate),r={kind:`ScalarCommandResponseSyntax`,source:{kind:`PropertyResponseSourceSyntax`,property:n.candidate.type.name,location:n.candidate.type.location},location:i(n.line)}}r!==null&&(Y===null?Y=r:t.error(e.InvalidCommandResponse,`A command declares at most one unconditional response.`,i(n.line)))}c(V,t),B!==null&&!s(B)&&w.length>0&&t.error(e.CommandWithProducesAndHandler,`Command '${d}' cannot declare both 'produces' and 'handler'`,i(n));let Z={kind:`CommandSyntax`,name:d,description:j,documentation:M,authorize:z,properties:_.filter(e=>!X.has(e)),validations:C,produces:w,handler:B,response:Y,stream:H,streamCandidates:U,location:i(n)};return N.set(Z,T),a.set(Z,{reads:E,concurrency:O}),Z}function addProperty(t,n,r,i,a,o){return d(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 parseValidate(t,r,a,o){if(r.content===`validate`){let s=t.peekChild(r.indent);if(s!==void 0&&s.content.startsWith("```")){t.reader.takeSignificant();let e=T(t.valueContext,s);return e===null&&t.skipFencedBody(),{kind:`CodeValidateSyntax`,code:e,location:i(r)}}let c=[],u=[],d;for(let s=t.peekChild(r.indent);s!==void 0;s=t.peekChild(r.indent)){if(t.reader.takeSignificant(),a===`concept`){if(t.sourceOptions.numericMode===`legacy`&&s.content.startsWith("```")){t.skipFencedBody();continue}if(d!==void 0&&s.indent<=d&&(d=void 0),d!==void 0||l(s.content)===`implementation`){t.error(e.InvalidValidationRule,`Invalid validation rule '${s.content}'`,i(s)),d??=s.indent;continue}}if(l(s.content)===`require`){let e=_(a===`concept`?t.valueContext:t,s.content.substring(7).trim(),i(s)),r=null,o=`Error`,c=!1;for(let e=t.peekChild(s.indent);e!==void 0;e=t.peekChild(s.indent)){t.reader.takeSignificant();let i=B.exec(e.content);i!==null&&i.index===0?r=i[1]===void 0?i[2]:n(i[1]):l(e.content)===`severity`?(c||(o=K[e.content.substring(8).trim()]??`Error`),c=!0):t.skipOpaqueBlock(e.indent)}e!==null&&u.push({kind:`RequirementSyntax`,condition:e,message:r,severity:o,location:i(s)});continue}let r=parseValidationRule(t,a===`concept`?{...s,content:`value ${s.content}`}:s,a,o);r!==void 0&&c.push(r)}return{kind:`DeclarativeValidateSyntax`,rules:c,requirements:u,location:i(r)}}if(a===`concept`&&l(r.content.substring(8).trimStart())===`checksum`){let e=parseValidationRule(t,{...r,content:`value ${r.content.substring(8).trimStart()}`},a,o);return e===void 0?void 0:{kind:`DeclarativeValidateSyntax`,rules:[e],requirements:[],location:i(r)}}if(r.content===`validate csharp`){let e=T(t.valueContext,{...r,content:`csharp`});return e===null&&t.skipOpaqueBlock(r.indent),{kind:`CodeValidateSyntax`,code:e,location:i(r)}}t.error(e.InvalidValidateDeclaration,`Invalid validate declaration '${r.content}' - expected 'validate' or 'validate csharp'`,i(r)),t.skipBlock(r.indent)}function parseValidationRule(t,n,r,a){let o=l(V.exec(n.content)?.[2]??``)===`checksum`,s=r===`concept`&&!o?t.valueContext:t,{content:c,message:u}=splitMessage(n.content),d=splitSeverity(s,n,c);if(d===void 0)return;let f=V.exec(d.content);if(f===null){s.error(e.InvalidValidationRule,`Invalid validation rule '${n.content}'`,i(n));return}let p=parseRule(s,f[2],n);if(p===void 0)return;p.kind===`Matches`&&p.value!==null&&M(t,p.value,i(n),n.raw,j(t,r,a,f[1]));let m=p.kind===`Rule`?parseRuleImplementation(t,n,r===`command`):{file:null,code:null,implementation:null};return{kind:`ValidationRuleSyntax`,property:f[1],rule:p.kind,value:p.value,message:u,severity:d.severity,...m,location:i(n)}}function parseRuleImplementation(t,n,r){let a=t.peekChild(n.indent);if(a===void 0)return{file:null,code:null,implementation:null};t.reader.takeSignificant();let o=r&&l(a.content)===`implementation`,s=o?O(t,a):{file:w(a)?E(t,a):null,code:!w(a)&&C(t,a)?T(t,a):null,implementation:null};!o&&s.file===null&&s.code===null&&(t.error(e.UnknownRuleImplementationDirective,`Unexpected '${a.content}' in rule implementation - expected 'file <path>' or an inline code block`,i(a)),t.skipBlock(a.indent));for(let a=t.peekChild(n.indent);a!==void 0&&(o||r&&l(a.content)===`implementation`);a=t.peekChild(n.indent))t.reader.takeSignificant(),t.error(o&&l(a.content)===`implementation`?e.InvalidImplementationBlock:e.ConflictingImplementationSources,`A named rule has one implementation wrapper and cannot mix wrapped and direct sources.`,i(a)),C(t,a)?T(t,a):t.skipBlock(a.indent);return s}function splitMessage(e){let t=B.exec(e);if(t===null)return{content:e,message:null};let r=t[1]===void 0?t[2]:n(t[1]);return{content:e.substring(0,t.index).trimEnd(),message:r}}function splitSeverity(t,n,r){let a=z.exec(r);if(a===null)return{content:r,severity:`Error`};let o=K[a[1]];if(o===void 0)t.error(e.InvalidValidationSeverity,`Unknown validation severity '${a[1]}' - expected information, warning or error`,i(n));else return{content:r.substring(0,a.index).trimEnd(),severity:o}}function parseRule(t,n,r){if(n===`not empty`)return{kind:`NotEmpty`,value:null};if(l(n)===`checksum`){let a=n.substring(8).trim();if(a!==`luhn`&&a!==`mod11`&&a!==`mod97`){t.error(e.InvalidGenerationArgument,`Checksum validation requires luhn, mod11 or mod97.`,i(r));return}return{kind:`Checksum`,value:{kind:`LiteralExpressionSyntax`,value:a,location:i(r)}}}let a=H.exec(n);if(a===null)t.error(e.InvalidValidationRule,`Invalid validation rule '${r.content}'`,i(r));else{if(a[1]===`rule`){let n=a[2].trim();if(!U.test(n)){t.error(e.InvalidRuleName,`Invalid rule name '${n}' in '${r.content}' - expected 'rule <Name>' with an identifier`,i(r));return}return{kind:`Rule`,value:{kind:`PathExpressionSyntax`,path:n,location:i(r)}}}return{kind:G[a[1]],value:o(a[2],i(r),t)}}}export{parseCommand,parseValidate};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{pattern as r}from"../Text/patterns.js";import{locationOf as i}from"./SourceLine.js";import{dependencySources as a}from"../Syntax/DependencySources.js";import{parseMappingSource as o}from"./ExpressionParser.js";import{isPendingHandler as s,validateHandlerOccurrences as c}from"./CommandHandlerValidator.js";import{firstWord as l}from"./LineText.js";import{reportInvalidModifierOrder as u,reportLegacyOptionalSuffix as d,tryParseProperty as f}from"./PropertyLineParser.js";import{combineAuthorize as p,parseAuthorize as m}from"./AuthorizeParser.js";import{parseDescription as h}from"./DescriptionParser.js";import{parseDocumentation as g}from"./DocumentationParser.js";import{parseCondition as _}from"./ConditionParser.js";import{ParserContext as v}from"./ParserContext.js";import{isReactionIdentityLine as y,misplacedReactionIdentity as b}from"./ReactionIdentityParser.js";import{sourceStreamPattern as x}from"../Text/SourceStreamNames.js";import{parseCommandStream as S}from"./EventSourceParser.js";import{isCode as C,isFile as w,parseCode as T,parseFile as E,parseHandler as D,parseImplementationWrapper as O}from"./ImplementationParser.js";import{parseCommandResponse as k,scalarResponsePattern as A}from"./CommandResponseParser.js";import{matchSubject as j,validateMatchOperand as M}from"./MatchOperandValidation.js";import{commandReadSources as N}from"./CommandReadSources.js";import{captureConcurrency as P}from"./DependencySourceParser.js";import{parseReads as F}from"./ReadsParser.js";import{parseProduces as I}from"./ProducesParser.js";const L=r(`^command\\s+([A-Za-z_]\\w*)$`),R=x(`^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$`),z=r(`^calendar\\s+(?:"|from\\s+\\$context\\.)`),B=r(`^calendar\\s+(?:"(${t})"|from\\s+\\$context\\.([A-Za-z_][A-Za-z0-9_]*(?:\\.[A-Za-z_][A-Za-z0-9_]*)*))$`),V=r(`\\bseverity\\s+(\\S+)$`),H=r(`\\bmessage\\s+(?:"(${t})"|(\\$strings\\.\\S*))$`),U=r(`^([\\w.]+)\\s+(.+)$`),W=r(`^(not empty|length ==|decimals <=|all >=|all >|matches|not contains|contains|starts with|ends with|max|min|rule|>=|<=|==|!=|>|<)\\s*(.*)$`),G=x(`^[A-Za-z_]\\w*$`),K=r(`^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)`),q={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`},J={information:`Information`,warning:`Warning`,error:`Error`},Y=/* @__PURE__ */ new Set([`reads`,`concurrency`]),ee=/* @__PURE__ */ new Set([`description`,`documentation`,`handler`,`concurrency`]);function parseCommand(e,t){let n=/* @__PURE__ */ new Set,r=new v(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,r,o,d){let _=L.exec(r.content)?.[1]??``;_===``&&t.error(e.InvalidCommandDeclaration,`Invalid command declaration '${r.content}' - expected 'command <Name>'`,i(r));let v=[],x=[],C,w=[],T=[],E=[],O=[],j,M=null,V=null,H=null,U=null,W=[],G=null,q=[],J=null;for(let a=t.peekChild(r.indent);a!==void 0;a=t.peekChild(r.indent)){t.reader.takeSignificant();let r=l(a.content),s=f(a);if(r===`calendar`&&z.test(a.content)){let r=B.exec(a.content);J!==null||r===null?t.error(e.InvalidCommandCalendar,`A command declares at most one 'calendar "<id>"' or 'calendar from $context.<member>'.`,i(a)):J={kind:`CommandCalendarSyntax`,id:r[1]===void 0?null:n(r[1]),contextMember:r[2]??null,location:i(a)}}else if(s!==void 0&&(ee.has(r)||r===`validate`&&a.content!==`validate csharp`))C=addProperty(t,v,s,_,a,C);else if(r===`returns`){let e=A.exec(a.content);e!==null&&!e[1].startsWith(`@`)&&s!==void 0?o===void 0?(v.push(s),x.push({line:a,candidate:s,response:null})):o.has(s.type.name)?x.push({line:a,candidate:null,response:k(t,a)}):C=addProperty(t,v,s,_,a,C):s===void 0?u(t,a)?t.skipBlock(a.indent):x.push({line:a,candidate:null,response:k(t,a)}):C=addProperty(t,v,s,_,a,C)}else if(r===`stream`&&R.test(a.content)&&s!==void 0&&t.streamCandidates?.hasSource(s.type.name.split(`.`)[0])===!0){let[n,r]=s.type.name.split(`.`),o=t.streamCandidates.hasPropertyType(s.type.name)&&t.streamCandidates.hasUniqueStream(n,r),c=S(t,a,s,o);(G!==null||q.length>0)&&t.error(e.InvalidCommandStream,`A command declares at most one stream route.`,i(a)),o||G!==null?q.push(c):G=c}else if(r===`runs`&&y(a))b(t,a);else if(r===`description`)M=h(t,a,M,`Command '${_}'`);else if(r===`documentation`)V=g(t,a,V,`Command '${_}'`);else if(r===`authorize`)H=p(H,m(t,a));else if(r===`validate`){let e=parseValidate(t,a,`command`,_);e!==void 0&&w.push(e)}else if(r===`produces`){let e=I(t,a,!0);e!==void 0&&T.push(e)}else if(r===`handler`)U=D(t,a),W.push({handler:U,location:i(a)});else if(Y.has(r)){let n=r===`reads`?F(t,a):void 0;n!==void 0&&O.push(n),r===`concurrency`&&j===void 0&&(j=P(t,a));let o=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(a.content);o!==null&&E.push({readModel:o[1],alias:o[2]??null}),K.test(a.content)&&t.error(e.OptionalReadsNotSupported,`Optional reads are not yet supported (see #308).`,i(a)),t.skipOpaqueBlock(a.indent)}else s===void 0?(u(t,a),t.error(e.UnknownCommandDirective,`Unexpected '${a.content}' in command body`,i(a)),t.skipBlock(a.indent)):C=addProperty(t,v,s,_,a,C)}let te=new Set(x.flatMap(e=>e.candidate===null?[]:[e.candidate])),X=new Set(v.filter(e=>!te.has(e)).map(e=>e.name));x.some(e=>e.candidate!==null&&!X.has(e.candidate.type.name)&&e.candidate.type.name!==`returns`)&&X.add(`returns`);for(let e of X)d?.add(e);let Z=null,Q=/* @__PURE__ */ new Set;for(let n of x){let r=n.response;if(n.candidate!==null){if(!X.has(n.candidate.type.name))continue;Q.add(n.candidate),r={kind:`ScalarCommandResponseSyntax`,source:{kind:`PropertyResponseSourceSyntax`,property:n.candidate.type.name,location:n.candidate.type.location},location:i(n.line)}}r!==null&&(Z===null?Z=r:t.error(e.InvalidCommandResponse,`A command declares at most one unconditional response.`,i(n.line)))}c(W,t),U!==null&&!s(U)&&T.length>0&&t.error(e.CommandWithProducesAndHandler,`Command '${_}' cannot declare both 'produces' and 'handler'`,i(r));let $={kind:`CommandSyntax`,name:_,description:M,documentation:V,authorize:H,properties:v.filter(e=>!Q.has(e)),validations:w,produces:T,handler:U,response:Z,stream:G,streamCandidates:q,...J===null?{}:{calendar:J},location:i(r)};return N.set($,E),a.set($,{reads:O,concurrency:j}),$}function addProperty(t,n,r,i,a,o){return d(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 parseValidate(t,r,a,o){if(r.content===`validate`){let s=t.peekChild(r.indent);if(s!==void 0&&s.content.startsWith("```")){t.reader.takeSignificant();let e=T(t.valueContext,s);return e===null&&t.skipFencedBody(),{kind:`CodeValidateSyntax`,code:e,location:i(r)}}let c=[],u=[],d;for(let s=t.peekChild(r.indent);s!==void 0;s=t.peekChild(r.indent)){if(t.reader.takeSignificant(),a===`concept`){if(t.sourceOptions.numericMode===`legacy`&&s.content.startsWith("```")){t.skipFencedBody();continue}if(d!==void 0&&s.indent<=d&&(d=void 0),d!==void 0||l(s.content)===`implementation`){t.error(e.InvalidValidationRule,`Invalid validation rule '${s.content}'`,i(s)),d??=s.indent;continue}}if(l(s.content)===`require`){let e=_(a===`concept`?t.valueContext:t,s.content.substring(7).trim(),i(s)),r=null,o=`Error`,c=!1;for(let e=t.peekChild(s.indent);e!==void 0;e=t.peekChild(s.indent)){t.reader.takeSignificant();let i=H.exec(e.content);i!==null&&i.index===0?r=i[1]===void 0?i[2]:n(i[1]):l(e.content)===`severity`?(c||(o=J[e.content.substring(8).trim()]??`Error`),c=!0):t.skipOpaqueBlock(e.indent)}e!==null&&u.push({kind:`RequirementSyntax`,condition:e,message:r,severity:o,location:i(s)});continue}let r=parseValidationRule(t,a===`concept`?{...s,content:`value ${s.content}`}:s,a,o);r!==void 0&&c.push(r)}return{kind:`DeclarativeValidateSyntax`,rules:c,requirements:u,location:i(r)}}if(a===`concept`&&l(r.content.substring(8).trimStart())===`checksum`){let e=parseValidationRule(t,{...r,content:`value ${r.content.substring(8).trimStart()}`},a,o);return e===void 0?void 0:{kind:`DeclarativeValidateSyntax`,rules:[e],requirements:[],location:i(r)}}if(r.content===`validate csharp`){let e=T(t.valueContext,{...r,content:`csharp`});return e===null&&t.skipOpaqueBlock(r.indent),{kind:`CodeValidateSyntax`,code:e,location:i(r)}}t.error(e.InvalidValidateDeclaration,`Invalid validate declaration '${r.content}' - expected 'validate' or 'validate csharp'`,i(r)),t.skipBlock(r.indent)}function parseValidationRule(t,n,r,a){let o=l(U.exec(n.content)?.[2]??``)===`checksum`,s=r===`concept`&&!o?t.valueContext:t,{content:c,message:u}=splitMessage(n.content),d=splitSeverity(s,n,c);if(d===void 0)return;let f=U.exec(d.content);if(f===null){s.error(e.InvalidValidationRule,`Invalid validation rule '${n.content}'`,i(n));return}let p=parseRule(s,f[2],n);if(p===void 0)return;p.kind===`Matches`&&p.value!==null&&M(t,p.value,i(n),n.raw,j(t,r,a,f[1]));let m=p.kind===`Rule`?parseRuleImplementation(t,n,r===`command`):{file:null,code:null,implementation:null};return{kind:`ValidationRuleSyntax`,property:f[1],rule:p.kind,value:p.value,message:u,severity:d.severity,...m,location:i(n)}}function parseRuleImplementation(t,n,r){let a=t.peekChild(n.indent);if(a===void 0)return{file:null,code:null,implementation:null};t.reader.takeSignificant();let o=r&&l(a.content)===`implementation`,s=o?O(t,a):{file:w(a)?E(t,a):null,code:!w(a)&&C(t,a)?T(t,a):null,implementation:null};!o&&s.file===null&&s.code===null&&(t.error(e.UnknownRuleImplementationDirective,`Unexpected '${a.content}' in rule implementation - expected 'file <path>' or an inline code block`,i(a)),t.skipBlock(a.indent));for(let a=t.peekChild(n.indent);a!==void 0&&(o||r&&l(a.content)===`implementation`);a=t.peekChild(n.indent))t.reader.takeSignificant(),t.error(o&&l(a.content)===`implementation`?e.InvalidImplementationBlock:e.ConflictingImplementationSources,`A named rule has one implementation wrapper and cannot mix wrapped and direct sources.`,i(a)),C(t,a)?T(t,a):t.skipBlock(a.indent);return s}function splitMessage(e){let t=H.exec(e);if(t===null)return{content:e,message:null};let r=t[1]===void 0?t[2]:n(t[1]);return{content:e.substring(0,t.index).trimEnd(),message:r}}function splitSeverity(t,n,r){let a=V.exec(r);if(a===null)return{content:r,severity:`Error`};let o=J[a[1]];if(o===void 0)t.error(e.InvalidValidationSeverity,`Unknown validation severity '${a[1]}' - expected information, warning or error`,i(n));else return{content:r.substring(0,a.index).trimEnd(),severity:o}}function parseRule(t,n,r){if(n===`not empty`)return{kind:`NotEmpty`,value:null};if(l(n)===`checksum`){let a=n.substring(8).trim();if(a!==`luhn`&&a!==`mod11`&&a!==`mod97`){t.error(e.InvalidGenerationArgument,`Checksum validation requires luhn, mod11 or mod97.`,i(r));return}return{kind:`Checksum`,value:{kind:`LiteralExpressionSyntax`,value:a,location:i(r)}}}let a=W.exec(n);if(a===null)t.error(e.InvalidValidationRule,`Invalid validation rule '${r.content}'`,i(r));else{if(a[1]===`rule`){let n=a[2].trim();if(!G.test(n)){t.error(e.InvalidRuleName,`Invalid rule name '${n}' in '${r.content}' - expected 'rule <Name>' with an identifier`,i(r));return}return{kind:`Rule`,value:{kind:`PathExpressionSyntax`,path:n,location:i(r)}}}return{kind:q[a[1]],value:o(a[2],i(r),t)}}}export{parseCommand,parseValidate};
2
2
  //# sourceMappingURL=CommandParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommandParser.js","names":["header","pattern","routeHeader","sourceStreamPattern","severityPattern","messagePattern","stringBodyPattern","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","handler","handlers","stream","streamCandidates","child","keyword","firstWord","asProperty","tryParseProperty","scalar","scalarResponsePattern","responseNames","parseCommandResponse","reportInvalidModifierOrder","source","streamName","ambiguous","route","parseCommandStream","isReactionIdentityLine","misplacedReactionIdentity","parseDescription","parseDocumentation","combineAuthorize","parseAuthorize","validate","production","parseProduces","parseHandler","reference","parseReads","captureConcurrency","read","candidates","entry","property","discoveredNames","response","removed","parsed","validateHandlerOccurrences","isPendingHandler","syntax","commandReadSources","dependencySources","reportLegacyOptionalSuffix","commandName","fence","code","parseCode","rules","requirements","wrapperIndent","owner","condition","parseCondition","message","severity","hasSeverity","directive","matched","unescapeString","rule","ownerName","checksum","valueContext","withSeverity","match","validateMatchOperand","matchSubject","body","wrapped","commandOwner","parseImplementationWrapper","isFile","parseFile","isCode","extra","content","text","algorithm","operand","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 { isPendingHandler, validateHandlerOccurrences } from './CommandHandlerValidator';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { RequirementSyntax } from '../Syntax/Conditions';\nimport { parseCondition } from './ConditionParser';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { CommandSyntax, ValidateSyntax, ValidationRuleKind, ValidationRuleSyntax, ValidationSeverity } from '../Syntax/Commands';\nimport { PropertySyntax } from '../Syntax/Declarations';\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';\n\nconst header = pattern('^command\\\\s+([A-Za-z_]\\\\w*)$');\nconst routeHeader = sourceStreamPattern('^stream\\\\s+[A-Za-z_]\\\\w*\\\\.[A-Za-z_]\\\\w*$');\nconst severityPattern = pattern('\\\\bseverity\\\\s+(\\\\S+)$');\nconst messagePattern = pattern(`\\\\bmessage\\\\s+(?:\"(${stringBodyPattern})\"|(\\\\$strings\\\\.\\\\S*))$`);\nconst rulePattern = pattern('^([\\\\w.]+)\\\\s+(.+)$');\nconst operandPattern = pattern('^(not empty|length ==|decimals <=|all >=|all >|matches|not contains|contains|starts with|ends with|max|min|rule|>=|<=|==|!=|>|<)\\\\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 handler: HandlerSyntax | null = null;\n const handlers: { handler: HandlerSyntax | null; location: SourceLocation }[] = [];\n let stream: CommandStreamSyntax | null = null;\n const streamCandidates: CommandStreamSyntax[] = [];\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 (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 authorize = combineAuthorize(authorize, parseAuthorize(context, child));\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`, 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 validateHandlerOccurrences(handlers, context);\n if (handler !== null && !isPendingHandler(handler) && produces.length > 0) {\n context.error(DiagnosticCodes.CommandWithProducesAndHandler, `Command '${name}' cannot declare both 'produces' and 'handler'`, locationOf(line));\n }\n const syntax: CommandSyntax = { kind: 'CommandSyntax', name, description, documentation, authorize, properties: properties.filter(property => !removed.has(property)), validations, produces, handler, response, stream, streamCandidates, 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\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 && 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 const condition = parseCondition(owner === 'concept' ? context.valueContext : context, child.content.substring('require'.length).trim(), locationOf(child));\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 if (operand[1] === 'rule') {\n const name = operand[2].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[operand[1]], value: parseMappingSource(operand[2], locationOf(line), context) };\n}\n"],"mappings":"ytDAsCA,MAAMA,EAASC,EAAQ,8BAA8B,EAC/CC,EAAcC,EAAoB,2CAA2C,EAC7EC,EAAkBH,EAAQ,wBAAwB,EAClDI,EAAiBJ,EAAQ,sBAAsBK,EAAkB,yBAAyB,EAC1FC,EAAcN,EAAQ,qBAAqB,EAC3CO,EAAiBP,EAAQ,2IAA2I,EACpKQ,EAAkBN,EAAoB,iBAAiB,EACvDO,EAAgBT,EAAQ,0CAA0C,EAGlEU,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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,CACA,MAAO,CAAE,KAAM,OAAQ,MAAO,CAAE,KAAM,uBAAwB,KAAMC,EAAM,SAAUE,EAAWH,CAAI,CAAE,CAAE,CAC3G,CACA,MAAO,CAAE,KAAMR,EAAawG,EAAQ,IAAK,MAAOC,EAAmBD,EAAQ,GAAI7F,EAAWH,CAAI,EAAGD,CAAO,CAAE,CAD1G,CAEJ"}
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","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","combineAuthorize","parseAuthorize","validate","production","parseProduces","parseHandler","reference","parseReads","captureConcurrency","read","candidates","entry","property","discoveredNames","response","removed","parsed","validateHandlerOccurrences","isPendingHandler","syntax","commandReadSources","dependencySources","reportLegacyOptionalSuffix","commandName","fence","code","parseCode","rules","requirements","wrapperIndent","owner","condition","parseCondition","message","severity","hasSeverity","directive","matched","rule","ownerName","checksum","valueContext","withSeverity","validateMatchOperand","matchSubject","body","wrapped","commandOwner","parseImplementationWrapper","isFile","parseFile","isCode","extra","content","text","algorithm","operand","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 { isPendingHandler, validateHandlerOccurrences } from './CommandHandlerValidator';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { RequirementSyntax } from '../Syntax/Conditions';\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';\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|length ==|decimals <=|all >=|all >|matches|not contains|contains|starts with|ends with|max|min|rule|>=|<=|==|!=|>|<)\\\\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 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 authorize = combineAuthorize(authorize, parseAuthorize(context, child));\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`, 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 validateHandlerOccurrences(handlers, context);\n if (handler !== null && !isPendingHandler(handler) && produces.length > 0) {\n context.error(DiagnosticCodes.CommandWithProducesAndHandler, `Command '${name}' cannot declare both 'produces' and 'handler'`, locationOf(line));\n }\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\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 && 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 const condition = parseCondition(owner === 'concept' ? context.valueContext : context, child.content.substring('require'.length).trim(), locationOf(child));\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 if (operand[1] === 'rule') {\n const name = operand[2].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[operand[1]], value: parseMappingSource(operand[2], locationOf(line), context) };\n}\n"],"mappings":"ytDAuCA,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,2IAA2I,EACpKU,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,mBAA2B,IAAI,IAAI,CAAC,cAAe,gBAAiB,UAAW,aAAa,CAAC,EAEnG,SAAgB,aAAa,EAAwB,EAAiC,CAGlF,IAAMC,kBAAQ,IAAI,IACZC,EAAY,IAAIC,EAAcC,EAAQ,OAAO,KAAK,EAA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ACZlG,EAAQ,MAAMG,EAAgB,sBAAuB,4BAA4BF,EAAK,QAAQ,GAAIG,EAAWH,CAAI,CAAC,MAGtH,IAAIiG,EAAQ,KAAO,OAAQ,CACvB,IAAMhG,EAAOgG,EAAQ,EAAE,CAAC,KAAK,EAC7B,GAAI,CAAC3G,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,EAAayG,EAAQ,IAAK,MAAOC,EAAmBD,EAAQ,GAAI9F,EAAWH,CAAI,EAAGD,CAAO,CAAE,CAD1G,CAEJ"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t}from"../Text/StringLiteral.js";import{dotNetWhitespace as n,nativePattern as r}from"../Text/patterns.js";import{parseModeledMappingSource as i}from"./ExpressionParser.js";const a={"==":`Equal`,"!=":`NotEqual`,">":`GreaterThan`,">=":`GreaterThanOrEqual`,"<":`LessThan`,"<=":`LessThanOrEqual`,contains:`Contains`,"starts with":`StartsWith`};function parseCondition(o,s,c,l=!1){l||(o=o.valueContext);let u=l?n:`\\s`,d=o.sourceOptions.numericMode===`exact`?`-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|${u}|[()])|`:``,f=o.sourceOptions.numericMode===`exact`&&!l?`[\\w.$-]+|[^\\s]`:`[\\w.$-]+`,p=new RegExp(r(`"${t}"|==|!=|>=|<=|>|<|\\(|\\)|${d}${f}`).source,`gu`);if(l){let t=s.replace(p,``).replace(new RegExp(n,`gu`),``);if(t.length>0)return o.error(e.UnsupportedActionConditionOperand,`Guarded action conditions contain unsupported character '${t[0]}'`,c),null}let m=s.match(p)??[],h=0,group=()=>{if(m[h]===`(`){h++;let t=or();return m[h]===`)`?h++:(l||o.sourceOptions.numericMode===`exact`)&&o.error(e.UnclosedConditionGroup,`Expected ')' in condition`,c),t}let t=m[h++];if(l&&t===void 0)return o.error(e.ExpectedCondition,`Expected a condition`,c),null;let n=m[h++];if(n===`starts`&&m[h]===`with`&&(n+=` with`,h++),l&&!Object.hasOwn(a,n))return o.error(e.ExpectedComparisonOperator,`Expected a comparison operator after '${t}'`,c),null;let r=m[h++];return l&&r===void 0?(o.error(e.ExpectedComparisonValue,`Expected a value to compare against`,c),null):t===void 0||r===void 0||a[n]===void 0?null:{kind:`ComparisonConditionSyntax`,left:t,operator:a[n],right:i(r,c,o),location:c}},and=()=>{let e=group();for(;e!==null&&m[h]===`and`;){h++;let t=group();if(t===null)return null;e={kind:`LogicalConditionSyntax`,left:e,operator:`And`,right:t,location:c}}return e},or=()=>{let e=and();for(;e!==null&&m[h]===`or`;){h++;let t=and();if(t===null)return null;e={kind:`LogicalConditionSyntax`,left:e,operator:`Or`,right:t,location:c}}return e},g=or();return(l||o.sourceOptions.numericMode===`exact`)&&(g===null&&!l?o.error(e.ExpectedCondition,`Expected a condition`,c):g!==null&&h<m.length&&o.error(e.UnexpectedTokenInCondition,`Unexpected '${m[h]}' in condition`,c)),g}export{parseCondition};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t}from"../Text/StringLiteral.js";import{dotNetWhitespace as n,nativePattern as r}from"../Text/patterns.js";import{parseModeledMappingSource as i}from"./ExpressionParser.js";import{parseClockOperand as a}from"./ClockOperandParser.js";const o={"==":`Equal`,"!=":`NotEqual`,">":`GreaterThan`,">=":`GreaterThanOrEqual`,"<":`LessThan`,"<=":`LessThanOrEqual`,contains:`Contains`,"starts with":`StartsWith`};function parseCondition(s,c,l,u=!1){let d=s;u||(s=s.valueContext);let f=u?n:`\\s`,p=s.sourceOptions.numericMode===`exact`?`-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|${f}|[()])|`:``,m=s.sourceOptions.numericMode===`exact`&&!u?`[\\w.$-]+|[^\\s]`:`[\\w.$-]+`,h=new RegExp(r(`"${t}"|==|!=|>=|<=|>|<|\\(|\\)|\\+|${p}${m}`).source,`gu`);if(u){let t=c.replace(h,``).replace(new RegExp(n,`gu`),``);if(t.length>0)return s.error(e.UnsupportedActionConditionOperand,`Guarded action conditions contain unsupported character '${t[0]}'`,l),null}let g=c.match(h)??[],_=0,operand=(e,t)=>{let n=a(d,g,_,l);if(n!==null)return n.expression===null?null:(_=n.position,n);let r=g[_++];return u&&r===void 0?(s.error(e,t,l),null):{text:r,expression:null}},group=()=>{if(g[_]===`(`){_++;let t=or();return g[_]===`)`?_++:(u||s.sourceOptions.numericMode===`exact`)&&s.error(e.UnclosedConditionGroup,`Expected ')' in condition`,l),t}let t=operand(e.ExpectedCondition,`Expected a condition`);if(t===null)return null;let{text:n,expression:r}=t,a=g[_++];if(a===`starts`&&g[_]===`with`&&(a+=` with`,_++),u&&!Object.hasOwn(o,a))return s.error(e.ExpectedComparisonOperator,`Expected a comparison operator after '${n}'`,l),null;let c=operand(e.ExpectedComparisonValue,`Expected a value to compare against`);if(c===null)return null;let{text:d,expression:f}=c;return n===void 0||d===void 0||o[a]===void 0?null:{kind:`ComparisonConditionSyntax`,left:n,...r===null?{}:{leftExpression:r},operator:o[a],right:f??i(d,l,s),location:l}},and=()=>{let e=group();for(;e!==null&&g[_]===`and`;){_++;let t=group();if(t===null)return null;e={kind:`LogicalConditionSyntax`,left:e,operator:`And`,right:t,location:l}}return e},or=()=>{let e=and();for(;e!==null&&g[_]===`or`;){_++;let t=and();if(t===null)return null;e={kind:`LogicalConditionSyntax`,left:e,operator:`Or`,right:t,location:l}}return e},v=or();return(u||s.sourceOptions.numericMode===`exact`)&&(v===null&&!u?s.error(e.ExpectedCondition,`Expected a condition`,l):v!==null&&_<g.length&&s.error(e.UnexpectedTokenInCondition,`Unexpected '${g[_]}' in condition`,l)),v}export{parseCondition};
2
2
  //# sourceMappingURL=ConditionParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionParser.js","names":["parseMappingSource","operators","strict","context","whitespace","dotNetWhitespace","numeric","words","regex","nativePattern","stringBodyPattern","unsupported","text","DiagnosticCodes","location","tokens","position","condition","left","operator","right","parseModeledMappingSource"],"sources":["../../../../../../Compiler/Parsing/ConditionParser.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 { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ComparisonOperator, ConditionSyntax } from '../Syntax/Conditions';\nimport { dotNetWhitespace, nativePattern } from '../Text/patterns';\nimport { stringBodyPattern } from '../Text/StringLiteral';\nimport { parseModeledMappingSource as parseMappingSource } from './ExpressionParser';\nimport { ParserContext } from './ParserContext';\n\nconst operators: Record<string, ComparisonOperator> = { '==': 'Equal', '!=': 'NotEqual', '>': 'GreaterThan', '>=': 'GreaterThanOrEqual', '<': 'LessThan', '<=': 'LessThanOrEqual', contains: 'Contains', 'starts with': 'StartsWith' };\n\n// The existing C# condition grammar: comparisons, left-associative and/or, and grouped conditions.\n// Previously omitted Legacy operands gain structure, not new parser diagnostics.\nexport function parseCondition(context: ParserContext, text: string, location: SourceLocation, strict = false): ConditionSyntax | null {\n if (!strict) context = context.valueContext;\n const whitespace = strict ? dotNetWhitespace : '\\\\s';\n const numeric = context.sourceOptions.numericMode === 'exact' ? `-?[0-9]+(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|${whitespace}|[()])|` : '';\n const words = context.sourceOptions.numericMode === 'exact' && !strict ? '[\\\\w.$-]+|[^\\\\s]' : '[\\\\w.$-]+';\n const regex = new RegExp(nativePattern(`\"${stringBodyPattern}\"|==|!=|>=|<=|>|<|\\\\(|\\\\)|${numeric}${words}`).source, 'gu');\n if (strict) {\n const unsupported = text.replace(regex, '').replace(new RegExp(dotNetWhitespace, 'gu'), '');\n if (unsupported.length > 0) {\n context.error(DiagnosticCodes.UnsupportedActionConditionOperand, `Guarded action conditions contain unsupported character '${unsupported[0]}'`, location);\n return null;\n }\n }\n const tokens = text.match(regex) ?? [];\n let position = 0;\n const group = (): ConditionSyntax | null => {\n if (tokens[position] === '(') {\n position++;\n const condition = or();\n if (tokens[position] === ')') position++;\n else if (strict || context.sourceOptions.numericMode === 'exact') context.error(DiagnosticCodes.UnclosedConditionGroup, \"Expected ')' in condition\", location);\n return condition;\n }\n const left = tokens[position++];\n if (strict && left === undefined) {\n context.error(DiagnosticCodes.ExpectedCondition, 'Expected a condition', location);\n return null;\n }\n let operator = tokens[position++];\n if (operator === 'starts' && tokens[position] === 'with') { operator += ' with'; position++; }\n if (strict && !Object.hasOwn(operators, operator)) {\n context.error(DiagnosticCodes.ExpectedComparisonOperator, `Expected a comparison operator after '${left}'`, location);\n return null;\n }\n const right = tokens[position++];\n if (strict && right === undefined) {\n context.error(DiagnosticCodes.ExpectedComparisonValue, 'Expected a value to compare against', location);\n return null;\n }\n return left === undefined || right === undefined || operators[operator] === undefined ? null : { kind: 'ComparisonConditionSyntax', left, operator: operators[operator], right: parseMappingSource(right, location, context), location };\n };\n const and = (): ConditionSyntax | null => {\n let left = group();\n while (left !== null && tokens[position] === 'and') {\n position++;\n const right = group();\n if (right === null) return null;\n left = { kind: 'LogicalConditionSyntax', left, operator: 'And', right, location };\n }\n return left;\n };\n const or = (): ConditionSyntax | null => {\n let left = and();\n while (left !== null && tokens[position] === 'or') {\n position++;\n const right = and();\n if (right === null) return null;\n left = { kind: 'LogicalConditionSyntax', left, operator: 'Or', right, location };\n }\n return left;\n };\n const condition = or();\n if (strict || context.sourceOptions.numericMode === 'exact') {\n if (condition === null && !strict) context.error(DiagnosticCodes.ExpectedCondition, 'Expected a condition', location);\n else if (condition !== null && position < tokens.length) context.error(DiagnosticCodes.UnexpectedTokenInCondition, `Unexpected '${tokens[position]}' in condition`, location);\n }\n return condition;\n}\n"],"mappings":"kUAWA,MAAMC,EAAgD,CAAE,KAAM,QAAS,KAAM,WAAY,IAAK,cAAe,KAAM,qBAAsB,IAAK,WAAY,KAAM,kBAAmB,SAAU,WAAY,cAAe,YAAa,EAIrO,SAAgB,eAAe,EAAwB,EAAc,EAA0B,EAAS,GAA+B,CAC9HC,IAAQ,EAAUC,EAAQ,cAC/B,IAAMC,EAAaF,EAASG,EAAmB,MACzCC,EAAUH,EAAQ,cAAc,cAAgB,QAAU,kDAAkDC,EAAW,SAAW,GAClIG,EAAQJ,EAAQ,cAAc,cAAgB,SAAW,CAACD,EAAS,mBAAqB,YACxFM,EAAQ,IAAI,OAAOC,EAAc,IAAIC,EAAkB,4BAA4BJ,IAAUC,GAAO,CAAC,CAAC,OAAQ,IAAI,EACxH,GAAIL,EAAQ,CACR,IAAMS,EAAcC,EAAK,QAAQJ,EAAO,EAAE,CAAC,CAAC,QAAQ,IAAI,OAAOH,EAAkB,IAAI,EAAG,EAAE,EAC1F,GAAIM,EAAY,OAAS,EAErB,OADAR,EAAQ,MAAMU,EAAgB,kCAAmC,4DAA4DF,EAAY,GAAG,GAAIG,CAAQ,EACjJ,IAEf,CACA,IAAMC,EAASH,EAAK,MAAMJ,CAAK,GAAK,CAAC,EACjCQ,EAAW,EACT,UAAsC,CACxC,GAAID,EAAOC,KAAc,IAAK,CAC1B,IACA,IAAMC,EAAY,GAAG,EAGrB,OAFIF,EAAOC,KAAc,IAAK,KACrBd,GAAUC,EAAQ,cAAc,cAAgB,UAASA,EAAQ,MAAMU,EAAgB,uBAAwB,4BAA6BC,CAAQ,EACtJG,CACX,CACA,IAAMC,EAAOH,EAAO,KACpB,GAAIb,GAAUgB,IAAS,IAAA,GAEnB,OADAf,EAAQ,MAAMU,EAAgB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,2BAA4B,eAAeE,EAAOC,GAAU,gBAAiBF,CAAQ,GAEzKG,CACX"}
1
+ {"version":3,"file":"ConditionParser.js","names":["parseMappingSource","operators","clockContext","context","strict","whitespace","dotNetWhitespace","numeric","words","regex","nativePattern","stringBodyPattern","unsupported","text","DiagnosticCodes","location","tokens","position","clock","parseClockOperand","missingCode","missingMessage","condition","leftOperand","left","leftExpression","operator","rightOperand","right","rightExpression","parseModeledMappingSource"],"sources":["../../../../../../Compiler/Parsing/ConditionParser.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 { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ComparisonOperator, ConditionSyntax } from '../Syntax/Conditions';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { parseClockOperand } from './ClockOperandParser';\nimport { dotNetWhitespace, nativePattern } from '../Text/patterns';\nimport { stringBodyPattern } from '../Text/StringLiteral';\nimport { parseModeledMappingSource as parseMappingSource } from './ExpressionParser';\nimport { ParserContext } from './ParserContext';\n\nconst operators: Record<string, ComparisonOperator> = { '==': 'Equal', '!=': 'NotEqual', '>': 'GreaterThan', '>=': 'GreaterThanOrEqual', '<': 'LessThan', '<=': 'LessThanOrEqual', contains: 'Contains', 'starts with': 'StartsWith' };\n\n// The existing C# condition grammar: comparisons, left-associative and/or, and grouped conditions.\n// Previously omitted Legacy operands gain structure, not new parser diagnostics.\nexport function parseCondition(context: ParserContext, text: string, location: SourceLocation, strict = false): ConditionSyntax | null {\n const clockContext = context;\n if (!strict) context = context.valueContext;\n const whitespace = strict ? dotNetWhitespace : '\\\\s';\n const numeric = context.sourceOptions.numericMode === 'exact' ? `-?[0-9]+(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|${whitespace}|[()])|` : '';\n const words = context.sourceOptions.numericMode === 'exact' && !strict ? '[\\\\w.$-]+|[^\\\\s]' : '[\\\\w.$-]+';\n const regex = new RegExp(nativePattern(`\"${stringBodyPattern}\"|==|!=|>=|<=|>|<|\\\\(|\\\\)|\\\\+|${numeric}${words}`).source, 'gu');\n if (strict) {\n const unsupported = text.replace(regex, '').replace(new RegExp(dotNetWhitespace, 'gu'), '');\n if (unsupported.length > 0) {\n context.error(DiagnosticCodes.UnsupportedActionConditionOperand, `Guarded action conditions contain unsupported character '${unsupported[0]}'`, location);\n return null;\n }\n }\n const tokens = text.match(regex) ?? [];\n let position = 0;\n const operand = (missingCode: string, missingMessage: string): { text: string; expression: ExpressionSyntax | null } | null => {\n const clock = parseClockOperand(clockContext, tokens, position, location);\n if (clock !== null) {\n if (clock.expression === null) return null;\n position = clock.position;\n return clock;\n }\n const text = tokens[position++];\n if (strict && text === undefined) {\n context.error(missingCode, missingMessage, location);\n return null;\n }\n return { text, expression: null };\n };\n const group = (): ConditionSyntax | null => {\n if (tokens[position] === '(') {\n position++;\n const condition = or();\n if (tokens[position] === ')') position++;\n else if (strict || context.sourceOptions.numericMode === 'exact') context.error(DiagnosticCodes.UnclosedConditionGroup, \"Expected ')' in condition\", location);\n return condition;\n }\n const leftOperand = operand(DiagnosticCodes.ExpectedCondition, 'Expected a condition');\n if (leftOperand === null) return null;\n const { text: left, expression: leftExpression } = leftOperand;\n let operator = tokens[position++];\n if (operator === 'starts' && tokens[position] === 'with') { operator += ' with'; position++; }\n if (strict && !Object.hasOwn(operators, operator)) {\n context.error(DiagnosticCodes.ExpectedComparisonOperator, `Expected a comparison operator after '${left}'`, location);\n return null;\n }\n const rightOperand = operand(DiagnosticCodes.ExpectedComparisonValue, 'Expected a value to compare against');\n if (rightOperand === null) return null;\n const { text: right, expression: rightExpression } = rightOperand;\n return left === undefined || right === undefined || operators[operator] === undefined ? null : { kind: 'ComparisonConditionSyntax', left, ...(leftExpression === null ? {} : { leftExpression }), operator: operators[operator], right: rightExpression ?? parseMappingSource(right, location, context), location };\n };\n const and = (): ConditionSyntax | null => {\n let left = group();\n while (left !== null && tokens[position] === 'and') {\n position++;\n const right = group();\n if (right === null) return null;\n left = { kind: 'LogicalConditionSyntax', left, operator: 'And', right, location };\n }\n return left;\n };\n const or = (): ConditionSyntax | null => {\n let left = and();\n while (left !== null && tokens[position] === 'or') {\n position++;\n const right = and();\n if (right === null) return null;\n left = { kind: 'LogicalConditionSyntax', left, operator: 'Or', right, location };\n }\n return left;\n };\n const condition = or();\n if (strict || context.sourceOptions.numericMode === 'exact') {\n if (condition === null && !strict) context.error(DiagnosticCodes.ExpectedCondition, 'Expected a condition', location);\n else if (condition !== null && position < tokens.length) context.error(DiagnosticCodes.UnexpectedTokenInCondition, `Unexpected '${tokens[position]}' in condition`, location);\n }\n return condition;\n}\n"],"mappings":"8XAaA,MAAMC,EAAgD,CAAE,KAAM,QAAS,KAAM,WAAY,IAAK,cAAe,KAAM,qBAAsB,IAAK,WAAY,KAAM,kBAAmB,SAAU,WAAY,cAAe,YAAa,EAIrO,SAAgB,eAAe,EAAwB,EAAc,EAA0B,EAAS,GAA+B,CACnI,IAAMC,EAAeC,EAChBC,IAAQ,EAAUD,EAAQ,cAC/B,IAAME,EAAaD,EAASE,EAAmB,MACzCC,EAAUJ,EAAQ,cAAc,cAAgB,QAAU,kDAAkDE,EAAW,SAAW,GAClIG,EAAQL,EAAQ,cAAc,cAAgB,SAAW,CAACC,EAAS,mBAAqB,YACxFK,EAAQ,IAAI,OAAOC,EAAc,IAAIC,EAAkB,gCAAgCJ,IAAUC,GAAO,CAAC,CAAC,OAAQ,IAAI,EAC5H,GAAIJ,EAAQ,CACR,IAAMQ,EAAcC,EAAK,QAAQJ,EAAO,EAAE,CAAC,CAAC,QAAQ,IAAI,OAAOH,EAAkB,IAAI,EAAG,EAAE,EAC1F,GAAIM,EAAY,OAAS,EAErB,OADAT,EAAQ,MAAMW,EAAgB,kCAAmC,4DAA4DF,EAAY,GAAG,GAAIG,CAAQ,EACjJ,IAEf,CACA,IAAMC,EAASH,EAAK,MAAMJ,CA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B,EAAOb,EAAUZ,CAAO,EAAG,UAAS,CACtT,EACM,QAAoC,CACtC,IAAIqB,EAAO,MAAM,EACjB,KAAOA,IAAS,MAAQR,EAAOC,KAAc,OAAO,CAChD,IACA,IAAMW,EAAQ,MAAM,EACpB,GAAIA,IAAU,KAAM,OAAO,KAC3B,EAAO,CAAE,KAAM,yBAA0B,OAAM,SAAU,MAAO,QAAO,UAAS,CACpF,CACA,OAAOJ,CACX,EACM,OAAmC,CACrC,IAAIA,EAAO,IAAI,EACf,KAAOA,IAAS,MAAQR,EAAOC,KAAc,MAAM,CAC/C,IACA,IAAMW,EAAQ,IAAI,EAClB,GAAIA,IAAU,KAAM,OAAO,KAC3B,EAAO,CAAE,KAAM,yBAA0B,OAAM,SAAU,KAAM,QAAO,UAAS,CACnF,CACA,OAAOJ,CACX,EACMF,EAAY,GAAG,EAKrB,OAJIlB,GAAUD,EAAQ,cAAc,cAAgB,WAC5CmB,IAAc,MAAQ,CAAClB,EAAQD,EAAQ,MAAMW,EAAgB,kBAAmB,uBAAwBC,CAAQ,EAC3GO,IAAc,MAAQL,EAAWD,EAAO,QAAQb,EAAQ,MAAMW,EAAgB,2BAA4B,eAAeE,EAAOC,GAAU,gBAAiBF,CAAQ,GAEzKO,CACX"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{eventDeclarations as t}from"../Syntax/EventDeclarations.js";import{AuthoringProductionResolver as n}from"../Syntax/AuthoringProductionResolver.js";import{dependencySourcesOf as r}from"../Syntax/DependencySources.js";import{ParserContext as i}from"./ParserContext.js";import{consumedEvents as a,isEventsSource as o}from"../Syntax/CaptureEventsSource.js";import{PublicEventUsageCollector as s}from"./PublicEventUsageCollector.js";import{validatePublicEventMetadata as c}from"./PublicEventMetadataValidator.js";import{validateCaptureEventFixtures as l}from"./CaptureEventFixturesValidator.js";function validatePublicEventUsage(t,r){c(t,r);let i=new n(t),a=new n(t,i.declarations.filter(e=>e.kind===`event`));for(let{slice:e,scope:n}of i.slices)validateOwnCaptureReactions(t,e,n,a,r);if(i.declarations.some(e=>e.node.kind===`EventSyntax`&&(e.node.visibility===`Public`||e.node.origin!=null))||t.imports.some(e=>e.visibility===`Public`||e.origin!=null)||i.slices.some(({slice:e})=>e.direction!=null||usesEventSource(e)||targetsEvent(e,i))){for(let{slice:e,scope:n}of i.slices)validateSlice(t,e,n,i,a,r);for(let n of t.seeds?.flatMap(e=>e.groups.flatMap(e=>e.events))??[]){let i=resolve(t,a,[],n.event,n,!0,r);if(i?.visibility!==`Public`)continue;let o=i.origin==null?e.PublicEventRequiresOutboundTranslation:e.ForeignPublicEventProduced;r.error(o,`Seed cannot append public event '${n.event}'; public production belongs to outbound translation, and foreign contracts cannot be produced locally.`,n.location)}}}function validateSlice(n,r,i,a,o,c){let u=new s;u.visitSlice(r);let d=[],f=r.type===`Translate`&&r.direction===`Outbound`,p=new Set(r.readModels.map(e=>e.name));for(let{target:t,node:a}of u.projectionTargets){let s=p.has(t)?void 0:resolve(n,o,i,t,a,!1,c);s!==void 0&&(f?(d.push({node:s,output:!0}),validateUse(r,t,a,!0,!1,s,c)):c.error(e.EventTargetOutsideOutboundTranslation,`'${t}' is an event: a projection or reducer may only target an event in an explicitly outbound Translate slice.`,a.location))}if((r.type!==`Translate`||r.direction!==`Inbound`)&&!f)for(let t of u.eventSources)c.error(e.EventsSourceOutsideInboundTranslation,`'source events' reads another application's public events and belongs to a Translate slice with 'direction inbound', not '${r.name}'.`,t.location);let m=/* @__PURE__ */ new Map;for(let e of u.uses){let t=resolve(n,e.node.kind===`ProducesSyntax`?a:o,i,e.name,e.node,e.output,c);t!==void 0&&(d.push({node:t,output:e.output}),validateUse(r,e.name,e.node,e.output,e.command,t,c),recordCaptureOrigin(e.node,t,m))}validateCaptureOrigins(r,m,c),l(r,i,o,c);for(let e of u.allEvents){let t=a.declarations.filter(e=>e.kind===`event`).map(e=>e.node);for(let i of[...t,...n.imports.filter(e=>e.visibility===`Public`)])d.push({node:i,output:!1}),validateUse(r,i.kind===`ImportSyntax`?i.qualifiedName:i.name,e,!1,!1,i,c)}if(r.type!==`Translate`||(r.direction==null&&(t(r).some(e=>e.visibility===`Public`)||d.some(e=>e.node.visibility===`Public`))&&c.error(e.PublicTranslationRequiresDirection,`A Translate slice using public events requires an explicit 'direction inbound' or 'direction outbound'. Legacy translations without public metadata remain inbound.`,r.location),r.direction!==`Outbound`))return;let h=new Set(d.filter(e=>e.output&&e.node.visibility===`Public`&&e.node.origin==null).map(e=>e.node)).size;h!==1&&c.error(e.OutboundPublicEventCount,`Outbound Translate slice '${r.name}' must produce exactly one local public event type; found ${h}.`,r.location);for(let t of r.captures)c.error(e.TranslationConstructDirection,`An outbound translation consumes private local events, not an external-data capture. Capture belongs to inbound translation.`,t.location)}function validateOwnCaptureReactions(t,n,r,a,o){if(n.type!==`Translate`||n.direction!=null)return;let c=new s;c.visitSlice(n);let l=new i(o.reader,o.path),u=new Set(c.uses.filter(e=>e.node.kind===`CaptureAppendSyntax`).map(e=>resolve(t,a,r,e.name,e.node,!0,l)).filter(e=>e!==void 0));for(let i of n.reactions.filter(e=>e.from==null)){let n=/* @__PURE__ */ new Map;for(let e of i.triggers){if(e.source.kind!==`NamedTriggerSourceSyntax`)continue;let i=e.source,o=resolve(t,a,r,i.name,i,!1,l);o!==void 0&&u.has(o)&&!n.has(o)&&n.set(o,i.name)}n.size!==0&&o.warning(e.DirectionlessTranslationReactsToOwnCapture,`Reaction '${i.name}' reacts to events appended by a capture in the same directionless Translate slice (${[...n.values()].join(`, `)}); keep the capture in this Translate slice and move the reaction to an Automation slice.`,i.location)}}function recordCaptureOrigin(e,t,n){if(e.kind!==`CaptureSourceSettingSyntax`)return;let r=publicOrigin(t);r!==void 0&&n.set(e,r)}function publicOrigin(e){if(e.visibility!==`Public`)return;let t=e.origin??``;return t.trim().length>0?t:void 0}function validateCaptureOrigins(t,n,r){for(let i of t.captures){let t=i.source;if(t==null||!o(t))continue;let s=[...new Set(a(t).flatMap(e=>{let t=n.get(e);return t==null?[]:[t]}))].sort();s.length<2||r.error(e.CaptureEventsFromSeveralOrigins,`The 'from' events of capture '${i.name}' originate from several event stores (${s.join(`, `)}); a capture reads one event store - split it into one capture per origin.`,t.location)}}function validateUse(t,n,r,i,a,o,s){let c=o.origin!=null,l=o.visibility===`Public`,error=(e,t)=>s.error(e,t,r.location);i?(a&&l&&error(e.CommandProducesPublicEvent,`Command cannot produce public event '${n}'; publish through an outbound Translate slice.`),t.type===`Translate`&&t.direction===`Outbound`&&!l&&error(e.OutboundTranslationOutput,`Outbound translation must produce its one local public event, not private event '${n}'.`),c&&error(e.ForeignPublicEventProduced,`Foreign public event '${n}' cannot be produced locally; translate it into a private local event.`),l&&!c&&(t.type!==`Translate`||t.direction!==`Outbound`)&&error(e.PublicEventRequiresOutboundTranslation,`Local public event '${n}' may only be produced by an explicitly outbound Translate slice.`),t.type===`Translate`&&(t.direction??`Inbound`)===`Inbound`&&(l||c)&&error(e.InboundTranslationOutput,`Inbound translation must produce private local events, not '${n}'.`)):(c&&(t.type!==`Translate`||t.direction!==`Inbound`)&&error(e.ForeignPublicEventConsumer,`Foreign public event '${n}' may only be consumed by an explicitly inbound Translate slice.`),t.type===`Translate`&&t.direction===`Outbound`&&(l||c)&&error(e.OutboundTranslationInput,`Outbound translation must consume private local events, not '${n}'.`),t.type===`Translate`&&t.direction===`Inbound`&&(!l||!c)&&error(e.InboundTranslationInput,`Explicitly inbound translation must consume foreign public events, not '${n}'.`))}function resolve(t,n,r,i,a,o,s){let c=n.resolveFromScope(i,r);if(c.declaration?.node.kind===`EventSyntax`)return c.declaration.node;if(c.kind===`operation`)return;if(c.kind===`ambiguous`){s.warning(e.AmbiguousReference,`Ambiguous event reference '${i}'; qualify it with its owning module, feature and slice.`,a.location);return}let l=t.imports.filter(e=>e.qualifiedName.split(`.`).at(-1)===i||e.qualifiedName===i);if(l.length===1){let t=l[0],o=n.resolveFromScope(t.qualifiedName,r);if(o.declaration?.node.kind===`EventSyntax`)return o.declaration.node;if(o.kind===`ambiguous`){s.warning(e.AmbiguousReference,`Ambiguous imported event reference '${i}'; qualify its declaration.`,a.location);return}return t.visibility===`Public`?t:void 0}l.length>1?s.warning(e.AmbiguousReference,`Ambiguous imported event reference '${i}'; use its qualified name.`,a.location):(o&&a.kind!==`CaptureAppendSyntax`||a.kind===`CaptureSourceSettingSyntax`)&&!s.diagnostics.some(t=>t.code===e.UnknownEvent&&t.location.path===a.location.path&&t.location.line===a.location.line&&t.location.column===a.location.column)&&s.warning(e.UnknownEvent,`Unknown event '${i}' - declare its contract before classifying its usage.`,a.location)}function usesEventSource(e){return e.captures.some(e=>e.source!=null&&o(e.source))}function targetsEvent(e,t){return[...e.projections.map(e=>e.readModel),...(r(e).reducers??[]).map(e=>e.readModel)].some(e=>e!=null&&t.declarations.some(t=>t.kind===`event`&&t.name===e))}export{validatePublicEventUsage};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{eventDeclarations as t}from"../Syntax/EventDeclarations.js";import{AuthoringProductionResolver as n}from"../Syntax/AuthoringProductionResolver.js";import{dependencySourcesOf as r}from"../Syntax/DependencySources.js";import{ParserContext as i}from"./ParserContext.js";import{consumedEvents as a,isEventsSource as o}from"../Syntax/CaptureEventsSource.js";import{PublicEventUsageCollector as s}from"./PublicEventUsageCollector.js";import{validatePublicEventMetadata as c}from"./PublicEventMetadataValidator.js";import{validateCaptureEventFixtures as l,validateEventSourceKeys as u}from"./CaptureEventFixturesValidator.js";function validatePublicEventUsage(t,r){c(t,r);let i=new n(t),a=new n(t,i.declarations.filter(e=>e.kind===`event`));for(let{slice:e,scope:n}of i.slices)validateOwnCaptureReactions(t,e,n,a,r),u(e,r);if(i.declarations.some(e=>e.node.kind===`EventSyntax`&&(e.node.visibility===`Public`||e.node.origin!=null))||t.imports.some(e=>e.visibility===`Public`||e.origin!=null)||i.slices.some(({slice:e})=>e.direction!=null||usesEventSource(e)||targetsEvent(e,i))){for(let{slice:e,scope:n}of i.slices)validateSlice(t,e,n,i,a,r);for(let n of t.seeds?.flatMap(e=>e.groups.flatMap(e=>e.events))??[]){let i=resolve(t,a,[],n.event,n,!0,r);if(i?.visibility!==`Public`)continue;let o=i.origin==null?e.PublicEventRequiresOutboundTranslation:e.ForeignPublicEventProduced;r.error(o,`Seed cannot append public event '${n.event}'; public production belongs to outbound translation, and foreign contracts cannot be produced locally.`,n.location)}}}function validateSlice(n,r,i,a,o,c){let u=new s;u.visitSlice(r);let d=[],f=r.type===`Translate`&&r.direction===`Outbound`,p=new Set(r.readModels.map(e=>e.name));for(let{target:t,node:a}of u.projectionTargets){let s=p.has(t)?void 0:resolve(n,o,i,t,a,!1,c);s!==void 0&&(f?(d.push({node:s,output:!0}),validateUse(r,t,a,!0,!1,s,c)):c.error(e.EventTargetOutsideOutboundTranslation,`'${t}' is an event: a projection or reducer may only target an event in an explicitly outbound Translate slice.`,a.location))}if((r.type!==`Translate`||r.direction!==`Inbound`)&&!f)for(let t of u.eventSources)c.error(e.EventsSourceOutsideInboundTranslation,`'source events' reads another application's public events and belongs to a Translate slice with 'direction inbound', not '${r.name}'.`,t.location);let m=/* @__PURE__ */ new Map;for(let e of u.uses){let t=resolve(n,e.node.kind===`ProducesSyntax`?a:o,i,e.name,e.node,e.output,c);t!==void 0&&(d.push({node:t,output:e.output}),validateUse(r,e.name,e.node,e.output,e.command,t,c),recordCaptureOrigin(e.node,t,m))}validateCaptureOrigins(r,m,c),l(r,i,o,c);for(let e of u.allEvents){let t=a.declarations.filter(e=>e.kind===`event`).map(e=>e.node);for(let i of[...t,...n.imports.filter(e=>e.visibility===`Public`)])d.push({node:i,output:!1}),validateUse(r,i.kind===`ImportSyntax`?i.qualifiedName:i.name,e,!1,!1,i,c)}if(r.type!==`Translate`||(r.direction==null&&(t(r).some(e=>e.visibility===`Public`)||d.some(e=>e.node.visibility===`Public`))&&c.error(e.PublicTranslationRequiresDirection,`A Translate slice using public events requires an explicit 'direction inbound' or 'direction outbound'. Legacy translations without public metadata remain inbound.`,r.location),r.direction!==`Outbound`))return;let h=new Set(d.filter(e=>e.output&&e.node.visibility===`Public`&&e.node.origin==null).map(e=>e.node)).size;h!==1&&c.error(e.OutboundPublicEventCount,`Outbound Translate slice '${r.name}' must produce exactly one local public event type; found ${h}.`,r.location);for(let t of r.captures)c.error(e.TranslationConstructDirection,`An outbound translation consumes private local events, not an external-data capture. Capture belongs to inbound translation.`,t.location)}function validateOwnCaptureReactions(t,n,r,a,o){if(n.type!==`Translate`||n.direction!=null)return;let c=new s;c.visitSlice(n);let l=new i(o.reader,o.path),u=new Set(c.uses.filter(e=>e.node.kind===`CaptureAppendSyntax`).map(e=>resolve(t,a,r,e.name,e.node,!0,l)).filter(e=>e!==void 0));for(let i of n.reactions.filter(e=>e.from==null)){let n=/* @__PURE__ */ new Map;for(let e of i.triggers){if(e.source.kind!==`NamedTriggerSourceSyntax`)continue;let i=e.source,o=resolve(t,a,r,i.name,i,!1,l);o!==void 0&&u.has(o)&&!n.has(o)&&n.set(o,i.name)}n.size!==0&&o.warning(e.DirectionlessTranslationReactsToOwnCapture,`Reaction '${i.name}' reacts to events appended by a capture in the same directionless Translate slice (${[...n.values()].join(`, `)}); keep the capture in this Translate slice and move the reaction to an Automation slice.`,i.location)}}function recordCaptureOrigin(e,t,n){if(e.kind!==`CaptureSourceSettingSyntax`)return;let r=publicOrigin(t);r!==void 0&&n.set(e,r)}function publicOrigin(e){if(e.visibility!==`Public`)return;let t=e.origin??``;return t.trim().length>0?t:void 0}function validateCaptureOrigins(t,n,r){for(let i of t.captures){let t=i.source;if(t==null||!o(t))continue;let s=[...new Set(a(t).flatMap(e=>{let t=n.get(e);return t==null?[]:[t]}))].sort();s.length<2||r.error(e.CaptureEventsFromSeveralOrigins,`The 'from' events of capture '${i.name}' originate from several event stores (${s.join(`, `)}); a capture reads one event store - split it into one capture per origin.`,t.location)}}function validateUse(t,n,r,i,a,o,s){let c=o.origin!=null,l=o.visibility===`Public`,error=(e,t)=>s.error(e,t,r.location);i?(a&&l&&error(e.CommandProducesPublicEvent,`Command cannot produce public event '${n}'; publish through an outbound Translate slice.`),t.type===`Translate`&&t.direction===`Outbound`&&!l&&error(e.OutboundTranslationOutput,`Outbound translation must produce its one local public event, not private event '${n}'.`),c&&error(e.ForeignPublicEventProduced,`Foreign public event '${n}' cannot be produced locally; translate it into a private local event.`),l&&!c&&(t.type!==`Translate`||t.direction!==`Outbound`)&&error(e.PublicEventRequiresOutboundTranslation,`Local public event '${n}' may only be produced by an explicitly outbound Translate slice.`),t.type===`Translate`&&(t.direction??`Inbound`)===`Inbound`&&(l||c)&&error(e.InboundTranslationOutput,`Inbound translation must produce private local events, not '${n}'.`)):(c&&(t.type!==`Translate`||t.direction!==`Inbound`)&&error(e.ForeignPublicEventConsumer,`Foreign public event '${n}' may only be consumed by an explicitly inbound Translate slice.`),t.type===`Translate`&&t.direction===`Outbound`&&(l||c)&&error(e.OutboundTranslationInput,`Outbound translation must consume private local events, not '${n}'.`),t.type===`Translate`&&t.direction===`Inbound`&&(!l||!c)&&error(e.InboundTranslationInput,`Explicitly inbound translation must consume foreign public events, not '${n}'.`))}function resolve(t,n,r,i,a,o,s){let c=n.resolveFromScope(i,r);if(c.declaration?.node.kind===`EventSyntax`)return c.declaration.node;if(c.kind===`operation`)return;if(c.kind===`ambiguous`){s.warning(e.AmbiguousReference,`Ambiguous event reference '${i}'; qualify it with its owning module, feature and slice.`,a.location);return}let l=t.imports.filter(e=>e.qualifiedName.split(`.`).at(-1)===i||e.qualifiedName===i);if(l.length===1){let t=l[0],o=n.resolveFromScope(t.qualifiedName,r);if(o.declaration?.node.kind===`EventSyntax`)return o.declaration.node;if(o.kind===`ambiguous`){s.warning(e.AmbiguousReference,`Ambiguous imported event reference '${i}'; qualify its declaration.`,a.location);return}return t.visibility===`Public`?t:void 0}l.length>1?s.warning(e.AmbiguousReference,`Ambiguous imported event reference '${i}'; use its qualified name.`,a.location):(o&&a.kind!==`CaptureAppendSyntax`||a.kind===`CaptureSourceSettingSyntax`)&&!s.diagnostics.some(t=>t.code===e.UnknownEvent&&t.location.path===a.location.path&&t.location.line===a.location.line&&t.location.column===a.location.column)&&s.warning(e.UnknownEvent,`Unknown event '${i}' - declare its contract before classifying its usage.`,a.location)}function usesEventSource(e){return e.captures.some(e=>e.source!=null&&o(e.source))}function targetsEvent(e,t){return[...e.projections.map(e=>e.readModel),...(r(e).reducers??[]).map(e=>e.readModel)].some(e=>e!=null&&t.declarations.some(t=>t.kind===`event`&&t.name===e))}export{validatePublicEventUsage};
2
2
  //# sourceMappingURL=PublicEventUsageValidator.js.map