@soda-gql/core 0.1.0 → 0.2.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 (68) hide show
  1. package/README.md +70 -135
  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-B-erotAZ.d.cts +657 -0
  11. package/dist/index-B-erotAZ.d.cts.map +1 -0
  12. package/dist/index-Djr9A4KL.d.ts +657 -0
  13. package/dist/index-Djr9A4KL.d.ts.map +1 -0
  14. package/dist/index.cjs +430 -416
  15. package/dist/index.cjs.map +1 -0
  16. package/dist/index.d.cts +88 -3
  17. package/dist/index.d.cts.map +1 -0
  18. package/dist/index.d.ts +88 -3
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +399 -386
  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-Bip7o0g3.cjs +128 -0
  31. package/dist/schema-Bip7o0g3.cjs.map +1 -0
  32. package/dist/{index-zGZ61WLt.d.cts → schema-BygZwEX8.d.ts} +246 -117
  33. package/dist/schema-BygZwEX8.d.ts.map +1 -0
  34. package/dist/schema-D9wIW5Dl.js +86 -0
  35. package/dist/schema-D9wIW5Dl.js.map +1 -0
  36. package/dist/{index-Db9ogofS.d.ts → schema-DRkKucYe.d.cts} +246 -117
  37. package/dist/schema-DRkKucYe.d.cts.map +1 -0
  38. package/dist/schema-builder-8zadflz-.d.cts +40 -0
  39. package/dist/schema-builder-8zadflz-.d.cts.map +1 -0
  40. package/dist/schema-builder-vwQtCGYI.d.ts +40 -0
  41. package/dist/schema-builder-vwQtCGYI.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.map +0 -1
  46. package/dist/index-Dth0NSJt.d.cts +0 -1015
  47. package/dist/index-Dth0NSJt.d.cts.map +0 -1
  48. package/dist/index-zGZ61WLt.d.cts.map +0 -1
  49. package/dist/merge-CeMx09is.js +0 -74
  50. package/dist/merge-CeMx09is.js.map +0 -1
  51. package/dist/merge-ZxKV1syS.cjs +0 -85
  52. package/dist/metadata/index.cjs +0 -62
  53. package/dist/metadata/index.d.cts +0 -71
  54. package/dist/metadata/index.d.cts.map +0 -1
  55. package/dist/metadata/index.d.ts +0 -71
  56. package/dist/metadata/index.d.ts.map +0 -1
  57. package/dist/metadata/index.js +0 -59
  58. package/dist/metadata/index.js.map +0 -1
  59. package/dist/runtime/index.cjs +0 -107
  60. package/dist/runtime/index.d.cts +0 -72
  61. package/dist/runtime/index.d.cts.map +0 -1
  62. package/dist/runtime/index.d.ts +0 -72
  63. package/dist/runtime/index.d.ts.map +0 -1
  64. package/dist/runtime/index.js +0 -104
  65. package/dist/runtime/index.js.map +0 -1
  66. package/dist/slice-BuSNc8vw.js +0 -278
  67. package/dist/slice-BuSNc8vw.js.map +0 -1
  68. package/dist/slice-C-FIQK-f.cjs +0 -373
