@cratis/screenplay-language 4.145.1 → 4.147.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 (45) hide show
  1. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
  2. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
  3. package/dist/bundles/compiler/Parsing/GenerationParser.js +2 -0
  4. package/dist/bundles/compiler/Parsing/GenerationParser.js.map +1 -0
  5. package/dist/bundles/compiler/Parsing/ResponseValidator.js +1 -1
  6. package/dist/bundles/compiler/Parsing/ResponseValidator.js.map +1 -1
  7. package/dist/bundles/compiler/Parsing/ScreenplayParser.js +1 -1
  8. package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -1
  9. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js +1 -1
  10. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js.map +1 -1
  11. package/dist/bundles/compiler/Syntax/SyntaxCollections.js +1 -1
  12. package/dist/bundles/compiler/Syntax/SyntaxCollections.js.map +1 -1
  13. package/dist/bundles/compiler/Syntax/SyntaxJson.js +1 -1
  14. package/dist/bundles/compiler/Syntax/SyntaxJson.js.map +1 -1
  15. package/dist/bundles/completion-items.js +1 -1
  16. package/dist/bundles/completion-items.js.map +1 -1
  17. package/dist/bundles/completion-planner.js +2 -2
  18. package/dist/bundles/completion-planner.js.map +1 -1
  19. package/dist/bundles/diagnostic-codes.js +1 -1
  20. package/dist/bundles/diagnostic-codes.js.map +1 -1
  21. package/dist/bundles/generation-completions.js +2 -0
  22. package/dist/bundles/generation-completions.js.map +1 -0
  23. package/dist/bundles/hover-content.js +5 -5
  24. package/dist/bundles/hover-content.js.map +1 -1
  25. package/dist/bundles/response-completions.js +1 -1
  26. package/dist/bundles/response-completions.js.map +1 -1
  27. package/dist/bundles/symbols.js +1 -1
  28. package/dist/bundles/symbols.js.map +1 -1
  29. package/dist/bundles/tokens.js +1 -1
  30. package/dist/bundles/tokens.js.map +1 -1
  31. package/dist/bundles/validation.js +1 -1
  32. package/dist/bundles/validation.js.map +1 -1
  33. package/dist/completion-items.d.ts.map +1 -1
  34. package/dist/completion-planner.d.ts.map +1 -1
  35. package/dist/diagnostic-codes.d.ts +13 -0
  36. package/dist/diagnostic-codes.d.ts.map +1 -1
  37. package/dist/generation-completions.d.ts +3 -0
  38. package/dist/generation-completions.d.ts.map +1 -0
  39. package/dist/hover-content.d.ts.map +1 -1
  40. package/dist/response-completions.d.ts.map +1 -1
  41. package/dist/symbols.d.ts +1 -0
  42. package/dist/symbols.d.ts.map +1 -1
  43. package/dist/tokens.d.ts.map +1 -1
  44. package/dist/validation.d.ts.map +1 -1
  45. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"hover-content.js","names":["fences","fenceMap","lines","lineIndex","line","endColumn","withoutComment","inString","inTemplate","index","startColumn","reaction","reactionReferenceAt","application","fixtureHover","exampleHover","sourceHover","eventSourceHover","operation","operationHover","start","column","word","name","before","enclosingChain","indentOf","complianceHeader","complianceBody","doc","attributeDocs","specialCategoryDocs","variable","branch","refusalContext","member","descriptions","detail","symbolsForBuffer","contextVariableDocs","\"$env\"","prefix","followsPropertyType","followsQueryType","source","eventAnalysisSource","subjectPrefix","ownerChain","enclosingHeaders","keywordDocs","chain","ruleContext","namedRuleContext","handlerIntentDocs","symbols","scanDocument","owner","command","property","typeReferenceText","propertyTypeReference","responseAvailability","response","field","type","specification","responseAnalysis","value","concept","candidate","attributes","values","reasons","attribute","reason","properties","policy","body","event","right","left","construct","getSubLanguage","step","specificationKeywordDocs","inEvent","directBody","directive","keywordDoc"],"sources":["../../hover-content.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 { reactionReferenceAt } from './reaction-authoring';\nimport { refusalContext } from './refusal-context';\nimport { namedRuleContext } from './named-rule-context';\nimport { eventSourceHover } from './event-source-authoring';\nimport { exampleHover } from './example-authoring';\nimport { operationHover } from './operation-authoring';\nimport { DocumentSymbols, symbolsForBuffer } from './symbols';\nimport { responseAnalysis, responseAvailability } from './response-analysis';\nimport { enclosingChain, enclosingHeaders, fenceMap, indentOf, withoutComment } from './document-context';\nimport { directBody, propertyTypeReference, scanDocument } from './symbols';\nimport { typeReferenceText } from './TypeReferenceSymbol';\nimport { eventAnalysisSource } from './event-analysis-source';\nimport { getSubLanguage } from './sub-language-registry';\nimport { attributeDocs, contextVariableDocs, handlerIntentDocs, keywordDocs, specialCategoryDocs, specificationKeywordDocs } from './keyword-docs';\n\n// Produces the hover markdown for a word at a position, without any editor\n// dependency — the Monaco service and the VSCode extension share this content.\n// Columns are 1-based, matching both editors' word-at-position APIs.\nexport function hoverContent(\n lines: string[],\n lineIndex: number,\n word: string,\n startColumn: number,\n endColumn: number,\n application?: DocumentSymbols,\n): string | null {\n const fences = fenceMap(lines);\n if (fences[lineIndex]) return null;\n\n const line = lines[lineIndex] ?? '';\n if (endColumn - 1 > withoutComment(line).length) return null;\n let inString = false;\n let inTemplate = false;\n for (let index = 0; index < startColumn - 1; index++) {\n if (line[index] === '\\\\' && inString) index++;\n else if (line[index] === '\"' && !inTemplate) inString = !inString;\n else if (line[index] === '`' && !inString) inTemplate = !inTemplate;\n }\n if (inString || inTemplate) return null;\n const reaction = reactionReferenceAt(lines, lineIndex, startColumn, endColumn, application);\n if (reaction) return reaction.content;\n const fixtureHover = exampleHover(lines, lineIndex, startColumn, endColumn, application);\n if (fixtureHover) return fixtureHover;\n const sourceHover = eventSourceHover(lines, lineIndex, startColumn, endColumn, application);\n if (sourceHover) return sourceHover;\n const operation = operationHover(lines, lineIndex, startColumn, endColumn, application);\n if (operation) return operation;\n const tokenAt = (column: number, name: string): boolean => {\n const start = column + (line[column - 1] === '@' ? 1 : 0);\n return word === name && startColumn === start && endColumn === start + name.length && line.slice(start - 1, endColumn - 1) === name;\n };\n const before = line.charAt(startColumn - 2);\n if (word === 'authorization' && enclosingChain(lines, fences, lineIndex, indentOf(line))[0] === 'purpose') return 'A quoted authorization in law for criminal-offence data (Art. 10).';\n\n const complianceHeader = /^\\s*concept\\s+[^\\s:]+\\s*:\\s*\\w+\\s+/.exec(line);\n const complianceBody = enclosingChain(lines, fences, lineIndex, indentOf(line))[0] === 'concept' && /^\\s*(?:@?pii|personal|@?sensitive|secret)\\s+(?:reason|scope|special|criminal)\\b/.test(line);\n if ((complianceHeader !== null && startColumn - 1 >= complianceHeader[0].length - 1) || complianceBody) {\n const doc = attributeDocs[word];\n if (doc) return doc;\n if (Object.hasOwn(specialCategoryDocs, word) && /^\\s*(?:@?pii|personal)\\s+special\\s+/.test(line)) return `**${word}** — ${specialCategoryDocs[word]}`;\n if (word === 'special') return 'GDPR Art. 9(1) special category; requires pii. At most one category per concept.';\n if (word === 'criminal') return 'Personal data relating to criminal convictions and offenses (GDPR Art. 10); requires pii.';\n if (/^\\s*(?:secret|sensitive|@sensitive)\\s+scope\\s+/.test(line) && ['subject', 'namespace', 'global'].includes(word)) return `**${word}** — Secret encryption scope${word === 'subject' ? ' per data subject' : word === 'namespace' ? ' per tenant namespace' : ' shared globally'}. Not an event-property subject role.`;\n if (word === 'scope') return 'Secret encryption scope: subject, namespace or global. Omitted scope keeps Chronicle’s Subject default; pii secret renders only [PII].';\n }\n if (before === '$' || before === '.') {\n const variable = line.substring(0, endColumn - 1).match(/\\$[\\w.]*$/)?.[0];\n if (variable) {\n if (variable.startsWith('$refusal')) {\n const branch = refusalContext(lines, lineIndex, indentOf(line));\n const member = variable.substring('$refusal.'.length);\n const descriptions: Record<string, string> = { reason: 'Refusal kind as a String: validation, constraint or authorization.', message: 'Rejection details verbatim, including unresolved $strings keys.', constraint: 'Violated constraint name as a String, only in a by constraint branch.' };\n return branch !== undefined && descriptions[member] !== undefined ? `**${variable}** — ${descriptions[member]} Syntax-only, not yet executable (PLAY0268).` : null;\n }\n if (variable.startsWith('$identity.')) {\n const name = variable.substring('$identity.'.length).split('.')[0];\n const detail = symbolsForBuffer(lines, application).identityDetails?.find(detail => detail.name === name);\n if (detail) return `**$identity.${detail.name}** — ${detail.type}. Declared caller detail; authoring metadata only, not executable until admitted (#600).`;\n }\n const doc =\n contextVariableDocs[variable] ??\n (variable.startsWith('$env') ? contextVariableDocs['$env'] : undefined);\n if (doc) return doc;\n }\n }\n\n // Do not mistake a property/type named optional for the contextual modifier.\n const prefix = line.slice(0, startColumn - 1);\n // Commit to query-parameter context before matching the name and type.\n const followsPropertyType = /^\\s*(?:by|filter)\\s+/.test(prefix)\n ? /^\\s*(?:by|filter)\\s+[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+$/.test(prefix)\n : /^\\s*@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+$/.test(prefix);\n const followsQueryType = /^\\s*query\\s+\\w+\\s*=>\\s*(?:observable\\s+)?[\\w.]+(?:\\[\\])?\\s+$/.test(prefix) &&\n !/^\\s*query\\s+\\w+\\s*=>\\s*observable\\s+$/.test(prefix);\n if (word === 'subject') {\n const source = eventAnalysisSource(lines);\n const subjectPrefix = /^\\s*@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?(?:\\s+generated)?(?:\\s+identifier)?\\s+$/.test(prefix);\n const ownerChain = enclosingChain(source, fences, lineIndex, indentOf(line));\n if (subjectPrefix && (ownerChain[0] === 'event' || /^produces\\s+event\\s+/.test(enclosingHeaders(source, fences, lineIndex, indentOf(line))[0] ?? ''))) {\n return '**subject** — This event property identifies its one data subject instead of the event source (decision 0008). Required scalar String, Uuid or their concepts, or an Int-backed concept; never pii or secret. Report-only lineage metadata (PLAY0270); no ESM bytes or provider output yet.';\n }\n if (/\\bclaim\\s+\"(?:[^\"\\\\]|\\\\.)*\"\\s+matches\\s+$/.test(prefix) && ownerChain.includes('policy')) return `**subject** — ${keywordDocs.subject}`;\n return null;\n }\n if (word === 'optional' && (followsPropertyType || followsQueryType)) {\n return `**optional** — ${keywordDocs.optional}`;\n }\n\n if (word === 'implementation' || word === 'hint') {\n const chain = enclosingChain(lines, fences, lineIndex, indentOf(line));\n const ruleContext = namedRuleContext(lines, lineIndex, indentOf(line));\n if ((word === 'implementation' && ruleContext === 'rule' && /^\\s*implementation\\s*$/.test(withoutComment(line))) ||\n (word === 'hint' && ruleContext === 'implementation' && /^\\s*hint\\s+\"/.test(line))) {\n return `**${word}** — Command named-rule guidance with at most one file or tagged fence. No payload means pending and fails binding (PLAY0268). Attached predicates keep their existing pure RuleContext contract; reference execution is unsupported, never confirmation.`;\n }\n if (word === 'implementation' && chain[0] === 'handler' && /^\\s*implementation\\s*$/.test(withoutComment(line))) {\n return `**implementation** — ${handlerIntentDocs.implementation}`;\n }\n if (word === 'hint' && chain[0] === 'implementation' && chain[1] === 'handler' && /^\\s*hint\\s+\"/.test(line)) {\n return `**hint** — ${handlerIntentDocs.hint}`;\n }\n }\n\n const symbols = scanDocument(lines);\n const owner = symbols.commands.filter(command => command.line < lineIndex).at(-1);\n const property = owner?.properties.find(property => property.name === word && property.line === lineIndex);\n if (property?.isGenerated || (word === 'generated' && owner?.properties.some(property => property.isGenerated && property.line === lineIndex) && followsPropertyType)) {\n return `**${property?.name ?? 'generated'}** — ${property ? typeReferenceText(propertyTypeReference(property)) + '. ' : ''}Generated value, not a request or form input. ${responseAvailability}`;\n }\n const response = owner?.response;\n if (response?.location.line === lineIndex + 1 && (tokenAt(response.location.column, 'returns') || (response.kind === 'ScalarCommandResponseSyntax' && tokenAt(response.source.location.column, response.source.property)))) {\n const source = response.kind === 'ScalarCommandResponseSyntax' ? owner?.properties.find(property => property.name === response.source.property) : undefined;\n return `**returns**${source ? ` — ${typeReferenceText(propertyTypeReference(source))}` : ' — unnamed record response'}. ${responseAvailability}`;\n }\n if (response?.kind === 'RecordCommandResponseSyntax') {\n const field = response.fields.find(field => field.location.line === lineIndex + 1 && (tokenAt(field.location.column, field.name) || tokenAt(field.source.location.column, field.source.property)));\n if (field) {\n const source = owner?.properties.find(property => property.name === field.source.property);\n const type = field.type ? typeReferenceText(field.type) : source ? typeReferenceText(propertyTypeReference(source)) : 'Unresolved type';\n return `**${field.name}** — ${type}${field.type ? ' (explicit)' : ' (inferred)'} = ${field.source.property}. ${source?.isGenerated ? 'Generated source, not request input. ' : ''}${responseAvailability}`;\n }\n }\n for (const specification of responseAnalysis(lines).specifications.values()) {\n if ((word === 'returns' && specification.thenReturns?.location.line === lineIndex + 1) || (word === 'generated' && specification.when?.generatedValues?.some(value => value.location.line === lineIndex + 1))) return responseAvailability;\n }\n\n const concept = symbols.concepts.find((candidate) => candidate.name === word);\n if (concept) {\n const attributes = concept.attributes.length ? ` ${concept.attributes.join(' ')}` : '';\n const values = concept.enumValues.length\n ? `\\n\\nValues: ${concept.enumValues.map((value, index) => concept.enumNumbers === undefined ? value : `${value} = ${concept.enumNumbers[index]}`).join(', ')}`\n : '';\n const reasons = Object.entries(concept.attributeReasons)\n .map(([attribute, reason]) => `\\n\\n**@${attribute}** — ${reason}`)\n .join('');\n return `\\`\\`\\`screenplay\\nconcept ${concept.name} : ${concept.primitive}${attributes}\\n\\`\\`\\`${reasons}${values}`;\n }\n\n const type = symbols.types.find((candidate) => candidate.name === word);\n if (type) {\n const properties = type.properties\n .map((property) => `${property.name} ${typeReferenceText(propertyTypeReference(property))}`)\n .join('\\n');\n return `\\`\\`\\`screenplay\\ntype ${type.name}\\n${properties}\\n\\`\\`\\``;\n }\n\n const policy = symbols.policies.find((candidate) => candidate.name === word);\n if (policy) {\n const body = policy.requires.length ? policy.requires.join('\\n') : '(custom C#)';\n return `\\`\\`\\`screenplay\\npolicy ${policy.name}\\n${body}\\n\\`\\`\\``;\n }\n\n const event = symbols.events.find((candidate) => candidate.name === word && candidate.line === lineIndex) ??\n symbols.events.filter((candidate) => candidate.name === word)\n .sort((left, right) => (right.generation ?? 1) - (left.generation ?? 1))[0];\n if (event) {\n const properties = event.properties\n .map((property) => `${property.name} ${typeReferenceText(propertyTypeReference(property))}${property.isSubject ? ' subject' : ''}`)\n .join('\\n');\n return `\\`\\`\\`screenplay\\n${event.visibility === 'Public' ? 'public ' : ''}event ${event.name}${event.generation !== undefined ? ` generation ${event.generation}` : ''}${event.origin !== undefined ? ` from ${JSON.stringify(event.origin)}` : ''}\\n${properties}\\n\\`\\`\\``;\n }\n\n const command = symbols.commands.find((candidate) => candidate.name === word);\n if (command && command.properties.length > 0) {\n const properties = command.properties\n .map(\n (property) =>\n `${property.name} ${typeReferenceText(propertyTypeReference(property))}${property.isGenerated ? ' generated' : ''}${property.isIdentifier ? ' identifier' : ''}`,\n )\n .join('\\n');\n return `\\`\\`\\`screenplay\\ncommand ${command.name}\\n${properties}\\n\\`\\`\\`${command.response || command.properties.some(property => property.isGenerated) ? `\\n\\n${responseAvailability}` : ''}`;\n }\n\n // Sub-language keywords take precedence inside their construct.\n const chain = enclosingChain(lines, fences, lineIndex, indentOf(line));\n for (const construct of [line.trim().split(/\\s+/)[0], ...chain]) {\n const subLanguage = getSubLanguage(construct ?? '');\n const doc = subLanguage?.hovers?.[word];\n if (doc) return doc;\n }\n\n if (word === 'reads' && (chain[0] === 'every' || chain[0] === 'at') && chain.includes('reaction')) {\n return '**reads** — Declares a whole view this clock trigger consults: `reads <View>`. Clock triggers take no values, so `by` is unavailable.';\n }\n\n const step = line.trim().match(/^(given|when|then)\\s+(?:no\\s+)?(\\w+)/);\n if (step && step[2] === word && chain[0] === 'specification' && specificationKeywordDocs[word]) {\n return `**${word}** — ${specificationKeywordDocs[word]}`;\n }\n\n if (word === 'id' || word === 'documentation') {\n const source = eventAnalysisSource(lines);\n const inEvent = symbols.events.some(event => directBody(source, fences, event.line, indentOf(source[event.line])).includes(lineIndex));\n const directive = word === 'id' ? /^\\s*id\\s+\"/.test(source[lineIndex]) : /^\\s*documentation\\s*$/.test(source[lineIndex]);\n const supportedOwner = inEvent || (word === 'documentation' && ['module', 'feature', 'slice', 'command', 'readmodel', 'reaction'].includes(chain[0]));\n if (!supportedOwner || !directive || startColumn !== indentOf(line) + 1) return null;\n }\n\n if (word === 'optional' || word === 'generated' || word === 'returns') return null;\n const keywordDoc = keywordDocs[word];\n if (keywordDoc) return `**${word}** — ${keywordDoc}`;\n\n return null;\n}\n"],"mappings":"qjCAqBA,SAAgB,aACZ,EACA,EACA,EACA,EACA,EACA,EACa,CACb,IAAMA,EAASC,EAASC,CAAK,EAC7B,GAAIF,EAAOG,GAAY,OAAO,KAE9B,IAAMC,EAAOF,EAAMC,IAAc,GACjC,GAAIE,EAAY,EAAIC,EAAeF,CAAI,CAAC,CAAC,OAAQ,OAAO,KACxD,IAAIG,EAAW,GACXC,EAAa,GACjB,IAAK,IAAIC,EAAQ,EAAGA,EAAQC,EAAc,EAAG,IACrCN,EAAKK,KAAW,MAAQF,EAAU,IAC7BH,EAAKK,KAAW,KAAO,CAACD,EAAY,EAAW,CAACD,EAChDH,EAAKK,KAAW,KAAO,CAACF,IAAU,EAAa,CAACC,GAE7D,GAAID,GAAYC,EAAY,OAAO,KACnC,IAAMG,EAAWC,GAAoBV,EAAOC,EAAWO,EAAaL,EAAWQ,CAAW,EAC1F,GAAIF,EAAU,OAAOA,EAAS,QAC9B,IAAMG,EAAeC,EAAab,EAAOC,EAAWO,EAAaL,EAAWQ,CAAW,EACvF,GAAIC,EAAc,OAAOA,EACzB,IAAME,EAAcC,EAAiBf,EAAOC,EAAWO,EAAaL,EAAWQ,CAAW,EAC1F,GAAIG,EAAa,OAAOA,EACxB,IAAME,EAAYC,EAAejB,EAAOC,EAAWO,EAAaL,EAAWQ,CAAW,EACtF,GAAIK,EAAW,OAAOA,EACtB,IAAM,SAAW,EAAgB,IAA0B,CACvD,IAAME,EAAQC,GAAU,IAAKA,EAAS,KAAO,KAC7C,OAAOC,IAASC,GAAQb,IAAgBU,GAASf,IAAce,EAAQG,EAAK,QAAUnB,EAAK,MAAMgB,EAAQ,EAAGf,EAAY,CAAC,IAAMkB,CACnI,EACMC,EAASpB,EAAK,OAAOM,EAAc,CAAC,EAC1C,GAA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S,CAAC,EAC/HoF,EAAYjE,IAAS,KAAO,aAAa,KAAKsB,EAAOzC,EAAU,EAAI,wBAAwB,KAAKyC,EAAOzC,EAAU,EAEvH,GAAI,EADmBkF,GAAY/D,IAAS,iBAAmB,CAAC,SAAU,UAAW,QAAS,UAAW,YAAa,UAAU,CAAC,CAAC,SAAS4B,EAAM,EAAE,IAC5H,CAACqC,GAAa7E,IAAgBgB,EAAStB,CAAI,EAAI,EAAG,OAAO,IACpF,CAEA,GAAIkB,IAAS,YAAcA,IAAS,aAAeA,IAAS,UAAW,OAAO,KAC9E,IAAMkE,EAAavC,EAAY3B,GAG/B,OAFIkE,EAAmB,KAAKlE,EAAK,OAAOkE,IAEjC,IACX"}
