houdini 1.0.0-next.1 → 1.0.0-next.11
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.
- package/build/cmd/generate.d.ts +0 -1
- package/build/cmd-cjs/index.js +3487 -4695
- package/build/cmd-esm/index.js +3473 -4681
- package/build/codegen/generators/artifacts/fieldKey.d.ts +1 -1
- package/build/codegen/generators/artifacts/index.d.ts +2 -2
- package/build/codegen/generators/artifacts/indexFile.d.ts +2 -2
- package/build/codegen/generators/artifacts/inputs.d.ts +2 -2
- package/build/codegen/generators/artifacts/operations.d.ts +2 -2
- package/build/codegen/generators/artifacts/selection.d.ts +5 -5
- package/build/codegen/generators/artifacts/utils.d.ts +1 -2
- package/build/codegen/generators/definitions/enums.d.ts +1 -1
- package/build/codegen/generators/definitions/index.d.ts +1 -1
- package/build/codegen/generators/indexFile/index.d.ts +2 -2
- package/build/codegen/generators/persistedQueries/index.d.ts +2 -2
- package/build/codegen/generators/runtime/graphqlFunction.d.ts +2 -0
- package/build/codegen/generators/runtime/index.d.ts +2 -2
- package/build/codegen/generators/runtime/injectPlugins.d.ts +7 -0
- package/build/codegen/generators/runtime/pluginIndex.d.ts +5 -0
- package/build/codegen/generators/typescript/addReferencedInputTypes.d.ts +1 -1
- package/build/codegen/generators/typescript/documentTypes.d.ts +2 -0
- package/build/codegen/generators/typescript/imperativeTypeDef.d.ts +2 -0
- package/build/codegen/generators/typescript/index.d.ts +2 -2
- package/build/codegen/generators/typescript/inlineType.d.ts +1 -1
- package/build/codegen/generators/typescript/typeReference.d.ts +5 -3
- package/build/codegen/generators/typescript/types.d.ts +1 -2
- package/build/codegen/index.d.ts +2 -2
- package/build/codegen/transforms/addID.d.ts +2 -2
- package/build/codegen/transforms/composeQueries.d.ts +5 -5
- package/build/codegen/transforms/fragmentVariables.d.ts +4 -3
- package/build/codegen/transforms/list.d.ts +2 -2
- package/build/codegen/transforms/paginate.d.ts +2 -2
- package/build/codegen/transforms/schema.d.ts +2 -2
- package/build/codegen/transforms/typename.d.ts +2 -2
- package/build/codegen/utils/commonjs.d.ts +2 -0
- package/build/codegen/utils/flattenSelections.d.ts +2 -2
- package/build/codegen/utils/moduleExport.d.ts +1 -1
- package/build/codegen/utils/objectIdentificationSelection.d.ts +1 -1
- package/build/codegen/validators/noIDAlias.d.ts +2 -2
- package/build/codegen/validators/plugins.d.ts +2 -2
- package/build/codegen/validators/typeCheck.d.ts +2 -2
- package/build/codegen/validators/uniqueNames.d.ts +2 -2
- package/build/codegen-cjs/index.js +3020 -4312
- package/build/codegen-esm/index.js +3058 -4350
- package/build/lib/config.d.ts +17 -91
- package/build/lib/deepMerge.d.ts +1 -0
- package/build/lib/fs.d.ts +1 -1
- package/build/lib/graphql.d.ts +5 -2
- package/build/lib/imports.d.ts +1 -1
- package/build/lib/index.d.ts +2 -0
- package/build/lib/path.d.ts +1 -1
- package/build/lib/pipeline.d.ts +1 -1
- package/build/lib/plugin.d.ts +2 -0
- package/build/lib/types.d.ts +254 -6
- package/build/lib/walk.d.ts +8 -5
- package/build/lib-cjs/index.js +885 -2394
- package/build/lib-esm/index.js +859 -2370
- package/build/runtime/cache/cache.d.ts +36 -17
- package/build/runtime/cache/gc.d.ts +1 -1
- package/build/runtime/cache/lists.d.ts +3 -2
- package/build/runtime/cache/schema.d.ts +2 -2
- package/build/runtime/cache/staleManager.d.ts +30 -0
- package/build/runtime/cache/storage.d.ts +5 -5
- package/build/runtime/cache/stuff.d.ts +1 -3
- package/build/runtime/cache/subscription.d.ts +20 -11
- package/build/runtime/client/documentStore.d.ts +88 -0
- package/build/runtime/client/index.d.ts +27 -0
- package/build/runtime/client/plugins/cache.d.ts +8 -0
- package/build/runtime/client/plugins/fetch.d.ts +37 -0
- package/build/runtime/client/plugins/fetchParams.d.ts +9 -0
- package/build/runtime/client/plugins/index.d.ts +7 -0
- package/build/runtime/client/plugins/injectedPlugins.d.ts +4 -0
- package/build/runtime/client/plugins/mutation.d.ts +1 -0
- package/build/runtime/client/plugins/query.d.ts +2 -0
- package/build/runtime/client/plugins/subscription.d.ts +17 -0
- package/build/runtime/client/plugins/throwOnError.d.ts +7 -0
- package/build/runtime/client/utils/documentPlugins.d.ts +3 -0
- package/build/runtime/client/utils/index.d.ts +1 -0
- package/build/runtime/generated.d.ts +1 -0
- package/build/runtime/imports/config.d.ts +3 -0
- package/build/runtime/index.d.ts +3 -2
- package/build/runtime/lib/config.d.ts +30 -25
- package/build/runtime/lib/flatten.d.ts +2 -0
- package/build/runtime/lib/index.d.ts +2 -2
- package/build/runtime/lib/key.d.ts +6 -0
- package/build/runtime/lib/scalars.d.ts +6 -5
- package/build/runtime/lib/selection.d.ts +1 -1
- package/build/runtime/lib/store.d.ts +19 -0
- package/build/runtime/lib/types.d.ts +27 -13
- package/build/runtime/public/cache.d.ts +27 -7
- package/build/runtime/public/list.d.ts +2 -2
- package/build/runtime/public/record.d.ts +27 -18
- package/build/runtime/public/tests/test.d.ts +53 -11
- package/build/runtime/public/types.d.ts +8 -0
- package/build/runtime-cjs/cache/cache.d.ts +36 -17
- package/build/runtime-cjs/cache/cache.js +102 -33
- package/build/runtime-cjs/cache/gc.d.ts +1 -1
- package/build/runtime-cjs/cache/gc.js +9 -0
- package/build/runtime-cjs/cache/lists.d.ts +3 -2
- package/build/runtime-cjs/cache/lists.js +11 -8
- package/build/runtime-cjs/cache/schema.d.ts +2 -2
- package/build/runtime-cjs/cache/staleManager.d.ts +30 -0
- package/build/runtime-cjs/cache/staleManager.js +95 -0
- package/build/runtime-cjs/cache/storage.d.ts +5 -5
- package/build/runtime-cjs/cache/storage.js +2 -2
- package/build/runtime-cjs/cache/stuff.d.ts +1 -3
- package/build/runtime-cjs/cache/stuff.js +2 -19
- package/build/runtime-cjs/cache/subscription.d.ts +20 -11
- package/build/runtime-cjs/cache/subscription.js +102 -59
- package/build/runtime-cjs/client/documentStore.d.ts +88 -0
- package/build/runtime-cjs/client/documentStore.js +361 -0
- package/build/runtime-cjs/client/index.d.ts +27 -0
- package/build/runtime-cjs/client/index.js +113 -0
- package/build/runtime-cjs/client/plugins/cache.d.ts +8 -0
- package/build/runtime-cjs/client/plugins/cache.js +101 -0
- package/build/runtime-cjs/client/plugins/fetch.d.ts +37 -0
- package/build/runtime-cjs/{lib/networkUtils.js → client/plugins/fetch.js} +96 -3
- package/build/runtime-cjs/client/plugins/fetchParams.d.ts +9 -0
- package/build/runtime-cjs/client/plugins/fetchParams.js +45 -0
- package/build/runtime-cjs/client/plugins/index.d.ts +7 -0
- package/build/runtime-cjs/client/plugins/index.js +24 -0
- package/build/runtime-cjs/client/plugins/injectedPlugins.d.ts +4 -0
- package/build/runtime-cjs/{lib/errors.js → client/plugins/injectedPlugins.js} +7 -15
- package/build/runtime-cjs/client/plugins/mutation.d.ts +1 -0
- package/build/runtime-cjs/client/plugins/mutation.js +86 -0
- package/build/runtime-cjs/client/plugins/query.d.ts +2 -0
- package/build/runtime-cjs/client/plugins/query.js +83 -0
- package/build/runtime-cjs/client/plugins/subscription.d.ts +17 -0
- package/build/runtime-cjs/client/plugins/subscription.js +100 -0
- package/build/runtime-cjs/client/plugins/throwOnError.d.ts +7 -0
- package/build/runtime-cjs/client/plugins/throwOnError.js +47 -0
- package/build/runtime-cjs/client/utils/documentPlugins.d.ts +3 -0
- package/build/runtime-cjs/client/utils/documentPlugins.js +56 -0
- package/build/runtime-cjs/client/utils/index.d.ts +1 -0
- package/build/runtime-cjs/client/utils/index.js +18 -0
- package/build/runtime-cjs/generated.d.ts +1 -0
- package/build/runtime-cjs/imports/config.d.ts +3 -0
- package/build/runtime-cjs/imports/config.js +26 -0
- package/build/runtime-cjs/index.d.ts +3 -2
- package/build/runtime-cjs/index.js +1 -0
- package/build/runtime-cjs/lib/config.d.ts +30 -25
- package/build/runtime-cjs/lib/config.js +5 -4
- package/build/runtime-cjs/lib/flatten.d.ts +2 -0
- package/build/runtime-cjs/lib/flatten.js +41 -0
- package/build/runtime-cjs/lib/index.d.ts +2 -2
- package/build/runtime-cjs/lib/index.js +2 -2
- package/build/runtime-cjs/lib/key.d.ts +6 -0
- package/build/runtime-cjs/lib/key.js +41 -0
- package/build/runtime-cjs/lib/scalars.d.ts +6 -5
- package/build/runtime-cjs/lib/scalars.js +20 -24
- package/build/runtime-cjs/lib/selection.d.ts +1 -1
- package/build/runtime-cjs/lib/store.d.ts +19 -0
- package/build/runtime-cjs/lib/store.js +81 -0
- package/build/runtime-cjs/lib/types.d.ts +27 -13
- package/build/runtime-cjs/public/cache.d.ts +27 -7
- package/build/runtime-cjs/public/cache.js +32 -32
- package/build/runtime-cjs/public/list.d.ts +2 -2
- package/build/runtime-cjs/public/list.js +6 -28
- package/build/runtime-cjs/public/record.d.ts +27 -18
- package/build/runtime-cjs/public/record.js +28 -188
- package/build/runtime-cjs/public/tests/test.d.ts +53 -11
- package/build/runtime-cjs/public/tests/test.js +27 -2
- package/build/runtime-cjs/public/types.d.ts +8 -0
- package/build/runtime-esm/cache/cache.d.ts +36 -17
- package/build/runtime-esm/cache/cache.js +104 -35
- package/build/runtime-esm/cache/gc.d.ts +1 -1
- package/build/runtime-esm/cache/gc.js +9 -0
- package/build/runtime-esm/cache/lists.d.ts +3 -2
- package/build/runtime-esm/cache/lists.js +11 -8
- package/build/runtime-esm/cache/schema.d.ts +2 -2
- package/build/runtime-esm/cache/staleManager.d.ts +30 -0
- package/build/runtime-esm/cache/staleManager.js +71 -0
- package/build/runtime-esm/cache/storage.d.ts +5 -5
- package/build/runtime-esm/cache/storage.js +2 -2
- package/build/runtime-esm/cache/stuff.d.ts +1 -3
- package/build/runtime-esm/cache/stuff.js +1 -17
- package/build/runtime-esm/cache/subscription.d.ts +20 -11
- package/build/runtime-esm/cache/subscription.js +103 -60
- package/build/runtime-esm/client/documentStore.d.ts +88 -0
- package/build/runtime-esm/client/documentStore.js +337 -0
- package/build/runtime-esm/client/index.d.ts +27 -0
- package/build/runtime-esm/client/index.js +83 -0
- package/build/runtime-esm/client/plugins/cache.d.ts +8 -0
- package/build/runtime-esm/client/plugins/cache.js +71 -0
- package/build/runtime-esm/client/plugins/fetch.d.ts +37 -0
- package/build/runtime-esm/client/plugins/fetch.js +152 -0
- package/build/runtime-esm/client/plugins/fetchParams.d.ts +9 -0
- package/build/runtime-esm/client/plugins/fetchParams.js +21 -0
- package/build/runtime-esm/client/plugins/index.d.ts +7 -0
- package/build/runtime-esm/client/plugins/index.js +7 -0
- package/build/runtime-esm/client/plugins/injectedPlugins.d.ts +4 -0
- package/build/runtime-esm/client/plugins/injectedPlugins.js +5 -0
- package/build/runtime-esm/client/plugins/mutation.d.ts +1 -0
- package/build/runtime-esm/client/plugins/mutation.js +56 -0
- package/build/runtime-esm/client/plugins/query.d.ts +2 -0
- package/build/runtime-esm/client/plugins/query.js +53 -0
- package/build/runtime-esm/client/plugins/subscription.d.ts +17 -0
- package/build/runtime-esm/client/plugins/subscription.js +76 -0
- package/build/runtime-esm/client/plugins/throwOnError.d.ts +7 -0
- package/build/runtime-esm/client/plugins/throwOnError.js +23 -0
- package/build/runtime-esm/client/utils/documentPlugins.d.ts +3 -0
- package/build/runtime-esm/client/utils/documentPlugins.js +32 -0
- package/build/runtime-esm/client/utils/index.d.ts +1 -0
- package/build/runtime-esm/client/utils/index.js +1 -0
- package/build/runtime-esm/generated.d.ts +1 -0
- package/build/runtime-esm/imports/config.d.ts +3 -0
- package/build/runtime-esm/imports/config.js +4 -0
- package/build/runtime-esm/index.d.ts +3 -2
- package/build/runtime-esm/index.js +1 -0
- package/build/runtime-esm/lib/config.d.ts +30 -25
- package/build/runtime-esm/lib/config.js +5 -4
- package/build/runtime-esm/lib/flatten.d.ts +2 -0
- package/build/runtime-esm/lib/flatten.js +17 -0
- package/build/runtime-esm/lib/index.d.ts +2 -2
- package/build/runtime-esm/lib/index.js +2 -2
- package/build/runtime-esm/lib/key.d.ts +6 -0
- package/build/runtime-esm/lib/key.js +17 -0
- package/build/runtime-esm/lib/scalars.d.ts +6 -5
- package/build/runtime-esm/lib/scalars.js +20 -24
- package/build/runtime-esm/lib/selection.d.ts +1 -1
- package/build/runtime-esm/lib/store.d.ts +19 -0
- package/build/runtime-esm/lib/store.js +57 -0
- package/build/runtime-esm/lib/types.d.ts +27 -13
- package/build/runtime-esm/public/cache.d.ts +27 -7
- package/build/runtime-esm/public/cache.js +31 -30
- package/build/runtime-esm/public/list.d.ts +2 -2
- package/build/runtime-esm/public/list.js +6 -28
- package/build/runtime-esm/public/record.d.ts +27 -18
- package/build/runtime-esm/public/record.js +27 -184
- package/build/runtime-esm/public/tests/test.d.ts +53 -11
- package/build/runtime-esm/public/tests/test.js +26 -1
- package/build/runtime-esm/public/types.d.ts +8 -0
- package/build/test/index.d.ts +6 -5
- package/build/test-cjs/index.js +3051 -4304
- package/build/test-esm/index.js +3048 -4301
- package/build/vite/ast.d.ts +1 -1
- package/build/vite/houdini.d.ts +1 -1
- package/build/vite/imports.d.ts +3 -3
- package/build/vite/index.d.ts +1 -1
- package/build/vite/schema.d.ts +1 -1
- package/build/vite-cjs/index.js +3499 -4691
- package/build/vite-esm/index.js +3448 -4640
- package/package.json +6 -5
- package/build/codegen/generators/typescript/imperativeCache.d.ts +0 -2
- package/build/runtime/lib/errors.d.ts +0 -3
- package/build/runtime/lib/network.d.ts +0 -79
- package/build/runtime/lib/networkUtils.d.ts +0 -8
- package/build/runtime-cjs/lib/errors.d.ts +0 -3
- package/build/runtime-cjs/lib/network.d.ts +0 -79
- package/build/runtime-cjs/lib/network.js +0 -200
- package/build/runtime-cjs/lib/networkUtils.d.ts +0 -8
- package/build/runtime-esm/lib/errors.d.ts +0 -3
- package/build/runtime-esm/lib/errors.js +0 -11
- package/build/runtime-esm/lib/network.d.ts +0 -79
- package/build/runtime-esm/lib/network.js +0 -170
- package/build/runtime-esm/lib/networkUtils.d.ts +0 -8
- package/build/runtime-esm/lib/networkUtils.js +0 -60
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import config from "../imports/config";
|
|
1
2
|
let mockConfig = null;
|
|
2
3
|
function getMockConfig() {
|
|
3
4
|
return mockConfig;
|
|
4
5
|
}
|
|
5
|
-
function setMockConfig(
|
|
6
|
-
mockConfig =
|
|
6
|
+
function setMockConfig(config2) {
|
|
7
|
+
mockConfig = config2;
|
|
7
8
|
}
|
|
8
9
|
function defaultConfigValues(file) {
|
|
9
10
|
return {
|
|
@@ -32,12 +33,12 @@ function computeID(configFile, type, data) {
|
|
|
32
33
|
}
|
|
33
34
|
return id.slice(0, -2);
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
+
function getCurrentConfig() {
|
|
36
37
|
const mockConfig2 = getMockConfig();
|
|
37
38
|
if (mockConfig2) {
|
|
38
39
|
return mockConfig2;
|
|
39
40
|
}
|
|
40
|
-
return defaultConfigValues(
|
|
41
|
+
return defaultConfigValues(config);
|
|
41
42
|
}
|
|
42
43
|
export {
|
|
43
44
|
computeID,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function flatten(source) {
|
|
2
|
+
if (!source) {
|
|
3
|
+
return [];
|
|
4
|
+
}
|
|
5
|
+
return source.reduce((acc, element) => {
|
|
6
|
+
if (!element) {
|
|
7
|
+
return acc;
|
|
8
|
+
}
|
|
9
|
+
if (Array.isArray(element)) {
|
|
10
|
+
return acc.concat(flatten(element));
|
|
11
|
+
}
|
|
12
|
+
return acc.concat(element);
|
|
13
|
+
}, []);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
flatten
|
|
17
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export * from './config';
|
|
2
2
|
export * from './constants';
|
|
3
3
|
export * from './deepEquals';
|
|
4
|
-
export * from './errors';
|
|
5
4
|
export * from './log';
|
|
6
|
-
export * from './network';
|
|
7
5
|
export * from './scalars';
|
|
8
6
|
export * from './types';
|
|
7
|
+
export * from './store';
|
|
8
|
+
export * from './key';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export * from "./config";
|
|
2
2
|
export * from "./constants";
|
|
3
3
|
export * from "./deepEquals";
|
|
4
|
-
export * from "./errors";
|
|
5
4
|
export * from "./log";
|
|
6
|
-
export * from "./network";
|
|
7
5
|
export * from "./scalars";
|
|
8
6
|
export * from "./types";
|
|
7
|
+
export * from "./store";
|
|
8
|
+
export * from "./key";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const computeKey = ({ field, args }) => {
|
|
2
|
+
const keys = Object.keys(args ?? {});
|
|
3
|
+
keys.sort();
|
|
4
|
+
return args && keys.length > 0 ? `${field}(${keys.map((key) => `${key}: ${stringifyObjectWithNoQuotesOnKeys(args[key])}`).join(", ")})` : field;
|
|
5
|
+
};
|
|
6
|
+
const stringifyObjectWithNoQuotesOnKeys = (obj_from_json) => {
|
|
7
|
+
if (Array.isArray(obj_from_json)) {
|
|
8
|
+
return `[${obj_from_json.map((obj) => `${stringifyObjectWithNoQuotesOnKeys(obj)}`).join(", ")}]`;
|
|
9
|
+
}
|
|
10
|
+
if (typeof obj_from_json !== "object" || obj_from_json instanceof Date || obj_from_json === null) {
|
|
11
|
+
return JSON.stringify(obj_from_json).replace(/"([^"]+)":/g, "$1: ");
|
|
12
|
+
}
|
|
13
|
+
return `{${Object.keys(obj_from_json).map((key) => `${key}: ${stringifyObjectWithNoQuotesOnKeys(obj_from_json[key])}`).join(", ")}}`;
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
computeKey
|
|
17
|
+
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { ConfigFile } from './config';
|
|
2
|
-
import { MutationArtifact, QueryArtifact, SubscriptionArtifact, SubscriptionSelection } from './types';
|
|
1
|
+
import type { ConfigFile } from './config';
|
|
2
|
+
import type { FragmentArtifact, MutationArtifact, QueryArtifact, SubscriptionArtifact, SubscriptionSelection } from './types';
|
|
3
3
|
export declare function marshalSelection({ selection, data, }: {
|
|
4
4
|
selection: SubscriptionSelection;
|
|
5
5
|
data: any;
|
|
6
6
|
}): Promise<{} | null | undefined>;
|
|
7
|
-
export declare function marshalInputs<T>({ artifact, input, rootType, }: {
|
|
8
|
-
artifact: QueryArtifact | MutationArtifact | SubscriptionArtifact;
|
|
7
|
+
export declare function marshalInputs<T>({ artifact, input, config, rootType, }: {
|
|
8
|
+
artifact: QueryArtifact | MutationArtifact | SubscriptionArtifact | FragmentArtifact;
|
|
9
9
|
input: unknown;
|
|
10
10
|
rootType?: string;
|
|
11
|
-
|
|
11
|
+
config: ConfigFile;
|
|
12
|
+
}): {} | null | undefined;
|
|
12
13
|
export declare function unmarshalSelection(config: ConfigFile, selection: SubscriptionSelection, data: any): {} | null | undefined;
|
|
13
14
|
export declare function isScalar(config: ConfigFile, type: string): boolean;
|
|
14
15
|
export declare function parseScalar(config: ConfigFile, type: string, value: string): string | number | boolean;
|
|
@@ -4,7 +4,7 @@ async function marshalSelection({
|
|
|
4
4
|
selection,
|
|
5
5
|
data
|
|
6
6
|
}) {
|
|
7
|
-
const config =
|
|
7
|
+
const config = getCurrentConfig();
|
|
8
8
|
if (data === null || typeof data === "undefined") {
|
|
9
9
|
return data;
|
|
10
10
|
}
|
|
@@ -39,12 +39,12 @@ async function marshalSelection({
|
|
|
39
39
|
)
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
function marshalInputs({
|
|
43
43
|
artifact,
|
|
44
44
|
input,
|
|
45
|
+
config,
|
|
45
46
|
rootType = "@root"
|
|
46
47
|
}) {
|
|
47
|
-
const config = await getCurrentConfig();
|
|
48
48
|
if (input === null || typeof input === "undefined") {
|
|
49
49
|
return input;
|
|
50
50
|
}
|
|
@@ -53,30 +53,26 @@ async function marshalInputs({
|
|
|
53
53
|
}
|
|
54
54
|
const fields = rootType === "@root" ? artifact.input.fields : artifact.input.types[rootType];
|
|
55
55
|
if (Array.isArray(input)) {
|
|
56
|
-
return
|
|
57
|
-
input.map(async (val) => await marshalInputs({ artifact, input: val, rootType }))
|
|
58
|
-
);
|
|
56
|
+
return input.map((val) => marshalInputs({ artifact, input: val, rootType, config }));
|
|
59
57
|
}
|
|
60
58
|
return Object.fromEntries(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
return [fieldName, value.map(marshalFn)];
|
|
71
|
-
}
|
|
72
|
-
return [fieldName, marshalFn(value)];
|
|
73
|
-
}
|
|
74
|
-
if (isScalar(config, type) || !artifact.input.types[type]) {
|
|
75
|
-
return [fieldName, value];
|
|
59
|
+
Object.entries(input).map(([fieldName, value]) => {
|
|
60
|
+
const type = fields?.[fieldName];
|
|
61
|
+
if (!type) {
|
|
62
|
+
return [fieldName, value];
|
|
63
|
+
}
|
|
64
|
+
const marshalFn = config.scalars?.[type]?.marshal;
|
|
65
|
+
if (marshalFn) {
|
|
66
|
+
if (Array.isArray(value)) {
|
|
67
|
+
return [fieldName, value.map(marshalFn)];
|
|
76
68
|
}
|
|
77
|
-
return [fieldName,
|
|
78
|
-
}
|
|
79
|
-
|
|
69
|
+
return [fieldName, marshalFn(value)];
|
|
70
|
+
}
|
|
71
|
+
if (isScalar(config, type) || !artifact.input.types[type]) {
|
|
72
|
+
return [fieldName, value];
|
|
73
|
+
}
|
|
74
|
+
return [fieldName, marshalInputs({ artifact, input: value, rootType: type, config })];
|
|
75
|
+
})
|
|
80
76
|
);
|
|
81
77
|
}
|
|
82
78
|
function unmarshalSelection(config, selection, data) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SubscriptionSelection } from './types';
|
|
1
|
+
import type { SubscriptionSelection } from './types';
|
|
2
2
|
export declare function getFieldsForType(selection: SubscriptionSelection, __typename: string | undefined | null): Required<SubscriptionSelection>['fields'];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class Writable<T> {
|
|
2
|
+
#private;
|
|
3
|
+
state: T;
|
|
4
|
+
constructor(value: T, start?: StartStopNotifier<T>);
|
|
5
|
+
set(new_value: T): void;
|
|
6
|
+
update(fn: Updater<T>): void;
|
|
7
|
+
subscribe(run: Subscriber<T>, invalidate?: Invalidator<T>): Unsubscriber;
|
|
8
|
+
}
|
|
9
|
+
/** Start and stop notification callbacks. */
|
|
10
|
+
type StartStopNotifier<T> = (set: Subscriber<T>) => Unsubscriber | void;
|
|
11
|
+
/** Callback to inform of a value updates. */
|
|
12
|
+
export type Subscriber<T> = (value: T) => void;
|
|
13
|
+
/** Unsubscribes from value updates. */
|
|
14
|
+
export type Unsubscriber = () => void;
|
|
15
|
+
/** Callback to update a value. */
|
|
16
|
+
type Updater<T> = (value: T) => T;
|
|
17
|
+
/** Cleanup logic callback. */
|
|
18
|
+
type Invalidator<T> = (value?: T) => void;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const subscriber_queue = [];
|
|
2
|
+
const noop = () => {
|
|
3
|
+
};
|
|
4
|
+
class Writable {
|
|
5
|
+
state;
|
|
6
|
+
#subscribers;
|
|
7
|
+
#stop;
|
|
8
|
+
#start;
|
|
9
|
+
constructor(value, start = noop) {
|
|
10
|
+
this.state = value;
|
|
11
|
+
this.#subscribers = /* @__PURE__ */ new Set();
|
|
12
|
+
this.#stop = null;
|
|
13
|
+
this.#start = start;
|
|
14
|
+
}
|
|
15
|
+
set(new_value) {
|
|
16
|
+
if (safe_not_equal(this.state, new_value)) {
|
|
17
|
+
this.state = new_value;
|
|
18
|
+
if (this.#stop) {
|
|
19
|
+
const run_queue = !subscriber_queue.length;
|
|
20
|
+
for (const subscriber of this.#subscribers) {
|
|
21
|
+
subscriber[1]();
|
|
22
|
+
subscriber_queue.push(subscriber, this.state);
|
|
23
|
+
}
|
|
24
|
+
if (run_queue) {
|
|
25
|
+
for (let i = 0; i < subscriber_queue.length; i += 2) {
|
|
26
|
+
subscriber_queue[i][0](subscriber_queue[i + 1]);
|
|
27
|
+
}
|
|
28
|
+
subscriber_queue.length = 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
update(fn) {
|
|
34
|
+
this.set(fn(this.state));
|
|
35
|
+
}
|
|
36
|
+
subscribe(run, invalidate = noop) {
|
|
37
|
+
const subscriber = [run, invalidate];
|
|
38
|
+
this.#subscribers.add(subscriber);
|
|
39
|
+
if (this.#subscribers.size === 1) {
|
|
40
|
+
this.#stop = this.#start(this.set) || noop;
|
|
41
|
+
}
|
|
42
|
+
run(this.state);
|
|
43
|
+
return () => {
|
|
44
|
+
this.#subscribers.delete(subscriber);
|
|
45
|
+
if (this.#subscribers.size === 0) {
|
|
46
|
+
this.#stop?.();
|
|
47
|
+
this.#stop = null;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function safe_not_equal(a, b) {
|
|
53
|
+
return a != a ? b == b : a !== b || a && typeof a === "object" || typeof a === "function";
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
Writable
|
|
57
|
+
};
|
|
@@ -4,6 +4,22 @@ export declare enum CachePolicy {
|
|
|
4
4
|
NetworkOnly = "NetworkOnly",
|
|
5
5
|
CacheAndNetwork = "CacheAndNetwork"
|
|
6
6
|
}
|
|
7
|
+
declare global {
|
|
8
|
+
namespace App {
|
|
9
|
+
interface Session {
|
|
10
|
+
}
|
|
11
|
+
interface Metadata {
|
|
12
|
+
}
|
|
13
|
+
interface Stuff {
|
|
14
|
+
inputs: {
|
|
15
|
+
init: boolean;
|
|
16
|
+
marshaled: Record<string, any>;
|
|
17
|
+
changed: boolean;
|
|
18
|
+
};
|
|
19
|
+
optimisticResponse?: GraphQLObject;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
7
23
|
export type Fragment<_Result> = {
|
|
8
24
|
readonly shape?: _Result;
|
|
9
25
|
};
|
|
@@ -55,7 +71,6 @@ export type BaseCompiledDocument = {
|
|
|
55
71
|
rootType: string;
|
|
56
72
|
input?: InputObject;
|
|
57
73
|
refetch?: {
|
|
58
|
-
update: RefetchUpdateMode;
|
|
59
74
|
path: string[];
|
|
60
75
|
method: 'cursor' | 'offset';
|
|
61
76
|
pageSize: number;
|
|
@@ -63,8 +78,9 @@ export type BaseCompiledDocument = {
|
|
|
63
78
|
embedded: boolean;
|
|
64
79
|
targetType: string;
|
|
65
80
|
paginated: boolean;
|
|
66
|
-
direction
|
|
81
|
+
direction: 'forward' | 'backward' | 'both';
|
|
67
82
|
};
|
|
83
|
+
plugin_data?: Record<string, any>;
|
|
68
84
|
};
|
|
69
85
|
export type HoudiniFetchContext = {
|
|
70
86
|
variables: () => {};
|
|
@@ -118,7 +134,7 @@ export type SubscriptionSelection = {
|
|
|
118
134
|
connection: boolean;
|
|
119
135
|
type: string;
|
|
120
136
|
};
|
|
121
|
-
|
|
137
|
+
updates?: string[];
|
|
122
138
|
filters?: {
|
|
123
139
|
[key: string]: {
|
|
124
140
|
kind: 'Boolean' | 'String' | 'Float' | 'Int' | 'Variable';
|
|
@@ -148,26 +164,24 @@ export type SubscriptionSpec = {
|
|
|
148
164
|
export type FetchQueryResult<_Data> = {
|
|
149
165
|
result: RequestPayload<_Data | null>;
|
|
150
166
|
source: DataSource | null;
|
|
151
|
-
partial: boolean;
|
|
152
167
|
};
|
|
153
|
-
export type QueryResult<_Data, _Input
|
|
168
|
+
export type QueryResult<_Data = GraphQLObject, _Input = Record<string, any>> = {
|
|
154
169
|
data: _Data | null;
|
|
155
170
|
errors: {
|
|
156
171
|
message: string;
|
|
157
172
|
}[] | null;
|
|
158
173
|
fetching: boolean;
|
|
159
174
|
partial: boolean;
|
|
175
|
+
stale: boolean;
|
|
160
176
|
source: DataSource | null;
|
|
161
|
-
variables: _Input;
|
|
162
|
-
}
|
|
163
|
-
export type RequestPayload<
|
|
164
|
-
data:
|
|
177
|
+
variables: _Input | null;
|
|
178
|
+
};
|
|
179
|
+
export type RequestPayload<GraphQLObject = any> = {
|
|
180
|
+
data: GraphQLObject | null;
|
|
165
181
|
errors: {
|
|
166
182
|
message: string;
|
|
167
183
|
}[] | null;
|
|
168
184
|
};
|
|
169
|
-
export type
|
|
170
|
-
|
|
171
|
-
body: RequestPayload<_Data>;
|
|
172
|
-
};
|
|
185
|
+
export type NestedList<_Result = string> = (_Result | null | NestedList<_Result>)[];
|
|
186
|
+
export type ValueOf<Parent> = Parent[keyof Parent];
|
|
173
187
|
export {};
|
|
@@ -1,19 +1,39 @@
|
|
|
1
|
-
import { Cache as _Cache } from '../cache/cache';
|
|
2
|
-
import {
|
|
1
|
+
import type { Cache as _Cache } from '../cache/cache';
|
|
2
|
+
import { type QueryArtifact } from '../lib';
|
|
3
3
|
import { ListCollection } from './list';
|
|
4
4
|
import { Record } from './record';
|
|
5
|
-
import type { CacheTypeDef, IDFields, TypeNames, ValidLists } from './types';
|
|
5
|
+
import type { ArgType, CacheTypeDef, IDFields, QueryInput, QueryList, QueryValue, TypeFieldNames, TypeNames, ValidLists } from './types';
|
|
6
6
|
export declare class Cache<Def extends CacheTypeDef> {
|
|
7
7
|
_internal_unstable: _Cache;
|
|
8
8
|
constructor(cache: _Cache);
|
|
9
9
|
validateInstabilityWarning(): void;
|
|
10
|
-
setFieldType(...args: Parameters<SchemaManager['setFieldType']>): void;
|
|
11
|
-
get root(): Record<Def, '__ROOT__'>;
|
|
12
10
|
get<T extends TypeNames<Def>>(type: T, data: IDFields<Def, T>): Record<Def, T>;
|
|
13
|
-
get config(): import("
|
|
11
|
+
get config(): import("../lib").ConfigFile;
|
|
14
12
|
list<Name extends ValidLists<Def>>(name: Name, { parentID, allLists }?: {
|
|
15
13
|
parentID?: string;
|
|
16
14
|
allLists?: boolean;
|
|
17
15
|
}): ListCollection<Def, Name>;
|
|
16
|
+
read<_Query extends {
|
|
17
|
+
artifact: QueryArtifact;
|
|
18
|
+
}>({ query, variables, }: {
|
|
19
|
+
query: _Query;
|
|
20
|
+
variables?: QueryInput<QueryList<Def>, _Query>;
|
|
21
|
+
}): {
|
|
22
|
+
data: QueryValue<QueryList<Def>, _Query> | null;
|
|
23
|
+
partial: boolean;
|
|
24
|
+
};
|
|
25
|
+
write<_Query extends {
|
|
26
|
+
artifact: QueryArtifact;
|
|
27
|
+
}>({ query, variables, data, }: {
|
|
28
|
+
query: _Query;
|
|
29
|
+
data: QueryValue<QueryList<Def>, _Query>;
|
|
30
|
+
variables?: QueryInput<QueryList<Def>, _Query>;
|
|
31
|
+
}): void;
|
|
32
|
+
/**
|
|
33
|
+
* Mark some elements of the cache stale.
|
|
34
|
+
*/
|
|
35
|
+
markStale<_Type extends TypeNames<Def>, _Field extends TypeFieldNames<Def, _Type>>(type?: _Type, options?: {
|
|
36
|
+
field?: _Field;
|
|
37
|
+
when?: ArgType<Def, _Type, _Field>;
|
|
38
|
+
}): void;
|
|
18
39
|
}
|
|
19
|
-
export declare function _typeInfo<Def extends CacheTypeDef>(cache: Cache<Def>, type: string, field: string): TypeInfo;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { marshalInputs } from "../lib";
|
|
2
2
|
import { ListCollection } from "./list";
|
|
3
3
|
import { Record } from "./record";
|
|
4
4
|
class Cache {
|
|
@@ -12,19 +12,6 @@ class Cache {
|
|
|
12
12
|
Please acknowledge this by setting acceptImperativeInstability to true in your config file.`);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
setFieldType(...args) {
|
|
16
|
-
this.validateInstabilityWarning();
|
|
17
|
-
this._internal_unstable._internal_unstable.schema.setFieldType(...args);
|
|
18
|
-
}
|
|
19
|
-
get root() {
|
|
20
|
-
this.validateInstabilityWarning();
|
|
21
|
-
return new Record({
|
|
22
|
-
cache: this,
|
|
23
|
-
type: "Query",
|
|
24
|
-
id: rootID,
|
|
25
|
-
idFields: {}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
15
|
get(type, data) {
|
|
29
16
|
this.validateInstabilityWarning();
|
|
30
17
|
let recordID = this._internal_unstable._internal_unstable.id(type, data);
|
|
@@ -42,6 +29,7 @@ Please acknowledge this by setting acceptImperativeInstability to true in your c
|
|
|
42
29
|
return this._internal_unstable._internal_unstable.config;
|
|
43
30
|
}
|
|
44
31
|
list(name, { parentID, allLists } = {}) {
|
|
32
|
+
this.validateInstabilityWarning();
|
|
45
33
|
return new ListCollection({
|
|
46
34
|
cache: this,
|
|
47
35
|
name,
|
|
@@ -49,24 +37,37 @@ Please acknowledge this by setting acceptImperativeInstability to true in your c
|
|
|
49
37
|
allLists
|
|
50
38
|
});
|
|
51
39
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
40
|
+
read({
|
|
41
|
+
query,
|
|
42
|
+
variables
|
|
43
|
+
}) {
|
|
44
|
+
this.validateInstabilityWarning();
|
|
45
|
+
return this._internal_unstable.read({
|
|
46
|
+
selection: query.artifact.selection,
|
|
47
|
+
variables
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
write({
|
|
51
|
+
query,
|
|
52
|
+
variables,
|
|
53
|
+
data
|
|
54
|
+
}) {
|
|
55
|
+
this.validateInstabilityWarning();
|
|
56
|
+
this._internal_unstable.write({
|
|
57
|
+
selection: query.artifact.selection,
|
|
58
|
+
data,
|
|
59
|
+
variables: marshalInputs({
|
|
60
|
+
config: this.config,
|
|
61
|
+
artifact: query.artifact,
|
|
62
|
+
input: variables
|
|
63
|
+
}) ?? {}
|
|
64
|
+
});
|
|
65
|
+
return;
|
|
60
66
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
throw new Error(
|
|
64
|
-
`Unknown field: ${field} for type ${type}. Please provide type information using setFieldType().`
|
|
65
|
-
);
|
|
67
|
+
markStale(type, options) {
|
|
68
|
+
return this._internal_unstable.markTypeStale(type ? { ...options, type } : void 0);
|
|
66
69
|
}
|
|
67
|
-
return info;
|
|
68
70
|
}
|
|
69
71
|
export {
|
|
70
|
-
Cache
|
|
71
|
-
_typeInfo
|
|
72
|
+
Cache
|
|
72
73
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Cache } from './cache';
|
|
2
|
-
import { CacheTypeDef, ListType, ValidLists, ListFilters } from './types';
|
|
1
|
+
import type { Cache } from './cache';
|
|
2
|
+
import type { CacheTypeDef, ListType, ValidLists, ListFilters } from './types';
|
|
3
3
|
export declare class ListCollection<Def extends CacheTypeDef, ListName extends ValidLists<Def>> {
|
|
4
4
|
#private;
|
|
5
5
|
constructor({ parentID, allLists, when, cache, name, }: {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { keyFieldsForType } from "../lib";
|
|
2
|
-
import { _typeInfo } from "./cache";
|
|
3
1
|
import { Record } from "./record";
|
|
4
2
|
class ListCollection {
|
|
5
3
|
#parentID;
|
|
@@ -60,7 +58,7 @@ class ListCollection {
|
|
|
60
58
|
return new ListCollection({
|
|
61
59
|
parentID: this.#parentID,
|
|
62
60
|
allLists: this.#allLists,
|
|
63
|
-
when:
|
|
61
|
+
when: filter,
|
|
64
62
|
cache: this.#cache,
|
|
65
63
|
name: this.#name
|
|
66
64
|
});
|
|
@@ -96,36 +94,16 @@ class ListCollection {
|
|
|
96
94
|
}
|
|
97
95
|
}
|
|
98
96
|
#listOperationPayload(records) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
};
|
|
97
|
+
let selection = this.#collection.selection;
|
|
98
|
+
const connectionSelection = selection.fields?.["edges"]?.selection?.fields?.node.selection;
|
|
99
|
+
if (connectionSelection) {
|
|
100
|
+
selection = connectionSelection;
|
|
101
|
+
}
|
|
105
102
|
const data = [];
|
|
106
103
|
for (const record of records) {
|
|
107
104
|
if (!(record instanceof Record)) {
|
|
108
105
|
throw new Error("You must provide a Record to a list operation");
|
|
109
106
|
}
|
|
110
|
-
const keys = keyFieldsForType(this.#cache.config, record.type);
|
|
111
|
-
selection.abstractFields.fields[record.type] = keys.reduce(
|
|
112
|
-
(acc, key) => {
|
|
113
|
-
const keyInfo = _typeInfo(this.#cache, record.type, key);
|
|
114
|
-
return {
|
|
115
|
-
...acc,
|
|
116
|
-
[key]: {
|
|
117
|
-
type: keyInfo.type,
|
|
118
|
-
keyRaw: key
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
__typename: {
|
|
124
|
-
type: "String",
|
|
125
|
-
keyRaw: "__typename"
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
);
|
|
129
107
|
data.push({ __typename: record.type, ...record.idFields });
|
|
130
108
|
}
|
|
131
109
|
return {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import type { FragmentArtifact } from '../lib/types';
|
|
2
|
+
import type { Cache } from './cache';
|
|
3
|
+
import type { ArgType, CacheTypeDef, FragmentList, FragmentValue, FragmentVariables, TypeFieldNames, ValidTypes } from './types';
|
|
3
4
|
export declare class Record<Def extends CacheTypeDef, Type extends ValidTypes<Def>> {
|
|
4
5
|
#private;
|
|
5
6
|
type: string;
|
|
@@ -10,22 +11,30 @@ export declare class Record<Def extends CacheTypeDef, Type extends ValidTypes<De
|
|
|
10
11
|
idFields: {};
|
|
11
12
|
id: string;
|
|
12
13
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
read<_Fragment extends {
|
|
15
|
+
artifact: FragmentArtifact;
|
|
16
|
+
}>({ fragment, variables, }: {
|
|
17
|
+
fragment: _Fragment;
|
|
18
|
+
variables?: FragmentVariables<FragmentList<Def, Type>, _Fragment>;
|
|
19
|
+
}): {
|
|
20
|
+
data: FragmentValue<FragmentList<Def, Type>, _Fragment> | null;
|
|
21
|
+
partial: boolean;
|
|
22
|
+
};
|
|
23
|
+
write<_Fragment extends {
|
|
24
|
+
artifact: FragmentArtifact;
|
|
25
|
+
}, _Variable>(args: {
|
|
26
|
+
fragment: _Fragment;
|
|
27
|
+
data: FragmentValue<FragmentList<Def, Type>, _Fragment>;
|
|
28
|
+
variables?: FragmentVariables<FragmentList<Def, Type>, _Fragment>;
|
|
29
|
+
forceStale?: boolean;
|
|
17
30
|
}): void;
|
|
18
|
-
get<Field extends TypeFieldNames<Def, Type>>({ field, args, }: {
|
|
19
|
-
field: Field;
|
|
20
|
-
args?: ArgType<Def, Type, Field>;
|
|
21
|
-
}): FieldType<Def, Type, Field>;
|
|
22
31
|
delete(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Mark some elements of the record stale in the cache.
|
|
34
|
+
* @param field
|
|
35
|
+
* @param when
|
|
36
|
+
*/
|
|
37
|
+
markStale<Field extends TypeFieldNames<Def, Type>>(field?: Field, { when, }?: {
|
|
38
|
+
when?: ArgType<Def, Type, Field>;
|
|
39
|
+
}): void;
|
|
23
40
|
}
|
|
24
|
-
export declare function computeKey({ field, args }: {
|
|
25
|
-
field: string;
|
|
26
|
-
args?: {
|
|
27
|
-
[key: string]: any;
|
|
28
|
-
};
|
|
29
|
-
}): string;
|
|
30
|
-
export declare const stringifyObjectWithNoQuotesOnKeys: (obj_from_json: {}) => string;
|
|
31
|
-
export declare function marshalNestedList(list: any[]): any[];
|