@cratis/screenplay-language 4.125.0 → 4.127.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/Authoring/QuickFixes.js +2 -2
  2. package/dist/bundles/compiler/Authoring/QuickFixes.js.map +1 -1
  3. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
  4. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
  5. package/dist/bundles/compiler/Parsing/CaptureParser.js +1 -1
  6. package/dist/bundles/compiler/Parsing/CommandParser.js +1 -1
  7. package/dist/bundles/compiler/Parsing/CommandResponseParser.js +1 -1
  8. package/dist/bundles/compiler/Parsing/CompositionParser.js +1 -1
  9. package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js +1 -1
  10. package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js.map +1 -1
  11. package/dist/bundles/compiler/Parsing/ConditionParser.js +1 -1
  12. package/dist/bundles/compiler/Parsing/ConstraintParser.js +1 -1
  13. package/dist/bundles/compiler/Parsing/DeclarationParsers.js +1 -1
  14. package/dist/bundles/compiler/Parsing/DependencySourceParser.js +1 -1
  15. package/dist/bundles/compiler/Parsing/DescriptionParser.js +1 -1
  16. package/dist/bundles/compiler/Parsing/EventMetadataParser.js +1 -1
  17. package/dist/bundles/compiler/Parsing/EventSourceParser.js +1 -1
  18. package/dist/bundles/compiler/Parsing/ExpressionParser.js +1 -1
  19. package/dist/bundles/compiler/Parsing/FeatureBody.js +1 -1
  20. package/dist/bundles/compiler/Parsing/GuardedActionParser.js +1 -1
  21. package/dist/bundles/compiler/Parsing/IdentityParser.js +1 -1
  22. package/dist/bundles/compiler/Parsing/ImplementationParser.js +2 -2
  23. package/dist/bundles/compiler/Parsing/InputUses.js +1 -1
  24. package/dist/bundles/compiler/Parsing/InteractionAlternatives.js +1 -1
  25. package/dist/bundles/compiler/Parsing/ModuleBody.js +1 -1
  26. package/dist/bundles/compiler/Parsing/OperationParser.js +1 -1
  27. package/dist/bundles/compiler/Parsing/PolicyParser.js +1 -1
  28. package/dist/bundles/compiler/Parsing/ProducesParser.js +1 -1
  29. package/dist/bundles/compiler/Parsing/ProjectionParser.js +1 -1
  30. package/dist/bundles/compiler/Parsing/PropertyLineParser.js +1 -1
  31. package/dist/bundles/compiler/Parsing/PurposeParser.js +1 -1
  32. package/dist/bundles/compiler/Parsing/QueryParser.js +1 -1
  33. package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js +1 -1
  34. package/dist/bundles/compiler/Parsing/ReactionParser.js +1 -1
  35. package/dist/bundles/compiler/Parsing/ScreenParser.js +1 -1
  36. package/dist/bundles/compiler/Parsing/ScreenplayParser.js +1 -1
  37. package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -1
  38. package/dist/bundles/compiler/Parsing/SeedParser.js +1 -1
  39. package/dist/bundles/compiler/Parsing/SliceParser.js +1 -1
  40. package/dist/bundles/compiler/Parsing/SourceOptionsParser.js +1 -1
  41. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js +1 -1
  42. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js +1 -1
  43. package/dist/bundles/compiler/Parsing/SpecificationParser.js +1 -1
  44. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js +1 -1
  45. package/dist/bundles/compiler/Parsing/TriggerDataParser.js +1 -1
  46. package/dist/bundles/compiler/index.js +1 -1
  47. package/dist/bundles/diagnostic-codes.js +1 -1
  48. package/dist/bundles/diagnostic-codes.js.map +1 -1
  49. package/dist/bundles/validation.js +1 -1
  50. package/dist/bundles/validation.js.map +1 -1
  51. package/dist/diagnostic-codes.d.ts +1 -0
  52. package/dist/diagnostic-codes.d.ts.map +1 -1
  53. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ConceptComplianceParser.js","names":["specialCategories","directivePattern","pattern","reasonPattern","stringBodyPattern","name","marker","markers","text","context","line","DiagnosticCodes","locationOf","match","setting","value","canonical","index","attributes","attribute","concept","reason","unescapeString"],"sources":["../../../../../../Compiler/Parsing/ConceptComplianceParser.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 { ConceptAttributeSyntax } from '../Syntax/Declarations';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { pattern } from '../Text/patterns';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nexport const specialCategories = ['racialOrEthnicOrigin', 'politicalOpinions', 'religiousOrPhilosophicalBeliefs', 'tradeUnionMembership', 'genetic', 'biometric', 'health', 'sexLifeOrSexualOrientation'];\nconst directivePattern = pattern('^(@?[a-z_]\\\\w*)\\\\s+(reason|scope|special|criminal)(?:\\\\s+(.*))?$');\nconst reasonPattern = pattern(`^\"(${stringBodyPattern})\"$`);\n\nexport function complianceWireName(marker: string): string {\n const name = marker.replace(/^@/, '');\n return name === 'personal' ? 'pii' : name === 'secret' ? 'sensitive' : name;\n}\n\nexport function canonicalComplianceName(marker: string): string {\n const name = complianceWireName(marker);\n return name === 'sensitive' ? 'secret' : name;\n}\n\nexport function parseComplianceMarkers(context: ParserContext, line: SourceLine, text: string): ConceptAttributeSyntax[] {\n const markers = text.trim().split(/\\s+/).filter(marker => marker.length > 0);\n reportLegacy(context, line, markers);\n return markers.map(marker => {\n const name = complianceWireName(marker);\n if (!['pii', 'sensitive'].includes(name) || marker === '@personal' || marker === '@secret') {\n context.error(DiagnosticCodes.UnknownComplianceMarker, `Unknown concept marker '${marker}' - expected pii, personal or secret`, locationOf(line));\n }\n return { kind: 'ConceptAttributeSyntax', name, reason: null, scope: null, specialCategory: null, criminal: false, location: locationOf(line) };\n });\n}\n\nexport function parseComplianceDirective(context: ParserContext, line: SourceLine, concept: string, attributes: ConceptAttributeSyntax[]): boolean {\n const match = directivePattern.exec(line.content);\n if (match === null) return false;\n const [, marker, setting] = match;\n const value = match[3] ?? '';\n const name = complianceWireName(marker);\n const canonical = canonicalComplianceName(marker);\n reportLegacy(context, line, [marker]);\n if (!['pii', 'sensitive'].includes(name) || marker === '@personal' || marker === '@secret') {\n context.error(DiagnosticCodes.UnknownComplianceMarker, `Unknown concept marker '${marker}' - expected pii, personal or secret`, locationOf(line));\n return true;\n }\n const index = attributes.findIndex(attribute => attribute.name === name);\n if (index < 0) {\n context.error(DiagnosticCodes.AttributeReasonWithoutAttribute, `Concept '${concept}' declares '${canonical} ${setting}' without the marker - write 'concept ${concept} : <Type> ${canonical}'`, locationOf(line));\n return true;\n }\n const attribute = attributes[index];\n switch (setting) {\n case 'reason': {\n const reason = reasonPattern.exec(value);\n if (reason === null) {\n context.error(DiagnosticCodes.UnknownConceptDirective, `Invalid '${canonical} reason' - expected '${canonical} reason \"<text>\"'`, locationOf(line));\n return true;\n }\n if (attribute.reason !== null) {\n context.error(DiagnosticCodes.DuplicateAttributeReason, `Concept '${concept}' already declares a reason for '${canonical}' - at most one is allowed`, locationOf(line));\n return true;\n }\n attributes[index] = { ...attribute, reason: unescapeString(reason[1]) };\n return true;\n }\n case 'scope':\n if (name !== 'sensitive' || !['subject', 'namespace', 'global'].includes(value)) {\n context.error(DiagnosticCodes.InvalidSecretScope, `Invalid '${canonical} scope ${value}' - scope belongs to secret and must be subject, namespace or global`, locationOf(line));\n return true;\n }\n if (attribute.scope != null) {\n context.error(DiagnosticCodes.DuplicateSecretScope, `Concept '${concept}' already declares secret scope - at most one is allowed`, locationOf(line));\n return true;\n }\n attributes[index] = { ...attribute, scope: value };\n if (attributes.some(attribute => attribute.name === 'pii')) {\n context.warning(DiagnosticCodes.SecretScopeIgnoredForPii, `Concept '${concept}' is pii secret - secret scope is ignored because only Chronicle [PII] renders`, locationOf(line));\n }\n return true;\n case 'special':\n case 'criminal':\n if (name !== 'pii' || (setting === 'special' ? !specialCategories.includes(value) : value.length > 0)) {\n context.error(DiagnosticCodes.InvalidPersonalDataQualifier, `Invalid '${canonical} ${setting}${value.length > 0 ? ` ${value}` : ''}' - expected 'pii criminal' or 'pii special <category>' with category ${specialCategories.join(', ')}`, locationOf(line));\n return true;\n }\n if (setting === 'special' && attribute.specialCategory != null) {\n context.error(DiagnosticCodes.DuplicateSpecialCategory, `Concept '${concept}' already declares pii special - at most one is allowed`, locationOf(line));\n return true;\n }\n attributes[index] = setting === 'special' ? { ...attribute, specialCategory: value } : { ...attribute, criminal: true };\n return true;\n default:\n return false;\n }\n}\n\nfunction reportLegacy(context: ParserContext, line: SourceLine, markers: readonly string[]): void {\n if (markers.some(marker => ['@pii', 'sensitive', '@sensitive'].includes(marker))) {\n context.information(DiagnosticCodes.LegacyComplianceMarker, 'Legacy compliance spelling - use bare pii for personal data and secret for operational secrets; reason text is preserved', locationOf(line));\n }\n}\n"],"mappings":"qSAUA,MAAaA,EAAoB,CAAC,uBAAwB,oBAAqB,kCAAmC,uBAAwB,UAAW,YAAa,SAAU,4BAA4B,EAClMC,EAAmBC,EAAQ,kEAAkE,EAC7FC,EAAgBD,EAAQ,MAAME,EAAkB,IAAI,EAE1D,SAAgB,mBAAmB,EAAwB,CACvD,IAAMC,EAAOC,EAAO,QAAQ,KAAM,EAAE,EACpC,OAAOD,IAAS,WAAa,MAAQA,IAAS,SAAW,YAAcA,CAC3E,CAEA,SAAgB,wBAAwB,EAAwB,CAC5D,IAAMA,EAAO,mBAAmBC,CAAM,EACtC,OAAOD,IAAS,YAAc,SAAWA,CAC7C,CAEA,SAAgB,uBAAuB,EAAwB,EAAkB,EAAwC,CACrH,IAAME,EAAUC,EAAK,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,GAAUF,EAAO,OAAS,CAAC,EAE3E,OADA,aAAaG,EAASC,EAAMH,CAAO,EAC5BA,EAAQ,IAAI,GAAU,CACzB,IAAMF,EAAO,mBAAmBC,CAAM,EAItC,OAHI,CAAC,CAAC,MAAO,WAAW,CAAC,CAAC,SAASD,CAAI,GAAKC,IAAW,aAAeA,IAAW,YAC7EG,EAAQ,MAAME,EAAgB,wBAAyB,2BAA2BL,EAAO,sCAAuCM,EAAWF,CAAI,CAAC,EAE7I,CAAE,KAAM,yBAA0B,OAAM,OAAQ,KAAM,MAAO,KAAM,gBAAiB,KAAM,SAAU,GAAO,SAAUE,EAAWF,CAAI,CAAE,CACjJ,CAAC,CACL,CAEA,SAAgB,yBAAyB,EAAwB,EAAkB,EAAiB,EAA+C,CAC/I,IAAMG,EAAQZ,EAAiB,KAAKS,EAAK,OAAO,EAChD,GAAIG,IAAU,KAAM,MAAO,GAC3B,GAAM,EAAGP,EAAQQ,GAAWD,EACtBE,EAAQF,EAAM,IAAM,GACpBR,EAAO,mBAAmBC,CAAM,EAChCU,EAAY,wBAAwBV,CAAM,EAEhD,GADA,aAAaG,EAASC,EAAM,CAACJ,CAAM,CAAC,EAChC,CAAC,CAAC,MAAO,WAAW,CAAC,CAAC,SAASD,CAAI,GAAKC,IAAW,aAAeA,IAAW,UAE7E,OADAG,EAAQ,MAAME,EAAgB,wBAAyB,2BAA2BL,EAAO,sCAAuCM,EAAWF,CAAI,CAAC,EACzI,GAEX,IAAMO,EAAQC,EAAW,UAAU,GAAaC,EAAU,OAASd,CAAI,EACvE,GAAIY,EAAQ,EAER,OADAR,EAAQ,MAAME,EAAgB,gCAAiC,YAAYS,EAAQ,cAAcJ,EAAU,GAAGF,EAAQ,wCAAwCM,EAAQ,YAAYJ,EAAU,GAAIJ,EAAWF,CAAI,CAAC,EACzM,GAEX,IAAMS,EAAYD,EAAWD,GAC7B,OAAQH,EAAR,CACI,IAAK,SAAU,CACX,IAAMO,EAASlB,EAAc,KAAKY,CAAK,EAUvC,OATIM,IAAW,MACXZ,EAAQ,MAAME,EAAgB,wBAAyB,YAAYK,EAAU,uBAAuBA,EAAU,mBAAoBJ,EAAWF,CAAI,CAAC,EAC3I,IAEPS,EAAU,SAAW,MAIzB,EAAWF,GAAS,CAAE,GAAGE,EAAW,OAAQG,EAAeD,EAAO,EAAE,CAAE,EAC/D,KAJHZ,EAAQ,MAAME,EAAgB,yBAA0B,YAAYS,EAAQ,mCAAmCJ,EAAU,4BAA6BJ,EAAWF,CAAI,CAAC,EAC/J,GAIf,CACA,IAAK,QAaD,OAZIL,IAAS,aAAe,CAAC,CAAC,UAAW,YAAa,QAAQ,CAAC,CAAC,SAASU,CAAK,GAC1EN,EAAQ,MAAME,EAAgB,mBAAoB,YAAYK,EAAU,SAASD,EAAM,sEAAuEH,EAAWF,CAAI,CAAC,EACvK,IAEPS,EAAU,OAAS,MAIvB,EAAWF,GAAS,CAAE,GAAGE,EAAW,MAAOJ,CAAM,EAC7CG,EAAW,KAAK,GAAaC,EAAU,OAAS,KAAK,GACrDV,EAAQ,QAAQE,EAAgB,yBAA0B,YAAYS,EAAQ,gFAAiFR,EAAWF,CAAI,CAAC,EAE5K,KAPHD,EAAQ,MAAME,EAAgB,qBAAsB,YAAYS,EAAQ,0DAA2DR,EAAWF,CAAI,CAAC,EAC5I,IAOf,IAAK,UACL,IAAK,WAUD,OATIL,IAAS,QAAUS,IAAY,UAAY,CAACd,EAAkB,SAASe,CAAK,EAAIA,EAAM,OAAS,IAC/FN,EAAQ,MAAME,EAAgB,6BAA8B,YAAYK,EAAU,GAAGF,IAAUC,EAAM,OAAS,EAAI,IAAIA,IAAU,GAAG,wEAAwEf,EAAkB,KAAK,IAAI,IAAKY,EAAWF,CAAI,CAAC,EACpP,IAEPI,IAAY,WAAaK,EAAU,iBAAmB,MACtDV,EAAQ,MAAME,EAAgB,yBAA0B,YAAYS,EAAQ,yDAA0DR,EAAWF,CAAI,CAAC,EAC/I,KAEX,EAAWO,GAASH,IAAY,UAAY,CAAE,GAAGK,EAAW,gBAAiBJ,CAAM,EAAI,CAAE,GAAGI,EAAW,SAAU,EAAK,EAC/G,IACX,QACI,MAAO,EACf,CACJ,CAEA,SAAS,aAAa,EAAwB,EAAkB,EAAkC,CAC1FZ,EAAQ,KAAK,GAAU,CAAC,OAAQ,YAAa,YAAY,CAAC,CAAC,SAASD,CAAM,CAAC,GAC3EG,EAAQ,YAAYE,EAAgB,uBAAwB,2HAA4HC,EAAWF,CAAI,CAAC,CAEhN"}
