@soda-gql/core 0.0.9 → 0.1.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 (38) hide show
  1. package/README.md +312 -0
  2. package/dist/{index-CFNJ_Aa6.d.ts → index-DYwkqPzd.d.ts} +124 -294
  3. package/dist/index-DYwkqPzd.d.ts.map +1 -0
  4. package/dist/index-Db9ogofS.d.ts +365 -0
  5. package/dist/index-Db9ogofS.d.ts.map +1 -0
  6. package/dist/{index-DHh8XRal.d.cts → index-Dth0NSJt.d.cts} +124 -294
  7. package/dist/index-Dth0NSJt.d.cts.map +1 -0
  8. package/dist/index-zGZ61WLt.d.cts +365 -0
  9. package/dist/index-zGZ61WLt.d.cts.map +1 -0
  10. package/dist/index.cjs +132 -44
  11. package/dist/index.d.cts +3 -2
  12. package/dist/index.d.ts +3 -2
  13. package/dist/index.js +129 -45
  14. package/dist/index.js.map +1 -1
  15. package/dist/merge-CeMx09is.js +74 -0
  16. package/dist/merge-CeMx09is.js.map +1 -0
  17. package/dist/merge-ZxKV1syS.cjs +85 -0
  18. package/dist/metadata/index.cjs +62 -0
  19. package/dist/metadata/index.d.cts +71 -0
  20. package/dist/metadata/index.d.cts.map +1 -0
  21. package/dist/metadata/index.d.ts +71 -0
  22. package/dist/metadata/index.d.ts.map +1 -0
  23. package/dist/metadata/index.js +59 -0
  24. package/dist/metadata/index.js.map +1 -0
  25. package/dist/runtime/index.cjs +5 -3
  26. package/dist/runtime/index.d.cts +2 -1
  27. package/dist/runtime/index.d.cts.map +1 -1
  28. package/dist/runtime/index.d.ts +2 -1
  29. package/dist/runtime/index.d.ts.map +1 -1
  30. package/dist/runtime/index.js +5 -3
  31. package/dist/runtime/index.js.map +1 -1
  32. package/dist/{slice-ua5mSfhV.js → slice-BuSNc8vw.js} +27 -5
  33. package/dist/slice-BuSNc8vw.js.map +1 -0
  34. package/dist/{slice-DlVY4UJG.cjs → slice-C-FIQK-f.cjs} +43 -3
  35. package/package.json +8 -1
  36. package/dist/index-CFNJ_Aa6.d.ts.map +0 -1
  37. package/dist/index-DHh8XRal.d.cts.map +0 -1
  38. package/dist/slice-ua5mSfhV.js.map +0 -1