1
+ {"version":3,"file":"hover-content.js","names":["fences","fenceMap","lines","lineIndex","line","endColumn","withoutComment","inString","inTemplate","index","startColumn","reaction","reactionReferenceAt","application","fixtureHover","exampleHover","sourceHover","eventSourceHover","operation","operationHover","start","column","word","name","before","enclosingChain","indentOf","generationDocs","complianceHeader","complianceBody","doc","attributeDocs","specialCategoryDocs","variable","branch","refusalContext","member","descriptions","detail","symbolsForBuffer","contextVariableDocs","\"$env\"","prefix","followsPropertyType","followsQueryType","source","eventAnalysisSource","subjectPrefix","ownerChain","enclosingHeaders","keywordDocs","chain","ruleContext","namedRuleContext","handlerIntentDocs","symbols","scanDocument","owner","command","property","typeReferenceText","propertyTypeReference","responseAvailability","response","field","type","specification","responseAnalysis","value","concept","candidate","attributes","values","reasons","attribute","reason","properties","policy","body","event","right","left","construct","getSubLanguage","step","specificationKeywordDocs","inEvent","directBody","directive","keywordDoc"],"sources":["../../hover-content.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 { reactionReferenceAt } from './reaction-authoring';\nimport { refusalContext } from './refusal-context';\nimport { namedRuleContext } from './named-rule-context';\nimport { eventSourceHover } from './event-source-authoring';\nimport { exampleHover } from './example-authoring';\nimport { operationHover } from './operation-authoring';\nimport { DocumentSymbols, symbolsForBuffer } from './symbols';\nimport { responseAnalysis, responseAvailability } from './response-analysis';\nimport { enclosingChain, enclosingHeaders, fenceMap, indentOf, withoutComment } from './document-context';\nimport { directBody, propertyTypeReference, scanDocument } from './symbols';\nimport { typeReferenceText } from './TypeReferenceSymbol';\nimport { eventAnalysisSource } from './event-analysis-source';\nimport { getSubLanguage } from './sub-language-registry';\nimport { attributeDocs, contextVariableDocs, handlerIntentDocs, keywordDocs, specialCategoryDocs, specificationKeywordDocs } from './keyword-docs';\n\n// Produces the hover markdown for a word at a position, without any editor\n// dependency — the Monaco service and the VSCode extension share this content.\n// Columns are 1-based, matching both editors' word-at-position APIs.\nexport function hoverContent(\n lines: string[],\n lineIndex: number,\n word: string,\n startColumn: number,\n endColumn: number,\n application?: DocumentSymbols,\n): string | null {\n const fences = fenceMap(lines);\n if (fences[lineIndex]) return null;\n\n const line = lines[lineIndex] ?? '';\n if (endColumn - 1 > withoutComment(line).length) return null;\n let inString = false;\n let inTemplate = false;\n for (let index = 0; index < startColumn - 1; index++) {\n if (line[index] === '\\\\' && inString) index++;\n else if (line[index] === '\"' && !inTemplate) inString = !inString;\n else if (line[index] === '`' && !inString) inTemplate = !inTemplate;\n }\n if (inString || inTemplate) return null;\n const reaction = reactionReferenceAt(lines, lineIndex, startColumn, endColumn, application);\n if (reaction) return reaction.content;\n const fixtureHover = exampleHover(lines, lineIndex, startColumn, endColumn, application);\n if (fixtureHover) return fixtureHover;\n const sourceHover = eventSourceHover(lines, lineIndex, startColumn, endColumn, application);\n if (sourceHover) return sourceHover;\n const operation = operationHover(lines, lineIndex, startColumn, endColumn, application);\n if (operation) return operation;\n const tokenAt = (column: number, name: string): boolean => {\n const start = column + (line[column - 1] === '@' ? 1 : 0);\n return word === name && startColumn === start && endColumn === start + name.length && line.slice(start - 1, endColumn - 1) === name;\n };\n const before = line.charAt(startColumn - 2);\n if (word === 'authorization' && enclosingChain(lines, fences, lineIndex, indentOf(line))[0] === 'purpose') return 'A quoted authorization in law for criminal-offence data (Art. 10).';\n\n if (enclosingChain(lines, fences, lineIndex, indentOf(line))[0] === 'concept' && /^\\s*generate\\b/.test(line)) {\n const generationDocs: Record<string, string> = {\n generate: 'The concept declares how; a command property declares generated. ESM v15 checks fixture shape and guards generated event sources against existing facts.',\n uuid: 'Random UUID v4, 122 random bits; about 3.27 × 10^17 values at 1% collision probability.',\n uuidv7: 'Time-ordered UUID v7, 74 random bits; about 1.95 × 10^10 values at 1% collision probability. Exposes time; not monotonic within a millisecond.',\n ulid: '26 Crockford base32 characters (uppercase by default), 80 random bits; about 1.56 × 10^11 values at 1% collision probability.',\n typeid: 'TypeID 0.3: lowercase UUIDv7 base32 with a 0..63-character prefix. 74 random bits; empty prefix has no separator.',\n nanoid: 'Default 21 characters over 64 symbols: 126 random bits. Custom entropy = size × log2(alphabet size).',\n bytes: '8 × count random bits; base64url, hex or base32 without padding. RFC 4648 unused trailing bits must be zero.',\n prefix: 'Printable ASCII prefix, at most 32 characters. UUID prefixes require a String concept; TypeID uses its own argument.',\n alphabet: 'NanoID only: 2..256 distinct printable ASCII characters.',\n case: 'lower or upper for String UUIDs, ULID, hex/base32 bytes. Never base64url, NanoID or TypeID.',\n pattern: 'Parsed, not yet executable (#616 phase 3).', random: 'Parsed, not yet executable (#616 phase 3).', rule: 'Parsed, not yet executable (#616 phase 3).', sequence: 'Reserved; binding refuses it until #619 is admitted.',\n };\n if (generationDocs[word]) return generationDocs[word];\n }\n\n const complianceHeader = /^\\s*concept\\s+[^\\s:]+\\s*:\\s*\\w+\\s+/.exec(line);\n const complianceBody = enclosingChain(lines, fences, lineIndex, indentOf(line))[0] === 'concept' && /^\\s*(?:@?pii|personal|@?sensitive|secret)\\s+(?:reason|scope|special|criminal)\\b/.test(line);\n if ((complianceHeader !== null && startColumn - 1 >= complianceHeader[0].length - 1) || complianceBody) {\n const doc = attributeDocs[word];\n if (doc) return doc;\n if (Object.hasOwn(specialCategoryDocs, word) && /^\\s*(?:@?pii|personal)\\s+special\\s+/.test(line)) return `**${word}** — ${specialCategoryDocs[word]}`;\n if (word === 'special') return 'GDPR Art. 9(1) special category; requires pii. At most one category per concept.';\n if (word === 'criminal') return 'Personal data relating to criminal convictions and offenses (GDPR Art. 10); requires pii.';\n if (/^\\s*(?:secret|sensitive|@sensitive)\\s+scope\\s+/.test(line) && ['subject', 'namespace', 'global'].includes(word)) return `**${word}** — Secret encryption scope${word === 'subject' ? ' per data subject' : word === 'namespace' ? ' per tenant namespace' : ' shared globally'}. Not an event-property subject role.`;\n if (word === 'scope') return 'Secret encryption scope: subject, namespace or global. Omitted scope keeps Chronicle’s Subject default; pii secret renders only [PII].';\n }\n if (before === '$' || before === '.') {\n const variable = line.substring(0, endColumn - 1).match(/\\$[\\w.]*$/)?.[0];\n if (variable) {\n if (variable.startsWith('$refusal')) {\n const branch = refusalContext(lines, lineIndex, indentOf(line));\n const member = variable.substring('$refusal.'.length);\n const descriptions: Record<string, string> = { reason: 'Refusal kind as a String: validation, constraint or authorization.', message: 'Rejection details verbatim, including unresolved $strings keys.', constraint: 'Violated constraint name as a String, only in a by constraint branch.' };\n return branch !== undefined && descriptions[member] !== undefined ? `**${variable}** — ${descriptions[member]} Syntax-only, not yet executable (PLAY0268).` : null;\n }\n if (variable.startsWith('$identity.')) {\n const name = variable.substring('$identity.'.length).split('.')[0];\n const detail = symbolsForBuffer(lines, application).identityDetails?.find(detail => detail.name === name);\n if (detail) return `**$identity.${detail.name}** — ${detail.type}. Declared caller detail; authoring metadata only, not executable until admitted (#600).`;\n }\n const doc =\n contextVariableDocs[variable] ??\n (variable.startsWith('$env') ? contextVariableDocs['$env'] : undefined);\n if (doc) return doc;\n }\n }\n\n // Do not mistake a property/type named optional for the contextual modifier.\n const prefix = line.slice(0, startColumn - 1);\n // Commit to query-parameter context before matching the name and type.\n const followsPropertyType = /^\\s*(?:by|filter)\\s+/.test(prefix)\n ? /^\\s*(?:by|filter)\\s+[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+$/.test(prefix)\n : /^\\s*@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+$/.test(prefix);\n const followsQueryType = /^\\s*query\\s+\\w+\\s*=>\\s*(?:observable\\s+)?[\\w.]+(?:\\[\\])?\\s+$/.test(prefix) &&\n !/^\\s*query\\s+\\w+\\s*=>\\s*observable\\s+$/.test(prefix);\n if (word === 'subject') {\n const source = eventAnalysisSource(lines);\n const subjectPrefix = /^\\s*@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?(?:\\s+generated)?(?:\\s+identifier)?\\s+$/.test(prefix);\n const ownerChain = enclosingChain(source, fences, lineIndex, indentOf(line));\n if (subjectPrefix && (ownerChain[0] === 'event' || /^produces\\s+event\\s+/.test(enclosingHeaders(source, fences, lineIndex, indentOf(line))[0] ?? ''))) {\n return '**subject** — This event property identifies its one data subject instead of the event source (decision 0008). Required scalar String, Uuid or their concepts, or an Int-backed concept; never pii or secret. Report-only lineage metadata (PLAY0270); no ESM bytes or provider output yet.';\n }\n if (/\\bclaim\\s+\"(?:[^\"\\\\]|\\\\.)*\"\\s+matches\\s+$/.test(prefix) && ownerChain.includes('policy')) return `**subject** — ${keywordDocs.subject}`;\n return null;\n }\n if (word === 'optional' && (followsPropertyType || followsQueryType)) {\n return `**optional** — ${keywordDocs.optional}`;\n }\n\n if (word === 'implementation' || word === 'hint') {\n const chain = enclosingChain(lines, fences, lineIndex, indentOf(line));\n const ruleContext = namedRuleContext(lines, lineIndex, indentOf(line));\n if ((word === 'implementation' && ruleContext === 'rule' && /^\\s*implementation\\s*$/.test(withoutComment(line))) ||\n (word === 'hint' && ruleContext === 'implementation' && /^\\s*hint\\s+\"/.test(line))) {\n return `**${word}** — Command named-rule guidance with at most one file or tagged fence. No payload means pending and fails binding (PLAY0268). Attached predicates keep their existing pure RuleContext contract; reference execution is unsupported, never confirmation.`;\n }\n if (word === 'implementation' && chain[0] === 'handler' && /^\\s*implementation\\s*$/.test(withoutComment(line))) {\n return `**implementation** — ${handlerIntentDocs.implementation}`;\n }\n if (word === 'hint' && chain[0] === 'implementation' && chain[1] === 'handler' && /^\\s*hint\\s+\"/.test(line)) {\n return `**hint** — ${handlerIntentDocs.hint}`;\n }\n }\n\n const symbols = scanDocument(lines);\n const owner = symbols.commands.filter(command => command.line < lineIndex).at(-1);\n const property = owner?.properties.find(property => property.name === word && property.line === lineIndex);\n if (property?.isGenerated || (word === 'generated' && owner?.properties.some(property => property.isGenerated && property.line === lineIndex) && followsPropertyType)) {\n return `**${property?.name ?? 'generated'}** — ${property ? typeReferenceText(propertyTypeReference(property)) + '. ' : ''}Generated value, not a request or form input. ${responseAvailability}`;\n }\n const response = owner?.response;\n if (response?.location.line === lineIndex + 1 && (tokenAt(response.location.column, 'returns') || (response.kind === 'ScalarCommandResponseSyntax' && tokenAt(response.source.location.column, response.source.property)))) {\n const source = response.kind === 'ScalarCommandResponseSyntax' ? owner?.properties.find(property => property.name === response.source.property) : undefined;\n return `**returns**${source ? ` — ${typeReferenceText(propertyTypeReference(source))}` : ' — unnamed record response'}. ${responseAvailability}`;\n }\n if (response?.kind === 'RecordCommandResponseSyntax') {\n const field = response.fields.find(field => field.location.line === lineIndex + 1 && (tokenAt(field.location.column, field.name) || tokenAt(field.source.location.column, field.source.property)));\n if (field) {\n const source = owner?.properties.find(property => property.name === field.source.property);\n const type = field.type ? typeReferenceText(field.type) : source ? typeReferenceText(propertyTypeReference(source)) : 'Unresolved type';\n return `**${field.name}** — ${type}${field.type ? ' (explicit)' : ' (inferred)'} = ${field.source.property}. ${source?.isGenerated ? 'Generated source, not request input. ' : ''}${responseAvailability}`;\n }\n }\n for (const specification of responseAnalysis(lines).specifications.values()) {\n if ((word === 'returns' && specification.thenReturns?.location.line === lineIndex + 1) || (word === 'generated' && specification.when?.generatedValues?.some(value => value.location.line === lineIndex + 1))) return responseAvailability;\n }\n\n const concept = symbols.concepts.find((candidate) => candidate.name === word);\n if (concept) {\n const attributes = concept.attributes.length ? ` ${concept.attributes.join(' ')}` : '';\n const values = concept.enumValues.length\n ? `\\n\\nValues: ${concept.enumValues.map((value, index) => concept.enumNumbers === undefined ? value : `${value} = ${concept.enumNumbers[index]}`).join(', ')}`\n : '';\n const reasons = Object.entries(concept.attributeReasons)\n .map(([attribute, reason]) => `\\n\\n**@${attribute}** — ${reason}`)\n .join('');\n return `\\`\\`\\`screenplay\\nconcept ${concept.name} : ${concept.primitive}${attributes}\\n\\`\\`\\`${reasons}${values}`;\n }\n\n const type = symbols.types.find((candidate) => candidate.name === word);\n if (type) {\n const properties = type.properties\n .map((property) => `${property.name} ${typeReferenceText(propertyTypeReference(property))}`)\n .join('\\n');\n return `\\`\\`\\`screenplay\\ntype ${type.name}\\n${properties}\\n\\`\\`\\``;\n }\n\n const policy = symbols.policies.find((candidate) => candidate.name === word);\n if (policy) {\n const body = policy.requires.length ? policy.requires.join('\\n') : '(custom C#)';\n return `\\`\\`\\`screenplay\\npolicy ${policy.name}\\n${body}\\n\\`\\`\\``;\n }\n\n const event = symbols.events.find((candidate) => candidate.name === word && candidate.line === lineIndex) ??\n symbols.events.filter((candidate) => candidate.name === word)\n .sort((left, right) => (right.generation ?? 1) - (left.generation ?? 1))[0];\n if (event) {\n const properties = event.properties\n .map((property) => `${property.name} ${typeReferenceText(propertyTypeReference(property))}${property.isSubject ? ' subject' : ''}`)\n .join('\\n');\n return `\\`\\`\\`screenplay\\n${event.visibility === 'Public' ? 'public ' : ''}event ${event.name}${event.generation !== undefined ? ` generation ${event.generation}` : ''}${event.origin !== undefined ? ` from ${JSON.stringify(event.origin)}` : ''}\\n${properties}\\n\\`\\`\\``;\n }\n\n const command = symbols.commands.find((candidate) => candidate.name === word);\n if (command && command.properties.length > 0) {\n const properties = command.properties\n .map(\n (property) =>\n `${property.name} ${typeReferenceText(propertyTypeReference(property))}${property.isGenerated ? ' generated' : ''}${property.isIdentifier ? ' identifier' : ''}`,\n )\n .join('\\n');\n return `\\`\\`\\`screenplay\\ncommand ${command.name}\\n${properties}\\n\\`\\`\\`${command.response || command.properties.some(property => property.isGenerated) ? `\\n\\n${responseAvailability}` : ''}`;\n }\n\n // Sub-language keywords take precedence inside their construct.\n const chain = enclosingChain(lines, fences, lineIndex, indentOf(line));\n for (const construct of [line.trim().split(/\\s+/)[0], ...chain]) {\n const subLanguage = getSubLanguage(construct ?? '');\n const doc = subLanguage?.hovers?.[word];\n if (doc) return doc;\n }\n\n if (word === 'reads' && (chain[0] === 'every' || chain[0] === 'at') && chain.includes('reaction')) {\n return '**reads** — Declares a whole view this clock trigger consults: `reads <View>`. Clock triggers take no values, so `by` is unavailable.';\n }\n\n const step = line.trim().match(/^(given|when|then)\\s+(?:no\\s+)?(\\w+)/);\n if (step && step[2] === word && chain[0] === 'specification' && specificationKeywordDocs[word]) {\n return `**${word}** — ${specificationKeywordDocs[word]}`;\n }\n\n if (word === 'id' || word === 'documentation') {\n const source = eventAnalysisSource(lines);\n const inEvent = symbols.events.some(event => directBody(source, fences, event.line, indentOf(source[event.line])).includes(lineIndex));\n const directive = word === 'id' ? /^\\s*id\\s+\"/.test(source[lineIndex]) : /^\\s*documentation\\s*$/.test(source[lineIndex]);\n const supportedOwner = inEvent || (word === 'documentation' && ['module', 'feature', 'slice', 'command', 'readmodel', 'reaction'].includes(chain[0]));\n if (!supportedOwner || !directive || startColumn !== indentOf(line) + 1) return null;\n }\n\n if (word === 'optional' || word === 'generated' || word === 'returns') return null;\n const keywordDoc = keywordDocs[word];\n if (keywordDoc) return `**${word}** — ${keywordDoc}`;\n\n return null;\n}\n"],"mappings":"ojCAqBA,SAAgB,aACZ,EACA,EACA,EACA,EACA,EACA,EACa,CACb,IAAMA,EAASC,EAASC,CAAK,EAC7B,GAAIF,EAAOG,GAAY,OAAO,KAE9B,IAAMC,EAAOF,EAAMC,IAAc,GACjC,GAAIE,EAAY,EAAIC,EAAeF,CAAI,CAAC,CAAC,OAAQ,OAAO,KACxD,IAAIG,EAAW,GACXC,EAAa,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F,EAAYlE,IAAS,KAAO,aAAa,KAAKuB,EAAO1C,EAAU,EAAI,wBAAwB,KAAK0C,EAAO1C,EAAU,EAEvH,GAAI,EADmBmF,GAAYhE,IAAS,iBAAmB,CAAC,SAAU,UAAW,QAAS,UAAW,YAAa,UAAU,CAAC,CAAC,SAAS6B,EAAM,EAAE,IAC5H,CAACqC,GAAa9E,IAAgBgB,EAAStB,CAAI,EAAI,EAAG,OAAO,IACpF,CAEA,GAAIkB,IAAS,YAAcA,IAAS,aAAeA,IAAS,UAAW,OAAO,KAC9E,IAAMmE,EAAavC,EAAY5B,GAG/B,OAFImE,EAAmB,KAAKnE,EAAK,OAAOmE,IAEjC,IACX"}
@@ -1,2 +1,2 @@
1
- import"./_virtual/_virtual/_rolldown/runtime.js";import{primitiveTypes as e}from"./language.js";import{typeReferenceText as t}from"./TypeReferenceSymbol.js";import{enclosingChain as n,fenceMap as r,indentOf as i,nearestEnclosingLine as a,withoutComment as o}from"./document-context.js";import{optionalTypeItems as s}from"./completion-items.js";import{responseAnalysis as c,responseAvailability as l}from"./response-analysis.js";import{propertyTypeReference as u,scanDocument as d}from"./symbols.js";function responseCompletions(f,p,m,h){let g=r(f);if(g[p]||o(m).length<m.length)return null;let _=m.trim()===``?m.length:i(f[p]),v=n(f,g,p,_),y=a(f,g,p,_),namedCommand=e=>{let t=h.commands.filter(t=>t.name===e);return t.length===1?t[0]:void 0},entry=(e,n=e.name)=>({label:e.name,insertText:n,documentation:`${t(u(e))}${e.isGenerated?` — generated, not request/form input`:``}. ${l}`});if(v.includes(`command`)){let t=d(f).commands.filter(e=>e.line<p).at(-1);if(!t)return null;if(v[0]===`command`){if(/^\s*returns\s+@?\w*$/.test(m))return!/returns\s+@/.test(m)&&t.properties.some(e=>e.name===`returns`&&e.line===p)?null:t.properties.map(e=>entry(e,`${/returns\s+@/.test(m)?``:`@`}${e.name}`));let e=m.match(/^\s*@?[a-z_]\w*\s+([\w.]+)\s+(\w*)$/);if(e&&[`generated`,`identifier`].some(t=>t.startsWith(e[2]))&&h.concepts.find(t=>t.name===e[1])?.primitive===`Uuid`)return[...`optional`.startsWith(e[2])?s:[],{label:`generated`,insertText:`generated`,documentation:`Required scalar Uuid concept with no validation rules; not a request/form input. ${l}`},{label:`generated identifier`,insertText:`generated identifier`,documentation:`Specification fixture uses an indented for value. ${l}`},{label:`identifier`,insertText:`identifier`,documentation:`Names the event source identifier.`}];if(/^\s*@?[a-z_]\w*\s+[\w.]+\s+generated\s+\w*$/.test(m))return[{label:`identifier`,insertText:`identifier`,documentation:l}]}if(v[0]===`returns`)return/=\s*@?\w*$/.test(m)?t.properties.map(e=>entry(e)):/^\s*@?[a-z_]\w*\s+[\w.]*$/.test(m)?[...h.concepts.map(e=>e.name),...h.types.map(e=>e.name),...e].map(e=>({label:e,insertText:e,documentation:`Explicit response type must exactly match the source. ${l}`})):t.properties.map(e=>entry(e,`${e.name} = ${e.name}`))}if(v[0]===`form`&&y&&(/^\s*field\s+\w*$/.test(m)||m.trim()===``)){let e=namedCommand(y.match(/\bfor\s+([\w.]+)$/)?.[1]);if(e)return e.properties.filter(e=>!e.isGenerated).map(e=>entry(e,m.trim()===``?`field ${e.name}`:e.name))}if(v.includes(`specification`)){if(v[0]===`when`&&y){let e=y.match(/^when\s+([\w.]+)$/)?.[1],t=namedCommand(e);if(!t)return null;if(/^\s*generated\s+\w*$/.test(m))return t.properties.filter(e=>e.isGenerated&&!e.isIdentifier).map(e=>entry(e,`${e.name} = "\${1:uuid}"`));if(m.trim()===``)return[...t.properties.filter(e=>!e.isGenerated).map(e=>entry(e,`${e.name} = \${1:value}`)),...t.properties.filter(e=>e.isGenerated&&!e.isIdentifier).map(e=>({...entry(e,`generated ${e.name} = "\${1:uuid}"`),label:`generated ${e.name}`})),...t.properties.some(e=>e.isGenerated&&e.isIdentifier)?[{label:`for`,insertText:'for "${1:uuid}"',documentation:`Generated identifier fixture, not request input. ${l}`}]:[]]}if(v[0]===`then`&&/^then\s+returns$/.test(y??``)){let e=namedCommand([...c(f).specifications.values()].filter(e=>e.location.line-1<p).at(-1)?.when?.commandType);if(e?.response?.kind===`RecordCommandResponseSyntax`){let n=new Map(e.properties.map(e=>[e.name,e]));return e.response.fields.map(e=>{let r=n.get(e.source.property),i=e.type??(r?u(r):void 0);return{label:e.name,insertText:`${e.name} = \${1:value}`,documentation:`${i?t(i):`Unresolved type`}. ${l}`}})}}}return null}export{responseCompletions};
1
+ import"./_virtual/_virtual/_rolldown/runtime.js";import{primitiveTypes as e}from"./language.js";import{typeReferenceText as t}from"./TypeReferenceSymbol.js";import{enclosingChain as n,fenceMap as r,indentOf as i,nearestEnclosingLine as a,withoutComment as o}from"./document-context.js";import{optionalTypeItems as s}from"./completion-items.js";import{responseAnalysis as c,responseAvailability as l}from"./response-analysis.js";import{propertyTypeReference as u,scanDocument as d}from"./symbols.js";function responseCompletions(f,p,m,h){let g=r(f);if(g[p]||o(m).length<m.length)return null;let _=m.trim()===``?m.length:i(f[p]),v=n(f,g,p,_),y=a(f,g,p,_),namedCommand=e=>{let t=h.commands.filter(t=>t.name===e);return t.length===1?t[0]:void 0},fixtureName=e=>h.concepts.find(t=>t.name===u(e).name)?.primitive===`String`?`generated-value`:`uuid`,entry=(e,n=e.name)=>({label:e.name,insertText:n,documentation:`${t(u(e))}${e.isGenerated?` — generated, not request/form input`:``}. ${l}`});if(v.includes(`command`)){let t=d(f).commands.filter(e=>e.line<p).at(-1);if(!t)return null;if(v[0]===`command`){if(/^\s*returns\s+@?\w*$/.test(m))return!/returns\s+@/.test(m)&&t.properties.some(e=>e.name===`returns`&&e.line===p)?null:t.properties.map(e=>entry(e,`${/returns\s+@/.test(m)?``:`@`}${e.name}`));let e=m.match(/^\s*@?[a-z_]\w*\s+([\w.]+)\s+(\w*)$/);if(e&&[`generated`,`identifier`].some(t=>t.startsWith(e[2]))){let t=h.concepts.find(t=>t.name===e[1]);if(t?.primitive===`Uuid`||t?.primitive===`String`&&t.generationStrategy!==void 0)return[...`optional`.startsWith(e[2])?s:[],{label:`generated`,insertText:`generated`,documentation:`Required scalar generatable concept without validation rules; not a request/form input. ${l}`},{label:`generated identifier`,insertText:`generated identifier`,documentation:`Specification fixture uses an indented for value. ${l}`},{label:`identifier`,insertText:`identifier`,documentation:`Names the event source identifier.`}]}if(/^\s*@?[a-z_]\w*\s+[\w.]+\s+generated\s+\w*$/.test(m))return[{label:`identifier`,insertText:`identifier`,documentation:l}]}if(v[0]===`returns`)return/=\s*@?\w*$/.test(m)?t.properties.map(e=>entry(e)):/^\s*@?[a-z_]\w*\s+[\w.]*$/.test(m)?[...h.concepts.map(e=>e.name),...h.types.map(e=>e.name),...e].map(e=>({label:e,insertText:e,documentation:`Explicit response type must exactly match the source. ${l}`})):t.properties.map(e=>entry(e,`${e.name} = ${e.name}`))}if(v[0]===`form`&&y&&(/^\s*field\s+\w*$/.test(m)||m.trim()===``)){let e=namedCommand(y.match(/\bfor\s+([\w.]+)$/)?.[1]);if(e)return e.properties.filter(e=>!e.isGenerated).map(e=>entry(e,m.trim()===``?`field ${e.name}`:e.name))}if(v.includes(`specification`)){if(v[0]===`when`&&y){let e=y.match(/^when\s+([\w.]+)$/)?.[1],t=namedCommand(e);if(!t)return null;if(/^\s*generated\s+\w*$/.test(m))return t.properties.filter(e=>e.isGenerated&&!e.isIdentifier).map(e=>entry(e,`${e.name} = "\${1:${fixtureName(e)}}"`));if(m.trim()===``)return[...t.properties.filter(e=>!e.isGenerated).map(e=>entry(e,`${e.name} = \${1:value}`)),...t.properties.filter(e=>e.isGenerated&&!e.isIdentifier).map(e=>({...entry(e,`generated ${e.name} = "\${1:${fixtureName(e)}}"`),label:`generated ${e.name}`})),...t.properties.some(e=>e.isGenerated&&e.isIdentifier)?[{label:`for`,insertText:`for "\${1:${fixtureName(t.properties.find(e=>e.isGenerated&&e.isIdentifier))}}"`,documentation:`Generated identifier fixture, not request input. ${l}`}]:[]]}if(v[0]===`then`&&/^then\s+returns$/.test(y??``)){let e=namedCommand([...c(f).specifications.values()].filter(e=>e.location.line-1<p).at(-1)?.when?.commandType);if(e?.response?.kind===`RecordCommandResponseSyntax`){let n=new Map(e.properties.map(e=>[e.name,e]));return e.response.fields.map(e=>{let r=n.get(e.source.property),i=e.type??(r?u(r):void 0);return{label:e.name,insertText:`${e.name} = \${1:value}`,documentation:`${i?t(i):`Unresolved type`}. ${l}`}})}}}return null}export{responseCompletions};
2
2
  //# sourceMappingURL=response-completions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"response-completions.js","names":["fences","fenceMap","lines","line","withoutComment","before","indent","indentOf","chain","enclosingChain","enclosing","nearestEnclosingLine","matches","symbols","command","name","property","typeReferenceText","propertyTypeReference","responseAvailability","scanDocument","modifier","word","concept","optionalTypeItems","type","primitiveTypes","responseAnalysis","specification","properties","source","field"],"sources":["../../response-completions.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 { enclosingChain, fenceMap, indentOf, nearestEnclosingLine, withoutComment } from './document-context';\nimport { CompletionEntry, optionalTypeItems } from './completion-items';\nimport { DocumentSymbols, PropertySymbol, propertyTypeReference, scanDocument } from './symbols';\nimport { typeReferenceText } from './TypeReferenceSymbol';\nimport { responseAvailability, responseAnalysis } from './response-analysis';\nimport { primitiveTypes } from './language';\n\nexport function responseCompletions(lines: string[], line: number, before: string, symbols: DocumentSymbols): CompletionEntry[] | null {\n const fences = fenceMap(lines);\n if (fences[line] || withoutComment(before).length < before.length) return null;\n const indent = before.trim() === '' ? before.length : indentOf(lines[line]);\n const chain = enclosingChain(lines, fences, line, indent);\n const enclosing = nearestEnclosingLine(lines, fences, line, indent);\n const namedCommand = (name: string | undefined) => {\n const matches = symbols.commands.filter(command => command.name === name);\n return matches.length === 1 ? matches[0] : undefined;\n };\n const entry = (property: PropertySymbol, insertText = property.name): CompletionEntry => ({\n label: property.name, insertText,\n documentation: `${typeReferenceText(propertyTypeReference(property))}${property.isGenerated ? ' — generated, not request/form input' : ''}. ${responseAvailability}`,\n });\n if (chain.includes('command')) {\n // Merged symbol line offsets belong to different documents. Only the current (possibly\n // unsaved) source can own the cursor; application symbols are for external lookup.\n const command = scanDocument(lines).commands.filter(command => command.line < line).at(-1);\n if (!command) return null;\n if (chain[0] === 'command') {\n if (/^\\s*returns\\s+@?\\w*$/.test(before)) {\n if (!/returns\\s+@/.test(before) && command.properties.some(property => property.name === 'returns' && property.line === line)) return null;\n return command.properties.map(property => entry(property, `${/returns\\s+@/.test(before) ? '' : '@'}${property.name}`));\n }\n const modifier = before.match(/^\\s*@?[a-z_]\\w*\\s+([\\w.]+)\\s+(\\w*)$/);\n if (modifier && ['generated', 'identifier'].some(word => word.startsWith(modifier[2]))) {\n const concept = symbols.concepts.find(concept => concept.name === modifier[1]);\n if (concept?.primitive === 'Uuid') return [\n ...('optional'.startsWith(modifier[2]) ? optionalTypeItems : []),\n { label: 'generated', insertText: 'generated', documentation: `Required scalar Uuid concept with no validation rules; not a request/form input. ${responseAvailability}` },\n { label: 'generated identifier', insertText: 'generated identifier', documentation: `Specification fixture uses an indented for value. ${responseAvailability}` },\n { label: 'identifier', insertText: 'identifier', documentation: 'Names the event source identifier.' },\n ];\n }\n if (/^\\s*@?[a-z_]\\w*\\s+[\\w.]+\\s+generated\\s+\\w*$/.test(before)) return [{ label: 'identifier', insertText: 'identifier', documentation: responseAvailability }];\n }\n if (chain[0] === 'returns') {\n if (/=\\s*@?\\w*$/.test(before)) return command.properties.map(property => entry(property));\n if (/^\\s*@?[a-z_]\\w*\\s+[\\w.]*$/.test(before)) return [...symbols.concepts.map(concept => concept.name), ...symbols.types.map(type => type.name), ...primitiveTypes].map(name => ({ label: name, insertText: name, documentation: `Explicit response type must exactly match the source. ${responseAvailability}` }));\n return command.properties.map(property => entry(property, `${property.name} = ${property.name}`));\n }\n }\n if (chain[0] === 'form' && enclosing && (/^\\s*field\\s+\\w*$/.test(before) || before.trim() === '')) {\n const command = namedCommand(enclosing.match(/\\bfor\\s+([\\w.]+)$/)?.[1]);\n if (command) return command.properties.filter(property => !property.isGenerated).map(property => entry(property, before.trim() === '' ? `field ${property.name}` : property.name));\n }\n if (chain.includes('specification')) {\n if (chain[0] === 'when' && enclosing) {\n const name = enclosing.match(/^when\\s+([\\w.]+)$/)?.[1];\n const command = namedCommand(name);\n if (!command) return null;\n if (/^\\s*generated\\s+\\w*$/.test(before)) return command.properties.filter(property => property.isGenerated && !property.isIdentifier).map(property => entry(property, `${property.name} = \"\\${1:uuid}\"`));\n if (before.trim() === '') return [\n ...command.properties.filter(property => !property.isGenerated).map(property => entry(property, `${property.name} = \\${1:value}`)),\n ...command.properties.filter(property => property.isGenerated && !property.isIdentifier).map(property => ({ ...entry(property, `generated ${property.name} = \"\\${1:uuid}\"`), label: `generated ${property.name}` })),\n ...(command.properties.some(property => property.isGenerated && property.isIdentifier) ? [{ label: 'for', insertText: 'for \"${1:uuid}\"', documentation: `Generated identifier fixture, not request input. ${responseAvailability}` }] : []),\n ];\n }\n if (chain[0] === 'then' && /^then\\s+returns$/.test(enclosing ?? '')) {\n const specification = [...responseAnalysis(lines).specifications.values()].filter(specification => specification.location.line - 1 < line).at(-1);\n const command = namedCommand(specification?.when?.commandType);\n if (command?.response?.kind === 'RecordCommandResponseSyntax') {\n const properties = new Map(command.properties.map(property => [property.name, property]));\n return command.response.fields.map(field => {\n const source = properties.get(field.source.property);\n const type = field.type ?? (source ? propertyTypeReference(source) : undefined);\n return { label: field.name, insertText: `${field.name} = \\${1:value}`, documentation: `${type ? typeReferenceText(type) : 'Unresolved type'}. ${responseAvailability}` };\n });\n }\n }\n }\n return null;\n}\n"],"mappings":"mfAUA,SAAgB,oBAAoB,EAAiB,EAAc,EAAgB,EAAoD,CACnI,IAAMA,EAASC,EAASC,CAAK,EAC7B,GAAIF,EAAOG,IAASC,EAAeC,CAAM,CAAC,CAAC,OAASA,EAAO,OAAQ,OAAO,KAC1E,IAAMC,EAASD,EAAO,KAAK,IAAM,GAAKA,EAAO,OAASE,EAASL,EAAMC,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AM,WAAY,GAAGA,EAAM,KAAK,gBAAiB,cAAe,GAAGN,EAAOR,EAAkBQ,CAAI,EAAI,kBAAkB,IAAIN,GAAuB,CAC3K,CAAC,CACL,CACJ,CACJ,CACA,OAAO,IACX"}
