houdini 1.0.0-next.1 → 1.0.0-next.3
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 +1400 -2836
- package/build/cmd-esm/index.js +1400 -2836
- package/build/codegen/generators/artifacts/fieldKey.d.ts +1 -1
- package/build/codegen/generators/artifacts/index.d.ts +1 -1
- package/build/codegen/generators/artifacts/indexFile.d.ts +1 -1
- 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 +1 -1
- package/build/codegen/generators/artifacts/utils.d.ts +1 -1
- 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 +1 -1
- package/build/codegen/generators/persistedQueries/index.d.ts +1 -1
- package/build/codegen/generators/runtime/graphqlFunction.d.ts +2 -0
- package/build/codegen/generators/runtime/index.d.ts +1 -1
- 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/{imperativeCache.d.ts → imperativeTypeDef.d.ts} +1 -1
- package/build/codegen/generators/typescript/index.d.ts +1 -1
- package/build/codegen/generators/typescript/inlineType.d.ts +1 -1
- package/build/codegen/generators/typescript/typeReference.d.ts +1 -1
- package/build/codegen/generators/typescript/types.d.ts +1 -1
- package/build/codegen/index.d.ts +1 -1
- package/build/codegen/transforms/addID.d.ts +1 -1
- package/build/codegen/transforms/composeQueries.d.ts +2 -2
- package/build/codegen/transforms/fragmentVariables.d.ts +3 -2
- package/build/codegen/transforms/list.d.ts +1 -1
- package/build/codegen/transforms/paginate.d.ts +1 -1
- package/build/codegen/transforms/schema.d.ts +1 -1
- package/build/codegen/transforms/typename.d.ts +1 -1
- 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 +1 -1
- package/build/codegen/validators/typeCheck.d.ts +1 -1
- package/build/codegen-cjs/index.js +1320 -2779
- package/build/codegen-esm/index.js +1320 -2779
- package/build/lib/config.d.ts +9 -4
- package/build/lib/fs.d.ts +1 -1
- package/build/lib/graphql.d.ts +1 -1
- package/build/lib/imports.d.ts +1 -1
- package/build/lib/types.d.ts +3 -3
- package/build/lib/walk.d.ts +8 -5
- package/build/lib-cjs/index.js +155 -1856
- package/build/lib-esm/index.js +155 -1856
- package/build/runtime/cache/cache.d.ts +10 -8
- 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/stuff.d.ts +2 -2
- package/build/runtime/cache/subscription.d.ts +19 -11
- package/build/runtime/client/documentStore.d.ts +87 -0
- package/build/runtime/client/index.d.ts +25 -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 +3 -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 +18 -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 +26 -25
- package/build/runtime/lib/index.d.ts +1 -2
- 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 +22 -9
- package/build/runtime/public/cache.d.ts +20 -7
- package/build/runtime/public/list.d.ts +2 -2
- package/build/runtime/public/record.d.ts +18 -18
- package/build/runtime/public/tests/test.d.ts +44 -1
- package/build/runtime/public/types.d.ts +8 -0
- package/build/runtime-cjs/cache/cache.d.ts +10 -8
- package/build/runtime-cjs/cache/cache.js +5 -11
- package/build/runtime-cjs/cache/gc.d.ts +1 -1
- package/build/runtime-cjs/cache/lists.d.ts +3 -2
- package/build/runtime-cjs/cache/lists.js +5 -2
- package/build/runtime-cjs/cache/schema.d.ts +2 -2
- package/build/runtime-cjs/cache/stuff.d.ts +2 -2
- package/build/runtime-cjs/cache/subscription.d.ts +19 -11
- package/build/runtime-cjs/cache/subscription.js +95 -56
- package/build/runtime-cjs/client/documentStore.d.ts +87 -0
- package/build/runtime-cjs/client/documentStore.js +360 -0
- package/build/runtime-cjs/client/index.d.ts +25 -0
- package/build/runtime-cjs/client/index.js +87 -0
- package/build/runtime-cjs/client/plugins/cache.d.ts +8 -0
- package/build/runtime-cjs/client/plugins/cache.js +99 -0
- package/build/runtime-cjs/client/plugins/fetch.d.ts +37 -0
- package/build/runtime-cjs/{lib/networkUtils.js → client/plugins/fetch.js} +95 -3
- package/build/runtime-cjs/client/plugins/fetchParams.d.ts +9 -0
- package/build/runtime-cjs/client/plugins/fetchParams.js +40 -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 +3 -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 +18 -0
- package/build/runtime-cjs/client/plugins/subscription.js +98 -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 +26 -25
- package/build/runtime-cjs/lib/config.js +5 -4
- package/build/runtime-cjs/lib/index.d.ts +1 -2
- package/build/runtime-cjs/lib/index.js +1 -2
- 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 +22 -9
- package/build/runtime-cjs/public/cache.d.ts +20 -7
- package/build/runtime-cjs/public/cache.js +29 -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 +18 -18
- package/build/runtime-cjs/public/record.js +23 -189
- package/build/runtime-cjs/public/tests/test.d.ts +44 -1
- 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 +10 -8
- package/build/runtime-esm/cache/cache.js +5 -11
- package/build/runtime-esm/cache/gc.d.ts +1 -1
- package/build/runtime-esm/cache/lists.d.ts +3 -2
- package/build/runtime-esm/cache/lists.js +5 -2
- package/build/runtime-esm/cache/schema.d.ts +2 -2
- package/build/runtime-esm/cache/stuff.d.ts +2 -2
- package/build/runtime-esm/cache/subscription.d.ts +19 -11
- package/build/runtime-esm/cache/subscription.js +95 -56
- package/build/runtime-esm/client/documentStore.d.ts +87 -0
- package/build/runtime-esm/client/documentStore.js +336 -0
- package/build/runtime-esm/client/index.d.ts +25 -0
- package/build/runtime-esm/client/index.js +58 -0
- package/build/runtime-esm/client/plugins/cache.d.ts +8 -0
- package/build/runtime-esm/client/plugins/cache.js +69 -0
- package/build/runtime-esm/client/plugins/fetch.d.ts +37 -0
- package/build/runtime-esm/client/plugins/fetch.js +151 -0
- package/build/runtime-esm/client/plugins/fetchParams.d.ts +9 -0
- package/build/runtime-esm/client/plugins/fetchParams.js +16 -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 +3 -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 +18 -0
- package/build/runtime-esm/client/plugins/subscription.js +74 -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 +26 -25
- package/build/runtime-esm/lib/config.js +5 -4
- package/build/runtime-esm/lib/index.d.ts +1 -2
- package/build/runtime-esm/lib/index.js +1 -2
- 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 +22 -9
- package/build/runtime-esm/public/cache.d.ts +20 -7
- package/build/runtime-esm/public/cache.js +28 -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 +18 -18
- package/build/runtime-esm/public/record.js +22 -185
- package/build/runtime-esm/public/tests/test.d.ts +44 -1
- 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 +4 -3
- package/build/test-cjs/index.js +1334 -2766
- package/build/test-esm/index.js +1334 -2766
- 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 +1395 -2821
- package/build/vite-esm/index.js +1395 -2821
- package/package.json +1 -1
- 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,7 +1,8 @@
|
|
|
1
|
-
import { Cache as InternalCache } from './cache/cache';
|
|
1
|
+
import type { Cache as InternalCache } from './cache/cache';
|
|
2
2
|
import type { CacheTypeDef } from './generated';
|
|
3
3
|
import { Cache } from './public';
|
|
4
|
+
export * from './client';
|
|
4
5
|
export * from './lib';
|
|
5
|
-
export declare function graphql(str:
|
|
6
|
+
export declare function graphql<_Payload>(str: TemplateStringsArray): _Payload;
|
|
6
7
|
export declare const cache: Cache<CacheTypeDef>;
|
|
7
8
|
export declare function getCache(): InternalCache;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { GraphQLSchema } from 'graphql';
|
|
2
|
-
import { CachePolicy } from './types';
|
|
1
|
+
import type { GraphQLSchema } from 'graphql';
|
|
2
|
+
import type { CachePolicy } from './types';
|
|
3
3
|
export declare function getMockConfig(): ConfigFile | null;
|
|
4
4
|
export declare function setMockConfig(config: ConfigFile | null): void;
|
|
5
5
|
export declare function defaultConfigValues(file: ConfigFile): ConfigFile;
|
|
6
6
|
export declare function keyFieldsForType(configFile: ConfigFile, type: string): string[];
|
|
7
7
|
export declare function computeID(configFile: ConfigFile, type: string, data: any): string;
|
|
8
|
-
export declare function getCurrentConfig():
|
|
8
|
+
export declare function getCurrentConfig(): ConfigFile;
|
|
9
9
|
export type ConfigFile = {
|
|
10
10
|
/**
|
|
11
11
|
* A glob pointing to all files that houdini should consider. Note, this must include .js files
|
|
@@ -31,10 +31,6 @@ export type ConfigFile = {
|
|
|
31
31
|
* FYI: `schemaPath` or `schema` should be defined
|
|
32
32
|
*/
|
|
33
33
|
schema?: string | GraphQLSchema;
|
|
34
|
-
/**
|
|
35
|
-
* A url to use to pull the schema. For more information: https://www.houdinigraphql.com/api/cli#generate
|
|
36
|
-
*/
|
|
37
|
-
apiUrl?: string | ((env: Record<string, string | undefined>) => string);
|
|
38
34
|
/**
|
|
39
35
|
* An object describing custom scalars for your project. For more information: https://www.houdinigraphql.com/api/config#custom-scalars
|
|
40
36
|
*/
|
|
@@ -43,11 +39,6 @@ export type ConfigFile = {
|
|
|
43
39
|
* A path that the generator will use to write schema.graphql and documents.gql files containing all of the internal fragment and directive definitions used in the project.
|
|
44
40
|
*/
|
|
45
41
|
definitionsPath?: string;
|
|
46
|
-
/**
|
|
47
|
-
* One of "kit" or "svelte". Used to tell the preprocessor what kind of loading paradigm to generate for you. (default: `kit`)
|
|
48
|
-
* @deprecated please follow the steps here: http://www.houdinigraphql.com/guides/release-notes#0170
|
|
49
|
-
*/
|
|
50
|
-
framework?: 'kit' | 'svelte';
|
|
51
42
|
/**
|
|
52
43
|
* One of "esm" or "commonjs". Tells the artifact generator what kind of modules to create. (default: `esm`)
|
|
53
44
|
*/
|
|
@@ -90,20 +81,9 @@ export type ConfigFile = {
|
|
|
90
81
|
*/
|
|
91
82
|
defaultFragmentMasking?: 'enable' | 'disable';
|
|
92
83
|
/**
|
|
93
|
-
*
|
|
94
|
-
* during development in order to keep it's definition of your schema up to date. The schemaPollingInterval
|
|
95
|
-
* config value sets the amount of time between each request in milliseconds (default 2 seconds).
|
|
96
|
-
* To limit the schema introspection to just on the start of the server, set schemaPollingInterval to 0.
|
|
97
|
-
* To disable the schema introspection, set schemaPollingInterval to null.
|
|
98
|
-
*/
|
|
99
|
-
schemaPollInterval?: number | null;
|
|
100
|
-
/**
|
|
101
|
-
* An object containing the environment variables you want passed onto the api when polling for a new schema.
|
|
102
|
-
* The keys dictate the header names. If the value is a string, the corresponding environment variable will be used
|
|
103
|
-
* directly. If the value is a function, the current environment will be passed to your function so you can perform any
|
|
104
|
-
* logic you need
|
|
84
|
+
* Configure the dev environment to watch a remote schema for changes
|
|
105
85
|
*/
|
|
106
|
-
|
|
86
|
+
watchSchema?: WatchSchemaConfig;
|
|
107
87
|
/**
|
|
108
88
|
* An object describing the plugins enabled for the project
|
|
109
89
|
*/
|
|
@@ -133,6 +113,25 @@ export type TypeConfig = {
|
|
|
133
113
|
};
|
|
134
114
|
};
|
|
135
115
|
};
|
|
116
|
+
export type WatchSchemaConfig = {
|
|
117
|
+
/**
|
|
118
|
+
* A url to use to pull the schema. For more information: https://www.houdinigraphql.com/api/cli#generate
|
|
119
|
+
*/
|
|
120
|
+
url: string | ((env: Record<string, string | undefined>) => string);
|
|
121
|
+
/**
|
|
122
|
+
* sets the amount of time between each request in milliseconds (default 2 seconds).
|
|
123
|
+
* To limit the schema introspection to just on the start of the server, set interval to 0.
|
|
124
|
+
* To disable the schema introspection, set interval to null.
|
|
125
|
+
*/
|
|
126
|
+
interval?: number | null;
|
|
127
|
+
/**
|
|
128
|
+
* An object containing the environment variables you want passed onto the api when polling for a new schema.
|
|
129
|
+
* The keys dictate the header names. If the value is a string, the corresponding environment variable will be used
|
|
130
|
+
* directly. If the value is a function, the current environment will be passed to your function so you can perform any
|
|
131
|
+
* logic you need
|
|
132
|
+
*/
|
|
133
|
+
headers?: Record<string, string | ((env: Record<string, string | undefined>) => string)> | ((env: Record<string, string | undefined>) => Record<string, string>);
|
|
134
|
+
};
|
|
136
135
|
export type ScalarSpec = {
|
|
137
136
|
type: string;
|
|
138
137
|
marshal?: (val: any) => any;
|
|
@@ -140,4 +139,6 @@ export type ScalarSpec = {
|
|
|
140
139
|
};
|
|
141
140
|
export interface HoudiniPluginConfig {
|
|
142
141
|
}
|
|
142
|
+
export interface HoudiniClientPluginConfig {
|
|
143
|
+
}
|
|
143
144
|
export {};
|
|
@@ -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,
|
|
@@ -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
|
};
|
|
@@ -65,6 +81,7 @@ export type BaseCompiledDocument = {
|
|
|
65
81
|
paginated: boolean;
|
|
66
82
|
direction?: 'forward' | 'backwards';
|
|
67
83
|
};
|
|
84
|
+
pluginsData?: Record<string, any>;
|
|
68
85
|
};
|
|
69
86
|
export type HoudiniFetchContext = {
|
|
70
87
|
variables: () => {};
|
|
@@ -150,7 +167,7 @@ export type FetchQueryResult<_Data> = {
|
|
|
150
167
|
source: DataSource | null;
|
|
151
168
|
partial: boolean;
|
|
152
169
|
};
|
|
153
|
-
export type QueryResult<_Data, _Input
|
|
170
|
+
export type QueryResult<_Data = GraphQLObject, _Input = Record<string, any>> = {
|
|
154
171
|
data: _Data | null;
|
|
155
172
|
errors: {
|
|
156
173
|
message: string;
|
|
@@ -158,16 +175,12 @@ export type QueryResult<_Data, _Input, _Extra = {}> = {
|
|
|
158
175
|
fetching: boolean;
|
|
159
176
|
partial: boolean;
|
|
160
177
|
source: DataSource | null;
|
|
161
|
-
variables: _Input;
|
|
162
|
-
}
|
|
163
|
-
export type RequestPayload<
|
|
164
|
-
data:
|
|
178
|
+
variables: _Input | null;
|
|
179
|
+
};
|
|
180
|
+
export type RequestPayload<GraphQLObject = any> = {
|
|
181
|
+
data: GraphQLObject | null;
|
|
165
182
|
errors: {
|
|
166
183
|
message: string;
|
|
167
184
|
}[] | null;
|
|
168
185
|
};
|
|
169
|
-
export type RequestPayloadMagic<_Data = any> = {
|
|
170
|
-
ssr: boolean;
|
|
171
|
-
body: RequestPayload<_Data>;
|
|
172
|
-
};
|
|
173
186
|
export {};
|
|
@@ -1,19 +1,32 @@
|
|
|
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 { CacheTypeDef, IDFields, QueryInput, QueryList, QueryValue, 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;
|
|
18
32
|
}
|
|
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,34 @@ 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
|
+
});
|
|
60
49
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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;
|
|
66
66
|
}
|
|
67
|
-
return info;
|
|
68
67
|
}
|
|
69
68
|
export {
|
|
70
|
-
Cache
|
|
71
|
-
_typeInfo
|
|
69
|
+
Cache
|
|
72
70
|
};
|
|
@@ -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 { CacheTypeDef, FragmentList, FragmentValue, FragmentVariables, 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,21 @@ 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>;
|
|
17
29
|
}): 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
30
|
delete(): void;
|
|
23
31
|
}
|
|
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[];
|