@@ -0,0 +1,62 @@
1
+ const require_merge = require('../merge-ZxKV1syS.cjs');
2
+
3
+ //#region packages/core/src/metadata/adapter.ts
4
+ /**
5
+ * Creates a type-safe metadata adapter for a schema.
6
+ * The adapter defines how metadata is processed at build time.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { createMetadataAdapter } from "@soda-gql/core/metadata";
11
+ * import { createHash } from "crypto";
12
+ *
13
+ * export const metadataAdapter = createMetadataAdapter({
14
+ * defaults: {
15
+ * headers: { "X-GraphQL-Client": "soda-gql" },
16
+ * },
17
+ *
18
+ * transform: ({ document, metadata }) => ({
19
+ * ...metadata,
20
+ * extensions: {
21
+ * ...metadata.extensions,
22
+ * persistedQuery: {
23
+ * version: 1,
24
+ * sha256Hash: createHash("sha256").update(document).digest("hex"),
25
+ * },
26
+ * },
27
+ * }),
28
+ * });
29
+ * ```
30
+ */
31
+ const createMetadataAdapter = (adapter) => adapter;
32
+ /**
33
+ * Processes metadata through an adapter, applying defaults, merging slice metadata,
34
+ * and running the transform function.
35
+ *
36
+ * @param adapter - The metadata adapter to use
37
+ * @param operationMetadata - Metadata defined on the operation
38
+ * @param sliceMetadataList - Metadata from embedded slices
39
+ * @param transformInput - Additional input for the transform function
40
+ * @returns Processed metadata ready for runtime use
41
+ */
42
+ const processMetadata = (adapter, operationMetadata, sliceMetadataList, transformInput) => {
43
+ const mergedFromSlices = (adapter.mergeSliceMetadata ?? require_merge.defaultMergeSliceMetadata)(operationMetadata ?? {}, sliceMetadataList);
44
+ const withDefaults = require_merge.mergeWithDefaults(adapter.defaults, mergedFromSlices);
45
+ if (adapter.transform) return adapter.transform({
46
+ ...transformInput,
47
+ metadata: withDefaults
48
+ });
49
+ return withDefaults;
50
+ };
51
+ /**
52
+ * Creates a no-op metadata adapter that passes through metadata unchanged.
53
+ * Useful when no metadata processing is needed.
54
+ */
55
+ const createNoopMetadataAdapter = () => ({ defaults: {} });
56
+
57
+ //#endregion
58
+ exports.createMetadataAdapter = createMetadataAdapter;
59
+ exports.createNoopMetadataAdapter = createNoopMetadataAdapter;
60
+ exports.defaultMergeSliceMetadata = require_merge.defaultMergeSliceMetadata;
61
+ exports.mergeWithDefaults = require_merge.mergeWithDefaults;
62
+ exports.processMetadata = processMetadata;
@@ -0,0 +1,71 @@
1
+ import { a as MetadataTransformInput, i as MetadataAdapter, l as OperationMetadata, u as SliceMetadata } from "../index-zGZ61WLt.cjs";
2
+
3
+ //#region packages/core/src/metadata/adapter.d.ts
4
+
5
+ /**
6
+ * Creates a type-safe metadata adapter for a schema.
7
+ * The adapter defines how metadata is processed at build time.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { createMetadataAdapter } from "@soda-gql/core/metadata";
12
+ * import { createHash } from "crypto";
13
+ *
14
+ * export const metadataAdapter = createMetadataAdapter({
15
+ * defaults: {
16
+ * headers: { "X-GraphQL-Client": "soda-gql" },
17
+ * },
18
+ *
19
+ * transform: ({ document, metadata }) => ({
20
+ * ...metadata,
21
+ * extensions: {
22
+ * ...metadata.extensions,
23
+ * persistedQuery: {
24
+ * version: 1,
25
+ * sha256Hash: createHash("sha256").update(document).digest("hex"),
26
+ * },
27
+ * },
28
+ * }),
29
+ * });
30
+ * ```
31
+ */
32
+ declare const createMetadataAdapter: <TInputMetadata extends OperationMetadata = OperationMetadata, TOutputMetadata extends OperationMetadata = TInputMetadata>(adapter: MetadataAdapter<TInputMetadata, TOutputMetadata>) => MetadataAdapter<TInputMetadata, TOutputMetadata>;
33
+ /**
34
+ * Processes metadata through an adapter, applying defaults, merging slice metadata,
35
+ * and running the transform function.
36
+ *
37
+ * @param adapter - The metadata adapter to use
38
+ * @param operationMetadata - Metadata defined on the operation
39
+ * @param sliceMetadataList - Metadata from embedded slices
40
+ * @param transformInput - Additional input for the transform function
41
+ * @returns Processed metadata ready for runtime use
42
+ */
43
+ declare const processMetadata: <TInputMetadata extends OperationMetadata, TOutputMetadata extends OperationMetadata>(adapter: MetadataAdapter<TInputMetadata, TOutputMetadata>, operationMetadata: TInputMetadata | undefined, sliceMetadataList: readonly SliceMetadata[], transformInput: Omit<MetadataTransformInput<TInputMetadata>, "metadata">) => TOutputMetadata;
44
+ /**
45
+ * Creates a no-op metadata adapter that passes through metadata unchanged.
46
+ * Useful when no metadata processing is needed.
47
+ */
48
+ declare const createNoopMetadataAdapter: () => MetadataAdapter<OperationMetadata, OperationMetadata>;
49
+ //#endregion
50
+ //#region packages/core/src/metadata/merge.d.ts
51
+ /**
52
+ * Default merge strategy for combining slice metadata with operation metadata.
53
+ * Performs a shallow merge where operation-level values take precedence.
54
+ *
55
+ * @param operationMetadata - Metadata defined on the operation itself
56
+ * @param sliceMetadataList - Array of metadata from all embedded slices
57
+ * @returns Merged metadata with operation values taking precedence
58
+ */
59
+ declare const defaultMergeSliceMetadata: <TMetadata extends OperationMetadata>(operationMetadata: TMetadata, sliceMetadataList: readonly SliceMetadata[]) => TMetadata;
60
+ /**
61
+ * Merge schema-level default metadata with operation-level metadata.
62
+ * Schema defaults are applied first, then operation metadata overrides.
63
+ *
64
+ * @param defaults - Schema-level default metadata
65
+ * @param operationMetadata - Operation-specific metadata
66
+ * @returns Merged metadata with operation values taking precedence
67
+ */
68
+ declare const mergeWithDefaults: <TMetadata extends OperationMetadata>(defaults: TMetadata, operationMetadata: TMetadata) => TMetadata;
69
+ //#endregion
70
+ export { createMetadataAdapter, createNoopMetadataAdapter, defaultMergeSliceMetadata, mergeWithDefaults, processMetadata };
71
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/metadata/adapter.ts","../../src/metadata/merge.ts"],"sourcesContent":[],"mappings":";;;;;;AA8BA;;;;;;;;;;;;AAiBA;;;;;;;;;;;;;AA4Ba,cA7CA,qBA+CX,EAAA,CAAA,uBA9CuB,iBA8CvB,GA9C2C,iBA8C3C,EAAA,wBA7CwB,iBA6CxB,GA7C4C,cA6C5C,CAAA,CAAA,OAAA,EA3CS,eA2CT,CA3CyB,cA2CzB,EA3CyC,eA2CzC,CAAA,EAAA,GA1CC,eA0CD,CA1CiB,cA0CjB,EA1CiC,eA0CjC,CAAA;;;;;;;;ACnEF;;;AAE8B,cDmCjB,eCnCiB,EAAA,CAAA,uBDmCyB,iBCnCzB,EAAA,wBDmCoE,iBCnCpE,CAAA,CAAA,OAAA,EDoCnB,eCpCmB,CDoCH,cCpCG,EDoCa,eCpCb,CAAA,EAAA,iBAAA,EDqCT,cCrCS,GAAA,SAAA,EAAA,iBAAA,EAAA,SDsCA,aCtCA,EAAA,EAAA,cAAA,EDuCZ,ICvCY,CDuCP,sBCvCO,CDuCgB,cCvChB,CAAA,EAAA,UAAA,CAAA,EAAA,GDwC3B,eCxC2B;;;AA6B9B;;AACY,cDiCC,yBCjCD,EAAA,GAAA,GDiCiC,eCjCjC,CDiCiD,iBCjCjD,EDiCoE,iBCjCpE,CAAA;;;;;ADZZ;;;;;;AAI2C,cCxB9B,yBDwB8B,EAAA,CAAA,kBCxBiB,iBDwBjB,CAAA,CAAA,iBAAA,ECvBtB,SDuBsB,EAAA,iBAAA,EAAA,SCtBb,aDsBa,EAAA,EAAA,GCrBxC,SDqBwC;;;;;;AAa3C;;;AAC2B,cCPd,iBDOc,EAAA,CAAA,kBCPyB,iBDOzB,CAAA,CAAA,QAAA,ECNf,SDMe,EAAA,iBAAA,ECLN,SDKM,EAAA,GCJxB,SDIwB"}
@@ -0,0 +1,71 @@
1
+ import { a as MetadataTransformInput, i as MetadataAdapter, l as OperationMetadata, u as SliceMetadata } from "../index-Db9ogofS.js";
2
+
3
+ //#region packages/core/src/metadata/adapter.d.ts
4
+
5
+ /**
6
+ * Creates a type-safe metadata adapter for a schema.
7
+ * The adapter defines how metadata is processed at build time.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { createMetadataAdapter } from "@soda-gql/core/metadata";
12
+ * import { createHash } from "crypto";
13
+ *
14
+ * export const metadataAdapter = createMetadataAdapter({
15
+ * defaults: {
16
+ * headers: { "X-GraphQL-Client": "soda-gql" },
17
+ * },
18
+ *
19
+ * transform: ({ document, metadata }) => ({
20
+ * ...metadata,
21
+ * extensions: {
22
+ * ...metadata.extensions,
23
+ * persistedQuery: {
24
+ * version: 1,
25
+ * sha256Hash: createHash("sha256").update(document).digest("hex"),
26
+ * },
27
+ * },
28
+ * }),
29
+ * });
30
+ * ```
31
+ */
32
+ declare const createMetadataAdapter: <TInputMetadata extends OperationMetadata = OperationMetadata, TOutputMetadata extends OperationMetadata = TInputMetadata>(adapter: MetadataAdapter<TInputMetadata, TOutputMetadata>) => MetadataAdapter<TInputMetadata, TOutputMetadata>;
33
+ /**
34
+ * Processes metadata through an adapter, applying defaults, merging slice metadata,
35
+ * and running the transform function.
36
+ *
37
+ * @param adapter - The metadata adapter to use
38
+ * @param operationMetadata - Metadata defined on the operation
39
+ * @param sliceMetadataList - Metadata from embedded slices
40
+ * @param transformInput - Additional input for the transform function
41
+ * @returns Processed metadata ready for runtime use
42
+ */
43
+ declare const processMetadata: <TInputMetadata extends OperationMetadata, TOutputMetadata extends OperationMetadata>(adapter: MetadataAdapter<TInputMetadata, TOutputMetadata>, operationMetadata: TInputMetadata | undefined, sliceMetadataList: readonly SliceMetadata[], transformInput: Omit<MetadataTransformInput<TInputMetadata>, "metadata">) => TOutputMetadata;
44
+ /**
45
+ * Creates a no-op metadata adapter that passes through metadata unchanged.
46
+ * Useful when no metadata processing is needed.
47
+ */
48
+ declare const createNoopMetadataAdapter: () => MetadataAdapter<OperationMetadata, OperationMetadata>;
49
+ //#endregion
50
+ //#region packages/core/src/metadata/merge.d.ts
51
+ /**
52
+ * Default merge strategy for combining slice metadata with operation metadata.
53
+ * Performs a shallow merge where operation-level values take precedence.
54
+ *
55
+ * @param operationMetadata - Metadata defined on the operation itself
56
+ * @param sliceMetadataList - Array of metadata from all embedded slices
57
+ * @returns Merged metadata with operation values taking precedence
58
+ */
59
+ declare const defaultMergeSliceMetadata: <TMetadata extends OperationMetadata>(operationMetadata: TMetadata, sliceMetadataList: readonly SliceMetadata[]) => TMetadata;
60
+ /**
61
+ * Merge schema-level default metadata with operation-level metadata.
62
+ * Schema defaults are applied first, then operation metadata overrides.
63
+ *
64
+ * @param defaults - Schema-level default metadata
65
+ * @param operationMetadata - Operation-specific metadata
66
+ * @returns Merged metadata with operation values taking precedence
67
+ */
68
+ declare const mergeWithDefaults: <TMetadata extends OperationMetadata>(defaults: TMetadata, operationMetadata: TMetadata) => TMetadata;
69
+ //#endregion
70
+ export { createMetadataAdapter, createNoopMetadataAdapter, defaultMergeSliceMetadata, mergeWithDefaults, processMetadata };
71
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/metadata/adapter.ts","../../src/metadata/merge.ts"],"sourcesContent":[],"mappings":";;;;;;AA8BA;;;;;;;;;;;;AAiBA;;;;;;;;;;;;;AA4Ba,cA7CA,qBA+CX,EAAA,CAAA,uBA9CuB,iBA8CvB,GA9C2C,iBA8C3C,EAAA,wBA7CwB,iBA6CxB,GA7C4C,cA6C5C,CAAA,CAAA,OAAA,EA3CS,eA2CT,CA3CyB,cA2CzB,EA3CyC,eA2CzC,CAAA,EAAA,GA1CC,eA0CD,CA1CiB,cA0CjB,EA1CiC,eA0CjC,CAAA;;;;;;;;ACnEF;;;AAE8B,cDmCjB,eCnCiB,EAAA,CAAA,uBDmCyB,iBCnCzB,EAAA,wBDmCoE,iBCnCpE,CAAA,CAAA,OAAA,EDoCnB,eCpCmB,CDoCH,cCpCG,EDoCa,eCpCb,CAAA,EAAA,iBAAA,EDqCT,cCrCS,GAAA,SAAA,EAAA,iBAAA,EAAA,SDsCA,aCtCA,EAAA,EAAA,cAAA,EDuCZ,ICvCY,CDuCP,sBCvCO,CDuCgB,cCvChB,CAAA,EAAA,UAAA,CAAA,EAAA,GDwC3B,eCxC2B;;;AA6B9B;;AACY,cDiCC,yBCjCD,EAAA,GAAA,GDiCiC,eCjCjC,CDiCiD,iBCjCjD,EDiCoE,iBCjCpE,CAAA;;;;;ADZZ;;;;;;AAI2C,cCxB9B,yBDwB8B,EAAA,CAAA,kBCxBiB,iBDwBjB,CAAA,CAAA,iBAAA,ECvBtB,SDuBsB,EAAA,iBAAA,EAAA,SCtBb,aDsBa,EAAA,EAAA,GCrBxC,SDqBwC;;;;;;AAa3C;;;AAC2B,cCPd,iBDOc,EAAA,CAAA,kBCPyB,iBDOzB,CAAA,CAAA,QAAA,ECNf,SDMe,EAAA,iBAAA,ECLN,SDKM,EAAA,GCJxB,SDIwB"}
@@ -0,0 +1,59 @@
1
+ import { n as mergeWithDefaults, t as defaultMergeSliceMetadata } from "../merge-CeMx09is.js";
2
+
3
+ //#region packages/core/src/metadata/adapter.ts
4
+ /**
5
+ * Creates a type-safe metadata adapter for a schema.
6
+ * The adapter defines how metadata is processed at build time.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { createMetadataAdapter } from "@soda-gql/core/metadata";
11
+ * import { createHash } from "crypto";
12
+ *
13
+ * export const metadataAdapter = createMetadataAdapter({
14
+ * defaults: {
15
+ * headers: { "X-GraphQL-Client": "soda-gql" },
16
+ * },
17
+ *
18
+ * transform: ({ document, metadata }) => ({
19
+ * ...metadata,
20
+ * extensions: {
21
+ * ...metadata.extensions,
22
+ * persistedQuery: {
23
+ * version: 1,
24
+ * sha256Hash: createHash("sha256").update(document).digest("hex"),
25
+ * },
26
+ * },
27
+ * }),
28
+ * });
29
+ * ```
30
+ */
31
+ const createMetadataAdapter = (adapter) => adapter;
32
+ /**
33
+ * Processes metadata through an adapter, applying defaults, merging slice metadata,
34
+ * and running the transform function.
35
+ *
36
+ * @param adapter - The metadata adapter to use
37
+ * @param operationMetadata - Metadata defined on the operation
38
+ * @param sliceMetadataList - Metadata from embedded slices
39
+ * @param transformInput - Additional input for the transform function
40
+ * @returns Processed metadata ready for runtime use
41
+ */
42
+ const processMetadata = (adapter, operationMetadata, sliceMetadataList, transformInput) => {
43
+ const mergedFromSlices = (adapter.mergeSliceMetadata ?? defaultMergeSliceMetadata)(operationMetadata ?? {}, sliceMetadataList);
44
+ const withDefaults = mergeWithDefaults(adapter.defaults, mergedFromSlices);
45
+ if (adapter.transform) return adapter.transform({
46
+ ...transformInput,
47
+ metadata: withDefaults
48
+ });
49
+ return withDefaults;
50
+ };
51
+ /**
52
+ * Creates a no-op metadata adapter that passes through metadata unchanged.
53
+ * Useful when no metadata processing is needed.
54
+ */
55
+ const createNoopMetadataAdapter = () => ({ defaults: {} });
56
+
57
+ //#endregion
58
+ export { createMetadataAdapter, createNoopMetadataAdapter, defaultMergeSliceMetadata, mergeWithDefaults, processMetadata };
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/metadata/adapter.ts"],"sourcesContent":["import type { MetadataAdapter, MetadataTransformInput, OperationMetadata, SliceMetadata } from \"../types/metadata\";\nimport { defaultMergeSliceMetadata, mergeWithDefaults } from \"./merge\";\n\n/**\n * Creates a type-safe metadata adapter for a schema.\n * The adapter defines how metadata is processed at build time.\n *\n * @example\n * ```typescript\n * import { createMetadataAdapter } from \"@soda-gql/core/metadata\";\n * import { createHash } from \"crypto\";\n *\n * export const metadataAdapter = createMetadataAdapter({\n * defaults: {\n * headers: { \"X-GraphQL-Client\": \"soda-gql\" },\n * },\n *\n * transform: ({ document, metadata }) => ({\n * ...metadata,\n * extensions: {\n * ...metadata.extensions,\n * persistedQuery: {\n * version: 1,\n * sha256Hash: createHash(\"sha256\").update(document).digest(\"hex\"),\n * },\n * },\n * }),\n * });\n * ```\n */\nexport const createMetadataAdapter = <\n TInputMetadata extends OperationMetadata = OperationMetadata,\n TOutputMetadata extends OperationMetadata = TInputMetadata,\n>(\n adapter: MetadataAdapter<TInputMetadata, TOutputMetadata>,\n): MetadataAdapter<TInputMetadata, TOutputMetadata> => adapter;\n\n/**\n * Processes metadata through an adapter, applying defaults, merging slice metadata,\n * and running the transform function.\n *\n * @param adapter - The metadata adapter to use\n * @param operationMetadata - Metadata defined on the operation\n * @param sliceMetadataList - Metadata from embedded slices\n * @param transformInput - Additional input for the transform function\n * @returns Processed metadata ready for runtime use\n */\nexport const processMetadata = <TInputMetadata extends OperationMetadata, TOutputMetadata extends OperationMetadata>(\n adapter: MetadataAdapter<TInputMetadata, TOutputMetadata>,\n operationMetadata: TInputMetadata | undefined,\n sliceMetadataList: readonly SliceMetadata[],\n transformInput: Omit<MetadataTransformInput<TInputMetadata>, \"metadata\">,\n): TOutputMetadata => {\n // Step 1: Merge slice metadata with operation metadata\n const mergeSliceMetadata = adapter.mergeSliceMetadata ?? defaultMergeSliceMetadata;\n const mergedFromSlices = mergeSliceMetadata(operationMetadata ?? ({} as TInputMetadata), sliceMetadataList);\n\n // Step 2: Merge with schema defaults\n const withDefaults = mergeWithDefaults(adapter.defaults, mergedFromSlices);\n\n // Step 3: Apply transform if provided\n if (adapter.transform) {\n return adapter.transform({\n ...transformInput,\n metadata: withDefaults,\n });\n }\n\n return withDefaults as unknown as TOutputMetadata;\n};\n\n/**\n * Creates a no-op metadata adapter that passes through metadata unchanged.\n * Useful when no metadata processing is needed.\n */\nexport const createNoopMetadataAdapter = (): MetadataAdapter<OperationMetadata, OperationMetadata> => ({\n defaults: {},\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,yBAIX,YACqD;;;;;;;;;;;AAYvD,MAAa,mBACX,SACA,mBACA,mBACA,mBACoB;CAGpB,MAAM,oBADqB,QAAQ,sBAAsB,2BACb,qBAAsB,EAAE,EAAqB,kBAAkB;CAG3G,MAAM,eAAe,kBAAkB,QAAQ,UAAU,iBAAiB;AAG1E,KAAI,QAAQ,UACV,QAAO,QAAQ,UAAU;EACvB,GAAG;EACH,UAAU;EACX,CAAC;AAGJ,QAAO;;;;;;AAOT,MAAa,mCAA0F,EACrG,UAAU,EAAE,EACb"}
@@ -1,4 +1,4 @@
1
- const require_slice = require('../slice-DlVY4UJG.cjs');
1
+ const require_slice = require('../slice-C-FIQK-f.cjs');
2
2
 