1
+ {"version":3,"file":"response-completions.js","names":["fences","fenceMap","lines","line","withoutComment","before","indent","indentOf","chain","enclosingChain","enclosing","nearestEnclosingLine","matches","symbols","command","name","concept","propertyTypeReference","property","typeReferenceText","responseAvailability","scanDocument","modifier","word","optionalTypeItems","type","primitiveTypes","responseAnalysis","specification","properties","source","field"],"sources":["../../response-completions.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 { enclosingChain, fenceMap, indentOf, nearestEnclosingLine, withoutComment } from './document-context';\nimport { CompletionEntry, optionalTypeItems } from './completion-items';\nimport { DocumentSymbols, PropertySymbol, propertyTypeReference, scanDocument } from './symbols';\nimport { typeReferenceText } from './TypeReferenceSymbol';\nimport { responseAvailability, responseAnalysis } from './response-analysis';\nimport { primitiveTypes } from './language';\n\nexport function responseCompletions(lines: string[], line: number, before: string, symbols: DocumentSymbols): CompletionEntry[] | null {\n const fences = fenceMap(lines);\n if (fences[line] || withoutComment(before).length < before.length) return null;\n const indent = before.trim() === '' ? before.length : indentOf(lines[line]);\n const chain = enclosingChain(lines, fences, line, indent);\n const enclosing = nearestEnclosingLine(lines, fences, line, indent);\n const namedCommand = (name: string | undefined) => {\n const matches = symbols.commands.filter(command => command.name === name);\n return matches.length === 1 ? matches[0] : undefined;\n };\n const fixtureName = (property: PropertySymbol): string => symbols.concepts.find(concept => concept.name === propertyTypeReference(property).name)?.primitive === 'String' ? 'generated-value' : 'uuid';\n const entry = (property: PropertySymbol, insertText = property.name): CompletionEntry => ({\n label: property.name, insertText,\n documentation: `${typeReferenceText(propertyTypeReference(property))}${property.isGenerated ? ' — generated, not request/form input' : ''}. ${responseAvailability}`,\n });\n if (chain.includes('command')) {\n // Merged symbol line offsets belong to different documents. Only the current (possibly\n // unsaved) source can own the cursor; application symbols are for external lookup.\n const command = scanDocument(lines).commands.filter(command => command.line < line).at(-1);\n if (!command) return null;\n if (chain[0] === 'command') {\n if (/^\\s*returns\\s+@?\\w*$/.test(before)) {\n if (!/returns\\s+@/.test(before) && command.properties.some(property => property.name === 'returns' && property.line === line)) return null;\n return command.properties.map(property => entry(property, `${/returns\\s+@/.test(before) ? '' : '@'}${property.name}`));\n }\n const modifier = before.match(/^\\s*@?[a-z_]\\w*\\s+([\\w.]+)\\s+(\\w*)$/);\n if (modifier && ['generated', 'identifier'].some(word => word.startsWith(modifier[2]))) {\n const concept = symbols.concepts.find(concept => concept.name === modifier[1]);\n if (concept?.primitive === 'Uuid' || (concept?.primitive === 'String' && concept.generationStrategy !== undefined)) return [\n ...('optional'.startsWith(modifier[2]) ? optionalTypeItems : []),\n { label: 'generated', insertText: 'generated', documentation: `Required scalar generatable concept without validation rules; not a request/form input. ${responseAvailability}` },\n { label: 'generated identifier', insertText: 'generated identifier', documentation: `Specification fixture uses an indented for value. ${responseAvailability}` },\n { label: 'identifier', insertText: 'identifier', documentation: 'Names the event source identifier.' },\n ];\n }\n if (/^\\s*@?[a-z_]\\w*\\s+[\\w.]+\\s+generated\\s+\\w*$/.test(before)) return [{ label: 'identifier', insertText: 'identifier', documentation: responseAvailability }];\n }\n if (chain[0] === 'returns') {\n if (/=\\s*@?\\w*$/.test(before)) return command.properties.map(property => entry(property));\n if (/^\\s*@?[a-z_]\\w*\\s+[\\w.]*$/.test(before)) return [...symbols.concepts.map(concept => concept.name), ...symbols.types.map(type => type.name), ...primitiveTypes].map(name => ({ label: name, insertText: name, documentation: `Explicit response type must exactly match the source. ${responseAvailability}` }));\n return command.properties.map(property => entry(property, `${property.name} = ${property.name}`));\n }\n }\n if (chain[0] === 'form' && enclosing && (/^\\s*field\\s+\\w*$/.test(before) || before.trim() === '')) {\n const command = namedCommand(enclosing.match(/\\bfor\\s+([\\w.]+)$/)?.[1]);\n if (command) return command.properties.filter(property => !property.isGenerated).map(property => entry(property, before.trim() === '' ? `field ${property.name}` : property.name));\n }\n if (chain.includes('specification')) {\n if (chain[0] === 'when' && enclosing) {\n const name = enclosing.match(/^when\\s+([\\w.]+)$/)?.[1];\n const command = namedCommand(name);\n if (!command) return null;\n if (/^\\s*generated\\s+\\w*$/.test(before)) return command.properties.filter(property => property.isGenerated && !property.isIdentifier).map(property => entry(property, `${property.name} = \"\\${1:${fixtureName(property)}}\"`));\n if (before.trim() === '') return [\n ...command.properties.filter(property => !property.isGenerated).map(property => entry(property, `${property.name} = \\${1:value}`)),\n ...command.properties.filter(property => property.isGenerated && !property.isIdentifier).map(property => ({ ...entry(property, `generated ${property.name} = \"\\${1:${fixtureName(property)}}\"`), label: `generated ${property.name}` })),\n ...(command.properties.some(property => property.isGenerated && property.isIdentifier) ? [{ label: 'for', insertText: `for \"\\${1:${fixtureName(command.properties.find(property => property.isGenerated && property.isIdentifier)!)}}\"`, documentation: `Generated identifier fixture, not request input. ${responseAvailability}` }] : []),\n ];\n }\n if (chain[0] === 'then' && /^then\\s+returns$/.test(enclosing ?? '')) {\n const specification = [...responseAnalysis(lines).specifications.values()].filter(specification => specification.location.line - 1 < line).at(-1);\n const command = namedCommand(specification?.when?.commandType);\n if (command?.response?.kind === 'RecordCommandResponseSyntax') {\n const properties = new Map(command.properties.map(property => [property.name, property]));\n return command.response.fields.map(field => {\n const source = properties.get(field.source.property);\n const type = field.type ?? (source ? propertyTypeReference(source) : undefined);\n return { label: field.name, insertText: `${field.name} = \\${1:value}`, documentation: `${type ? typeReferenceText(type) : 'Unresolved type'}. ${responseAvailability}` };\n });\n }\n }\n }\n return null;\n}\n"],"mappings":"mfAUA,SAAgB,oBAAoB,EAAiB,EAAc,EAAgB,EAAoD,CACnI,IAAMA,EAASC,EAASC,CAAK,EAC7B,GAAIF,EAAOG,IAASC,EAAeC,CAAM,CAAC,CAAC,OAASA,EAAO,OAAQ,OAAO,KAC1E,IA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AAS,KAAO,EAAIzB,CAAI,CAAC,CAAC,GAAG,EACrG,CAAC,EAAE,MAAM,WAAW,EAC7D,GAAIW,GAAS,UAAU,OAAS,8BAA+B,CAC3D,IAAMe,EAAa,IAAI,IAAIf,EAAQ,WAAW,IAAI,GAAY,CAACI,EAAS,KAAMA,CAAQ,CAAC,CAAC,EACxF,OAAOJ,EAAQ,SAAS,OAAO,IAAI,GAAS,CACxC,IAAMgB,EAASD,EAAW,IAAIE,EAAM,OAAO,QAAQ,EAC7CN,EAAOM,EAAM,OAASD,EAASb,EAAsBa,CAAM,EAAI,IAAA,IACrE,MAAO,CAAE,MAAOC,EAAM,KAAM,WAAY,GAAGA,EAAM,KAAK,gBAAiB,cAAe,GAAGN,EAAON,EAAkBM,CAAI,EAAI,kBAAkB,IAAIL,GAAuB,CAC3K,CAAC,CACL,CACJ,CACJ,CACA,OAAO,IACX"}
@@ -1,3 +1,3 @@
1
1
  import"./_virtual/_virtual/_rolldown/runtime.js";import{clauseKeywords as e}from"./language.js";import{bmpWordCharacters as t}from"./bmp-word-characters.js";import{typeReferenceSymbol as n}from"./TypeReferenceSymbol.js";import{unescapeString as r}from"./compiler/Text/StringLiteral.js";import{eventBodyReservedWords as i}from"./compiler/Text/ReservedWords.js";import"./compiler/index.js";import{fenceMap as a,indentOf as o}from"./document-context.js";import{eventAnalysisSource as s}from"./event-analysis-source.js";import{responseAnalysis as c}from"./response-analysis.js";import{fileReferenceOn as l}from"./file-references.js";const u=/^concept\s+(\w+)\s*:\s*(\w+)((?:\s+@\w+)*)\s*$/,d=RegExp(`^@?([a-z_][${t}]*)(?:\\s*=\\s*(-?(?:0|[1-9][0-9]*)))?(?:\\s*//.*)?$`),f=/^\s*(@?[a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(\s+generated)?(\s+identifier)?(\s+subject)?\s*$/,p=/^([a-z_]\w*)\s+reason\s+"((?:[^"\\]|\\.)*)"\s*$/,m=/^\s*reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?\s*$/,h=[`authorize`,`produces`,`reads`],g=/^(?:(?:or|and)\s+)?[A-Za-z_(][\p{L}\p{Mn}\p{Nd}\p{Pc}\s()]*$/u,_=i,v=[`tag`,`for`,`generation`,`origin`,`namespace`,`sequence`,`correlation`,`causation`,`causedBy`,`occurred`],y=/^\s*(?:by|filter)\s+([a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(?:\s+from\s+.+)?\s*$/;function propertyTypeReference(e){return e.typeReference??n(e.type)}function sourceTypeAt(e,t){let n=e.slice(t-1).match(/^[\p{L}\p{Mn}\p{Nd}\p{Pc}.]+(?:\[\])?(?:\?|\s+optional\b)?/u)?.[0]??``;return{text:n,startColumn:t,endColumn:t+n.length}}function propertiesIn(e,t,r){return t.map(t=>({index:t,match:e[t].match(f)})).filter(e=>e.match!==null).filter(({match:e})=>e[1].startsWith(`@`)||e[1]===`as`||!r.includes(e[1])).map(({index:t,match:r})=>({name:r[1].replace(/^@/,``),type:r[2],typeReference:n(r[2]),sourceType:sourceTypeAt(e[t],e[t].match(/^\s*\S+\s+/)[0].length+1),isIdentifier:r[4]!==void 0,...r[3]===void 0?{}:{isGenerated:!0},...r[5]===void 0?{}:{isSubject:!0},line:t}))}function collectBody(e,t,n,r){let i=[];for(let a=n+1;a<e.length;a++){if(t[a])continue;let n=e[a];if(n.trim().length!==0){if(o(n)<=r)break;i.push(a)}}return i}function directBody(e,t,n,r){let i=collectBody(e,t,n,r).filter(n=>!t[n]&&!/^\s*(?:\/\/|#)/.test(e[n]));if(!/^\s*command\b/.test(e[n]))return i;let a,s=!1;return i.filter(t=>{let n=o(e[t]),r=e[t].trim();return a!==void 0&&n>a&&(!s||g.test(r))?!1:(a=r!==`validate csharp`&&propertiesIn(e,[t],h).length>0||/^description(?:\s|$)/.test(r)?void 0:n,s=/^authorize(?:\s|$)/.test(r),!0)})}const b=/* @__PURE__ */ new Map;function scanDocument(t){let i=t.join(`