1
+ {"version":3,"file":"ConceptComplianceParser.js","names":["specialCategories","directivePattern","pattern","reasonPattern","stringBodyPattern","name","marker","markers","text","context","line","attributes","firstMarkers","reported","DiagnosticCodes","locationOf","first","canonical","alias","concept","match","setting","value","index","attribute","reason","unescapeString"],"sources":["../../../../../../Compiler/Parsing/ConceptComplianceParser.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 { ConceptAttributeSyntax } from '../Syntax/Declarations';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { pattern } from '../Text/patterns';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nexport const specialCategories = ['racialOrEthnicOrigin', 'politicalOpinions', 'religiousOrPhilosophicalBeliefs', 'tradeUnionMembership', 'genetic', 'biometric', 'health', 'sexLifeOrSexualOrientation'];\nconst directivePattern = pattern('^(@?[a-z_]\\\\w*)\\\\s+(reason|scope|special|criminal)(?:\\\\s+(.*))?$');\nconst reasonPattern = pattern(`^\"(${stringBodyPattern})\"$`);\n\nexport function complianceWireName(marker: string): string {\n const name = marker.replace(/^@/, '');\n return name === 'personal' ? 'pii' : name === 'secret' ? 'sensitive' : name;\n}\n\nexport function canonicalComplianceName(marker: string): string {\n const name = complianceWireName(marker);\n return name === 'sensitive' ? 'secret' : name;\n}\n\nexport function parseComplianceMarkers(context: ParserContext, line: SourceLine, concept: string, text: string): ConceptAttributeSyntax[] {\n const markers = text.trim().split(/\\s+/).filter(marker => marker.length > 0);\n reportLegacy(context, line, markers);\n const attributes: ConceptAttributeSyntax[] = [];\n const firstMarkers = new Map<string, string>();\n let reported = false;\n for (const marker of markers) {\n const name = complianceWireName(marker);\n if (!['pii', 'sensitive'].includes(name) || marker === '@personal' || marker === '@secret') {\n context.error(DiagnosticCodes.UnknownComplianceMarker, `Unknown concept marker '${marker}' - expected pii, personal or secret`, locationOf(line));\n }\n const first = firstMarkers.get(name);\n if (first !== undefined) {\n if (!reported) {\n const canonical = canonicalComplianceName(marker);\n const alias = first === marker ? '' : ` - '${marker === canonical ? first : marker}' is the same marker as '${canonical}'`;\n context.warning(DiagnosticCodes.DuplicateComplianceMarker, `Concept '${concept}' repeats the '${canonical}' marker${alias} - remove the duplicate`, locationOf(line));\n reported = true;\n }\n continue;\n }\n firstMarkers.set(name, marker);\n attributes.push({ kind: 'ConceptAttributeSyntax', name, reason: null, scope: null, specialCategory: null, criminal: false, location: locationOf(line) });\n }\n return attributes;\n}\n\nexport function parseComplianceDirective(context: ParserContext, line: SourceLine, concept: string, attributes: ConceptAttributeSyntax[]): boolean {\n const match = directivePattern.exec(line.content);\n if (match === null) return false;\n const [, marker, setting] = match;\n const value = match[3] ?? '';\n const name = complianceWireName(marker);\n const canonical = canonicalComplianceName(marker);\n reportLegacy(context, line, [marker]);\n if (!['pii', 'sensitive'].includes(name) || marker === '@personal' || marker === '@secret') {\n context.error(DiagnosticCodes.UnknownComplianceMarker, `Unknown concept marker '${marker}' - expected pii, personal or secret`, locationOf(line));\n return true;\n }\n const index = attributes.findIndex(attribute => attribute.name === name);\n if (index < 0) {\n context.error(DiagnosticCodes.AttributeReasonWithoutAttribute, `Concept '${concept}' declares '${canonical} ${setting}' without the marker - write 'concept ${concept} : <Type> ${canonical}'`, locationOf(line));\n return true;\n }\n const attribute = attributes[index];\n switch (setting) {\n case 'reason': {\n const reason = reasonPattern.exec(value);\n if (reason === null) {\n context.error(DiagnosticCodes.UnknownConceptDirective, `Invalid '${canonical} reason' - expected '${canonical} reason \"<text>\"'`, locationOf(line));\n return true;\n }\n if (attribute.reason !== null) {\n context.error(DiagnosticCodes.DuplicateAttributeReason, `Concept '${concept}' already declares a reason for '${canonical}' - at most one is allowed`, locationOf(line));\n return true;\n }\n attributes[index] = { ...attribute, reason: unescapeString(reason[1]) };\n return true;\n }\n case 'scope':\n if (name !== 'sensitive' || !['subject', 'namespace', 'global'].includes(value)) {\n context.error(DiagnosticCodes.InvalidSecretScope, `Invalid '${canonical} scope ${value}' - scope belongs to secret and must be subject, namespace or global`, locationOf(line));\n return true;\n }\n if (attribute.scope != null) {\n context.error(DiagnosticCodes.DuplicateSecretScope, `Concept '${concept}' already declares secret scope - at most one is allowed`, locationOf(line));\n return true;\n }\n attributes[index] = { ...attribute, scope: value };\n if (attributes.some(attribute => attribute.name === 'pii')) {\n context.warning(DiagnosticCodes.SecretScopeIgnoredForPii, `Concept '${concept}' is pii secret - secret scope is ignored because only Chronicle [PII] renders`, locationOf(line));\n }\n return true;\n case 'special':\n case 'criminal':\n if (name !== 'pii' || (setting === 'special' ? !specialCategories.includes(value) : value.length > 0)) {\n context.error(DiagnosticCodes.InvalidPersonalDataQualifier, `Invalid '${canonical} ${setting}${value.length > 0 ? ` ${value}` : ''}' - expected 'pii criminal' or 'pii special <category>' with category ${specialCategories.join(', ')}`, locationOf(line));\n return true;\n }\n if (setting === 'special' && attribute.specialCategory != null) {\n context.error(DiagnosticCodes.DuplicateSpecialCategory, `Concept '${concept}' already declares pii special - at most one is allowed`, locationOf(line));\n return true;\n }\n attributes[index] = setting === 'special' ? { ...attribute, specialCategory: value } : { ...attribute, criminal: true };\n return true;\n default:\n return false;\n }\n}\n\nfunction reportLegacy(context: ParserContext, line: SourceLine, markers: readonly string[]): void {\n if (markers.some(marker => ['@pii', 'sensitive', '@sensitive'].includes(marker))) {\n context.information(DiagnosticCodes.LegacyComplianceMarker, 'Legacy compliance spelling - use bare pii for personal data and secret for operational secrets; reason text is preserved', locationOf(line));\n }\n}\n"],"mappings":"qSAUA,MAAaA,EAAoB,CAAC,uBAAwB,oBAAqB,kCAAmC,uBAAwB,UAAW,YAAa,SAAU,4BAA4B,EAClMC,EAAmBC,EAAQ,kEAAkE,EAC7FC,EAAgBD,EAAQ,MAAME,EAAkB,IAAI,EAE1D,SAAgB,mBAAmB,EAAwB,CACvD,IAAMC,EAAOC,EAAO,QAAQ,KAAM,EAAE,EACpC,OAAOD,IAAS,WAAa,MAAQA,IAAS,SAAW,YAAcA,CAC3E,CAEA,SAAgB,wBAAwB,EAAwB,CAC5D,IAAMA,EAAO,mBAAmBC,CAAM,EACtC,OAAOD,IAAS,YAAc,SAAWA,CAC7C,CAEA,SAAgB,uBAAuB,EAAwB,EAAkB,EAAiB,EAAwC,CACtI,IAAME,EAAUC,EAAK,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,GAAUF,EAAO,OAAS,CAAC,EAC3E,aAAaG,EAASC,EAAMH,CAAO,EACnC,IAAMI,EAAuC,CAAC,EACxCC,kBAAe,IAAI,IACrBC,EAAW,GACf,IAAK,IAAMP,KAAUC,EAAS,CAC1B,IAAMF,EAAO,mBAAmBC,CAAM,GAClC,CAAC,CAAC,MAAO,WAAW,CAAC,CAAC,SAASD,CAAI,GAAKC,IAAW,aAAeA,IAAW,YAC7EG,EAAQ,MAAMK,EAAgB,wBAAyB,2BAA2BR,EAAO,sCAAuCS,EAAWL,CAAI,CAAC,EAEpJ,IAAMM,EAAQJ,EAAa,IAAIP,CAAI,EACnC,GAAIW,IAAU,IAAA,GACV,IAAI,CAACH,EAAU,CACX,IAAMI,EAAY,wBAAwBX,CAAM,EAC1CY,EAAQF,IAAUV,EAAS,GAAK,OAAOA,IAAWW,EAAYD,EAAQV,EAAO,2BAA2BW,EAAU,GACxHR,EAAQ,QAAQK,EAAgB,0BAA2B,YAAYK,EAAQ,iBAAiBF,EAAU,UAAUC,EAAM,yBAA0BH,EAAWL,CAAI,CAAC,EACpK,EAAW,EACf,OAGJE,EAAa,IAAIP,EAAMC,CAAM,EAC7BK,EAAW,KAAK,CAAE,KAAM,yBAA0B,OAAM,OAAQ,KAAM,MAAO,KAAM,gBAAiB,KAAM,SAAU,GAAO,SAAUI,EAAWL,CAAI,CAAE,CAAC,CAC3J,CACA,OAAOC,CACX,CAEA,SAAgB,yBAAyB,EAAwB,EAAkB,EAAiB,EAA+C,CAC/I,IAAMS,EAAQnB,EAAiB,KAAKS,EAAK,OAAO,EAChD,GAAIU,IAAU,KAAM,MAAO,GAC3B,GAAM,EAAGd,EAAQe,GAAWD,EACtBE,EAAQF,EAAM,IAAM,GACpBf,EAAO,mBAAmBC,CAAM,EAChCW,EAAY,wBAAwBX,CAAM,EAEhD,GADA,aAAaG,EAASC,EAAM,CAACJ,CAAM,CAAC,EAChC,CAAC,CAAC,MAAO,WAAW,CAAC,CAAC,SAASD,CAAI,GAAKC,IAAW,aAAeA,IAAW,UAE7E,OADAG,EAAQ,MAAMK,EAAgB,wBAAyB,2BAA2BR,EAAO,sCAAuCS,EAAWL,CAAI,CAAC,EACzI,GAEX,IAAMa,EAAQZ,EAAW,UAAU,GAAaa,EAAU,OAASnB,CAAI,EACvE,GAAIkB,EAAQ,EAER,OADAd,EAAQ,MAAMK,EAAgB,gCAAiC,YAAYK,EAAQ,cAAcF,EAAU,GAAGI,EAAQ,wCAAwCF,EAAQ,YAAYF,EAAU,GAAIF,EAAWL,CAAI,CAAC,EACzM,GAEX,IAAMc,EAAYb,EAAWY,GAC7B,OAAQF,EAAR,CACI,IAAK,SAAU,CACX,IAAMI,EAAStB,EAAc,KAAKmB,CAAK,EAUvC,OATIG,IAAW,MACXhB,EAAQ,MAAMK,EAAgB,wBAAyB,YAAYG,EAAU,uBAAuBA,EAAU,mBAAoBF,EAAWL,CAAI,CAAC,EAC3I,IAEPc,EAAU,SAAW,MAIzB,EAAWD,GAAS,CAAE,GAAGC,EAAW,OAAQE,EAAeD,EAAO,EAAE,CAAE,EAC/D,KAJHhB,EAAQ,MAAMK,EAAgB,yBAA0B,YAAYK,EAAQ,mCAAmCF,EAAU,4BAA6BF,EAAWL,CAAI,CAAC,EAC/J,GAIf,CACA,IAAK,QAaD,OAZIL,IAAS,aAAe,CAAC,CAAC,UAAW,YAAa,QAAQ,CAAC,CAAC,SAASiB,CAAK,GAC1Eb,EAAQ,MAAMK,EAAgB,mBAAoB,YAAYG,EAAU,SAASK,EAAM,sEAAuEP,EAAWL,CAAI,CAAC,EACvK,IAEPc,EAAU,OAAS,MAIvB,EAAWD,GAAS,CAAE,GAAGC,EAAW,MAAOF,CAAM,EAC7CX,EAAW,KAAK,GAAaa,EAAU,OAAS,KAAK,GACrDf,EAAQ,QAAQK,EAAgB,yBAA0B,YAAYK,EAAQ,gFAAiFJ,EAAWL,CAAI,CAAC,EAE5K,KAPHD,EAAQ,MAAMK,EAAgB,qBAAsB,YAAYK,EAAQ,0DAA2DJ,EAAWL,CAAI,CAAC,EAC5I,IAOf,IAAK,UACL,IAAK,WAUD,OATIL,IAAS,QAAUgB,IAAY,UAAY,CAACrB,EAAkB,SAASsB,CAAK,EAAIA,EAAM,OAAS,IAC/Fb,EAAQ,MAAMK,EAAgB,6BAA8B,YAAYG,EAAU,GAAGI,IAAUC,EAAM,OAAS,EAAI,IAAIA,IAAU,GAAG,wEAAwEtB,EAAkB,KAAK,IAAI,IAAKe,EAAWL,CAAI,CAAC,EACpP,IAEPW,IAAY,WAAaG,EAAU,iBAAmB,MACtDf,EAAQ,MAAMK,EAAgB,yBAA0B,YAAYK,EAAQ,yDAA0DJ,EAAWL,CAAI,CAAC,EAC/I,KAEX,EAAWa,GAASF,IAAY,UAAY,CAAE,GAAGG,EAAW,gBAAiBF,CAAM,EAAI,CAAE,GAAGE,EAAW,SAAU,EAAK,EAC/G,IACX,QACI,MAAO,EACf,CACJ,CAEA,SAAS,aAAa,EAAwB,EAAkB,EAAkC,CAC1FjB,EAAQ,KAAK,GAAU,CAAC,OAAQ,YAAa,YAAY,CAAC,CAAC,SAASD,CAAM,CAAC,GAC3EG,EAAQ,YAAYK,EAAgB,uBAAwB,2HAA4HC,EAAWL,CAAI,CAAC,CAEhN"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{dotNetWhitespace as t,nativePattern as n}from"../Text/patterns.js";import{stringBodyPattern as r}from"../Text/StringLiteral.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?t:`\\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(n(`"${r}"|==|!=|>=|<=|>|<|\\(|\\)|${d}${f}`).source,`gu`);if(l){let n=s.replace(p,``).replace(new RegExp(t,`gu`),``);if(n.length>0)return o.error(e.UnsupportedActionConditionOperand,`Guarded action conditions contain unsupported character '${n[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";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};
2
2
  //# sourceMappingURL=ConditionParser.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{stringBodyPattern as n,unescapeString as r}from"../Text/StringLiteral.js";import{firstWord as i}from"./LineText.js";import{locationOf as a}from"./SourceLine.js";import{parseDescription as o}from"./DescriptionParser.js";import{isFileDirective as s}from"./FileReferences.js";const c=t(`^constraint\\s+([A-Za-z_]\\w*)$`),l=t(`^unique\\s+event\\s+([A-Z]\\w*)$`),u=t(`^unique\\s+([a-z_][\\w.]*(?:\\s*,\\s*[a-z_][\\w.]*)*)\\s+on\\s+([A-Z]\\w*)$`),d=t(`^released\\s+by\\s+([A-Z]\\w*)$`),f=t(`^message\\s+"(${n})"$`),targetOf=e=>e.kind===`FileConstraintSyntax`?void 0:e.event;function parseConstraint(t,n){let s=c.exec(n.content);s===null&&t.error(e.InvalidConstraintDeclaration,`Invalid constraint declaration '${n.content}' - expected 'constraint <Name>'`,a(n));let l=s?.[1]??i(n.content),u=[],p=[],m=/* @__PURE__ */ new Set,h=/* @__PURE__ */ new Set,g=null,_=null,v=!1;for(let s=t.peekChild(n.indent);s!==void 0;s=t.peekChild(n.indent)){if(t.reader.takeSignificant(),i(s.content)===`description`){_=o(t,s,_,`Constraint '${l}'`);continue}let n=d.exec(s.content),c=f.exec(s.content);n===null?c===null?s.content===`ignore casing`?(v&&t.error(e.DuplicateConstraintBody,`Constraint '${l}' already ignores casing`,a(s)),v=!0):addRule(t,l,s,u,h):g===null?g=r(c[1]):t.error(e.DuplicateConstraintBody,`Constraint '${l}' already has a message`,a(s)):m.has(n[1])?t.error(e.DuplicateConstraintBody,`Constraint '${l}' already releases with event '${n[1]}'`,a(s)):(p.push(n[1]),m.add(n[1]))}for(let r of p.filter(e=>h.has(e)))t.error(e.DuplicateConstraintBody,`Constraint '${l}' cannot target and release event '${r}'`,a(n));return u.length===0&&(t.error(e.ConstraintWithoutRule,`Constraint '${l}' must declare 'unique ... on ...', 'unique event ...' or 'file ...'`,a(n)),u.push(rule(l,a(n),{kind:`UniqueEventConstraintSyntax`,event:``}))),u[0].kind===`FileConstraintSyntax`&&(p.length>0||g!==null||v)&&t.error(e.InvalidConstraintBody,`File constraint '${l}' cannot have declarative options`,a(n)),{...u[0],additionalRules:u.slice(1),releasedBy:p,message:g,ignoreCasing:v,description:_}}function addRule(t,n,r,i,o){let s=parseRule(t,n,r);if(s===void 0)return;if(i.length>0&&(s.kind===`FileConstraintSyntax`||i[0].kind===`FileConstraintSyntax`||s.kind===`UniqueEventConstraintSyntax`!=(i[0].kind===`UniqueEventConstraintSyntax`))){t.error(e.DuplicateConstraintBody,`Constraint '${n}' cannot mix constraint kinds`,a(r));return}let c=targetOf(s);c!==void 0&&o.has(c)?t.error(e.DuplicateConstraintBody,`Constraint '${n}' already targets event '${c}'`,a(r)):(c!==void 0&&o.add(c),i.push(s))}function parseRule(t,n,r){let i=a(r),o=l.exec(r.content);if(o!==null)return rule(n,i,{kind:`UniqueEventConstraintSyntax`,event:o[1]});let c=u.exec(r.content);if(c!==null){let r=c[1].split(`,`).map(e=>e.trim());if(new Set(r).size!==r.length){t.error(e.DuplicateConstraintBody,`Constraint '${n}' repeats a property in its composite key`,i);return}return rule(n,i,{kind:`UniquePropertyConstraintSyntax`,property:r[0],additionalProperties:r.slice(1),event:c[2]})}if(s(r))return t.warning(e.FileConstraintOnlySupportsUniqueness,`A file constraint can only declare unique constraints in Chronicle - declare them with 'unique ...' so they are portable; a rule that is not uniqueness belongs in command validation or a 'require' condition`,i),rule(n,i,{kind:`FileConstraintSyntax`,file:{kind:`FileReferenceSyntax`,path:r.content.substring(4).trim(),location:i}});t.error(e.InvalidConstraintBody,`Invalid constraint body '${r.content}'`,i)}function rule(e,t,n){return{...n,name:e,additionalRules:[],releasedBy:[],ignoreCasing:!1,message:null,location:t}}export{parseConstraint};
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{firstWord as a}from"./LineText.js";import{parseDescription as o}from"./DescriptionParser.js";import{isFileDirective as s}from"./FileReferences.js";const c=r(`^constraint\\s+([A-Za-z_]\\w*)$`),l=r(`^unique\\s+event\\s+([A-Z]\\w*)$`),u=r(`^unique\\s+([a-z_][\\w.]*(?:\\s*,\\s*[a-z_][\\w.]*)*)\\s+on\\s+([A-Z]\\w*)$`),d=r(`^released\\s+by\\s+([A-Z]\\w*)$`),f=r(`^message\\s+"(${t})"$`),targetOf=e=>e.kind===`FileConstraintSyntax`?void 0:e.event;function parseConstraint(t,r){let s=c.exec(r.content);s===null&&t.error(e.InvalidConstraintDeclaration,`Invalid constraint declaration '${r.content}' - expected 'constraint <Name>'`,i(r));let l=s?.[1]??a(r.content),u=[],p=[],m=/* @__PURE__ */ new Set,h=/* @__PURE__ */ new Set,g=null,_=null,v=!1;for(let s=t.peekChild(r.indent);s!==void 0;s=t.peekChild(r.indent)){if(t.reader.takeSignificant(),a(s.content)===`description`){_=o(t,s,_,`Constraint '${l}'`);continue}let r=d.exec(s.content),c=f.exec(s.content);r===null?c===null?s.content===`ignore casing`?(v&&t.error(e.DuplicateConstraintBody,`Constraint '${l}' already ignores casing`,i(s)),v=!0):addRule(t,l,s,u,h):g===null?g=n(c[1]):t.error(e.DuplicateConstraintBody,`Constraint '${l}' already has a message`,i(s)):m.has(r[1])?t.error(e.DuplicateConstraintBody,`Constraint '${l}' already releases with event '${r[1]}'`,i(s)):(p.push(r[1]),m.add(r[1]))}for(let n of p.filter(e=>h.has(e)))t.error(e.DuplicateConstraintBody,`Constraint '${l}' cannot target and release event '${n}'`,i(r));return u.length===0&&(t.error(e.ConstraintWithoutRule,`Constraint '${l}' must declare 'unique ... on ...', 'unique event ...' or 'file ...'`,i(r)),u.push(rule(l,i(r),{kind:`UniqueEventConstraintSyntax`,event:``}))),u[0].kind===`FileConstraintSyntax`&&(p.length>0||g!==null||v)&&t.error(e.InvalidConstraintBody,`File constraint '${l}' cannot have declarative options`,i(r)),{...u[0],additionalRules:u.slice(1),releasedBy:p,message:g,ignoreCasing:v,description:_}}function addRule(t,n,r,a,o){let s=parseRule(t,n,r);if(s===void 0)return;if(a.length>0&&(s.kind===`FileConstraintSyntax`||a[0].kind===`FileConstraintSyntax`||s.kind===`UniqueEventConstraintSyntax`!=(a[0].kind===`UniqueEventConstraintSyntax`))){t.error(e.DuplicateConstraintBody,`Constraint '${n}' cannot mix constraint kinds`,i(r));return}let c=targetOf(s);c!==void 0&&o.has(c)?t.error(e.DuplicateConstraintBody,`Constraint '${n}' already targets event '${c}'`,i(r)):(c!==void 0&&o.add(c),a.push(s))}function parseRule(t,n,r){let a=i(r),o=l.exec(r.content);if(o!==null)return rule(n,a,{kind:`UniqueEventConstraintSyntax`,event:o[1]});let c=u.exec(r.content);if(c!==null){let r=c[1].split(`,`).map(e=>e.trim());if(new Set(r).size!==r.length){t.error(e.DuplicateConstraintBody,`Constraint '${n}' repeats a property in its composite key`,a);return}return rule(n,a,{kind:`UniquePropertyConstraintSyntax`,property:r[0],additionalProperties:r.slice(1),event:c[2]})}if(s(r))return t.warning(e.FileConstraintOnlySupportsUniqueness,`A file constraint can only declare unique constraints in Chronicle - declare them with 'unique ...' so they are portable; a rule that is not uniqueness belongs in command validation or a 'require' condition`,a),rule(n,a,{kind:`FileConstraintSyntax`,file:{kind:`FileReferenceSyntax`,path:r.content.substring(4).trim(),location:a}});t.error(e.InvalidConstraintBody,`Invalid constraint body '${r.content}'`,a)}function rule(e,t,n){return{...n,name:e,additionalRules:[],releasedBy:[],ignoreCasing:!1,message:null,location:t}}export{parseConstraint};
2
2
  //# sourceMappingURL=ConstraintParser.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{stringBodyPattern as n,unescapeString as r}from"../Text/StringLiteral.js";import{parseMappingSource as i}from"./ExpressionParser.js";import{firstWord as a}from"./LineText.js";import{locationOf as o}from"./SourceLine.js";import{parseProperty as s,tryParseProperty as c}from"./PropertyLineParser.js";import{parseDescription as l}from"./DescriptionParser.js";import{parseDocumentation as u}from"./DocumentationParser.js";import{isFileDirectiveAmongProperties as d}from"./FileReferences.js";import{isBlankPublicEventOrigin as f}from"../Syntax/PublicEventInvariants.js";import{eventBodyReservedWords as p}from"../Text/ReservedWords.js";import{EventMetadataParser as m}from"./EventMetadataParser.js";const h=t(`^type\\s+([A-Za-z_]\\w*)$`),g=t(`^(?:(?<public>public)\\s+)?event\\s+(?<name>[A-Za-z_]\\w*)(?:\\s+generation\\s+(?<generation>[0-9]+))?(?:\\s+from\\s+"(?<origin>${n})")?$`),_=t(`^readmodel\\s+([A-Za-z_]\\w*)$`),v=t(`^[A-Z]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$`),y=t(`^[A-Za-z_]\\w*$`),isDescription=e=>a(e.content)===`description`&&c(e)===void 0;function withoutIdentifier(e,t,n,r,i){return t.isIdentifier?(e.error(r,i,o(n)),{...t,isIdentifier:!1}):t}function parseType(t,n){let r=h.exec(n.content)?.[1]??``;r===``&&t.error(e.InvalidTypeDeclaration,`Invalid type declaration '${n.content}' - expected 'type <Name>'`,o(n));let i=[],a=null;for(let c=t.peekChild(n.indent);c!==void 0;c=t.peekChild(n.indent)){if(t.reader.takeSignificant(),isDescription(c)){a=l(t,c,a,`Type '${r}'`);continue}if(d(c))continue;let n=s(t,c);n===void 0?t.error(e.InvalidPropertyDeclaration,`Invalid property '${c.content}' - expected '<name> <Type>'`,o(c)):i.push(withoutIdentifier(t,n,c,e.IdentifierOutsideCommand,`Property '${n.name}' of type '${r}' cannot be marked identifier - only a command property can be`))}return i.length===0&&t.error(e.TypeWithoutProperties,`Type '${r}' must declare at least one property`,o(n)),{kind:`TypeSyntax`,name:r,properties:i,description:a,location:o(n)}}function parseEvent(t,n){let i=g.exec(n.content),c=i?.groups?.name??``;i===null&&t.error(e.InvalidEventDeclaration,`Invalid event declaration '${n.content}' - expected '[public] event <Name> [generation <N>] [from "<origin>"]'`,o(n));let l=i?.groups?.origin===void 0?null:r(i.groups.origin),u=i?.groups?.public!==void 0||l!==null?`Public`:`Private`;l!==null&&f(l)&&t.error(e.InvalidEventDeclaration,`An event origin must be a nonblank quoted string`,o(n));let h=i?.groups?.generation!==void 0,_=1;if(h){let r=Number(i.groups.generation);!Number.isSafeInteger(r)||r===0||r>=4294967295?t.error(e.InvalidEventGeneration,`Event '${c}' must declare a generation between 1 and 4294967294`,o(n)):_=r}let v=[],y=[],b=new m(c);for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){if(t.reader.takeSignificant(),d(r))continue;if(p.includes(a(r.content))){let e=parseTag(t,r);e!==void 0&&y.push(e);continue}let n=s(t,r);n===void 0?b.tryParse(t,r)||t.error(e.InvalidPropertyDeclaration,`Invalid property '${r.content}' - expected '<name> <Type>'`,o(r)):v.push(withoutIdentifier(t,n,r,e.IdentifierOnEventProperty,`Property '${n.name}' of event '${c}' cannot be marked identifier - an event never carries its event source id`))}return{kind:`EventSyntax`,name:c,properties:v,tags:y,visibility:u,origin:l,generation:_,hasGenerationMarker:h,...b.value,location:o(n)}}function parseTag(t,n,r=!0){let a=n.content.substring(3).trim();if(r&&v.test(a)&&t.warning(e.TagPropertyReadAsTag,`'${n.content}' declares a static tag with the value '${a}', not a property named 'tag' - write 'tag "${a}"' for the tag, or '@${n.content}' for the property`,o(n)),a.length===0){t.error(e.TagWithoutValue,`Expected a value after 'tag' - an identifier, a string literal or a context expression`,o(n));return}if(y.test(a))return{kind:`TagSyntax`,value:{kind:`LiteralExpressionSyntax`,value:a,location:o(n)},location:o(n)};let s=i(a,o(n),t);if(s.kind===`RawExpressionSyntax`)t.error(e.InvalidTagValue,`Invalid tag value '${a}' - expected an identifier, a string literal or a context expression`,o(n));else return{kind:`TagSyntax`,value:s,location:o(n)}}function parseReadModel(t,n){let r=_.exec(n.content)?.[1]??``;r===``&&t.error(e.InvalidReadModelDeclaration,`Invalid read model declaration '${n.content}' - expected 'readmodel <Name>'`,o(n));let i=[],f=null,p=null;for(let m=t.peekChild(n.indent);m!==void 0;m=t.peekChild(n.indent))if(t.reader.takeSignificant(),isDescription(m))f=l(t,m,f,`Read model '${r}'`);else if(a(m.content)===`documentation`&&c(m)===void 0)p=u(t,m,p,`Read model '${r}'`);else if(d(m))continue;else{let n=s(t,m);if(n===void 0){t.error(e.InvalidPropertyDeclaration,`Invalid property '${m.content}' - expected '<name> <Type>'`,o(m));continue}i.push(withoutIdentifier(t,n,m,e.IdentifierOutsideCommand,`Property '${n.name}' of read model '${r}' cannot be marked identifier - only a command property can be`))}return{kind:`ReadModelSyntax`,name:r,properties:i,description:f,documentation:p,location:o(n)}}export{parseEvent,parseReadModel,parseTag,parseType};
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{parseMappingSource as a}from"./ExpressionParser.js";import{firstWord as o}from"./LineText.js";import{parseProperty as s,tryParseProperty as c}from"./PropertyLineParser.js";import{parseDescription as l}from"./DescriptionParser.js";import{parseDocumentation as u}from"./DocumentationParser.js";import{isFileDirectiveAmongProperties as d}from"./FileReferences.js";import{isBlankPublicEventOrigin as f}from"../Syntax/PublicEventInvariants.js";import{eventBodyReservedWords as p}from"../Text/ReservedWords.js";import{EventMetadataParser as m}from"./EventMetadataParser.js";const h=r(`^type\\s+([A-Za-z_]\\w*)$`),g=r(`^(?:(?<public>public)\\s+)?event\\s+(?<name>[A-Za-z_]\\w*)(?:\\s+generation\\s+(?<generation>[0-9]+))?(?:\\s+from\\s+"(?<origin>${t})")?$`),_=r(`^readmodel\\s+([A-Za-z_]\\w*)$`),v=r(`^[A-Z]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$`),y=r(`^[A-Za-z_]\\w*$`),isDescription=e=>o(e.content)===`description`&&c(e)===void 0;function withoutIdentifier(e,t,n,r,a){return t.isIdentifier?(e.error(r,a,i(n)),{...t,isIdentifier:!1}):t}function parseType(t,n){let r=h.exec(n.content)?.[1]??``;r===``&&t.error(e.InvalidTypeDeclaration,`Invalid type declaration '${n.content}' - expected 'type <Name>'`,i(n));let a=[],o=null;for(let c=t.peekChild(n.indent);c!==void 0;c=t.peekChild(n.indent)){if(t.reader.takeSignificant(),isDescription(c)){o=l(t,c,o,`Type '${r}'`);continue}if(d(c))continue;let n=s(t,c);n===void 0?t.error(e.InvalidPropertyDeclaration,`Invalid property '${c.content}' - expected '<name> <Type>'`,i(c)):a.push(withoutIdentifier(t,n,c,e.IdentifierOutsideCommand,`Property '${n.name}' of type '${r}' cannot be marked identifier - only a command property can be`))}return a.length===0&&t.error(e.TypeWithoutProperties,`Type '${r}' must declare at least one property`,i(n)),{kind:`TypeSyntax`,name:r,properties:a,description:o,location:i(n)}}function parseEvent(t,r){let a=g.exec(r.content),c=a?.groups?.name??``;a===null&&t.error(e.InvalidEventDeclaration,`Invalid event declaration '${r.content}' - expected '[public] event <Name> [generation <N>] [from "<origin>"]'`,i(r));let l=a?.groups?.origin===void 0?null:n(a.groups.origin),u=a?.groups?.public!==void 0||l!==null?`Public`:`Private`;l!==null&&f(l)&&t.error(e.InvalidEventDeclaration,`An event origin must be a nonblank quoted string`,i(r));let h=a?.groups?.generation!==void 0,_=1;if(h){let n=Number(a.groups.generation);!Number.isSafeInteger(n)||n===0||n>=4294967295?t.error(e.InvalidEventGeneration,`Event '${c}' must declare a generation between 1 and 4294967294`,i(r)):_=n}let v=[],y=[],b=new m(c);for(let n=t.peekChild(r.indent);n!==void 0;n=t.peekChild(r.indent)){if(t.reader.takeSignificant(),d(n))continue;if(p.includes(o(n.content))){let e=parseTag(t,n);e!==void 0&&y.push(e);continue}let r=s(t,n);r===void 0?b.tryParse(t,n)||t.error(e.InvalidPropertyDeclaration,`Invalid property '${n.content}' - expected '<name> <Type>'`,i(n)):v.push(withoutIdentifier(t,r,n,e.IdentifierOnEventProperty,`Property '${r.name}' of event '${c}' cannot be marked identifier - an event never carries its event source id`))}return{kind:`EventSyntax`,name:c,properties:v,tags:y,visibility:u,origin:l,generation:_,hasGenerationMarker:h,...b.value,location:i(r)}}function parseTag(t,n,r=!0){let o=n.content.substring(3).trim();if(r&&v.test(o)&&t.warning(e.TagPropertyReadAsTag,`'${n.content}' declares a static tag with the value '${o}', not a property named 'tag' - write 'tag "${o}"' for the tag, or '@${n.content}' for the property`,i(n)),o.length===0){t.error(e.TagWithoutValue,`Expected a value after 'tag' - an identifier, a string literal or a context expression`,i(n));return}if(y.test(o))return{kind:`TagSyntax`,value:{kind:`LiteralExpressionSyntax`,value:o,location:i(n)},location:i(n)};let s=a(o,i(n),t);if(s.kind===`RawExpressionSyntax`)t.error(e.InvalidTagValue,`Invalid tag value '${o}' - expected an identifier, a string literal or a context expression`,i(n));else return{kind:`TagSyntax`,value:s,location:i(n)}}function parseReadModel(t,n){let r=_.exec(n.content)?.[1]??``;r===``&&t.error(e.InvalidReadModelDeclaration,`Invalid read model declaration '${n.content}' - expected 'readmodel <Name>'`,i(n));let a=[],f=null,p=null;for(let m=t.peekChild(n.indent);m!==void 0;m=t.peekChild(n.indent))if(t.reader.takeSignificant(),isDescription(m))f=l(t,m,f,`Read model '${r}'`);else if(o(m.content)===`documentation`&&c(m)===void 0)p=u(t,m,p,`Read model '${r}'`);else if(d(m))continue;else{let n=s(t,m);if(n===void 0){t.error(e.InvalidPropertyDeclaration,`Invalid property '${m.content}' - expected '<name> <Type>'`,i(m));continue}a.push(withoutIdentifier(t,n,m,e.IdentifierOutsideCommand,`Property '${n.name}' of read model '${r}' cannot be marked identifier - only a command property can be`))}return{kind:`ReadModelSyntax`,name:r,properties:a,description:f,documentation:p,location:i(n)}}export{parseEvent,parseReadModel,parseTag,parseType};
2
2
  //# sourceMappingURL=DeclarationParsers.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{dotNetWhitespace as e,nativePattern as t}from"../Text/patterns.js";import{firstWord as n}from"./LineText.js";import{locationOf as r}from"./SourceLine.js";import{parseDescription as i}from"./DescriptionParser.js";import{ParserContext as a}from"./ParserContext.js";function captureReads(n){let i=t(`^reads${e}+([A-Z]\\w*)(?:${e}+as${e}+([a-z_]\\w*))?(?:${e}+by${e}+([a-z_]\\w*))?$`).exec(n.content);if(!(i===null||[`as`,`by`,`reads`].includes(i[2])))return{kind:`ReadsSyntax`,readModel:i[1],alias:i[2]??null,by:i[3]??null,location:r(n)}}function fork(e){return new a(e.reader.fork(),e.path,e.languages)}function captureConcurrency(i,a){if(a.content!==`concurrency`)return;let o=fork(i),s=!1,c={},l;for(let r=o.peekChild(a.indent);r!==void 0;r=o.peekChild(a.indent))switch(o.reader.takeSignificant(),n(r.content)){case`eventSource`:r.content===`eventSource`&&(s=!0);break;case`sourceType`:case`streamType`:case`streamId`:{let n=t(`^(sourceType|streamType|streamId)${e}+([A-Za-z_]\\w*)$`).exec(r.content);n!==null&&(c[n[1]]??=n[2]);break}case`events`:{if(l!==void 0)break;let n=r.content.slice(6).split(`,`).map(t=>t.replace(RegExp(`^${e}+|${e}+$`,`gu`),``)).filter(Boolean);n.length>0&&n.every(e=>t(`^[A-Z]\\w*$`).test(e))&&(l=n);break}default:o.skipBlock(r.indent)}return{kind:`ConcurrencySyntax`,eventSource:s,eventSourceType:c.sourceType??null,eventStreamType:c.streamType??null,eventStreamId:c.streamId??null,eventTypes:l??[],location:r(a)}}function captureReducer(a,o){let s=t(`^reducer${e}+([A-Za-z_]\\w*)${e}*=>${e}*([A-Za-z_]\\w*)$`).exec(o.content),c=fork(a),l=[];for(let a=c.peekChild(o.indent);a!==void 0;a=c.peekChild(o.indent)){if(c.reader.takeSignificant(),n(a.content)===`description`){i(c,a,null,`Reducer`);continue}let o=t(`^on${e}+([A-Z]\\w*)$`).exec(a.content);o!==null&&l.push({kind:`ReducerRuleSyntax`,event:o[1],file:null,code:null,description:null,location:r(a)}),c.skipOpaqueBlock(a.indent)}return{kind:`ReducerSyntax`,name:s?.[1]??``,readModel:s?.[2]??``,rules:l,description:null,location:r(o)}}export{captureConcurrency,captureReads,captureReducer};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{dotNetWhitespace as e,nativePattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{firstWord as r}from"./LineText.js";import{parseDescription as i}from"./DescriptionParser.js";import{ParserContext as a}from"./ParserContext.js";function captureReads(r){let i=t(`^reads${e}+([A-Z]\\w*)(?:${e}+as${e}+([a-z_]\\w*))?(?:${e}+by${e}+([a-z_]\\w*))?$`).exec(r.content);if(!(i===null||[`as`,`by`,`reads`].includes(i[2])))return{kind:`ReadsSyntax`,readModel:i[1],alias:i[2]??null,by:i[3]??null,location:n(r)}}function fork(e){return new a(e.reader.fork(),e.path,e.languages)}function captureConcurrency(i,a){if(a.content!==`concurrency`)return;let o=fork(i),s=!1,c={},l;for(let n=o.peekChild(a.indent);n!==void 0;n=o.peekChild(a.indent))switch(o.reader.takeSignificant(),r(n.content)){case`eventSource`:n.content===`eventSource`&&(s=!0);break;case`sourceType`:case`streamType`:case`streamId`:{let r=t(`^(sourceType|streamType|streamId)${e}+([A-Za-z_]\\w*)$`).exec(n.content);r!==null&&(c[r[1]]??=r[2]);break}case`events`:{if(l!==void 0)break;let r=n.content.slice(6).split(`,`).map(t=>t.replace(RegExp(`^${e}+|${e}+$`,`gu`),``)).filter(Boolean);r.length>0&&r.every(e=>t(`^[A-Z]\\w*$`).test(e))&&(l=r);break}default:o.skipBlock(n.indent)}return{kind:`ConcurrencySyntax`,eventSource:s,eventSourceType:c.sourceType??null,eventStreamType:c.streamType??null,eventStreamId:c.streamId??null,eventTypes:l??[],location:n(a)}}function captureReducer(a,o){let s=t(`^reducer${e}+([A-Za-z_]\\w*)${e}*=>${e}*([A-Za-z_]\\w*)$`).exec(o.content),c=fork(a),l=[];for(let a=c.peekChild(o.indent);a!==void 0;a=c.peekChild(o.indent)){if(c.reader.takeSignificant(),r(a.content)===`description`){i(c,a,null,`Reducer`);continue}let o=t(`^on${e}+([A-Z]\\w*)$`).exec(a.content);o!==null&&l.push({kind:`ReducerRuleSyntax`,event:o[1],file:null,code:null,description:null,location:n(a)}),c.skipOpaqueBlock(a.indent)}return{kind:`ReducerSyntax`,name:s?.[1]??``,readModel:s?.[2]??``,rules:l,description:null,location:n(o)}}export{captureConcurrency,captureReads,captureReducer};