3
3
  //#region packages/core/src/runtime/runtime-registry.ts
4
4
  const composedOperationRegistry = /* @__PURE__ */ new Map();
@@ -54,7 +54,8 @@ const createRuntimeComposedOperation = (input) => {
54
54
  parse: require_slice.createExecutionResultParser({
55
55
  fragments: input.runtime.getSlices({ $: require_slice.createVarRefs(Object.fromEntries(input.prebuild.variableNames.map((name) => [name, null]))) }),
56
56
  projectionPathGraph: input.prebuild.projectionPathGraph
57
- })
57
+ }),
58
+ metadata: input.prebuild.metadata
58
59
  };
59
60
  registerComposedOperation(operation);
60
61
  return operation;
@@ -68,7 +69,8 @@ const createRuntimeInlineOperation = (input) => {
68
69
  operationName: input.prebuild.operationName,
69
70
  variableNames: input.prebuild.variableNames,
70
71
  documentSource: require_slice.hidden(),
71
- document: input.prebuild.document
72
+ document: input.prebuild.document,
73
+ metadata: input.prebuild.metadata
72
74
  };
73
75
  registerInlineOperation(operation);
74
76
  return operation;
@@ -1,4 +1,5 @@
1
- import { $ as AnySliceOf, C as AnyInlineOperationOf, Dt as StripFunctions, Et as AnyGraphqlRuntimeAdapter, G as AnyComposedOperationOf, H as AnyExecutionResultProjectionsBuilder, Sn as OperationType, et as AnySlicePayload, in as AnyAssignableInput, jt as Hidden, xn as OperationRoots, y as AnyModel } from "../index-DHh8XRal.cjs";
1
+ import { C as OperationRoots, w as OperationType } from "../index-zGZ61WLt.cjs";
2
+ import { At as StripFunctions, E as AnyInlineOperationOf, G as AnyExecutionResultProjectionsBuilder, J as AnyComposedOperationOf, Pt as Hidden, S as AnyModel, kt as AnyGraphqlRuntimeAdapter, nt as AnySliceOf, rt as AnySlicePayload, sn as AnyAssignableInput } from "../index-Dth0NSJt.cjs";
2
3
 
