@cratis/screenplay-language 4.51.0 → 4.53.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 (190) hide show
  1. package/dist/TypeReferenceSymbol.d.ts +8 -0
  2. package/dist/TypeReferenceSymbol.d.ts.map +1 -0
  3. package/dist/bundles/chunk-7WJEZ72S.js +4463 -0
  4. package/dist/bundles/chunk-7WJEZ72S.js.map +7 -0
  5. package/dist/bundles/index.js +1410 -0
  6. package/dist/bundles/index.js.map +7 -0
  7. package/dist/bundles/sub-languages/capture/index.js +677 -0
  8. package/dist/bundles/sub-languages/capture/index.js.map +7 -0
  9. package/dist/bundles/sub-languages/projection/index.js +1647 -0
  10. package/dist/bundles/sub-languages/projection/index.js.map +7 -0
  11. package/dist/code-actions.d.ts +3 -0
  12. package/dist/code-actions.d.ts.map +1 -0
  13. package/dist/completion-items.d.ts +1 -0
  14. package/dist/completion-items.d.ts.map +1 -1
  15. package/dist/completion-planner.d.ts.map +1 -1
  16. package/dist/completions.d.ts.map +1 -1
  17. package/dist/diagnostic-codes.d.ts +3 -0
  18. package/dist/diagnostic-codes.d.ts.map +1 -1
  19. package/dist/diagnostics.d.ts.map +1 -1
  20. package/dist/hover-content.d.ts.map +1 -1
  21. package/dist/index.d.ts +3 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/keyword-docs.d.ts.map +1 -1
  24. package/dist/language.d.ts +1 -0
  25. package/dist/language.d.ts.map +1 -1
  26. package/dist/production-destinations.d.ts.map +1 -1
  27. package/dist/symbols.d.ts +4 -0
  28. package/dist/symbols.d.ts.map +1 -1
  29. package/dist/tokens.d.ts.map +1 -1
  30. package/dist/validation.d.ts +1 -0
  31. package/dist/validation.d.ts.map +1 -1
  32. package/package.json +13 -9
  33. package/DestinationHint.ts +0 -8
  34. package/ProductionSymbol.ts +0 -11
  35. package/completion-items.ts +0 -261
  36. package/completion-planner.ts +0 -167
  37. package/completions.ts +0 -156
  38. package/diagnostic-codes.ts +0 -43
  39. package/diagnostics.ts +0 -55
  40. package/dist/DestinationHint.js +0 -4
  41. package/dist/DestinationHint.js.map +0 -1
  42. package/dist/ProductionSymbol.js +0 -4
  43. package/dist/ProductionSymbol.js.map +0 -1
  44. package/dist/completion-items.js +0 -228
  45. package/dist/completion-items.js.map +0 -1
  46. package/dist/completion-planner.js +0 -143
  47. package/dist/completion-planner.js.map +0 -1
  48. package/dist/completions.js +0 -101
  49. package/dist/completions.js.map +0 -1
  50. package/dist/diagnostic-codes.js +0 -41
  51. package/dist/diagnostic-codes.js.map +0 -1
  52. package/dist/diagnostics.js +0 -50
  53. package/dist/diagnostics.js.map +0 -1
  54. package/dist/document-context.js +0 -85
  55. package/dist/document-context.js.map +0 -1
  56. package/dist/event-analysis-source.js +0 -19
  57. package/dist/event-analysis-source.js.map +0 -1
  58. package/dist/event-context-catalog.js +0 -116
  59. package/dist/event-context-catalog.js.map +0 -1
  60. package/dist/event-context.js +0 -88
  61. package/dist/event-context.js.map +0 -1
  62. package/dist/file-imports.js +0 -58
  63. package/dist/file-imports.js.map +0 -1
  64. package/dist/file-references.js +0 -70
  65. package/dist/file-references.js.map +0 -1
  66. package/dist/hover-content.js +0 -98
  67. package/dist/hover-content.js.map +0 -1
  68. package/dist/hover.js +0 -15
  69. package/dist/hover.js.map +0 -1
  70. package/dist/index.js +0 -61
  71. package/dist/index.js.map +0 -1
  72. package/dist/inlay-hints.js +0 -15
  73. package/dist/inlay-hints.js.map +0 -1
  74. package/dist/inline-event-validation.js +0 -131
  75. package/dist/inline-event-validation.js.map +0 -1
  76. package/dist/keyword-docs.js +0 -148
  77. package/dist/keyword-docs.js.map +0 -1
  78. package/dist/language.js +0 -196
  79. package/dist/language.js.map +0 -1
  80. package/dist/production-destinations.js +0 -32
  81. package/dist/production-destinations.js.map +0 -1
  82. package/dist/sub-language-registry.js +0 -18
  83. package/dist/sub-language-registry.js.map +0 -1
  84. package/dist/sub-languages/capture/CompletionProvider.js +0 -332
  85. package/dist/sub-languages/capture/CompletionProvider.js.map +0 -1
  86. package/dist/sub-languages/capture/HoverProvider.js +0 -87
  87. package/dist/sub-languages/capture/HoverProvider.js.map +0 -1
  88. package/dist/sub-languages/capture/Validator.js +0 -72
  89. package/dist/sub-languages/capture/Validator.js.map +0 -1
  90. package/dist/sub-languages/capture/index.js +0 -58
  91. package/dist/sub-languages/capture/index.js.map +0 -1
  92. package/dist/sub-languages/capture/language.js +0 -160
  93. package/dist/sub-languages/capture/language.js.map +0 -1
  94. package/dist/sub-languages/cdl.js +0 -74
  95. package/dist/sub-languages/cdl.js.map +0 -1
  96. package/dist/sub-languages/pdl.js +0 -73
  97. package/dist/sub-languages/pdl.js.map +0 -1
  98. package/dist/sub-languages/projection/CodeActionProvider.js +0 -93
  99. package/dist/sub-languages/projection/CodeActionProvider.js.map +0 -1
  100. package/dist/sub-languages/projection/CompletionProvider.js +0 -595
  101. package/dist/sub-languages/projection/CompletionProvider.js.map +0 -1
  102. package/dist/sub-languages/projection/HoverProvider.js +0 -333
  103. package/dist/sub-languages/projection/HoverProvider.js.map +0 -1
  104. package/dist/sub-languages/projection/Validator.js +0 -388
  105. package/dist/sub-languages/projection/Validator.js.map +0 -1
  106. package/dist/sub-languages/projection/index.js +0 -160
  107. package/dist/sub-languages/projection/index.js.map +0 -1
  108. package/dist/sub-languages/projection/language.js +0 -171
  109. package/dist/sub-languages/projection/language.js.map +0 -1
  110. package/dist/symbols.js +0 -275
  111. package/dist/symbols.js.map +0 -1
  112. package/dist/themes/screenplay-dark.js +0 -30
  113. package/dist/themes/screenplay-dark.js.map +0 -1
  114. package/dist/themes/screenplay-light.js +0 -30
  115. package/dist/themes/screenplay-light.js.map +0 -1
  116. package/dist/tokens.js +0 -147
  117. package/dist/tokens.js.map +0 -1
  118. package/dist/validation.js +0 -248
  119. package/dist/validation.js.map +0 -1
  120. package/document-context.ts +0 -93
  121. package/event-analysis-source.ts +0 -18
  122. package/event-context-catalog.ts +0 -135
  123. package/event-context.ts +0 -119
  124. package/file-imports.ts +0 -70
  125. package/file-references.ts +0 -87
  126. package/for_documentContext/when_stripping_comments.ts +0 -32
  127. package/for_eventContext/when_resolving_generated_catalog_vectors.ts +0 -15
  128. package/for_eventGenerations/when_editing_event_generations.ts +0 -57
  129. package/for_fileImports/when_finding_file_imports.ts +0 -38
  130. package/for_fileReferences/when_recognizing_an_absolute_path/with_paths_of_every_shape.ts +0 -26
  131. package/for_fileReferences/when_scanning_a_document/inside_a_code_fence.ts +0 -26
  132. package/for_fileReferences/when_scanning_a_document/with_a_bare_file_keyword.ts +0 -19
  133. package/for_fileReferences/when_scanning_a_document/with_a_file_directive.ts +0 -30
  134. package/for_fileReferences/when_scanning_a_document/with_a_property_named_file.ts +0 -25
  135. package/for_fileReferences/when_scanning_a_document/with_a_trailing_comment.ts +0 -25
  136. package/for_fileReferences/when_scanning_a_document/with_directives_on_several_constructs.ts +0 -41
  137. package/for_importablePaths/when_listing_what_a_document_can_import.ts +0 -34
  138. package/for_inlineEvents/when_analyzing_many_inline_events.ts +0 -59
  139. package/for_inlineEvents/when_authoring_inline_events.ts +0 -149
  140. package/for_inlineEvents/when_completing_many_events.ts +0 -49
  141. package/for_inlineEvents/when_indexing_command_production_ownership.ts +0 -79
  142. package/for_planCompletions/when_completing_a_file_import.ts +0 -26
  143. package/for_planCompletions/when_completing_a_specification_query.ts +0 -24
  144. package/for_planCompletions/when_completing_a_specification_step.ts +0 -42
  145. package/for_planCompletions/when_completing_an_absent_read_model.ts +0 -14
  146. package/for_planCompletions/when_completing_reaction_reads.ts +0 -36
  147. package/for_projectionCompletionProvider/when_completing_an_event_context_path.ts +0 -102
  148. package/for_projectionHoverProvider/when_hovering_an_event_context_path.ts +0 -44
  149. package/for_projectionValidator/when_validating_a_projection_with_variants.ts +0 -128
  150. package/for_projectionValidator/when_validating_event_context_paths.ts +0 -31
  151. package/for_scanDocument/when_scanning_a_query/with_a_dotted_return_type.ts +0 -34
  152. package/for_scanDocument/when_scanning_aliased_reads.ts +0 -33
  153. package/for_scanDocument/when_scanning_many_commands.ts +0 -47
  154. package/for_tokens/when_highlighting_a_file_import.ts +0 -18
  155. package/for_tokens/when_highlighting_event_metadata.ts +0 -63
  156. package/for_tokens/when_highlighting_specification_steps.ts +0 -28
  157. package/for_validateLines/when_validating_a_document/with_a_problem_of_every_coded_kind.ts +0 -77
  158. package/for_validateLines/when_validating_a_document/with_an_unknown_policy.ts +0 -33
  159. package/for_validateLines/when_validating_a_file_placed_by_an_import/with_names_declared_in_other_files.ts +0 -43
  160. package/for_validateLines/when_validating_event_context_paths/in_a_projection.ts +0 -97
  161. package/for_validateLines/when_validating_file_imports/at_every_level.ts +0 -36
  162. package/for_validateLines/when_validating_production_destinations/with_an_available_identifier.ts +0 -120
  163. package/hover-content.ts +0 -117
  164. package/hover.ts +0 -23
  165. package/index.ts +0 -125
  166. package/inlay-hints.ts +0 -17
  167. package/inline-event-validation.ts +0 -115
  168. package/keyword-docs.ts +0 -152
  169. package/language.ts +0 -212
  170. package/production-destinations.ts +0 -32
  171. package/sub-language-registry.ts +0 -42
  172. package/sub-languages/capture/CompletionProvider.ts +0 -365
  173. package/sub-languages/capture/HoverProvider.ts +0 -99
  174. package/sub-languages/capture/Validator.ts +0 -97
  175. package/sub-languages/capture/index.ts +0 -72
  176. package/sub-languages/capture/language.ts +0 -176
  177. package/sub-languages/cdl.ts +0 -76
  178. package/sub-languages/pdl.ts +0 -75
  179. package/sub-languages/projection/CodeActionProvider.ts +0 -123
  180. package/sub-languages/projection/CompletionProvider.ts +0 -660
  181. package/sub-languages/projection/HoverProvider.ts +0 -377
  182. package/sub-languages/projection/Validator.ts +0 -441
  183. package/sub-languages/projection/index.ts +0 -223
  184. package/sub-languages/projection/language.ts +0 -193
  185. package/symbols.ts +0 -374
  186. package/themes/screenplay-dark.ts +0 -33
  187. package/themes/screenplay-light.ts +0 -33
  188. package/tokens.ts +0 -174
  189. package/validation.ts +0 -443
  190. package/vitest.setup.ts +0 -5