2
2
  //# sourceMappingURL=DependencySourceParser.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{stringBodyPattern as n,unescapeString as r}from"../Text/StringLiteral.js";import{locationOf as i}from"./SourceLine.js";import{parseFencedText as a}from"./CodeBlockParser.js";const o=t(`^description\\s+"(${n})"$`);function parseDescription(t,n,s,c,l=!1){if(n.content===`description`){let r=a(t,`description`,n,l);return r===null?s:r.trim().length===0?(t.error(e.EmptyDescription,`${c} declares an empty description - the fenced block must contain text`,i(n)),s):keep(t,n,s,c,r)}let u=o.exec(n.content);return u===null?(t.error(e.InvalidDescription,`Invalid description '${n.content}' - expected 'description "<text>"'`,i(n)),s):keep(t,n,s,c,r(u[1]))}function keep(t,n,r,a,o){return r===null?o:(t.error(e.DuplicateDescription,`${a} already declares a description - at most one is allowed`,i(n)),r)}export{parseDescription};
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{parseFencedText as a}from"./CodeBlockParser.js";const o=r(`^description\\s+"(${t})"$`);function parseDescription(t,r,s,c,l=!1){if(r.content===`description`){let n=a(t,`description`,r,l);return n===null?s:n.trim().length===0?(t.error(e.EmptyDescription,`${c} declares an empty description - the fenced block must contain text`,i(r)),s):keep(t,r,s,c,n)}let u=o.exec(r.content);return u===null?(t.error(e.InvalidDescription,`Invalid description '${r.content}' - expected 'description "<text>"'`,i(r)),s):keep(t,r,s,c,n(u[1]))}function keep(t,n,r,a,o){return r===null?o:(t.error(e.DuplicateDescription,`${a} already declares a description - at most one is allowed`,i(n)),r)}export{parseDescription};
2
2
  //# sourceMappingURL=DescriptionParser.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{stringBodyPattern as n,unescapeString as r}from"../Text/StringLiteral.js";import{firstWord as i}from"./LineText.js";import{locationOf as a}from"./SourceLine.js";import{parseDescription as o}from"./DescriptionParser.js";import{parseDocumentation as s}from"./DocumentationParser.js";const c=t(`^id\\s+"(${n})"$`);var EventMetadataParser=class{name;value={id:null,description:null,documentation:null};constructor(e){this.name=e}tryParse(t,n){let l=a(n);switch(i(n.content)){case`id`:{let i=c.exec(n.content),a=i===null?``:r(i[1]);return a.trim().length===0||this.value.id!==null?t.error(e.InvalidEventId,`Event '${this.name}' accepts one nonempty 'id "<old-name>"'`,l):(this.value.id=a,a===this.name&&t.information(e.RedundantEventId,`Event '${this.name}' already has this name as its identity - remove the redundant id`,l)),!0}case`description`:return this.value.description=o(t,n,this.value.description,`Event '${this.name}'`,!0),!0;case`documentation`:return this.value.documentation=s(t,n,this.value.documentation,`Event '${this.name}'`,e.InvalidEventDocumentation),!0;default:return!1}}};export{EventMetadataParser};
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{firstWord as a}from"./LineText.js";import{parseDescription as o}from"./DescriptionParser.js";import{parseDocumentation as s}from"./DocumentationParser.js";const c=r(`^id\\s+"(${t})"$`);var EventMetadataParser=class{name;value={id:null,description:null,documentation:null};constructor(e){this.name=e}tryParse(t,r){let l=i(r);switch(a(r.content)){case`id`:{let i=c.exec(r.content),a=i===null?``:n(i[1]);return a.trim().length===0||this.value.id!==null?t.error(e.InvalidEventId,`Event '${this.name}' accepts one nonempty 'id "<old-name>"'`,l):(this.value.id=a,a===this.name&&t.information(e.RedundantEventId,`Event '${this.name}' already has this name as its identity - remove the redundant id`,l)),!0}case`description`:return this.value.description=o(t,r,this.value.description,`Event '${this.name}'`,!0),!0;case`documentation`:return this.value.documentation=s(t,r,this.value.documentation,`Event '${this.name}'`,e.InvalidEventDocumentation),!0;default:return!1}}};export{EventMetadataParser};
2
2
  //# sourceMappingURL=EventMetadataParser.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{stringBodyPattern as n,unescapeString as r}from"../Text/StringLiteral.js";import{parseMappingSource as i}from"./ExpressionParser.js";import{firstWord as a}from"./LineText.js";import{locationOf as o}from"./SourceLine.js";import{parseTypeRef as s,reportLegacyOptionalSuffix as c}from"./PropertyLineParser.js";import{parseDescription as l}from"./DescriptionParser.js";import{sourceStreamPattern as u}from"../Text/SourceStreamNames.js";const d=t(`^id\\s+"(${n})"$`),f=u(`^(identifier|streamId)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$`),p=u(`^eventsource\\s+([A-Za-z_]\\w*)$`),m=u(`^stream\\s+([A-Za-z_]\\w*)$`);function parseEventSource(e,t){let n=p.exec(t.content)?.[1]??``;n===``&&invalid(e,t,`Expected 'eventsource <Name>'.`);let r=[],i=null,s=null,c=null;for(let o=e.peekChild(t.indent);o!==void 0;o=e.peekChild(t.indent))switch(e.reader.takeSignificant(),a(o.content)){case`stream`:r.push(parseEventStream(e,o));break;case`identifier`:i=parseType(e,o,`identifier`,i);break;case`description`:s=l(e,o,s,`Event source '${n}'`,!0);break;case`id`:c=parsePin(e,o,n,c);break;default:invalid(e,o,`An event source accepts description, id, identifier and stream declarations.`),e.skipBlock(o.indent)}return{kind:`EventSourceSyntax`,name:n,streams:r,identifier:i,description:s,id:c,location:o(t)}}function parseEventStream(e,t){let n=m.exec(t.content)?.[1]??``;n===``&&invalid(e,t,`Expected 'stream <Name>'.`);let r=null,i=[],s=!1,c={},u=null,d=null;for(let f=e.peekChild(t.indent);f!==void 0;f=e.peekChild(t.indent))switch(e.reader.takeSignificant(),a(f.content)){case`streamId`:s?(invalid(e,f,`Declare either one 'streamId <Type>' or one streamId part block.`),e.skipBlock(f.indent)):f.content===`streamId`?(s=!0,c.streamId=o(f),i=parseStreamIdParts(e,f)):(r=parseType(e,f,`streamId`,r),s=r!==null);break;case`description`:u=l(e,f,u,`Stream '${n}'`,!0);break;case`id`:d=parsePin(e,f,n,d);break;default:invalid(e,f,`A stream accepts description, id and streamId declarations.`),e.skipBlock(f.indent)}return{kind:`EventStreamSyntax`,name:n,streamId:r,streamIdParts:i,description:u,id:d,directiveLocations:c,location:o(t)}}function parseType(t,n,r,i){let a=f.exec(n.content);return a===null||i!==null?invalid(t,n,`Declare at most one '${r} <Type>'.`):(i=s(a[2],{...o(n),column:n.indent+1+n.content.indexOf(a[2],r.length)}),c(t,i,n)),rejectChildren(t,n,e.InvalidEventSourceDeclaration),i}function parsePin(t,n,i,a){let s=d.exec(n.content),c=s===null?null:r(s[1]);return c===null||c.trim()===``||a!==null?invalid(t,n,`Declare at most one nonempty rename-only 'id "<old-name>"'.`):(a=c,c===i&&t.information(e.RedundantSourceStreamId,`The rename pin repeats the current name; omit it for a new declaration.`,o(n))),rejectChildren(t,n,e.InvalidEventSourceDeclaration),a}function parseCommandStream(t,n,r,a){let[s,c]=r.type.name.split(`.`),l={kind:`CommandStreamSyntax`,eventSource:s,stream:c,streamId:null,streamIdParts:[],propertyCandidate:null,referenceLocation:r.type.location,referenceLength:r.type.name.length,location:o(n)};if(a)return t.error(e.AmbiguousCommandStream,`'${n.content}' has both a property type and a stream route interpretation; neither is selected.`,o(n)),{...l,propertyCandidate:r};let u=null,d=[],f=!1,p={};for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){if(t.reader.takeSignificant(),r.content===`streamId`){u!==null||f?(t.error(e.InvalidCommandStream,`Declare either one 'streamId = <source>' mapping or one streamId part block.`,o(r)),t.skipBlock(r.indent)):(f=!0,p.streamId=o(r),d=parseRouteParts(t,r,e.InvalidCommandStream));continue}let n=/^streamId\s*=\s*(.+)$/.exec(r.content);if(n===null||u!==null||f)t.error(e.InvalidCommandStream,`Declare either one 'streamId = <source>' mapping or one streamId part block.`,o(r)),t.skipBlock(r.indent);else{let a={...o(r),column:r.indent+1+r.content.indexOf(n[1],r.content.indexOf(`=`)+1)};u={kind:`PropertyMappingSyntax`,property:`streamId`,source:i(n[1],a,t),location:o(r)},rejectChildren(t,r,e.InvalidCommandStream)}}return{...l,streamId:u,streamIdParts:d,directiveLocations:p}}function parseStreamIdParts(t,n){let r=[],i=u(`^([A-Za-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$`);for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent)){t.reader.takeSignificant();let n=i.exec(a.content);if(n===null){invalid(t,a,`Expected '<part> <Type>' without modifiers in a streamId part block.`),t.skipBlock(a.indent);continue}let l=s(n[2],{...o(a),column:a.indent+1+a.content.indexOf(n[2],n[1].length)});c(t,l,a),r.push({kind:`EventStreamIdPartSyntax`,name:n[1],type:l,location:o(a)}),rejectChildren(t,a,e.InvalidEventSourceDeclaration)}return r.length===0&&invalid(t,n,`A streamId part block cannot be empty.`),r}function parseRouteParts(e,t,n){let r=[],a=u(`^([A-Za-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$`);for(let s=e.peekChild(t.indent);s!==void 0;s=e.peekChild(t.indent)){e.reader.takeSignificant();let t=a.exec(s.content);if(t===null){e.error(n,`Expected '<part> = <source>' in a streamId part block.`,o(s)),e.skipBlock(s.indent);continue}let c={...o(s),column:s.indent+1+s.content.indexOf(t[2],s.content.indexOf(`=`)+1)};r.push({kind:`PropertyMappingSyntax`,property:t[1],source:i(t[2],c,e),location:o(s)}),rejectChildren(e,s,n)}return r.length===0&&e.error(n,`A streamId part block cannot be empty.`,o(t)),r}function rejectChildren(e,t,n){let r=e.peekChild(t.indent);r!==void 0&&(e.error(n,`This directive cannot have children.`,o(r)),e.skipBlock(t.indent))}function invalid(t,n,r){t.error(e.InvalidEventSourceDeclaration,r,o(n))}export{parseCommandStream,parseEventSource,parseRouteParts};
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{parseMappingSource as a}from"./ExpressionParser.js";import{firstWord as o}from"./LineText.js";import{parseTypeRef as s,reportLegacyOptionalSuffix as c}from"./PropertyLineParser.js";import{parseDescription as l}from"./DescriptionParser.js";import{sourceStreamPattern as u}from"../Text/SourceStreamNames.js";const d=r(`^id\\s+"(${t})"$`),f=u(`^(identifier|streamId)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$`),p=u(`^eventsource\\s+([A-Za-z_]\\w*)$`),m=u(`^stream\\s+([A-Za-z_]\\w*)$`);function parseEventSource(e,t){let n=p.exec(t.content)?.[1]??``;n===``&&invalid(e,t,`Expected 'eventsource <Name>'.`);let r=[],a=null,s=null,c=null;for(let i=e.peekChild(t.indent);i!==void 0;i=e.peekChild(t.indent))switch(e.reader.takeSignificant(),o(i.content)){case`stream`:r.push(parseEventStream(e,i));break;case`identifier`:a=parseType(e,i,`identifier`,a);break;case`description`:s=l(e,i,s,`Event source '${n}'`,!0);break;case`id`:c=parsePin(e,i,n,c);break;default:invalid(e,i,`An event source accepts description, id, identifier and stream declarations.`),e.skipBlock(i.indent)}return{kind:`EventSourceSyntax`,name:n,streams:r,identifier:a,description:s,id:c,location:i(t)}}function parseEventStream(e,t){let n=m.exec(t.content)?.[1]??``;n===``&&invalid(e,t,`Expected 'stream <Name>'.`);let r=null,a=[],s=!1,c={},u=null,d=null;for(let f=e.peekChild(t.indent);f!==void 0;f=e.peekChild(t.indent))switch(e.reader.takeSignificant(),o(f.content)){case`streamId`:s?(invalid(e,f,`Declare either one 'streamId <Type>' or one streamId part block.`),e.skipBlock(f.indent)):f.content===`streamId`?(s=!0,c.streamId=i(f),a=parseStreamIdParts(e,f)):(r=parseType(e,f,`streamId`,r),s=r!==null);break;case`description`:u=l(e,f,u,`Stream '${n}'`,!0);break;case`id`:d=parsePin(e,f,n,d);break;default:invalid(e,f,`A stream accepts description, id and streamId declarations.`),e.skipBlock(f.indent)}return{kind:`EventStreamSyntax`,name:n,streamId:r,streamIdParts:a,description:u,id:d,directiveLocations:c,location:i(t)}}function parseType(t,n,r,a){let o=f.exec(n.content);return o===null||a!==null?invalid(t,n,`Declare at most one '${r} <Type>'.`):(a=s(o[2],{...i(n),column:n.indent+1+n.content.indexOf(o[2],r.length)}),c(t,a,n)),rejectChildren(t,n,e.InvalidEventSourceDeclaration),a}function parsePin(t,r,a,o){let s=d.exec(r.content),c=s===null?null:n(s[1]);return c===null||c.trim()===``||o!==null?invalid(t,r,`Declare at most one nonempty rename-only 'id "<old-name>"'.`):(o=c,c===a&&t.information(e.RedundantSourceStreamId,`The rename pin repeats the current name; omit it for a new declaration.`,i(r))),rejectChildren(t,r,e.InvalidEventSourceDeclaration),o}function parseCommandStream(t,n,r,o){let[s,c]=r.type.name.split(`.`),l={kind:`CommandStreamSyntax`,eventSource:s,stream:c,streamId:null,streamIdParts:[],propertyCandidate:null,referenceLocation:r.type.location,referenceLength:r.type.name.length,location:i(n)};if(o)return t.error(e.AmbiguousCommandStream,`'${n.content}' has both a property type and a stream route interpretation; neither is selected.`,i(n)),{...l,propertyCandidate:r};let u=null,d=[],f=!1,p={};for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){if(t.reader.takeSignificant(),r.content===`streamId`){u!==null||f?(t.error(e.InvalidCommandStream,`Declare either one 'streamId = <source>' mapping or one streamId part block.`,i(r)),t.skipBlock(r.indent)):(f=!0,p.streamId=i(r),d=parseRouteParts(t,r,e.InvalidCommandStream));continue}let n=/^streamId\s*=\s*(.+)$/.exec(r.content);if(n===null||u!==null||f)t.error(e.InvalidCommandStream,`Declare either one 'streamId = <source>' mapping or one streamId part block.`,i(r)),t.skipBlock(r.indent);else{let o={...i(r),column:r.indent+1+r.content.indexOf(n[1],r.content.indexOf(`=`)+1)};u={kind:`PropertyMappingSyntax`,property:`streamId`,source:a(n[1],o,t),location:i(r)},rejectChildren(t,r,e.InvalidCommandStream)}}return{...l,streamId:u,streamIdParts:d,directiveLocations:p}}function parseStreamIdParts(t,n){let r=[],a=u(`^([A-Za-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$`);for(let o=t.peekChild(n.indent);o!==void 0;o=t.peekChild(n.indent)){t.reader.takeSignificant();let n=a.exec(o.content);if(n===null){invalid(t,o,`Expected '<part> <Type>' without modifiers in a streamId part block.`),t.skipBlock(o.indent);continue}let l=s(n[2],{...i(o),column:o.indent+1+o.content.indexOf(n[2],n[1].length)});c(t,l,o),r.push({kind:`EventStreamIdPartSyntax`,name:n[1],type:l,location:i(o)}),rejectChildren(t,o,e.InvalidEventSourceDeclaration)}return r.length===0&&invalid(t,n,`A streamId part block cannot be empty.`),r}function parseRouteParts(e,t,n){let r=[],o=u(`^([A-Za-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$`);for(let s=e.peekChild(t.indent);s!==void 0;s=e.peekChild(t.indent)){e.reader.takeSignificant();let t=o.exec(s.content);if(t===null){e.error(n,`Expected '<part> = <source>' in a streamId part block.`,i(s)),e.skipBlock(s.indent);continue}let c={...i(s),column:s.indent+1+s.content.indexOf(t[2],s.content.indexOf(`=`)+1)};r.push({kind:`PropertyMappingSyntax`,property:t[1],source:a(t[2],c,e),location:i(s)}),rejectChildren(e,s,n)}return r.length===0&&e.error(n,`A streamId part block cannot be empty.`,i(t)),r}function rejectChildren(e,t,n){let r=e.peekChild(t.indent);r!==void 0&&(e.error(n,`This directive cannot have children.`,i(r)),e.skipBlock(t.indent))}function invalid(t,n,r){t.error(e.InvalidEventSourceDeclaration,r,i(n))}export{parseCommandStream,parseEventSource,parseRouteParts};
2
2
  //# sourceMappingURL=EventSourceParser.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{nativePattern as t,pattern as n}from"../Text/patterns.js";import{isExactNumberToken as r,parseExactNumber as i}from"../Syntax/ExactNumber.js";import{unescapeString as a}from"../Text/StringLiteral.js";import{InvalidStructuredValue as o,StructuredValueParser as s}from"./StructuredValueParser.js";const c=n(`^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$`),l=t(`^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$`),u=n(`^-?\\d+(\\.\\d+)?$`),d=[`command`,`arguments`,`tenant`,`causedBy`,`causation`,`occurred`,`identity`],f=[`subject`,`name`,`userName`],p=[`id`,`name`,`userName`,`isAuthenticated`,`roles`,`claims`];function parseModeledMappingSource(e,t,n){return parseMappingSource(e,t,n,!0)}function parseMappingSource(t,n,r,i=!1){if(t=t.trim(),t===`$refusal`||t.startsWith(`$refusal.`))return{kind:`RefusalExpressionSyntax`,member:t===`$refusal`?``:t.substring(9),location:n};if(t===`$identity`||t===`$identity.`)return r?.error(e.InvalidExpression,`Invalid expression '${t}'`,n),{kind:`RawExpressionSyntax`,text:t,location:n};if(t.startsWith(`$identity.`)){let e=t.substring(10);return r?.deferIdentityValidation!==!0&&warnOnUnknownIdentityProperty(e.split(`.`)[0],`$identity`,n,r),{kind:`IdentityExpressionSyntax`,path:e,location:n}}if(t.startsWith(`$context.`)){let e=t.substring(9);return warnOnUnknownContextPath(e,n,r),{kind:`ContextExpressionSyntax`,path:e,location:n}}if(t.startsWith(`$env.`))return{kind:`EnvironmentExpressionSyntax`,name:t.substring(5),location:n};if(t.startsWith(`$strings.`))return{kind:`StringsExpressionSyntax`,key:t.substring(9),location:n};if(t.startsWith(`$.`))return{kind:`SourceItemExpressionSyntax`,path:t.substring(2),location:n};if(t.startsWith(`{`)||t.startsWith(`[`))try{return new s(t,n,r).parse()}catch(i){if(!(i instanceof o))throw i;return r?.error(e.InvalidStructuredValue,`Invalid inline structured value: ${i.message}`,n),{kind:`RawExpressionSyntax`,text:t,location:n}}let a=r===void 0?parseLiteral(t,n):parseLiteral(t,n,r);return a===void 0?(i||r?.sourceOptions.numericMode===`exact`?l:c).test(t)?{kind:`PathExpressionSyntax`,path:t,location:n}:{kind:`RawExpressionSyntax`,text:t,location:n}:a}function warnOnUnknownContextPath(t,n,r){let[i,a]=t.split(`.`);d.includes(i)?a!==void 0&&i===`causedBy`&&!f.includes(a)?r?.warning(e.UnknownContextCausedByProperty,`Unknown $context.causedBy property '${a}' - expected ${f.join(`, `)}`,n):a!==void 0&&i===`identity`&&warnOnUnknownIdentityProperty(a,`$context.identity`,n,r):r?.warning(e.UnknownContextPath,`Unknown $context path '${t}' - expected one of ${d.join(`, `)}`,n)}function warnOnUnknownIdentityProperty(t,n,r,i){p.includes(t)||i?.warning(e.UnknownContextIdentityProperty,`Unknown ${n} property '${t}' - expected ${p.join(`, `)}`,r)}function parseLiteral(t,n,o){let literal=e=>({kind:`LiteralExpressionSyntax`,value:e,location:n});switch(t){case`true`:return literal(!0);case`false`:return literal(!1);case`null`:return literal(null)}if(t.length>=2&&(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)))return literal(a(t.substring(1,t.length-1)));if(o?.sourceOptions.numericMode===`exact`){if(!r(t))return;let a=i(t);return a===void 0?(o.error(e.InexactNumericLiteral,`Numeric literal is not exactly representable in the bounded Decimal domain.`,n),{kind:`RawExpressionSyntax`,text:t,location:n}):literal(a)}if(u.test(t)&&!Number.isNaN(Number(t)))return literal(Number(t))}export{p as identityProperties,parseLiteral,parseMappingSource,parseModeledMappingSource};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{unescapeString as t}from"../Text/StringLiteral.js";import{nativePattern as n,pattern as r}from"../Text/patterns.js";import{isExactNumberToken as i,parseExactNumber as a}from"../Syntax/ExactNumber.js";import{InvalidStructuredValue as o,StructuredValueParser as s}from"./StructuredValueParser.js";const c=r(`^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$`),l=n(`^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$`),u=r(`^-?\\d+(\\.\\d+)?$`),d=[`command`,`arguments`,`tenant`,`causedBy`,`causation`,`occurred`,`identity`],f=[`subject`,`name`,`userName`],p=[`id`,`name`,`userName`,`isAuthenticated`,`roles`,`claims`];function parseModeledMappingSource(e,t,n){return parseMappingSource(e,t,n,!0)}function parseMappingSource(t,n,r,i=!1){if(t=t.trim(),t===`$refusal`||t.startsWith(`$refusal.`))return{kind:`RefusalExpressionSyntax`,member:t===`$refusal`?``:t.substring(9),location:n};if(t===`$identity`||t===`$identity.`)return r?.error(e.InvalidExpression,`Invalid expression '${t}'`,n),{kind:`RawExpressionSyntax`,text:t,location:n};if(t.startsWith(`$identity.`)){let e=t.substring(10);return r?.deferIdentityValidation!==!0&&warnOnUnknownIdentityProperty(e.split(`.`)[0],`$identity`,n,r),{kind:`IdentityExpressionSyntax`,path:e,location:n}}if(t.startsWith(`$context.`)){let e=t.substring(9);return warnOnUnknownContextPath(e,n,r),{kind:`ContextExpressionSyntax`,path:e,location:n}}if(t.startsWith(`$env.`))return{kind:`EnvironmentExpressionSyntax`,name:t.substring(5),location:n};if(t.startsWith(`$strings.`))return{kind:`StringsExpressionSyntax`,key:t.substring(9),location:n};if(t.startsWith(`$.`))return{kind:`SourceItemExpressionSyntax`,path:t.substring(2),location:n};if(t.startsWith(`{`)||t.startsWith(`[`))try{return new s(t,n,r).parse()}catch(i){if(!(i instanceof o))throw i;return r?.error(e.InvalidStructuredValue,`Invalid inline structured value: ${i.message}`,n),{kind:`RawExpressionSyntax`,text:t,location:n}}let a=r===void 0?parseLiteral(t,n):parseLiteral(t,n,r);return a===void 0?(i||r?.sourceOptions.numericMode===`exact`?l:c).test(t)?{kind:`PathExpressionSyntax`,path:t,location:n}:{kind:`RawExpressionSyntax`,text:t,location:n}:a}function warnOnUnknownContextPath(t,n,r){let[i,a]=t.split(`.`);d.includes(i)?a!==void 0&&i===`causedBy`&&!f.includes(a)?r?.warning(e.UnknownContextCausedByProperty,`Unknown $context.causedBy property '${a}' - expected ${f.join(`, `)}`,n):a!==void 0&&i===`identity`&&warnOnUnknownIdentityProperty(a,`$context.identity`,n,r):r?.warning(e.UnknownContextPath,`Unknown $context path '${t}' - expected one of ${d.join(`, `)}`,n)}function warnOnUnknownIdentityProperty(t,n,r,i){p.includes(t)||i?.warning(e.UnknownContextIdentityProperty,`Unknown ${n} property '${t}' - expected ${p.join(`, `)}`,r)}function parseLiteral(n,r,o){let literal=e=>({kind:`LiteralExpressionSyntax`,value:e,location:r});switch(n){case`true`:return literal(!0);case`false`:return literal(!1);case`null`:return literal(null)}if(n.length>=2&&(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`)))return literal(t(n.substring(1,n.length-1)));if(o?.sourceOptions.numericMode===`exact`){if(!i(n))return;let t=a(n);return t===void 0?(o.error(e.InexactNumericLiteral,`Numeric literal is not exactly representable in the bounded Decimal domain.`,r),{kind:`RawExpressionSyntax`,text:n,location:r}):literal(t)}if(u.test(n)&&!Number.isNaN(Number(n)))return literal(Number(n))}export{p as identityProperties,parseLiteral,parseMappingSource,parseModeledMappingSource};