3
4
  //#region packages/core/src/runtime/model.d.ts
4
5
  type RuntimeModelInput = {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/runtime/model.ts","../../src/runtime/composed-operation.ts","../../src/runtime/inline-operation.ts","../../src/runtime/slice.ts","../../src/runtime/runtime-adapter.ts","../../src/runtime/runtime-registry.ts","../../src/runtime/index.ts"],"sourcesContent":[],"mappings":";;;KAIY,iBAAA;EAAA,QAAA,EACA,cADiB,CACF,QAAA,CAAA;;;;ACI3B,CAAA;;;KAAY,6BAAA;YACA,eAAe,uBAAuB;;IADtC,SAAA,EAAA,CAAA,KAAA,EAAA;MACsC,CAAA,EAEtB,kBAFsB;IAAvB,CAAA,EAAA,GAAA;MAAf,CAAA,GAAA,EAAA,MAAA,CAAA,EAE0D,eAF1D;IAEgB,CAAA;EAA0C,CAAA;CAAe;;;ADRzE,KEEA,2BAAA,GFDe;YEEf,eAAe,qBAAqB;;;;;AFHpC,KGEA,iBAAA,GHFiB;YGGjB,eAAe,WAAW;;qBAEjB;EFAT,CAAA;CACsC;;;KGN7C,8CAA8C;EJAvC,IAAA,EAAA,CAAA,CAAA,CAAA,GAAA,GICK,MJDY,CICL,CJDK,CAAA;MIEvB;cAEO,+CAAgD,mCAClD,sBAAsB,qBAAgB;;;;AHAjD;;;AACY,cIwBC,sBJxBD,EAAA,GAAA,GAAA,IAAA;;;;;cIiCC,yCAAwC,oBAAoB,uBAAuB;;AHrChG;;;AACY,cG4CC,+BH5CD,EAAA,GAAA,GG4CuC,WH5CvC,CAAA,MAAA,EG4C2D,oBH5C3D,CG4CgF,aH5ChF,CAAA,CAAA;;;cIUC;ELRD,KAAA,EAAA,CAAA,KAAA,EKeX,iBLfwC,EAAA,WAAA;EACS,iBAAA,EAAA,CAAA,KAAA,+BAAA,EAAA,yBAAA,eAAA;EAAvB,eAAA,EAAA,CAAA,KAAA,6BAAA,EAAA,uBAAA,eAAA;EAAf,KAAA,EAAA,CAAA,KAAA,mBAAA,EAAA,aAAA,eAAA;EAEgB,oBAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,yBAAA,CAAA,oBAAA,CAAA;EAA0C,kBAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,uBAAA,CAAA,oBAAA,CAAA;CAAe"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/runtime/model.ts","../../src/runtime/composed-operation.ts","../../src/runtime/inline-operation.ts","../../src/runtime/slice.ts","../../src/runtime/runtime-adapter.ts","../../src/runtime/runtime-registry.ts","../../src/runtime/index.ts"],"sourcesContent":[],"mappings":";;;;KAIY,iBAAA;YACA,eAAe;EADf,OAAA,EAAA;;;;;;AAAA,KCKA,6BAAA,GDJe;YCKf,eAAe,uBAAuB;;;MADtC,CAAA,EAGgB,kBAHhB;IACsC,CAAA,EAAA,GAAA;MAAvB,CAAA,GAAA,EAAA,MAAA,CAAA,EAE2C,eAF3C;IAAf,CAAA;EAEgB,CAAA;CAA0C;;;KCN1D,2BAAA;EFFA,QAAA,EEGA,cFHiB,CEGF,oBFFf,CEEoC,aFFtB,CAAA,CAAA;;;;;KGCd,iBAAA;EHFA,QAAA,EGGA,cHHiB,CGGF,UHFA,CGEW,aHF1B,CAAA,CAAA;;qBGIS;;AFArB,CAAA;;;KGLK,8CAA8C;iBAClC,OAAO;AJDxB,CAAA,EAAA,GIEM,eJFM;cIIC,+CAAgD,mCAClD,sBAAsB,qBAAgB;;;;;AHAjD;;AAC2B,cIwBd,sBJxBc,EAAA,GAAA,GAAA,IAAA;;;;;cIiCd,yCAAwC,oBAAoB,uBAAuB;;;AHrChG;;AAC2B,cG4Cd,+BH5Cc,EAAA,GAAA,GG4CwB,WH5CxB,CAAA,MAAA,EG4C4C,oBH5C5C,CG4CiE,aH5CjE,CAAA,CAAA;;;cIUd;iBAOZ;ELfW,iBAAA,EAAA,CAAA,KAAA,+BAA6B,EAAA,yBAAA,eAAA;EACS,eAAA,EAAA,CAAA,KAAA,6BAAA,EAAA,uBAAA,eAAA;EAAvB,KAAA,EAAA,CAAA,KAAA,mBAAA,EAAA,aAAA,eAAA;EAAf,oBAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,yBAAA,CAAA,oBAAA,CAAA;EAEgB,kBAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,uBAAA,CAAA,oBAAA,CAAA;CAA0C"}
