agentlang 0.0.32 → 0.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +10 -2
  2. package/out/api/http.d.ts.map +1 -1
  3. package/out/api/http.js +13 -6
  4. package/out/api/http.js.map +1 -1
  5. package/out/language/generated/ast.d.ts +1 -1
  6. package/out/language/generated/ast.d.ts.map +1 -1
  7. package/out/language/generated/grammar.js +1 -1
  8. package/out/language/main.cjs +1 -1
  9. package/out/language/main.cjs.map +1 -1
  10. package/out/language/parser.d.ts.map +1 -1
  11. package/out/language/parser.js +21 -8
  12. package/out/language/parser.js.map +1 -1
  13. package/out/language/syntax.d.ts +8 -1
  14. package/out/language/syntax.d.ts.map +1 -1
  15. package/out/language/syntax.js +23 -2
  16. package/out/language/syntax.js.map +1 -1
  17. package/out/runtime/defs.d.ts +1 -0
  18. package/out/runtime/defs.d.ts.map +1 -1
  19. package/out/runtime/defs.js +1 -0
  20. package/out/runtime/defs.js.map +1 -1
  21. package/out/runtime/interpreter.d.ts +2 -1
  22. package/out/runtime/interpreter.d.ts.map +1 -1
  23. package/out/runtime/interpreter.js +27 -6
  24. package/out/runtime/interpreter.js.map +1 -1
  25. package/out/runtime/module.d.ts +5 -1
  26. package/out/runtime/module.d.ts.map +1 -1
  27. package/out/runtime/module.js +15 -2
  28. package/out/runtime/module.js.map +1 -1
  29. package/out/runtime/modules/ai.js +1 -1
  30. package/out/runtime/modules/core.d.ts.map +1 -1
  31. package/out/runtime/modules/core.js +3 -2
  32. package/out/runtime/modules/core.js.map +1 -1
  33. package/out/runtime/resolvers/sqldb/database.d.ts +1 -0
  34. package/out/runtime/resolvers/sqldb/database.d.ts.map +1 -1
  35. package/out/runtime/resolvers/sqldb/database.js +11 -1
  36. package/out/runtime/resolvers/sqldb/database.js.map +1 -1
  37. package/out/runtime/resolvers/sqldb/impl.d.ts.map +1 -1
  38. package/out/runtime/resolvers/sqldb/impl.js +4 -2
  39. package/out/runtime/resolvers/sqldb/impl.js.map +1 -1
  40. package/package.json +1 -1
  41. package/src/api/http.ts +13 -5
  42. package/src/language/agentlang.langium +1 -1
  43. package/src/language/generated/ast.ts +1 -1
  44. package/src/language/generated/grammar.ts +1 -1
  45. package/src/language/parser.ts +24 -10
  46. package/src/language/syntax.ts +30 -4
  47. package/src/runtime/defs.ts +2 -0
  48. package/src/runtime/interpreter.ts +32 -6
  49. package/src/runtime/module.ts +18 -3
  50. package/src/runtime/modules/ai.ts +1 -1
  51. package/src/runtime/modules/core.ts +3 -2
  52. package/src/runtime/resolvers/sqldb/database.ts +22 -1
  53. package/src/runtime/resolvers/sqldb/impl.ts +4 -2
@@ -19,7 +19,12 @@ import {
19
19
  } from '../../module.js';
20
20
  import pgvector from 'pgvector';
21
21
  import { isString } from '../../util.js';
22
- import { DeletedFlagAttributeName, PathAttributeName, UnauthorisedError } from '../../defs.js';
22
+ import {
23
+ DeletedFlagAttributeName,
24
+ ForceReadPermFlag,
25
+ PathAttributeName,
26
+ UnauthorisedError,
27
+ } from '../../defs.js';
23
28
 
24
29
  export let defaultDataSource: DataSource | undefined;
25
30
 
@@ -110,6 +115,10 @@ export class DbContext {
110
115
  isInKernelMode(): boolean {
111
116
  return this.inKernelMode;
112
117
  }
118
+
119
+ forceReadPermission(): boolean {
120
+ return this.activeEnv.lookup(ForceReadPermFlag);
121
+ }
113
122
  }
114
123
 
115
124
  export type JoinOn = {
@@ -400,6 +409,8 @@ export async function insertRows(
400
409
  if (!doUpsert) {
401
410
  if (!ctx.isInKernelMode()) {
402
411
  await createOwnership(tableName, rows, ctx);
412
+ } else if (ctx.forceReadPermission()) {
413
+ await createReadPermission(tableName, rows, ctx);
403
414
  }
404
415
  if (ctx.rbacRules) {
405
416
  for (let i = 0; i < ctx.rbacRules.length; ++i) {
@@ -479,6 +490,16 @@ async function createOwnership(tableName: string, rows: object[], ctx: DbContext
479
490
  await createLimitedOwnership(tableName, rows, ctx.authInfo.userId, AllPerms, ctx);
480
491
  }
481
492
 
493
+ const ReadPermOnly = new Set<RbacPermissionFlag>().add(RbacPermissionFlag.READ);
494
+
495
+ async function createReadPermission(
496
+ tableName: string,
497
+ rows: object[],
498
+ ctx: DbContext
499
+ ): Promise<void> {
500
+ await createLimitedOwnership(tableName, rows, ctx.authInfo.userId, ReadPermOnly, ctx);
501
+ }
502
+
482
503
  async function createLimitedOwnership(
483
504
  tableName: string,
484
505
  rows: object[],
@@ -217,15 +217,17 @@ export class SqlDbResolver extends Resolver {
217
217
  inst.addQuery(col, '=', connectedInstance.lookup(PathAttributeName));
218
218
  return await this.queryInstances(inst, false);
219
219
  } else {
220
+ const from = relationship.getAliasFor(connectedInstance);
221
+ const to = relationship.getInverseAliasFor(connectedInstance);
220
222
  await getAllConnected(
221
223
  asTableReference(inst.moduleName, inst.name),
222
224
  inst.queryAttributesAsObject(),
223
225
  inst.queryAttributeValuesAsObject(),
224
226
  {
225
227
  connectionTable: asTableReference(inst.moduleName, relationship.name),
226
- fromColumn: relationship.node1.alias,
228
+ fromColumn: from,
227
229
  fromValue: `'${connectedInstance.lookup(PathAttributeName)}'`,
228
- toColumn: relationship.node2.alias,
230
+ toColumn: to,
229
231
  toRef: PathAttributeName,
230
232
  },
231
233
  this.getDbContext(inst.getFqName())