2
- `),f=b.get(i);if(f)return f;let h=c(t),g={...h.identityDetails?.length?{identityDetails:h.identityDetails}:{},authoringSources:[i],eventSources:h.eventSources.declarations,imports:[],concepts:[],types:[],policies:[],events:[],commands:[],queries:[],screens:[],triggers:[]};t=s(t);let x=a(t),S=t,C=x,w=t.map(e=>e.replace(/\s*=(?!=|>).*/,``));for(let i=0;i<t.length;i++){if(x[i])continue;let a=t[i],s=a.trim(),c=o(a),f=S[i].trim().match(/^import\s+([\w.]+)(?:\s+from\s+"(?:[^"\\]|\\.)*")?\s*$/);if(f&&c===0){let e=f[1],t=e.split(`.`).pop()??e;g.imports.push({qualifiedName:e,shortName:t,line:i});continue}let b=s.match(u);if(b){let e=collectBody(t,x,i,c).map(e=>t[e].trim()),n={};for(let t of e){let e=t.match(p);e&&n[e[1]]===void 0&&(n[e[1]]=e[2])}let r=b[2]===`Enum`?e.filter(e=>e!==`validate`).map(e=>d.exec(e)).filter(e=>e!==null):[],a=r.map(e=>e[1]),o=r.length>0&&r.every(e=>e[2]!==void 0)?r.map(e=>Number(e[2])):void 0;g.concepts.push({name:b[1],primitive:b[2],attributes:b[3].trim().split(/\s+/).filter(Boolean),attributeReasons:n,enumValues:a,...o===void 0?{}:{enumNumbers:o},line:i});continue}let T=s.match(/^type\s+(\w+)\s*$/);if(T){g.types.push({name:T[1],properties:propertiesIn(t,collectBody(t,x,i,c),e),line:i});continue}let E=s.match(/^policy\s+(\w+)\s*$/);if(E){let e=collectBody(t,x,i,c).filter(e=>!x[e]).map(e=>t[e].trim());g.policies.push({name:E[1],requires:e,line:i});continue}let D=S[i].trim().match(/^(?:(?:produces|(?<public>public))\s+)?event\s+(?<name>\w+)(?:\s+generation\s+(?<generation>\d+))?(?:\s+from\s+(?<origin>"(?:[^"\\]|\\.)*"))?\s*$/);if(D){let e=s.startsWith(`produces `),t=directBody(S,C,i,c),n=e?t:t.filter(e=>l(S[e],e)===void 0);g.events.push({name:D.groups.name,...D.groups.generation?{generation:Number(D.groups.generation)}:{},...D.groups.public||D.groups.origin?{visibility:`Public`}:{},...D.groups.origin?{origin:r(D.groups.origin.slice(1,-1))}:{},inline:e,properties:propertiesIn(e?w:S,n,e?v:_),line:i});continue}let O=h.commands.get(i);if(O){let e=directBody(t,x,i,c),n=e.filter(e=>/^\s*produces\b/.test(t[e])&&!h.operationProductionLines?.has(e));g.commands.push({name:O.name,properties:O.properties.map(e=>({name:e.name,type:`${e.type.name}${e.type.isCollection?`[]`:``}${e.type.isOptional?` optional`:``}`,typeReference:{name:e.type.name,isCollection:e.type.isCollection,isOptional:e.type.isOptional},sourceType:sourceTypeAt(t[e.type.location.line-1],e.type.location.column),isIdentifier:e.isIdentifier||/\sidentifier\s*$/.test(t[e.location.line-1]),...e.isGenerated?{isGenerated:!0}:{},line:e.location.line-1})),response:O.response,productionHeaders:n,produces:n.flatMap(e=>{let t=S[e].trim(),n=/^produces\s+event\b/.test(t),r=/^produces\s+when\b/.test(t),i=r?directBody(S,C,e,o(S[e]))[0]:e;if(i===void 0)return[];let a=r?S[i].trim():t.match(n?/^produces\s+event\s+([A-Za-z_]\w*)(?:\s+generation\s+\d+)?\s*$/:/^produces\s+([A-Z]\w*)\s*$/)?.[1];if(a===void 0||!/^[A-Za-z_]\w*$/.test(a))return[];let s=directBody(S,C,i,o(S[i])),c=s.map(e=>S[e].trim().match(/^for(?:\s+(.*))?$/)).filter(e=>e!==null);return[{name:a,inline:n,conditional:r,line:e,target:c.length===0?void 0:c.length===1?c[0][1]??``:``,mappings:s.flatMap(e=>{let t=S[e].trim().match(n?/^(@?[a-z_]\w*)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?\s*=(?!=|>)\s*(.+)$/:/^(@?[\w.]+)\s*=(?!=|>)\s*(.+)$/);return t===null?[]:[{name:t[1].replace(/^@/,``),source:t[2],line:e}]})}]}),reads:e.filter(e=>!x[e]).map(e=>({line:e,match:t[e].match(m)})).filter(e=>e.match!==null).map(({line:e,match:t})=>({view:t[1],...t[2]?{alias:t[2]}:{},...t[3]?{by:t[3]}:{},line:e})),line:i});continue}let k=s.match(/^query\s+(\w+)\s*=>\s*(?:observable\s+)?([\w.]+(?:\[\])?(?:\?|\s+optional)?)\s*$/);if(k){let e=collectBody(t,x,i,c).map(e=>({index:e,match:t[e].match(y)})).filter(e=>e.match!==null).map(({index:e,match:r})=>({name:r[1],type:r[2],typeReference:n(r[2]),sourceType:sourceTypeAt(t[e],t[e].match(/^\s*(?:by|filter)\s+\S+\s+/)[0].length+1),isIdentifier:!1,line:e}));g.queries.push({name:k[1],returnType:k[2],returnTypeReference:n(k[2]),parameters:e,line:i});continue}let A=s.match(/^screen\s+(\w+)\s*$/);if(A){g.screens.push({name:A[1],line:i});continue}let j=s.match(/^trigger\s+(\w+)\s*$/);j&&c===0&&g.triggers.push({name:j[1],line:i})}return b.size>=16&&b.delete(b.keys().next().value),b.set(i,g),g}function mergeSymbols(...e){return{...e.some(e=>e.identityDetails?.length)?{identityDetails:e.flatMap(e=>e.identityDetails??[])}:{},authoringSources:e.flatMap(e=>e.authoringSources??[]),...e.some(e=>e.authoringDocuments)?{authoringDocuments:e.flatMap(e=>e.authoringDocuments??[])}:{},eventSources:e.flatMap(e=>e.eventSources??[]),imports:e.flatMap(e=>e.imports),concepts:e.flatMap(e=>e.concepts),types:e.flatMap(e=>e.types),policies:e.flatMap(e=>e.policies),events:e.flatMap(e=>e.events),commands:e.flatMap(e=>e.commands),queries:e.flatMap(e=>e.queries),screens:e.flatMap(e=>e.screens),triggers:e.flatMap(e=>e.triggers)}}function symbolsForBuffer(e,t){let n=t?.authoringPath??`current.play`,r=t?.authoringDocuments?.find(e=>e.path===n);return{...mergeSymbols(scanDocument(e),t??mergeSymbols()),authoringDocuments:t?.authoringDocuments,authoringPath:n,authoringPlacement:t?.authoringPlacement??r?.placement,authoringPlacementResolved:t?.authoringPlacementResolved??r?.isPlacementResolved}}function knownEventNames(e){return[...e.events.map(e=>e.name),...e.imports.map(e=>e.shortName)]}const x=[`Startup`,`Shutdown`];function knownTriggerNames(e){return[...knownEventNames(e),...e.triggers.map(e=>e.name),...x]}function knownTypeNames(e,t){return[...t,...e.concepts.map(e=>e.name),...e.types.map(e=>e.name),...e.imports.map(e=>e.shortName)]}export{x as builtInTriggerNames,directBody,knownEventNames,knownTriggerNames,knownTypeNames,mergeSymbols,propertyTypeReference,scanDocument,symbolsForBuffer};
2
+ `),f=b.get(i);if(f)return f;let h=c(t),g={...h.identityDetails?.length?{identityDetails:h.identityDetails}:{},authoringSources:[i],eventSources:h.eventSources.declarations,imports:[],concepts:[],types:[],policies:[],events:[],commands:[],queries:[],screens:[],triggers:[]};t=s(t);let x=a(t),S=t,C=x,w=t.map(e=>e.replace(/\s*=(?!=|>).*/,``));for(let i=0;i<t.length;i++){if(x[i])continue;let a=t[i],s=a.trim(),c=o(a),f=S[i].trim().match(/^import\s+([\w.]+)(?:\s+from\s+"(?:[^"\\]|\\.)*")?\s*$/);if(f&&c===0){let e=f[1],t=e.split(`.`).pop()??e;g.imports.push({qualifiedName:e,shortName:t,line:i});continue}let b=s.match(u);if(b){let e=collectBody(t,x,i,c),n=e.map(e=>t[e].trim()),r=Math.min(...e.filter(e=>!x[e]&&t[e].trim()!==``).map(e=>o(t[e]))),a=e.find(e=>!x[e]&&o(t[e])===r&&/^\s*generate\s+\w+/.test(t[e])),s=a===void 0?void 0:t[a].match(/^\s*generate\s+(\w+)/)?.[1],l={};for(let e of n){let t=e.match(p);t&&l[t[1]]===void 0&&(l[t[1]]=t[2])}let u=b[2]===`Enum`?n.filter(e=>e!==`validate`).map(e=>d.exec(e)).filter(e=>e!==null):[],f=u.map(e=>e[1]),m=u.length>0&&u.every(e=>e[2]!==void 0)?u.map(e=>Number(e[2])):void 0;g.concepts.push({name:b[1],primitive:b[2],attributes:b[3].trim().split(/\s+/).filter(Boolean),attributeReasons:l,enumValues:f,...m===void 0?{}:{enumNumbers:m},...s===void 0?{}:{generationStrategy:s},line:i});continue}let T=s.match(/^type\s+(\w+)\s*$/);if(T){g.types.push({name:T[1],properties:propertiesIn(t,collectBody(t,x,i,c),e),line:i});continue}let E=s.match(/^policy\s+(\w+)\s*$/);if(E){let e=collectBody(t,x,i,c).filter(e=>!x[e]).map(e=>t[e].trim());g.policies.push({name:E[1],requires:e,line:i});continue}let D=S[i].trim().match(/^(?:(?:produces|(?<public>public))\s+)?event\s+(?<name>\w+)(?:\s+generation\s+(?<generation>\d+))?(?:\s+from\s+(?<origin>"(?:[^"\\]|\\.)*"))?\s*$/);if(D){let e=s.startsWith(`produces `),t=directBody(S,C,i,c),n=e?t:t.filter(e=>l(S[e],e)===void 0);g.events.push({name:D.groups.name,...D.groups.generation?{generation:Number(D.groups.generation)}:{},...D.groups.public||D.groups.origin?{visibility:`Public`}:{},...D.groups.origin?{origin:r(D.groups.origin.slice(1,-1))}:{},inline:e,properties:propertiesIn(e?w:S,n,e?v:_),line:i});continue}let O=h.commands.get(i);if(O){let e=directBody(t,x,i,c),n=e.filter(e=>/^\s*produces\b/.test(t[e])&&!h.operationProductionLines?.has(e));g.commands.push({name:O.name,properties:O.properties.map(e=>({name:e.name,type:`${e.type.name}${e.type.isCollection?`[]`:``}${e.type.isOptional?` optional`:``}`,typeReference:{name:e.type.name,isCollection:e.type.isCollection,isOptional:e.type.isOptional},sourceType:sourceTypeAt(t[e.type.location.line-1],e.type.location.column),isIdentifier:e.isIdentifier||/\sidentifier\s*$/.test(t[e.location.line-1]),...e.isGenerated?{isGenerated:!0}:{},line:e.location.line-1})),response:O.response,productionHeaders:n,produces:n.flatMap(e=>{let t=S[e].trim(),n=/^produces\s+event\b/.test(t),r=/^produces\s+when\b/.test(t),i=r?directBody(S,C,e,o(S[e]))[0]:e;if(i===void 0)return[];let a=r?S[i].trim():t.match(n?/^produces\s+event\s+([A-Za-z_]\w*)(?:\s+generation\s+\d+)?\s*$/:/^produces\s+([A-Z]\w*)\s*$/)?.[1];if(a===void 0||!/^[A-Za-z_]\w*$/.test(a))return[];let s=directBody(S,C,i,o(S[i])),c=s.map(e=>S[e].trim().match(/^for(?:\s+(.*))?$/)).filter(e=>e!==null);return[{name:a,inline:n,conditional:r,line:e,target:c.length===0?void 0:c.length===1?c[0][1]??``:``,mappings:s.flatMap(e=>{let t=S[e].trim().match(n?/^(@?[a-z_]\w*)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?\s*=(?!=|>)\s*(.+)$/:/^(@?[\w.]+)\s*=(?!=|>)\s*(.+)$/);return t===null?[]:[{name:t[1].replace(/^@/,``),source:t[2],line:e}]})}]}),reads:e.filter(e=>!x[e]).map(e=>({line:e,match:t[e].match(m)})).filter(e=>e.match!==null).map(({line:e,match:t})=>({view:t[1],...t[2]?{alias:t[2]}:{},...t[3]?{by:t[3]}:{},line:e})),line:i});continue}let k=s.match(/^query\s+(\w+)\s*=>\s*(?:observable\s+)?([\w.]+(?:\[\])?(?:\?|\s+optional)?)\s*$/);if(k){let e=collectBody(t,x,i,c).map(e=>({index:e,match:t[e].match(y)})).filter(e=>e.match!==null).map(({index:e,match:r})=>({name:r[1],type:r[2],typeReference:n(r[2]),sourceType:sourceTypeAt(t[e],t[e].match(/^\s*(?:by|filter)\s+\S+\s+/)[0].length+1),isIdentifier:!1,line:e}));g.queries.push({name:k[1],returnType:k[2],returnTypeReference:n(k[2]),parameters:e,line:i});continue}let A=s.match(/^screen\s+(\w+)\s*$/);if(A){g.screens.push({name:A[1],line:i});continue}let j=s.match(/^trigger\s+(\w+)\s*$/);j&&c===0&&g.triggers.push({name:j[1],line:i})}return b.size>=16&&b.delete(b.keys().next().value),b.set(i,g),g}function mergeSymbols(...e){return{...e.some(e=>e.identityDetails?.length)?{identityDetails:e.flatMap(e=>e.identityDetails??[])}:{},authoringSources:e.flatMap(e=>e.authoringSources??[]),...e.some(e=>e.authoringDocuments)?{authoringDocuments:e.flatMap(e=>e.authoringDocuments??[])}:{},eventSources:e.flatMap(e=>e.eventSources??[]),imports:e.flatMap(e=>e.imports),concepts:e.flatMap(e=>e.concepts),types:e.flatMap(e=>e.types),policies:e.flatMap(e=>e.policies),events:e.flatMap(e=>e.events),commands:e.flatMap(e=>e.commands),queries:e.flatMap(e=>e.queries),screens:e.flatMap(e=>e.screens),triggers:e.flatMap(e=>e.triggers)}}function symbolsForBuffer(e,t){let n=t?.authoringPath??`current.play`,r=t?.authoringDocuments?.find(e=>e.path===n);return{...mergeSymbols(scanDocument(e),t??mergeSymbols()),authoringDocuments:t?.authoringDocuments,authoringPath:n,authoringPlacement:t?.authoringPlacement??r?.placement,authoringPlacementResolved:t?.authoringPlacementResolved??r?.isPlacementResolved}}function knownEventNames(e){return[...e.events.map(e=>e.name),...e.imports.map(e=>e.shortName)]}const x=[`Startup`,`Shutdown`];function knownTriggerNames(e){return[...knownEventNames(e),...e.triggers.map(e=>e.name),...x]}function knownTypeNames(e,t){return[...t,...e.concepts.map(e=>e.name),...e.types.map(e=>e.name),...e.imports.map(e=>e.shortName)]}export{x as builtInTriggerNames,directBody,knownEventNames,knownTriggerNames,knownTypeNames,mergeSymbols,propertyTypeReference,scanDocument,symbolsForBuffer};
3
3
  //# sourceMappingURL=symbols.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"symbols.js","names":["conceptPattern","enumerationMemberPattern","bmpWordCharacters","propertyPattern","attributeReasonPattern","readPattern","commandReserved","authorizationContinuation","eventReserved","eventBodyReservedWords","inlineEventReserved","queryParameterPattern","property","typeReferenceSymbol","text","line","startColumn","body","lines","index","entry","match","reserved","start","fences","indentOf","indent","blockIndent","authorization","childIndent","symbolRevisions","source","cached","analysis","responseAnalysis","symbols","eventAnalysisSource","fenceMap","eventLines","eventFences","eventPropertyLines","trimmed","importMatch","qualifiedName","shortName","conceptMatch","i","attributeReasons","reason","members","enumValues","member","enumNumbers","typeMatch","clauseKeywords","policyMatch","requires","eventMatch","inline","propertyBody","fileReferenceOn","unescapeString","command","productionHeaders","header","conditional","eventLine","name","children","targets","queryMatch","parameters","screenMatch","triggerMatch","documents","document","path","application","current","event","imported","builtInTriggerNames","trigger","primitives","concept","type"],"sources":["../../symbols.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 { EventVisibility, eventBodyReservedWords, unescapeString } from '@cratis/screenplay-compiler';\nimport { fenceMap, indentOf } from './document-context';\nimport { eventAnalysisSource } from './event-analysis-source';\nimport { CommandResponseSymbol, responseAnalysis } from './response-analysis';\nimport { fileReferenceOn } from './file-references';\nimport { clauseKeywords } from './language';\nimport { bmpWordCharacters } from './bmp-word-characters';\nimport { AuthoringDocument } from './AuthoringDocument';\nimport { AuthoredEventSource } from './AuthoredEventSource';\nimport { ProductionSymbol } from './ProductionSymbol';\nimport { TypeReferenceSymbol, typeReferenceSymbol } from './TypeReferenceSymbol';\n\nexport interface PropertySymbol {\n name: string;\n type: string;\n typeReference?: TypeReferenceSymbol;\n // Exact spelling and UTF-16 columns in the authoring source, independent of normalization.\n sourceType?: { text: string; startColumn: number; endColumn: number };\n isIdentifier: boolean;\n isGenerated?: boolean;\n isSubject?: boolean;\n line: number;\n}\n\nexport interface ConceptSymbol {\n name: string;\n primitive: string;\n attributes: string[];\n attributeReasons: Record<string, string>;\n enumValues: string[];\n enumNumbers?: number[];\n line: number;\n}\n\nexport interface TypeSymbol {\n name: string;\n properties: PropertySymbol[];\n line: number;\n}\n\nexport interface PolicySymbol {\n name: string;\n requires: string[];\n line: number;\n}\n\nexport interface EventSymbol {\n // Public editor declarations stay structural; the compiler is privately bundled.\n visibility?: 'Private' | 'Public';\n origin?: string;\n name: string;\n generation?: number;\n inline?: boolean;\n properties: PropertySymbol[];\n line: number;\n}\n\nexport interface CommandSymbol extends NamedSymbol {\n properties: PropertySymbol[];\n reads?: ReadSymbol[];\n produces?: ProductionSymbol[];\n productionHeaders?: number[];\n response?: CommandResponseSymbol | null;\n}\n\nexport interface ReadSymbol {\n view: string;\n alias?: string;\n by?: string;\n line: number;\n}\n\nexport interface NamedSymbol {\n name: string;\n line: number;\n}\n\nexport interface QuerySymbol extends NamedSymbol {\n returnType: string;\n returnTypeReference?: TypeReferenceSymbol;\n parameters: PropertySymbol[];\n}\n\nexport interface ImportSymbol {\n qualifiedName: string;\n shortName: string;\n line: number;\n}\n\nexport interface DocumentSymbols {\n identityDetails?: readonly { readonly name: string; readonly type: string; readonly line: number }[];\n authoringSources?: readonly string[];\n authoringPath?: string;\n authoringPlacement?: readonly string[];\n authoringPlacementResolved?: boolean;\n authoringDocuments?: readonly AuthoringDocument[];\n eventSources?: readonly AuthoredEventSource[];\n imports: ImportSymbol[];\n concepts: ConceptSymbol[];\n types: TypeSymbol[];\n policies: PolicySymbol[];\n events: EventSymbol[];\n commands: CommandSymbol[];\n queries: QuerySymbol[];\n screens: NamedSymbol[];\n triggers: NamedSymbol[];\n}\n\nconst conceptPattern = /^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@\\w+)*)\\s*$/;\nconst enumerationMemberPattern = new RegExp(`^@?([a-z_][${bmpWordCharacters}]*)(?:\\\\s*=\\\\s*(-?(?:0|[1-9][0-9]*)))?(?:\\\\s*//.*)?$`);\nconst propertyPattern = /^\\s*(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(\\s+generated)?(\\s+identifier)?(\\s+subject)?\\s*$/;\nconst attributeReasonPattern = /^([a-z_]\\w*)\\s+reason\\s+\"((?:[^\"\\\\]|\\\\.)*)\"\\s*$/;\nconst readPattern = /^\\s*reads\\s+([A-Z]\\w*)(?:\\s+as\\s+([a-z_]\\w*))?(?:\\s+by\\s+([a-z_]\\w*))?\\s*$/;\nconst commandReserved = ['authorize', 'produces', 'reads'];\n// AuthorizeParser's continuation pattern, including the compiler's Unicode word characters.\nconst authorizationContinuation = /^(?:(?:or|and)\\s+)?[A-Za-z_(][\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}\\s()]*$/u;\n// Use the compiler's contextual inventory, not the global completion vocabulary.\nconst eventReserved = eventBodyReservedWords;\nconst inlineEventReserved = ['tag', 'for', 'generation', 'origin', 'namespace', 'sequence', 'correlation', 'causation', 'causedBy', 'occurred'];\nconst queryParameterPattern =\n /^\\s*(?:by|filter)\\s+([a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+.+)?\\s*$/;\n\n// Property-shaped clauses depend on their owner. Commands reserve only authorize,\n// produces and reads; bare directives such as description and handler can be properties.\n// The @ escape always denotes a property, and 'as' keeps its established property meaning.\nexport function propertyTypeReference(property: PropertySymbol): TypeReferenceSymbol {\n return property.typeReference ?? typeReferenceSymbol(property.type);\n}\n\nfunction sourceTypeAt(line: string, startColumn: number): NonNullable<PropertySymbol['sourceType']> {\n const text = line.slice(startColumn - 1).match(/^[\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}.]+(?:\\[\\])?(?:\\?|\\s+optional\\b)?/u)?.[0] ?? '';\n return { text, startColumn, endColumn: startColumn + text.length };\n}\n\nfunction propertiesIn(lines: string[], body: number[], reserved: readonly string[]): PropertySymbol[] {\n return body\n .map((index) => ({ index, match: lines[index].match(propertyPattern) }))\n .filter((entry): entry is { index: number; match: RegExpMatchArray } => entry.match !== null)\n .filter(({ match }) => match[1].startsWith('@') || match[1] === 'as' || !reserved.includes(match[1]))\n .map(({ index, match }) => ({\n name: match[1].replace(/^@/, ''),\n type: match[2],\n typeReference: typeReferenceSymbol(match[2]),\n sourceType: sourceTypeAt(lines[index], lines[index].match(/^\\s*\\S+\\s+/)![0].length + 1),\n isIdentifier: match[4] !== undefined,\n ...(match[3] !== undefined ? { isGenerated: true } : {}),\n ...(match[5] !== undefined ? { isSubject: true } : {}),\n line: index,\n }));\n}\n\nfunction collectBody(lines: string[], fences: boolean[], start: number, indent: number): number[] {\n const body: number[] = [];\n for (let index = start + 1; index < lines.length; index++) {\n if (fences[index]) {\n continue;\n }\n const line = lines[index];\n if (line.trim().length === 0) continue;\n if (indentOf(line) <= indent) break;\n body.push(index);\n }\n return body;\n}\n\n// Event/production parsers accept every greater indent, not just the smallest child indent.\n// Command block directives own their nested lines; properties do not. Fenced prose is never syntax.\nexport function directBody(lines: string[], fences: boolean[], start: number, indent: number): number[] {\n const body = collectBody(lines, fences, start, indent).filter(index => !fences[index] && !/^\\s*(?:\\/\\/|#)/.test(lines[index]));\n if (!/^\\s*command\\b/.test(lines[start])) return body;\n let blockIndent: number | undefined;\n let authorization = false;\n return body.filter(index => {\n const childIndent = indentOf(lines[index]);\n const text = lines[index].trim();\n // AuthorizeParser owns only consecutive deeper lines with requirement shape.\n // Unlike opaque blocks, a nonmatching line returns control to CommandParser.\n if (blockIndent !== undefined && childIndent > blockIndent &&\n (!authorization || authorizationContinuation.test(text))) return false;\n const property = text !== 'validate csharp' && propertiesIn(lines, [index], commandReserved).length > 0;\n // Description consumes only a quoted value or a fence (already excluded above).\n const leaf = property || /^description(?:\\s|$)/.test(text);\n blockIndent = leaf ? undefined : childIndent;\n authorization = /^authorize(?:\\s|$)/.test(text);\n return true;\n });\n}\n\nconst symbolRevisions = new Map<string, DocumentSymbols>();\n\nexport function scanDocument(lines: string[]): DocumentSymbols {\n const source = lines.join('\\n');\n const cached = symbolRevisions.get(source);\n if (cached) return cached;\n const analysis = responseAnalysis(lines);\n const symbols: DocumentSymbols = {\n ...(analysis.identityDetails?.length ? { identityDetails: analysis.identityDetails } : {}),\n authoringSources: [source],\n eventSources: analysis.eventSources.declarations,\n imports: [],\n concepts: [],\n types: [],\n policies: [],\n events: [],\n commands: [],\n queries: [],\n screens: [],\n triggers: [],\n };\n // One normalization pass for every declaration, including comments on fence openers.\n lines = eventAnalysisSource(lines);\n const fences = fenceMap(lines);\n const eventLines = lines;\n const eventFences = fences;\n // Typed inline mappings share property syntax once their source expression is removed.\n // Do this once, never once per inline event.\n const eventPropertyLines = lines.map(line => line.replace(/\\s*=(?!=|>).*/, ''));\n\n for (let index = 0; index < lines.length; index++) {\n if (fences[index]) continue;\n const line = lines[index];\n const trimmed = line.trim();\n const indent = indentOf(line);\n\n const importMatch = eventLines[index].trim().match(/^import\\s+([\\w.]+)(?:\\s+from\\s+\"(?:[^\"\\\\]|\\\\.)*\")?\\s*$/);\n if (importMatch && indent === 0) {\n const qualifiedName = importMatch[1];\n const shortName = qualifiedName.split('.').pop() ?? qualifiedName;\n symbols.imports.push({ qualifiedName, shortName, line: index });\n continue;\n }\n\n const conceptMatch = trimmed.match(conceptPattern);\n if (conceptMatch) {\n const body = collectBody(lines, fences, index, indent).map((i) => lines[i].trim());\n const attributeReasons: Record<string, string> = {};\n for (const line of body) {\n const reason = line.match(attributeReasonPattern);\n if (reason && attributeReasons[reason[1]] === undefined) {\n attributeReasons[reason[1]] = reason[2];\n }\n }\n const members = conceptMatch[2] === 'Enum'\n ? body.filter(line => line !== 'validate').map(line => enumerationMemberPattern.exec(line)).filter(match => match !== null)\n : [];\n const enumValues = members.map(member => member[1]);\n const enumNumbers = members.length > 0 && members.every(member => member[2] !== undefined) ? members.map(member => Number(member[2])) : undefined;\n symbols.concepts.push({\n name: conceptMatch[1],\n primitive: conceptMatch[2],\n attributes: conceptMatch[3].trim().split(/\\s+/).filter(Boolean),\n attributeReasons,\n enumValues,\n ...(enumNumbers === undefined ? {} : { enumNumbers }),\n line: index,\n });\n continue;\n }\n\n const typeMatch = trimmed.match(/^type\\s+(\\w+)\\s*$/);\n if (typeMatch) {\n symbols.types.push({\n name: typeMatch[1],\n properties: propertiesIn(lines, collectBody(lines, fences, index, indent), clauseKeywords),\n line: index,\n });\n continue;\n }\n\n const policyMatch = trimmed.match(/^policy\\s+(\\w+)\\s*$/);\n if (policyMatch) {\n const requires = collectBody(lines, fences, index, indent)\n .filter((i) => !fences[i])\n .map((i) => lines[i].trim());\n symbols.policies.push({ name: policyMatch[1], requires, line: index });\n continue;\n }\n\n const eventMatch = eventLines[index].trim().match(/^(?:(?:produces|(?<public>public))\\s+)?event\\s+(?<name>\\w+)(?:\\s+generation\\s+(?<generation>\\d+))?(?:\\s+from\\s+(?<origin>\"(?:[^\"\\\\]|\\\\.)*\"))?\\s*$/);\n if (eventMatch) {\n const inline = trimmed.startsWith('produces ');\n const body = directBody(eventLines, eventFences, index, indent);\n // Standalone events distinguish file metadata from properties by path shape.\n const propertyBody = inline ? body : body.filter(line => fileReferenceOn(eventLines[line], line) === undefined);\n symbols.events.push({\n name: eventMatch.groups!.name,\n ...(eventMatch.groups!.generation ? { generation: Number(eventMatch.groups!.generation) } : {}),\n ...(eventMatch.groups!.public || eventMatch.groups!.origin ? { visibility: EventVisibility.Public } : {}),\n ...(eventMatch.groups!.origin ? { origin: unescapeString(eventMatch.groups!.origin.slice(1, -1)) } : {}),\n inline,\n properties: propertiesIn(inline ? eventPropertyLines : eventLines,\n propertyBody, inline ? inlineEventReserved : eventReserved),\n line: index,\n });\n continue;\n }\n\n const command = analysis.commands.get(index);\n if (command) {\n // A command property is a leaf, not an indentation owner. Share the parser-shaped\n // body with properties, productions, advice and destination hints.\n const body = directBody(lines, fences, index, indent);\n const productionHeaders = body.filter(line => /^\\s*produces\\b/.test(lines[line]) && !analysis.operationProductionLines?.has(line));\n symbols.commands.push({\n name: command.name,\n properties: command.properties.map(property => ({\n name: property.name,\n type: `${property.type.name}${property.type.isCollection ? '[]' : ''}${property.type.isOptional ? ' optional' : ''}`,\n typeReference: { name: property.type.name, isCollection: property.type.isCollection, isOptional: property.type.isOptional },\n sourceType: sourceTypeAt(lines[property.type.location.line - 1], property.type.location.column),\n isIdentifier: property.isIdentifier || /\\sidentifier\\s*$/.test(lines[property.location.line - 1]),\n ...(property.isGenerated ? { isGenerated: true } : {}),\n line: property.location.line - 1,\n })),\n response: command.response,\n productionHeaders,\n produces: productionHeaders.flatMap(line => {\n const header = eventLines[line].trim();\n const inline = /^produces\\s+event\\b/.test(header);\n const conditional = /^produces\\s+when\\b/.test(header);\n const eventLine = conditional ? directBody(eventLines, eventFences, line, indentOf(eventLines[line]))[0] : line;\n if (eventLine === undefined) return [];\n const name = conditional ? eventLines[eventLine].trim() : header.match(inline ? /^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+generation\\s+\\d+)?\\s*$/ : /^produces\\s+([A-Z]\\w*)\\s*$/)?.[1];\n if (name === undefined || !/^[A-Za-z_]\\w*$/.test(name)) return [];\n const children = directBody(eventLines, eventFences, eventLine, indentOf(eventLines[eventLine]));\n const targets = children.map(index => eventLines[index].trim().match(/^for(?:\\s+(.*))?$/)).filter(match => match !== null);\n // Empty or repeated targets are uncertain, not implicit destinations.\n const target = targets.length === 0 ? undefined : targets.length === 1 ? targets[0][1] ?? '' : '';\n const mappings = children.flatMap(index => {\n const match = eventLines[index].trim().match(inline ? /^(@?[a-z_]\\w*)\\s+[\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?\\s*=(?!=|>)\\s*(.+)$/ : /^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$/);\n return match === null ? [] : [{ name: match[1].replace(/^@/, ''), source: match[2], line: index }];\n });\n return [{ name, inline, conditional, line, target, mappings }];\n }),\n reads: body.filter((line) => !fences[line])\n .map((line) => ({ line, match: lines[line].match(readPattern) }))\n .filter((entry): entry is { line: number; match: RegExpMatchArray } => entry.match !== null)\n .map(({ line, match }) => ({\n view: match[1],\n ...(match[2] ? { alias: match[2] } : {}),\n ...(match[3] ? { by: match[3] } : {}),\n line,\n })),\n line: index,\n });\n continue;\n }\n\n // The return type shape is the compiler's, dots and all - QueryParser's\n // ^query\\s+([A-Za-z_]\\w*)\\s*=>\\s*(observable\\s+)?([\\w.]+(?:\\[\\])?\\??)$. A narrower one here\n // silently drops the query from the symbol table, and with it every check and completion that\n // reads from it.\n const queryMatch = trimmed.match(/^query\\s+(\\w+)\\s*=>\\s*(?:observable\\s+)?([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)\\s*$/);\n if (queryMatch) {\n // The return type names a read model, which no construct declares — only the\n // 'by' and 'filter' parameters resolve against the document's own types.\n const parameters = collectBody(lines, fences, index, indent)\n .map((i) => ({ index: i, match: lines[i].match(queryParameterPattern) }))\n .filter(\n (entry): entry is { index: number; match: RegExpMatchArray } =>\n entry.match !== null,\n )\n .map(({ index: line, match }) => ({\n name: match[1],\n type: match[2],\n typeReference: typeReferenceSymbol(match[2]),\n sourceType: sourceTypeAt(lines[line], lines[line].match(/^\\s*(?:by|filter)\\s+\\S+\\s+/)![0].length + 1),\n isIdentifier: false,\n line,\n }));\n symbols.queries.push({\n name: queryMatch[1],\n returnType: queryMatch[2],\n returnTypeReference: typeReferenceSymbol(queryMatch[2]),\n parameters,\n line: index,\n });\n continue;\n }\n\n const screenMatch = trimmed.match(/^screen\\s+(\\w+)\\s*$/);\n if (screenMatch) {\n symbols.screens.push({ name: screenMatch[1], line: index });\n continue;\n }\n\n const triggerMatch = trimmed.match(/^trigger\\s+(\\w+)\\s*$/);\n if (triggerMatch && indent === 0) {\n symbols.triggers.push({ name: triggerMatch[1], line: index });\n }\n }\n\n if (symbolRevisions.size >= 16) symbolRevisions.delete(symbolRevisions.keys().next().value!);\n symbolRevisions.set(source, symbols);\n return symbols;\n}\n\n// The symbols of several documents as one - what an application spread over files declares. Lines refer to\n// the document each symbol came from, so the result names things; it does not locate them.\nexport function mergeSymbols(...documents: DocumentSymbols[]): DocumentSymbols {\n return {\n ...(documents.some(document => document.identityDetails?.length) ? { identityDetails: documents.flatMap(document => document.identityDetails ?? []) } : {}),\n authoringSources: documents.flatMap(document => document.authoringSources ?? []),\n ...(documents.some(document => document.authoringDocuments) ? { authoringDocuments: documents.flatMap(document => document.authoringDocuments ?? []) } : {}),\n eventSources: documents.flatMap(document => document.eventSources ?? []),\n imports: documents.flatMap((document) => document.imports),\n concepts: documents.flatMap((document) => document.concepts),\n types: documents.flatMap((document) => document.types),\n policies: documents.flatMap((document) => document.policies),\n events: documents.flatMap((document) => document.events),\n commands: documents.flatMap((document) => document.commands),\n queries: documents.flatMap((document) => document.queries),\n screens: documents.flatMap((document) => document.screens),\n triggers: documents.flatMap((document) => document.triggers),\n };\n}\n\n// Name scans are not physical input documents. Keep the host's authoritative paths separate,\n// and let responseAnalysis replace the current document with this buffer exactly once.\nexport function symbolsForBuffer(lines: string[], application?: DocumentSymbols): DocumentSymbols {\n const path = application?.authoringPath ?? 'current.play';\n const current = application?.authoringDocuments?.find(document => document.path === path);\n return { ...mergeSymbols(scanDocument(lines), application ?? mergeSymbols()),\n authoringDocuments: application?.authoringDocuments,\n authoringPath: path,\n authoringPlacement: application?.authoringPlacement ?? current?.placement,\n authoringPlacementResolved: application?.authoringPlacementResolved ?? current?.isPlacementResolved,\n };\n}\n\nexport function knownEventNames(symbols: DocumentSymbols): string[] {\n return [\n ...symbols.events.map((event) => event.name),\n ...symbols.imports.map((imported) => imported.shortName),\n ];\n}\n\n// The built-in host signals, which have no declaration to scan for because every application has them.\nexport const builtInTriggerNames = ['Startup', 'Shutdown'];\n\n// What a reaction's `when` may name: an event, a declared trigger, or a host signal. The compiler resolves\n// the three in that order, and the editor offers them the same way rather than guessing which was meant.\nexport function knownTriggerNames(symbols: DocumentSymbols): string[] {\n return [\n ...knownEventNames(symbols),\n ...symbols.triggers.map((trigger) => trigger.name),\n ...builtInTriggerNames,\n ];\n}\n\n// Everything a property type reference can resolve to — the primitives, the declared\n// concepts and types, and the short names of the imports.\nexport function knownTypeNames(symbols: DocumentSymbols, primitives: readonly string[]): string[] {\n return [\n ...primitives,\n ...symbols.concepts.map((concept) => concept.name),\n ...symbols.types.map((type) => type.name),\n ...symbols.imports.map((imported) => imported.shortName),\n ];\n}\n"],"mappings":"qnBA+GA,MAAMA,EAAiB,iDACjBC,EAA+B,OAAO,cAAcC,EAAkB,qDAAqD,EAC3HC,EAAkB,2GAClBC,EAAyB,kDACzBC,EAAc,6EACdC,EAAkB,CAAC,YAAa,WAAY,OAAO,EAEnDC,EAA4B,gEAE5BC,EAAgBC,EAChBC,EAAsB,CAAC,MAAO,MAAO,aAAc,SAAU,YAAa,WAAY,cAAe,YAAa,WAAY,UAAU,EACxIC,EACF,8FAKJ,SAAgB,sBAAsB,EAA+C,CACjF,OAAOC,EAAS,e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AAa1D,CAAK,EAAG2D,GAAe,aAAa,CAAC,EACvE,mBAAoBA,GAAa,mBACjC,cAAeD,EACf,mBAAoBC,GAAa,oBAAsBC,GAAS,UAChE,2BAA4BD,GAAa,4BAA8BC,GAAS,mBACpF,CACJ,CAEA,SAAgB,gBAAgB,EAAoC,CAChE,MAAO,CACH,GAAG3C,EAAQ,OAAO,IAAK,GAAU4C,EAAM,IAAI,EAC3C,GAAG5C,EAAQ,QAAQ,IAAK,GAAa6C,EAAS,SAAS,CAC3D,CACJ,CAGA,MAAaC,EAAsB,CAAC,UAAW,UAAU,EAIzD,SAAgB,kBAAkB,EAAoC,CAClE,MAAO,CACH,GAAG,gBAAgB9C,CAAO,EAC1B,GAAGA,EAAQ,SAAS,IAAK,GAAY+C,EAAQ,IAAI,EACjD,GAAGD,CACP,CACJ,CAIA,SAAgB,eAAe,EAA0B,EAAyC,CAC9F,MAAO,CACH,GAAGE,EACH,GAAGhD,EAAQ,SAAS,IAAK,GAAYiD,EAAQ,IAAI,EACjD,GAAGjD,EAAQ,MAAM,IAAK,GAASkD,EAAK,IAAI,EACxC,GAAGlD,EAAQ,QAAQ,IAAK,GAAa6C,EAAS,SAAS,CAC3D,CACJ"}
