agentlang 0.7.9 → 0.7.11

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 (131) hide show
  1. package/out/api/http.d.ts.map +1 -1
  2. package/out/api/http.js +8 -1
  3. package/out/api/http.js.map +1 -1
  4. package/out/cli/main.d.ts.map +1 -1
  5. package/out/cli/main.js +33 -2
  6. package/out/cli/main.js.map +1 -1
  7. package/out/extension/main.cjs +250 -250
  8. package/out/extension/main.cjs.map +2 -2
  9. package/out/language/agentlang-validator.d.ts +1 -2
  10. package/out/language/agentlang-validator.d.ts.map +1 -1
  11. package/out/language/agentlang-validator.js +0 -39
  12. package/out/language/agentlang-validator.js.map +1 -1
  13. package/out/language/generated/ast.d.ts +62 -11
  14. package/out/language/generated/ast.d.ts.map +1 -1
  15. package/out/language/generated/ast.js +75 -3
  16. package/out/language/generated/ast.js.map +1 -1
  17. package/out/language/generated/grammar.d.ts.map +1 -1
  18. package/out/language/generated/grammar.js +758 -239
  19. package/out/language/generated/grammar.js.map +1 -1
  20. package/out/language/main.cjs +1370 -824
  21. package/out/language/main.cjs.map +4 -4
  22. package/out/language/parser.d.ts +1 -0
  23. package/out/language/parser.d.ts.map +1 -1
  24. package/out/language/parser.js +44 -7
  25. package/out/language/parser.js.map +1 -1
  26. package/out/language/syntax.d.ts +1 -1
  27. package/out/language/syntax.d.ts.map +1 -1
  28. package/out/language/syntax.js +22 -13
  29. package/out/language/syntax.js.map +1 -1
  30. package/out/runtime/api.d.ts +2 -0
  31. package/out/runtime/api.d.ts.map +1 -1
  32. package/out/runtime/api.js +5 -0
  33. package/out/runtime/api.js.map +1 -1
  34. package/out/runtime/auth/cognito.d.ts.map +1 -1
  35. package/out/runtime/auth/cognito.js +4 -4
  36. package/out/runtime/auth/cognito.js.map +1 -1
  37. package/out/runtime/defs.d.ts +5 -0
  38. package/out/runtime/defs.d.ts.map +1 -1
  39. package/out/runtime/defs.js +16 -0
  40. package/out/runtime/defs.js.map +1 -1
  41. package/out/runtime/exec-graph.js +1 -1
  42. package/out/runtime/exec-graph.js.map +1 -1
  43. package/out/runtime/interpreter.d.ts +6 -1
  44. package/out/runtime/interpreter.d.ts.map +1 -1
  45. package/out/runtime/interpreter.js +144 -112
  46. package/out/runtime/interpreter.js.map +1 -1
  47. package/out/runtime/loader.d.ts +1 -1
  48. package/out/runtime/loader.d.ts.map +1 -1
  49. package/out/runtime/loader.js +74 -27
  50. package/out/runtime/loader.js.map +1 -1
  51. package/out/runtime/module.d.ts +41 -11
  52. package/out/runtime/module.d.ts.map +1 -1
  53. package/out/runtime/module.js +238 -50
  54. package/out/runtime/module.js.map +1 -1
  55. package/out/runtime/modules/ai.d.ts.map +1 -1
  56. package/out/runtime/modules/ai.js +13 -6
  57. package/out/runtime/modules/ai.js.map +1 -1
  58. package/out/runtime/modules/auth.d.ts +2 -1
  59. package/out/runtime/modules/auth.d.ts.map +1 -1
  60. package/out/runtime/modules/auth.js +93 -3
  61. package/out/runtime/modules/auth.js.map +1 -1
  62. package/out/runtime/modules/core.d.ts +7 -5
  63. package/out/runtime/modules/core.d.ts.map +1 -1
  64. package/out/runtime/modules/core.js +93 -16
  65. package/out/runtime/modules/core.js.map +1 -1
  66. package/out/runtime/monitor.d.ts.map +1 -1
  67. package/out/runtime/monitor.js +1 -0
  68. package/out/runtime/monitor.js.map +1 -1
  69. package/out/runtime/resolvers/interface.d.ts +6 -1
  70. package/out/runtime/resolvers/interface.d.ts.map +1 -1
  71. package/out/runtime/resolvers/interface.js +2 -2
  72. package/out/runtime/resolvers/interface.js.map +1 -1
  73. package/out/runtime/resolvers/sqldb/database.d.ts +19 -2
  74. package/out/runtime/resolvers/sqldb/database.d.ts.map +1 -1
  75. package/out/runtime/resolvers/sqldb/database.js +107 -21
  76. package/out/runtime/resolvers/sqldb/database.js.map +1 -1
  77. package/out/runtime/resolvers/sqldb/dbutil.d.ts +1 -0
  78. package/out/runtime/resolvers/sqldb/dbutil.d.ts.map +1 -1
  79. package/out/runtime/resolvers/sqldb/dbutil.js +25 -3
  80. package/out/runtime/resolvers/sqldb/dbutil.js.map +1 -1
  81. package/out/runtime/resolvers/sqldb/impl.d.ts +3 -2
  82. package/out/runtime/resolvers/sqldb/impl.d.ts.map +1 -1
  83. package/out/runtime/resolvers/sqldb/impl.js +80 -6
  84. package/out/runtime/resolvers/sqldb/impl.js.map +1 -1
  85. package/out/runtime/state.d.ts +58 -0
  86. package/out/runtime/state.d.ts.map +1 -1
  87. package/out/runtime/state.js +12 -0
  88. package/out/runtime/state.js.map +1 -1
  89. package/out/runtime/util.d.ts +1 -1
  90. package/out/runtime/util.d.ts.map +1 -1
  91. package/out/runtime/util.js +27 -13
  92. package/out/runtime/util.js.map +1 -1
  93. package/out/setupClassic.d.ts +98 -0
  94. package/out/setupClassic.d.ts.map +1 -0
  95. package/out/setupClassic.js +38 -0
  96. package/out/setupClassic.js.map +1 -0
  97. package/out/setupCommon.d.ts +2 -0
  98. package/out/setupCommon.d.ts.map +1 -0
  99. package/out/setupCommon.js +33 -0
  100. package/out/setupCommon.js.map +1 -0
  101. package/out/setupExtended.d.ts +40 -0
  102. package/out/setupExtended.d.ts.map +1 -0
  103. package/out/setupExtended.js +67 -0
  104. package/out/setupExtended.js.map +1 -0
  105. package/out/syntaxes/agentlang.monarch.js +1 -1
  106. package/out/syntaxes/agentlang.monarch.js.map +1 -1
  107. package/package.json +187 -185
  108. package/src/api/http.ts +8 -0
  109. package/src/cli/main.ts +38 -2
  110. package/src/language/agentlang-validator.ts +1 -51
  111. package/src/language/agentlang.langium +17 -4
  112. package/src/language/generated/ast.ts +147 -13
  113. package/src/language/generated/grammar.ts +758 -239
  114. package/src/language/parser.ts +43 -8
  115. package/src/language/syntax.ts +25 -12
  116. package/src/runtime/api.ts +8 -0
  117. package/src/runtime/defs.ts +8 -0
  118. package/src/runtime/interpreter.ts +104 -76
  119. package/src/runtime/loader.ts +75 -25
  120. package/src/runtime/module.ts +194 -32
  121. package/src/runtime/modules/ai.ts +10 -4
  122. package/src/runtime/modules/auth.ts +1 -0
  123. package/src/runtime/modules/core.ts +99 -23
  124. package/src/runtime/monitor.ts +1 -0
  125. package/src/runtime/resolvers/interface.ts +9 -2
  126. package/src/runtime/resolvers/sqldb/database.ts +68 -17
  127. package/src/runtime/resolvers/sqldb/dbutil.ts +28 -6
  128. package/src/runtime/resolvers/sqldb/impl.ts +86 -14
  129. package/src/runtime/state.ts +14 -0
  130. package/src/runtime/util.ts +25 -12
  131. package/src/syntaxes/agentlang.monarch.ts +1 -1