@@ -1,4 +1,5 @@
1
- import { $ as AnySliceOf, C as AnyInlineOperationOf, Dt as StripFunctions, Et as AnyGraphqlRuntimeAdapter, G as AnyComposedOperationOf, H as AnyExecutionResultProjectionsBuilder, Sn as OperationType, et as AnySlicePayload, in as AnyAssignableInput, jt as Hidden, xn as OperationRoots, y as AnyModel } from "../index-CFNJ_Aa6.js";
1
+ import { C as OperationRoots, w as OperationType } from "../index-Db9ogofS.js";
2
+ import { At as StripFunctions, E as AnyInlineOperationOf, G as AnyExecutionResultProjectionsBuilder, J as AnyComposedOperationOf, Pt as Hidden, S as AnyModel, kt as AnyGraphqlRuntimeAdapter, nt as AnySliceOf, rt as AnySlicePayload, sn as AnyAssignableInput } from "../index-DYwkqPzd.js";
2
3
 
3
4
  //#region packages/core/src/runtime/model.d.ts
4
5
  type RuntimeModelInput = {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/runtime/model.ts","../../src/runtime/composed-operation.ts","../../src/runtime/inline-operation.ts","../../src/runtime/slice.ts","../../src/runtime/runtime-adapter.ts","../../src/runtime/runtime-registry.ts","../../src/runtime/index.ts"],"sourcesContent":[],"mappings":";;;KAIY,iBAAA;EAAA,QAAA,EACA,cADiB,CACF,QAAA,CAAA;;;;ACI3B,CAAA;;;KAAY,6BAAA;YACA,eAAe,uBAAuB;;IADtC,SAAA,EAAA,CAAA,KAAA,EAAA;MACsC,CAAA,EAEtB,kBAFsB;IAAvB,CAAA,EAAA,GAAA;MAAf,CAAA,GAAA,EAAA,MAAA,CAAA,EAE0D,eAF1D;IAEgB,CAAA;EAA0C,CAAA;CAAe;;;ADRzE,KEEA,2BAAA,GFDe;YEEf,eAAe,qBAAqB;;;;;AFHpC,KGEA,iBAAA,GHFiB;YGGjB,eAAe,WAAW;;qBAEjB;EFAT,CAAA;CACsC;;;KGN7C,8CAA8C;EJAvC,IAAA,EAAA,CAAA,CAAA,CAAA,GAAA,GICK,MJDY,CICL,CJDK,CAAA;MIEvB;cAEO,+CAAgD,mCAClD,sBAAsB,qBAAgB;;;;AHAjD;;;AACY,cIwBC,sBJxBD,EAAA,GAAA,GAAA,IAAA;;;;;cIiCC,yCAAwC,oBAAoB,uBAAuB;;AHrChG;;;AACY,cG4CC,+BH5CD,EAAA,GAAA,GG4CuC,WH5CvC,CAAA,MAAA,EG4C2D,oBH5C3D,CG4CgF,aH5ChF,CAAA,CAAA;;;cIUC;ELRD,KAAA,EAAA,CAAA,KAAA,EKeX,iBLfwC,EAAA,WAAA;EACS,iBAAA,EAAA,CAAA,KAAA,+BAAA,EAAA,yBAAA,eAAA;EAAvB,eAAA,EAAA,CAAA,KAAA,6BAAA,EAAA,uBAAA,eAAA;EAAf,KAAA,EAAA,CAAA,KAAA,mBAAA,EAAA,aAAA,eAAA;EAEgB,oBAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,yBAAA,CAAA,oBAAA,CAAA;EAA0C,kBAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,uBAAA,CAAA,oBAAA,CAAA;CAAe"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/runtime/model.ts","../../src/runtime/composed-operation.ts","../../src/runtime/inline-operation.ts","../../src/runtime/slice.ts","../../src/runtime/runtime-adapter.ts","../../src/runtime/runtime-registry.ts","../../src/runtime/index.ts"],"sourcesContent":[],"mappings":";;;;KAIY,iBAAA;YACA,eAAe;EADf,OAAA,EAAA;;;;;;AAAA,KCKA,6BAAA,GDJe;YCKf,eAAe,uBAAuB;;;MADtC,CAAA,EAGgB,kBAHhB;IACsC,CAAA,EAAA,GAAA;MAAvB,CAAA,GAAA,EAAA,MAAA,CAAA,EAE2C,eAF3C;IAAf,CAAA;EAEgB,CAAA;CAA0C;;;KCN1D,2BAAA;EFFA,QAAA,EEGA,cFHiB,CEGF,oBFFf,CEEoC,aFFtB,CAAA,CAAA;;;;;KGCd,iBAAA;EHFA,QAAA,EGGA,cHHiB,CGGF,UHFA,CGEW,aHF1B,CAAA,CAAA;;qBGIS;;AFArB,CAAA;;;KGLK,8CAA8C;iBAClC,OAAO;AJDxB,CAAA,EAAA,GIEM,eJFM;cIIC,+CAAgD,mCAClD,sBAAsB,qBAAgB;;;;;AHAjD;;AAC2B,cIwBd,sBJxBc,EAAA,GAAA,GAAA,IAAA;;;;;cIiCd,yCAAwC,oBAAoB,uBAAuB;;;AHrChG;;AAC2B,cG4Cd,+BH5Cc,EAAA,GAAA,GG4CwB,WH5CxB,CAAA,MAAA,EG4C4C,oBH5C5C,CG4CiE,aH5CjE,CAAA,CAAA;;;cIUd;iBAOZ;ELfW,iBAAA,EAAA,CAAA,KAAA,+BAA6B,EAAA,yBAAA,eAAA;EACS,eAAA,EAAA,CAAA,KAAA,6BAAA,EAAA,uBAAA,eAAA;EAAvB,KAAA,EAAA,CAAA,KAAA,mBAAA,EAAA,aAAA,eAAA;EAAf,oBAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,yBAAA,CAAA,oBAAA,CAAA;EAEgB,kBAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,uBAAA,CAAA,oBAAA,CAAA;CAA0C"}