1
+ {"version":3,"file":"symbols.js","names":["conceptPattern","enumerationMemberPattern","bmpWordCharacters","propertyPattern","attributeReasonPattern","readPattern","commandReserved","authorizationContinuation","eventReserved","eventBodyReservedWords","inlineEventReserved","queryParameterPattern","property","typeReferenceSymbol","text","line","startColumn","body","lines","index","entry","match","reserved","start","fences","indentOf","indent","blockIndent","authorization","childIndent","symbolRevisions","source","cached","analysis","responseAnalysis","symbols","eventAnalysisSource","fenceMap","eventLines","eventFences","eventPropertyLines","trimmed","importMatch","qualifiedName","shortName","conceptMatch","bodyLines","i","directIndent","generationLine","generationStrategy","attributeReasons","reason","members","enumValues","member","enumNumbers","typeMatch","clauseKeywords","policyMatch","requires","eventMatch","inline","propertyBody","fileReferenceOn","unescapeString","command","productionHeaders","header","conditional","eventLine","name","children","targets","queryMatch","parameters","screenMatch","triggerMatch","documents","document","path","application","current","event","imported","builtInTriggerNames","trigger","primitives","concept","type"],"sources":["../../symbols.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 { EventVisibility, eventBodyReservedWords, unescapeString } from '@cratis/screenplay-compiler';\nimport { fenceMap, indentOf } from './document-context';\nimport { eventAnalysisSource } from './event-analysis-source';\nimport { CommandResponseSymbol, responseAnalysis } from './response-analysis';\nimport { fileReferenceOn } from './file-references';\nimport { clauseKeywords } from './language';\nimport { bmpWordCharacters } from './bmp-word-characters';\nimport { AuthoringDocument } from './AuthoringDocument';\nimport { AuthoredEventSource } from './AuthoredEventSource';\nimport { ProductionSymbol } from './ProductionSymbol';\nimport { TypeReferenceSymbol, typeReferenceSymbol } from './TypeReferenceSymbol';\n\nexport interface PropertySymbol {\n name: string;\n type: string;\n typeReference?: TypeReferenceSymbol;\n // Exact spelling and UTF-16 columns in the authoring source, independent of normalization.\n sourceType?: { text: string; startColumn: number; endColumn: number };\n isIdentifier: boolean;\n isGenerated?: boolean;\n isSubject?: boolean;\n line: number;\n}\n\nexport interface ConceptSymbol {\n name: string;\n primitive: string;\n attributes: string[];\n attributeReasons: Record<string, string>;\n enumValues: string[];\n enumNumbers?: number[];\n generationStrategy?: string;\n line: number;\n}\n\nexport interface TypeSymbol {\n name: string;\n properties: PropertySymbol[];\n line: number;\n}\n\nexport interface PolicySymbol {\n name: string;\n requires: string[];\n line: number;\n}\n\nexport interface EventSymbol {\n // Public editor declarations stay structural; the compiler is privately bundled.\n visibility?: 'Private' | 'Public';\n origin?: string;\n name: string;\n generation?: number;\n inline?: boolean;\n properties: PropertySymbol[];\n line: number;\n}\n\nexport interface CommandSymbol extends NamedSymbol {\n properties: PropertySymbol[];\n reads?: ReadSymbol[];\n produces?: ProductionSymbol[];\n productionHeaders?: number[];\n response?: CommandResponseSymbol | null;\n}\n\nexport interface ReadSymbol {\n view: string;\n alias?: string;\n by?: string;\n line: number;\n}\n\nexport interface NamedSymbol {\n name: string;\n line: number;\n}\n\nexport interface QuerySymbol extends NamedSymbol {\n returnType: string;\n returnTypeReference?: TypeReferenceSymbol;\n parameters: PropertySymbol[];\n}\n\nexport interface ImportSymbol {\n qualifiedName: string;\n shortName: string;\n line: number;\n}\n\nexport interface DocumentSymbols {\n identityDetails?: readonly { readonly name: string; readonly type: string; readonly line: number }[];\n authoringSources?: readonly string[];\n authoringPath?: string;\n authoringPlacement?: readonly string[];\n authoringPlacementResolved?: boolean;\n authoringDocuments?: readonly AuthoringDocument[];\n eventSources?: readonly AuthoredEventSource[];\n imports: ImportSymbol[];\n concepts: ConceptSymbol[];\n types: TypeSymbol[];\n policies: PolicySymbol[];\n events: EventSymbol[];\n commands: CommandSymbol[];\n queries: QuerySymbol[];\n screens: NamedSymbol[];\n triggers: NamedSymbol[];\n}\n\nconst conceptPattern = /^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@\\w+)*)\\s*$/;\nconst enumerationMemberPattern = new RegExp(`^@?([a-z_][${bmpWordCharacters}]*)(?:\\\\s*=\\\\s*(-?(?:0|[1-9][0-9]*)))?(?:\\\\s*//.*)?$`);\nconst propertyPattern = /^\\s*(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(\\s+generated)?(\\s+identifier)?(\\s+subject)?\\s*$/;\nconst attributeReasonPattern = /^([a-z_]\\w*)\\s+reason\\s+\"((?:[^\"\\\\]|\\\\.)*)\"\\s*$/;\nconst readPattern = /^\\s*reads\\s+([A-Z]\\w*)(?:\\s+as\\s+([a-z_]\\w*))?(?:\\s+by\\s+([a-z_]\\w*))?\\s*$/;\nconst commandReserved = ['authorize', 'produces', 'reads'];\n// AuthorizeParser's continuation pattern, including the compiler's Unicode word characters.\nconst authorizationContinuation = /^(?:(?:or|and)\\s+)?[A-Za-z_(][\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}\\s()]*$/u;\n// Use the compiler's contextual inventory, not the global completion vocabulary.\nconst eventReserved = eventBodyReservedWords;\nconst inlineEventReserved = ['tag', 'for', 'generation', 'origin', 'namespace', 'sequence', 'correlation', 'causation', 'causedBy', 'occurred'];\nconst queryParameterPattern =\n /^\\s*(?:by|filter)\\s+([a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+.+)?\\s*$/;\n\n// Property-shaped clauses depend on their owner. Commands reserve only authorize,\n// produces and reads; bare directives such as description and handler can be properties.\n// The @ escape always denotes a property, and 'as' keeps its established property meaning.\nexport function propertyTypeReference(property: PropertySymbol): TypeReferenceSymbol {\n return property.typeReference ?? typeReferenceSymbol(property.type);\n}\n\nfunction sourceTypeAt(line: string, startColumn: number): NonNullable<PropertySymbol['sourceType']> {\n const text = line.slice(startColumn - 1).match(/^[\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}.]+(?:\\[\\])?(?:\\?|\\s+optional\\b)?/u)?.[0] ?? '';\n return { text, startColumn, endColumn: startColumn + text.length };\n}\n\nfunction propertiesIn(lines: string[], body: number[], reserved: readonly string[]): PropertySymbol[] {\n return body\n .map((index) => ({ index, match: lines[index].match(propertyPattern) }))\n .filter((entry): entry is { index: number; match: RegExpMatchArray } => entry.match !== null)\n .filter(({ match }) => match[1].startsWith('@') || match[1] === 'as' || !reserved.includes(match[1]))\n .map(({ index, match }) => ({\n name: match[1].replace(/^@/, ''),\n type: match[2],\n typeReference: typeReferenceSymbol(match[2]),\n sourceType: sourceTypeAt(lines[index], lines[index].match(/^\\s*\\S+\\s+/)![0].length + 1),\n isIdentifier: match[4] !== undefined,\n ...(match[3] !== undefined ? { isGenerated: true } : {}),\n ...(match[5] !== undefined ? { isSubject: true } : {}),\n line: index,\n }));\n}\n\nfunction collectBody(lines: string[], fences: boolean[], start: number, indent: number): number[] {\n const body: number[] = [];\n for (let index = start + 1; index < lines.length; index++) {\n if (fences[index]) {\n continue;\n }\n const line = lines[index];\n if (line.trim().length === 0) continue;\n if (indentOf(line) <= indent) break;\n body.push(index);\n }\n return body;\n}\n\n// Event/production parsers accept every greater indent, not just the smallest child indent.\n// Command block directives own their nested lines; properties do not. Fenced prose is never syntax.\nexport function directBody(lines: string[], fences: boolean[], start: number, indent: number): number[] {\n const body = collectBody(lines, fences, start, indent).filter(index => !fences[index] && !/^\\s*(?:\\/\\/|#)/.test(lines[index]));\n if (!/^\\s*command\\b/.test(lines[start])) return body;\n let blockIndent: number | undefined;\n let authorization = false;\n return body.filter(index => {\n const childIndent = indentOf(lines[index]);\n const text = lines[index].trim();\n // AuthorizeParser owns only consecutive deeper lines with requirement shape.\n // Unlike opaque blocks, a nonmatching line returns control to CommandParser.\n if (blockIndent !== undefined && childIndent > blockIndent &&\n (!authorization || authorizationContinuation.test(text))) return false;\n const property = text !== 'validate csharp' && propertiesIn(lines, [index], commandReserved).length > 0;\n // Description consumes only a quoted value or a fence (already excluded above).\n const leaf = property || /^description(?:\\s|$)/.test(text);\n blockIndent = leaf ? undefined : childIndent;\n authorization = /^authorize(?:\\s|$)/.test(text);\n return true;\n });\n}\n\nconst symbolRevisions = new Map<string, DocumentSymbols>();\n\nexport function scanDocument(lines: string[]): DocumentSymbols {\n const source = lines.join('\\n');\n const cached = symbolRevisions.get(source);\n if (cached) return cached;\n const analysis = responseAnalysis(lines);\n const symbols: DocumentSymbols = {\n ...(analysis.identityDetails?.length ? { identityDetails: analysis.identityDetails } : {}),\n authoringSources: [source],\n eventSources: analysis.eventSources.declarations,\n imports: [],\n concepts: [],\n types: [],\n policies: [],\n events: [],\n commands: [],\n queries: [],\n screens: [],\n triggers: [],\n };\n // One normalization pass for every declaration, including comments on fence openers.\n lines = eventAnalysisSource(lines);\n const fences = fenceMap(lines);\n const eventLines = lines;\n const eventFences = fences;\n // Typed inline mappings share property syntax once their source expression is removed.\n // Do this once, never once per inline event.\n const eventPropertyLines = lines.map(line => line.replace(/\\s*=(?!=|>).*/, ''));\n\n for (let index = 0; index < lines.length; index++) {\n if (fences[index]) continue;\n const line = lines[index];\n const trimmed = line.trim();\n const indent = indentOf(line);\n\n const importMatch = eventLines[index].trim().match(/^import\\s+([\\w.]+)(?:\\s+from\\s+\"(?:[^\"\\\\]|\\\\.)*\")?\\s*$/);\n if (importMatch && indent === 0) {\n const qualifiedName = importMatch[1];\n const shortName = qualifiedName.split('.').pop() ?? qualifiedName;\n symbols.imports.push({ qualifiedName, shortName, line: index });\n continue;\n }\n\n const conceptMatch = trimmed.match(conceptPattern);\n if (conceptMatch) {\n const bodyLines = collectBody(lines, fences, index, indent);\n const body = bodyLines.map((i) => lines[i].trim());\n const directIndent = Math.min(...bodyLines.filter(i => !fences[i] && lines[i].trim() !== '').map(i => indentOf(lines[i])));\n const generationLine = bodyLines.find(i => !fences[i] && indentOf(lines[i]) === directIndent && /^\\s*generate\\s+\\w+/.test(lines[i]));\n const generationStrategy = generationLine === undefined ? undefined : lines[generationLine].match(/^\\s*generate\\s+(\\w+)/)?.[1];\n const attributeReasons: Record<string, string> = {};\n for (const line of body) {\n const reason = line.match(attributeReasonPattern);\n if (reason && attributeReasons[reason[1]] === undefined) {\n attributeReasons[reason[1]] = reason[2];\n }\n }\n const members = conceptMatch[2] === 'Enum'\n ? body.filter(line => line !== 'validate').map(line => enumerationMemberPattern.exec(line)).filter(match => match !== null)\n : [];\n const enumValues = members.map(member => member[1]);\n const enumNumbers = members.length > 0 && members.every(member => member[2] !== undefined) ? members.map(member => Number(member[2])) : undefined;\n symbols.concepts.push({\n name: conceptMatch[1],\n primitive: conceptMatch[2],\n attributes: conceptMatch[3].trim().split(/\\s+/).filter(Boolean),\n attributeReasons,\n enumValues,\n ...(enumNumbers === undefined ? {} : { enumNumbers }),\n ...(generationStrategy === undefined ? {} : { generationStrategy }),\n line: index,\n });\n continue;\n }\n\n const typeMatch = trimmed.match(/^type\\s+(\\w+)\\s*$/);\n if (typeMatch) {\n symbols.types.push({\n name: typeMatch[1],\n properties: propertiesIn(lines, collectBody(lines, fences, index, indent), clauseKeywords),\n line: index,\n });\n continue;\n }\n\n const policyMatch = trimmed.match(/^policy\\s+(\\w+)\\s*$/);\n if (policyMatch) {\n const requires = collectBody(lines, fences, index, indent)\n .filter((i) => !fences[i])\n .map((i) => lines[i].trim());\n symbols.policies.push({ name: policyMatch[1], requires, line: index });\n continue;\n }\n\n const eventMatch = eventLines[index].trim().match(/^(?:(?:produces|(?<public>public))\\s+)?event\\s+(?<name>\\w+)(?:\\s+generation\\s+(?<generation>\\d+))?(?:\\s+from\\s+(?<origin>\"(?:[^\"\\\\]|\\\\.)*\"))?\\s*$/);\n if (eventMatch) {\n const inline = trimmed.startsWith('produces ');\n const body = directBody(eventLines, eventFences, index, indent);\n // Standalone events distinguish file metadata from properties by path shape.\n const propertyBody = inline ? body : body.filter(line => fileReferenceOn(eventLines[line], line) === undefined);\n symbols.events.push({\n name: eventMatch.groups!.name,\n ...(eventMatch.groups!.generation ? { generation: Number(eventMatch.groups!.generation) } : {}),\n ...(eventMatch.groups!.public || eventMatch.groups!.origin ? { visibility: EventVisibility.Public } : {}),\n ...(eventMatch.groups!.origin ? { origin: unescapeString(eventMatch.groups!.origin.slice(1, -1)) } : {}),\n inline,\n properties: propertiesIn(inline ? eventPropertyLines : eventLines,\n propertyBody, inline ? inlineEventReserved : eventReserved),\n line: index,\n });\n continue;\n }\n\n const command = analysis.commands.get(index);\n if (command) {\n // A command property is a leaf, not an indentation owner. Share the parser-shaped\n // body with properties, productions, advice and destination hints.\n const body = directBody(lines, fences, index, indent);\n const productionHeaders = body.filter(line => /^\\s*produces\\b/.test(lines[line]) && !analysis.operationProductionLines?.has(line));\n symbols.commands.push({\n name: command.name,\n properties: command.properties.map(property => ({\n name: property.name,\n type: `${property.type.name}${property.type.isCollection ? '[]' : ''}${property.type.isOptional ? ' optional' : ''}`,\n typeReference: { name: property.type.name, isCollection: property.type.isCollection, isOptional: property.type.isOptional },\n sourceType: sourceTypeAt(lines[property.type.location.line - 1], property.type.location.column),\n isIdentifier: property.isIdentifier || /\\sidentifier\\s*$/.test(lines[property.location.line - 1]),\n ...(property.isGenerated ? { isGenerated: true } : {}),\n line: property.location.line - 1,\n })),\n response: command.response,\n productionHeaders,\n produces: productionHeaders.flatMap(line => {\n const header = eventLines[line].trim();\n const inline = /^produces\\s+event\\b/.test(header);\n const conditional = /^produces\\s+when\\b/.test(header);\n const eventLine = conditional ? directBody(eventLines, eventFences, line, indentOf(eventLines[line]))[0] : line;\n if (eventLine === undefined) return [];\n const name = conditional ? eventLines[eventLine].trim() : header.match(inline ? /^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+generation\\s+\\d+)?\\s*$/ : /^produces\\s+([A-Z]\\w*)\\s*$/)?.[1];\n if (name === undefined || !/^[A-Za-z_]\\w*$/.test(name)) return [];\n const children = directBody(eventLines, eventFences, eventLine, indentOf(eventLines[eventLine]));\n const targets = children.map(index => eventLines[index].trim().match(/^for(?:\\s+(.*))?$/)).filter(match => match !== null);\n // Empty or repeated targets are uncertain, not implicit destinations.\n const target = targets.length === 0 ? undefined : targets.length === 1 ? targets[0][1] ?? '' : '';\n const mappings = children.flatMap(index => {\n const match = eventLines[index].trim().match(inline ? /^(@?[a-z_]\\w*)\\s+[\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?\\s*=(?!=|>)\\s*(.+)$/ : /^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$/);\n return match === null ? [] : [{ name: match[1].replace(/^@/, ''), source: match[2], line: index }];\n });\n return [{ name, inline, conditional, line, target, mappings }];\n }),\n reads: body.filter((line) => !fences[line])\n .map((line) => ({ line, match: lines[line].match(readPattern) }))\n .filter((entry): entry is { line: number; match: RegExpMatchArray } => entry.match !== null)\n .map(({ line, match }) => ({\n view: match[1],\n ...(match[2] ? { alias: match[2] } : {}),\n ...(match[3] ? { by: match[3] } : {}),\n line,\n })),\n line: index,\n });\n continue;\n }\n\n // The return type shape is the compiler's, dots and all - QueryParser's\n // ^query\\s+([A-Za-z_]\\w*)\\s*=>\\s*(observable\\s+)?([\\w.]+(?:\\[\\])?\\??)$. A narrower one here\n // silently drops the query from the symbol table, and with it every check and completion that\n // reads from it.\n const queryMatch = trimmed.match(/^query\\s+(\\w+)\\s*=>\\s*(?:observable\\s+)?([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)\\s*$/);\n if (queryMatch) {\n // The return type names a read model, which no construct declares — only the\n // 'by' and 'filter' parameters resolve against the document's own types.\n const parameters = collectBody(lines, fences, index, indent)\n .map((i) => ({ index: i, match: lines[i].match(queryParameterPattern) }))\n .filter(\n (entry): entry is { index: number; match: RegExpMatchArray } =>\n entry.match !== null,\n )\n .map(({ index: line, match }) => ({\n name: match[1],\n type: match[2],\n typeReference: typeReferenceSymbol(match[2]),\n sourceType: sourceTypeAt(lines[line], lines[line].match(/^\\s*(?:by|filter)\\s+\\S+\\s+/)![0].length + 1),\n isIdentifier: false,\n line,\n }));\n symbols.queries.push({\n name: queryMatch[1],\n returnType: queryMatch[2],\n returnTypeReference: typeReferenceSymbol(queryMatch[2]),\n parameters,\n line: index,\n });\n continue;\n }\n\n const screenMatch = trimmed.match(/^screen\\s+(\\w+)\\s*$/);\n if (screenMatch) {\n symbols.screens.push({ name: screenMatch[1], line: index });\n continue;\n }\n\n const triggerMatch = trimmed.match(/^trigger\\s+(\\w+)\\s*$/);\n if (triggerMatch && indent === 0) {\n symbols.triggers.push({ name: triggerMatch[1], line: index });\n }\n }\n\n if (symbolRevisions.size >= 16) symbolRevisions.delete(symbolRevisions.keys().next().value!);\n symbolRevisions.set(source, symbols);\n return symbols;\n}\n\n// The symbols of several documents as one - what an application spread over files declares. Lines refer to\n// the document each symbol came from, so the result names things; it does not locate them.\nexport function mergeSymbols(...documents: DocumentSymbols[]): DocumentSymbols {\n return {\n ...(documents.some(document => document.identityDetails?.length) ? { identityDetails: documents.flatMap(document => document.identityDetails ?? []) } : {}),\n authoringSources: documents.flatMap(document => document.authoringSources ?? []),\n ...(documents.some(document => document.authoringDocuments) ? { authoringDocuments: documents.flatMap(document => document.authoringDocuments ?? []) } : {}),\n eventSources: documents.flatMap(document => document.eventSources ?? []),\n imports: documents.flatMap((document) => document.imports),\n concepts: documents.flatMap((document) => document.concepts),\n types: documents.flatMap((document) => document.types),\n policies: documents.flatMap((document) => document.policies),\n events: documents.flatMap((document) => document.events),\n commands: documents.flatMap((document) => document.commands),\n queries: documents.flatMap((document) => document.queries),\n screens: documents.flatMap((document) => document.screens),\n triggers: documents.flatMap((document) => document.triggers),\n };\n}\n\n// Name scans are not physical input documents. Keep the host's authoritative paths separate,\n// and let responseAnalysis replace the current document with this buffer exactly once.\nexport function symbolsForBuffer(lines: string[], application?: DocumentSymbols): DocumentSymbols {\n const path = application?.authoringPath ?? 'current.play';\n const current = application?.authoringDocuments?.find(document => document.path === path);\n return { ...mergeSymbols(scanDocument(lines), application ?? mergeSymbols()),\n authoringDocuments: application?.authoringDocuments,\n authoringPath: path,\n authoringPlacement: application?.authoringPlacement ?? current?.placement,\n authoringPlacementResolved: application?.authoringPlacementResolved ?? current?.isPlacementResolved,\n };\n}\n\nexport function knownEventNames(symbols: DocumentSymbols): string[] {\n return [\n ...symbols.events.map((event) => event.name),\n ...symbols.imports.map((imported) => imported.shortName),\n ];\n}\n\n// The built-in host signals, which have no declaration to scan for because every application has them.\nexport const builtInTriggerNames = ['Startup', 'Shutdown'];\n\n// What a reaction's `when` may name: an event, a declared trigger, or a host signal. The compiler resolves\n// the three in that order, and the editor offers them the same way rather than guessing which was meant.\nexport function knownTriggerNames(symbols: DocumentSymbols): string[] {\n return [\n ...knownEventNames(symbols),\n ...symbols.triggers.map((trigger) => trigger.name),\n ...builtInTriggerNames,\n ];\n}\n\n// Everything a property type reference can resolve to — the primitives, the declared\n// concepts and types, and the short names of the imports.\nexport function knownTypeNames(symbols: DocumentSymbols, primitives: readonly string[]): string[] {\n return [\n ...primitives,\n ...symbols.concepts.map((concept) => concept.name),\n ...symbols.types.map((type) => type.name),\n ...symbols.im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oC,CAClE,MAAO,CACH,GAAG,gBAAgBlD,CAAO,EAC1B,GAAGA,EAAQ,SAAS,IAAK,GAAYmD,EAAQ,IAAI,EACjD,GAAGD,CACP,CACJ,CAIA,SAAgB,eAAe,EAA0B,EAAyC,CAC9F,MAAO,CACH,GAAGE,EACH,GAAGpD,EAAQ,SAAS,IAAK,GAAYqD,EAAQ,IAAI,EACjD,GAAGrD,EAAQ,MAAM,IAAK,GAASsD,EAAK,IAAI,EACxC,GAAGtD,EAAQ,QAAQ,IAAK,GAAaiD,EAAS,SAAS,CAC3D,CACJ"}
@@ -1,2 +1,2 @@
1
- import"./_virtual/_virtual/_rolldown/runtime.js";import{clauseKeywords as e,codeBlockTags as t,constructKeywords as n,primitiveTypes as r,sliceTypes as i}from"./language.js";import{bmpWordCharacters as a}from"./bmp-word-characters.js";const o=/* @__PURE__ */ new Set([`operation`,`system`,`eventsource`,`purpose`,`runs`]),s={csharp:`csharp`,typescript:`typescript`,react:`typescript`,html:`html`,sql:`sql`};function subLanguageState(e){return`subLanguage_${e}`}function subLanguageExitRule(e){let t=[...n.filter(e=>!o.has(e)),...e.map(e=>e.keyword)];return[RegExp(`^\\s*(?:${t.join(`|`)})\\b`),{token:`@rematch`,next:`@pop`}]}const c=[[/\/\/.*$/,`comment`],[/\$(?:context|identity|eventContext|eventSourceId|causedBy|refusal)(?:\.\w+)*/,`variable.predefined`],[/\$(?:env|secrets|strings)\.[\w.]+/,`variable.predefined`],[/\$\.[\w.]*/,`variable.predefined`],[/"(?:[^"\\]|\\.)*"/,`string`],[/"(?:[^"\\]|\\.)*$/,`string.invalid`],[/\d+(?:ms|s|m|h|d)\b/,`number`],[/-?\d+\.\d+/,`number.float`],[/-?\d+/,`number`],[/=>|==|!=|>=|<=|[><=:?]/,`operator`],[/[[\](),.]/,`delimiter`],[/\s+/,`white`]];function createTokensProvider(l){let u={root:[[RegExp(`^(\\s*)(example)(\\s+)([A-Z][${a}]*)(\\s*)(:)(\\s*)([A-Z][${a}.]*)(?=\\s*(?://.*)?$)`),[`white`,`keyword`,`white`,`type.identifier`,`white`,`operator`,`white`,`type.identifier`]],[/^(\s*)(direction)(\s+)(inbound|outbound)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`keyword`]],[RegExp(`^()(purpose)(\\s+)([A-Za-z_][${a}]*)(?=\\s*(?://.*)?$)`),[`white`,`keyword`,`white`,{token:`type.identifier`,next:`@purposeBody.$1`}]],[/^(\s*)(parameter)(\s+)([a-z_]\w*)(\s+)([\w.]+(?:\[\])?(?:\s+optional)?)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`identifier`,`white`,`type.identifier`]],[/^(\s*)(case)(\s+)([A-Za-z_]\w*)(?=\s*(?:[a-z_]\w*\s*=|\/\/|$))/,[`white`,`keyword`,`white`,`type.identifier`]],[/\b(case)(\.)([a-z_]\w*)\b/,[`keyword`,`delimiter`,`identifier`]],[/^(\s*)(concept)(\s+)([^\s:]+)(\s*:\s*)(\w+)((?:\s+(?:@?pii|personal|@?sensitive|secret))*)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`type.identifier`,`operator`,{token:`type.identifier`,next:`@conceptBody.$1`},`keyword`]],[/^(numbers)([ \t]+)(exact)(?=[ \t]*(?:(?:\/\/|#).*)?$)/,[`keyword`,`white`,`keyword`]],[/^(eventsource)(\s+)([A-Za-z_]\w*)(?=\s*(?:\/\/.*)?$)/,[`keyword`,`white`,`type.identifier`]],[/^(system)(\s+)([A-Z]\w*)(?=\s*(?:\/\/.*)?$)/,[`keyword`,`white`,`type.identifier`]],[/^(\s*)(runs)(\s+)(as)(\s+)(system)\b/,[`white`,`keyword`,`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(produces\s+operation)(\s+)([A-Z]\w*)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,{token:`type.identifier`,next:`@operationBody.$1`}]],[/^(\s*)(given\s+operation)(\s+)([\w.]+)(\s+)(fails)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`type.identifier`,`white`,`keyword`]],[/^(\s*)(then\s+(?:operation|compensated))(\s+)([\w.]+)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`type.identifier`]],[RegExp(`^(\\s*)(command)(\\s+)([A-Za-z_][${a}]*)(?=\\s*(?://.*)?$)`),[`white`,`keyword`,`white`,{token:`type.identifier`,next:`@commandBody.$1`}]],[/^(\s*)(handler)(?=\s*(?:\/\/.*)?$)/,[`white`,{token:`keyword`,next:`@handlerBody.$1`}]],[/^(\s*@?[a-z_]\w*\s+)([\w.]+(?:\[\])?(?:\?|\s+optional)?)(\s+)(generated)(\s+identifier|)(?=\s*(?:\/\/.*)?$)/,[`identifier`,`type.identifier`,`white`,`keyword`,`keyword`]],[/^(\s*)(generated)(\s+)([a-z_]\w*)(\s*=(?!=|>))/,[`white`,`keyword`,`white`,`identifier`,`operator`]],[/^(\s*)(then)(\s+)(returns)\b/,[`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(returns)(?=\s*(?:\/\/.*)?$|\s+@\w+\s*(?:\/\/.*)?$)/,[`white`,`keyword`]],[/^(\s*@?[a-z_]\w*\s+)([\w.]+)(\s+)(key)(?=\s*(?:\/\/.*)?$)/,[`identifier`,`type.identifier`,`white`,`keyword`]],[/^(\s*(?:by|filter)\s+[a-z_]\w*\s+)([\w.]+(?:\[\])?)(\s+)(optional)\b(?=\s*(?:from\b|\/\/|$))/,[`identifier`,`type.identifier`,`white`,`keyword`]],[/^(?!\s*(?:by|filter)\s+)(\s*@?[a-z_]\w*\s+)([\w.]+(?:\[\])?)(\s+)(optional)\b(?=\s*(?:identifier\b|from\b|=(?!=|>)|\/\/|$))/,[`identifier`,`type.identifier`,`white`,`keyword`]],[/^(\s*query\s+[A-Za-z_]\w*\s*=>\s*(?!observable\s+optional\s*(?:\/\/.*)?$)(?:observable\s+)?)([\w.]+(?:\[\])?)(\s+)(optional)\b(?=\s*(?:\/\/.*)?$)/,[`keyword`,`type.identifier`,`white`,`keyword`]],[RegExp(`^(\\s*)(given)(\\s+)(caller)(\\s+)(as)(\\s+)([A-Za-z_][${a}]*)(?=\\s*(?://.*)?$)`),[`white`,`keyword`,`white`,`keyword`,`white`,`keyword`,`white`,`type.identifier`]],[/^(\s*)(given|when)(\s+)(clock|capture|trigger|query)\b/,[`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(then)(\s+)(result|no\s+(?:result|events))\b/,[`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(then)(\s+)(events)(\s+)(in any order)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(when)(\s+)(redelivered)(\s+)([\w.]+)(\s+)(to)(\s+)([\w.]+)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`keyword`,`white`,`type.identifier`,`white`,`keyword`,`white`,`type.identifier`]],[/^(\s*)(otherwise)(\s+)(hidden)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(otherwise)(\s+)(execute)(\s+)([\w.]+)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`keyword`,`white`,`type.identifier`]],[/^(\s*)(when)(\s+)(?=.+\s+execute\s+[\w.]+\s*(?:\/\/.*)?$)/,[`white`,`keyword`,{token:`white`,next:`@guardedActionCondition`}]],[/^(\s*)(behavior)(\s+)([A-Za-z_]\w*)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,{token:`type.identifier`,next:`@behaviorBody.$1`}]],[/^(\s*)(on)(\s+)(refused)(\s+)(by)(\s+)(validation|constraint|authorization)\b/,[`white`,`keyword`,`white`,`keyword`,`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(on)(\s+)(refused)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(on)(\s+)([\w-]+)\b/,[`white`,`keyword`,`white`,{token:`keyword`,next:`@interactionBody.$1`}]],[/^(\s*)(acknowledge)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`]],[/^(\s*)(import)(\s+)("[^"\\]*")/,[`white`,`keyword`,`white`,`string.link`]],[/^(\s*)((?:(?:produces|public)\s+)?event)(\s+)([A-Za-z_]\w*)(\s+)(generation)(\s+)(\d+)(?=\s*(?:from\s+"(?:[^"\\]|\\.)*"\s*)?(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`type.identifier`,`white`,`keyword`,`white`,{token:`number`,next:`@eventBody.$1`}]],[/^(\s*)((?:(?:produces|public)\s+)?event)(\s+)([A-Za-z_]\w*)(?=\s*(?:from\s+"(?:[^"\\]|\\.)*"\s*)?(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,{token:`type.identifier`,next:`@eventBody.$1`}]],...t.map(e=>[RegExp(`^\\s*\\x60\\x60\\x60${e}\\s*$`),{token:`string.quote`,next:`@codeBlock.${s[e]}`,nextEmbedded:s[e]}]),...t.map(e=>[RegExp(`\\b${e}\\b(?=\\s*$)`),{token:`keyword.tag`,next:`@codeBlockPending.${s[e]}`}]),...l.map(e=>[RegExp(`\\b${e.keyword}\\b`),{token:`keyword`,next:`@${subLanguageState(e.keyword)}`}]),[/^(\s*)(documentation)(?=\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?\s*(?:identifier\b|generated\b|=(?!=|>)|\/\/|$))/,[`white`,`identifier`]],[/\b(?:description|documentation)\b(?=\s*(?:\/\/.*)?$)/,{token:`keyword`,next:`@descriptionBlockPending`}],[/\brow-click\b/,`keyword`],[/^\s*@[a-z_]\w*/,`identifier`],[/@\w+/,`annotation`],[/[A-Z]\w*/,{cases:{"@sliceTypes":`keyword.type`,"@primitiveTypes":`type`,"@default":`type.identifier`}}],[/[a-z_]\w*/,{cases:{"@keywords":`keyword`,"@default":`identifier`}}],{include:`@common`}],guardedActionCondition:[[/(execute)(\s+)([\w.]+)(?=\s*(?:\/\/.*)?$)/,[`keyword`,`white`,{token:`type.identifier`,next:`@pop`}]],{include:`@root`}],behaviorBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],{include:`@root`}],interactionBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(otherwise)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`]],[/^(\s*)(when)(\s+)(?=item\.|\()/,[`white`,`keyword`,`white`]],[/^(\s*)(execute)(\s+)([\w.]+)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`type.identifier`]],{include:`@root`}],purposeBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(basis|interest|condition|authorization|subjects|retention|recipient|transfer|erasure)(\s+)/,[`white`,`keyword`,`white`]],[/\b(safeguard|exception)\b/,`keyword`],{include:`@root`}],conceptBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[RegExp(`^(\\s*)(@?[a-z_][${a}]*)(\\s*)(=)(\\s*)(-?(?:0|[1-9][0-9]*))(?=\\s*(?://.*)?$)`),[`white`,`identifier`,`white`,`operator`,`white`,`number`]],[/^(\s*)(@?pii|personal|@?sensitive|secret)(\s+)(reason|scope|special|criminal)\b/,[`white`,`keyword`,`white`,`keyword`]],{include:`@root`}],commandBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(validate)(?=\s*(?:\/\/.*)?$)/,[`white`,{token:`keyword`,next:`@commandValidation.$1`}]],{include:`@root`}],commandValidation:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[RegExp(`^(\\s*)([${a}.]+)(\\s+)(rule)(\\s+)([A-Za-z_][${a}]*)(?=\\s*(?:severity\\s+\\w+|message\\s+.*|//.*|$))`),[`white`,`identifier`,`white`,`keyword`,`white`,{token:`type.identifier`,next:`@namedRuleBody.$1`}]],{include:`@root`}],namedRuleBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(implementation)(?=\s*(?:\/\/.*)?$)/,[`white`,{token:`keyword`,next:`@implementationBody.$1`}]],{include:`@root`}],operationBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(execute|compensate)(?=\s*(?:\/\/.*)?$)/,[`white`,{token:`keyword`,next:`@operationPhase.$1`}]],[/^(\s*)(uses)(\s+)([A-Z]\w*)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`type.identifier`]],[/^(\s*)(@?[a-z_]\w*)(\s+)([\w.]+(?:\[\])?(?:\?|\s+optional)?)(?=\s*(?:=(?!=|>)|\/\/|$))/,[`white`,`identifier`,`white`,`type.identifier`]],{include:`@root`}],operationPhase:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(implementation)(?=\s*(?:\/\/.*)?$)/,[`white`,{token:`keyword`,next:`@implementationBody.$1`}]],{include:`@root`}],handlerBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(implementation)(?=\s*(?:\/\/.*)?$)/,[`white`,{token:`keyword`,next:`@implementationBody.$1`}]],{include:`@root`}],implementationBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(hint)(?=\s+")/,[`white`,`keyword`]],{include:`@root`}],eventBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(id)(?=\s+")/,[`white`,`keyword`]],[/^(\s*)(documentation)(?=\s*(?:\/\/.*)?$)/,[`white`,{token:`keyword`,next:`@descriptionBlockPending`}]],{include:`@root`}],common:c,codeBlockPending:[[/^\s*```\s*$/,{token:`string.quote`,switchTo:`@codeBlock.$S2`,nextEmbedded:`$S2`}],[/^\s*[^\s`].*$/,{token:`@rematch`,next:`@pop`}],[/\s+/,`white`]],codeBlock:[[/^\s*```\s*$/,{token:`string.quote`,next:`@pop`,nextEmbedded:`@pop`}],[/[^`]+/,``],[/`/,``]],descriptionBlockPending:[[/\/\/.*$/,`comment`],[/^\s*```(?:text|markdown)?\s*$/,{token:`string.quote`,switchTo:`@descriptionBlock`}],[/^\s*[^\s`].*$/,{token:`@rematch`,next:`@pop`}],[/\s+/,`white`]],descriptionBlock:[[/^\s*```\s*$/,{token:`string.quote`,next:`@pop`}],[/.+/,`string`]]};for(let e of l)u[subLanguageState(e.keyword)]=[subLanguageExitRule(l),...e.tokens,{include:`@common`},[/[A-Z]\w*/,`type.identifier`],[/[a-z_]\w*/,`identifier`]];return{defaultToken:``,tokenPostfix:`.play`,ignoreCase:!1,keywords:[...n.filter(e=>!o.has(e)),...e,...t],sliceTypes:i,primitiveTypes:r,tokenizer:u}}export{c as commonTokenRules,createTokensProvider};
1
+ import"./_virtual/_virtual/_rolldown/runtime.js";import{clauseKeywords as e,codeBlockTags as t,constructKeywords as n,primitiveTypes as r,sliceTypes as i}from"./language.js";import{bmpWordCharacters as a}from"./bmp-word-characters.js";const o=/* @__PURE__ */ new Set([`operation`,`system`,`eventsource`,`purpose`,`runs`]),s={csharp:`csharp`,typescript:`typescript`,react:`typescript`,html:`html`,sql:`sql`};function subLanguageState(e){return`subLanguage_${e}`}function subLanguageExitRule(e){let t=[...n.filter(e=>!o.has(e)),...e.map(e=>e.keyword)];return[RegExp(`^\\s*(?:${t.join(`|`)})\\b`),{token:`@rematch`,next:`@pop`}]}const c=[[/\/\/.*$/,`comment`],[/\$(?:context|identity|eventContext|eventSourceId|causedBy|refusal)(?:\.\w+)*/,`variable.predefined`],[/\$(?:env|secrets|strings)\.[\w.]+/,`variable.predefined`],[/\$\.[\w.]*/,`variable.predefined`],[/"(?:[^"\\]|\\.)*"/,`string`],[/"(?:[^"\\]|\\.)*$/,`string.invalid`],[/\d+(?:ms|s|m|h|d)\b/,`number`],[/-?\d+\.\d+/,`number.float`],[/-?\d+/,`number`],[/=>|==|!=|>=|<=|[><=:?]/,`operator`],[/[[\](),.]/,`delimiter`],[/\s+/,`white`]];function createTokensProvider(l){let u={root:[[RegExp(`^(\\s*)(example)(\\s+)([A-Z][${a}]*)(\\s*)(:)(\\s*)([A-Z][${a}.]*)(?=\\s*(?://.*)?$)`),[`white`,`keyword`,`white`,`type.identifier`,`white`,`operator`,`white`,`type.identifier`]],[/^(\s*)(direction)(\s+)(inbound|outbound)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`keyword`]],[RegExp(`^()(purpose)(\\s+)([A-Za-z_][${a}]*)(?=\\s*(?://.*)?$)`),[`white`,`keyword`,`white`,{token:`type.identifier`,next:`@purposeBody.$1`}]],[/^(\s*)(parameter)(\s+)([a-z_]\w*)(\s+)([\w.]+(?:\[\])?(?:\s+optional)?)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`identifier`,`white`,`type.identifier`]],[/^(\s*)(case)(\s+)([A-Za-z_]\w*)(?=\s*(?:[a-z_]\w*\s*=|\/\/|$))/,[`white`,`keyword`,`white`,`type.identifier`]],[/\b(case)(\.)([a-z_]\w*)\b/,[`keyword`,`delimiter`,`identifier`]],[/^(\s*)(concept)(\s+)([^\s:]+)(\s*:\s*)(\w+)((?:\s+(?:@?pii|personal|@?sensitive|secret))*)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`type.identifier`,`operator`,{token:`type.identifier`,next:`@conceptBody.$1`},`keyword`]],[/^(numbers)([ \t]+)(exact)(?=[ \t]*(?:(?:\/\/|#).*)?$)/,[`keyword`,`white`,`keyword`]],[/^(eventsource)(\s+)([A-Za-z_]\w*)(?=\s*(?:\/\/.*)?$)/,[`keyword`,`white`,`type.identifier`]],[/^(system)(\s+)([A-Z]\w*)(?=\s*(?:\/\/.*)?$)/,[`keyword`,`white`,`type.identifier`]],[/^(\s*)(runs)(\s+)(as)(\s+)(system)\b/,[`white`,`keyword`,`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(produces\s+operation)(\s+)([A-Z]\w*)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,{token:`type.identifier`,next:`@operationBody.$1`}]],[/^(\s*)(given\s+operation)(\s+)([\w.]+)(\s+)(fails)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`type.identifier`,`white`,`keyword`]],[/^(\s*)(then\s+(?:operation|compensated))(\s+)([\w.]+)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`type.identifier`]],[RegExp(`^(\\s*)(command)(\\s+)([A-Za-z_][${a}]*)(?=\\s*(?://.*)?$)`),[`white`,`keyword`,`white`,{token:`type.identifier`,next:`@commandBody.$1`}]],[/^(\s*)(handler)(?=\s*(?:\/\/.*)?$)/,[`white`,{token:`keyword`,next:`@handlerBody.$1`}]],[/^(\s*@?[a-z_]\w*\s+)([\w.]+(?:\[\])?(?:\?|\s+optional)?)(\s+)(generated)(\s+identifier|)(?=\s*(?:\/\/.*)?$)/,[`identifier`,`type.identifier`,`white`,`keyword`,`keyword`]],[/^(\s*)(generated)(\s+)([a-z_]\w*)(\s*=(?!=|>))/,[`white`,`keyword`,`white`,`identifier`,`operator`]],[/^(\s*)(then)(\s+)(returns)\b/,[`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(returns)(?=\s*(?:\/\/.*)?$|\s+@\w+\s*(?:\/\/.*)?$)/,[`white`,`keyword`]],[/^(\s*@?[a-z_]\w*\s+)([\w.]+)(\s+)(key)(?=\s*(?:\/\/.*)?$)/,[`identifier`,`type.identifier`,`white`,`keyword`]],[/^(\s*(?:by|filter)\s+[a-z_]\w*\s+)([\w.]+(?:\[\])?)(\s+)(optional)\b(?=\s*(?:from\b|\/\/|$))/,[`identifier`,`type.identifier`,`white`,`keyword`]],[/^(?!\s*(?:by|filter)\s+)(\s*@?[a-z_]\w*\s+)([\w.]+(?:\[\])?)(\s+)(optional)\b(?=\s*(?:identifier\b|from\b|=(?!=|>)|\/\/|$))/,[`identifier`,`type.identifier`,`white`,`keyword`]],[/^(\s*query\s+[A-Za-z_]\w*\s*=>\s*(?!observable\s+optional\s*(?:\/\/.*)?$)(?:observable\s+)?)([\w.]+(?:\[\])?)(\s+)(optional)\b(?=\s*(?:\/\/.*)?$)/,[`keyword`,`type.identifier`,`white`,`keyword`]],[RegExp(`^(\\s*)(given)(\\s+)(caller)(\\s+)(as)(\\s+)([A-Za-z_][${a}]*)(?=\\s*(?://.*)?$)`),[`white`,`keyword`,`white`,`keyword`,`white`,`keyword`,`white`,`type.identifier`]],[/^(\s*)(given|when)(\s+)(clock|capture|trigger|query)\b/,[`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(then)(\s+)(result|no\s+(?:result|events))\b/,[`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(then)(\s+)(events)(\s+)(in any order)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(when)(\s+)(redelivered)(\s+)([\w.]+)(\s+)(to)(\s+)([\w.]+)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`keyword`,`white`,`type.identifier`,`white`,`keyword`,`white`,`type.identifier`]],[/^(\s*)(otherwise)(\s+)(hidden)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(otherwise)(\s+)(execute)(\s+)([\w.]+)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`keyword`,`white`,`type.identifier`]],[/^(\s*)(when)(\s+)(?=.+\s+execute\s+[\w.]+\s*(?:\/\/.*)?$)/,[`white`,`keyword`,{token:`white`,next:`@guardedActionCondition`}]],[/^(\s*)(behavior)(\s+)([A-Za-z_]\w*)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,{token:`type.identifier`,next:`@behaviorBody.$1`}]],[/^(\s*)(on)(\s+)(refused)(\s+)(by)(\s+)(validation|constraint|authorization)\b/,[`white`,`keyword`,`white`,`keyword`,`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(on)(\s+)(refused)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(on)(\s+)([\w-]+)\b/,[`white`,`keyword`,`white`,{token:`keyword`,next:`@interactionBody.$1`}]],[/^(\s*)(acknowledge)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`]],[/^(\s*)(import)(\s+)("[^"\\]*")/,[`white`,`keyword`,`white`,`string.link`]],[/^(\s*)((?:(?:produces|public)\s+)?event)(\s+)([A-Za-z_]\w*)(\s+)(generation)(\s+)(\d+)(?=\s*(?:from\s+"(?:[^"\\]|\\.)*"\s*)?(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`type.identifier`,`white`,`keyword`,`white`,{token:`number`,next:`@eventBody.$1`}]],[/^(\s*)((?:(?:produces|public)\s+)?event)(\s+)([A-Za-z_]\w*)(?=\s*(?:from\s+"(?:[^"\\]|\\.)*"\s*)?(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,{token:`type.identifier`,next:`@eventBody.$1`}]],...t.map(e=>[RegExp(`^\\s*\\x60\\x60\\x60${e}\\s*$`),{token:`string.quote`,next:`@codeBlock.${s[e]}`,nextEmbedded:s[e]}]),...t.map(e=>[RegExp(`\\b${e}\\b(?=\\s*$)`),{token:`keyword.tag`,next:`@codeBlockPending.${s[e]}`}]),...l.map(e=>[RegExp(`\\b${e.keyword}\\b`),{token:`keyword`,next:`@${subLanguageState(e.keyword)}`}]),[/^(\s*)(documentation)(?=\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?\s*(?:identifier\b|generated\b|=(?!=|>)|\/\/|$))/,[`white`,`identifier`]],[/\b(?:description|documentation)\b(?=\s*(?:\/\/.*)?$)/,{token:`keyword`,next:`@descriptionBlockPending`}],[/\brow-click\b/,`keyword`],[/^\s*@[a-z_]\w*/,`identifier`],[/@\w+/,`annotation`],[/[A-Z]\w*/,{cases:{"@sliceTypes":`keyword.type`,"@primitiveTypes":`type`,"@default":`type.identifier`}}],[/[a-z_]\w*/,{cases:{"@keywords":`keyword`,"@default":`identifier`}}],{include:`@common`}],guardedActionCondition:[[/(execute)(\s+)([\w.]+)(?=\s*(?:\/\/.*)?$)/,[`keyword`,`white`,{token:`type.identifier`,next:`@pop`}]],{include:`@root`}],behaviorBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],{include:`@root`}],interactionBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(otherwise)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`]],[/^(\s*)(when)(\s+)(?=item\.|\()/,[`white`,`keyword`,`white`]],[/^(\s*)(execute)(\s+)([\w.]+)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`type.identifier`]],{include:`@root`}],purposeBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(basis|interest|condition|authorization|subjects|retention|recipient|transfer|erasure)(\s+)/,[`white`,`keyword`,`white`]],[/\b(safeguard|exception)\b/,`keyword`],{include:`@root`}],generationLine:[[/^/,{token:`@rematch`,next:`@pop`}],[/\b(prefix|case|alphabet|checksum|base64url|hex|base32|lower|upper|luhn|mod11|mod97)\b/,`keyword`],{include:`@common`}],conceptBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[RegExp(`^(\\s*)(@?[a-z_][${a}]*)(\\s*)(=)(\\s*)(-?(?:0|[1-9][0-9]*))(?=\\s*(?://.*)?$)`),[`white`,`identifier`,`white`,`operator`,`white`,`number`]],[/^(\s*)(@?pii|personal|@?sensitive|secret)(\s+)(reason|scope|special|criminal)\b/,[`white`,`keyword`,`white`,`keyword`]],[/^(\s*)(generate)(\s+)(uuidv7|uuid|ulid|typeid|nanoid|bytes|pattern|random|rule|sequence)\b/,[`white`,`keyword`,`white`,{token:`keyword`,next:`@generationLine`}]],{include:`@root`}],commandBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(validate)(?=\s*(?:\/\/.*)?$)/,[`white`,{token:`keyword`,next:`@commandValidation.$1`}]],{include:`@root`}],commandValidation:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[RegExp(`^(\\s*)([${a}.]+)(\\s+)(rule)(\\s+)([A-Za-z_][${a}]*)(?=\\s*(?:severity\\s+\\w+|message\\s+.*|//.*|$))`),[`white`,`identifier`,`white`,`keyword`,`white`,{token:`type.identifier`,next:`@namedRuleBody.$1`}]],{include:`@root`}],namedRuleBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(implementation)(?=\s*(?:\/\/.*)?$)/,[`white`,{token:`keyword`,next:`@implementationBody.$1`}]],{include:`@root`}],operationBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(execute|compensate)(?=\s*(?:\/\/.*)?$)/,[`white`,{token:`keyword`,next:`@operationPhase.$1`}]],[/^(\s*)(uses)(\s+)([A-Z]\w*)(?=\s*(?:\/\/.*)?$)/,[`white`,`keyword`,`white`,`type.identifier`]],[/^(\s*)(@?[a-z_]\w*)(\s+)([\w.]+(?:\[\])?(?:\?|\s+optional)?)(?=\s*(?:=(?!=|>)|\/\/|$))/,[`white`,`identifier`,`white`,`type.identifier`]],{include:`@root`}],operationPhase:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(implementation)(?=\s*(?:\/\/.*)?$)/,[`white`,{token:`keyword`,next:`@implementationBody.$1`}]],{include:`@root`}],handlerBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(implementation)(?=\s*(?:\/\/.*)?$)/,[`white`,{token:`keyword`,next:`@implementationBody.$1`}]],{include:`@root`}],implementationBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(hint)(?=\s+")/,[`white`,`keyword`]],{include:`@root`}],eventBody:[[/^(?!$S2[ \t]+|\s*$)/,{token:`@rematch`,next:`@pop`}],[/^(\s*)(id)(?=\s+")/,[`white`,`keyword`]],[/^(\s*)(documentation)(?=\s*(?:\/\/.*)?$)/,[`white`,{token:`keyword`,next:`@descriptionBlockPending`}]],{include:`@root`}],common:c,codeBlockPending:[[/^\s*```\s*$/,{token:`string.quote`,switchTo:`@codeBlock.$S2`,nextEmbedded:`$S2`}],[/^\s*[^\s`].*$/,{token:`@rematch`,next:`@pop`}],[/\s+/,`white`]],codeBlock:[[/^\s*```\s*$/,{token:`string.quote`,next:`@pop`,nextEmbedded:`@pop`}],[/[^`]+/,``],[/`/,``]],descriptionBlockPending:[[/\/\/.*$/,`comment`],[/^\s*```(?:text|markdown)?\s*$/,{token:`string.quote`,switchTo:`@descriptionBlock`}],[/^\s*[^\s`].*$/,{token:`@rematch`,next:`@pop`}],[/\s+/,`white`]],descriptionBlock:[[/^\s*```\s*$/,{token:`string.quote`,next:`@pop`}],[/.+/,`string`]]};for(let e of l)u[subLanguageState(e.keyword)]=[subLanguageExitRule(l),...e.tokens,{include:`@common`},[/[A-Z]\w*/,`type.identifier`],[/[a-z_]\w*/,`identifier`]];return{defaultToken:``,tokenPostfix:`.play`,ignoreCase:!1,keywords:[...n.filter(e=>!o.has(e)),...e,...t],sliceTypes:i,primitiveTypes:r,tokenizer:u}}export{c as commonTokenRules,createTokensProvider};
2
2
  //# sourceMappingURL=tokens.js.map