package/src/api/http.ts CHANGED
@@ -48,6 +48,7 @@ import {
48
48
  PathAttributeNameQuery,
49
49
  setEntityEndpointsUpdater,
50
50
  setEventEndpointsUpdater,
51
+ setRelationshipEndpointsUpdater,
51
52
  UnauthorisedError,
52
53
  } from '../runtime/defs.js';
53
54
  import { evaluate } from '../runtime/interpreter.js';
@@ -311,6 +312,13 @@ export async function startServer(
311
312
  addEntityHandlers(moduleName, n);
312
313
  });
313
314
  });
315
+ setRelationshipEndpointsUpdater((moduleName: string) => {
316
+ const m = fetchModule(moduleName);
317
+ const relNames = m.getBetweenRelationshipNames();
318
+ relNames.forEach((n: string) => {
319
+ addBetweenHandlers(moduleName, n);
320
+ });
321
+ });
314
322
  }
315
323
 
316
324
  function ok(res: Response) {
package/src/cli/main.ts CHANGED
@@ -17,7 +17,7 @@ import * as url from 'node:url';
17
17
  import * as fs from 'node:fs/promises';
18
18
  import * as path from 'node:path';
19
19
  import { logger, updateLoggerFromConfig } from '../runtime/logger.js';
20
- import { Module } from '../runtime/module.js';
20
+ import { Instance, Module } from '../runtime/module.js';
21
21
  import { ModuleDefinition } from '../language/generated/ast.js';
22
22
  import { Config } from '../runtime/state.js';
23
23
  import { prepareIntegrations } from '../runtime/integrations.js';
@@ -32,6 +32,7 @@ import { importModule } from '../runtime/jsmodules.js';
32
32
  import {
33
33
  isRuntimeMode_dev,
34
34
  isRuntimeMode_prod,
35
+ isRuntimeMode_test,
35
36
  setInternDynamicModuleFn,
36
37
  setRuntimeMode_generate_migration,
37
38
  setRuntimeMode_init_schema,
@@ -41,7 +42,11 @@ import {
41
42
  updateEndpoints,
42
43
  } from '../runtime/defs.js';
43
44
  import { initGlobalApi } from '../runtime/api.js';
44
- import { initCoreModuleManager } from '../runtime/modules/core.js';
45
+ import {
46
+ initCoreModuleManager,
47
+ lookupTimersWithRunningStatus,
48
+ triggerTimer,
49
+ } from '../runtime/modules/core.js';
45
50
 
46
51
  const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
47
52
 
@@ -134,6 +139,7 @@ export async function runPostInitTasks(appSpec?: ApplicationSpec, config?: Confi
134
139
  await runInitFunctions();
135
140
  await runStandaloneStatements();
136
141
  initCoreModuleManager();
142
+ await runPersistedTimers();
137
143
  logger.info(
138
144
  `Running application ${appSpec?.name || 'unknown'} version ${appSpec?.version || 'unknown'} on port ${config?.service?.port || 8080}`
139
145
  );
@@ -169,6 +175,36 @@ export async function runPreInitTasks(): Promise<boolean> {
169
175
  return result;
170
176
  }
171
177
 
178
+ async function runPersistedTimers() {
179
+ if (!isRuntimeMode_test()) {
180
+ const insts: Instance[] = await lookupTimersWithRunningStatus();
181
+ if (insts) {
182
+ for (let i = 0; i < insts.length; ++i) {
183
+ const inst: Instance = insts[i];
184
+ if (await restartTimer(inst)) {
185
+ logger.info(`Timer ${inst.lookup('name')} setup to restart`);
186
+ }
187
+ }
188
+ }
189
+ }
190
+ }
191
+
192
+ async function restartTimer(timerInst: Instance): Promise<boolean> {
193
+ const n = timerInst.lookup('name');
194
+ try {
195
+ if (isRuntimeMode_prod()) {
196
+ // TODO: create and configure an independent timer-managerment service.
197
+ logger.warn(`Cannot restart timer ${n}, timer management service is not configured`);
198
+ } else {
199
+ triggerTimer(timerInst);
200
+ return true;
201
+ }
202
+ } catch (reason: any) {
203
+ logger.warn(`Error while restarting timer ${n} - ${reason}`);
204
+ }
205
+ return false;
206
+ }
207
+
172
208
  async function internDynamicModule(name: string, definition: string): Promise<string> {
173
209
  await refreshModuleDefinition(name, definition);
174
210
  await resetDefaultDatabase();
@@ -1,11 +1,5 @@
1
1
  import type { ValidationAcceptor, ValidationChecks } from 'langium';
2
- import {
3
- AgentlangAstType,
4
- AttributeDefinition,
5
- isStandaloneStatement,
6
- ModuleDefinition,
7
- SchemaDefinition,
8
- } from './generated/ast.js';
2
+ import { AgentlangAstType, AttributeDefinition, SchemaDefinition } from './generated/ast.js';
9
3
  import type { AgentlangServices } from './agentlang-module.js';
10
4
 
11
5
  /**
@@ -15,7 +9,6 @@ export function registerValidationChecks(services: AgentlangServices) {
15
9
  const registry = services.validation.ValidationRegistry;
16
10
  const validator = services.validation.AgentlangValidator;
17
11
  const checks: ValidationChecks<AgentlangAstType> = {
18
- ModuleDefinition: validator.checkUniqueDefs,
19
12
  SchemaDefinition: validator.checkUniqueAttributes,
20
13
  };
21
14
  registry.register(checks, validator);
@@ -25,49 +18,6 @@ export function registerValidationChecks(services: AgentlangServices) {
25
18
  * Implementation of custom validations.
26
19
  */
27
20
  export class AgentlangValidator {
28
- // our new validation function for defs
29
- checkUniqueDefs(module: ModuleDefinition, accept: ValidationAcceptor): void {
30
- // create a set of visited functions
31
- // and report an error when we see one we've already seen
32
- const reported = new Set();
33
- module.defs.forEach(d => {
34
- let n: string | undefined;
35
- if (!isStandaloneStatement(d)) {
36
- if (
37
- d.$type === 'PublicWorkflowDefinition' ||
38
- d.$type === 'PublicAgentDefinition' ||
39
- d.$type === 'PublicEventDefinition'
40
- ) {
41
- n = d.def.name;
42
- } else {
43
- n = d.name;
44
- }
45
- if (
46
- d.$type != 'WorkflowDefinition' &&
47
- d.$type != 'FlowDefinition' &&
48
- d.$type != 'PublicWorkflowDefinition' &&
49
- d.$type != 'ScenarioDefinition' &&
50
- d.$type != 'DirectiveDefinition' &&
51
- d.$type != 'GlossaryEntryDefinition' &&
52
- reported.has(n)
53
- ) {
54
- accept('error', `Definition has non-unique name '${n}'.`, {
55
- node: d,
56
- property: 'name',
57
- });
58
- }
59
- if (
60
- d.$type != 'FlowDefinition' &&
61
- d.$type != 'ScenarioDefinition' &&
62
- d.$type != 'DirectiveDefinition' &&
63
- d.$type != 'GlossaryEntryDefinition'
64
- ) {
65
- reported.add(n);
66
- }
67
- }
68
- });
69
- }
70
-
71
21
  checkUniqueAttributes(def: SchemaDefinition, accept: ValidationAcceptor): void {
72
22
  // create a set of visited functions
73
23
  // and report an error when we see one we've already seen
@@ -119,8 +119,11 @@ CrudMap: '{' (name=QueryId (':')? '{''}'
119
119
  | (name=QualifiedName (':')? '{''}' ',' '@from' source=Literal (',' upsert+='@upsert')?)
120
120
  | name=QualifiedName (':')? body=CrudMapBody)
121
121
  (',' relationships+=RelationshipPattern (',' relationships+=RelationshipPattern)*)?
122
- (',' join=JoinSpec)?
122
+ (',' joins+=JoinSpec)*
123
123
  (',' into=SelectIntoSpec)?
124
+ (',' where=WhereSpec)?
125
+ (',' groupByClause=GroupByClause)?
126
+ (',' orderByClause=OrderByClause)?
124
127
  (',' upsert+='@upsert')?
125
128
  (',' distinct+='@distinct')?
126
129
  '}';
@@ -129,12 +132,18 @@ CrudMapBody: '{' (attributes+=SetAttribute (',' attributes+=SetAttribute)*)+ pro
129
132
 
130
133
  SelectIntoSpec: '@into' '{' entries+=SelectIntoEntry (',' entries+=SelectIntoEntry)* '}';
131
134
 
132
- SelectIntoEntry: alias=ID (':')? attribute=Ref;
135
+ SelectIntoEntry: alias=ID (':')? (attribute=Ref | aggregate=AggregateFunctionSpec);
133
136
 
134
137
  JoinSpec: type=JoinType name=QualifiedName '{' lhs=QueryId op=SqlComparisonOpr? rhs=Ref '}';
135
138
 
136
139
  JoinType returns string: ('@join' | '@inner_join' | '@left_join' | '@right_join' | '@full_join');
137
140
 
141
+ WhereSpec: '@where' ('{' (clauses+=WhereSpecClause (',' clauses+=WhereSpecClause)*)+ '}');
142
+ WhereSpecClause: lhs=QueryId op=SqlComparisonOpr? rhs=Expr;
143
+
144
+ GroupByClause: '@groupBy' ('(' (colNames+=QualifiedName (',' colNames+=QualifiedName)*)+ ')');
145
+ OrderByClause: '@orderBy' ('(' (colNames+=QualifiedName (',' colNames+=QualifiedName)*)+ ')') (order=('@asc' | '@desc'))?;
146
+
138
147
  FullTextSearch: '{' name=QueryId query=Literal options=MapLiteral? '}';
139
148
 
140
149
  Return: 'return' pattern=Pattern;
@@ -179,9 +188,11 @@ RetryDefinition: 'agentlang/retry' name=ID '{' ('attempts' attempts=Decimal)? ('
179
188
 
180
189
  BackoffSpec: 'backoff' '{' (attributes+=SetAttribute (',' attributes+=SetAttribute)*)+ '}';
181
190
 
182
- ResolverDefinition: 'resolver' name=GenericName '[' (paths+=GenericName (',' paths+=GenericName)*)+ ']'
191
+ ResolverDefinition: 'resolver' name=QualifiedName '[' (paths+=ResolverPathEntry (',' paths+=ResolverPathEntry)*)+ ']'
183
192
  '{' (methods+=ResolverMethodSpec (',' methods+=ResolverMethodSpec)*)+ '}';
184
193
 
194
+ ResolverPathEntry returns string: QualifiedName | GenericName;
195
+
185
196
  ResolverMethodSpec: key=ResolverMethodName fn=ResolverFnName;
186
197
 
187
198
  ResolverFnName: name=(ID | Ref | STRING);
@@ -204,7 +215,7 @@ Delete: 'delete' pattern=Pattern;
204
215
 
205
216
  Purge: 'purge' pattern=Pattern;
206
217
 
207
- SetAttribute: name=QueryId op=SqlComparisonOpr? (':')? value=AttributeValueExpression;
218
+ SetAttribute: name=QueryId op=SqlComparisonOpr? (':')? (value=AttributeValueExpression | aggregate=AggregateFunctionSpec);
208
219
 
209
220
  SqlComparisonOpr returns string: ('='|'<>' | '!=' |'<'|'<='|'>'|'>='|'in'|'like'|'between');
210
221
 
@@ -226,6 +237,8 @@ Comparison infers Expr:
226
237
 
227
238
  PrimExpr: Literal | Group | NegExpr | NotExpr;
228
239
 
240
+ AggregateFunctionSpec: '@' name=ID (('(' ')') | ('(' (args+=QualifiedName (',' args+=QualifiedName)*)+ ')'));
241
+
229
242
  // grouped expression with parentheses
230
243
  Group: '(' ge=Expr ')';
231
244
  // negated expression
@@ -42,26 +42,31 @@ export type AgentlangKeywordNames =
42
42
  | "@actions"
43
43
  | "@after"
44
44
  | "@as"
45
+ | "@asc"
45
46
  | "@async"
46
47
  | "@before"
47
48
  | "@catch"
49
+ | "@desc"
48
50
  | "@distinct"
49
51
  | "@enum"
50
52
  | "@expr"
51
53
  | "@from"
52
54
  | "@full_join"
55
+ | "@groupBy"
53
56
  | "@inner_join"
54
57
  | "@into"
55
58
  | "@join"
56
59
  | "@left_join"
57
60
  | "@meta"
58
61
  | "@oneof"
62
+ | "@orderBy"
59
63
  | "@public"
60
64
  | "@rbac"
61
65
  | "@ref"
62
66
  | "@right_join"
63
67
  | "@then"
64
68
  | "@upsert"
69
+ | "@where"
65
70
  | "@with_unique"
66
71
  | "["
67
72
  | "]"
@@ -203,6 +208,12 @@ export function isRef(item: unknown): item is Ref {
203
208
  return typeof item === 'string';
204
209
  }
205
210
 
211
+ export type ResolverPathEntry = GenericName | QualifiedName;
212
+
213
+ export function isResolverPathEntry(item: unknown): item is ResolverPathEntry {
214
+ return isQualifiedName(item) || isGenericName(item);
215
+ }
216
+
206
217
  export type SchemaDefinition = EntityDefinition | EventDefinition | PublicEventDefinition | RecordDefinition;
207
218
 
208
219
  export const SchemaDefinition = 'SchemaDefinition';
@@ -298,6 +309,19 @@ export function isAgentXtraSpec(item: unknown): item is AgentXtraSpec {
298
309
  return reflection.isInstance(item, AgentXtraSpec);
299
310
  }
300
311
 
312
+ export interface AggregateFunctionSpec extends langium.AstNode {
313
+ readonly $container: SelectIntoEntry | SetAttribute;
314
+ readonly $type: 'AggregateFunctionSpec';
315
+ args: Array<QualifiedName>;
316
+ name: string;
317
+ }
318
+
319
+ export const AggregateFunctionSpec = 'AggregateFunctionSpec';
320
+
321
+ export function isAggregateFunctionSpec(item: unknown): item is AggregateFunctionSpec {
322
+ return reflection.isInstance(item, AggregateFunctionSpec);
323
+ }
324
+
301
325
  export interface AliasSpec extends langium.AstNode {
302
326
  readonly $container: RuntimeHint;
303
327
  readonly $type: 'AliasSpec';
@@ -379,7 +403,7 @@ export function isBeforeTriggerDefinition(item: unknown): item is BeforeTriggerD
379
403
  }
380
404
 
381
405
  export interface BinExpr extends langium.AstNode {
382
- readonly $container: AttributeDefinition | BinExpr | CaseEntry | FnCall | Group | If | MapEntry | NegExpr | NotExpr | Pattern | SetAttribute | ThrowError;
406
+ readonly $container: AttributeDefinition | BinExpr | CaseEntry | FnCall | Group | If | MapEntry | NegExpr | NotExpr | Pattern | SetAttribute | ThrowError | WhereSpecClause;
383
407
  readonly $type: 'BinExpr';
384
408
  e1: Expr | PrimExpr;
385
409
  e2: Expr | PrimExpr;
@@ -447,12 +471,15 @@ export interface CrudMap extends langium.AstNode {
447
471
  readonly $type: 'CrudMap';
448
472
  body?: CrudMapBody;
449
473
  distinct: Array<'@distinct'>;
474
+ groupByClause?: GroupByClause;
450
475
  into?: SelectIntoSpec;
451
- join?: JoinSpec;
476
+ joins: Array<JoinSpec>;
452
477
  name: QualifiedName | QueryId;
478
+ orderByClause?: OrderByClause;
453
479
  relationships: Array<RelationshipPattern>;
454
480
  source?: Literal;
455
481
  upsert: Array<'@upsert'>;
482
+ where?: WhereSpec;
456
483
  }
457
484
 
458
485
  export const CrudMap = 'CrudMap';
@@ -722,7 +749,7 @@ export function isGlossaryEntryDefinition(item: unknown): item is GlossaryEntryD
722
749
  }
723
750
 
724
751
  export interface Group extends langium.AstNode {
725
- readonly $container: AttributeDefinition | BinExpr | CaseEntry | FnCall | Group | If | MapEntry | NegExpr | NotExpr | Pattern | SetAttribute | ThrowError;
752
+ readonly $container: AttributeDefinition | BinExpr | CaseEntry | FnCall | Group | If | MapEntry | NegExpr | NotExpr | Pattern | SetAttribute | ThrowError | WhereSpecClause;
726
753
  readonly $type: 'Group';
727
754
  ge: Expr;
728
755
  }
@@ -733,6 +760,18 @@ export function isGroup(item: unknown): item is Group {
733
760
  return reflection.isInstance(item, Group);
734
761
  }
735
762
 
763
+ export interface GroupByClause extends langium.AstNode {
764
+ readonly $container: CrudMap;
765
+ readonly $type: 'GroupByClause';
766
+ colNames: Array<QualifiedName>;
767
+ }
768
+
769
+ export const GroupByClause = 'GroupByClause';
770
+
771
+ export function isGroupByClause(item: unknown): item is GroupByClause {
772
+ return reflection.isInstance(item, GroupByClause);
773
+ }
774
+
736
775
  export interface Handler extends langium.AstNode {
737
776
  readonly $container: CatchSpec;
738
777
  readonly $type: 'Handler';
@@ -815,7 +854,7 @@ export function isKvPairs(item: unknown): item is KvPairs {
815
854
  }
816
855
 
817
856
  export interface Literal extends langium.AstNode {
818
- readonly $container: AttributeDefinition | BinExpr | CaseEntry | CrudMap | FnCall | FullTextSearch | GenericPropertyDef | Group | If | KvPair | MapEntry | NegExpr | NotExpr | Pattern | SetAttribute | ThrowError;
857
+ readonly $container: AttributeDefinition | BinExpr | CaseEntry | CrudMap | FnCall | FullTextSearch | GenericPropertyDef | Group | If | KvPair | MapEntry | NegExpr | NotExpr | Pattern | SetAttribute | ThrowError | WhereSpecClause;
819
858
  readonly $type: 'Literal';
820
859
  array?: ArrayLiteral;
821
860
  asyncFnCall?: AsyncFnCall;
@@ -899,7 +938,7 @@ export function isModuleDefinition(item: unknown): item is ModuleDefinition {
899
938
  }
900
939
 
901
940
  export interface NegExpr extends langium.AstNode {
902
- readonly $container: AttributeDefinition | BinExpr | CaseEntry | FnCall | Group | If | MapEntry | NegExpr | NotExpr | Pattern | SetAttribute | ThrowError;
941
+ readonly $container: AttributeDefinition | BinExpr | CaseEntry | FnCall | Group | If | MapEntry | NegExpr | NotExpr | Pattern | SetAttribute | ThrowError | WhereSpecClause;
903
942
  readonly $type: 'NegExpr';
904
943
  ne: Expr;
905
944
  }
@@ -924,7 +963,7 @@ export function isNodeDefinition(item: unknown): item is NodeDefinition {
924
963
  }
925
964
 
926
965
  export interface NotExpr extends langium.AstNode {
927
- readonly $container: AttributeDefinition | BinExpr | CaseEntry | FnCall | Group | If | MapEntry | NegExpr | NotExpr | Pattern | SetAttribute | ThrowError;
966
+ readonly $container: AttributeDefinition | BinExpr | CaseEntry | FnCall | Group | If | MapEntry | NegExpr | NotExpr | Pattern | SetAttribute | ThrowError | WhereSpecClause;
928
967
  readonly $type: 'NotExpr';
929
968
  ne: Expr;
930
969
  }
@@ -947,6 +986,19 @@ export function isOneOfSpec(item: unknown): item is OneOfSpec {
947
986
  return reflection.isInstance(item, OneOfSpec);
948
987
  }
949
988
 
989
+ export interface OrderByClause extends langium.AstNode {
990
+ readonly $container: CrudMap;
991
+ readonly $type: 'OrderByClause';
992
+ colNames: Array<QualifiedName>;
993
+ order?: '@asc' | '@desc';
994
+ }
995
+
996
+ export const OrderByClause = 'OrderByClause';
997
+
998
+ export function isOrderByClause(item: unknown): item is OrderByClause {
999
+ return reflection.isInstance(item, OrderByClause);
1000
+ }
1001
+
950
1002
  export interface Pattern extends langium.AstNode {
951
1003
  readonly $container: Delete | ForEach | Purge | RelationshipPattern | Return | Statement;
952
1004
  readonly $type: 'Pattern';
@@ -1230,8 +1282,8 @@ export interface ResolverDefinition extends langium.AstNode {
1230
1282
  readonly $container: ModuleDefinition;
1231
1283
  readonly $type: 'ResolverDefinition';
1232
1284
  methods: Array<ResolverMethodSpec>;
1233
- name: GenericName;
1234
- paths: Array<GenericName>;
1285
+ name: QualifiedName;
1286
+ paths: Array<ResolverPathEntry>;
1235
1287
  }
1236
1288
 
1237
1289
  export const ResolverDefinition = 'ResolverDefinition';
@@ -1334,8 +1386,9 @@ export function isScenarioDefinition(item: unknown): item is ScenarioDefinition
1334
1386
  export interface SelectIntoEntry extends langium.AstNode {
1335
1387
  readonly $container: SelectIntoSpec;
1336
1388
  readonly $type: 'SelectIntoEntry';
1389
+ aggregate?: AggregateFunctionSpec;
1337
1390
  alias: string;
1338
- attribute: Ref;
1391
+ attribute?: Ref;
1339
1392
  }
1340
1393
 
1341
1394
  export const SelectIntoEntry = 'SelectIntoEntry';
@@ -1359,9 +1412,10 @@ export function isSelectIntoSpec(item: unknown): item is SelectIntoSpec {
1359
1412
  export interface SetAttribute extends langium.AstNode {
1360
1413
  readonly $container: BackoffSpec | CrudMapBody;
1361
1414
  readonly $type: 'SetAttribute';
1415
+ aggregate?: AggregateFunctionSpec;
1362
1416
  name: QueryId;
1363
1417
  op?: SqlComparisonOpr;
1364
- value: AttributeValueExpression;
1418
+ value?: AttributeValueExpression;
1365
1419
  }
1366
1420
 
1367
1421
  export const SetAttribute = 'SetAttribute';
@@ -1445,6 +1499,32 @@ export function isTriggerEntry(item: unknown): item is TriggerEntry {
1445
1499
  return reflection.isInstance(item, TriggerEntry);
1446
1500
  }
1447
1501
 
1502
+ export interface WhereSpec extends langium.AstNode {
1503
+ readonly $container: CrudMap;
1504
+ readonly $type: 'WhereSpec';
1505
+ clauses: Array<WhereSpecClause>;
1506
+ }
1507
+
1508
+ export const WhereSpec = 'WhereSpec';
1509
+
1510
+ export function isWhereSpec(item: unknown): item is WhereSpec {
1511
+ return reflection.isInstance(item, WhereSpec);
1512
+ }
1513
+
1514
+ export interface WhereSpecClause extends langium.AstNode {
1515
+ readonly $container: WhereSpec;
1516
+ readonly $type: 'WhereSpecClause';
1517
+ lhs: QueryId;
1518
+ op?: SqlComparisonOpr;
1519
+ rhs: Expr;
1520
+ }
1521
+
1522
+ export const WhereSpecClause = 'WhereSpecClause';
1523
+
1524
+ export function isWhereSpecClause(item: unknown): item is WhereSpecClause {
1525
+ return reflection.isInstance(item, WhereSpecClause);
1526
+ }
1527
+
1448
1528
  export interface WorkflowDefinition extends langium.AstNode {
1449
1529
  readonly $container: ModuleDefinition | PublicWorkflowDefinition;
1450
1530
  readonly $type: 'WorkflowDefinition';
@@ -1479,6 +1559,7 @@ export type AgentlangAstType = {
1479
1559
  AgentDefinition: AgentDefinition
1480
1560
  AgentXtraAttribute: AgentXtraAttribute
1481
1561
  AgentXtraSpec: AgentXtraSpec
1562
+ AggregateFunctionSpec: AggregateFunctionSpec
1482
1563
  AliasSpec: AliasSpec
1483
1564
  ArrayLiteral: ArrayLiteral
1484
1565
  AsyncFnCall: AsyncFnCall
@@ -1516,6 +1597,7 @@ export type AgentlangAstType = {
1516
1597
  GenericPropertyDef: GenericPropertyDef
1517
1598
  GlossaryEntryDefinition: GlossaryEntryDefinition
1518
1599
  Group: Group
1600
+ GroupByClause: GroupByClause
1519
1601
  Handler: Handler
1520
1602
  If: If
1521
1603
  Import: Import
@@ -1532,6 +1614,7 @@ export type AgentlangAstType = {
1532
1614
  NodeDefinition: NodeDefinition
1533
1615
  NotExpr: NotExpr
1534
1616
  OneOfSpec: OneOfSpec
1617
+ OrderByClause: OrderByClause
1535
1618
  Pattern: Pattern
1536
1619
  PrePostTriggerDefinition: PrePostTriggerDefinition
1537
1620
  PrimExpr: PrimExpr
@@ -1572,6 +1655,8 @@ export type AgentlangAstType = {
1572
1655
  ThrowError: ThrowError
1573
1656
  TriggerDefinition: TriggerDefinition
1574
1657
  TriggerEntry: TriggerEntry
1658
+ WhereSpec: WhereSpec
1659
+ WhereSpecClause: WhereSpecClause
1575
1660
  WorkflowDefinition: WorkflowDefinition
1576
1661
  WorkflowHeader: WorkflowHeader
1577
1662
  }
@@ -1579,7 +1664,7 @@ export type AgentlangAstType = {
1579
1664
  export class AgentlangAstReflection extends langium.AbstractAstReflection {
1580
1665
 
1581
1666
  getAllTypes(): string[] {
1582
- return [ActionEntry, AfterTriggerDefinition, AgentDefinition, AgentXtraAttribute, AgentXtraSpec, AliasSpec, ArrayLiteral, AsyncFnCall, AttributeDefinition, AttributeValueExpression, BackoffSpec, BeforeTriggerDefinition, BinExpr, CaseEntry, CatchSpec, CompositeUniqueDefinition, ConditionalFlowStep, CrudMap, CrudMapBody, DecisionDefBody, DecisionDefinition, Definition, Delete, DirectiveDefinition, Else, EntityActionsDefinitions, EntityDefinition, EnumSpec, EventDefinition, Expr, ExtendsClause, FlowDefBody, FlowDefinition, FlowEntry, FlowStepSpec, FnCall, ForEach, FullTextSearch, GenericDefBody, GenericPropertyDef, GlossaryEntryDefinition, Group, Handler, If, Import, JoinSpec, KvPair, KvPairs, Literal, MapEntry, MapKey, MapLiteral, MetaDefinition, ModuleDefinition, NegExpr, NodeDefinition, NotExpr, OneOfSpec, Pattern, PrePostTriggerDefinition, PrimExpr, PropertyDefinition, PublicAgentDefinition, PublicEventDefinition, PublicWorkflowDefinition, Purge, RbacAllowSpec, RbacExpressionSpec, RbacOpr, RbacRolesSpec, RbacSpecDefinition, RbacSpecEntries, RbacSpecEntry, RecordDefinition, RecordExtraDefinition, RecordSchemaDefinition, RefSpec, RelNodes, RelationshipDefinition, RelationshipPattern, ResolverDefinition, ResolverFnName, ResolverMethodName, ResolverMethodSpec, RetryDefinition, Return, RuntimeHint, ScenarioDefinition, SchemaDefinition, SelectIntoEntry, SelectIntoSpec, SetAttribute, StandaloneStatement, Statement, ThenSpec, ThrowError, TriggerDefinition, TriggerEntry, WorkflowDefinition, WorkflowHeader];
1667
+ return [ActionEntry, AfterTriggerDefinition, AgentDefinition, AgentXtraAttribute, AgentXtraSpec, AggregateFunctionSpec, AliasSpec, ArrayLiteral, AsyncFnCall, AttributeDefinition, AttributeValueExpression, BackoffSpec, BeforeTriggerDefinition, BinExpr, CaseEntry, CatchSpec, CompositeUniqueDefinition, ConditionalFlowStep, CrudMap, CrudMapBody, DecisionDefBody, DecisionDefinition, Definition, Delete, DirectiveDefinition, Else, EntityActionsDefinitions, EntityDefinition, EnumSpec, EventDefinition, Expr, ExtendsClause, FlowDefBody, FlowDefinition, FlowEntry, FlowStepSpec, FnCall, ForEach, FullTextSearch, GenericDefBody, GenericPropertyDef, GlossaryEntryDefinition, Group, GroupByClause, Handler, If, Import, JoinSpec, KvPair, KvPairs, Literal, MapEntry, MapKey, MapLiteral, MetaDefinition, ModuleDefinition, NegExpr, NodeDefinition, NotExpr, OneOfSpec, OrderByClause, Pattern, PrePostTriggerDefinition, PrimExpr, PropertyDefinition, PublicAgentDefinition, PublicEventDefinition, PublicWorkflowDefinition, Purge, RbacAllowSpec, RbacExpressionSpec, RbacOpr, RbacRolesSpec, RbacSpecDefinition, RbacSpecEntries, RbacSpecEntry, RecordDefinition, RecordExtraDefinition, RecordSchemaDefinition, RefSpec, RelNodes, RelationshipDefinition, RelationshipPattern, ResolverDefinition, ResolverFnName, ResolverMethodName, ResolverMethodSpec, RetryDefinition, Return, RuntimeHint, ScenarioDefinition, SchemaDefinition, SelectIntoEntry, SelectIntoSpec, SetAttribute, StandaloneStatement, Statement, ThenSpec, ThrowError, TriggerDefinition, TriggerEntry, WhereSpec, WhereSpecClause, WorkflowDefinition, WorkflowHeader];
1583
1668
  }
1584
1669
 
1585
1670
  protected override computeIsSubtype(subtype: string, supertype: string): boolean {
@@ -1682,6 +1767,15 @@ export class AgentlangAstReflection extends langium.AbstractAstReflection {
1682
1767
  ]
1683
1768
  };
1684
1769
  }
1770
+ case AggregateFunctionSpec: {
1771
+ return {
1772
+ name: AggregateFunctionSpec,
1773
+ properties: [
1774
+ { name: 'args', defaultValue: [] },
1775
+ { name: 'name' }
1776
+ ]
1777
+ };
1778
+ }
1685
1779
  case AliasSpec: {
1686
1780
  return {
1687
1781
  name: AliasSpec,
@@ -1788,12 +1882,15 @@ export class AgentlangAstReflection extends langium.AbstractAstReflection {
1788
1882
  properties: [
1789
1883
  { name: 'body' },
1790
1884
  { name: 'distinct', defaultValue: [] },
1885
+ { name: 'groupByClause' },
1791
1886
  { name: 'into' },
1792
- { name: 'join' },
1887
+ { name: 'joins', defaultValue: [] },
1793
1888
  { name: 'name' },
1889
+ { name: 'orderByClause' },
1794
1890
  { name: 'relationships', defaultValue: [] },
1795
1891
  { name: 'source' },
1796
- { name: 'upsert', defaultValue: [] }
1892
+ { name: 'upsert', defaultValue: [] },
1893
+ { name: 'where' }
1797
1894
  ]
1798
1895
  };
1799
1896
  }
@@ -1985,6 +2082,14 @@ export class AgentlangAstReflection extends langium.AbstractAstReflection {
1985
2082
  ]
1986
2083
  };
1987
2084
  }
2085
+ case GroupByClause: {
2086
+ return {
2087
+ name: GroupByClause,
2088
+ properties: [
2089
+ { name: 'colNames', defaultValue: [] }
2090
+ ]
2091
+ };
2092
+ }
1988
2093
  case Handler: {
1989
2094
  return {
1990
2095
  name: Handler,
@@ -2136,6 +2241,15 @@ export class AgentlangAstReflection extends langium.AbstractAstReflection {
2136
2241
  ]
2137
2242
  };
2138
2243
  }
2244
+ case OrderByClause: {
2245
+ return {
2246
+ name: OrderByClause,
2247
+ properties: [
2248
+ { name: 'colNames', defaultValue: [] },
2249
+ { name: 'order' }
2250
+ ]
2251
+ };
2252
+ }
2139
2253
  case Pattern: {
2140
2254
  return {
2141
2255
  name: Pattern,
@@ -2408,6 +2522,7 @@ export class AgentlangAstReflection extends langium.AbstractAstReflection {
2408
2522
  return {
2409
2523
  name: SelectIntoEntry,
2410
2524
  properties: [
2525
+ { name: 'aggregate' },
2411
2526
  { name: 'alias' },
2412
2527
  { name: 'attribute' }
2413
2528
  ]
@@ -2425,6 +2540,7 @@ export class AgentlangAstReflection extends langium.AbstractAstReflection {
2425
2540
  return {
2426
2541
  name: SetAttribute,
2427
2542
  properties: [
2543
+ { name: 'aggregate' },
2428
2544
  { name: 'name' },
2429
2545
  { name: 'op' },
2430
2546
  { name: 'value' }
@@ -2482,6 +2598,24 @@ export class AgentlangAstReflection extends langium.AbstractAstReflection {
2482
2598
  ]
2483
2599
  };
2484
2600
  }
2601
+ case WhereSpec: {
2602
+ return {
2603
+ name: WhereSpec,
2604
+ properties: [
2605
+ { name: 'clauses', defaultValue: [] }
2606
+ ]
2607
+ };
2608
+ }
2609
+ case WhereSpecClause: {
2610
+ return {
2611
+ name: WhereSpecClause,
2612
+ properties: [
2613
+ { name: 'lhs' },
2614
+ { name: 'op' },
2615
+ { name: 'rhs' }
2616
+ ]
2617
+ };
2618
+ }
2485
2619
  case WorkflowDefinition: {
2486
2620
  return {
2487
2621
  name: WorkflowDefinition,