@@ -1,176 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import type { languages } from 'monaco-editor';
5
-
6
- export type Monaco = typeof import('monaco-editor');
7
-
8
- // Capture Declaration Language (CDL) — Chronicle's DSL for declaring change-data-capture
9
- // rules, registered here as its own standalone top-level Monaco language. This is distinct
10
- // from the lightweight CDL sub-language embedded inside a `.play` document's `capture`
11
- // blocks (../cdl.ts) — this module owns its own language id, tokenizer, and providers.
12
- export const languageId = 'cdl';
13
-
14
- // `route`/`poll` are API source properties; `path` is the webhook inbound path; `topic`
15
- // is the message source subject. There is no `auth`/`bearer`/`url` — an API source
16
- // references a named External Service (`api <ServiceName>`) for base URL and auth, and
17
- // a webhook source's authentication is configured on the source builder, not in CDL text.
18
- const KEYWORDS = [
19
- 'capture',
20
- 'source',
21
- 'key',
22
- 'map',
23
- 'append',
24
- 'when',
25
- 'nested',
26
- 'children',
27
- 'identified',
28
- 'by',
29
- 'api',
30
- 'webhook',
31
- 'message',
32
- 'route',
33
- 'poll',
34
- 'path',
35
- 'topic',
36
- 'from',
37
- 'to',
38
- 'or',
39
- 'and',
40
- 'added',
41
- 'removed',
42
- 'translate',
43
- 'split',
44
- ] as const;
45
-
46
- const BUILTINS = [
47
- '$context',
48
- '$previous',
49
- '$env',
50
- ] as const;
51
-
52
- const OPERATORS = ['=', '=>', '.'];
53
-
54
- export const languageConfiguration: languages.LanguageConfiguration = {
55
- comments: {
56
- lineComment: '#',
57
- },
58
- brackets: [
59
- ['{', '}'],
60
- ['[', ']'],
61
- ['(', ')'],
62
- ],
63
- autoClosingPairs: [
64
- { open: '{', close: '}' },
65
- { open: '[', close: ']' },
66
- { open: '(', close: ')' },
67
- { open: '"', close: '"' },
68
- { open: "'", close: "'" },
69
- { open: '`', close: '`' },
70
- ],
71
- surroundingPairs: [
72
- { open: '{', close: '}' },
73
- { open: '[', close: ']' },
74
- { open: '(', close: ')' },
75
- { open: '"', close: '"' },
76
- { open: "'", close: "'" },
77
- { open: '`', close: '`' },
78
- ],
79
- indentationRules: {
80
- increaseIndentPattern: /^.*(\bcapture\b\s+\S+|\bsource\b(?:\s+\w+)?|\bmap\b|\bappend\b\s+\S+|\bnested\b\s+\S+|\bchildren\b\s+\S+.*|\btranslate\b|\bsplit\b.*)\s*$/,
81
- decreaseIndentPattern: /^.*\}.*$/,
82
- },
83
- folding: {
84
- offSide: true,
85
- markers: {
86
- start: /^\s*(capture|source|map|append|nested|children|translate|split)/,
87
- end: /^\s*$/,
88
- },
89
- },
90
- wordPattern: /[$]?[a-zA-Z_][\w$-]*/,
91
- };
92
-
93
- export const monarchLanguage: languages.IMonarchLanguage = {
94
- defaultToken: '',
95
- tokenPostfix: '.cdl',
96
-
97
- keywords: KEYWORDS,
98
- builtins: BUILTINS,
99
- operators: OPERATORS,
100
-
101
- symbols: /[=><!~?:&|+\-*/^%]+/,
102
- escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
103
-
104
- tokenizer: {
105
- root: [
106
- { include: '@whitespace' },
107
- [/`/, { token: 'string.template', next: '@templateString' }],
108
- [/\$\.(?:[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)?/, 'variable'],
109
- [/\$previous(?:\.[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)?/, 'variable.predefined'],
110
- [/\$context(?:\.(?:occurred|eventSourceId))?/, 'variable.predefined'],
111
- [/\$env(?:\.[A-Z_][A-Z0-9_]*)?/, 'variable.predefined'],
112
- [/@[a-zA-Z_$][\w$]*/, 'identifier.escape'],
113
- [
114
- /[A-Z][a-zA-Z_$][\w$]*/,
115
- {
116
- cases: {
117
- '@keywords': 'invalid',
118
- '@default': 'identifier',
119
- },
120
- },
121
- ],
122
- [
123
- /[a-z_$][\w$]*/,
124
- {
125
- cases: {
126
- '@keywords': 'keyword',
127
- '@builtins': 'variable.predefined',
128
- '@default': 'identifier',
129
- },
130
- },
131
- ],
132
- [/[{}()[\]]/, '@brackets'],
133
- [/=>/, 'operator.arrow'],
134
- [
135
- /@symbols/,
136
- {
137
- cases: {
138
- '@operators': 'operator',
139
- '@default': '',
140
- },
141
- },
142
- ],
143
- [/\d*\.\d+([eE][-+]?\d+)?/, 'number.float'],
144
- [/0[xX][0-9a-fA-F]+/, 'number.hex'],
145
- [/\d+/, 'number'],
146
- [/[;,.]/, 'delimiter'],
147
- [/"([^"\\]|\\.)*$/, 'string.invalid'],
148
- [/"/, { token: 'string.quote', next: '@string' }],
149
- ],
150
-
151
- whitespace: [
152
- [/[ \t\r\n]+/, ''],
153
- [/#.*$/, 'comment'],
154
- ],
155
-
156
- templateString: [
157
- [/\$\{/, { token: 'delimiter.bracket', next: '@templateExpression' }],
158
- [/[^\\`$]+/, 'string.template'],
159
- [/@escapes/, 'string.template.escape'],
160
- [/\\./, 'string.template.escape.invalid'],
161
- [/`/, { token: 'string.template', next: '@pop' }],
162
- ],
163
-
164
- templateExpression: [
165
- [/\}/, { token: 'delimiter.bracket', next: '@pop' }],
166
- { include: '@root' },
167
- ],
168
-
169
- string: [
170
- [/[^\\"]+/, 'string'],
171
- [/@escapes/, 'string.escape'],
172
- [/\\./, 'string.escape.invalid'],
173
- [/"/, { token: 'string.quote', next: '@pop' }],
174
- ],
175
- },
176
- };
@@ -1,76 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import { SubLanguageDefinition } from '../sub-language-registry';
5
-
6
- // Change Data Capture Language (CDL) — embedded inside `capture` blocks. This is the
7
- // lightweight definition mixed into the composite `.play` tokenizer; the full standalone
8
- // CDL language (its own tokenizer, context-aware completions, hover, and validation) lives
9
- // in `./capture` and is what `@cratis/screenplay-language/capture` exposes to consumers.
10
- export const cdl: SubLanguageDefinition = {
11
- tokens: [
12
- [
13
- /\b(?:source|api|route|poll|path|topic|key|map|translate|split|append|tag|when|children|nested|identified|by|from|to|and|or|added|removed)\b/,
14
- 'keyword',
15
- ],
16
- ],
17
- completions: [
18
- {
19
- label: 'source',
20
- insertText: 'source ${1:api}',
21
- documentation: 'Declares where the captured data comes from.',
22
- },
23
- {
24
- label: 'key',
25
- insertText: 'key ${1:property}',
26
- documentation: 'Declares which source property identifies an instance.',
27
- },
28
- {
29
- label: 'map',
30
- insertText: 'map\n ${1:property} = ${2:source}',
31
- documentation: 'Maps and translates source values before events are appended.',
32
- },
33
- {
34
- label: 'append',
35
- insertText: 'append ${1:EventType}\n when ${2:property}',
36
- documentation: 'Appends an event when the source data changes.',
37
- },
38
- {
39
- label: 'translate',
40
- insertText: 'translate\n "${1:source}" => ${2:target}',
41
- documentation: 'Translates source values into Screenplay values.',
42
- },
43
- {
44
- label: 'children',
45
- insertText: 'children ${1:collection} identified by ${2:key}',
46
- documentation: 'Captures changes in a child collection of the source data.',
47
- },
48
- {
49
- label: 'when added',
50
- insertText: 'when added',
51
- documentation: 'Appends the event when a new item appears in the source.',
52
- },
53
- {
54
- label: 'when removed',
55
- insertText: 'when removed',
56
- documentation: 'Appends the event when an item disappears from the source.',
57
- },
58
- ],
59
- hovers: {
60
- source: 'CDL — declares where the captured data comes from.',
61
- api: 'CDL — as a source type, polls an HTTP API; as a source property (`api <ServiceName>`), references a named External Service for the base URL and authentication.',
62
- route: 'CDL — optional path appended to an API source\'s External Service base URL.',
63
- poll: 'CDL — the polling interval for an API source, e.g. 5m.',
64
- path: 'CDL — the inbound path a webhook source listens on.',
65
- topic: 'CDL — the topic a message source subscribes to.',
66
- key: 'CDL — declares which source property identifies an instance.',
67
- map: 'CDL — maps and translates source values before events are appended.',
68
- translate: 'CDL — translates source values into Screenplay values.',
69
- append: 'CDL — appends an event when the source data changes.',
70
- when: 'CDL — the change condition: a property change, added, or removed.',
71
- added: 'CDL — matches items that appear in the source.',
72
- removed: 'CDL — matches items that disappear from the source.',
73
- children: 'CDL — captures changes in a child collection of the source data.',
74
- identified: 'CDL — introduces the identifying key of a child collection.',
75
- },
76
- };
@@ -1,75 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import { SubLanguageDefinition } from '../sub-language-registry';
5
-
6
- // Projection Declaration Language (PDL) — embedded inside `projection` blocks.
7
- // See https://www.cratis.io/chronicle/projections/projection-declaration-language/grammar/
8
- export const pdl: SubLanguageDefinition = {
9
- tokens: [
10
- [
11
- /\b(?:from|every|all|nested|join|children|identified|by|key|parent|with|remove|via|clear|on|sequence|automap|no|exclude|literal|set|increment|decrement|add|subtract|count)\b/,
12
- 'keyword',
13
- ],
14
- ],
15
- completions: [
16
- {
17
- label: 'key',
18
- insertText: 'key ${1:property}',
19
- documentation: 'Declares which property identifies the read model instance.',
20
- },
21
- {
22
- label: 'from',
23
- insertText: 'from ${1:EventType}',
24
- documentation: 'Maps properties from an event onto the read model.',
25
- },
26
- {
27
- label: 'join',
28
- insertText: 'join ${1:property} on ${2:key}',
29
- documentation: 'Joins related state onto the read model by a key property.',
30
- },
31
- {
32
- label: 'children',
33
- insertText: 'children ${1:collection} identified by ${2:key}',
34
- documentation: 'Projects events into a child collection on the read model.',
35
- },
36
- {
37
- label: 'remove with',
38
- insertText: 'remove with ${1:EventType}',
39
- documentation: 'Removes the read model instance when the event occurs.',
40
- },
41
- {
42
- label: 'parent',
43
- insertText: 'parent ${1:property}',
44
- documentation: 'Declares the property that identifies the parent of a child.',
45
- },
46
- {
47
- label: 'clear',
48
- insertText: 'clear ${1:property}',
49
- documentation: 'Removes the value a property holds when the event occurs.',
50
- },
51
- {
52
- label: 'increment',
53
- insertText: 'increment ${1:property}',
54
- documentation: 'Increments a numeric property when the event occurs.',
55
- },
56
- {
57
- label: 'decrement',
58
- insertText: 'decrement ${1:property}',
59
- documentation: 'Decrements a numeric property when the event occurs.',
60
- },
61
- ],
62
- hovers: {
63
- from: 'PDL — maps properties from an event onto the read model.',
64
- every: 'PDL — applies property mappings for every event type in the projection.',
65
- join: 'PDL — joins related state onto the read model by a key property.',
66
- children: 'PDL — projects events into a child collection on the read model.',
67
- identified: 'PDL — introduces the identifying key of a child collection.',
68
- key: 'PDL — declares which property identifies the read model instance.',
69
- parent: 'PDL — declares the property that identifies the parent of a child.',
70
- remove: 'PDL — removes the read model instance when an event occurs.',
71
- clear: 'PDL — clear <property> removes the value a property holds; clear with <EventType> nulls a nested object.',
72
- increment: 'PDL — increments a numeric property when the event occurs.',
73
- decrement: 'PDL — decrements a numeric property when the event occurs.',
74
- },
75
- };
@@ -1,123 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import type * as Monaco from 'monaco-editor';
5
- import type { JsonSchema, ReadModelInfo, DraftReadModelInfo } from './index';
6
-
7
- export class CodeActionProvider {
8
- private readModels: ReadModelInfo[] = [];
9
- private draftReadModel: DraftReadModelInfo | null = null;
10
- private onCreateReadModel?: (readModelName: string) => void;
11
- private onEditReadModel?: (readModelName: string, currentSchema: JsonSchema) => void;
12
-
13
- setReadModels(readModels: ReadModelInfo[]): void {
14
- this.readModels = readModels;
15
- }
16
-
17
- setDraftReadModel(draft: DraftReadModelInfo | null): void {
18
- this.draftReadModel = draft;
19
- }
20
-
21
- // Keep for backwards compatibility
22
- setReadModelSchemas(schemas: JsonSchema[]): void {
23
- this.readModels = schemas.map(schema => ({
24
- identifier: schema.title || schema.name || '',
25
- displayName: schema.title || schema.name || '',
26
- schema
27
- }));
28
- }
29
-
30
- setCreateReadModelCallback(callback: (readModelName: string) => void): void {
31
- this.onCreateReadModel = callback;
32
- }
33
-
34
- setEditReadModelCallback(callback: (readModelName: string, currentSchema: JsonSchema) => void): void {
35
- this.onEditReadModel = callback;
36
- }
37
-
38
- invokeCreateReadModel(readModelName: string): void {
39
- this.onCreateReadModel?.(readModelName);
40
- }
41
-
42
- invokeEditReadModel(readModelName: string, currentSchema: JsonSchema): void {
43
- this.onEditReadModel?.(readModelName, currentSchema);
44
- }
45
-
46
- provideCodeActions(
47
- _model: Monaco.editor.ITextModel,
48
- _range: Monaco.Range,
49
- context: Monaco.languages.CodeActionContext
50
- ): Monaco.languages.ProviderResult<Monaco.languages.CodeActionList> {
51
- const actions: Monaco.languages.CodeAction[] = [];
52
-
53
- // Check for diagnostics about undefined read models (errors)
54
- const notFoundDiagnostics = context.markers.filter(
55
- (marker: Monaco.editor.IMarkerData) => marker.message.includes("Read model") && marker.message.includes("not found")
56
- );
57
-
58
- // Check for diagnostics about draft read models (info markers)
59
- const draftDiagnostics = context.markers.filter(
60
- (marker: Monaco.editor.IMarkerData) => marker.message.includes("Read model") && marker.message.includes("is a draft")
61
- );
62
-
63
- // Handle "not found" errors - offer to create
64
- for (const diagnostic of notFoundDiagnostics) {
65
- const match = diagnostic.message.match(/Read model ['"]([\w.]+)['"]/);
66
- if (match && match[1]) {
67
- const readModelName = match[1];
68
-
69
- // Check if this read model already exists as a persisted read model
70
- const existsAsPersisted = this.readModels.some(
71
- rm => rm.identifier === readModelName || rm.displayName === readModelName
72
- );
73
-
74
- if (!existsAsPersisted && this.onCreateReadModel) {
75
- actions.push({
76
- title: `Create read model '${readModelName}'`,
77
- diagnostics: [diagnostic],
78
- kind: 'quickfix',
79
- edit: undefined,
80
- isPreferred: true,
81
- command: {
82
- id: 'pdl.createReadModel',
83
- title: `Create ${readModelName}`,
84
- arguments: [readModelName]
85
- }
86
- });
87
- }
88
- }
89
- }
90
-
91
- // Handle draft read model info markers - offer to edit
92
- for (const diagnostic of draftDiagnostics) {
93
- const match = diagnostic.message.match(/Read model ['"]([\w.]+)['"]/);
94
- if (match && match[1]) {
95
- const readModelName = match[1];
96
-
97
- if (this.draftReadModel && this.isDraftReadModel(readModelName) && this.onEditReadModel) {
98
- actions.push({
99
- title: `Edit read model '${readModelName}'`,
100
- diagnostics: [diagnostic],
101
- kind: 'quickfix',
102
- edit: undefined,
103
- isPreferred: true,
104
- command: {
105
- id: 'pdl.editReadModel',
106
- title: `Edit ${readModelName}`,
107
- arguments: [readModelName, this.draftReadModel.schema]
108
- }
109
- });
110
- }
111
- }
112
- }
113
-
114
- return {
115
- actions,
116
- dispose: () => { /* No cleanup needed */ }
117
- };
118
- }
119
-
120
- private isDraftReadModel(readModelToken: string): boolean {
121
- return !!this.draftReadModel && (this.draftReadModel.identifier === readModelToken || this.draftReadModel.displayName === readModelToken);
122
- }
123
- }