@@ -1,4 +1,4 @@
1
- import { a as createVarRefs, c as createExecutionResultParser, r as hidden, t as createRuntimeSlice } from "../slice-ua5mSfhV.js";
1
+ import { a as createVarRefs, c as createExecutionResultParser, r as hidden, t as createRuntimeSlice } from "../slice-BuSNc8vw.js";
2
2
 
3
3
  //#region packages/core/src/runtime/runtime-registry.ts
4
4
  const composedOperationRegistry = /* @__PURE__ */ new Map();
@@ -54,7 +54,8 @@ const createRuntimeComposedOperation = (input) => {
54
54
  parse: createExecutionResultParser({
55
55
  fragments: input.runtime.getSlices({ $: createVarRefs(Object.fromEntries(input.prebuild.variableNames.map((name) => [name, null]))) }),
56
56
  projectionPathGraph: input.prebuild.projectionPathGraph
57
- })
57
+ }),
58
+ metadata: input.prebuild.metadata
58
59
  };
59
60
  registerComposedOperation(operation);
60
61
  return operation;
@@ -68,7 +69,8 @@ const createRuntimeInlineOperation = (input) => {
68
69
  operationName: input.prebuild.operationName,
69
70
  variableNames: input.prebuild.variableNames,
70
71
  documentSource: hidden(),
71
- document: input.prebuild.document
72
+ document: input.prebuild.document,
73
+ metadata: input.prebuild.metadata
72
74
  };
