@soda-gql/core 0.1.0 → 0.3.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 (70) hide show
  1. package/README.md +108 -161
  2. package/dist/adapter.cjs +35 -0
  3. package/dist/adapter.cjs.map +1 -0
  4. package/dist/adapter.d.cts +35 -0
  5. package/dist/adapter.d.cts.map +1 -0
  6. package/dist/adapter.d.ts +35 -0
  7. package/dist/adapter.d.ts.map +1 -0
  8. package/dist/adapter.js +34 -0
  9. package/dist/adapter.js.map +1 -0
  10. package/dist/index-DH3lMepk.d.cts +569 -0
  11. package/dist/index-DH3lMepk.d.cts.map +1 -0
  12. package/dist/index-WU6aMZjg.d.ts +569 -0
  13. package/dist/index-WU6aMZjg.d.ts.map +1 -0
  14. package/dist/index.cjs +485 -470
  15. package/dist/index.cjs.map +1 -0
  16. package/dist/index.d.cts +97 -3
  17. package/dist/index.d.cts.map +1 -0
  18. package/dist/index.d.ts +97 -3
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +458 -443
  21. package/dist/index.js.map +1 -1
  22. package/dist/runtime.cjs +85 -0
  23. package/dist/runtime.cjs.map +1 -0
  24. package/dist/runtime.d.cts +40 -0
  25. package/dist/runtime.d.cts.map +1 -0
  26. package/dist/runtime.d.ts +40 -0
  27. package/dist/runtime.d.ts.map +1 -0
  28. package/dist/runtime.js +82 -0
  29. package/dist/runtime.js.map +1 -0
  30. package/dist/schema-BElqa12z.d.cts +520 -0
  31. package/dist/schema-BElqa12z.d.cts.map +1 -0
  32. package/dist/schema-BbCrsNkQ.js +86 -0
  33. package/dist/schema-BbCrsNkQ.js.map +1 -0
  34. package/dist/schema-C7q047S0.d.ts +520 -0
  35. package/dist/schema-C7q047S0.d.ts.map +1 -0
  36. package/dist/schema-DuWaRhdp.cjs +122 -0
  37. package/dist/schema-DuWaRhdp.cjs.map +1 -0
  38. package/dist/schema-builder-DDfulXP3.d.cts +40 -0
  39. package/dist/schema-builder-DDfulXP3.d.cts.map +1 -0
  40. package/dist/schema-builder-DfyTaFMt.d.ts +40 -0
  41. package/dist/schema-builder-DfyTaFMt.d.ts.map +1 -0
  42. package/package.json +34 -14
  43. package/dist/index-DYwkqPzd.d.ts +0 -1015
  44. package/dist/index-DYwkqPzd.d.ts.map +0 -1
  45. package/dist/index-Db9ogofS.d.ts +0 -365
  46. package/dist/index-Db9ogofS.d.ts.map +0 -1
  47. package/dist/index-Dth0NSJt.d.cts +0 -1015
  48. package/dist/index-Dth0NSJt.d.cts.map +0 -1
  49. package/dist/index-zGZ61WLt.d.cts +0 -365
  50. package/dist/index-zGZ61WLt.d.cts.map +0 -1
  51. package/dist/merge-CeMx09is.js +0 -74
  52. package/dist/merge-CeMx09is.js.map +0 -1
  53. package/dist/merge-ZxKV1syS.cjs +0 -85
  54. package/dist/metadata/index.cjs +0 -62
  55. package/dist/metadata/index.d.cts +0 -71
  56. package/dist/metadata/index.d.cts.map +0 -1
  57. package/dist/metadata/index.d.ts +0 -71
  58. package/dist/metadata/index.d.ts.map +0 -1
  59. package/dist/metadata/index.js +0 -59
  60. package/dist/metadata/index.js.map +0 -1
  61. package/dist/runtime/index.cjs +0 -107
  62. package/dist/runtime/index.d.cts +0 -72
  63. package/dist/runtime/index.d.cts.map +0 -1
  64. package/dist/runtime/index.d.ts +0 -72
  65. package/dist/runtime/index.d.ts.map +0 -1
  66. package/dist/runtime/index.js +0 -104
  67. package/dist/runtime/index.js.map +0 -1
  68. package/dist/slice-BuSNc8vw.js +0 -278
  69. package/dist/slice-BuSNc8vw.js.map +0 -1
  70. package/dist/slice-C-FIQK-f.cjs +0 -373
