@versori/run 0.2.0 → 0.2.1-alpha.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 (51) hide show
  1. package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +21 -0
  2. package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
  3. package/esm/src/context/Context.d.ts +13 -24
  4. package/esm/src/context/Context.d.ts.map +1 -1
  5. package/esm/src/context/Context.js +19 -15
  6. package/esm/src/context/ContextProvider.d.ts +3 -3
  7. package/esm/src/context/ContextProvider.d.ts.map +1 -1
  8. package/esm/src/dsl/http/default.js +1 -1
  9. package/esm/src/dsl/http/versori/contextcredentials.d.ts +2 -2
  10. package/esm/src/dsl/http/versori/contextcredentials.d.ts.map +1 -1
  11. package/esm/src/dsl/http/versori/credentials/credentials.d.ts +4 -3
  12. package/esm/src/dsl/http/versori/credentials/credentials.d.ts.map +1 -1
  13. package/esm/src/dsl/http/versori/credentials/credentials.js +0 -1
  14. package/esm/src/dsl/http/versori/roundtripper.d.ts +5 -5
  15. package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
  16. package/esm/src/dsl/http/versori/roundtripper.js +59 -66
  17. package/esm/src/dsl/tasks/HttpTask.d.ts +13 -4
  18. package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
  19. package/esm/src/dsl/tasks/HttpTask.js +42 -21
  20. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  21. package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  22. package/esm/src/interpreter/memory/compilers/schedule.js +1 -1
  23. package/esm/src/interpreter/memory/compilers/webhook.js +1 -1
  24. package/esm/src/kv/nats/NatsKeyValueProvider.d.ts +1 -0
  25. package/esm/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
  26. package/package.json +2 -2
  27. package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +21 -0
  28. package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
  29. package/script/src/context/Context.d.ts +13 -24
  30. package/script/src/context/Context.d.ts.map +1 -1
  31. package/script/src/context/Context.js +19 -15
  32. package/script/src/context/ContextProvider.d.ts +3 -3
  33. package/script/src/context/ContextProvider.d.ts.map +1 -1
  34. package/script/src/dsl/http/default.js +1 -1
  35. package/script/src/dsl/http/versori/contextcredentials.d.ts +2 -2
  36. package/script/src/dsl/http/versori/contextcredentials.d.ts.map +1 -1
  37. package/script/src/dsl/http/versori/credentials/credentials.d.ts +4 -3
  38. package/script/src/dsl/http/versori/credentials/credentials.d.ts.map +1 -1
  39. package/script/src/dsl/http/versori/credentials/credentials.js +0 -1
  40. package/script/src/dsl/http/versori/roundtripper.d.ts +5 -5
  41. package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
  42. package/script/src/dsl/http/versori/roundtripper.js +63 -70
  43. package/script/src/dsl/tasks/HttpTask.d.ts +13 -4
  44. package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
  45. package/script/src/dsl/tasks/HttpTask.js +42 -21
  46. package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  47. package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  48. package/script/src/interpreter/memory/compilers/schedule.js +1 -1
  49. package/script/src/interpreter/memory/compilers/webhook.js +1 -1
  50. package/script/src/kv/nats/NatsKeyValueProvider.d.ts +1 -0
  51. package/script/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