73
75
  registerInlineOperation(operation);
74
76
  return operation;
@@ -1 +1 @@
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 } 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 } 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;EACH;AAED,2BAA0B,UAAU;AAEpC,QAAO;;;;;ACxBT,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;EAC1B;AAED,yBAAwB,UAAU;AAElC,QAAO;;;;;ACVT,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
+ {"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"}
@@ -22,6 +22,27 @@ const createVarRefFromConstValue = (value) => {
22
22
  value
23
23
  });
24
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
+ };
25
46
 
26
47
  //#endregion
27
48
  //#region packages/core/src/types/runtime/projection.ts
@@ -220,9 +241,10 @@ function mapValues(obj, fn) {
220
241
  //#region packages/core/src/composer/input.ts
221
242
  const mergeVarDefinitions = (definitions) => Object.assign({}, ...definitions);
222
243
  const createVarAssignments = (definitions, providedValues) => {
223
- return mapValues(definitions, (definition, _) => {
224
- if (!providedValues || providedValues[definition.name] === void 0) return createVarRefFromConstValue(void 0);
225
- const provided = providedValues[definition.name];
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];
226
248
  if (isVarRef(provided)) return provided;
227
249
  return createVarRefFromConstValue(provided);
228
250
  });
@@ -252,5 +274,5 @@ const createRuntimeSlice = (input) => {
252
274
  };
253
275
 
254
276
  //#endregion
255
- export { createVarRefs as a, createExecutionResultParser as c, SlicedExecutionResultSuccess as d, Projection as f, createVarAssignments as i, SlicedExecutionResultEmpty as l, handleProjectionBuilder as n, mergeVarDefinitions as o, VarRef as p, hidden as r, mapValues as s, createRuntimeSlice as t, SlicedExecutionResultError as u };
256
- //# sourceMappingURL=slice-ua5mSfhV.js.map
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
@@ -0,0 +1 @@
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":"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"}
@@ -23,6 +23,27 @@ const createVarRefFromConstValue = (value) => {
23
23
  value
24
24
  });