@@ -1,104 +0,0 @@
1
- import { a as createVarRefs, c as createExecutionResultParser, r as hidden, t as createRuntimeSlice } from "../slice-BuSNc8vw.js";
2
-
3
- //#region packages/core/src/runtime/runtime-registry.ts
4
- const composedOperationRegistry = /* @__PURE__ */ new Map();
5
- const inlineOperationRegistry = /* @__PURE__ */ new Map();
6
- const registerComposedOperation = (operation) => {
7
- composedOperationRegistry.set(operation.operationName, operation);
8
- };
9
- const registerInlineOperation = (operation) => {
10
- inlineOperationRegistry.set(operation.operationName, operation);
11
- };
12
- const getComposedOperation = (name) => {
13
- const operation = composedOperationRegistry.get(name);
14
- if (!operation) throw new Error(`Operation ${name} not found`);
15
- return operation;
16
- };
17
- const getInlineOperation = (name) => {
18
- const operation = inlineOperationRegistry.get(name);
19
- if (!operation) throw new Error(`Operation ${name} not found`);
20
- return operation;
21
- };
22
- /**
23
- * Test-only function to reset the operation registry
24
- * @internal
25
- */
26
- const __resetRuntimeRegistry = () => {
27
- composedOperationRegistry.clear();
28
- inlineOperationRegistry.clear();
29
- };
30
- /**
31
- * Test-only function to get all registered composed operations
32
- * @internal
33
- */
34
- const __getRegisteredComposedOperations = () => {
35
- return composedOperationRegistry;
36
- };
37
- /**
38
- * Test-only function to get all registered inline operations
39
- * @internal
40
- */
41
- const __getRegisteredInlineOperations = () => {
42
- return inlineOperationRegistry;
43
- };
44
-
45
- //#endregion
46
- //#region packages/core/src/runtime/composed-operation.ts
47
- const createRuntimeComposedOperation = (input) => {
48
- const operation = {
49
- operationType: input.prebuild.operationType,
50
- operationName: input.prebuild.operationName,
51
- variableNames: input.prebuild.variableNames,
52
- projectionPathGraph: input.prebuild.projectionPathGraph,
53
- document: input.prebuild.document,
54
- parse: createExecutionResultParser({
55
- fragments: input.runtime.getSlices({ $: createVarRefs(Object.fromEntries(input.prebuild.variableNames.map((name) => [name, null]))) }),
56
- projectionPathGraph: input.prebuild.projectionPathGraph
57
- }),
58
- metadata: input.prebuild.metadata
59
- };
60
- registerComposedOperation(operation);
61
- return operation;
62
- };
63
-
64
- //#endregion
65
- //#region packages/core/src/runtime/inline-operation.ts
66
- const createRuntimeInlineOperation = (input) => {
67
- const operation = {
68
- operationType: input.prebuild.operationType,
69
- operationName: input.prebuild.operationName,
70
- variableNames: input.prebuild.variableNames,
71
- documentSource: hidden(),
72
- document: input.prebuild.document,
73
- metadata: input.prebuild.metadata
74
- };
75
- registerInlineOperation(operation);
76
- return operation;
77
- };
78
-
79
- //#endregion
80
- //#region packages/core/src/runtime/model.ts
81
- const createRuntimeModel = (input) => ({
82
- typename: input.prebuild.typename,
83
- fragment: hidden(),
84
- normalize: input.runtime.normalize
85
- });
86
-
87
- //#endregion
88
- //#region packages/core/src/runtime/runtime-adapter.ts
89
- const createRuntimeAdapter = (factory) => factory({ type: hidden });
90
-
91
- //#endregion
92
- //#region packages/core/src/runtime/index.ts
93
- const gqlRuntime = {
94
- model: createRuntimeModel,
95
- composedOperation: createRuntimeComposedOperation,
96
- inlineOperation: createRuntimeInlineOperation,
97
- slice: createRuntimeSlice,
98
- getComposedOperation,
99
- getInlineOperation
100
- };
101
-
102
- //#endregion
103
- export { __getRegisteredComposedOperations, __getRegisteredInlineOperations, __resetRuntimeRegistry, createRuntimeAdapter, gqlRuntime };
104
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/runtime/runtime-registry.ts","../../src/runtime/composed-operation.ts","../../src/runtime/inline-operation.ts","../../src/runtime/model.ts","../../src/runtime/runtime-adapter.ts","../../src/runtime/index.ts"],"sourcesContent":["import type { AnyComposedOperationOf, AnyInlineOperationOf } from \"../types/element\";\nimport type { OperationType } from \"../types/schema\";\n\nconst composedOperationRegistry = new Map<string, AnyComposedOperationOf<OperationType>>();\nconst inlineOperationRegistry = new Map<string, AnyInlineOperationOf<OperationType>>();\n\nexport const registerComposedOperation = (operation: AnyComposedOperationOf<OperationType>) => {\n composedOperationRegistry.set(operation.operationName, operation);\n};\n\nexport const registerInlineOperation = (operation: AnyInlineOperationOf<OperationType>) => {\n inlineOperationRegistry.set(operation.operationName, operation);\n};\n\nexport const getComposedOperation = (name: string) => {\n const operation = composedOperationRegistry.get(name);\n if (!operation) {\n throw new Error(`Operation ${name} not found`);\n }\n return operation;\n};\n\nexport const getInlineOperation = (name: string) => {\n const operation = inlineOperationRegistry.get(name);\n if (!operation) {\n throw new Error(`Operation ${name} not found`);\n }\n return operation;\n};\n\n/**\n * Test-only function to reset the operation registry\n * @internal\n */\nexport const __resetRuntimeRegistry = () => {\n composedOperationRegistry.clear();\n inlineOperationRegistry.clear();\n};\n\n/**\n * Test-only function to get all registered composed operations\n * @internal\n */\nexport const __getRegisteredComposedOperations = (): ReadonlyMap<string, AnyComposedOperationOf<OperationType>> => {\n return composedOperationRegistry;\n};\n\n/**\n * Test-only function to get all registered inline operations\n * @internal\n */\nexport const __getRegisteredInlineOperations = (): ReadonlyMap<string, AnyInlineOperationOf<OperationType>> => {\n return inlineOperationRegistry;\n};\n","import { createVarRefs } from \"../composer/input\";\nimport type { AnyComposedOperationOf, AnySlicePayload } from \"../types/element\";\nimport type { AnyAssignableInput } from \"../types/fragment\";\nimport type { AnyGraphqlSchema, OperationType } from \"../types/schema\";\nimport type { InputTypeSpecifier, InputTypeSpecifiers } from \"../types/type-foundation\";\nimport type { StripFunctions, StripSymbols } from \"../utils/type-utils\";\nimport { createExecutionResultParser } from \"./parse-execution-result\";\nimport { registerComposedOperation } from \"./runtime-registry\";\n\nexport type RuntimeComposedOperationInput = {\n prebuild: StripFunctions<AnyComposedOperationOf<OperationType>>;\n runtime: {\n getSlices: (tools: { $: AnyAssignableInput }) => { [key: string]: AnySlicePayload };\n };\n};\n\nexport const createRuntimeComposedOperation = (input: RuntimeComposedOperationInput): AnyComposedOperationOf<OperationType> => {\n const operation = {\n operationType: input.prebuild.operationType,\n operationName: input.prebuild.operationName,\n variableNames: input.prebuild.variableNames,\n projectionPathGraph: input.prebuild.projectionPathGraph,\n document: input.prebuild.document,\n parse: createExecutionResultParser({\n fragments: input.runtime.getSlices({\n $: createVarRefs<AnyGraphqlSchema, InputTypeSpecifiers>(\n Object.fromEntries(input.prebuild.variableNames.map((name) => [name, null as unknown as InputTypeSpecifier])),\n ),\n }),\n projectionPathGraph: input.prebuild.projectionPathGraph,\n }),\n metadata: input.prebuild.metadata,\n } satisfies StripSymbols<AnyComposedOperationOf<OperationType>> as AnyComposedOperationOf<OperationType>;\n\n registerComposedOperation(operation);\n\n return operation;\n};\n","import type { AnyInlineOperationOf } from \"../types/element\";\nimport type { OperationType } from \"../types/schema\";\nimport { hidden } from \"../utils/hidden\";\nimport type { StripFunctions, StripSymbols } from \"../utils/type-utils\";\nimport { registerInlineOperation } from \"./runtime-registry\";\n\nexport type RuntimeInlineOperationInput = {\n prebuild: StripFunctions<AnyInlineOperationOf<OperationType>>;\n runtime: {};\n};\n\nexport const createRuntimeInlineOperation = (input: RuntimeInlineOperationInput): AnyInlineOperationOf<OperationType> => {\n const operation = {\n operationType: input.prebuild.operationType,\n operationName: input.prebuild.operationName,\n variableNames: input.prebuild.variableNames,\n documentSource: hidden(),\n document: input.prebuild.document,\n metadata: input.prebuild.metadata,\n } satisfies StripSymbols<AnyInlineOperationOf<OperationType>> as AnyInlineOperationOf<OperationType>;\n\n registerInlineOperation(operation);\n\n return operation;\n};\n","import type { AnyModel } from \"../types/element\";\nimport { hidden } from \"../utils/hidden\";\nimport type { StripFunctions, StripSymbols } from \"../utils/type-utils\";\n\nexport type RuntimeModelInput = {\n prebuild: StripFunctions<AnyModel>;\n runtime: {\n // biome-ignore lint/suspicious/noExplicitAny: any is ok here\n normalize: (raw: any) => object;\n };\n};\n\nexport const createRuntimeModel = (input: RuntimeModelInput): AnyModel =>\n ({\n typename: input.prebuild.typename,\n fragment: hidden(),\n normalize: input.runtime.normalize,\n }) satisfies StripSymbols<AnyModel> as unknown as AnyModel;\n","import type { AnyGraphqlRuntimeAdapter } from \"../types/runtime\";\nimport type { Hidden } from \"../utils/hidden\";\nimport { hidden } from \"../utils/hidden\";\n\ntype RuntimeAdapterFactory<TRuntimeAdapter extends AnyGraphqlRuntimeAdapter> = (tools: {\n type: <T>() => Hidden<T>;\n}) => TRuntimeAdapter;\n\nexport const createRuntimeAdapter = <TRuntimeAdapter extends AnyGraphqlRuntimeAdapter>(\n factory: RuntimeAdapterFactory<TRuntimeAdapter>,\n) => factory({ type: hidden });\n","import { createRuntimeComposedOperation } from \"./composed-operation\";\nimport { createRuntimeInlineOperation } from \"./inline-operation\";\nimport { createRuntimeModel } from \"./model\";\nimport { getComposedOperation, getInlineOperation } from \"./runtime-registry\";\nimport { createRuntimeSlice } from \"./slice\";\n\nexport type { RuntimeComposedOperationInput } from \"./composed-operation\";\nexport type { RuntimeInlineOperationInput } from \"./inline-operation\";\nexport type { RuntimeModelInput } from \"./model\";\nexport { createRuntimeAdapter } from \"./runtime-adapter\";\nexport {\n __getRegisteredComposedOperations,\n __getRegisteredInlineOperations,\n __resetRuntimeRegistry,\n} from \"./runtime-registry\";\nexport type { RuntimeSliceInput } from \"./slice\";\n\nexport const gqlRuntime = {\n model: createRuntimeModel,\n composedOperation: createRuntimeComposedOperation,\n inlineOperation: createRuntimeInlineOperation,\n slice: createRuntimeSlice,\n getComposedOperation,\n getInlineOperation,\n};\n"],"mappings":";;;AAGA,MAAM,4CAA4B,IAAI,KAAoD;AAC1F,MAAM,0CAA0B,IAAI,KAAkD;AAEtF,MAAa,6BAA6B,cAAqD;AAC7F,2BAA0B,IAAI,UAAU,eAAe,UAAU;;AAGnE,MAAa,2BAA2B,cAAmD;AACzF,yBAAwB,IAAI,UAAU,eAAe,UAAU;;AAGjE,MAAa,wBAAwB,SAAiB;CACpD,MAAM,YAAY,0BAA0B,IAAI,KAAK;AACrD,KAAI,CAAC,UACH,OAAM,IAAI,MAAM,aAAa,KAAK,YAAY;AAEhD,QAAO;;AAGT,MAAa,sBAAsB,SAAiB;CAClD,MAAM,YAAY,wBAAwB,IAAI,KAAK;AACnD,KAAI,CAAC,UACH,OAAM,IAAI,MAAM,aAAa,KAAK,YAAY;AAEhD,QAAO;;;;;;AAOT,MAAa,+BAA+B;AAC1C,2BAA0B,OAAO;AACjC,yBAAwB,OAAO;;;;;;AAOjC,MAAa,0CAAsG;AACjH,QAAO;;;;;;AAOT,MAAa,wCAAkG;AAC7G,QAAO;;;;;ACpCT,MAAa,kCAAkC,UAAgF;CAC7H,MAAM,YAAY;EAChB,eAAe,MAAM,SAAS;EAC9B,eAAe,MAAM,SAAS;EAC9B,eAAe,MAAM,SAAS;EAC9B,qBAAqB,MAAM,SAAS;EACpC,UAAU,MAAM,SAAS;EACzB,OAAO,4BAA4B;GACjC,WAAW,MAAM,QAAQ,UAAU,EACjC,GAAG,cACD,OAAO,YAAY,MAAM,SAAS,cAAc,KAAK,SAAS,CAAC,MAAM,KAAsC,CAAC,CAAC,CAC9G,EACF,CAAC;GACF,qBAAqB,MAAM,SAAS;GACrC,CAAC;EACF,UAAU,MAAM,SAAS;EAC1B;AAED,2BAA0B,UAAU;AAEpC,QAAO;;;;;ACzBT,MAAa,gCAAgC,UAA4E;CACvH,MAAM,YAAY;EAChB,eAAe,MAAM,SAAS;EAC9B,eAAe,MAAM,SAAS;EAC9B,eAAe,MAAM,SAAS;EAC9B,gBAAgB,QAAQ;EACxB,UAAU,MAAM,SAAS;EACzB,UAAU,MAAM,SAAS;EAC1B;AAED,yBAAwB,UAAU;AAElC,QAAO;;;;;ACXT,MAAa,sBAAsB,WAChC;CACC,UAAU,MAAM,SAAS;CACzB,UAAU,QAAQ;CAClB,WAAW,MAAM,QAAQ;CAC1B;;;;ACTH,MAAa,wBACX,YACG,QAAQ,EAAE,MAAM,QAAQ,CAAC;;;;ACO9B,MAAa,aAAa;CACxB,OAAO;CACP,mBAAmB;CACnB,iBAAiB;CACjB,OAAO;CACP;CACA;CACD"}
@@ -1,278 +0,0 @@
1
- //#region packages/core/src/types/type-foundation/var-ref.ts
2
- var VarRef = class {
3
- constructor(inner) {
4
- this.inner = inner;
5
- }
6
- static getInner(varRef) {
7
- return varRef.inner;
8
- }
9
- };
10
- const isVarRef = (value) => {
11
- return typeof value === "object" && value !== null && value instanceof VarRef;
12
- };
13
- const createVarRefFromVariable = (name) => {
14
- return new VarRef({
15
- type: "variable",
16
- name
17
- });
18
- };
19
- const createVarRefFromConstValue = (value) => {
20
- return new VarRef({
21
- type: "const-value",
22
- value
23
- });
24
- };
25
- const getVarRefInner = (varRef) => {
26
- return VarRef.getInner(varRef);
27
- };
28
- /**
29
- * Get the variable name from a VarRef.
30
- * Throws if the VarRef contains a const-value instead of a variable reference.
31
- */
32
- const getVarRefName = (varRef) => {
33
- const inner = VarRef.getInner(varRef);
34
- if (inner.type !== "variable") throw new Error("Expected variable reference, got const-value");
35
- return inner.name;
36
- };
37
- /**
38
- * Get the const value from a VarRef.
39
- * Throws if the VarRef contains a variable reference instead of a const-value.
40
- */
41
- const getVarRefValue = (varRef) => {
42
- const inner = VarRef.getInner(varRef);
43
- if (inner.type !== "const-value") throw new Error("Expected const-value, got variable reference");
44
- return inner.value;
45
- };
46
-
47
- //#endregion
48
- //#region packages/core/src/types/runtime/projection.ts
49
- /**
50
- * Nominal type representing any slice selection regardless of schema specifics.
51
- * Encodes how individual slices map a concrete field path to a projection
52
- * function. Multiple selections allow slices to expose several derived values.
53
- */
54
- var Projection = class {
55
- constructor(paths, projector) {
56
- this.projector = projector;
57
- this.paths = paths.map((path) => createProjectionPath(path));
58
- }
59
- paths;
60
- };
61
- function createProjectionPath(path) {
62
- const segments = path.split(".");
63
- if (path === "$" || segments.length <= 1) throw new Error("Field path must not be only $ or empty");
64
- return {
65
- full: path,
66
- segments: segments.slice(1)
67
- };
68
- }
69
-
70
- //#endregion
71
- //#region packages/core/src/types/runtime/sliced-execution-result.ts
72
- /** Runtime guard interface shared by all slice result variants. */
73
- var SlicedExecutionResultGuards = class {
74
- isSuccess() {
75
- return this.type === "success";
76
- }
77
- isError() {
78
- return this.type === "error";
79
- }
80
- isEmpty() {
81
- return this.type === "empty";
82
- }
83
- constructor(type) {
84
- this.type = type;
85
- }
86
- };
87
- /** Variant representing an empty payload (no data, no error). */
88
- var SlicedExecutionResultEmpty = class extends SlicedExecutionResultGuards {
89
- constructor() {
90
- super("empty");
91
- }
92
- unwrap() {
93
- return null;
94
- }
95
- safeUnwrap() {
96
- return {
97
- data: void 0,
98
- error: void 0
99
- };
100
- }
101
- };
102
- /** Variant representing a successful payload. */
103
- var SlicedExecutionResultSuccess = class extends SlicedExecutionResultGuards {
104
- constructor(data, extensions) {
105
- super("success");
106
- this.data = data;
107
- this.extensions = extensions;
108
- }
109
- unwrap() {
110
- return this.data;
111
- }
112
- safeUnwrap(transform) {
113
- return {
114
- data: transform(this.data),
115
- error: void 0
116
- };
117
- }
118
- };
119
- /** Variant representing an error payload created by the adapter. */
120
- var SlicedExecutionResultError = class extends SlicedExecutionResultGuards {
121
- constructor(error, extensions) {
122
- super("error");
123
- this.error = error;
124
- this.extensions = extensions;
125
- }
126
- unwrap() {
127
- throw this.error;
128
- }
129
- safeUnwrap() {
130
- return {
131
- data: void 0,
132
- error: this.error
133
- };
134
- }
135
- };
136
-
137
- //#endregion
138
- //#region packages/core/src/runtime/parse-execution-result.ts
139
- function* generateErrorMapEntries(errors, projectionPathGraph) {
140
- for (const error of errors) {
141
- const errorPath = error.path ?? [];
142
- let stack = projectionPathGraph;
143
- for (let i = 0; i <= errorPath.length; i++) {
144
- const segment = errorPath[i];
145
- if (segment == null || typeof segment === "number") {
146
- yield* stack.matches.map(({ label, path }) => ({
147
- label,
148
- path,
149
- error
150
- }));
151
- break;
152
- }
153
- yield* stack.matches.filter(({ exact }) => exact).map(({ label, path }) => ({
154
- label,
155
- path,
156
- error
157
- }));
158
- const next = stack.children[segment];
159
- if (!next) break;
160
- stack = next;
161
- }
162
- }
163
- }
164
- const createErrorMaps = (errors, projectionPathGraph) => {
165
- const errorMaps = {};
166
- for (const { label, path, error } of generateErrorMapEntries(errors ?? [], projectionPathGraph)) {
167
- const mapPerLabel = errorMaps[label] || (errorMaps[label] = {});
168
- (mapPerLabel[path] || (mapPerLabel[path] = [])).push({ error });
169
- }
170
- return errorMaps;
171
- };
172
- const accessDataByPathSegments = (data, pathSegments) => {
173
- let current = data;
174
- for (const segment of pathSegments) {
175
- if (current == null) return { error: /* @__PURE__ */ new Error("No data") };
176
- if (typeof current !== "object") return { error: /* @__PURE__ */ new Error("Incorrect data type") };
177
- if (Array.isArray(current)) return { error: /* @__PURE__ */ new Error("Incorrect data type") };
178
- current = current[segment];
179
- }
180
- return { data: current };
181
- };
182
- const createExecutionResultParser = ({ fragments, projectionPathGraph }) => {
183
- const prepare = (result) => {
184
- if (result.type === "graphql") {
185
- const errorMaps = createErrorMaps(result.body.errors, projectionPathGraph);
186
- return {
187
- ...result,
188
- errorMaps
189
- };
190
- }
191
- if (result.type === "non-graphql-error") return {
192
- ...result,
193
- error: new SlicedExecutionResultError({
194
- type: "non-graphql-error",
195
- error: result.error
196
- })
197
- };
198
- if (result.type === "empty") return {
199
- ...result,
200
- error: new SlicedExecutionResultEmpty()
201
- };
202
- throw new Error("Invalid result type", { cause: result });
203
- };
204
- return (result) => {
205
- const prepared = prepare(result);
206
- const entries = Object.entries(fragments).map(([label, fragment]) => {
207
- const { projection } = fragment;
208
- if (prepared.type === "graphql") {
209
- const matchedErrors = projection.paths.flatMap(({ full: raw }) => prepared.errorMaps[label]?.[raw] ?? []);
210
- const uniqueErrors = Array.from(new Set(matchedErrors.map(({ error }) => error)).values());
211
- if (uniqueErrors.length > 0) return [label, projection.projector(new SlicedExecutionResultError({
212
- type: "graphql-error",
213
- errors: uniqueErrors
214
- }))];
215
- const dataResults = projection.paths.map(({ segments }) => prepared.body.data ? accessDataByPathSegments(prepared.body.data, segments) : { error: /* @__PURE__ */ new Error("No data") });
216
- if (dataResults.some(({ error }) => error)) {
217
- const errors = dataResults.flatMap(({ error }) => error ? [error] : []);
218
- return [label, projection.projector(new SlicedExecutionResultError({
219
- type: "parse-error",
220
- errors
221
- }))];
222
- }
223
- const dataList = dataResults.map(({ data }) => data);
224
- return [label, projection.projector(new SlicedExecutionResultSuccess(dataList))];
225
- }
226
- if (prepared.type === "non-graphql-error") return [label, projection.projector(prepared.error)];
227
- if (prepared.type === "empty") return [label, projection.projector(prepared.error)];
228
- throw new Error("Invalid result type", { cause: prepared });
229
- });
230
- return Object.fromEntries(entries);
231
- };
232
- };
233
-
234
- //#endregion
235
- //#region packages/core/src/utils/map-values.ts
236
- function mapValues(obj, fn) {
237
- return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, fn(value, key)]));
238
- }
239
-
240
- //#endregion
241
- //#region packages/core/src/composer/input.ts
242
- const mergeVarDefinitions = (definitions) => Object.assign({}, ...definitions);
243
- const createVarAssignments = (definitions, providedValues) => {
244
- return mapValues(definitions, (_definition, key) => {
245
- const varName = key;
246
- if (!providedValues || providedValues[varName] === void 0) return createVarRefFromConstValue(void 0);
247
- const provided = providedValues[varName];
248
- if (isVarRef(provided)) return provided;
249
- return createVarRefFromConstValue(provided);
250
- });
251
- };
252
- const createVarRefs = (definitions) => mapValues(definitions, (_ref, name) => createVarRefFromVariable(name));
253
-
254
- //#endregion
255
- //#region packages/core/src/utils/hidden.ts
256
- const _dummy = () => {
257
- throw new Error("DO NOT CALL THIS FUNCTION -- we use function to safely transfer type information");
258
- };
259
- const hidden = () => _dummy;
260
-
261
- //#endregion
262
- //#region packages/core/src/runtime/slice.ts
263
- const handleProjectionBuilder = (projectionBuilder) => projectionBuilder({ select: (path, projector) => new Projection(path, projector) });
264
- const createRuntimeSlice = (input) => {
265
- const projection = handleProjectionBuilder(input.runtime.buildProjection);
266
- return {
267
- operationType: input.prebuild.operationType,
268
- embed: (variables) => ({
269
- variables,
270
- getFields: hidden(),
271
- projection
272
- })
273
- };
274
- };
275
-
276
- //#endregion
277
- export { createVarRefs as a, createExecutionResultParser as c, SlicedExecutionResultSuccess as d, Projection as f, getVarRefValue as g, getVarRefName as h, createVarAssignments as i, SlicedExecutionResultEmpty as l, getVarRefInner as m, handleProjectionBuilder as n, mergeVarDefinitions as o, VarRef as p, hidden as r, mapValues as s, createRuntimeSlice as t, SlicedExecutionResultError as u };
278
- //# sourceMappingURL=slice-BuSNc8vw.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slice-BuSNc8vw.js","names":["inner: VarRefInner","projector: (result: AnySlicedExecutionResult) => TProjected","type: \"success\" | \"error\" | \"empty\"","data: TData","extensions?: unknown","error: NormalizedError<TRuntimeAdapter>","errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } }","current: unknown"],"sources":["../src/types/type-foundation/var-ref.ts","../src/types/runtime/projection.ts","../src/types/runtime/sliced-execution-result.ts","../src/runtime/parse-execution-result.ts","../src/utils/map-values.ts","../src/composer/input.ts","../src/utils/hidden.ts","../src/runtime/slice.ts"],"sourcesContent":["import type { ConstValue } from \"./const-value\";\nimport type { TypeProfile } from \"./type-profile\";\n\nexport interface AnyVarRefMeta {\n readonly profile: TypeProfile;\n readonly signature: unknown;\n}\n\nexport type VarRefInner =\n | {\n type: \"variable\";\n name: string;\n }\n | {\n type: \"const-value\";\n value: ConstValue;\n };\n\nexport type AnyVarRef = VarRef<any>;\n\ndeclare const __VAR_REF_BRAND__: unique symbol;\nexport class VarRef<TMeta extends AnyVarRefMeta> {\n declare readonly [__VAR_REF_BRAND__]: TMeta;\n\n constructor(private readonly inner: VarRefInner) {}\n\n static getInner(varRef: AnyVarRef): VarRefInner {\n return varRef.inner;\n }\n}\n\nexport const isVarRef = (value: unknown): value is AnyVarRef => {\n return typeof value === \"object\" && value !== null && value instanceof VarRef;\n};\n\nexport const createVarRefFromVariable = <TProfile extends TypeProfile.WithMeta>(name: string) => {\n return new VarRef<TypeProfile.AssigningVarRefMeta<TProfile>>({ type: \"variable\", name });\n};\n\nexport const createVarRefFromConstValue = <TProfile extends TypeProfile.WithMeta>(value: ConstValue) => {\n return new VarRef<TypeProfile.AssigningVarRefMeta<TProfile>>({ type: \"const-value\", value });\n};\n\nexport const getVarRefInner = (varRef: AnyVarRef): VarRefInner => {\n return VarRef.getInner(varRef);\n};\n\n/**\n * Get the variable name from a VarRef.\n * Throws if the VarRef contains a const-value instead of a variable reference.\n */\nexport const getVarRefName = (varRef: AnyVarRef): string => {\n const inner = VarRef.getInner(varRef);\n if (inner.type !== \"variable\") {\n throw new Error(\"Expected variable reference, got const-value\");\n }\n return inner.name;\n};\n\n/**\n * Get the const value from a VarRef.\n * Throws if the VarRef contains a variable reference instead of a const-value.\n */\nexport const getVarRefValue = (varRef: AnyVarRef): ConstValue => {\n const inner = VarRef.getInner(varRef);\n if (inner.type !== \"const-value\") {\n throw new Error(\"Expected const-value, got variable reference\");\n }\n return inner.value;\n};\n","import type { Hidden } from \"../../utils/hidden\";\nimport type { Tuple } from \"../../utils/type-utils\";\nimport type { AnySlicedExecutionResult } from \"./sliced-execution-result\";\n\n/** Shape of a single selection slice projection. */\nexport type AnyProjection = Projection<any>;\n\ndeclare const __PROJECTION_BRAND__: unique symbol;\n/**\n * Nominal type representing any slice selection regardless of schema specifics.\n * Encodes how individual slices map a concrete field path to a projection\n * function. Multiple selections allow slices to expose several derived values.\n */\nexport class Projection<TProjected> {\n declare readonly [__PROJECTION_BRAND__]: Hidden<never>;\n constructor(\n paths: Tuple<string>,\n public readonly projector: (result: AnySlicedExecutionResult) => TProjected,\n ) {\n this.paths = paths.map((path) => createProjectionPath(path));\n }\n\n public readonly paths: ProjectionPath[];\n}\n\nexport type ProjectionPath = {\n full: string;\n segments: Tuple<string>;\n};\n\nfunction createProjectionPath(path: string): ProjectionPath {\n const segments = path.split(\".\");\n if (path === \"$\" || segments.length <= 1) {\n throw new Error(\"Field path must not be only $ or empty\");\n }\n\n return {\n full: path,\n segments: segments.slice(1) as Tuple<string>,\n };\n}\n\nexport type InferExecutionResultProjection<TProjection extends AnyProjection> = ReturnType<TProjection[\"projector\"]>;\n","/** Result-like wrapper types returned from slice projections. */\n\nimport type { NormalizedError } from \"./execution-result\";\nimport type { AnyGraphqlRuntimeAdapter } from \"./runtime-adapter\";\n\nexport type AnySlicedExecutionResult = SlicedExecutionResult<any, AnyGraphqlRuntimeAdapter>;\n\n/**\n * Internal discriminated union describing the Result-like wrapper exposed to\n * slice selection callbacks. The adapter decides how raw errors are\n * materialized.\n */\nexport type AnySlicedExecutionResultRecord = {\n [path: string]: AnySlicedExecutionResult;\n};\n\nexport type SafeUnwrapResult<TTransformed, TError> =\n | {\n data?: never;\n error?: never;\n }\n | {\n data: TTransformed;\n error?: never;\n }\n | {\n data?: never;\n error: TError;\n };\n\n/** Utility signature returned by the safe unwrap helper. */\ntype SlicedExecutionResultCommon<TData, TError> = {\n safeUnwrap<TTransformed>(transform: (data: TData) => TTransformed): SafeUnwrapResult<TTransformed, TError>;\n};\n\n/** Public union used by selection callbacks to inspect data, empty, or error states. */\nexport type SlicedExecutionResult<TData, TRuntimeAdapter extends AnyGraphqlRuntimeAdapter> =\n | SlicedExecutionResultEmpty<TData, TRuntimeAdapter>\n | SlicedExecutionResultSuccess<TData, TRuntimeAdapter>\n | SlicedExecutionResultError<TData, TRuntimeAdapter>;\n\n/** Runtime guard interface shared by all slice result variants. */\nclass SlicedExecutionResultGuards<TData, TRuntimeAdapter extends AnyGraphqlRuntimeAdapter> {\n isSuccess(): this is SlicedExecutionResultSuccess<TData, TRuntimeAdapter> {\n return this.type === \"success\";\n }\n isError(): this is SlicedExecutionResultError<TData, TRuntimeAdapter> {\n return this.type === \"error\";\n }\n isEmpty(): this is SlicedExecutionResultEmpty<TData, TRuntimeAdapter> {\n return this.type === \"empty\";\n }\n\n constructor(private readonly type: \"success\" | \"error\" | \"empty\") {}\n}\n\n/** Variant representing an empty payload (no data, no error). */\nexport class SlicedExecutionResultEmpty<TData, TRuntimeAdapter extends AnyGraphqlRuntimeAdapter>\n extends SlicedExecutionResultGuards<TData, TRuntimeAdapter>\n implements SlicedExecutionResultCommon<TData, NormalizedError<TRuntimeAdapter>>\n{\n constructor() {\n super(\"empty\");\n }\n\n unwrap(): null {\n return null;\n }\n\n safeUnwrap() {\n return {\n data: undefined,\n error: undefined,\n };\n }\n}\n\n/** Variant representing a successful payload. */\nexport class SlicedExecutionResultSuccess<TData, TRuntimeAdapter extends AnyGraphqlRuntimeAdapter>\n extends SlicedExecutionResultGuards<TData, TRuntimeAdapter>\n implements SlicedExecutionResultCommon<TData, NormalizedError<TRuntimeAdapter>>\n{\n constructor(\n public readonly data: TData,\n public readonly extensions?: unknown,\n ) {\n super(\"success\");\n }\n\n unwrap(): TData {\n return this.data;\n }\n\n safeUnwrap<TTransformed>(transform: (data: TData) => TTransformed) {\n return {\n data: transform(this.data),\n error: undefined,\n };\n }\n}\n\n/** Variant representing an error payload created by the adapter. */\nexport class SlicedExecutionResultError<TData, TRuntimeAdapter extends AnyGraphqlRuntimeAdapter>\n extends SlicedExecutionResultGuards<TData, TRuntimeAdapter>\n implements SlicedExecutionResultCommon<TData, NormalizedError<TRuntimeAdapter>>\n{\n constructor(\n public readonly error: NormalizedError<TRuntimeAdapter>,\n public readonly extensions?: unknown,\n ) {\n super(\"error\");\n }\n\n unwrap(): never {\n throw this.error;\n }\n\n safeUnwrap() {\n return {\n data: undefined,\n error: this.error,\n };\n }\n}\n","import type { GraphQLFormattedError } from \"graphql\";\nimport type { AnySlicePayloads, ProjectionPathGraphNode } from \"../types/element\";\nimport {\n type AnyGraphqlRuntimeAdapter,\n SlicedExecutionResultEmpty,\n SlicedExecutionResultError,\n SlicedExecutionResultSuccess,\n} from \"../types/runtime\";\nimport type { NormalizedExecutionResult } from \"../types/runtime/execution-result\";\n\nfunction* generateErrorMapEntries(errors: readonly GraphQLFormattedError[], projectionPathGraph: ProjectionPathGraphNode) {\n for (const error of errors) {\n const errorPath = error.path ?? [];\n let stack = projectionPathGraph;\n\n for (\n let i = 0;\n // i <= errorPath.length to handle the case where the error path is empty\n i <= errorPath.length;\n i++\n ) {\n const segment = errorPath[i];\n\n if (\n // the end of the path\n segment == null ||\n // FieldPath does not support index access. We treat it as the end of the path.\n typeof segment === \"number\"\n ) {\n yield* stack.matches.map(({ label, path }) => ({ label, path, error }));\n break;\n }\n\n yield* stack.matches.filter(({ exact }) => exact).map(({ label, path }) => ({ label, path, error }));\n\n const next = stack.children[segment];\n if (!next) {\n break;\n }\n\n stack = next;\n }\n }\n}\n\nconst createErrorMaps = (errors: readonly GraphQLFormattedError[] | undefined, projectionPathGraph: ProjectionPathGraphNode) => {\n const errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } } = {};\n for (const { label, path, error } of generateErrorMapEntries(errors ?? [], projectionPathGraph)) {\n const mapPerLabel = errorMaps[label] || (errorMaps[label] = {});\n const mapPerPath = mapPerLabel[path] || (mapPerLabel[path] = []);\n mapPerPath.push({ error });\n }\n return errorMaps;\n};\n\nconst accessDataByPathSegments = (data: object, pathSegments: string[]) => {\n let current: unknown = data;\n\n for (const segment of pathSegments) {\n if (current == null) {\n return { error: new Error(\"No data\") };\n }\n\n if (typeof current !== \"object\") {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n if (Array.isArray(current)) {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n current = (current as Record<string, unknown>)[segment];\n }\n\n return { data: current };\n};\n\nexport const createExecutionResultParser = <TRuntimeAdapter extends AnyGraphqlRuntimeAdapter>({\n fragments,\n projectionPathGraph,\n}: {\n fragments: AnySlicePayloads;\n projectionPathGraph: ProjectionPathGraphNode;\n}) => {\n const prepare = (result: NormalizedExecutionResult<TRuntimeAdapter, object, object>) => {\n if (result.type === \"graphql\") {\n const errorMaps = createErrorMaps(result.body.errors, projectionPathGraph);\n\n return { ...result, errorMaps };\n }\n\n if (result.type === \"non-graphql-error\") {\n return { ...result, error: new SlicedExecutionResultError({ type: \"non-graphql-error\", error: result.error }) };\n }\n\n if (result.type === \"empty\") {\n return { ...result, error: new SlicedExecutionResultEmpty() };\n }\n\n throw new Error(\"Invalid result type\", { cause: result satisfies never });\n };\n\n return (result: NormalizedExecutionResult<TRuntimeAdapter, object, object>) => {\n const prepared = prepare(result);\n\n const entries = Object.entries(fragments).map(([label, fragment]) => {\n const { projection } = fragment;\n\n if (prepared.type === \"graphql\") {\n const matchedErrors = projection.paths.flatMap(({ full: raw }) => prepared.errorMaps[label]?.[raw] ?? []);\n const uniqueErrors = Array.from(new Set(matchedErrors.map(({ error }) => error)).values());\n\n if (uniqueErrors.length > 0) {\n return [label, projection.projector(new SlicedExecutionResultError({ type: \"graphql-error\", errors: uniqueErrors }))];\n }\n\n const dataResults = projection.paths.map(({ segments }) =>\n prepared.body.data ? accessDataByPathSegments(prepared.body.data, segments) : { error: new Error(\"No data\") },\n );\n if (dataResults.some(({ error }) => error)) {\n const errors = dataResults.flatMap(({ error }) => (error ? [error] : []));\n return [label, projection.projector(new SlicedExecutionResultError({ type: \"parse-error\", errors }))];\n }\n\n const dataList = dataResults.map(({ data }) => data);\n return [label, projection.projector(new SlicedExecutionResultSuccess(dataList))];\n }\n\n if (prepared.type === \"non-graphql-error\") {\n return [label, projection.projector(prepared.error)];\n }\n\n if (prepared.type === \"empty\") {\n return [label, projection.projector(prepared.error)];\n }\n\n throw new Error(\"Invalid result type\", { cause: prepared satisfies never });\n });\n\n return Object.fromEntries(entries);\n };\n};\n","type ArgEntries<T extends object> = { [K in keyof T]-?: [value: T[K], key: K] }[keyof T];\ntype Entries<T extends object> = { [K in keyof T]: [key: K, value: T[K]] }[keyof T];\n\nexport function mapValues<TObject extends object, TMappedValue>(\n obj: TObject,\n fn: (...args: ArgEntries<TObject>) => TMappedValue,\n): {\n [K in keyof TObject]: TMappedValue;\n} {\n return Object.fromEntries((Object.entries(obj) as Entries<TObject>[]).map(([key, value]) => [key, fn(value, key)])) as {\n [K in keyof TObject]: TMappedValue;\n };\n}\n","import {\n type AnyAssignableInput,\n type AssigningInput,\n createVarRefFromConstValue,\n createVarRefFromVariable,\n isVarRef,\n} from \"../types/fragment\";\nimport type { AnyGraphqlSchema, InferInputProfile } from \"../types/schema\";\nimport type { AnyVarRef, ConstValue, InputTypeSpecifiers } from \"../types/type-foundation\";\nimport { mapValues } from \"../utils/map-values\";\nimport type { UnionToIntersection } from \"../utils/type-utils\";\n\nexport const mergeVarDefinitions = <TVarDefinitions extends InputTypeSpecifiers[]>(definitions: TVarDefinitions) =>\n Object.assign({}, ...definitions) as MergeVarDefinitions<TVarDefinitions>;\n\nexport type MergeVarDefinitions<TVarDefinitions extends InputTypeSpecifiers[]> = UnionToIntersection<\n TVarDefinitions[number]\n> extends infer TDefinitions\n ? {\n readonly [K in keyof TDefinitions]: TDefinitions[K];\n }\n : never;\n\nexport const createVarAssignments = <TSchema extends AnyGraphqlSchema, TVariableDefinitions extends InputTypeSpecifiers>(\n definitions: TVariableDefinitions,\n providedValues: AnyAssignableInput | void,\n): AssigningInput<TSchema, TVariableDefinitions> => {\n return mapValues(definitions, (_definition, key): AnyVarRef => {\n const varName = key as string;\n if (!providedValues || providedValues[varName] === undefined) {\n return createVarRefFromConstValue<InferInputProfile<TSchema, typeof _definition>>(undefined);\n }\n\n const provided = providedValues[varName];\n if (isVarRef(provided)) {\n return provided;\n }\n\n return createVarRefFromConstValue<InferInputProfile<TSchema, typeof _definition>>(provided as ConstValue);\n }) as AssigningInput<TSchema, TVariableDefinitions>;\n};\n\nexport const createVarRefs = <TSchema extends AnyGraphqlSchema, TVarDefinitions extends InputTypeSpecifiers>(\n definitions: TVarDefinitions,\n) =>\n mapValues(definitions as InputTypeSpecifiers, (_ref, name) =>\n createVarRefFromVariable<InferInputProfile<TSchema, typeof _ref>>(name),\n ) as AssigningInput<TSchema, TVarDefinitions>;\n","const _dummy = () => {\n throw new Error(\"DO NOT CALL THIS FUNCTION -- we use function to safely transfer type information\");\n};\nexport const hidden = <T>(): (() => T) => _dummy;\nexport type Hidden<T> = () => T;\n","import type { AnyExecutionResultProjectionsBuilder, AnySliceOf } from \"../types/element\";\nimport { Projection } from \"../types/runtime\";\nimport type { OperationType } from \"../types/schema\";\nimport { hidden } from \"../utils/hidden\";\nimport type { StripFunctions, StripSymbols } from \"../utils/type-utils\";\n\nexport type RuntimeSliceInput = {\n prebuild: StripFunctions<AnySliceOf<OperationType>>;\n runtime: {\n buildProjection: AnyExecutionResultProjectionsBuilder;\n };\n};\n\nexport const handleProjectionBuilder = <TBuilder extends AnyExecutionResultProjectionsBuilder>(\n projectionBuilder: TBuilder,\n): ReturnType<TBuilder> =>\n projectionBuilder({\n select: (path, projector) => new Projection(path, projector),\n });\n\nexport const createRuntimeSlice = (input: RuntimeSliceInput) => {\n const projection = handleProjectionBuilder(input.runtime.buildProjection);\n return {\n operationType: input.prebuild.operationType,\n embed: (variables) => ({\n variables,\n getFields: hidden(),\n projection,\n }),\n } satisfies StripSymbols<AnySliceOf<OperationType>> as AnySliceOf<OperationType>;\n};\n"],"mappings":";AAqBA,IAAa,SAAb,MAAiD;CAG/C,YAAY,AAAiBA,OAAoB;EAApB;;CAE7B,OAAO,SAAS,QAAgC;AAC9C,SAAO,OAAO;;;AAIlB,MAAa,YAAY,UAAuC;AAC9D,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,iBAAiB;;AAGzE,MAAa,4BAAmE,SAAiB;AAC/F,QAAO,IAAI,OAAkD;EAAE,MAAM;EAAY;EAAM,CAAC;;AAG1F,MAAa,8BAAqE,UAAsB;AACtG,QAAO,IAAI,OAAkD;EAAE,MAAM;EAAe;EAAO,CAAC;;AAG9F,MAAa,kBAAkB,WAAmC;AAChE,QAAO,OAAO,SAAS,OAAO;;;;;;AAOhC,MAAa,iBAAiB,WAA8B;CAC1D,MAAM,QAAQ,OAAO,SAAS,OAAO;AACrC,KAAI,MAAM,SAAS,WACjB,OAAM,IAAI,MAAM,+CAA+C;AAEjE,QAAO,MAAM;;;;;;AAOf,MAAa,kBAAkB,WAAkC;CAC/D,MAAM,QAAQ,OAAO,SAAS,OAAO;AACrC,KAAI,MAAM,SAAS,cACjB,OAAM,IAAI,MAAM,+CAA+C;AAEjE,QAAO,MAAM;;;;;;;;;;ACvDf,IAAa,aAAb,MAAoC;CAElC,YACE,OACA,AAAgBC,WAChB;EADgB;AAEhB,OAAK,QAAQ,MAAM,KAAK,SAAS,qBAAqB,KAAK,CAAC;;CAG9D,AAAgB;;AAQlB,SAAS,qBAAqB,MAA8B;CAC1D,MAAM,WAAW,KAAK,MAAM,IAAI;AAChC,KAAI,SAAS,OAAO,SAAS,UAAU,EACrC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