@glubean/sdk 0.2.1 → 0.2.2

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 (100) hide show
  1. package/dist/configure/http.d.ts +25 -0
  2. package/dist/configure/http.d.ts.map +1 -0
  3. package/dist/configure/http.js +88 -0
  4. package/dist/configure/http.js.map +1 -0
  5. package/dist/configure/index.d.ts +78 -0
  6. package/dist/configure/index.d.ts.map +1 -0
  7. package/dist/configure/index.js +78 -0
  8. package/dist/configure/index.js.map +1 -0
  9. package/dist/configure/plugin.d.ts +23 -0
  10. package/dist/configure/plugin.d.ts.map +1 -0
  11. package/dist/configure/plugin.js +81 -0
  12. package/dist/configure/plugin.js.map +1 -0
  13. package/dist/configure/runtime.d.ts +24 -0
  14. package/dist/configure/runtime.d.ts.map +1 -0
  15. package/dist/configure/runtime.js +45 -0
  16. package/dist/configure/runtime.js.map +1 -0
  17. package/dist/configure/template.d.ts +22 -0
  18. package/dist/configure/template.d.ts.map +1 -0
  19. package/dist/configure/template.js +34 -0
  20. package/dist/configure/template.js.map +1 -0
  21. package/dist/configure/vars.d.ts +20 -0
  22. package/dist/configure/vars.d.ts.map +1 -0
  23. package/dist/configure/vars.js +48 -0
  24. package/dist/configure/vars.js.map +1 -0
  25. package/dist/configure.d.ts +2 -133
  26. package/dist/configure.d.ts.map +1 -1
  27. package/dist/configure.js +2 -436
  28. package/dist/configure.js.map +1 -1
  29. package/dist/contract-artifacts.d.ts +268 -0
  30. package/dist/contract-artifacts.d.ts.map +1 -0
  31. package/dist/contract-artifacts.js +402 -0
  32. package/dist/contract-artifacts.js.map +1 -0
  33. package/dist/contract-core.d.ts +30 -0
  34. package/dist/contract-core.d.ts.map +1 -1
  35. package/dist/contract-core.js +47 -0
  36. package/dist/contract-core.js.map +1 -1
  37. package/dist/contract-http/adapter.d.ts.map +1 -1
  38. package/dist/contract-http/adapter.js +22 -7
  39. package/dist/contract-http/adapter.js.map +1 -1
  40. package/dist/contract-http/factory.d.ts.map +1 -1
  41. package/dist/contract-http/factory.js +13 -14
  42. package/dist/contract-http/factory.js.map +1 -1
  43. package/dist/contract-http/openapi.d.ts +56 -7
  44. package/dist/contract-http/openapi.d.ts.map +1 -1
  45. package/dist/contract-http/openapi.js +371 -21
  46. package/dist/contract-http/openapi.js.map +1 -1
  47. package/dist/contract-http/types.d.ts +2 -13
  48. package/dist/contract-http/types.d.ts.map +1 -1
  49. package/dist/contract-types.d.ts +59 -10
  50. package/dist/contract-types.d.ts.map +1 -1
  51. package/dist/expect.d.ts +13 -0
  52. package/dist/expect.d.ts.map +1 -1
  53. package/dist/expect.js +18 -0
  54. package/dist/expect.js.map +1 -1
  55. package/dist/index.d.ts +55 -10
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +14 -8
  58. package/dist/index.js.map +1 -1
  59. package/dist/install-plugin.d.ts +94 -0
  60. package/dist/install-plugin.d.ts.map +1 -0
  61. package/dist/install-plugin.js +222 -0
  62. package/dist/install-plugin.js.map +1 -0
  63. package/dist/internal.d.ts +1 -0
  64. package/dist/internal.d.ts.map +1 -1
  65. package/dist/internal.js +5 -0
  66. package/dist/internal.js.map +1 -1
  67. package/dist/plugin.d.ts +45 -34
  68. package/dist/plugin.d.ts.map +1 -1
  69. package/dist/plugin.js +47 -34
  70. package/dist/plugin.js.map +1 -1
  71. package/dist/{test-builder.d.ts → test/builder.d.ts} +2 -2
  72. package/dist/test/builder.d.ts.map +1 -0
  73. package/dist/{test-builder.js → test/builder.js} +3 -3
  74. package/dist/{test-builder.js.map → test/builder.js.map} +1 -1
  75. package/dist/{each-builder.d.ts → test/each-builder.d.ts} +1 -1
  76. package/dist/test/each-builder.d.ts.map +1 -0
  77. package/dist/{each-builder.js → test/each-builder.js} +3 -3
  78. package/dist/test/each-builder.js.map +1 -0
  79. package/dist/{test-extend.d.ts → test/extend.d.ts} +3 -3
  80. package/dist/test/extend.d.ts.map +1 -0
  81. package/dist/{test-extend.js → test/extend.js} +5 -5
  82. package/dist/test/extend.js.map +1 -0
  83. package/dist/{test-utils.d.ts → test/utils.d.ts} +2 -2
  84. package/dist/test/utils.d.ts.map +1 -0
  85. package/dist/{test-utils.js → test/utils.js} +1 -1
  86. package/dist/test/utils.js.map +1 -0
  87. package/dist/types.d.ts +78 -7
  88. package/dist/types.d.ts.map +1 -1
  89. package/package.json +1 -1
  90. package/dist/contract-http/markdown.d.ts +0 -10
  91. package/dist/contract-http/markdown.d.ts.map +0 -1
  92. package/dist/contract-http/markdown.js +0 -21
  93. package/dist/contract-http/markdown.js.map +0 -1
  94. package/dist/each-builder.d.ts.map +0 -1
  95. package/dist/each-builder.js.map +0 -1
  96. package/dist/test-builder.d.ts.map +0 -1
  97. package/dist/test-extend.d.ts.map +0 -1
  98. package/dist/test-extend.js.map +0 -1
  99. package/dist/test-utils.d.ts.map +0 -1
  100. package/dist/test-utils.js.map +0 -1
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @module configure/http
3
+ *
4
+ * Lazy HTTP client builders for configure().
5
+ *
6
+ * - `buildLazyHttp` — creates a proxy that resolves and caches an extended
7
+ * HttpClient on first call (WeakMap keyed by runtime identity).
8
+ * - `buildPassthroughHttp` — delegates directly to runtime.http when no
9
+ * http options are declared in configure().
10
+ */
11
+ import type { ConfigureHttpOptions, HttpClient } from "../types.js";
12
+ /**
13
+ * Build a lazy HTTP client proxy.
14
+ * On first method call, resolves the config and creates an extended client.
15
+ * Result is cached per runtime identity via WeakMap.
16
+ * @internal
17
+ */
18
+ export declare function buildLazyHttp(httpOptions: ConfigureHttpOptions): HttpClient;
19
+ /**
20
+ * Build a passthrough HTTP client that delegates directly to runtime.http.
21
+ * Used when configure() is called without http options.
22
+ * @internal
23
+ */
24
+ export declare function buildPassthroughHttp(): HttpClient;
25
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/configure/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIpE;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,oBAAoB,GAAG,UAAU,CA0E3E;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,UAAU,CAcjD"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @module configure/http
3
+ *
4
+ * Lazy HTTP client builders for configure().
5
+ *
6
+ * - `buildLazyHttp` — creates a proxy that resolves and caches an extended
7
+ * HttpClient on first call (WeakMap keyed by runtime identity).
8
+ * - `buildPassthroughHttp` — delegates directly to runtime.http when no
9
+ * http options are declared in configure().
10
+ */
11
+ import { getRuntime } from "./runtime.js";
12
+ import { resolveTemplate } from "./template.js";
13
+ /**
14
+ * Build a lazy HTTP client proxy.
15
+ * On first method call, resolves the config and creates an extended client.
16
+ * Result is cached per runtime identity via WeakMap.
17
+ * @internal
18
+ */
19
+ export function buildLazyHttp(httpOptions) {
20
+ const cache = new WeakMap();
21
+ function getClient() {
22
+ const runtime = getRuntime();
23
+ let client = cache.get(runtime);
24
+ if (client)
25
+ return client;
26
+ const extendOptions = {};
27
+ if (httpOptions.prefixUrl) {
28
+ extendOptions.prefixUrl = resolveTemplate(httpOptions.prefixUrl, runtime.vars, runtime.secrets, runtime.session);
29
+ }
30
+ if (httpOptions.headers) {
31
+ const resolvedHeaders = {};
32
+ for (const [name, template] of Object.entries(httpOptions.headers)) {
33
+ resolvedHeaders[name] = resolveTemplate(template, runtime.vars, runtime.secrets, runtime.session);
34
+ }
35
+ extendOptions.headers = resolvedHeaders;
36
+ }
37
+ if (httpOptions.searchParams) {
38
+ const resolvedParams = {};
39
+ for (const [name, template] of Object.entries(httpOptions.searchParams)) {
40
+ resolvedParams[name] = resolveTemplate(template, runtime.vars, runtime.secrets, runtime.session);
41
+ }
42
+ extendOptions.searchParams = resolvedParams;
43
+ }
44
+ if (httpOptions.timeout !== undefined)
45
+ extendOptions.timeout = httpOptions.timeout;
46
+ if (httpOptions.retry !== undefined)
47
+ extendOptions.retry = httpOptions.retry;
48
+ if (httpOptions.throwHttpErrors !== undefined)
49
+ extendOptions.throwHttpErrors = httpOptions.throwHttpErrors;
50
+ if (httpOptions.hooks)
51
+ extendOptions.hooks = httpOptions.hooks;
52
+ if (httpOptions.redirect !== undefined)
53
+ extendOptions.redirect = httpOptions.redirect;
54
+ if (typeof process !== "undefined" && process.env?.["GLUBEAN_DEBUG"]) {
55
+ process.stderr.write(`[glubean:debug] configure.getClient extendOptions=${JSON.stringify({ ...extendOptions, headers: "..." })}\n`);
56
+ }
57
+ client = runtime.http.extend(extendOptions);
58
+ cache.set(runtime, client);
59
+ return client;
60
+ }
61
+ const HTTP_METHODS = ["get", "post", "put", "patch", "delete", "head"];
62
+ const proxy = function (url, options) {
63
+ return getClient()(url, options);
64
+ };
65
+ for (const method of HTTP_METHODS) {
66
+ proxy[method] = (url, options) => getClient()[method](url, options);
67
+ }
68
+ proxy.extend = (options) => getClient().extend(options);
69
+ proxy._configuredTimeout = httpOptions.timeout;
70
+ return proxy;
71
+ }
72
+ /**
73
+ * Build a passthrough HTTP client that delegates directly to runtime.http.
74
+ * Used when configure() is called without http options.
75
+ * @internal
76
+ */
77
+ export function buildPassthroughHttp() {
78
+ const HTTP_METHODS = ["get", "post", "put", "patch", "delete", "head"];
79
+ const proxy = function (url, options) {
80
+ return getRuntime().http(url, options);
81
+ };
82
+ for (const method of HTTP_METHODS) {
83
+ proxy[method] = (url, options) => getRuntime().http[method](url, options);
84
+ }
85
+ proxy.extend = (options) => getRuntime().http.extend(options);
86
+ return proxy;
87
+ }
88
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/configure/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,UAAU,EAAwB,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,M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AC;IAEF,KAAK,MAAM,MAAM,IAAI,YAAY,EAAE,CAAC;QAClC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,GAA2B,EAAE,OAAa,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACpG,CAAC;IAED,KAAK,CAAC,MAAM,GAAG,CAAC,OAAY,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC5D,KAAa,CAAC,kBAAkB,GAAG,WAAW,CAAC,OAAO,CAAC;IAExD,OAAO,KAAmB,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;IAEhF,MAAM,KAAK,GAAQ,UAAU,GAA2B,EAAE,OAAa;QACrE,OAAO,UAAU,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC,CAAC;IAEF,KAAK,MAAM,MAAM,IAAI,YAAY,EAAE,CAAC;QAClC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,GAA2B,EAAE,OAAa,EAAE,EAAE,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1G,CAAC;IAED,KAAK,CAAC,MAAM,GAAG,CAAC,OAAY,EAAE,EAAE,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAEnE,OAAO,KAAmB,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @module configure
3
+ *
4
+ * File-level configuration for Glubean tests.
5
+ *
6
+ * `configure()` lets you declare shared dependencies (vars, secrets, HTTP config)
7
+ * once at the top of a test file (or in a shared `configure.ts`), eliminating
8
+ * repetitive `ctx.vars.require()` / `ctx.secrets.require()` calls in every test.
9
+ *
10
+ * All returned values are **lazy** — they are not resolved until a test function
11
+ * actually accesses them at runtime. This means:
12
+ * - Safe to call at module top-level (scanner won't trigger resolution)
13
+ * - Safe to share across files via re-exports
14
+ * - Each test execution gets the correct runtime values
15
+ *
16
+ * @example Single file usage
17
+ * ```ts
18
+ * import { test, configure } from "@glubean/sdk";
19
+ *
20
+ * const { vars, secrets, http } = configure({
21
+ * vars: { baseUrl: "{{BASE_URL}}" },
22
+ * secrets: { apiKey: "{{API_KEY}}" },
23
+ * http: {
24
+ * prefixUrl: "{{BASE_URL}}",
25
+ * headers: { Authorization: "Bearer {{API_KEY}}" },
26
+ * },
27
+ * });
28
+ *
29
+ * export const listUsers = test("list-users", async (ctx) => {
30
+ * const res = await http.get("users").json();
31
+ * ctx.assert(res.length > 0, "has users");
32
+ * });
33
+ * ```
34
+ *
35
+ * @example Shared across files (tests/configure.ts)
36
+ * ```ts
37
+ * // tests/configure.ts
38
+ * export const { vars, http } = configure({
39
+ * vars: { baseUrl: "{{BASE_URL}}" },
40
+ * http: { prefixUrl: "{{BASE_URL}}" },
41
+ * });
42
+ *
43
+ * // tests/users.test.ts
44
+ * import { http } from "./configure.js";
45
+ * export const listUsers = test("list-users", async (ctx) => {
46
+ * const res = await http.get("users").json();
47
+ * });
48
+ * ```
49
+ */
50
+ import type { ConfigureOptions, ConfigureResult, PluginFactory, ReservedConfigureKeys, ResolvePlugins } from "../types.js";
51
+ export type { InternalRuntime } from "./runtime.js";
52
+ export { resolveTemplate } from "./template.js";
53
+ /**
54
+ * Declare file-level dependencies on vars, secrets, and HTTP configuration.
55
+ *
56
+ * Returns lazy accessors that resolve at test runtime, not at import time.
57
+ * All declared vars and secrets are **required** — missing values cause the test
58
+ * to fail immediately with a clear error message.
59
+ *
60
+ * @param options Configuration declaring vars, secrets, and HTTP defaults
61
+ * @returns Lazy accessors for vars, secrets, and a pre-configured HTTP client
62
+ */
63
+ export declare function configure<V extends Record<string, string> = Record<string, string>, S extends Record<string, string> = Record<string, string>, P extends Record<string, PluginFactory<any>> = Record<string, never>>(options: ConfigureOptions & {
64
+ vars?: {
65
+ [K in keyof V]: string;
66
+ };
67
+ secrets?: {
68
+ [K in keyof S]: string;
69
+ };
70
+ plugins?: P & {
71
+ [K in ReservedConfigureKeys]?: never;
72
+ };
73
+ }): ConfigureResult<{
74
+ [K in keyof V]: string;
75
+ }, {
76
+ [K in keyof S]: string;
77
+ }> & ResolvePlugins<P>;
78
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configure/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,cAAc,EACf,MAAM,aAAa,CAAC;AAKrB,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CACvB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzD,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzD,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAEpE,OAAO,EAAE,gBAAgB,GAAG;IAC1B,IAAI,CAAC,EAAE;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM;KAAE,CAAC;IAClC,OAAO,CAAC,EAAE;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM;KAAE,CAAC;IACrC,OAAO,CAAC,EAAE,CAAC,GAAG;SAAG,CAAC,IAAI,qBAAqB,CAAC,CAAC,EAAE,KAAK;KAAE,CAAC;CACxD,GAEC,eAAe,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM;CAAE,EAAE;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM;CAAE,CAAC,GACvE,cAAc,CAAC,CAAC,CAAC,CAoBpB"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @module configure
3
+ *
4
+ * File-level configuration for Glubean tests.
5
+ *
6
+ * `configure()` lets you declare shared dependencies (vars, secrets, HTTP config)
7
+ * once at the top of a test file (or in a shared `configure.ts`), eliminating
8
+ * repetitive `ctx.vars.require()` / `ctx.secrets.require()` calls in every test.
9
+ *
10
+ * All returned values are **lazy** — they are not resolved until a test function
11
+ * actually accesses them at runtime. This means:
12
+ * - Safe to call at module top-level (scanner won't trigger resolution)
13
+ * - Safe to share across files via re-exports
14
+ * - Each test execution gets the correct runtime values
15
+ *
16
+ * @example Single file usage
17
+ * ```ts
18
+ * import { test, configure } from "@glubean/sdk";
19
+ *
20
+ * const { vars, secrets, http } = configure({
21
+ * vars: { baseUrl: "{{BASE_URL}}" },
22
+ * secrets: { apiKey: "{{API_KEY}}" },
23
+ * http: {
24
+ * prefixUrl: "{{BASE_URL}}",
25
+ * headers: { Authorization: "Bearer {{API_KEY}}" },
26
+ * },
27
+ * });
28
+ *
29
+ * export const listUsers = test("list-users", async (ctx) => {
30
+ * const res = await http.get("users").json();
31
+ * ctx.assert(res.length > 0, "has users");
32
+ * });
33
+ * ```
34
+ *
35
+ * @example Shared across files (tests/configure.ts)
36
+ * ```ts
37
+ * // tests/configure.ts
38
+ * export const { vars, http } = configure({
39
+ * vars: { baseUrl: "{{BASE_URL}}" },
40
+ * http: { prefixUrl: "{{BASE_URL}}" },
41
+ * });
42
+ *
43
+ * // tests/users.test.ts
44
+ * import { http } from "./configure.js";
45
+ * export const listUsers = test("list-users", async (ctx) => {
46
+ * const res = await http.get("users").json();
47
+ * });
48
+ * ```
49
+ */
50
+ import { buildLazyVars, buildLazySecrets } from "./vars.js";
51
+ import { buildLazyHttp, buildPassthroughHttp } from "./http.js";
52
+ import { buildLazyPlugins } from "./plugin.js";
53
+ export { resolveTemplate } from "./template.js";
54
+ /**
55
+ * Declare file-level dependencies on vars, secrets, and HTTP configuration.
56
+ *
57
+ * Returns lazy accessors that resolve at test runtime, not at import time.
58
+ * All declared vars and secrets are **required** — missing values cause the test
59
+ * to fail immediately with a clear error message.
60
+ *
61
+ * @param options Configuration declaring vars, secrets, and HTTP defaults
62
+ * @returns Lazy accessors for vars, secrets, and a pre-configured HTTP client
63
+ */
64
+ export function configure(options) {
65
+ const vars = options.vars
66
+ ? buildLazyVars(options.vars)
67
+ : {};
68
+ const secrets = options.secrets
69
+ ? buildLazySecrets(options.secrets)
70
+ : {};
71
+ const http = options.http ? buildLazyHttp(options.http) : buildPassthroughHttp();
72
+ const base = { vars, secrets, http };
73
+ if (options.plugins) {
74
+ Object.assign(base, buildLazyPlugins(options.plugins));
75
+ }
76
+ return base;
77
+ }
78
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configure/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AASH,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CAKvB,OAIC;IAID,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI;QACvB,CAAC,CAAC,aAAa,CAA6B,OAAO,CAAC,IAAI,CAAC;QACzD,CAAC,CAAE,EAA2C,CAAC;IAEjD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO;QAC7B,CAAC,CAAC,gBAAgB,CAA6B,OAAO,CAAC,OAAO,CAAC;QAC/D,CAAC,CAAE,EAA2C,CAAC;IAEjD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,oBAAoB,EAAE,CAAC;IAEjF,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAErC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,IAEc,CAAC;AACxB,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @module configure/plugin
3
+ *
4
+ * Lazy plugin builder for configure().
5
+ *
6
+ * Each plugin is a transparent Proxy at module load time. On first property
7
+ * access during test execution, the plugin factory is called with an augmented
8
+ * GlubeanRuntime. The instance is cached per runtime identity via WeakMap.
9
+ */
10
+ import type { PluginFactory } from "../types.js";
11
+ /** Reserved keys that plugins cannot shadow. */
12
+ export declare const RESERVED_KEYS: Set<string>;
13
+ /**
14
+ * Build a transparent Proxy that defers plugin instantiation until first use.
15
+ * @internal
16
+ */
17
+ export declare function buildLazyPlugin(factory: PluginFactory<any>): unknown;
18
+ /**
19
+ * Build lazy proxies for all declared plugins, checking for reserved key conflicts.
20
+ * @internal
21
+ */
22
+ export declare function buildLazyPlugins(plugins: Record<string, PluginFactory<any>>): Record<string, unknown>;
23
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/configure/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjE,gDAAgD;AAChD,eAAO,MAAM,aAAa,aAAuC,CAAC;AAkClE;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAsBpE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,GAC1C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYzB"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @module configure/plugin
3
+ *
4
+ * Lazy plugin builder for configure().
5
+ *
6
+ * Each plugin is a transparent Proxy at module load time. On first property
7
+ * access during test execution, the plugin factory is called with an augmented
8
+ * GlubeanRuntime. The instance is cached per runtime identity via WeakMap.
9
+ */
10
+ import { getRuntime, requireVar, requireSecret } from "./runtime.js";
11
+ import { resolveTemplate } from "./template.js";
12
+ /** Reserved keys that plugins cannot shadow. */
13
+ export const RESERVED_KEYS = new Set(["vars", "secrets", "http"]);
14
+ /**
15
+ * Resolve (or retrieve cached) the real plugin instance for the current runtime.
16
+ * @internal
17
+ */
18
+ function resolvePlugin(factory, cache) {
19
+ const runtime = getRuntime();
20
+ if (cache.has(runtime))
21
+ return cache.get(runtime);
22
+ const noop = () => { };
23
+ const augmented = {
24
+ vars: runtime.vars,
25
+ secrets: runtime.secrets,
26
+ http: runtime.http,
27
+ test: runtime.test,
28
+ requireVar,
29
+ requireSecret,
30
+ resolveTemplate: (template) => resolveTemplate(template, runtime.vars, runtime.secrets, runtime.session),
31
+ trace: runtime.trace?.bind(runtime) ?? noop,
32
+ action: runtime.action?.bind(runtime) ?? noop,
33
+ event: runtime.event?.bind(runtime) ?? noop,
34
+ log: runtime.log?.bind(runtime) ?? noop,
35
+ };
36
+ const instance = factory.create(augmented);
37
+ cache.set(runtime, instance);
38
+ return instance;
39
+ }
40
+ /**
41
+ * Build a transparent Proxy that defers plugin instantiation until first use.
42
+ * @internal
43
+ */
44
+ export function buildLazyPlugin(factory) {
45
+ const cache = new WeakMap();
46
+ return new Proxy(Object.create(null), {
47
+ get(_target, prop, receiver) {
48
+ const instance = resolvePlugin(factory, cache);
49
+ const value = Reflect.get(instance, prop, receiver);
50
+ return typeof value === "function" ? value.bind(instance) : value;
51
+ },
52
+ set(_target, prop, value) {
53
+ return Reflect.set(resolvePlugin(factory, cache), prop, value);
54
+ },
55
+ has(_target, prop) {
56
+ return Reflect.has(resolvePlugin(factory, cache), prop);
57
+ },
58
+ ownKeys() {
59
+ return Reflect.ownKeys(resolvePlugin(factory, cache));
60
+ },
61
+ getOwnPropertyDescriptor(_target, prop) {
62
+ return Object.getOwnPropertyDescriptor(resolvePlugin(factory, cache), prop);
63
+ },
64
+ });
65
+ }
66
+ /**
67
+ * Build lazy proxies for all declared plugins, checking for reserved key conflicts.
68
+ * @internal
69
+ */
70
+ export function buildLazyPlugins(plugins) {
71
+ const result = {};
72
+ for (const [name, factory] of Object.entries(plugins)) {
73
+ if (RESERVED_KEYS.has(name)) {
74
+ throw new Error(`Plugin name "${name}" conflicts with a reserved configure() field. ` +
75
+ `Choose a different key (reserved: ${[...RESERVED_KEYS].join(", ")}).`);
76
+ }
77
+ result[name] = buildLazyPlugin(factory);
78
+ }
79
+ return result;
80
+ }
81
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/configure/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAwB,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,gDAAgD;AAChD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAA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,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CACb,gBAAgB,IAAI,iDAAiD;gBACnE,qCAAqC,CAAC,GAAG,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CACzE,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @module configure/runtime
3
+ *
4
+ * Runtime accessor helpers used by all configure lazy builders.
5
+ * Wraps the carrier's optional getRuntime() with a throw-on-missing contract.
6
+ */
7
+ import { type InternalRuntime } from "../runtime-carrier.js";
8
+ export type { InternalRuntime };
9
+ /**
10
+ * Get the current runtime context, throwing if accessed outside test execution.
11
+ * @internal
12
+ */
13
+ export declare function getRuntime(): InternalRuntime;
14
+ /**
15
+ * Require a var from the runtime context. Throws if missing or empty.
16
+ * @internal
17
+ */
18
+ export declare function requireVar(key: string): string;
19
+ /**
20
+ * Require a secret from the runtime context. Throws if missing or empty.
21
+ * @internal
22
+ */
23
+ export declare function requireSecret(key: string): string;
24
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/configure/runtime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC;;;GAGG;AACH,wBAAgB,UAAU,IAAI,eAAe,CAU5C;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO9C;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOjD"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @module configure/runtime
3
+ *
4
+ * Runtime accessor helpers used by all configure lazy builders.
5
+ * Wraps the carrier's optional getRuntime() with a throw-on-missing contract.
6
+ */
7
+ import { getRuntime as getCarrierRuntime, } from "../runtime-carrier.js";
8
+ /**
9
+ * Get the current runtime context, throwing if accessed outside test execution.
10
+ * @internal
11
+ */
12
+ export function getRuntime() {
13
+ const runtime = getCarrierRuntime();
14
+ if (!runtime) {
15
+ throw new Error("configure() values can only be accessed during test execution. " +
16
+ "Did you try to read a var or secret at module load time? " +
17
+ "Move the access inside a test function.");
18
+ }
19
+ return runtime;
20
+ }
21
+ /**
22
+ * Require a var from the runtime context. Throws if missing or empty.
23
+ * @internal
24
+ */
25
+ export function requireVar(key) {
26
+ const runtime = getRuntime();
27
+ const value = runtime.vars[key];
28
+ if (value === undefined || value === null || value === "") {
29
+ throw new Error(`Missing required var: ${key}`);
30
+ }
31
+ return value;
32
+ }
33
+ /**
34
+ * Require a secret from the runtime context. Throws if missing or empty.
35
+ * @internal
36
+ */
37
+ export function requireSecret(key) {
38
+ const runtime = getRuntime();
39
+ const value = runtime.secrets[key];
40
+ if (value === undefined || value === null || value === "") {
41
+ throw new Error(`Missing required secret: ${key}`);
42
+ }
43
+ return value;
44
+ }
45
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/configure/runtime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,UAAU,IAAI,iBAAiB,GAEhC,MAAM,uBAAuB,CAAC;AAI/B;;;GAGG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,iEAAiE;YAC/D,2DAA2D;YAC3D,yCAAyC,CAC5C,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @module configure/template
3
+ *
4
+ * `{{key}}` placeholder resolution used by vars, secrets, and http builders.
5
+ *
6
+ * Resolution priority: session → secrets → vars.
7
+ */
8
+ /** Regex for `{{key}}` template placeholders. */
9
+ export declare const TEMPLATE_RE: RegExp;
10
+ /**
11
+ * Resolve `{{key}}` template placeholders in a string.
12
+ *
13
+ * Resolution priority (first non-empty wins):
14
+ * 1. Session — dynamic values set during session setup (e.g., auth tokens)
15
+ * 2. Secrets — from `.env.secrets`
16
+ * 3. Vars — from `.env`
17
+ *
18
+ * Session values must be strings to resolve in templates. Non-string session
19
+ * values are silently skipped (they're still accessible via `ctx.session.get()`).
20
+ */
21
+ export declare function resolveTemplate(template: string, vars: Record<string, string>, secrets: Record<string, string>, session?: Record<string, unknown>): string;
22
+ //# sourceMappingURL=template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/configure/template.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iDAAiD;AACjD,eAAO,MAAM,WAAW,QAAsB,CAAC;AAE/C;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,MAAM,CAeR"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @module configure/template
3
+ *
4
+ * `{{key}}` placeholder resolution used by vars, secrets, and http builders.
5
+ *
6
+ * Resolution priority: session → secrets → vars.
7
+ */
8
+ /** Regex for `{{key}}` template placeholders. */
9
+ export const TEMPLATE_RE = /\{\{([\w-]+)\}\}/g;
10
+ /**
11
+ * Resolve `{{key}}` template placeholders in a string.
12
+ *
13
+ * Resolution priority (first non-empty wins):
14
+ * 1. Session — dynamic values set during session setup (e.g., auth tokens)
15
+ * 2. Secrets — from `.env.secrets`
16
+ * 3. Vars — from `.env`
17
+ *
18
+ * Session values must be strings to resolve in templates. Non-string session
19
+ * values are silently skipped (they're still accessible via `ctx.session.get()`).
20
+ */
21
+ export function resolveTemplate(template, vars, secrets, session) {
22
+ return template.replace(TEMPLATE_RE, (_match, key) => {
23
+ const sessionValue = session?.[key];
24
+ const value = (typeof sessionValue === "string" ? sessionValue : undefined) ??
25
+ secrets[key] ??
26
+ vars[key];
27
+ if (value === undefined || value === null || value === "") {
28
+ throw new Error(`Missing value for template placeholder "{{${key}}}" in configure() http headers. ` +
29
+ `Ensure "${key}" is available in session, as a secret, or as a var.`);
30
+ }
31
+ return value;
32
+ });
33
+ }
34
+ //# sourceMappingURL=template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/configure/template.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iDAAiD;AACjD,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAE/C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAgB,EAChB,IAA4B,EAC5B,OAA+B,EAC/B,OAAiC;IAEjC,OAAO,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,GAAW,EAAE,EAAE;QAC3D,MAAM,YAAY,GAAG,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;QACpC,MAAM,KAAK,GACT,CAAC,OAAO,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;YAC7D,OAAO,CAAC,GAAG,CAAC;YACZ,IAAI,CAAC,GAAG,CAAC,CAAC;QACZ,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;YAC1D,MAAM,IAAI,KAAK,CACb,6CAA6C,GAAG,mCAAmC;gBACjF,WAAW,GAAG,sDAAsD,CACvE,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @module configure/vars
3
+ *
4
+ * Lazy vars and secrets accessor builders for configure().
5
+ *
6
+ * Each property is an Object.defineProperty getter that resolves at access time.
7
+ * Values support `{{key}}` template syntax or literal strings.
8
+ * Not cached — re-reads runtime on every access so session updates are visible.
9
+ */
10
+ /**
11
+ * Build a lazy vars accessor. Each property resolves via resolveTemplate on access.
12
+ * @internal
13
+ */
14
+ export declare function buildLazyVars<V extends Record<string, string>>(mapping: Record<string, string>): Readonly<V>;
15
+ /**
16
+ * Build a lazy secrets accessor. Each property resolves via resolveTemplate on access.
17
+ * @internal
18
+ */
19
+ export declare function buildLazySecrets<S extends Record<string, string>>(mapping: Record<string, string>): Readonly<S>;
20
+ //# sourceMappingURL=vars.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vars.d.ts","sourceRoot":"","sources":["../../src/configure/vars.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,QAAQ,CAAC,CAAC,CAAC,CAab;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,QAAQ,CAAC,CAAC,CAAC,CAab"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @module configure/vars
3
+ *
4
+ * Lazy vars and secrets accessor builders for configure().
5
+ *
6
+ * Each property is an Object.defineProperty getter that resolves at access time.
7
+ * Values support `{{key}}` template syntax or literal strings.
8
+ * Not cached — re-reads runtime on every access so session updates are visible.
9
+ */
10
+ import { getRuntime } from "./runtime.js";
11
+ import { resolveTemplate } from "./template.js";
12
+ /**
13
+ * Build a lazy vars accessor. Each property resolves via resolveTemplate on access.
14
+ * @internal
15
+ */
16
+ export function buildLazyVars(mapping) {
17
+ const obj = {};
18
+ for (const [prop, value] of Object.entries(mapping)) {
19
+ Object.defineProperty(obj, prop, {
20
+ get() {
21
+ const runtime = getRuntime();
22
+ return resolveTemplate(value, runtime.vars, runtime.secrets, runtime.session);
23
+ },
24
+ enumerable: true,
25
+ configurable: false,
26
+ });
27
+ }
28
+ return obj;
29
+ }
30
+ /**
31
+ * Build a lazy secrets accessor. Each property resolves via resolveTemplate on access.
32
+ * @internal
33
+ */
34
+ export function buildLazySecrets(mapping) {
35
+ const obj = {};
36
+ for (const [prop, value] of Object.entries(mapping)) {
37
+ Object.defineProperty(obj, prop, {
38
+ get() {
39
+ const runtime = getRuntime();
40
+ return resolveTemplate(value, runtime.vars, runtime.secrets, runtime.session);
41
+ },
42
+ enumerable: true,
43
+ configurable: false,
44
+ });
45
+ }
46
+ return obj;
47
+ }
48
+ //# sourceMappingURL=vars.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vars.js","sourceRoot":"","sources":["../../src/configure/vars.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,OAA+B;IAE/B,MAAM,GAAG,GAAG,EAA4B,CAAC;IACzC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACpD,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE;YAC/B,GAAG;gBACD,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;gBAC7B,OAAO,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YAChF,CAAC;YACD,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAA6B,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAA+B;IAE/B,MAAM,GAAG,GAAG,EAA4B,CAAC;IACzC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACpD,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE;YAC/B,GAAG;gBACD,MAAM,OAAO,GAAG,UA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