25
25
  };
26
+ const getVarRefInner = (varRef) => {
27
+ return VarRef.getInner(varRef);
28
+ };
29
+ /**
30
+ * Get the variable name from a VarRef.
31
+ * Throws if the VarRef contains a const-value instead of a variable reference.
32
+ */
33
+ const getVarRefName = (varRef) => {
34
+ const inner = VarRef.getInner(varRef);
35
+ if (inner.type !== "variable") throw new Error("Expected variable reference, got const-value");
36
+ return inner.name;
37
+ };
38
+ /**
39
+ * Get the const value from a VarRef.
40
+ * Throws if the VarRef contains a variable reference instead of a const-value.
41
+ */
42
+ const getVarRefValue = (varRef) => {
43
+ const inner = VarRef.getInner(varRef);
44
+ if (inner.type !== "const-value") throw new Error("Expected const-value, got variable reference");
45
+ return inner.value;
46
+ };
26
47
 
27
48
  //#endregion
28
49
  //#region packages/core/src/types/runtime/projection.ts
@@ -221,9 +242,10 @@ function mapValues(obj, fn) {
221
242
  //#region packages/core/src/composer/input.ts
222
243
  const mergeVarDefinitions = (definitions) => Object.assign({}, ...definitions);
223
244
  const createVarAssignments = (definitions, providedValues) => {
224
- return mapValues(definitions, (definition, _) => {
225
- if (!providedValues || providedValues[definition.name] === void 0) return createVarRefFromConstValue(void 0);
226
- const provided = providedValues[definition.name];
245
+ return mapValues(definitions, (_definition, key) => {
246
+ const varName = key;
247
+ if (!providedValues || providedValues[varName] === void 0) return createVarRefFromConstValue(void 0);
248
+ const provided = providedValues[varName];
227
249
  if (isVarRef(provided)) return provided;
228
250
  return createVarRefFromConstValue(provided);
229
251
  });
@@ -307,6 +329,24 @@ Object.defineProperty(exports, 'createVarRefs', {
307
329
  return createVarRefs;
308
330
  }
309
331
  });
332
+ Object.defineProperty(exports, 'getVarRefInner', {
333
+ enumerable: true,
334
+ get: function () {
335
+ return getVarRefInner;
336
+ }
337
+ });
338
+ Object.defineProperty(exports, 'getVarRefName', {
339
+ enumerable: true,
340
+ get: function () {
341
+ return getVarRefName;
342
+ }
343
+ });
344
+ Object.defineProperty(exports, 'getVarRefValue', {
345
+ enumerable: true,
346
+ get: function () {
347
+ return getVarRefValue;
348
+ }
349
+ });
310
350
  Object.defineProperty(exports, 'handleProjectionBuilder', {
311
351
  enumerable: true,
312
352
  get: function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soda-gql/core",
3
- "version": "0.0.9",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "license": "MIT",
@@ -30,6 +30,13 @@
30
30
  "require": "./dist/runtime/index.cjs",
31
31
  "default": "./dist/runtime/index.js"
32
32
  },
33
+ "./metadata": {
34
+ "@soda-gql": "./src/metadata/index.ts",
35
+ "types": "./dist/metadata/index.d.ts",
36
+ "import": "./dist/metadata/index.js",
37
+ "require": "./dist/metadata/index.cjs",
38
+ "default": "./dist/metadata/index.js"
39
+ },
33
40
  "./package.json": "./package.json"
34
41
  },
35
42
  "dependencies": {