@cratis/screenplay-language 4.52.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.
- package/dist/TypeReferenceSymbol.d.ts +8 -0
- package/dist/TypeReferenceSymbol.d.ts.map +1 -0
- package/dist/bundles/chunk-7WJEZ72S.js +4463 -0
- package/dist/bundles/chunk-7WJEZ72S.js.map +7 -0
- package/dist/bundles/index.js +1410 -0
- package/dist/bundles/index.js.map +7 -0
- package/dist/bundles/sub-languages/capture/index.js +677 -0
- package/dist/bundles/sub-languages/capture/index.js.map +7 -0
- package/dist/bundles/sub-languages/projection/index.js +1647 -0
- package/dist/bundles/sub-languages/projection/index.js.map +7 -0
- package/dist/code-actions.d.ts +3 -0
- package/dist/code-actions.d.ts.map +1 -0
- package/dist/completion-items.d.ts +1 -0
- package/dist/completion-items.d.ts.map +1 -1
- package/dist/completion-planner.d.ts.map +1 -1
- package/dist/completions.d.ts.map +1 -1
- package/dist/diagnostic-codes.d.ts +3 -0
- package/dist/diagnostic-codes.d.ts.map +1 -1
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/hover-content.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/keyword-docs.d.ts.map +1 -1
- package/dist/language.d.ts +1 -0
- package/dist/language.d.ts.map +1 -1
- package/dist/production-destinations.d.ts.map +1 -1
- package/dist/symbols.d.ts +4 -0
- package/dist/symbols.d.ts.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/validation.d.ts +1 -0
- package/dist/validation.d.ts.map +1 -1
- package/package.json +13 -9
- package/DestinationHint.ts +0 -8
- package/ProductionSymbol.ts +0 -11
- package/completion-items.ts +0 -261
- package/completion-planner.ts +0 -167
- package/completions.ts +0 -156
- package/diagnostic-codes.ts +0 -43
- package/diagnostics.ts +0 -55
- package/dist/DestinationHint.js +0 -4
- package/dist/DestinationHint.js.map +0 -1
- package/dist/ProductionSymbol.js +0 -4
- package/dist/ProductionSymbol.js.map +0 -1
- package/dist/completion-items.js +0 -228
- package/dist/completion-items.js.map +0 -1
- package/dist/completion-planner.js +0 -143
- package/dist/completion-planner.js.map +0 -1
- package/dist/completions.js +0 -101
- package/dist/completions.js.map +0 -1
- package/dist/diagnostic-codes.js +0 -41
- package/dist/diagnostic-codes.js.map +0 -1
- package/dist/diagnostics.js +0 -50
- package/dist/diagnostics.js.map +0 -1
- package/dist/document-context.js +0 -85
- package/dist/document-context.js.map +0 -1
- package/dist/event-analysis-source.js +0 -19
- package/dist/event-analysis-source.js.map +0 -1
- package/dist/event-context-catalog.js +0 -116
- package/dist/event-context-catalog.js.map +0 -1
- package/dist/event-context.js +0 -88
- package/dist/event-context.js.map +0 -1
- package/dist/file-imports.js +0 -58
- package/dist/file-imports.js.map +0 -1
- package/dist/file-references.js +0 -70
- package/dist/file-references.js.map +0 -1
- package/dist/hover-content.js +0 -98
- package/dist/hover-content.js.map +0 -1
- package/dist/hover.js +0 -15
- package/dist/hover.js.map +0 -1
- package/dist/index.js +0 -61
- package/dist/index.js.map +0 -1
- package/dist/inlay-hints.js +0 -15
- package/dist/inlay-hints.js.map +0 -1
- package/dist/inline-event-validation.js +0 -131
- package/dist/inline-event-validation.js.map +0 -1
- package/dist/keyword-docs.js +0 -148
- package/dist/keyword-docs.js.map +0 -1
- package/dist/language.js +0 -196
- package/dist/language.js.map +0 -1
- package/dist/production-destinations.js +0 -32
- package/dist/production-destinations.js.map +0 -1
- package/dist/sub-language-registry.js +0 -18
- package/dist/sub-language-registry.js.map +0 -1
- package/dist/sub-languages/capture/CompletionProvider.js +0 -332
- package/dist/sub-languages/capture/CompletionProvider.js.map +0 -1
- package/dist/sub-languages/capture/HoverProvider.js +0 -87
- package/dist/sub-languages/capture/HoverProvider.js.map +0 -1
- package/dist/sub-languages/capture/Validator.js +0 -72
- package/dist/sub-languages/capture/Validator.js.map +0 -1
- package/dist/sub-languages/capture/index.js +0 -58
- package/dist/sub-languages/capture/index.js.map +0 -1
- package/dist/sub-languages/capture/language.js +0 -160
- package/dist/sub-languages/capture/language.js.map +0 -1
- package/dist/sub-languages/cdl.js +0 -74
- package/dist/sub-languages/cdl.js.map +0 -1
- package/dist/sub-languages/pdl.js +0 -73
- package/dist/sub-languages/pdl.js.map +0 -1
- package/dist/sub-languages/projection/CodeActionProvider.js +0 -93
- package/dist/sub-languages/projection/CodeActionProvider.js.map +0 -1
- package/dist/sub-languages/projection/CompletionProvider.js +0 -595
- package/dist/sub-languages/projection/CompletionProvider.js.map +0 -1
- package/dist/sub-languages/projection/HoverProvider.js +0 -333
- package/dist/sub-languages/projection/HoverProvider.js.map +0 -1
- package/dist/sub-languages/projection/Validator.js +0 -388
- package/dist/sub-languages/projection/Validator.js.map +0 -1
- package/dist/sub-languages/projection/index.js +0 -160
- package/dist/sub-languages/projection/index.js.map +0 -1
- package/dist/sub-languages/projection/language.js +0 -171
- package/dist/sub-languages/projection/language.js.map +0 -1
- package/dist/symbols.js +0 -275
- package/dist/symbols.js.map +0 -1
- package/dist/themes/screenplay-dark.js +0 -30
- package/dist/themes/screenplay-dark.js.map +0 -1
- package/dist/themes/screenplay-light.js +0 -30
- package/dist/themes/screenplay-light.js.map +0 -1
- package/dist/tokens.js +0 -147
- package/dist/tokens.js.map +0 -1
- package/dist/validation.js +0 -248
- package/dist/validation.js.map +0 -1
- package/document-context.ts +0 -93
- package/event-analysis-source.ts +0 -18
- package/event-context-catalog.ts +0 -135
- package/event-context.ts +0 -119
- package/file-imports.ts +0 -70
- package/file-references.ts +0 -87
- package/for_documentContext/when_stripping_comments.ts +0 -32
- package/for_eventContext/when_resolving_generated_catalog_vectors.ts +0 -15
- package/for_eventGenerations/when_editing_event_generations.ts +0 -57
- package/for_fileImports/when_finding_file_imports.ts +0 -38
- package/for_fileReferences/when_recognizing_an_absolute_path/with_paths_of_every_shape.ts +0 -26
- package/for_fileReferences/when_scanning_a_document/inside_a_code_fence.ts +0 -26
- package/for_fileReferences/when_scanning_a_document/with_a_bare_file_keyword.ts +0 -19
- package/for_fileReferences/when_scanning_a_document/with_a_file_directive.ts +0 -30
- package/for_fileReferences/when_scanning_a_document/with_a_property_named_file.ts +0 -25
- package/for_fileReferences/when_scanning_a_document/with_a_trailing_comment.ts +0 -25
- package/for_fileReferences/when_scanning_a_document/with_directives_on_several_constructs.ts +0 -41
- package/for_importablePaths/when_listing_what_a_document_can_import.ts +0 -34
- package/for_inlineEvents/when_analyzing_many_inline_events.ts +0 -59
- package/for_inlineEvents/when_authoring_inline_events.ts +0 -149
- package/for_inlineEvents/when_completing_many_events.ts +0 -49
- package/for_inlineEvents/when_indexing_command_production_ownership.ts +0 -79
- package/for_planCompletions/when_completing_a_file_import.ts +0 -26
- package/for_planCompletions/when_completing_a_specification_query.ts +0 -24
- package/for_planCompletions/when_completing_a_specification_step.ts +0 -42
- package/for_planCompletions/when_completing_an_absent_read_model.ts +0 -14
- package/for_planCompletions/when_completing_reaction_reads.ts +0 -36
- package/for_projectionCompletionProvider/when_completing_an_event_context_path.ts +0 -102
- package/for_projectionHoverProvider/when_hovering_an_event_context_path.ts +0 -44
- package/for_projectionValidator/when_validating_a_projection_with_variants.ts +0 -128
- package/for_projectionValidator/when_validating_event_context_paths.ts +0 -31
- package/for_scanDocument/when_scanning_a_query/with_a_dotted_return_type.ts +0 -34
- package/for_scanDocument/when_scanning_aliased_reads.ts +0 -33
- package/for_scanDocument/when_scanning_many_commands.ts +0 -47
- package/for_tokens/when_highlighting_a_file_import.ts +0 -18
- package/for_tokens/when_highlighting_event_metadata.ts +0 -63
- package/for_tokens/when_highlighting_specification_steps.ts +0 -28
- package/for_validateLines/when_validating_a_document/with_a_problem_of_every_coded_kind.ts +0 -77
- package/for_validateLines/when_validating_a_document/with_an_unknown_policy.ts +0 -33
- package/for_validateLines/when_validating_a_file_placed_by_an_import/with_names_declared_in_other_files.ts +0 -43
- package/for_validateLines/when_validating_event_context_paths/in_a_projection.ts +0 -97
- package/for_validateLines/when_validating_file_imports/at_every_level.ts +0 -36
- package/for_validateLines/when_validating_production_destinations/with_an_available_identifier.ts +0 -120
- package/hover-content.ts +0 -117
- package/hover.ts +0 -23
- package/index.ts +0 -125
- package/inlay-hints.ts +0 -17
- package/inline-event-validation.ts +0 -115
- package/keyword-docs.ts +0 -152
- package/language.ts +0 -212
- package/production-destinations.ts +0 -32
- package/sub-language-registry.ts +0 -42
- package/sub-languages/capture/CompletionProvider.ts +0 -365
- package/sub-languages/capture/HoverProvider.ts +0 -99
- package/sub-languages/capture/Validator.ts +0 -97
- package/sub-languages/capture/index.ts +0 -72
- package/sub-languages/capture/language.ts +0 -176
- package/sub-languages/cdl.ts +0 -76
- package/sub-languages/pdl.ts +0 -75
- package/sub-languages/projection/CodeActionProvider.ts +0 -123
- package/sub-languages/projection/CompletionProvider.ts +0 -660
- package/sub-languages/projection/HoverProvider.ts +0 -377
- package/sub-languages/projection/Validator.ts +0 -441
- package/sub-languages/projection/index.ts +0 -223
- package/sub-languages/projection/language.ts +0 -193
- package/symbols.ts +0 -374
- package/themes/screenplay-dark.ts +0 -33
- package/themes/screenplay-light.ts +0 -33
- package/tokens.ts +0 -174
- package/validation.ts +0 -443
- 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
|
-
};
|
package/sub-languages/cdl.ts
DELETED
|
@@ -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
|
-
};
|
package/sub-languages/pdl.ts
DELETED
|
@@ -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
|
-
}
|