2
2
  //# sourceMappingURL=ExpressionParser.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{firstWord as n}from"./LineText.js";import{locationOf as r}from"./SourceLine.js";import{combineAuthorize as i,parseAuthorize as a}from"./AuthorizeParser.js";import{parseDescription as o}from"./DescriptionParser.js";import{parsePurposeReference as s}from"./PurposeParser.js";import{parseDocumentation as c}from"./DocumentationParser.js";import{parseDependsOn as l}from"./DependsOnParser.js";import{parseFileImport as u}from"./FileImportParser.js";import{collectInputUses as d}from"./InputUses.js";import{misplacedReactionIdentity as f}from"./ReactionIdentityParser.js";import{parseExample as p}from"./SpecificationExampleParser.js";import{parseSlice as m}from"./SliceParser.js";const h=t(`^feature\\s+([A-Za-z_]\\w*)$`),g=/* @__PURE__ */ new Set([`on`,`uses`,`contribute`]),_=`description, documentation, depends on <Name>, authorize, import, feature, slice, contribute, example, 'on <trigger>' or 'uses <Behavior>'`;var FeatureBody=class{name;#e=[];#t=[];#n=[];#r=[];#i=[];#a=[];#o=null;#s=null;#c=null;constructor(e){this.name=e}tryParse(t,r){let h=n(r.content);switch(h){case`runs`:return f(t,r),!0;case`description`:return this.#o=o(t,r,this.#o,`Feature '${this.name}'`),!0;case`documentation`:return this.#s=c(t,r,this.#s,`Feature '${this.name}'`),!0;case`depends`:return l(t,r,this.#i,e.UnknownFeatureDirective),!0;case`purpose`:return s(t,r,this.#a),!0;case`authorize`:return this.#c=i(this.#c,a(t,r)),!0;case`import`:return u(t,r,this.#r),!0;case`feature`:return this.#e.push(parseFeature(t,r)),!0;case`example`:return this.#n.push(p(t,r)),!0;case`slice`:return this.#t.push(m(t,r)),!0;default:return g.has(h)?(d(t,r),!0):!1}}build(e,t=!1){return{kind:`FeatureSyntax`,name:this.name,description:this.#o,documentation:this.#s,authorize:this.#c,dependsOn:this.#i,purposes:this.#a,features:this.#e,slices:this.#t,examples:this.#n,fileImports:this.#r,isPlacement:t,location:e}}};function parseFeature(t,i){let a=h.exec(i.content)?.[1]??``;a===``&&t.error(e.InvalidFeatureDeclaration,`Invalid feature declaration '${i.content}' - expected 'feature <Name>'`,r(i));let o=new FeatureBody(a),s=t.scope;t.scope=[...s,a];for(let a=t.peekChild(i.indent);a!==void 0;a=t.peekChild(i.indent))t.reader.takeSignificant(),o.tryParse(t,a)||(t.error(e.UnknownFeatureDirective,`Unexpected '${n(a.content)}' in feature body - expected ${_}`,r(a)),t.skipBlock(a.indent));return t.scope=s,o.build(r(i))}export{FeatureBody,_ as featureBodyExpected,parseFeature};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{firstWord as r}from"./LineText.js";import{combineAuthorize as i,parseAuthorize as a}from"./AuthorizeParser.js";import{parseDescription as o}from"./DescriptionParser.js";import{parsePurposeReference as s}from"./PurposeParser.js";import{parseDocumentation as c}from"./DocumentationParser.js";import{parseDependsOn as l}from"./DependsOnParser.js";import{parseFileImport as u}from"./FileImportParser.js";import{collectInputUses as d}from"./InputUses.js";import{misplacedReactionIdentity as f}from"./ReactionIdentityParser.js";import{parseExample as p}from"./SpecificationExampleParser.js";import{parseSlice as m}from"./SliceParser.js";const h=t(`^feature\\s+([A-Za-z_]\\w*)$`),g=/* @__PURE__ */ new Set([`on`,`uses`,`contribute`]),_=`description, documentation, depends on <Name>, authorize, import, feature, slice, contribute, example, 'on <trigger>' or 'uses <Behavior>'`;var FeatureBody=class{name;#e=[];#t=[];#n=[];#r=[];#i=[];#a=[];#o=null;#s=null;#c=null;constructor(e){this.name=e}tryParse(t,n){let h=r(n.content);switch(h){case`runs`:return f(t,n),!0;case`description`:return this.#o=o(t,n,this.#o,`Feature '${this.name}'`),!0;case`documentation`:return this.#s=c(t,n,this.#s,`Feature '${this.name}'`),!0;case`depends`:return l(t,n,this.#i,e.UnknownFeatureDirective),!0;case`purpose`:return s(t,n,this.#a),!0;case`authorize`:return this.#c=i(this.#c,a(t,n)),!0;case`import`:return u(t,n,this.#r),!0;case`feature`:return this.#e.push(parseFeature(t,n)),!0;case`example`:return this.#n.push(p(t,n)),!0;case`slice`:return this.#t.push(m(t,n)),!0;default:return g.has(h)?(d(t,n),!0):!1}}build(e,t=!1){return{kind:`FeatureSyntax`,name:this.name,description:this.#o,documentation:this.#s,authorize:this.#c,dependsOn:this.#i,purposes:this.#a,features:this.#e,slices:this.#t,examples:this.#n,fileImports:this.#r,isPlacement:t,location:e}}};function parseFeature(t,i){let a=h.exec(i.content)?.[1]??``;a===``&&t.error(e.InvalidFeatureDeclaration,`Invalid feature declaration '${i.content}' - expected 'feature <Name>'`,n(i));let o=new FeatureBody(a),s=t.scope;t.scope=[...s,a];for(let a=t.peekChild(i.indent);a!==void 0;a=t.peekChild(i.indent))t.reader.takeSignificant(),o.tryParse(t,a)||(t.error(e.UnknownFeatureDirective,`Unexpected '${r(a.content)}' in feature body - expected ${_}`,n(a)),t.skipBlock(a.indent));return t.scope=s,o.build(n(i))}export{FeatureBody,_ as featureBodyExpected,parseFeature};
2
2
  //# sourceMappingURL=FeatureBody.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{dotNetWhitespace as t,pattern as n}from"../Text/patterns.js";import{firstWord as r}from"./LineText.js";import{locationOf as i}from"./SourceLine.js";import{parseCondition as a}from"./ConditionParser.js";const o=n(`^when${t}+([^\\n]+)${t}+execute${t}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),s=n(`^otherwise${t}+execute${t}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),c=n(`^with${t}+([A-Za-z_]\\w*)${t}+from${t}+([^\\n]+)$`),l=n(`^item\\.[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$`),u=RegExp(`^${t}+|${t}+$`,`gu`);function parseGuardedAction(t,n,c,l){let u=[],d=null,f=null,p=!1;for(let c=t.peekChild(n.indent);c!==void 0;c=t.peekChild(n.indent)){t.reader.takeSignificant();let n=o.exec(c.content),m=s.exec(c.content);if(n!==null){p&&t.error(e.MisplacedActionOtherwise,`A 'when' alternative must precede 'otherwise'`,i(c));let r=a(t,n[1],i(c),!0),o=parseArguments(t,c);r!==null&&(validateCondition(t,r),u.push({kind:`ScreenActionAlternativeSyntax`,condition:r,command:n[2],arguments:o,location:i(c)}))}else if(c.content===`otherwise hidden`||m!==null){if(p&&t.error(e.MisplacedActionOtherwise,`A guarded action permits only one 'otherwise'`,i(c)),p=!0,m!==null)d={kind:`ScreenActionOtherwiseSyntax`,outcome:`Execute`,command:m[1],arguments:parseArguments(t,c),location:i(c)};else{d={kind:`ScreenActionOtherwiseSyntax`,outcome:`Hidden`,command:null,arguments:[],location:i(c)};for(let n=t.peekChild(c.indent);n!==void 0;n=t.peekChild(c.indent))t.reader.takeSignificant(),t.error(e.InvalidActionAlternative,`'otherwise hidden' cannot declare command arguments`,i(n)),t.skipBlock(n.indent)}}else if(r(c.content)===`navigate`)f!==null&&t.error(e.InvalidActionAlternative,`A guarded action permits only one 'navigate to'`,i(c)),f=l(t,c.content,c)??null;else{let n=r(c.content)===`label`;t.error(n?e.UnknownActionDirective:e.InvalidActionAlternative,n?`A guarded action's header already supplies its label`:`Unexpected '${c.content}' in guarded action - expected 'when <condition> execute <Command>', 'otherwise hidden', 'otherwise execute <Command>' or 'navigate to ...'`,i(c)),t.skipBlock(c.indent)}}return u.length===0&&t.error(e.GuardedActionWithoutAlternatives,`A guarded action must declare at least one 'when' alternative`,i(n)),{kind:`ScreenGuardedActionSyntax`,label:c,alternatives:u,otherwise:d,navigate:f,location:i(n)}}function parseArguments(t,n){let r=[];for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent)){t.reader.takeSignificant();let n=c.exec(a.content);n===null?(t.error(e.InvalidInteractionArgument,`Invalid argument '${a.content}' - expected 'with <name> from <binding>'`,i(a)),t.skipBlock(a.indent)):r.push({kind:`InteractionArgumentSyntax`,name:n[1],binding:n[2].replace(u,``),location:i(a)})}return r}function validateCondition(t,n){if(n.kind===`LogicalConditionSyntax`){validateCondition(t,n.left),validateCondition(t,n.right);return}let r=n.right.kind===`LiteralExpressionSyntax`?n.right.value:void 0,i=l.test(n.left)&&n.right.kind===`LiteralExpressionSyntax`;[`GreaterThan`,`GreaterThanOrEqual`,`LessThan`,`LessThanOrEqual`].includes(n.operator)?i&&=typeof r==`number`||typeof r==`object`&&!!r:[`Contains`,`StartsWith`].includes(n.operator)&&(i&&=typeof r==`string`),i||t.error(e.UnsupportedActionConditionOperand,`Guarded action conditions compare 'item.<field>' with a literal; ordering requires a number and text operators require a string`,n.location)}export{parseGuardedAction,validateCondition};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{dotNetWhitespace as t,pattern as n}from"../Text/patterns.js";import{locationOf as r}from"./SourceLine.js";import{firstWord as i}from"./LineText.js";import{parseCondition as a}from"./ConditionParser.js";const o=n(`^when${t}+([^\\n]+)${t}+execute${t}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),s=n(`^otherwise${t}+execute${t}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),c=n(`^with${t}+([A-Za-z_]\\w*)${t}+from${t}+([^\\n]+)$`),l=n(`^item\\.[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$`),u=RegExp(`^${t}+|${t}+$`,`gu`);function parseGuardedAction(t,n,c,l){let u=[],d=null,f=null,p=!1;for(let c=t.peekChild(n.indent);c!==void 0;c=t.peekChild(n.indent)){t.reader.takeSignificant();let n=o.exec(c.content),m=s.exec(c.content);if(n!==null){p&&t.error(e.MisplacedActionOtherwise,`A 'when' alternative must precede 'otherwise'`,r(c));let i=a(t,n[1],r(c),!0),o=parseArguments(t,c);i!==null&&(validateCondition(t,i),u.push({kind:`ScreenActionAlternativeSyntax`,condition:i,command:n[2],arguments:o,location:r(c)}))}else if(c.content===`otherwise hidden`||m!==null){if(p&&t.error(e.MisplacedActionOtherwise,`A guarded action permits only one 'otherwise'`,r(c)),p=!0,m!==null)d={kind:`ScreenActionOtherwiseSyntax`,outcome:`Execute`,command:m[1],arguments:parseArguments(t,c),location:r(c)};else{d={kind:`ScreenActionOtherwiseSyntax`,outcome:`Hidden`,command:null,arguments:[],location:r(c)};for(let n=t.peekChild(c.indent);n!==void 0;n=t.peekChild(c.indent))t.reader.takeSignificant(),t.error(e.InvalidActionAlternative,`'otherwise hidden' cannot declare command arguments`,r(n)),t.skipBlock(n.indent)}}else if(i(c.content)===`navigate`)f!==null&&t.error(e.InvalidActionAlternative,`A guarded action permits only one 'navigate to'`,r(c)),f=l(t,c.content,c)??null;else{let n=i(c.content)===`label`;t.error(n?e.UnknownActionDirective:e.InvalidActionAlternative,n?`A guarded action's header already supplies its label`:`Unexpected '${c.content}' in guarded action - expected 'when <condition> execute <Command>', 'otherwise hidden', 'otherwise execute <Command>' or 'navigate to ...'`,r(c)),t.skipBlock(c.indent)}}return u.length===0&&t.error(e.GuardedActionWithoutAlternatives,`A guarded action must declare at least one 'when' alternative`,r(n)),{kind:`ScreenGuardedActionSyntax`,label:c,alternatives:u,otherwise:d,navigate:f,location:r(n)}}function parseArguments(t,n){let i=[];for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent)){t.reader.takeSignificant();let n=c.exec(a.content);n===null?(t.error(e.InvalidInteractionArgument,`Invalid argument '${a.content}' - expected 'with <name> from <binding>'`,r(a)),t.skipBlock(a.indent)):i.push({kind:`InteractionArgumentSyntax`,name:n[1],binding:n[2].replace(u,``),location:r(a)})}return i}function validateCondition(t,n){if(n.kind===`LogicalConditionSyntax`){validateCondition(t,n.left),validateCondition(t,n.right);return}let r=n.right.kind===`LiteralExpressionSyntax`?n.right.value:void 0,i=l.test(n.left)&&n.right.kind===`LiteralExpressionSyntax`;[`GreaterThan`,`GreaterThanOrEqual`,`LessThan`,`LessThanOrEqual`].includes(n.operator)?i&&=typeof r==`number`||typeof r==`object`&&!!r:[`Contains`,`StartsWith`].includes(n.operator)&&(i&&=typeof r==`string`),i||t.error(e.UnsupportedActionConditionOperand,`Guarded action conditions compare 'item.<field>' with a literal; ordering requires a number and text operators require a string`,n.location)}export{parseGuardedAction,validateCondition};