@@ -1,107 +0,0 @@
1
- const require_slice = require('../slice-C-FIQK-f.cjs');
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: require_slice.createExecutionResultParser({
55
- fragments: input.runtime.getSlices({ $: require_slice.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: require_slice.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: require_slice.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: require_slice.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: require_slice.createRuntimeSlice,
98
- getComposedOperation,
99
- getInlineOperation
100
- };
101
-
102
- //#endregion
103
- exports.__getRegisteredComposedOperations = __getRegisteredComposedOperations;
104
- exports.__getRegisteredInlineOperations = __getRegisteredInlineOperations;
105
- exports.__resetRuntimeRegistry = __resetRuntimeRegistry;
106
- exports.createRuntimeAdapter = createRuntimeAdapter;
107
- exports.gqlRuntime = gqlRuntime;
@@ -1,72 +0,0 @@
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";
3
-
4
- //#region packages/core/src/runtime/model.d.ts
5
- type RuntimeModelInput = {
6
- prebuild: StripFunctions<AnyModel>;
7
- runtime: {
8
- normalize: (raw: any) => object;
9
- };
10
- };
11
- //#endregion
12
- //#region packages/core/src/runtime/composed-operation.d.ts
13
- type RuntimeComposedOperationInput = {
14
- prebuild: StripFunctions<AnyComposedOperationOf<OperationType>>;
15
- runtime: {
16
- getSlices: (tools: {
17
- $: AnyAssignableInput;
18
- }) => {
19
- [key: string]: AnySlicePayload;
20
- };
21
- };
22
- };
23
- //#endregion
24
- //#region packages/core/src/runtime/inline-operation.d.ts
25
- type RuntimeInlineOperationInput = {
26
- prebuild: StripFunctions<AnyInlineOperationOf<OperationType>>;
27
- runtime: {};
28
- };
29
- //#endregion
30
- //#region packages/core/src/runtime/slice.d.ts
31
- type RuntimeSliceInput = {
32
- prebuild: StripFunctions<AnySliceOf<OperationType>>;
33
- runtime: {
34
- buildProjection: AnyExecutionResultProjectionsBuilder;
35
- };
36
- };
37
- //#endregion
38
- //#region packages/core/src/runtime/runtime-adapter.d.ts
39
- type RuntimeAdapterFactory<TRuntimeAdapter extends AnyGraphqlRuntimeAdapter> = (tools: {
40
- type: <T>() => Hidden<T>;
41
- }) => TRuntimeAdapter;
42
- declare const createRuntimeAdapter: <TRuntimeAdapter extends AnyGraphqlRuntimeAdapter>(factory: RuntimeAdapterFactory<TRuntimeAdapter>) => TRuntimeAdapter;
43
- //#endregion
44
- //#region packages/core/src/runtime/runtime-registry.d.ts
45
- /**
46
- * Test-only function to reset the operation registry
47
- * @internal
48
- */
49
- declare const __resetRuntimeRegistry: () => void;
50
- /**
51
- * Test-only function to get all registered composed operations
52
- * @internal
53
- */
54
- declare const __getRegisteredComposedOperations: () => ReadonlyMap<string, AnyComposedOperationOf<OperationType>>;
55
- /**
56
- * Test-only function to get all registered inline operations
57
- * @internal
58
- */
59
- declare const __getRegisteredInlineOperations: () => ReadonlyMap<string, AnyInlineOperationOf<OperationType>>;
60
- //#endregion
61
- //#region packages/core/src/runtime/index.d.ts
62
- declare const gqlRuntime: {
63
- model: (input: RuntimeModelInput) => AnyModel;
64
- composedOperation: (input: RuntimeComposedOperationInput) => AnyComposedOperationOf<OperationType>;
65
- inlineOperation: (input: RuntimeInlineOperationInput) => AnyInlineOperationOf<OperationType>;
66
- slice: (input: RuntimeSliceInput) => AnySliceOf<OperationType>;
67
- getComposedOperation: (name: string) => AnyComposedOperationOf<keyof OperationRoots>;
68
- getInlineOperation: (name: string) => AnyInlineOperationOf<keyof OperationRoots>;
69
- };
70
- //#endregion
71
- export { type RuntimeComposedOperationInput, type RuntimeInlineOperationInput, type RuntimeModelInput, type RuntimeSliceInput, __getRegisteredComposedOperations, __getRegisteredInlineOperations, __resetRuntimeRegistry, createRuntimeAdapter, gqlRuntime };
72
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
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,72 +0,0 @@
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";
3
-
4
- //#region packages/core/src/runtime/model.d.ts
5
- type RuntimeModelInput = {
6
- prebuild: StripFunctions<AnyModel>;
7
- runtime: {
8
- normalize: (raw: any) => object;
9
- };
10
- };
11
- //#endregion
12
- //#region packages/core/src/runtime/composed-operation.d.ts
13
- type RuntimeComposedOperationInput = {
14
- prebuild: StripFunctions<AnyComposedOperationOf<OperationType>>;
15
- runtime: {
16
- getSlices: (tools: {
17
- $: AnyAssignableInput;
18
- }) => {
19
- [key: string]: AnySlicePayload;
20
- };
21
- };
22
- };
23
- //#endregion
24
- //#region packages/core/src/runtime/inline-operation.d.ts
25
- type RuntimeInlineOperationInput = {
26
- prebuild: StripFunctions<AnyInlineOperationOf<OperationType>>;
27
- runtime: {};
28
- };
29
- //#endregion
30
- //#region packages/core/src/runtime/slice.d.ts
31
- type RuntimeSliceInput = {
32
- prebuild: StripFunctions<AnySliceOf<OperationType>>;
33
- runtime: {
34
- buildProjection: AnyExecutionResultProjectionsBuilder;
35
- };
36
- };
37
- //#endregion
38
- //#region packages/core/src/runtime/runtime-adapter.d.ts
39
- type RuntimeAdapterFactory<TRuntimeAdapter extends AnyGraphqlRuntimeAdapter> = (tools: {
40
- type: <T>() => Hidden<T>;
41
- }) => TRuntimeAdapter;
42
- declare const createRuntimeAdapter: <TRuntimeAdapter extends AnyGraphqlRuntimeAdapter>(factory: RuntimeAdapterFactory<TRuntimeAdapter>) => TRuntimeAdapter;
43
- //#endregion
44
- //#region packages/core/src/runtime/runtime-registry.d.ts
45
- /**
46
- * Test-only function to reset the operation registry
47
- * @internal
48
- */
49
- declare const __resetRuntimeRegistry: () => void;
50
- /**
51
- * Test-only function to get all registered composed operations
52
- * @internal
53
- */
54
- declare const __getRegisteredComposedOperations: () => ReadonlyMap<string, AnyComposedOperationOf<OperationType>>;
55
- /**
56
- * Test-only function to get all registered inline operations
57
- * @internal
58
- */
59
- declare const __getRegisteredInlineOperations: () => ReadonlyMap<string, AnyInlineOperationOf<OperationType>>;
60
- //#endregion
61
- //#region packages/core/src/runtime/index.d.ts
62
- declare const gqlRuntime: {
63
- model: (input: RuntimeModelInput) => AnyModel;
64
- composedOperation: (input: RuntimeComposedOperationInput) => AnyComposedOperationOf<OperationType>;
65
- inlineOperation: (input: RuntimeInlineOperationInput) => AnyInlineOperationOf<OperationType>;
66
- slice: (input: RuntimeSliceInput) => AnySliceOf<OperationType>;
67
- getComposedOperation: (name: string) => AnyComposedOperationOf<keyof OperationRoots>;
68
- getInlineOperation: (name: string) => AnyInlineOperationOf<keyof OperationRoots>;
69
- };
70
- //#endregion
71
- export { type RuntimeComposedOperationInput, type RuntimeInlineOperationInput, type RuntimeModelInput, type RuntimeSliceInput, __getRegisteredComposedOperations, __getRegisteredInlineOperations, __resetRuntimeRegistry, createRuntimeAdapter, gqlRuntime };
72
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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,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