@@ -301,5 +301,26 @@ export declare abstract class BaseHandler {
301
301
  * ```
302
302
  */
303
303
  destroy(): void;
304
+ /**
305
+ * Automatically disposes of the handler when instantiated with the `using`
306
+ * keyword by calling the {@linkcode BaseHandler.destroy} method.
307
+ *
308
+ * @example Usage
309
+ * ```ts
310
+ * import { BaseHandler } from "@std/log/base-handler";
311
+ * import { LogRecord } from "@std/log/logger";
312
+ * import { assertInstanceOf } from "@std/assert/instance-of";
313
+ *
314
+ * class MyHandler extends BaseHandler {
315
+ * log(msg: string) {
316
+ * console.log(msg);
317
+ * }
318
+ * }
319
+ *
320
+ * using handler = new MyHandler("INFO");
321
+ * assertInstanceOf(handler, BaseHandler);
322
+ * ```
323
+ */
324
+ [Symbol.dispose](): void;
304
325
  }
305
326
  //# sourceMappingURL=base_handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base_handler.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/log/0.224.14/base_handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,QAAQ,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,SAAS,KAAK,MAAM,CAAC;AAIjE,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,2CAA2C;IAC3C,SAAS,CAAC,EAAE,iBAAiB,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,8BAAsB,WAAW;;IAG/B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,SAAS,EAAE,iBAAiB,CAAC;IAE7B;;;;;OAKG;gBAED,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE,kBAAkB;IAQ9B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,IAAI,KAAK,IAAI,QAAQ,CAEpB;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,IAAI,KAAK,CAAC,KAAK,EAAE,QAAQ,EAGxB;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,IAAI,SAAS,IAAI,SAAS,CAEzB;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,IAAI,SAAS,CAAC,SAAS,EAAE,SAAS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AK,EAAE,QAAQ,EAGxB;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,IAAI,SAAS,IAAI,SAAS,CAEzB;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,IAAI,SAAS,CAAC,SAAS,EAAE,SAAS,EAGjC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,MAAM,CAAC,SAAS,EAAE,SAAS;IAO3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM;IAIpC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,KAAK;IAEL;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,OAAO;IAEP;;;;;;;;;;;;;;;;;;;OAmBG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;CAGjB"}
@@ -10,11 +10,11 @@ export type ContextOptions = {
10
10
  onError?: OnErrorFn;
11
11
  };
12
12
  export interface Context<D> {
13
- log: Logger;
14
- executionId: string;
15
- startTime: Date;
13
+ readonly log: Logger;
14
+ readonly executionId: string;
15
+ readonly startTime: Date;
16
+ readonly data: D;
16
17
  activation?: Activation;
17
- data: D;
18
18
  /**
19
19
  * Opens a key value store for the given scope, defaulting to ':project:' if not provided.
20
20
  * @param scope
@@ -22,34 +22,23 @@ export interface Context<D> {
22
22
  openKv(scope?: KeyValueScope): KeyValue;
23
23
  credentials(): Credentials;
24
24
  }
25
- export interface InternalContext<D, Index = void> extends Context<D> {
26
- withData<D2>(data: D2): InternalContext<D2, Index>;
27
- withActivation(activation: Activation): InternalContext<D, Index>;
28
- setIndex(idx: number): InternalContext<D, number>;
29
- idx: Index;
30
- readonly activation: Activation | undefined;
31
- readonly kvp: KeyValueProvider;
32
- readonly options: ContextOptions;
33
- destroy(scope: KeyValueScope): Promise<void>;
34
- }
35
- export declare class ContextImpl<D, Index = void> implements InternalContext<D, Index> {
36
- log: Logger;
37
- executionId: string;
38
- startTime: Date;
39
- data: D;
40
- creds: Credentials;
25
+ export declare class ContextImpl<D, Index = void> implements Context<D> {
26
+ #private;
27
+ readonly log: Logger;
28
+ readonly executionId: string;
29
+ readonly startTime: Date;
30
+ readonly data: D;
41
31
  idx: Index;
42
32
  readonly kvp: KeyValueProvider;
43
33
  readonly options: ContextOptions;
44
34
  constructor(log: Logger, kvp: KeyValueProvider, creds: Credentials, executionId: string, startTime: Date, data: D, options?: ContextOptions);
45
35
  get activation(): Activation | undefined;
46
- setIndex(idx: number): InternalContext<D, number>;
47
- withActivation(activation: Activation): InternalContext<D, Index>;
48
- withData<D2>(data: D2): InternalContext<D2, Index>;
36
+ setIndex(idx: number): ContextImpl<D, number>;
37
+ withActivation(activation: Activation): ContextImpl<D, Index>;
38
+ withData<D2>(data: D2): ContextImpl<D2, Index>;
49
39
  openKv(scope?: KeyValueScope): KeyValue;
50
40
  credentials(): Credentials;
51
41
  destroy(scope: KeyValueScope): Promise<void>;
52
42
  [Symbol.toPrimitive](): Record<string, unknown>;
53
- toJSON(): Record<string, unknown>;
54
43
  }
55
44
  //# sourceMappingURL=Context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/src/context/Context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAExE,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;AACtD,MAAM,MAAM,SAAS,GA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EAAE,gBAAgB,EACrB,KAAK,EAAE,WAAW,EAClB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,IAAI,EACf,IAAI,EAAE,CAAC,EACP,OAAO,GAAE,cAAmB;IAmBhC,IAAI,UAAU,IAAI,UAAU,GAAG,SAAS,CAEvC;IAED,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC;IAe7C,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,WAAW,CAAC,CAAC,EAAE,KAAK,CAAC;IAoB7D,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC;IAY9C,MAAM,CAAC,KAAK,GAAE,aAA2B,GAAG,QAAQ;IAepD,WAAW,IAAI,WAAW;IAI1B,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAe5C,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAQlD"}
@@ -1,3 +1,15 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _ContextImpl_creds;
1
13
  export class ContextImpl {
2
14
  constructor(log, kvp, creds, executionId, startTime, data, options = {}) {
3
15
  Object.defineProperty(this, "log", {
@@ -24,12 +36,6 @@ export class ContextImpl {
24
36
  writable: true,
25
37
  value: void 0
26
38
  });
27
- Object.defineProperty(this, "creds", {
28
- enumerable: true,
29
- configurable: true,
30
- writable: true,
31
- value: void 0
32
- });
33
39
  Object.defineProperty(this, "idx", {
34
40
  enumerable: true,
35
41
  configurable: true,
@@ -48,9 +54,10 @@ export class ContextImpl {
48
54
  writable: true,
49
55
  value: void 0
50
56
  });
57
+ _ContextImpl_creds.set(this, void 0);
51
58
  this.log = log;
52
59
  this.executionId = executionId;
53
- this.creds = creds;
60
+ __classPrivateFieldSet(this, _ContextImpl_creds, creds, "f");
54
61
  this.startTime = startTime;
55
62
  this.data = data;
56
63
  this.idx = void 0;
@@ -66,7 +73,7 @@ export class ContextImpl {
66
73
  return this.options.activation;
67
74
  }
68
75
  setIndex(idx) {
69
- const next = new ContextImpl(this.log, this.kvp, this.creds, this.executionId, this.startTime, this.data, this.options);
76
+ const next = new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, this.data, this.options);
70
77
  next.idx = idx;
71
78
  return next;
72
79
  }
@@ -75,13 +82,13 @@ export class ContextImpl {
75
82
  if (this.activation) {
76
83
  throw new Error('Activation is already set');
77
84
  }
78
- return new ContextImpl(this.log, this.kvp, this.creds, this.executionId, this.startTime, this.data, {
85
+ return new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, this.data, {
79
86
  ...this.options,
80
87
  activation,
81
88
  });
82
89
  }
83
90
  withData(data) {
84
- return new ContextImpl(this.log, this.kvp, this.creds, this.executionId, this.startTime, data, this.options);
91
+ return new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, data, this.options);
85
92
  }
86
93
  openKv(scope = ':project:') {
87
94
  if (scope === ':execution:') {
@@ -97,7 +104,7 @@ export class ContextImpl {
97
104
  });
98
105
  }
99
106
  credentials() {
100
- return this.creds;
107
+ return __classPrivateFieldGet(this, _ContextImpl_creds, "f");
101
108
  }
102
109
  destroy(scope) {
103
110
  if (scope === ':execution:') {
@@ -112,7 +119,7 @@ export class ContextImpl {
112
119
  activationId: this.activation?.id,
113
120
  });
114
121
  }
115
- [Symbol.toPrimitive]() {
122
+ [(_ContextImpl_creds = new WeakMap(), Symbol.toPrimitive)]() {
116
123
  return {
117
124
  startTime: this.startTime,
118
125
  executionId: this.executionId,
@@ -120,7 +127,4 @@ export class ContextImpl {
120
127
  data: this.data,
121
128
  };
122
129
  }
123
- toJSON() {
124
- return this[Symbol.toPrimitive]();
125
- }
126
130
  }
@@ -1,9 +1,9 @@
1
1
  import { KeyValueProvider } from '../kv/KeyValue.js';
2
2
  import { Logger } from '../observability/logging/Logger.js';
3
- import { Context, ContextOptions, InternalContext } from './Context.js';
3
+ import { Context, ContextImpl, ContextOptions } from './Context.js';
4
4
  import { Credentials } from '../dsl/http/versori/contextcredentials.js';
5
5
  export interface ContextProvider {
6
- create<D>(data: D, options?: ContextOptions): InternalContext<D, void>;
6
+ create<D>(data: D, options?: ContextOptions): ContextImpl<D, void>;
7
7
  destroy(ctx: Context<any>): Promise<void>;
8
8
  }
9
9
  export declare class ContextProviderImpl implements ContextProvider {
@@ -11,7 +11,7 @@ export declare class ContextProviderImpl implements ContextProvider {
11
11
  kvp: KeyValueProvider;
12
12
  creds: Credentials;
13
13
  constructor(log: Logger, kvp: KeyValueProvider, creds: Credentials);
14
- create<D>(data: D, options?: ContextOptions): InternalContext<D, void>;
14
+ create<D>(data: D, options?: ContextOptions): ContextImpl<D>;
15
15
  destroy(ctx: Context<any>): Promise<void>;
16
16
  }
17
17
  //# sourceMappingURL=ContextProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextProvider.d.ts","sourceRoot":"","sources":["../../../src/src/context/ContextProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAe,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAExE,MAAM,WAAW,eAAe;IAC5B,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACvE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C;AAED,qBAAa,mBAAoB,YAAW,eAAe;IACvD,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,gBAAgB,CAAC;IACtB,KAAK,EAAE,WAAW,CAAC;gBAEP,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,WAAW;IAMlE,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,GAAE,cAAmB,GAAG,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC;IAe1E,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAM5C"}
1
+ {"version":3,"file":"ContextProvider.d.ts","sourceRoot":"","sources":["../../../src/src/context/ContextProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAExE,MAAM,WAAW,eAAe;IAC5B,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACnE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C;AAED,qBAAa,mBAAoB,YAAW,eAAe;IACvD,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,gBAAgB,CAAC;IACtB,KAAK,EAAE,WAAW,CAAC;gBAEP,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,WAAW;IAMlE,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,GAAE,cAAmB,GAAG,WAAW,CAAC,CAAC,CAAC;IAehE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAM5C"}
@@ -26,7 +26,7 @@ export class DefaultRoundTripperFactory {
26
26
  }
27
27
  credentials() {
28
28
  return {
29
- getRaw: () => Promise.resolve(new ArrayBuffer(0)),
29
+ getRaw: () => Promise.resolve(new Uint8Array(0)),
30
30
  getAccessToken: () => Promise.resolve({
31
31
  accessToken: '',
32
32
  tokenType: '',
@@ -4,7 +4,7 @@ export type Token = {
4
4
  expiry?: Date;
5
5
  };
6
6
  export interface Credentials {
7
- getRaw(name: string): Promise<ArrayBuffer>;
8
- getAccessToken(name: string): Promise<Token>;
7
+ getRaw(name: string): Promise<Uint8Array>;
8
+ getAccessToken(name: string, forceRefresh?: boolean): Promise<Token>;
9
9
  }
10
10
  //# sourceMappingURL=contextcredentials.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contextcredentials.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/contextcredentials.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,IAAI,CAAC;CACjB,CAAA;AAED,MAAM,WAAW,WAAW;IACxB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC3C,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CAChD"}
1
+ {"version":3,"file":"contextcredentials.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/contextcredentials.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,IAAI,CAAC;CACjB,CAAA;AAED,MAAM,WAAW,WAAW;IACxB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1C,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CACxE"}
@@ -1,4 +1,5 @@
1
- export declare function createTokenClient(baseUrl?: string): import("@connectrpc/connect").Client<import("@bufbuild/protobuf/codegenv1").GenService<{
1
+ import { Client } from '@connectrpc/connect';
2
+ export declare function createTokenClient(baseUrl?: string): Client<import("@bufbuild/protobuf/codegenv1").GenService<{
2
3
  getToken: {
3
4
  methodKind: "unary";
4
5
  input: typeof import("./tokens/v1/token_service_pb.js").GetTokenRequestSchema;
@@ -11,7 +12,7 @@ export declare function createTokenClient(baseUrl?: string): import("@connectrpc
11
12
  };
12
13
  }>>;
13
14
  export type TokenClient = ReturnType<typeof createTokenClient>;
14
- export declare function createOAuth2TokenService(baseUrl?: string): import("@connectrpc/connect").Client<import("@bufbuild/protobuf/codegenv1").GenService<{
15
+ export declare function createOAuth2TokenService(baseUrl?: string): Client<import("@bufbuild/protobuf/codegenv1").GenService<{
15
16
  getAccessToken: {
16
17
  methodKind: "unary";
17
18
  input: typeof import("./oauth2/v1/token_service_pb.js").GetAccessTokenRequestSchema;
@@ -39,7 +40,7 @@ export declare function createOAuth2TokenService(baseUrl?: string): import("@con
39
40
  };
40
41
  }>>;
41
42
  export type OAuth2TokenClient = ReturnType<typeof createOAuth2TokenService>;
42
- export declare function createCredentialsClient(baseUrl?: string): import("@connectrpc/connect").Client<import("@bufbuild/protobuf/codegenv1").GenService<{
43
+ export declare function createCredentialsClient(baseUrl?: string): Client<import("@bufbuild/protobuf/codegenv1").GenService<{
43
44
  create: {
44
45
  methodKind: "unary";
45
46
  input: typeof import("./v1alpha1/credential_service_pb.js").CreateCredentialRequestSchema;
@@ -1 +1 @@
1
- {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../../../../src/src/dsl/http/versori/credentials/credentials.ts"],"names":[],"mappings":"AAeA,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,MAAgC;;;;;;;;;;;IAK1E;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE/D,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,MAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;IAKjF;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE5E,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,MAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKhF;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../../../../src/src/dsl/http/versori/credentials/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgB,MAAM,qBAAqB,CAAC;AAe3D,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,MAAgC;;;;;;;;;;;IAK1E;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE/D,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,MAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;IAKjF;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE5E,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,MAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKhF;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
@@ -2,7 +2,6 @@ import { createClient } from '@connectrpc/connect';
2
2
  import { createGrpcTransport } from '@connectrpc/connect-node';
3
3
  import { TokenService } from './tokens/v1/token_service_pb.js';
4
4
  import { OAuth2TokenService } from './oauth2/v1/token_service_pb.js';
5
- // // @deno-types="./v1alpha1/credential_service_pb.d.ts"
6
5
  import { CredentialService } from './v1alpha1/credential_service_pb.js';
7
6
  // // @deno-types="./customauth/v1/customauth_service_pb.d.ts"
8
7
  // import { CustomAuthenticationService } from './customauth/v1/customauth_service_pb.d.ts';
@@ -1,8 +1,8 @@
1
+ import { Logger } from '../../../observability/logging/Logger.js';
1
2
  import { DynamicFetcher, RoundTripperFactory } from '../types.js';
3
+ import { Credentials } from './contextcredentials.js';
2
4
  import { VersoriCredentialClient } from './credentials/mod.js';
3
5
  import { PlatformAPIClient } from './platformapi.js';
4
- import { Logger } from '../../../observability/logging/Logger.js';
5
- import { Credentials } from './contextcredentials.js';
6
6
  /**
7
7
  * VersoriRoundTripper is an implementation of the RoundTripperFactory interface for Versori connections.
8
8
  * This is the intended implementation for when projects/services are hosted on Versori infrastructure.
@@ -21,14 +21,14 @@ export declare class VersoriCredentialsFactory implements RoundTripperFactory {
21
21
  private platformAPIClient;
22
22
  private versoriCfg;
23
23
  private log;
24
- private readonly defaultDynamic;
25
24
  constructor(credsClient: VersoriCredentialClient, credsBaseURL: string, platformAPIClient: PlatformAPIClient, logger: Logger);
26
25
  static fromEnv(logger?: Logger): VersoriCredentialsFactory;
27
- private changeRequestInit;
28
- private changeBaseUrl;
29
26
  create(connName: string, fn?: typeof fetch): Promise<typeof fetch | undefined>;
30
27
  createDynamic(templateName: string, fn?: typeof fetch): Promise<DynamicFetcher | undefined>;
31
28
  credentials(): Credentials;
29
+ private readonly defaultDynamic;
30
+ private changeRequestInit;
31
+ private changeBaseUrl;
32
32
  private getTokenByName;
33
33
  private getRawByName;
34
34
  private getCredentialIDFromName;
@@ -1 +1 @@
1
- {"version":3,"file":"roundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/roundtripper.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,cAAc,EACd,mBAAmB,EAEtB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAWlE,OAAO,EAAE,WAAW,EAAS,MAAM,yBAAyB,CAAC;AAE7D;;;;;;;;;;;GAWG;AACH,qBAAa,yBAA0B,YAAW,mBAAmB;IACjE,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,OAAO,CAAC,UAAU,CAAmB;IAErC,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAK7B;gBAGE,WAAW,EAAE,uBAAuB,EACpC,YAAY,EAAE,MAAM,EACpB,iBAAiB,EAAE,iBAAiB,EACpC,MAAM,EAAE,MAAM;IAWlB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,yBAAyB;IA6B1D,OAAO,CAAC,iBAAiB;IAezB,OAAO,C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AAM,GAAG,yBAAyB;IA0B1D,MAAM,CACF,QAAQ,EAAE,MAAM,EAChB,EAAE,GAAE,OAAO,KAAwB,GACpC,OAAO,CAAC,OAAO,KAAK,GAAG,SAAS,CAAC;IAsCpC,aAAa,CACT,YAAY,EAAE,MAAM,EACpB,EAAE,GAAE,OAAO,KAAwB,GACpC,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IA8CtC,WAAW,IAAI,WAAW;IAO1B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAK7B;IAGF,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,aAAa;YAwBP,cAAc;YAed,YAAY;YAWZ,uBAAuB;IAkBrC,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,aAAa;IAuDrB,OAAO,CAAC,gBAAgB;IAmCxB,OAAO,CAAC,kBAAkB;IAiC1B,OAAO,CAAC,aAAa;YAsEP,QAAQ;CAwBzB"}
@@ -1,9 +1,9 @@
1
+ import { Code, ConnectError } from '@connectrpc/connect';
2
+ import { ConsoleLogger } from '../../../observability/mod.js';
1
3
  import { LoadConfigFromFile } from './configloader.js';
4
+ import { envVarCredsBaseURL, envVarEnvId, envVarOrgId, envVarPlatformApiBaseURL, } from './constants.js';
2
5
  import { VersoriCredentialClient } from './credentials/mod.js';
3
6
  import { PlatformAPIClient } from './platformapi.js';
4
- import { ConsoleLogger } from '../../../observability/mod.js';
5
- import { envVarCredsBaseURL, envVarEnvId, envVarOrgId, envVarPlatformApiBaseURL, } from './constants.js';
6
- import { ConnectError, Code } from '@connectrpc/connect';
7
7
  /**
8
8
  * VersoriRoundTripper is an implementation of the RoundTripperFactory interface for Versori connections.
9
9
  * This is the intended implementation for when projects/services are hosted on Versori infrastructure.
@@ -88,51 +88,15 @@ export class VersoriCredentialsFactory {
88
88
  const tokenClient = new VersoriCredentialClient(credsBaseURL);
89
89
  return new VersoriCredentialsFactory(tokenClient, credsBaseURL, pAPIClient, log);
90
90
  }
91
- // takes the info and modifies the url using changeBaseUrl if necessary
92
- // if a full valid URL is passed as a string, it will be returned as is
93
- // if a valid URL object is passed, it will be returned as is
94
- changeRequestInit(info, conn) {
95
- if (typeof info === 'string') {
96
- if (isValidURL(info)) {
97
- return info;
98
- }
99
- return this.changeBaseUrl(info, conn);
100
- }
101
- else if (info instanceof URL) {
102
- return info;
103
- }
104
- else if (info instanceof Request) {
105
- const url = this.changeBaseUrl(info.url, conn);
106
- return new Request(url, info);
107
- }
108
- return info;
109
- }
110
- changeBaseUrl(pathname, conn) {
111
- const connBaseURL = conn.baseUrl;
112
- // if the connection has no baseUrl set, but the pathname is a valid URL, return it as is
113
- if (!connBaseURL && isValidURL(pathname)) {
114
- this.log.debug('Using given URL as is', { url: pathname });
115
- return pathname;
116
- }
117
- const connBaseURLObj = new URL(connBaseURL);
118
- let _pathname = pathname;
119
- if (isValidURL(pathname)) {
120
- const pathnameObj = new URL(pathname);
121
- _pathname = pathnameObj.pathname;
122
- }
123
- const newURL = new URL(_pathname, connBaseURLObj.origin);
124
- this.log.debug('Using baseURL from connection', { url: newURL.toString() });
125
- return newURL.toString();
126
- }
127
91
  create(connName, fn = globalThis.fetch) {
128
92
  const cnxId = this.getConnectionID(connName);
129
93
  if (!cnxId) {
130
94
  this.log.debug('Connection not found in config, could be a dynamic connection', {
131
95
  connectionName: connName,
132
96
  });
133
- return undefined;
97
+ return Promise.resolve(undefined);
134
98
  }
135
- const _fn = async (input, init) => {
99
+ return Promise.resolve(async (input, init) => {
136
100
  const conn = await this.platformAPIClient.getStaticConnection(cnxId);
137
101
  if (!conn) {
138
102
  this.log.error('Connection not found for user, using default fetch', {
@@ -153,18 +117,19 @@ export class VersoriCredentialsFactory {
153
117
  default:
154
118
  return fn(_input, init);
155
119
  }
156
- };
157
- return _fn;
120
+ });
158
121
  }
122
+ // takes the info and modifies the url using changeBaseUrl if necessary
123
+ // if a full valid URL is passed as a string, it will be returned as is
159
124
  createDynamic(templateName, fn = globalThis.fetch) {
160
125
  const template = this.getTemplateID(templateName);
161
126
  if (!template) {
162
127
  this.log.debug('Template not found in config, could be a static connection', {
163
128
  templateName: templateName,
164
129
  });
165
- return undefined;
130
+ return Promise.resolve(undefined);
166
131
  }
167
- const _fn = async (activation, input, init) => {
132
+ return Promise.resolve(async (activation, input, init) => {
168
133
  const conn = await this.platformAPIClient.getActivationConnection(template, activation.id);
169
134
  if (!conn) {
170
135
  return this.defaultDynamic('Connection not found for user, using default fetch', {
@@ -186,8 +151,7 @@ export class VersoriCredentialsFactory {
186
151
  default:
187
152
  return fn(_input, init);
188
153
  }
189
- };
190
- return _fn;
154
+ });
191
155
  }
192
156
  credentials() {
193
157
  return {
@@ -195,9 +159,43 @@ export class VersoriCredentialsFactory {
195
159
  getAccessToken: this.getTokenByName.bind(this),
196
160
  };
197
161
  }
198
- async getTokenByName(name) {
162
+ // if a valid URL object is passed, it will be returned as is
163
+ changeRequestInit(info, conn) {
164
+ if (typeof info === 'string') {
165
+ if (isValidURL(info)) {
166
+ return info;
167
+ }
168
+ return this.changeBaseUrl(info, conn);
169
+ }
170
+ else if (info instanceof URL) {
171
+ return info;
172
+ }
173
+ else if (info instanceof Request) {
174
+ const url = this.changeBaseUrl(info.url, conn);
175
+ return new Request(url, info);
176
+ }
177
+ return info;
178
+ }
179
+ changeBaseUrl(pathname, conn) {
180
+ const connBaseURL = conn.baseUrl;
181
+ // if the connection has no baseUrl set, but the pathname is a valid URL, return it as is
182
+ if (!connBaseURL && isValidURL(pathname)) {
183
+ this.log.debug('Using given URL as is', { url: pathname });
184
+ return pathname;
185
+ }
186
+ const connBaseURLObj = new URL(connBaseURL);
187
+ let _pathname = pathname;
188
+ if (isValidURL(pathname)) {
189
+ const pathnameObj = new URL(pathname);
190
+ _pathname = pathnameObj.pathname;
191
+ }
192
+ const newURL = new URL(_pathname, connBaseURLObj.origin);
193
+ this.log.debug('Using baseURL from connection', { url: newURL.toString() });
194
+ return newURL.toString();
195
+ }
196
+ async getTokenByName(name, forceRefresh = false) {
199
197
  const credId = await this.getCredentialIDFromName(name);
200
- const token = await this.tokenClient.getToken(credId);
198
+ const token = await this.tokenClient.getToken(credId, forceRefresh);
201
199
  if (!token?.token) {
202
200
  throw new Error(`Token not found for connection ${name} with credential ID ${credId}`);
203
201
  }
@@ -213,8 +211,7 @@ export class VersoriCredentialsFactory {
213
211
  if (!raw) {
214
212
  throw new Error(`Raw data not found for connection ${name} with credential ID ${credId}`);
215
213
  }
216
- let buffer = raw?.credential?.data['raw'];
217
- return buffer;
214
+ return raw?.credential?.data['raw'] ?? new Uint8Array(0);
218
215
  }
219
216
  async getCredentialIDFromName(name) {
220
217
  const conId = this.getConnectionID(name);
@@ -246,7 +243,7 @@ export class VersoriCredentialsFactory {
246
243
  return template.templateId;
247
244
  }
248
245
  apiKeyFetcher(conn, fn) {
249
- const _fn = async (input, init) => {
246
+ return Promise.resolve(async (input, init) => {
250
247
  const tokenResponse = await this.getToken(conn.credentials[0].credential.id);
251
248
  const token = tokenResponse.token?.accessToken;
252
249
  const asc = conn.credentials[0].authSchemeConfig.apiKey;
@@ -267,7 +264,7 @@ export class VersoriCredentialsFactory {
267
264
  if (init.headers instanceof Headers) {
268
265
  init.headers.set(asc.name, token);
269
266
  }
270
- else if (init.headers instanceof Array) {
267
+ else if (Array.isArray(init.headers)) {
271
268
  init.headers.push([asc.name, token]);
272
269
  }
273
270
  else {
@@ -290,11 +287,10 @@ export class VersoriCredentialsFactory {
290
287
  break;
291
288
  }
292
289
  return fn(input, init);
293
- };
294
- return _fn;
290
+ });
295
291
  }
296
292
  basicAuthFetcher(conn, fn) {
297
- const _fn = async (input, init) => {
293
+ return Promise.resolve(async (input, init) => {
298
294
  const tokenResponse = await this.getToken(conn.credentials[0].credential.id);
299
295
  const token = tokenResponse.token?.accessToken;
300
296
  if (!token) {
@@ -319,12 +315,11 @@ export class VersoriCredentialsFactory {
319
315
  };
320
316
  }
321
317
  return fn(input, init);
322
- };
323
- return _fn;
318
+ });
324
319
  }
325
320
  // TODO: need to make the prefix and header name configurable from authschemeconfig
326
321
  bearerTokenFetcher(conn, fn) {
327
- const _fn = async (input, init) => {
322
+ return Promise.resolve(async (input, init) => {
328
323
  const tokenResponse = await this.getToken(conn.credentials[0].credential.id);
329
324
  const token = tokenResponse.token?.accessToken;
330
325
  if (!token) {
@@ -349,8 +344,7 @@ export class VersoriCredentialsFactory {
349
344
  };
350
345
  }
351
346
  return fn(input, init);
352
- };
353
- return _fn;
347
+ });
354
348
  }
355
349
  oauth2Fetcher(conn, fn) {
356
350
  const refreshFn = async (input, init, forceRefresh = false) => {
@@ -393,7 +387,7 @@ export class VersoriCredentialsFactory {
393
387
  }
394
388
  return fn(input, init);
395
389
  };
396
- const _fn = async (input, init) => {
390
+ return Promise.resolve(async (input, init) => {
397
391
  const resp = await refreshFn(input, init, false);
398
392
  if (resp.status === 401) {
399
393
  this.log.debug('Received 401 Unauthorized response, attempting refresh', {
@@ -404,12 +398,11 @@ export class VersoriCredentialsFactory {
404
398
  return refreshFn(input, init, true);
405
399
  }
406
400
  return Promise.resolve(resp);
407
- };
408
- return _fn;
401
+ });
409
402
  }
410
- async getToken(id) {
403
+ async getToken(id, forceRefresh = false) {
411
404
  try {
412
- return await this.tokenClient.getToken(id);
405
+ return await this.tokenClient.getToken(id, forceRefresh);
413
406
  }
414
407
  catch (error) {
415
408
  this.log.error('unable to get credential', { error });
@@ -1,5 +1,8 @@
1
1
  import { Context, ContextImpl } from '../../context/Context.js';
2
- import { DynamicFetcher } from '../http/types.js';
2
+ import { KeyValueScope, KeyValue } from '../../kv/KeyValue.js';
3
+ import { Logger } from '../../observability/logging/Logger.js';
4
+ import { Activation, DynamicFetcher } from '../http/types.js';
5
+ import { Credentials } from '../http/versori/contextcredentials.js';
3
6
  import { ArrayTask, Task, Taskable, TaskType } from '../Task.js';
4
7
  export interface HttpContext<Data, PageParams = undefined> extends Context<Data> {
5
8
  fetch: typeof fetch;
@@ -28,12 +31,18 @@ export declare class HttpTaskImpl<In, Out, PageParams> implements Task<In, Out>
28
31
  unpack<NextOut>(mapper: (data: Out) => NextOut[]): ArrayTask<In, NextOut>;
29
32
  clone(): Task<In, Out>;
30
33
  }
31
- export declare class HttpContextImpl<D, PageParams> extends ContextImpl<D> implements HttpContext<D, PageParams> {
34
+ export declare class HttpContextImpl<D, PageParams> implements HttpContext<D, PageParams> {
35
+ #private;
32
36
  connectionVariables: Record<string, any>;
33
37
  pageParams?: PageParams;
34
- private dynamicFetcher?;
35
- private staticFetcher?;
36
38
  constructor(ctx: ContextImpl<D, any>, connectionVars: Record<string, any>, staticFetcher?: typeof globalThis.fetch, dynamicFetcher?: DynamicFetcher, pageParams?: PageParams);
39
+ get log(): Logger;
40
+ get executionId(): string;
41
+ get startTime(): Date;
42
+ get activation(): Activation | undefined;
43
+ get data(): D;
44
+ openKv(scope?: KeyValueScope): KeyValue;
45
+ credentials(): Credentials;
37
46
  get fetch(): typeof globalThis.fetch;
38
47
  nextPage(nextParams: PageParams): Promise<void>;
39
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"HttpTask.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/tasks/HttpTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAmB,MAAM,0BAA0B,CAAC;AAGjF,OAAO,EAAc,cAAc,EAAsB,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOjE,MAAM,WAAW,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAE,SAAQ,OAAO,CAAC,IAAI,CAAC;IAC5E,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACzC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CA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