2
2
  //# sourceMappingURL=GuardedActionParser.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{stringBodyPattern as n,unescapeString as r}from"../Text/StringLiteral.js";import{parseMappingSource as i}from"./ExpressionParser.js";import{firstWord as a,unescapeIdentifier as o}from"./LineText.js";import{locationOf as s}from"./SourceLine.js";import{parseTypeRef as c,reportLegacyOptionalSuffix as l}from"./PropertyLineParser.js";import{parseDescription as u}from"./DescriptionParser.js";import{isCode as d,isFile as f,parseCode as p,parseFile as m}from"./ImplementationParser.js";const h=t(`^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$`),g=t(`^claim\\s+"(${n})"$`),_=t(`^query\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(?:\\s+by\\s+(.+))?$`);function parseIdentity(t,n,r){if(n.content!==`identity`)return t.error(e.InvalidIdentityDeclaration,`Invalid identity declaration '${n.content}' - expected 'identity'`,s(n)),t.skipBlock(n.indent),r;if(r!==null)return t.error(e.DuplicateIdentity,`The document already declares an identity block - a document can have at most one`,s(n)),t.skipBlock(n.indent),r;let i=[],d=null;for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){if(t.reader.takeSignificant(),a(r.content)===`description`){d=u(t,r,d,`Identity`);continue}let n=h.exec(r.content);if(n===null){t.error(e.InvalidIdentityDetail,`Invalid identity detail '${r.content}' - expected '<name> <Type> [from claim "<name>" | from query <Query> by <expression>]'`,s(r)),t.skipBlock(r.indent);continue}let f=c(n[2],{...s(r),column:r.indent+1+r.content.indexOf(n[2],n[1].length)});l(t,f,r);let p=n[3]===void 0?parseEscape(t,r):parseSource(t,r,n[3]);p!==null&&i.push({kind:`IdentityDetailSyntax`,name:o(n[1]),type:f,source:p,location:s(r)}),rejectBody(t,r,n[3]===void 0?e.InvalidIdentityDetail:e.IdentitySourceWithBody)}return{kind:`IdentitySyntax`,details:i,description:d,location:s(n)}}function parseSource(t,n,o){let c=g.exec(o);if(c!==null)return{kind:`ClaimIdentitySourceSyntax`,claim:r(c[1]),location:s(n)};let l=_.exec(o);if(l!==null)return l[2]===void 0?(t.error(e.IdentityQueryWithoutKey,`An identity query source requires 'by <expression>'`,s(n)),null):{kind:`QueryIdentitySourceSyntax`,query:l[1],by:i(l[2],s(n),t),location:s(n)};let u=a(o);return t.error(u===`claim`||u===`query`?e.InvalidIdentityDetail:e.UnknownIdentitySource,`Invalid identity source '${o}' - expected 'claim "<name>"' or 'query <Query> by <expression>'`,s(n)),null}function parseEscape(t,n){let r=t.peekChild(n.indent);if(r===void 0)return t.error(e.IdentityDetailWithoutSource,`An identity detail requires a claim, query, inline code block or file source`,s(n)),null;if(t.reader.takeSignificant(),f(r)){let n=m(t,r);return rejectBody(t,r,e.InvalidIdentityDetail),{kind:`FileIdentitySourceSyntax`,file:n,location:s(r)}}if(d(t,r)){let e=p(t,r);return e===null?null:{kind:`CodeIdentitySourceSyntax`,code:e,location:s(r)}}return t.error(e.InvalidIdentityDetail,`Unexpected '${r.content}' under an identity detail - expected a file reference or inline code block`,s(r)),t.skipBlock(r.indent),null}function rejectBody(e,t,n){for(let r=e.peekChild(t.indent);r!==void 0;r=e.peekChild(t.indent))e.reader.takeSignificant(),e.error(n,`Unexpected '${r.content}' under an identity source - refresh and caching are the runtime's business; a detail has exactly one source`,s(r)),e.skipBlock(r.indent)}export{parseIdentity};
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{parseMappingSource as a}from"./ExpressionParser.js";import{firstWord as o,unescapeIdentifier as s}from"./LineText.js";import{parseTypeRef as c,reportLegacyOptionalSuffix as l}from"./PropertyLineParser.js";import{parseDescription as u}from"./DescriptionParser.js";import{isCode as d,isFile as f,parseCode as p,parseFile as m}from"./ImplementationParser.js";const h=r(`^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$`),g=r(`^claim\\s+"(${t})"$`),_=r(`^query\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(?:\\s+by\\s+(.+))?$`);function parseIdentity(t,n,r){if(n.content!==`identity`)return t.error(e.InvalidIdentityDeclaration,`Invalid identity declaration '${n.content}' - expected 'identity'`,i(n)),t.skipBlock(n.indent),r;if(r!==null)return t.error(e.DuplicateIdentity,`The document already declares an identity block - a document can have at most one`,i(n)),t.skipBlock(n.indent),r;let a=[],d=null;for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){if(t.reader.takeSignificant(),o(r.content)===`description`){d=u(t,r,d,`Identity`);continue}let n=h.exec(r.content);if(n===null){t.error(e.InvalidIdentityDetail,`Invalid identity detail '${r.content}' - expected '<name> <Type> [from claim "<name>" | from query <Query> by <expression>]'`,i(r)),t.skipBlock(r.indent);continue}let f=c(n[2],{...i(r),column:r.indent+1+r.content.indexOf(n[2],n[1].length)});l(t,f,r);let p=n[3]===void 0?parseEscape(t,r):parseSource(t,r,n[3]);p!==null&&a.push({kind:`IdentityDetailSyntax`,name:s(n[1]),type:f,source:p,location:i(r)}),rejectBody(t,r,n[3]===void 0?e.InvalidIdentityDetail:e.IdentitySourceWithBody)}return{kind:`IdentitySyntax`,details:a,description:d,location:i(n)}}function parseSource(t,r,s){let c=g.exec(s);if(c!==null)return{kind:`ClaimIdentitySourceSyntax`,claim:n(c[1]),location:i(r)};let l=_.exec(s);if(l!==null)return l[2]===void 0?(t.error(e.IdentityQueryWithoutKey,`An identity query source requires 'by <expression>'`,i(r)),null):{kind:`QueryIdentitySourceSyntax`,query:l[1],by:a(l[2],i(r),t),location:i(r)};let u=o(s);return t.error(u===`claim`||u===`query`?e.InvalidIdentityDetail:e.UnknownIdentitySource,`Invalid identity source '${s}' - expected 'claim "<name>"' or 'query <Query> by <expression>'`,i(r)),null}function parseEscape(t,n){let r=t.peekChild(n.indent);if(r===void 0)return t.error(e.IdentityDetailWithoutSource,`An identity detail requires a claim, query, inline code block or file source`,i(n)),null;if(t.reader.takeSignificant(),f(r)){let n=m(t,r);return rejectBody(t,r,e.InvalidIdentityDetail),{kind:`FileIdentitySourceSyntax`,file:n,location:i(r)}}if(d(t,r)){let e=p(t,r);return e===null?null:{kind:`CodeIdentitySourceSyntax`,code:e,location:i(r)}}return t.error(e.InvalidIdentityDetail,`Unexpected '${r.content}' under an identity detail - expected a file reference or inline code block`,i(r)),t.skipBlock(r.indent),null}function rejectBody(e,t,n){for(let r=e.peekChild(t.indent);r!==void 0;r=e.peekChild(t.indent))e.reader.takeSignificant(),e.error(n,`Unexpected '${r.content}' under an identity source - refresh and caching are the runtime's business; a detail has exactly one source`,i(r)),e.skipBlock(r.indent)}export{parseIdentity};
2
2
  //# sourceMappingURL=IdentityParser.js.map
@@ -1,3 +1,3 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{unescapeString as t}from"../Text/StringLiteral.js";import{firstWord as n}from"./LineText.js";import{locationOf as r}from"./SourceLine.js";import{isBlankImplementationHint as i}from"../Text/ImplementationHintText.js";const a=/* @__PURE__ */ RegExp(`^hint[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+"((?:[^"\\\\\\r\\n]|\\\\[^\\r\\n])*)"$`),isFile=e=>n(e.content)===`file`&&e.content.substring(4).trim().length>0,isCode=(e,t)=>t.content.startsWith("```")||e.languages.has(t.content);function parseFile(t,n){let i=n.content.substring(4).trim();return/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/.test(i)&&t.warning(e.AbsoluteFileReference,`'${i}' is an absolute path - a file reference is relative to the repository root, so it means the same thing on every machine`,r(n)),{kind:`FileReferenceSyntax`,path:i,location:r(n)}}const isClosingCodeFence=e=>e.raw.trim()==="```";function parseCode(t,n){let i=n.content.startsWith("```")?n.content.substring(3):n.content;if(!t.languages.has(i))return t.error(e.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${n.content}'`,r(n)),null;let a=n;if(!n.content.startsWith("```")){t.warning(e.LegacyInlineCodeFence,`'${i}' on its own line is deprecated - use '\`\`\`${i}' instead`,r(n));let o=t.reader.peekSignificant();if(o===void 0||o.indent<=n.indent||o.content!=="```"&&o.content!==`\`\`\`${i}`)return t.error(e.ExpectedCodeFence,`Expected an opening \`\`\`${i} fence after '${i}'`,r(n)),null;a=t.reader.takeSignificant()}let o=[];for(;;){let n=t.reader.takeRaw();if(n===void 0){t.error(e.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",r(a));break}if(isClosingCodeFence(n))break;let i=0;for(;i<a.indent&&n.raw[i]===` `;)i++;o.push(n.raw.substring(i))}return{kind:`CodeBlockSyntax`,language:i,code:o.join(`
2
- `),location:r(n)}}function parseHandler(t,i){let a=t.peekChild(i.indent);if(a===void 0)return t.error(e.HandlerWithoutImplementation,`Expected a 'file' directive or an inline code block in the handler`,r(i)),null;if(t.reader.takeSignificant(),n(a.content)===`implementation`)return parseImplementation(t,i,a);let o=isFile(a)?parseFile(t,a):null,s=o===null&&isCode(t,a)?parseCode(t,a):null;if(o!==null||s!==null){let a=t.peekChild(i.indent);return a!==void 0&&n(a.content)===`implementation`&&(t.error(e.ConflictingImplementationSources,`A handler cannot mix wrapped and direct sources.`,r(a)),t.skipBlock(i.indent)),{kind:`HandlerSyntax`,file:o,code:s,implementation:null,location:r(i)}}return t.error(e.UnknownHandlerDirective,`Unexpected '${a.content}' in handler - expected 'file <path>' or an inline code block`,r(a)),t.skipBlock(i.indent),null}function parseImplementation(t,i,a){let o=parseImplementationWrapper(t,a);for(let a=t.peekChild(i.indent);a!==void 0;a=t.peekChild(i.indent))t.reader.takeSignificant(),t.error(n(a.content)===`implementation`?e.InvalidImplementationBlock:e.ConflictingImplementationSources,`A handler has one implementation wrapper and cannot mix wrapped and direct sources.`,r(a)),isCode(t,a)?parseCode(t,a):t.skipBlock(a.indent);return{kind:`HandlerSyntax`,...o,location:r(i)}}function parseImplementationWrapper(o,s){let c=[],l=null,u=null,d=!1;s.content!==`implementation`&&o.error(e.InvalidImplementationBlock,`Expected 'implementation' with no operand.`,r(s));for(let f=o.peekChild(s.indent);f!==void 0;f=o.peekChild(s.indent))if(o.reader.takeSignificant(),n(f.content)===`hint`||a.test(f.content)){let n=a.exec(f.content),s=n===null?null:t(n[1]);i(s)?o.error(e.InvalidImplementationHint,`Expected 'hint' followed by one nonblank quoted string.`,r(f)):c.push({kind:`ImplementationHintSyntax`,text:s,location:r(f)});let l=o.peekChild(f.indent);l!==void 0&&(o.error(e.InvalidImplementationHint,`A hint cannot have children.`,r(l)),o.skipBlock(f.indent))}else if(isFile(f)||f.content.startsWith("```")){d&&o.error(e.ConflictingImplementationSources,`An implementation has at most one file or inline payload.`,r(f));let t=isFile(f)?parseFile(o,f):null,n=t===null?parseCode(o,f):null;d||(l=t,u=n),d=!0;let i=o.peekChild(f.indent);t!==null&&i!==void 0&&(o.error(e.InvalidImplementationBlock,`A file directive cannot have children.`,r(i)),o.skipBlock(f.indent))}else o.error(e.InvalidImplementationBlock,`Unexpected '${f.content}' in implementation - expected hint, file or a tagged fence.`,r(f)),o.skipBlock(f.indent);return{file:l,code:u,implementation:{kind:`ImplementationSyntax`,hints:c,location:r(s)}}}export{isClosingCodeFence,isCode,isFile,parseCode,parseFile,parseHandler,parseImplementationWrapper};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{unescapeString as t}from"../Text/StringLiteral.js";import{locationOf as n}from"./SourceLine.js";import{firstWord as r}from"./LineText.js";import{isBlankImplementationHint as i}from"../Text/ImplementationHintText.js";const a=/* @__PURE__ */ RegExp(`^hint[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+"((?:[^"\\\\\\r\\n]|\\\\[^\\r\\n])*)"$`),isFile=e=>r(e.content)===`file`&&e.content.substring(4).trim().length>0,isCode=(e,t)=>t.content.startsWith("```")||e.languages.has(t.content);function parseFile(t,r){let i=r.content.substring(4).trim();return/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/.test(i)&&t.warning(e.AbsoluteFileReference,`'${i}' is an absolute path - a file reference is relative to the repository root, so it means the same thing on every machine`,n(r)),{kind:`FileReferenceSyntax`,path:i,location:n(r)}}const isClosingCodeFence=e=>e.raw.trim()==="```";function parseCode(t,r){let i=r.content.startsWith("```")?r.content.substring(3):r.content;if(!t.languages.has(i))return t.error(e.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${r.content}'`,n(r)),null;let a=r;if(!r.content.startsWith("```")){t.warning(e.LegacyInlineCodeFence,`'${i}' on its own line is deprecated - use '\`\`\`${i}' instead`,n(r));let o=t.reader.peekSignificant();if(o===void 0||o.indent<=r.indent||o.content!=="```"&&o.content!==`\`\`\`${i}`)return t.error(e.ExpectedCodeFence,`Expected an opening \`\`\`${i} fence after '${i}'`,n(r)),null;a=t.reader.takeSignificant()}let o=[];for(;;){let r=t.reader.takeRaw();if(r===void 0){t.error(e.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",n(a));break}if(isClosingCodeFence(r))break;let i=0;for(;i<a.indent&&r.raw[i]===` `;)i++;o.push(r.raw.substring(i))}return{kind:`CodeBlockSyntax`,language:i,code:o.join(`
2
+ `),location:n(r)}}function parseHandler(t,i){let a=t.peekChild(i.indent);if(a===void 0)return t.error(e.HandlerWithoutImplementation,`Expected a 'file' directive or an inline code block in the handler`,n(i)),null;if(t.reader.takeSignificant(),r(a.content)===`implementation`)return parseImplementation(t,i,a);let o=isFile(a)?parseFile(t,a):null,s=o===null&&isCode(t,a)?parseCode(t,a):null;if(o!==null||s!==null){let a=t.peekChild(i.indent);return a!==void 0&&r(a.content)===`implementation`&&(t.error(e.ConflictingImplementationSources,`A handler cannot mix wrapped and direct sources.`,n(a)),t.skipBlock(i.indent)),{kind:`HandlerSyntax`,file:o,code:s,implementation:null,location:n(i)}}return t.error(e.UnknownHandlerDirective,`Unexpected '${a.content}' in handler - expected 'file <path>' or an inline code block`,n(a)),t.skipBlock(i.indent),null}function parseImplementation(t,i,a){let o=parseImplementationWrapper(t,a);for(let a=t.peekChild(i.indent);a!==void 0;a=t.peekChild(i.indent))t.reader.takeSignificant(),t.error(r(a.content)===`implementation`?e.InvalidImplementationBlock:e.ConflictingImplementationSources,`A handler has one implementation wrapper and cannot mix wrapped and direct sources.`,n(a)),isCode(t,a)?parseCode(t,a):t.skipBlock(a.indent);return{kind:`HandlerSyntax`,...o,location:n(i)}}function parseImplementationWrapper(o,s){let c=[],l=null,u=null,d=!1;s.content!==`implementation`&&o.error(e.InvalidImplementationBlock,`Expected 'implementation' with no operand.`,n(s));for(let f=o.peekChild(s.indent);f!==void 0;f=o.peekChild(s.indent))if(o.reader.takeSignificant(),r(f.content)===`hint`||a.test(f.content)){let r=a.exec(f.content),s=r===null?null:t(r[1]);i(s)?o.error(e.InvalidImplementationHint,`Expected 'hint' followed by one nonblank quoted string.`,n(f)):c.push({kind:`ImplementationHintSyntax`,text:s,location:n(f)});let l=o.peekChild(f.indent);l!==void 0&&(o.error(e.InvalidImplementationHint,`A hint cannot have children.`,n(l)),o.skipBlock(f.indent))}else if(isFile(f)||f.content.startsWith("```")){d&&o.error(e.ConflictingImplementationSources,`An implementation has at most one file or inline payload.`,n(f));let t=isFile(f)?parseFile(o,f):null,r=t===null?parseCode(o,f):null;d||(l=t,u=r),d=!0;let i=o.peekChild(f.indent);t!==null&&i!==void 0&&(o.error(e.InvalidImplementationBlock,`A file directive cannot have children.`,n(i)),o.skipBlock(f.indent))}else o.error(e.InvalidImplementationBlock,`Unexpected '${f.content}' in implementation - expected hint, file or a tagged fence.`,n(f)),o.skipBlock(f.indent);return{file:l,code:u,implementation:{kind:`ImplementationSyntax`,hints:c,location:n(s)}}}export{isClosingCodeFence,isCode,isFile,parseCode,parseFile,parseHandler,parseImplementationWrapper};
3
3
  //# sourceMappingURL=ImplementationParser.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{pattern as e}from"../Text/patterns.js";import{firstWord as t,unescapeIdentifier as n}from"./LineText.js";import{locationOf as r}from"./SourceLine.js";import{parseDescription as i}from"./DescriptionParser.js";import{validateInteractionBodies as a}from"./InteractionAlternatives.js";const o=e(`^form\\s+[A-Za-z_]\\w*\\s+for\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),s=e(`^(execute|invokes)\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),c=e(`^field\\s+([\\w.]+)(?:\\s|$)`),l=e(`^with\\s+([A-Za-z_]\\w*)\\s+from\\s+.+$`),u=e(`^(@?[\\w.]+)\\s*=(?!=|>)\\s*.+$`),d=e(`^parameter\\s+([A-Za-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?))?$`),f=/* @__PURE__ */ new Set([`refresh`,`navigate`,`open`,`close`,`set`,`notify`,`confirm`,`raise`,`on`,`when`,`otherwise`]);function collectInputUses(p,m){let h=[],g=/* @__PURE__ */ new Set,_=[],v=t(m.content)===`behavior`,y=null,recognize=e=>{for(;h.length>0&&h[h.length-1].indent>=e.indent;)h.pop();let i=v&&h.length===0?d.exec(e.content):null;i!==null&&g.add(i[1]);let a=o.exec(e.content),m=s.exec(e.content);if(a!==null)h.push({command:a[1],kind:`form`,indent:e.indent});else if(m!==null)h.push({command:m[2],kind:m[1],indent:e.indent});else if(f.has(t(e.content)))h.push({command:``,kind:`other`,indent:e.indent});else{let t=h.at(-1);if(t===void 0||t.kind===`other`)return;let i=(t.kind===`form`?c:t.kind===`execute`?l:u).exec(e.content);i!==null&&_.push({command:t.command,property:n(i[1]),scope:p.scope,location:r(e)})}};recognize(m);let b=[m];for(let n=p.peekChild(m.indent);n!==void 0;n=p.peekChild(m.indent)){for(p.reader.takeSignificant();h.length>0&&h[h.length-1].indent>=n.indent;)h.pop();o.test(m.content)&&t(n.content)===`description`&&h.at(-1)?.kind===`form`?y=i(p,n,y,`Form '${m.content.split(e(`\\s+`))[1]}'`):n.content.startsWith("```")?p.skipFencedBody():(b.push(n),recognize(n))}a(p,b);for(let e of _)p.inputUses.push(g.has(e.command)?{...e,isParameter:!0}:e)}export{collectInputUses};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{pattern as e}from"../Text/patterns.js";import{locationOf as t}from"./SourceLine.js";import{firstWord as n,unescapeIdentifier as r}from"./LineText.js";import{parseDescription as i}from"./DescriptionParser.js";import{validateInteractionBodies as a}from"./InteractionAlternatives.js";const o=e(`^form\\s+[A-Za-z_]\\w*\\s+for\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),s=e(`^(execute|invokes)\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),c=e(`^field\\s+([\\w.]+)(?:\\s|$)`),l=e(`^with\\s+([A-Za-z_]\\w*)\\s+from\\s+.+$`),u=e(`^(@?[\\w.]+)\\s*=(?!=|>)\\s*.+$`),d=e(`^parameter\\s+([A-Za-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?))?$`),f=/* @__PURE__ */ new Set([`refresh`,`navigate`,`open`,`close`,`set`,`notify`,`confirm`,`raise`,`on`,`when`,`otherwise`]);function collectInputUses(p,m){let h=[],g=/* @__PURE__ */ new Set,_=[],v=n(m.content)===`behavior`,y=null,recognize=e=>{for(;h.length>0&&h[h.length-1].indent>=e.indent;)h.pop();let i=v&&h.length===0?d.exec(e.content):null;i!==null&&g.add(i[1]);let a=o.exec(e.content),m=s.exec(e.content);if(a!==null)h.push({command:a[1],kind:`form`,indent:e.indent});else if(m!==null)h.push({command:m[2],kind:m[1],indent:e.indent});else if(f.has(n(e.content)))h.push({command:``,kind:`other`,indent:e.indent});else{let n=h.at(-1);if(n===void 0||n.kind===`other`)return;let i=(n.kind===`form`?c:n.kind===`execute`?l:u).exec(e.content);i!==null&&_.push({command:n.command,property:r(i[1]),scope:p.scope,location:t(e)})}};recognize(m);let b=[m];for(let t=p.peekChild(m.indent);t!==void 0;t=p.peekChild(m.indent)){for(p.reader.takeSignificant();h.length>0&&h[h.length-1].indent>=t.indent;)h.pop();o.test(m.content)&&n(t.content)===`description`&&h.at(-1)?.kind===`form`?y=i(p,t,y,`Form '${m.content.split(e(`\\s+`))[1]}'`):t.content.startsWith("```")?p.skipFencedBody():(b.push(t),recognize(t))}a(p,b);for(let e of _)p.inputUses.push(g.has(e.command)?{...e,isParameter:!0}:e)}export{collectInputUses};
2
2
  //# sourceMappingURL=InputUses.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{dotNetWhitespace as t,pattern as n}from"../Text/patterns.js";import{firstWord as r}from"./LineText.js";import{locationOf as i}from"./SourceLine.js";import{parseCondition as a}from"./ConditionParser.js";import{validateCondition as o}from"./GuardedActionParser.js";import{LineReader as s}from"./LineReader.js";import{ParserContext as c}from"./ParserContext.js";const l=n(`^when${t}+([^\\n]+)${t}+execute${t}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),u=n(`^on${t}+([^\\n]+)$`),d=n(`^where${t}+([^\\n]+)$`),f=/* @__PURE__ */ new Set([`execute`,`navigate`,`open`,`close`,`refresh`,`set`,`notify`,`confirm`,`raise`]);function validateInteractionBodies(t,n){for(let s=0;s<n.length;s++){let c=n[s],p=u.exec(c.content);if(p===null||p[1].startsWith(`row-click `))continue;let m=[];for(let e=s+1;e<n.length&&n[e].indent>c.indent;e++)m.push(n[e]);let h=m.filter(e=>e.indent===m[0]?.indent),g=h.filter(e=>[`when`,`otherwise`].includes(r(e.content))),_=[`click`,`double click`,`select`].includes(p[1].trim()),v=h.filter(e=>d.test(e.content)),y=!1;for(let n of g){let s=r(n.content)===`when`,c=s?l.exec(n.content):null;if(s){y&&t.error(e.MisplacedActionOtherwise,`A 'when' alternative must precede 'otherwise'`,i(n));let r=a(t,c?.[1]??n.content.slice(4).trim(),i(n),!0);r!==null&&o(t,r),c!==null&&t.error(e.InlineInteractionAlternative,`Interaction alternatives require an indented action list, not 'when <condition> execute <Command>'`,i(n))}else(y||n.content!==`otherwise`)&&t.error(e.MisplacedActionOtherwise,`An interaction permits one final block-form 'otherwise'`,i(n)),y=!0;let u=m[m.indexOf(n)+1];c===null&&(u===void 0||u.indent<=n.indent||!f.has(r(u.content)))&&t.error(e.InteractionAlternativeWithoutActions,`An interaction alternative requires a non-empty action list`,i(n))}if(g.length>0&&(_||t.error(e.UnsupportedInteractionAlternatives,`Interaction alternatives are only supported on click, double click and select`,i(c)),(v.length>0||h.some(e=>f.has(r(e.content))))&&t.error(e.MixedInteractionAlternatives,`Interaction alternatives cannot mix with plain actions or 'where'`,i(c)),g.some(e=>r(e.content)===`when`)||t.error(e.GuardedActionWithoutAlternatives,`A guarded interaction requires at least one 'when' alternative`,i(c))),_)for(let e of v)deprecateWhere(t,e)}}function deprecateWhere(t,n){let r=new c(new s([]));r.sourceOptions=t.sourceOptions;let l=a(r,d.exec(n.content)[1].trim(),i(n),!0);l!==null&&o(r,l);let u=`Opaque 'where' on click, double click and select is deprecated; use block-form 'when' item conditions`;l!==null&&r.diagnostics.length===0?t.warning(e.LegacyInteractionWhere,u,i(n)):t.information(e.LegacyInteractionWhere,u,i(n))}export{validateInteractionBodies};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{dotNetWhitespace as t,pattern as n}from"../Text/patterns.js";import{locationOf as r}from"./SourceLine.js";import{firstWord as i}from"./LineText.js";import{parseCondition as a}from"./ConditionParser.js";import{validateCondition as o}from"./GuardedActionParser.js";import{LineReader as s}from"./LineReader.js";import{ParserContext as c}from"./ParserContext.js";const l=n(`^when${t}+([^\\n]+)${t}+execute${t}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),u=n(`^on${t}+([^\\n]+)$`),d=n(`^where${t}+([^\\n]+)$`),f=/* @__PURE__ */ new Set([`execute`,`navigate`,`open`,`close`,`refresh`,`set`,`notify`,`confirm`,`raise`]);function validateInteractionBodies(t,n){for(let s=0;s<n.length;s++){let c=n[s],p=u.exec(c.content);if(p===null||p[1].startsWith(`row-click `))continue;let m=[];for(let e=s+1;e<n.length&&n[e].indent>c.indent;e++)m.push(n[e]);let h=m.filter(e=>e.indent===m[0]?.indent),g=h.filter(e=>[`when`,`otherwise`].includes(i(e.content))),_=[`click`,`double click`,`select`].includes(p[1].trim()),v=h.filter(e=>d.test(e.content)),y=!1;for(let n of g){let s=i(n.content)===`when`,c=s?l.exec(n.content):null;if(s){y&&t.error(e.MisplacedActionOtherwise,`A 'when' alternative must precede 'otherwise'`,r(n));let i=a(t,c?.[1]??n.content.slice(4).trim(),r(n),!0);i!==null&&o(t,i),c!==null&&t.error(e.InlineInteractionAlternative,`Interaction alternatives require an indented action list, not 'when <condition> execute <Command>'`,r(n))}else(y||n.content!==`otherwise`)&&t.error(e.MisplacedActionOtherwise,`An interaction permits one final block-form 'otherwise'`,r(n)),y=!0;let u=m[m.indexOf(n)+1];c===null&&(u===void 0||u.indent<=n.indent||!f.has(i(u.content)))&&t.error(e.InteractionAlternativeWithoutActions,`An interaction alternative requires a non-empty action list`,r(n))}if(g.length>0&&(_||t.error(e.UnsupportedInteractionAlternatives,`Interaction alternatives are only supported on click, double click and select`,r(c)),(v.length>0||h.some(e=>f.has(i(e.content))))&&t.error(e.MixedInteractionAlternatives,`Interaction alternatives cannot mix with plain actions or 'where'`,r(c)),g.some(e=>i(e.content)===`when`)||t.error(e.GuardedActionWithoutAlternatives,`A guarded interaction requires at least one 'when' alternative`,r(c))),_)for(let e of v)deprecateWhere(t,e)}}function deprecateWhere(t,n){let i=new c(new s([]));i.sourceOptions=t.sourceOptions;let l=a(i,d.exec(n.content)[1].trim(),r(n),!0);l!==null&&o(i,l);let u=`Opaque 'where' on click, double click and select is deprecated; use block-form 'when' item conditions`;l!==null&&i.diagnostics.length===0?t.warning(e.LegacyInteractionWhere,u,r(n)):t.information(e.LegacyInteractionWhere,u,r(n))}export{validateInteractionBodies};
2
2
  //# sourceMappingURL=InteractionAlternatives.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{firstWord as n}from"./LineText.js";import{locationOf as r}from"./SourceLine.js";import{combineAuthorize as i,parseAuthorize as a}from"./AuthorizeParser.js";import{parseDescription as o}from"./DescriptionParser.js";import{parsePurposeReference as s}from"./PurposeParser.js";import{parseDocumentation as c}from"./DocumentationParser.js";import{parseDependsOn as l}from"./DependsOnParser.js";import{parseFileImport as u}from"./FileImportParser.js";import{collectInputUses as d}from"./InputUses.js";import{misplacedReactionIdentity as f}from"./ReactionIdentityParser.js";import{parseExample as p}from"./SpecificationExampleParser.js";import{parseFeature as m}from"./FeatureBody.js";const h=t(`^module\\s+([A-Za-z_]\\w*)$`),g=/* @__PURE__ */ new Set([`on`,`uses`,`screen`,`dialog`,`form`,`contribute`]),_=`description, documentation, depends on <Name>, authorize, import, screen template, dialog template, form, contribute, feature, example, 'on <trigger>' or 'uses <Behavior>'`;var ModuleBody=class{name;#e=[];#t=[];#n=[];#r=[];#i=[];#a=null;#o=null;#s=null;constructor(e){this.name=e}tryParse(t,r){let h=n(r.content);switch(h){case`runs`:return f(t,r),!0;case`description`:return this.#a=o(t,r,this.#a,`Module '${this.name}'`),!0;case`documentation`:return this.#o=c(t,r,this.#o,`Module '${this.name}'`),!0;case`depends`:return l(t,r,this.#r,e.UnknownModuleDirective),!0;case`purpose`:return s(t,r,this.#i),!0;case`authorize`:return this.#s=i(this.#s,a(t,r)),!0;case`import`:return u(t,r,this.#n),!0;case`example`:return this.#t.push(p(t,r)),!0;case`feature`:return this.#e.push(m(t,r)),!0;default:return g.has(h)?(d(t,r),!0):!1}}parseChildren(t,i){for(let a=t.peekChild(i.indent);a!==void 0;a=t.peekChild(i.indent))t.reader.takeSignificant(),this.tryParse(t,a)||(t.error(e.UnknownModuleDirective,`Unexpected '${n(a.content)}' in module body - expected ${_}`,r(a)),t.skipBlock(a.indent))}build(e,t=!1){return{kind:`ModuleSyntax`,name:this.name,description:this.#a,documentation:this.#o,authorize:this.#s,dependsOn:this.#r,purposes:this.#i,features:this.#e,examples:this.#t,fileImports:this.#n,isPlacement:t,location:e}}};function parseModule(t,n){let i=h.exec(n.content)?.[1]??``;i===``&&t.error(e.InvalidModuleDeclaration,`Invalid module declaration '${n.content}' - expected 'module <Name>'`,r(n));let a=new ModuleBody(i),o=t.scope;return t.scope=[i],a.parseChildren(t,n),t.scope=o,a.build(r(n))}export{ModuleBody,_ as moduleBodyExpected,h as modulePattern,parseModule};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{firstWord as r}from"./LineText.js";import{combineAuthorize as i,parseAuthorize as a}from"./AuthorizeParser.js";import{parseDescription as o}from"./DescriptionParser.js";import{parsePurposeReference as s}from"./PurposeParser.js";import{parseDocumentation as c}from"./DocumentationParser.js";import{parseDependsOn as l}from"./DependsOnParser.js";import{parseFileImport as u}from"./FileImportParser.js";import{collectInputUses as d}from"./InputUses.js";import{misplacedReactionIdentity as f}from"./ReactionIdentityParser.js";import{parseExample as p}from"./SpecificationExampleParser.js";import{parseFeature as m}from"./FeatureBody.js";const h=t(`^module\\s+([A-Za-z_]\\w*)$`),g=/* @__PURE__ */ new Set([`on`,`uses`,`screen`,`dialog`,`form`,`contribute`]),_=`description, documentation, depends on <Name>, authorize, import, screen template, dialog template, form, contribute, feature, example, 'on <trigger>' or 'uses <Behavior>'`;var ModuleBody=class{name;#e=[];#t=[];#n=[];#r=[];#i=[];#a=null;#o=null;#s=null;constructor(e){this.name=e}tryParse(t,n){let h=r(n.content);switch(h){case`runs`:return f(t,n),!0;case`description`:return this.#a=o(t,n,this.#a,`Module '${this.name}'`),!0;case`documentation`:return this.#o=c(t,n,this.#o,`Module '${this.name}'`),!0;case`depends`:return l(t,n,this.#r,e.UnknownModuleDirective),!0;case`purpose`:return s(t,n,this.#i),!0;case`authorize`:return this.#s=i(this.#s,a(t,n)),!0;case`import`:return u(t,n,this.#n),!0;case`example`:return this.#t.push(p(t,n)),!0;case`feature`:return this.#e.push(m(t,n)),!0;default:return g.has(h)?(d(t,n),!0):!1}}parseChildren(t,i){for(let a=t.peekChild(i.indent);a!==void 0;a=t.peekChild(i.indent))t.reader.takeSignificant(),this.tryParse(t,a)||(t.error(e.UnknownModuleDirective,`Unexpected '${r(a.content)}' in module body - expected ${_}`,n(a)),t.skipBlock(a.indent))}build(e,t=!1){return{kind:`ModuleSyntax`,name:this.name,description:this.#a,documentation:this.#o,authorize:this.#s,dependsOn:this.#r,purposes:this.#i,features:this.#e,examples:this.#t,fileImports:this.#n,isPlacement:t,location:e}}};function parseModule(t,r){let i=h.exec(r.content)?.[1]??``;i===``&&t.error(e.InvalidModuleDeclaration,`Invalid module declaration '${r.content}' - expected 'module <Name>'`,n(r));let a=new ModuleBody(i),o=t.scope;return t.scope=[i],a.parseChildren(t,r),t.scope=o,a.build(n(r))}export{ModuleBody,_ as moduleBodyExpected,h as modulePattern,parseModule};
2
2
  //# sourceMappingURL=ModuleBody.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{parseMappingSource as n}from"./ExpressionParser.js";import{firstWord as r}from"./LineText.js";import{locationOf as i}from"./SourceLine.js";import{parseProperty as a,tryParseProperty as o}from"./PropertyLineParser.js";import{parseDescription as s}from"./DescriptionParser.js";import{isFileDirective as c}from"./FileReferences.js";import{parseCode as l,parseFile as u,parseImplementationWrapper as d}from"./ImplementationParser.js";const f=t(`^system\\s+([A-Za-z_]\\w*)$`),p=t(`^operation\\s+([A-Za-z_]\\w*)$`),m=t(`^produces\\s+operation\\s+([A-Za-z_]\\w*)$`),h=t(`^uses\\s+([A-Za-z_]\\w*)$`),g=t(`^(.+?)\\s*=(?!=|>)\\s*(.+)$`),_=/* @__PURE__ */ new Set([`for`,`tag`,`generation`,`origin`,`documentation`,`namespace`,`sequence`,`correlation`,`causation`,`causedBy`,`occurred`]);function rejectOperationChildren(e,t,n,r){let a=e.peekChild(t.indent);a!==void 0&&(e.error(n,r,i(a)),e.skipBlock(t.indent))}function parseSystem(t,n){let a=f.exec(n.content);a===null&&t.error(e.InvalidSystemDeclaration,`Expected 'system <Name>'.`,i(n));let o=null;for(let c=t.peekChild(n.indent);c!==void 0;c=t.peekChild(n.indent))t.reader.takeSignificant(),r(c.content)===`description`?o=s(t,c,o,`System '${a?.[1]??``}'`):(t.error(e.InvalidSystemDeclaration,`A system accepts only a description; abilities are not supported.`,i(c)),t.skipBlock(c.indent));return{kind:`SystemSyntax`,name:a?.[1]??``,description:o,location:i(n)}}function parseOperation(t,c,l=!1){let u=(l?m:p).exec(c.content),d=u?.[1]??``;u===null&&t.error(e.InvalidOperationDeclaration,`Expected an operation declaration with one name.`,i(c));let f=null,v=null,y=i(c),b=null,x=null,S=[],C=[],w=/* @__PURE__ */ new Set;for(let u=t.peekChild(c.indent);u!==void 0;u=t.peekChild(c.indent)){t.reader.takeSignificant();let c=g.exec(u.content),p=l&&c!==null?{...u,content:c[1].trimEnd()}:u;if(c===null&&_.has(r(u.content)))t.error(e.InvalidOperationDeclaration,`Operations cannot declare event routing or metadata; escape a keyword-named input with @.`,i(u)),t.skipBlock(u.indent);else if(!h.test(u.content)&&o(p)!==void 0){let r=a(t,p);l&&c===null&&t.error(e.InvalidOperationMapping,`An inline operation input requires '<property> <Type> = <source>'.`,i(u)),r.isSubject&&t.error(e.InvalidSubjectOwner,`The subject modifier is only valid on event properties, not operation inputs (decision 0008: one data subject per event).`,i(u)),(r.isIdentifier||r.isGenerated)&&t.error(e.InvalidOperationDeclaration,`Operation inputs cannot be identifier or generated properties.`,i(u)),w.has(r.name)&&t.error(e.DuplicateDeclaration,`Operation '${d}' already declares input '${r.name}'.`,i(u)),w.add(r.name),S.push(r),l&&c!==null&&C.push({kind:`PropertyMappingSyntax`,property:r.name,source:n(c[2],{...i(u),column:u.indent+u.content.length-c[2].length+1},t),location:i(u)}),rejectOperationChildren(t,u,e.InvalidOperationDeclaration,`An operation input cannot have children.`)}else if(r(u.content)===`description`)f=s(t,u,f,`Operation '${d}'`);else if(h.test(u.content))v===null?(v=h.exec(u.content)[1],y={...i(u),column:i(u).column+u.content.indexOf(v,4)}):t.error(e.InvalidSystemReference,`An operation declares exactly one 'uses <System>'.`,i(u)),rejectOperationChildren(t,u,e.InvalidSystemReference,`A system reference cannot have children.`);else if(u.content===`execute`||u.content===`compensate`){let n=parseOperationPhase(t,u);u.content===`execute`?b===null?b=n:t.error(e.InvalidOperationDeclaration,`An operation declares execute at most once.`,i(u)):x===null?x=n:t.error(e.InvalidOperationDeclaration,`An operation declares compensate at most once.`,i(u))}else t.error(e.InvalidOperationDeclaration,`Unexpected '${u.content}' in operation - expected uses, an input, description, execute or compensate.`,i(u)),t.skipBlock(u.indent)}return v===null&&t.error(e.InvalidSystemReference,`An operation requires exactly one 'uses <System>'.`,i(c)),{operation:{kind:`OperationSyntax`,name:d,uses:v??``,usesLocation:y,inputs:S,description:f,execute:b,compensate:x,location:i(c)},mappings:C}}function parseOperationPhase(t,n){let a=null,o=null,f=null,p=null,m=!1;for(let h=t.peekChild(n.indent);h!==void 0;h=t.peekChild(n.indent))if(t.reader.takeSignificant(),r(h.content)===`description`)a=s(t,h,a,`Operation phase '${n.content}'`);else if(r(h.content)===`implementation`){m&&t.error(e.ConflictingImplementationSources,`A phase cannot mix wrapped and direct sources or repeat its wrapper.`,i(h));let n=d(t,h);m||(o=n.file,f=n.code,p=n.implementation),m=!0}else if(c(h)||h.content.startsWith("```")){m&&t.error(e.ConflictingImplementationSources,`A phase has at most one file or inline payload.`,i(h));let n=c(h)?u(t,h):null,r=n===null?l(t,h):null;m||(o=n,f=r),m=!0,n!==null&&rejectOperationChildren(t,h,e.InvalidImplementationBlock,`A file directive cannot have children.`)}else t.error(e.InvalidOperationDeclaration,`A phase accepts description, file, a tagged fence or implementation.`,i(h)),t.skipBlock(h.indent);return{kind:`OperationPhaseSyntax`,description:a,file:o,code:f,implementation:p,location:i(n)}}export{parseOperation,parseSystem,rejectOperationChildren};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{parseMappingSource as r}from"./ExpressionParser.js";import{firstWord as i}from"./LineText.js";import{parseProperty as a,tryParseProperty as o}from"./PropertyLineParser.js";import{parseDescription as s}from"./DescriptionParser.js";import{isFileDirective as c}from"./FileReferences.js";import{parseCode as l,parseFile as u,parseImplementationWrapper as d}from"./ImplementationParser.js";const f=t(`^system\\s+([A-Za-z_]\\w*)$`),p=t(`^operation\\s+([A-Za-z_]\\w*)$`),m=t(`^produces\\s+operation\\s+([A-Za-z_]\\w*)$`),h=t(`^uses\\s+([A-Za-z_]\\w*)$`),g=t(`^(.+?)\\s*=(?!=|>)\\s*(.+)$`),_=/* @__PURE__ */ new Set([`for`,`tag`,`generation`,`origin`,`documentation`,`namespace`,`sequence`,`correlation`,`causation`,`causedBy`,`occurred`]);function rejectOperationChildren(e,t,r,i){let a=e.peekChild(t.indent);a!==void 0&&(e.error(r,i,n(a)),e.skipBlock(t.indent))}function parseSystem(t,r){let a=f.exec(r.content);a===null&&t.error(e.InvalidSystemDeclaration,`Expected 'system <Name>'.`,n(r));let o=null;for(let c=t.peekChild(r.indent);c!==void 0;c=t.peekChild(r.indent))t.reader.takeSignificant(),i(c.content)===`description`?o=s(t,c,o,`System '${a?.[1]??``}'`):(t.error(e.InvalidSystemDeclaration,`A system accepts only a description; abilities are not supported.`,n(c)),t.skipBlock(c.indent));return{kind:`SystemSyntax`,name:a?.[1]??``,description:o,location:n(r)}}function parseOperation(t,c,l=!1){let u=(l?m:p).exec(c.content),d=u?.[1]??``;u===null&&t.error(e.InvalidOperationDeclaration,`Expected an operation declaration with one name.`,n(c));let f=null,v=null,y=n(c),b=null,x=null,S=[],C=[],w=/* @__PURE__ */ new Set;for(let u=t.peekChild(c.indent);u!==void 0;u=t.peekChild(c.indent)){t.reader.takeSignificant();let c=g.exec(u.content),p=l&&c!==null?{...u,content:c[1].trimEnd()}:u;if(c===null&&_.has(i(u.content)))t.error(e.InvalidOperationDeclaration,`Operations cannot declare event routing or metadata; escape a keyword-named input with @.`,n(u)),t.skipBlock(u.indent);else if(!h.test(u.content)&&o(p)!==void 0){let i=a(t,p);l&&c===null&&t.error(e.InvalidOperationMapping,`An inline operation input requires '<property> <Type> = <source>'.`,n(u)),i.isSubject&&t.error(e.InvalidSubjectOwner,`The subject modifier is only valid on event properties, not operation inputs (decision 0008: one data subject per event).`,n(u)),(i.isIdentifier||i.isGenerated)&&t.error(e.InvalidOperationDeclaration,`Operation inputs cannot be identifier or generated properties.`,n(u)),w.has(i.name)&&t.error(e.DuplicateDeclaration,`Operation '${d}' already declares input '${i.name}'.`,n(u)),w.add(i.name),S.push(i),l&&c!==null&&C.push({kind:`PropertyMappingSyntax`,property:i.name,source:r(c[2],{...n(u),column:u.indent+u.content.length-c[2].length+1},t),location:n(u)}),rejectOperationChildren(t,u,e.InvalidOperationDeclaration,`An operation input cannot have children.`)}else if(i(u.content)===`description`)f=s(t,u,f,`Operation '${d}'`);else if(h.test(u.content))v===null?(v=h.exec(u.content)[1],y={...n(u),column:n(u).column+u.content.indexOf(v,4)}):t.error(e.InvalidSystemReference,`An operation declares exactly one 'uses <System>'.`,n(u)),rejectOperationChildren(t,u,e.InvalidSystemReference,`A system reference cannot have children.`);else if(u.content===`execute`||u.content===`compensate`){let r=parseOperationPhase(t,u);u.content===`execute`?b===null?b=r:t.error(e.InvalidOperationDeclaration,`An operation declares execute at most once.`,n(u)):x===null?x=r:t.error(e.InvalidOperationDeclaration,`An operation declares compensate at most once.`,n(u))}else t.error(e.InvalidOperationDeclaration,`Unexpected '${u.content}' in operation - expected uses, an input, description, execute or compensate.`,n(u)),t.skipBlock(u.indent)}return v===null&&t.error(e.InvalidSystemReference,`An operation requires exactly one 'uses <System>'.`,n(c)),{operation:{kind:`OperationSyntax`,name:d,uses:v??``,usesLocation:y,inputs:S,description:f,execute:b,compensate:x,location:n(c)},mappings:C}}function parseOperationPhase(t,r){let a=null,o=null,f=null,p=null,m=!1;for(let h=t.peekChild(r.indent);h!==void 0;h=t.peekChild(r.indent))if(t.reader.takeSignificant(),i(h.content)===`description`)a=s(t,h,a,`Operation phase '${r.content}'`);else if(i(h.content)===`implementation`){m&&t.error(e.ConflictingImplementationSources,`A phase cannot mix wrapped and direct sources or repeat its wrapper.`,n(h));let r=d(t,h);m||(o=r.file,f=r.code,p=r.implementation),m=!0}else if(c(h)||h.content.startsWith("```")){m&&t.error(e.ConflictingImplementationSources,`A phase has at most one file or inline payload.`,n(h));let r=c(h)?u(t,h):null,i=r===null?l(t,h):null;m||(o=r,f=i),m=!0,r!==null&&rejectOperationChildren(t,h,e.InvalidImplementationBlock,`A file directive cannot have children.`)}else t.error(e.InvalidOperationDeclaration,`A phase accepts description, file, a tagged fence or implementation.`,n(h)),t.skipBlock(h.indent);return{kind:`OperationPhaseSyntax`,description:a,file:o,code:f,implementation:p,location:n(r)}}export{parseOperation,parseSystem,rejectOperationChildren};
2
2
  //# sourceMappingURL=OperationParser.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{nativePattern as t}from"../Text/patterns.js";import{unescapeString as n}from"../Text/StringLiteral.js";import{parseModeledMappingSource as r}from"./ExpressionParser.js";import{firstWord as i}from"./LineText.js";import{locationOf as a}from"./SourceLine.js";import{parseDescription as o}from"./DescriptionParser.js";import{parseCode as s,parseFile as c}from"./ImplementationParser.js";const l=t(`^policy\\s+([A-Za-z_]\\w*)$`);function parsePolicy(t,n){let r=t;t=t.valueContext;let u=l.exec(n.content)?.[1]??``;u===``&&t.error(e.InvalidPolicyDeclaration,`Invalid policy declaration '${n.content}' - expected 'policy <Name>'`,a(n));let d=null,f=null,p=null,m=!1,h=null;for(let l=t.peekChild(n.indent);l!==void 0;l=t.peekChild(n.indent))if(t.reader.takeSignificant(),i(l.content)===`description`)h=o(r,l,h,`Policy '${u}'`);else if(i(l.content)===`require`){let n=l.content.substring(7).trim();for(let e=t.peekChild(l.indent);e!==void 0;e=t.peekChild(l.indent))t.reader.takeSignificant(),n+=` ${e.content}`;let i=tokenizePolicyCondition(t,n);i.includes(`not`)&&(t=r);let o=parsePolicyCondition(t,i,a(l));m?t.error(e.RepeatedPolicyRequirement,`Policy '${u}' has more than one require line; combine the conditions with and/or in one require`,a(l)):d=o,m=!0}else if(i(l.content)===`file`){let n=c(t,l);f===null&&p===null?p=n:t.error(e.UnknownPolicyDirective,`Policy '${u}' must have only one implementation - a file reference or an inline code block, not both`,a(l))}else if(l.content.startsWith("```")||t.languages.has(l.content)){let n=s(t,l);f===null&&p===null?f=n:t.error(e.UnknownPolicyDirective,`Policy '${u}' must have only one implementation - a file reference or an inline code block, not both`,a(l))}else t.error(e.UnknownPolicyDirective,`Unexpected '${l.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`,a(l)),t.skipOpaqueBlock(l.indent);return d!==null&&(f!==null||p!==null)&&t.error(e.MixedPolicyImplementation,`Policy '${u}' cannot combine 'require' with a file or inline code block`,a(n)),d===null&&f===null&&p===null&&t.error(e.PolicyWithoutRequirement,`Policy '${u}' must declare a 'require' condition, a file reference or an inline code block`,a(n)),{kind:`PolicySyntax`,name:u,condition:d,code:f,file:p,description:h,location:a(n)}}function tokenizePolicyCondition(e,n){let r=e.sourceOptions.numericMode===`exact`?`-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\s()])|[\\w.$-]+|[^\\s]`:`[\\w.$]+`;return[...n.match(new RegExp(t(`"(?:[^"\\\\]|\\\\.)*"|\\(|\\)|${r}`).source,`gu`))??[]]}function parsePolicyCondition(t,i,a){let o=t.sourceOptions.numericMode===`exact`||i.includes(`not`),s=0,quoted=e=>e!==void 0&&e.startsWith(`"`)&&e.endsWith(`"`),unquote=e=>n(e.substring(1,e.length-1)),group=()=>{if(i[s]===`not`){s++;let e=group();return e===null?null:{kind:`NotPolicyConditionSyntax`,operand:e,location:a}}if(i[s]===`(`){s++;let n=or();return i[s]===`)`?s++:o&&t.error(e.UnclosedPolicyConditionGroup,`Expected ')' in policy condition`,a),n}let n=i[s++];if(n===`authenticated`)return{kind:`AuthenticatedConditionSyntax`,location:a};if(n!==`role`&&n!==`claim`)return t.error(n===void 0?e.ExpectedPolicyCondition:e.UnexpectedTokenInPolicyCondition,n===void 0?`Expected a policy condition`:`Unexpected '${n}' in policy condition`,a),null;let c=i[s++];if(!quoted(c))return t.error(n===`role`?e.ExpectedRoleName:e.ExpectedClaimName,`Expected a quoted ${n} name after '${n}'`,a),null;if(n===`role`)return{kind:`RoleConditionSyntax`,role:unquote(c),location:a};if(i[s++]!==`matches`)return t.error(e.ExpectedClaimMatches,`Expected 'matches' after the claim name`,a),null;let l=i[s++];return l===void 0?(t.error(e.ExpectedClaimMatchTarget,`Expected 'subject' or a value after 'matches'`,a),null):{kind:`ClaimConditionSyntax`,claim:unquote(c),matchesSubject:l===`subject`,matches:l===`subject`?null:r(l,a,t),location:a}},and=()=>{let e=group();for(;e!==null&&i[s]===`and`;){s++;let t=group();if(t===null)return null;e={kind:`LogicalPolicyConditionSyntax`,left:e,operator:`And`,right:t,location:a}}return e},or=()=>{let e=and();for(;e!==null&&i[s]===`or`;){s++;let t=and();if(t===null)return null;e={kind:`LogicalPolicyConditionSyntax`,left:e,operator:`Or`,right:t,location:a}}return e},c=or();return o&&c!==null&&s<i.length&&t.error(e.UnexpectedTokenInPolicyCondition,`Unexpected '${i[s]}' in policy condition`,a),c}export{parsePolicy};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{unescapeString as t}from"../Text/StringLiteral.js";import{nativePattern as n}from"../Text/patterns.js";import{locationOf as r}from"./SourceLine.js";import{parseModeledMappingSource as i}from"./ExpressionParser.js";import{firstWord as a}from"./LineText.js";import{parseDescription as o}from"./DescriptionParser.js";import{parseCode as s,parseFile as c}from"./ImplementationParser.js";const l=n(`^policy\\s+([A-Za-z_]\\w*)$`);function parsePolicy(t,n){let i=t;t=t.valueContext;let u=l.exec(n.content)?.[1]??``;u===``&&t.error(e.InvalidPolicyDeclaration,`Invalid policy declaration '${n.content}' - expected 'policy <Name>'`,r(n));let d=null,f=null,p=null,m=!1,h=null;for(let l=t.peekChild(n.indent);l!==void 0;l=t.peekChild(n.indent))if(t.reader.takeSignificant(),a(l.content)===`description`)h=o(i,l,h,`Policy '${u}'`);else if(a(l.content)===`require`){let n=l.content.substring(7).trim();for(let e=t.peekChild(l.indent);e!==void 0;e=t.peekChild(l.indent))t.reader.takeSignificant(),n+=` ${e.content}`;let a=tokenizePolicyCondition(t,n);a.includes(`not`)&&(t=i);let o=parsePolicyCondition(t,a,r(l));m?t.error(e.RepeatedPolicyRequirement,`Policy '${u}' has more than one require line; combine the conditions with and/or in one require`,r(l)):d=o,m=!0}else if(a(l.content)===`file`){let n=c(t,l);f===null&&p===null?p=n:t.error(e.UnknownPolicyDirective,`Policy '${u}' must have only one implementation - a file reference or an inline code block, not both`,r(l))}else if(l.content.startsWith("```")||t.languages.has(l.content)){let n=s(t,l);f===null&&p===null?f=n:t.error(e.UnknownPolicyDirective,`Policy '${u}' must have only one implementation - a file reference or an inline code block, not both`,r(l))}else t.error(e.UnknownPolicyDirective,`Unexpected '${l.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`,r(l)),t.skipOpaqueBlock(l.indent);return d!==null&&(f!==null||p!==null)&&t.error(e.MixedPolicyImplementation,`Policy '${u}' cannot combine 'require' with a file or inline code block`,r(n)),d===null&&f===null&&p===null&&t.error(e.PolicyWithoutRequirement,`Policy '${u}' must declare a 'require' condition, a file reference or an inline code block`,r(n)),{kind:`PolicySyntax`,name:u,condition:d,code:f,file:p,description:h,location:r(n)}}function tokenizePolicyCondition(e,t){let r=e.sourceOptions.numericMode===`exact`?`-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\s()])|[\\w.$-]+|[^\\s]`:`[\\w.$]+`;return[...t.match(new RegExp(n(`"(?:[^"\\\\]|\\\\.)*"|\\(|\\)|${r}`).source,`gu`))??[]]}function parsePolicyCondition(n,r,a){let o=n.sourceOptions.numericMode===`exact`||r.includes(`not`),s=0,quoted=e=>e!==void 0&&e.startsWith(`"`)&&e.endsWith(`"`),unquote=e=>t(e.substring(1,e.length-1)),group=()=>{if(r[s]===`not`){s++;let e=group();return e===null?null:{kind:`NotPolicyConditionSyntax`,operand:e,location:a}}if(r[s]===`(`){s++;let t=or();return r[s]===`)`?s++:o&&n.error(e.UnclosedPolicyConditionGroup,`Expected ')' in policy condition`,a),t}let t=r[s++];if(t===`authenticated`)return{kind:`AuthenticatedConditionSyntax`,location:a};if(t!==`role`&&t!==`claim`)return n.error(t===void 0?e.ExpectedPolicyCondition:e.UnexpectedTokenInPolicyCondition,t===void 0?`Expected a policy condition`:`Unexpected '${t}' in policy condition`,a),null;let c=r[s++];if(!quoted(c))return n.error(t===`role`?e.ExpectedRoleName:e.ExpectedClaimName,`Expected a quoted ${t} name after '${t}'`,a),null;if(t===`role`)return{kind:`RoleConditionSyntax`,role:unquote(c),location:a};if(r[s++]!==`matches`)return n.error(e.ExpectedClaimMatches,`Expected 'matches' after the claim name`,a),null;let l=r[s++];return l===void 0?(n.error(e.ExpectedClaimMatchTarget,`Expected 'subject' or a value after 'matches'`,a),null):{kind:`ClaimConditionSyntax`,claim:unquote(c),matchesSubject:l===`subject`,matches:l===`subject`?null:i(l,a,n),location:a}},and=()=>{let e=group();for(;e!==null&&r[s]===`and`;){s++;let t=group();if(t===null)return null;e={kind:`LogicalPolicyConditionSyntax`,left:e,operator:`And`,right:t,location:a}}return e},or=()=>{let e=and();for(;e!==null&&r[s]===`or`;){s++;let t=and();if(t===null)return null;e={kind:`LogicalPolicyConditionSyntax`,left:e,operator:`Or`,right:t,location:a}}return e},c=or();return o&&c!==null&&s<r.length&&n.error(e.UnexpectedTokenInPolicyCondition,`Unexpected '${r[s]}' in policy condition`,a),c}export{parsePolicy};
2
2
  //# sourceMappingURL=PolicyParser.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{parseMappingSource as n}from"./ExpressionParser.js";import{firstWord as r,unescapeIdentifier as i}from"./LineText.js";import{locationOf as a}from"./SourceLine.js";import{parseProperty as o}from"./PropertyLineParser.js";import{parseCondition as s}from"./ConditionParser.js";import{parseOperation as c}from"./OperationParser.js";import{EventMetadataParser as l}from"./EventMetadataParser.js";import{parseTag as u}from"./DeclarationParsers.js";const d=t(`^produces\\s+operation(?:\\s|$)`),f=t(`^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+(generation)(?:\\s+.*)?)?$`),p=t(`^produces\\s+([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)$`),m=t(`^produces\\s+when\\s+(.+)$`),h=t(`^[A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*$`),g=t(`^for\\s+(\\S.*)$`),_=t(`^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),v=t(`^(.+?)\\s*=(?!=|>)\\s*(.+)$`),y=/* @__PURE__ */ new Set([`namespace`,`sequence`,`correlation`,`causation`,`causedBy`,`occurred`]);function parseProduces(t,b,x=!1){if(d.test(b.content)){if(!x){t.error(e.OperationOutsideCommand,`Operations can only be produced by commands.`,a(b)),t.skipOpaqueBlock(b.indent);return}let n=c(t,b,!0);return{kind:`ProducesSyntax`,when:null,event:n.operation.name,targetLocation:{...a(b),column:b.indent+b.content.match(/^produces\s+operation(?:\s+|$)/)[0].length+1},inlineEvent:null,inlineOperation:n.operation,mappings:n.mappings,for:null,tags:[],location:a(b)}}let S=f.exec(b.content),C=b,w=null,T,E;if(S!==null){if(!x){t.error(e.InlineEventOutsideCommand,`Inline events can only be declared inside commands`,a(b)),t.skipOpaqueBlock(b.indent);return}S[2]!==void 0&&t.error(e.InlineEventGeneration,`Inline events are generation 1 - extract the event before declaring generations`,a(b)),T=S[1],E=b.indent+b.content.match(/^produces\s+event\s+/)[0].length+1}else if(m.test(b.content)){w=s(t,m.exec(b.content)[1],a(b));let n=t.peekChild(b.indent);if(n===void 0||!h.test(n.content)){t.error(e.ProducesWhenWithoutEvent,`Expected an event name on the line after 'produces when'`,a(b)),t.skipOpaqueBlock(b.indent);return}t.reader.takeSignificant(),C=n,T=n.content,E=n.indent+1}else{let n=p.exec(b.content);if(n===null){t.error(e.InvalidProducesDeclaration,`Invalid produces declaration '${b.content}' - expected 'produces <EventType>' or 'produces when <condition>'`,a(b)),t.skipOpaqueBlock(b.indent);return}T=n[1],E=b.indent+b.content.match(/^produces\s+/)[0].length+1}let D=[],O=/* @__PURE__ */ new Set,k=[],A=[],j=new l(T),M=null;for(let s=t.peekChild(C.indent);s!==void 0;s=t.peekChild(C.indent)){t.reader.takeSignificant();let c=r(s.content),l=a(s);if(y.has(c)){t.error(e.ReservedProductionMetadata,`'${c}' is system-assigned production metadata and cannot be supplied here`,l),t.skipOpaqueBlock(s.indent);continue}if(S!==null&&(c===`generation`||c===`origin`)){t.error(c===`generation`?e.InlineEventGeneration:e.ReservedProductionMetadata,c===`generation`?`Inline events are generation 1 - extract the event before declaring generations`:`An inline event is local to its command and cannot declare origin`,l),t.skipOpaqueBlock(s.indent);continue}if(c===`tag`){let e=u(t,s,!1);e!==void 0&&A.push(e);continue}let d=g.exec(s.content);if(d!==null){M===null?M=n(d[1],l,t):t.error(e.DuplicateProducesTarget,`'${C.content}' already declares where it lands - an event is appended to one event source`,l);continue}let f=(S===null?_:v).exec(s.content),p=f===null||S===null?void 0:o(t,{...s,content:f[1].trimEnd()});if(f!==null&&(S===null||p!==void 0)){if(p!==void 0){p.isIdentifier&&(t.error(e.IdentifierOnEventProperty,`Property '${p.name}' of event '${T}' cannot be marked identifier - an event never carries its event source id`,l),p={...p,isIdentifier:!1});let n=p.name;O.has(n)&&t.error(e.DuplicateDeclaration,`Event '${T}' already declares property '${p.name}'`,l),O.add(n),D.push(p)}k.push({kind:`PropertyMappingSyntax`,property:p?.name??i(f[1]),source:n(f[2],{...l,column:s.indent+s.content.length-f[2].length+1},t),location:l})}else(S===null||!j.tryParse(t,s))&&t.error(e.InvalidPropertyMapping,`Invalid ${S===null?``:`inline `}property mapping '${s.content}' - expected '<property>${S===null?``:` <Type>`} = <source>'`,l)}return C!==b&&t.skipBlock(b.indent),{kind:`ProducesSyntax`,when:w,event:T,targetLocation:{...a(C),column:E},inlineOperation:null,mappings:k,for:M,tags:S===null?A:[],location:a(b),inlineEvent:S===null?null:{kind:`EventSyntax`,name:T,properties:D,tags:A,generation:1,hasGenerationMarker:!1,...j.value,location:a(b)}}}export{parseProduces};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{parseMappingSource as r}from"./ExpressionParser.js";import{firstWord as i,unescapeIdentifier as a}from"./LineText.js";import{parseProperty as o}from"./PropertyLineParser.js";import{parseCondition as s}from"./ConditionParser.js";import{parseOperation as c}from"./OperationParser.js";import{EventMetadataParser as l}from"./EventMetadataParser.js";import{parseTag as u}from"./DeclarationParsers.js";const d=t(`^produces\\s+operation(?:\\s|$)`),f=t(`^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+(generation)(?:\\s+.*)?)?$`),p=t(`^produces\\s+([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)$`),m=t(`^produces\\s+when\\s+(.+)$`),h=t(`^[A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*$`),g=t(`^for\\s+(\\S.*)$`),_=t(`^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),v=t(`^(.+?)\\s*=(?!=|>)\\s*(.+)$`),y=/* @__PURE__ */ new Set([`namespace`,`sequence`,`correlation`,`causation`,`causedBy`,`occurred`]);function parseProduces(t,b,x=!1){if(d.test(b.content)){if(!x){t.error(e.OperationOutsideCommand,`Operations can only be produced by commands.`,n(b)),t.skipOpaqueBlock(b.indent);return}let r=c(t,b,!0);return{kind:`ProducesSyntax`,when:null,event:r.operation.name,targetLocation:{...n(b),column:b.indent+b.content.match(/^produces\s+operation(?:\s+|$)/)[0].length+1},inlineEvent:null,inlineOperation:r.operation,mappings:r.mappings,for:null,tags:[],location:n(b)}}let S=f.exec(b.content),C=b,w=null,T,E;if(S!==null){if(!x){t.error(e.InlineEventOutsideCommand,`Inline events can only be declared inside commands`,n(b)),t.skipOpaqueBlock(b.indent);return}S[2]!==void 0&&t.error(e.InlineEventGeneration,`Inline events are generation 1 - extract the event before declaring generations`,n(b)),T=S[1],E=b.indent+b.content.match(/^produces\s+event\s+/)[0].length+1}else if(m.test(b.content)){w=s(t,m.exec(b.content)[1],n(b));let r=t.peekChild(b.indent);if(r===void 0||!h.test(r.content)){t.error(e.ProducesWhenWithoutEvent,`Expected an event name on the line after 'produces when'`,n(b)),t.skipOpaqueBlock(b.indent);return}t.reader.takeSignificant(),C=r,T=r.content,E=r.indent+1}else{let r=p.exec(b.content);if(r===null){t.error(e.InvalidProducesDeclaration,`Invalid produces declaration '${b.content}' - expected 'produces <EventType>' or 'produces when <condition>'`,n(b)),t.skipOpaqueBlock(b.indent);return}T=r[1],E=b.indent+b.content.match(/^produces\s+/)[0].length+1}let D=[],O=/* @__PURE__ */ new Set,k=[],A=[],j=new l(T),M=null;for(let s=t.peekChild(C.indent);s!==void 0;s=t.peekChild(C.indent)){t.reader.takeSignificant();let c=i(s.content),l=n(s);if(y.has(c)){t.error(e.ReservedProductionMetadata,`'${c}' is system-assigned production metadata and cannot be supplied here`,l),t.skipOpaqueBlock(s.indent);continue}if(S!==null&&(c===`generation`||c===`origin`)){t.error(c===`generation`?e.InlineEventGeneration:e.ReservedProductionMetadata,c===`generation`?`Inline events are generation 1 - extract the event before declaring generations`:`An inline event is local to its command and cannot declare origin`,l),t.skipOpaqueBlock(s.indent);continue}if(c===`tag`){let e=u(t,s,!1);e!==void 0&&A.push(e);continue}let d=g.exec(s.content);if(d!==null){M===null?M=r(d[1],l,t):t.error(e.DuplicateProducesTarget,`'${C.content}' already declares where it lands - an event is appended to one event source`,l);continue}let f=(S===null?_:v).exec(s.content),p=f===null||S===null?void 0:o(t,{...s,content:f[1].trimEnd()});if(f!==null&&(S===null||p!==void 0)){if(p!==void 0){p.isIdentifier&&(t.error(e.IdentifierOnEventProperty,`Property '${p.name}' of event '${T}' cannot be marked identifier - an event never carries its event source id`,l),p={...p,isIdentifier:!1});let n=p.name;O.has(n)&&t.error(e.DuplicateDeclaration,`Event '${T}' already declares property '${p.name}'`,l),O.add(n),D.push(p)}k.push({kind:`PropertyMappingSyntax`,property:p?.name??a(f[1]),source:r(f[2],{...l,column:s.indent+s.content.length-f[2].length+1},t),location:l})}else(S===null||!j.tryParse(t,s))&&t.error(e.InvalidPropertyMapping,`Invalid ${S===null?``:`inline `}property mapping '${s.content}' - expected '<property>${S===null?``:` <Type>`} = <source>'`,l)}return C!==b&&t.skipBlock(b.indent),{kind:`ProducesSyntax`,when:w,event:T,targetLocation:{...n(C),column:E},inlineOperation:null,mappings:k,for:M,tags:S===null?A:[],location:n(b),inlineEvent:S===null?null:{kind:`EventSyntax`,name:T,properties:D,tags:A,generation:1,hasGenerationMarker:!1,...j.value,location:n(b)}}}export{parseProduces};
2
2
  //# sourceMappingURL=ProducesParser.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{firstWord as n,splitTopLevel as r,unescapeIdentifier as i}from"./LineText.js";import{locationOf as a}from"./SourceLine.js";import{parseDescription as o}from"./DescriptionParser.js";import{isFileDirective as s}from"./FileReferences.js";import{parseProjectionExpression as c}from"./ProjectionExpressionParser.js";const l=t(`^projection\\s+(@?[\\w.]+)\\s*(?:=>\\s*([\\w.]+))?$`),u=t(`^(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),d=t(`^join\\s+(@?[\\w.]+)\\s+on\\s+(@?[\\w.]+)$`),f=t(`^with\\s+(@?[\\w.]+)$`),p=t(`^children\\s+(@?[\\w.]+)\\s+identified\\s+by\\s+(.+)$`),m=t(`^nested\\s+(@?[\\w.]+)$`),h=t(`^remove\\s+with\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),g=t(`^remove\\s+via\\s+join\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),_=t(`^clear\\s+with\\s+(@?[\\w.]+)$`),v=t(`^variant\\s+(@?[\\w.]+)\\s*$`),y=t(`^enters\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),b=t(`^(increment|decrement|count|clear)\\s+(@?[$\\w.]+)$`),x=t(`^(add|subtract)\\s+(@?[$\\w.]+)\\s+by\\s+(.+)$`),S=t(`^set\\s+(@?[$\\w.]+)\\s+(?:=|to)\\s+(.+)$`),C=t(`^(@?[$\\w.@]+)\\s*=(?!=|>)\\s*(.+)$`),w={increment:`IncrementMappingSyntax`,decrement:`DecrementMappingSyntax`,clear:`ClearMappingSyntax`,count:`CountMappingSyntax`};function parseProjection(t,r){let i=l.exec(r.content);if(i===null)return t.error(e.InvalidProjectionDeclaration,`Invalid projection declaration '${r.content}' - expected 'projection <Name> [=> <ReadModel>]'`,a(r)),t.skipBlock(r.indent),{kind:`ProjectionSyntax`,sourceOptions:t.sourceOptions,name:n(r.content),readModel:null,sequence:null,autoMap:`Inherit`,blocks:[],location:a(r)};let c=i[1],u=null,d=null,f=`Inherit`,p=null,m=[];for(let e=t.peekChild(r.indent);e!==void 0;e=t.peekChild(r.indent)){if(t.reader.takeSignificant(),s(e))continue;let r=n(e.content);if(r===`description`)d=o(t,e,d,`Projection '${c}'`);else if(r===`sequence`)u=e.content.substring(8).trim();else if(r===`automap`)f=`Enabled`;else if(e.content===`no automap`)f=`Disabled`;else if(r===`key`)p=parseKey(t,e);else if(r===`variant`)m.push(parseVariant(t,e));else{let n=parseBlock(t,e,!1);n!==void 0&&m.push(n)}}return reportVariantConflicts(t,m,c),m.length===0&&t.error(e.EmptyProjection,`Projection '${c}' must contain at least one directive`,a(r)),{kind:`ProjectionSyntax`,sourceOptions:t.sourceOptions,name:c,readModel:i[2]??null,sequence:u,autoMap:f,key:p,blocks:m,description:d,location:a(r)}}function reportVariantConflicts(t,n,r){let i=n.filter(e=>e.kind===`ProjectionVariantSyntax`),a=/* @__PURE__ */ new Map;i.forEach(e=>a.set(e.name,[...a.get(e.name)??[],e]));for(let n of[...a.values()].flatMap(e=>e.slice(1)))t.error(e.DuplicateProjectionVariant,`Duplicate variant '${n.name}' - a variant name is declared once`,n.location);let o=/* @__PURE__ */ new Set;for(let i of n.flatMap(e=>e.kind===`ProjectionVariantSyntax`?e.entersOn:[]))i.event.length>0&&o.has(i.event)&&t.error(e.DuplicateVariantEnteringEvent,`Entering event '${i.event}' is claimed more than once in projection '${r}'`,i.location),o.add(i.event)}function parseBlock(t,r,i){let o=a(r);switch(n(r.content)){case`from`:return parseFrom(t,r);case`every`:{let e=!0,{autoMap:n,mappings:i}=parseMappingBlock(t,r,t=>t.content===`exclude children`&&(e=!1,!0));return{kind:`EverySyntax`,includeChildren:e,autoMap:n,mappings:i,location:o}}case`all`:{let{autoMap:e,mappings:n}=parseMappingBlock(t,r);return{kind:`AllSyntax`,autoMap:e,mappings:n,location:o}}case`join`:return parseJoin(t,r);case`children`:return parseChildren(t,r);case`nested`:return parseNested(t,r);case`remove`:return parseRemove(t,r);case`clear`:return i||t.error(e.ClearWithOutsideNestedBlock,`'clear with' is only valid inside a nested block`,o),parseClearWith(t,r);default:t.error(e.UnknownProjectionDirective,`Unexpected '${n(r.content)}' in projection body`,o),t.skipBlock(r.indent);return}}function parseFrom(t,o){let s=[];for(let n of r(o.content.substring(4),`,`)){let r=n.trim();if(r.length===0){t.error(e.FromWithoutEvent,`Expected an event type after 'from'`,a(o));continue}let l=u.exec(r);l===null?t.error(e.InvalidEventReference,`Invalid event reference '${r}'`,a(o)):s.push({kind:`EventSpecSyntax`,event:i(l[1]),key:l[2]===void 0?null:c(l[2],a(o),t),location:a(o)})}let l=[],d=null,f=null;for(let e=t.peekChild(o.indent);e!==void 0;e=t.peekChild(o.indent)){t.reader.takeSignificant();let r=n(e.content);r===`key`?d=parseKey(t,e):r===`parent`?f=c(e.content.substring(6),a(e),t):pushMapping(t,e,l)}return{kind:`FromSyntax`,events:s,key:d,parentKey:f,mappings:l,location:a(o)}}function parseJoin(t,n){let r=d.exec(n.content);if(r===null)return t.error(e.InvalidJoinDeclaration,`Invalid join declaration '${n.content}' - expected 'join <property> on <key>'`,a(n)),t.skipBlock(n.indent),{kind:`JoinSyntax`,property:``,on:``,events:[],location:a(n)};let o=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=f.exec(r.content);if(n===null){t.error(e.JoinWithoutEvent,`Expected 'with <EventType>' in join block, got '${r.content}'`,a(r)),t.skipBlock(r.indent);continue}let{autoMap:s,mappings:c}=parseMappingBlock(t,r);o.push({kind:`JoinEventSyntax`,event:i(n[1]),autoMap:s,mappings:c,location:a(r)})}return{kind:`JoinSyntax`,property:i(r[1]),on:i(r[2]),events:o,location:a(n)}}function parseChildren(t,n){let r=p.exec(n.content);if(r===null)return t.error(e.InvalidChildrenDeclaration,`Invalid children declaration '${n.content}' - expected 'children <collection> identified by <key>'`,a(n)),t.skipBlock(n.indent),{kind:`ChildrenSyntax`,property:``,autoMap:`Inherit`,blocks:[],location:a(n)};let{autoMap:o,blocks:s}=parseChildBlocks(t,n);return{kind:`ChildrenSyntax`,property:i(r[1]),identifiedBy:c(r[2],a(n),t),autoMap:o,blocks:s,location:a(n)}}function parseNested(t,n){let r=m.exec(n.content);if(r===null)return t.error(e.InvalidNestedDeclaration,`Invalid nested declaration '${n.content}' - expected 'nested <property>'`,a(n)),t.skipBlock(n.indent),{kind:`NestedSyntax`,property:``,autoMap:`Inherit`,blocks:[],location:a(n)};let o=i(r[1]),{autoMap:s,blocks:c}=parseChildBlocks(t,n);return c.some(e=>e.kind===`FromSyntax`)||t.error(e.NestedBlockWithoutFrom,`Nested block '${o}' must contain at least one 'from' directive`,a(n)),{kind:`NestedSyntax`,property:o,autoMap:s,blocks:c,location:a(n)}}function parseChildBlocks(e,t){let n=[],r=`Inherit`;for(let i=e.peekChild(t.indent);i!==void 0;i=e.peekChild(t.indent)){if(e.reader.takeSignificant(),i.content===`automap`){r=`Enabled`;continue}if(i.content===`no automap`){r=`Disabled`;continue}let t=parseBlock(e,i,!0);t!==void 0&&n.push(t)}return{autoMap:r,blocks:n}}function parseRemove(t,r){let o=g.exec(r.content);if(o!==null)return{kind:`RemoveViaJoinSyntax`,event:i(o[1]),key:o[2]===void 0?null:c(o[2],a(r),t),location:a(r)};let s=h.exec(r.content);if(s===null){t.error(e.InvalidRemoveDeclaration,`Invalid remove declaration '${r.content}' - expected 'remove with <EventType>' or 'remove via join on <EventType>'`,a(r)),t.skipBlock(r.indent);return}let l=null;for(let i=t.peekChild(r.indent);i!==void 0;i=t.peekChild(r.indent))t.reader.takeSignificant(),n(i.content)===`parent`?l=c(i.content.substring(6),a(i),t):t.error(e.UnknownRemoveDirective,`Unexpected '${i.content}' in remove block - only 'parent' is allowed`,a(i));return{kind:`RemoveWithSyntax`,event:i(s[1]),key:s[2]===void 0?null:c(s[2],a(r),t),parentKey:l,location:a(r)}}function parseClearWith(t,n){let r=_.exec(n.content);return r===null?(t.error(e.InvalidClearDeclaration,`Invalid clear declaration '${n.content}' - expected 'clear with <EventType>'`,a(n)),{kind:`ClearWithSyntax`,event:``,location:a(n)}):{kind:`ClearWithSyntax`,event:i(r[1]),location:a(n)}}function parseVariant(t,r){let o=v.exec(r.content);if(o===null)return t.error(e.InvalidProjectionVariantDeclaration,`Invalid variant declaration '${r.content}' - expected 'variant <Name>'`,a(r)),t.skipBlock(r.indent),{kind:`ProjectionVariantSyntax`,name:n(r.content),entersOn:[],blocks:[],location:a(r)};let s=i(o[1]),c=[],l=[];for(let i=t.peekChild(r.indent);i!==void 0;i=t.peekChild(r.indent)){t.reader.takeSignificant();let r=n(i.content);if(r===`enters`)c.push(parseEntersOn(t,i));else if(r===`variant`)t.error(e.NestedProjectionVariantNotAllowed,`A variant cannot be declared inside another variant`,a(i)),t.skipBlock(i.indent);else{let e=parseBlock(t,i,!1);e!==void 0&&l.push(e)}}return c.length===0&&t.error(e.VariantRequiresEnteringEvent,`Variant '${s}' must declare at least one 'enters on' event`,a(r)),{kind:`ProjectionVariantSyntax`,name:s,entersOn:c,blocks:l,location:a(r)}}function parseEntersOn(t,n){let r=y.exec(n.content);return r===null?(t.error(e.InvalidEntersOnDeclaration,`Invalid 'enters on' declaration '${n.content}' - expected 'enters on <EventType> [key <expression>]'`,a(n)),t.skipBlock(n.indent),{kind:`ProjectionEntersOnSyntax`,event:``,key:null,location:a(n)}):{kind:`ProjectionEntersOnSyntax`,event:i(r[1]),key:r[2]===void 0?null:c(r[2],a(n),t),location:a(n)}}function parseKey(t,n){let r=n.content.substring(3).trim();if(t.peekChild(n.indent)===void 0)return{kind:`ExpressionKeySyntax`,expression:c(r,a(n),t),location:a(n)};let o=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){if(t.reader.takeSignificant(),r.content===`}`)continue;let n=C.exec(r.content);if(n===null){t.sourceOptions.numericMode===`exact`&&t.error(e.InvalidCompositeKeyPart,`Invalid composite key part '${r.content}' - expected '<property> = <expression>'`,a(r));continue}let s=c(n[2],a(r),t);t.sourceOptions.numericMode===`exact`&&s.kind===`TemplateExpressionSyntax`&&t.error(e.TemplateInCompositeKey,`Template expressions are not allowed in composite keys`,a(r)),o.push({kind:`KeyPartSyntax`,property:i(n[1]),expression:s,location:a(r)})}let s=t.reader.peekSignificant();return s!==void 0&&s.indent===n.indent&&s.content===`}`&&t.reader.takeSignificant(),t.sourceOptions.numericMode===`exact`&&o.length===0&&t.error(e.EmptyCompositeKey,`Composite keys must contain at least one part`,a(n)),{kind:`CompositeKeySyntax`,type:r.replace(/\{$/,``).trim(),parts:o,location:a(n)}}function parseMappingBlock(e,t,n=()=>!1){let r=`Inherit`,i=[];for(let a=e.peekChild(t.indent);a!==void 0;a=e.peekChild(t.indent))e.reader.takeSignificant(),a.content===`automap`?r=`Enabled`:a.content===`no automap`?r=`Disabled`:n(a)||pushMapping(e,a,i);return{autoMap:r,mappings:i}}function pushMapping(t,n,r){let o=a(n),s=b.exec(n.content);if(s!==null){s[1]!==`clear`||s[2]!==`with`?r.push({kind:w[s[1]],property:i(s[2]),location:o}):t.sourceOptions.numericMode===`exact`&&t.error(e.InvalidProjectionMapping,`Invalid mapping '${n.content}' - 'clear with' is a block directive and needs an event type; to clear a property named 'with', write 'clear @with'`,o);return}let l=x.exec(n.content);if(l!==null){r.push({kind:l[1]===`add`?`AddMappingSyntax`:`SubtractMappingSyntax`,property:i(l[2]),value:c(l[3],o,t),location:o});return}let u=S.exec(n.content)??C.exec(n.content);u===null?t.sourceOptions.numericMode===`exact`&&t.error(e.InvalidProjectionMapping,`Invalid mapping '${n.content}'`,o):r.push({kind:`SetMappingSyntax`,property:i(u[1]),source:c(u[2],o,t),location:o})}export{parseProjection};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{firstWord as r,splitTopLevel as i,unescapeIdentifier as a}from"./LineText.js";import{parseDescription as o}from"./DescriptionParser.js";import{isFileDirective as s}from"./FileReferences.js";import{parseProjectionExpression as c}from"./ProjectionExpressionParser.js";const l=t(`^projection\\s+(@?[\\w.]+)\\s*(?:=>\\s*([\\w.]+))?$`),u=t(`^(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),d=t(`^join\\s+(@?[\\w.]+)\\s+on\\s+(@?[\\w.]+)$`),f=t(`^with\\s+(@?[\\w.]+)$`),p=t(`^children\\s+(@?[\\w.]+)\\s+identified\\s+by\\s+(.+)$`),m=t(`^nested\\s+(@?[\\w.]+)$`),h=t(`^remove\\s+with\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),g=t(`^remove\\s+via\\s+join\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),_=t(`^clear\\s+with\\s+(@?[\\w.]+)$`),v=t(`^variant\\s+(@?[\\w.]+)\\s*$`),y=t(`^enters\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),b=t(`^(increment|decrement|count|clear)\\s+(@?[$\\w.]+)$`),x=t(`^(add|subtract)\\s+(@?[$\\w.]+)\\s+by\\s+(.+)$`),S=t(`^set\\s+(@?[$\\w.]+)\\s+(?:=|to)\\s+(.+)$`),C=t(`^(@?[$\\w.@]+)\\s*=(?!=|>)\\s*(.+)$`),w={increment:`IncrementMappingSyntax`,decrement:`DecrementMappingSyntax`,clear:`ClearMappingSyntax`,count:`CountMappingSyntax`};function parseProjection(t,i){let a=l.exec(i.content);if(a===null)return t.error(e.InvalidProjectionDeclaration,`Invalid projection declaration '${i.content}' - expected 'projection <Name> [=> <ReadModel>]'`,n(i)),t.skipBlock(i.indent),{kind:`ProjectionSyntax`,sourceOptions:t.sourceOptions,name:r(i.content),readModel:null,sequence:null,autoMap:`Inherit`,blocks:[],location:n(i)};let c=a[1],u=null,d=null,f=`Inherit`,p=null,m=[];for(let e=t.peekChild(i.indent);e!==void 0;e=t.peekChild(i.indent)){if(t.reader.takeSignificant(),s(e))continue;let n=r(e.content);if(n===`description`)d=o(t,e,d,`Projection '${c}'`);else if(n===`sequence`)u=e.content.substring(8).trim();else if(n===`automap`)f=`Enabled`;else if(e.content===`no automap`)f=`Disabled`;else if(n===`key`)p=parseKey(t,e);else if(n===`variant`)m.push(parseVariant(t,e));else{let n=parseBlock(t,e,!1);n!==void 0&&m.push(n)}}return reportVariantConflicts(t,m,c),m.length===0&&t.error(e.EmptyProjection,`Projection '${c}' must contain at least one directive`,n(i)),{kind:`ProjectionSyntax`,sourceOptions:t.sourceOptions,name:c,readModel:a[2]??null,sequence:u,autoMap:f,key:p,blocks:m,description:d,location:n(i)}}function reportVariantConflicts(t,n,r){let i=n.filter(e=>e.kind===`ProjectionVariantSyntax`),a=/* @__PURE__ */ new Map;i.forEach(e=>a.set(e.name,[...a.get(e.name)??[],e]));for(let n of[...a.values()].flatMap(e=>e.slice(1)))t.error(e.DuplicateProjectionVariant,`Duplicate variant '${n.name}' - a variant name is declared once`,n.location);let o=/* @__PURE__ */ new Set;for(let i of n.flatMap(e=>e.kind===`ProjectionVariantSyntax`?e.entersOn:[]))i.event.length>0&&o.has(i.event)&&t.error(e.DuplicateVariantEnteringEvent,`Entering event '${i.event}' is claimed more than once in projection '${r}'`,i.location),o.add(i.event)}function parseBlock(t,i,a){let o=n(i);switch(r(i.content)){case`from`:return parseFrom(t,i);case`every`:{let e=!0,{autoMap:n,mappings:r}=parseMappingBlock(t,i,t=>t.content===`exclude children`&&(e=!1,!0));return{kind:`EverySyntax`,includeChildren:e,autoMap:n,mappings:r,location:o}}case`all`:{let{autoMap:e,mappings:n}=parseMappingBlock(t,i);return{kind:`AllSyntax`,autoMap:e,mappings:n,location:o}}case`join`:return parseJoin(t,i);case`children`:return parseChildren(t,i);case`nested`:return parseNested(t,i);case`remove`:return parseRemove(t,i);case`clear`:return a||t.error(e.ClearWithOutsideNestedBlock,`'clear with' is only valid inside a nested block`,o),parseClearWith(t,i);default:t.error(e.UnknownProjectionDirective,`Unexpected '${r(i.content)}' in projection body`,o),t.skipBlock(i.indent);return}}function parseFrom(t,o){let s=[];for(let r of i(o.content.substring(4),`,`)){let i=r.trim();if(i.length===0){t.error(e.FromWithoutEvent,`Expected an event type after 'from'`,n(o));continue}let l=u.exec(i);l===null?t.error(e.InvalidEventReference,`Invalid event reference '${i}'`,n(o)):s.push({kind:`EventSpecSyntax`,event:a(l[1]),key:l[2]===void 0?null:c(l[2],n(o),t),location:n(o)})}let l=[],d=null,f=null;for(let e=t.peekChild(o.indent);e!==void 0;e=t.peekChild(o.indent)){t.reader.takeSignificant();let i=r(e.content);i===`key`?d=parseKey(t,e):i===`parent`?f=c(e.content.substring(6),n(e),t):pushMapping(t,e,l)}return{kind:`FromSyntax`,events:s,key:d,parentKey:f,mappings:l,location:n(o)}}function parseJoin(t,r){let i=d.exec(r.content);if(i===null)return t.error(e.InvalidJoinDeclaration,`Invalid join declaration '${r.content}' - expected 'join <property> on <key>'`,n(r)),t.skipBlock(r.indent),{kind:`JoinSyntax`,property:``,on:``,events:[],location:n(r)};let o=[];for(let i=t.peekChild(r.indent);i!==void 0;i=t.peekChild(r.indent)){t.reader.takeSignificant();let r=f.exec(i.content);if(r===null){t.error(e.JoinWithoutEvent,`Expected 'with <EventType>' in join block, got '${i.content}'`,n(i)),t.skipBlock(i.indent);continue}let{autoMap:s,mappings:c}=parseMappingBlock(t,i);o.push({kind:`JoinEventSyntax`,event:a(r[1]),autoMap:s,mappings:c,location:n(i)})}return{kind:`JoinSyntax`,property:a(i[1]),on:a(i[2]),events:o,location:n(r)}}function parseChildren(t,r){let i=p.exec(r.content);if(i===null)return t.error(e.InvalidChildrenDeclaration,`Invalid children declaration '${r.content}' - expected 'children <collection> identified by <key>'`,n(r)),t.skipBlock(r.indent),{kind:`ChildrenSyntax`,property:``,autoMap:`Inherit`,blocks:[],location:n(r)};let{autoMap:o,blocks:s}=parseChildBlocks(t,r);return{kind:`ChildrenSyntax`,property:a(i[1]),identifiedBy:c(i[2],n(r),t),autoMap:o,blocks:s,location:n(r)}}function parseNested(t,r){let i=m.exec(r.content);if(i===null)return t.error(e.InvalidNestedDeclaration,`Invalid nested declaration '${r.content}' - expected 'nested <property>'`,n(r)),t.skipBlock(r.indent),{kind:`NestedSyntax`,property:``,autoMap:`Inherit`,blocks:[],location:n(r)};let o=a(i[1]),{autoMap:s,blocks:c}=parseChildBlocks(t,r);return c.some(e=>e.kind===`FromSyntax`)||t.error(e.NestedBlockWithoutFrom,`Nested block '${o}' must contain at least one 'from' directive`,n(r)),{kind:`NestedSyntax`,property:o,autoMap:s,blocks:c,location:n(r)}}function parseChildBlocks(e,t){let n=[],r=`Inherit`;for(let i=e.peekChild(t.indent);i!==void 0;i=e.peekChild(t.indent)){if(e.reader.takeSignificant(),i.content===`automap`){r=`Enabled`;continue}if(i.content===`no automap`){r=`Disabled`;continue}let t=parseBlock(e,i,!0);t!==void 0&&n.push(t)}return{autoMap:r,blocks:n}}function parseRemove(t,i){let o=g.exec(i.content);if(o!==null)return{kind:`RemoveViaJoinSyntax`,event:a(o[1]),key:o[2]===void 0?null:c(o[2],n(i),t),location:n(i)};let s=h.exec(i.content);if(s===null){t.error(e.InvalidRemoveDeclaration,`Invalid remove declaration '${i.content}' - expected 'remove with <EventType>' or 'remove via join on <EventType>'`,n(i)),t.skipBlock(i.indent);return}let l=null;for(let a=t.peekChild(i.indent);a!==void 0;a=t.peekChild(i.indent))t.reader.takeSignificant(),r(a.content)===`parent`?l=c(a.content.substring(6),n(a),t):t.error(e.UnknownRemoveDirective,`Unexpected '${a.content}' in remove block - only 'parent' is allowed`,n(a));return{kind:`RemoveWithSyntax`,event:a(s[1]),key:s[2]===void 0?null:c(s[2],n(i),t),parentKey:l,location:n(i)}}function parseClearWith(t,r){let i=_.exec(r.content);return i===null?(t.error(e.InvalidClearDeclaration,`Invalid clear declaration '${r.content}' - expected 'clear with <EventType>'`,n(r)),{kind:`ClearWithSyntax`,event:``,location:n(r)}):{kind:`ClearWithSyntax`,event:a(i[1]),location:n(r)}}function parseVariant(t,i){let o=v.exec(i.content);if(o===null)return t.error(e.InvalidProjectionVariantDeclaration,`Invalid variant declaration '${i.content}' - expected 'variant <Name>'`,n(i)),t.skipBlock(i.indent),{kind:`ProjectionVariantSyntax`,name:r(i.content),entersOn:[],blocks:[],location:n(i)};let s=a(o[1]),c=[],l=[];for(let a=t.peekChild(i.indent);a!==void 0;a=t.peekChild(i.indent)){t.reader.takeSignificant();let i=r(a.content);if(i===`enters`)c.push(parseEntersOn(t,a));else if(i===`variant`)t.error(e.NestedProjectionVariantNotAllowed,`A variant cannot be declared inside another variant`,n(a)),t.skipBlock(a.indent);else{let e=parseBlock(t,a,!1);e!==void 0&&l.push(e)}}return c.length===0&&t.error(e.VariantRequiresEnteringEvent,`Variant '${s}' must declare at least one 'enters on' event`,n(i)),{kind:`ProjectionVariantSyntax`,name:s,entersOn:c,blocks:l,location:n(i)}}function parseEntersOn(t,r){let i=y.exec(r.content);return i===null?(t.error(e.InvalidEntersOnDeclaration,`Invalid 'enters on' declaration '${r.content}' - expected 'enters on <EventType> [key <expression>]'`,n(r)),t.skipBlock(r.indent),{kind:`ProjectionEntersOnSyntax`,event:``,key:null,location:n(r)}):{kind:`ProjectionEntersOnSyntax`,event:a(i[1]),key:i[2]===void 0?null:c(i[2],n(r),t),location:n(r)}}function parseKey(t,r){let i=r.content.substring(3).trim();if(t.peekChild(r.indent)===void 0)return{kind:`ExpressionKeySyntax`,expression:c(i,n(r),t),location:n(r)};let o=[];for(let i=t.peekChild(r.indent);i!==void 0;i=t.peekChild(r.indent)){if(t.reader.takeSignificant(),i.content===`}`)continue;let r=C.exec(i.content);if(r===null){t.sourceOptions.numericMode===`exact`&&t.error(e.InvalidCompositeKeyPart,`Invalid composite key part '${i.content}' - expected '<property> = <expression>'`,n(i));continue}let s=c(r[2],n(i),t);t.sourceOptions.numericMode===`exact`&&s.kind===`TemplateExpressionSyntax`&&t.error(e.TemplateInCompositeKey,`Template expressions are not allowed in composite keys`,n(i)),o.push({kind:`KeyPartSyntax`,property:a(r[1]),expression:s,location:n(i)})}let s=t.reader.peekSignificant();return s!==void 0&&s.indent===r.indent&&s.content===`}`&&t.reader.takeSignificant(),t.sourceOptions.numericMode===`exact`&&o.length===0&&t.error(e.EmptyCompositeKey,`Composite keys must contain at least one part`,n(r)),{kind:`CompositeKeySyntax`,type:i.replace(/\{$/,``).trim(),parts:o,location:n(r)}}function parseMappingBlock(e,t,n=()=>!1){let r=`Inherit`,i=[];for(let a=e.peekChild(t.indent);a!==void 0;a=e.peekChild(t.indent))e.reader.takeSignificant(),a.content===`automap`?r=`Enabled`:a.content===`no automap`?r=`Disabled`:n(a)||pushMapping(e,a,i);return{autoMap:r,mappings:i}}function pushMapping(t,r,i){let o=n(r),s=b.exec(r.content);if(s!==null){s[1]!==`clear`||s[2]!==`with`?i.push({kind:w[s[1]],property:a(s[2]),location:o}):t.sourceOptions.numericMode===`exact`&&t.error(e.InvalidProjectionMapping,`Invalid mapping '${r.content}' - 'clear with' is a block directive and needs an event type; to clear a property named 'with', write 'clear @with'`,o);return}let l=x.exec(r.content);if(l!==null){i.push({kind:l[1]===`add`?`AddMappingSyntax`:`SubtractMappingSyntax`,property:a(l[2]),value:c(l[3],o,t),location:o});return}let u=S.exec(r.content)??C.exec(r.content);u===null?t.sourceOptions.numericMode===`exact`&&t.error(e.InvalidProjectionMapping,`Invalid mapping '${r.content}'`,o):i.push({kind:`SetMappingSyntax`,property:a(u[1]),source:c(u[2],o,t),location:o})}export{parseProjection};
2
2
  //# sourceMappingURL=ProjectionParser.js.map
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{unescapeIdentifier as n}from"./LineText.js";import{locationOf as r}from"./SourceLine.js";const i=t(`^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+(generated))?(?:\\s+(identifier))?(?:\\s+(subject))?$`),a=t(`^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\??\\s+((?:optional|generated|identifier|subject)(?:\\s+(?:optional|generated|identifier|subject))*)$`),o=t(`^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+identifier\\s+optional(?:\\s*=.*)?$`);function tryParseProperty(e){let t=i.exec(e.content);if(t===null)return;let a=r(e);return{kind:`PropertySyntax`,name:n(t[1]),type:parseTypeRef(t[2],{...a,column:a.column+e.content.indexOf(t[2],t[1].length)}),isGenerated:t[3]!==void 0,nameWasEscaped:t[1].startsWith(`@`),isIdentifier:t[4]!==void 0,...t[5]===void 0?{}:{isSubject:!0},location:a}}function parseTypeRef(e,t){let n=e.endsWith(`?`),r=/\soptional$/.test(e),i=n||r;i&&(e=e.substring(0,e.length-(n?1:8)).trimEnd());let a=e.endsWith(`[]`);return a&&(e=e.substring(0,e.length-2)),{kind:`TypeRefSyntax`,name:e,isCollection:a,isOptional:i,location:t}}function parseProperty(e,t){let n=tryParseProperty(t);return n===void 0?reportInvalidModifierOrder(e,t):reportLegacyOptionalSuffix(e,n.type,t),n}function reportLegacyOptionalSuffix(t,n,r){t.claimField(r);let i=n.name.length+(n.isCollection?2:0),a=n.location.column-r.indent-1+i;if(n.isOptional&&r.content[a]===`?`){let r=n.name+(n.isCollection?`[]`:``);t.information(e.LegacyOptionalSuffix,`Write '${r} optional' instead of '${r}?'.`,n.location)}}function reportInvalidModifierOrder(t,n){let i=a.exec(n.content);if(i!==null&&i[1].split(/\s+/).includes(`subject`))return t.error(e.InvalidSubjectModifierOrder,`Write each modifier once in order: '<name> <Type> optional generated identifier subject'.`,r(n)),!0;if(o.test(n.content))return t.error(e.InvalidOptionalModifierOrder,`Write 'optional' before 'identifier': '<name> <Type> optional identifier'.`,r(n)),!0;{let i=a.exec(n.content);if(i!==null&&i[1].split(/\s+/).some(e=>e===`generated`||e===`identifier`))return t.error(e.InvalidGeneratedModifierOrder,`Write each modifier once in order: '<name> <Type> optional generated identifier'.`,r(n)),!0}return!1}export{parseProperty,parseTypeRef,reportInvalidModifierOrder,reportLegacyOptionalSuffix,tryParseProperty};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{unescapeIdentifier as r}from"./LineText.js";const i=t(`^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+(generated))?(?:\\s+(identifier))?(?:\\s+(subject))?$`),a=t(`^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\??\\s+((?:optional|generated|identifier|subject)(?:\\s+(?:optional|generated|identifier|subject))*)$`),o=t(`^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+identifier\\s+optional(?:\\s*=.*)?$`);function tryParseProperty(e){let t=i.exec(e.content);if(t===null)return;let a=n(e);return{kind:`PropertySyntax`,name:r(t[1]),type:parseTypeRef(t[2],{...a,column:a.column+e.content.indexOf(t[2],t[1].length)}),isGenerated:t[3]!==void 0,nameWasEscaped:t[1].startsWith(`@`),isIdentifier:t[4]!==void 0,...t[5]===void 0?{}:{isSubject:!0},location:a}}function parseTypeRef(e,t){let n=e.endsWith(`?`),r=/\soptional$/.test(e),i=n||r;i&&(e=e.substring(0,e.length-(n?1:8)).trimEnd());let a=e.endsWith(`[]`);return a&&(e=e.substring(0,e.length-2)),{kind:`TypeRefSyntax`,name:e,isCollection:a,isOptional:i,location:t}}function parseProperty(e,t){let n=tryParseProperty(t);return n===void 0?reportInvalidModifierOrder(e,t):reportLegacyOptionalSuffix(e,n.type,t),n}function reportLegacyOptionalSuffix(t,n,r){t.claimField(r);let i=n.name.length+(n.isCollection?2:0),a=n.location.column-r.indent-1+i;if(n.isOptional&&r.content[a]===`?`){let r=n.name+(n.isCollection?`[]`:``);t.information(e.LegacyOptionalSuffix,`Write '${r} optional' instead of '${r}?'.`,n.location)}}function reportInvalidModifierOrder(t,r){let i=a.exec(r.content);if(i!==null&&i[1].split(/\s+/).includes(`subject`))return t.error(e.InvalidSubjectModifierOrder,`Write each modifier once in order: '<name> <Type> optional generated identifier subject'.`,n(r)),!0;if(o.test(r.content))return t.error(e.InvalidOptionalModifierOrder,`Write 'optional' before 'identifier': '<name> <Type> optional identifier'.`,n(r)),!0;{let i=a.exec(r.content);if(i!==null&&i[1].split(/\s+/).some(e=>e===`generated`||e===`identifier`))return t.error(e.InvalidGeneratedModifierOrder,`Write each modifier once in order: '<name> <Type> optional generated identifier'.`,n(r)),!0}return!1}export{parseProperty,parseTypeRef,reportInvalidModifierOrder,reportLegacyOptionalSuffix,tryParseProperty};
2
2
  //# sourceMappingURL=PropertyLineParser.js.map