houdini 1.0.0-next.1 → 1.0.0-next.2
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 +398 -2024
- package/build/cmd-esm/index.js +398 -2024
- 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/imperativeCache.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 +2 -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 +330 -1977
- package/build/codegen-esm/index.js +330 -1977
- package/build/lib/config.d.ts +8 -3
- 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 +4 -4
- package/build/lib-cjs/index.js +145 -1846
- package/build/lib-esm/index.js +145 -1846
- 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 +2 -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/imports/config.d.ts +3 -0
- package/build/runtime/index.d.ts +2 -1
- package/build/runtime/lib/config.d.ts +5 -3
- package/build/runtime/lib/index.d.ts +1 -2
- package/build/runtime/lib/scalars.d.ts +5 -4
- 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 +2 -2
- package/build/runtime/public/list.d.ts +2 -2
- package/build/runtime/public/record.d.ts +1 -1
- package/build/runtime/public/tests/test.d.ts +1 -1
- 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 +2 -2
- package/build/runtime-cjs/cache/lists.js +2 -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/imports/config.d.ts +3 -0
- package/build/runtime-cjs/imports/config.js +26 -0
- package/build/runtime-cjs/index.d.ts +2 -1
- package/build/runtime-cjs/index.js +1 -0
- package/build/runtime-cjs/lib/config.d.ts +5 -3
- 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 +5 -4
- 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 +2 -2
- package/build/runtime-cjs/public/list.d.ts +2 -2
- package/build/runtime-cjs/public/list.js +2 -2
- package/build/runtime-cjs/public/record.d.ts +1 -1
- package/build/runtime-cjs/public/record.js +4 -4
- package/build/runtime-cjs/public/tests/test.d.ts +1 -1
- 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 +2 -2
- package/build/runtime-esm/cache/lists.js +2 -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/imports/config.d.ts +3 -0
- package/build/runtime-esm/imports/config.js +4 -0
- package/build/runtime-esm/index.d.ts +2 -1
- package/build/runtime-esm/index.js +1 -0
- package/build/runtime-esm/lib/config.d.ts +5 -3
- 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 +5 -4
- 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 +2 -2
- package/build/runtime-esm/public/list.d.ts +2 -2
- package/build/runtime-esm/public/list.js +1 -1
- package/build/runtime-esm/public/record.d.ts +1 -1
- package/build/runtime-esm/public/record.js +1 -1
- package/build/runtime-esm/public/tests/test.d.ts +1 -1
- package/build/test/index.d.ts +4 -3
- package/build/test-cjs/index.js +336 -1955
- package/build/test-esm/index.js +336 -1955
- 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 +396 -2010
- package/build/vite-esm/index.js +396 -2010
- 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
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const documentPlugin = (kind, source) => {
|
|
2
|
+
return () => {
|
|
3
|
+
const sourceHandlers = source();
|
|
4
|
+
const enterWrapper = (handler) => {
|
|
5
|
+
return !handler ? void 0 : (ctx, handlers) => {
|
|
6
|
+
if (ctx.artifact.kind !== kind) {
|
|
7
|
+
return handlers.next(ctx);
|
|
8
|
+
}
|
|
9
|
+
return handler(ctx, handlers);
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
const exitWrapper = (handler) => {
|
|
13
|
+
return !handler ? void 0 : (ctx, handlers) => {
|
|
14
|
+
if (ctx.artifact.kind !== kind) {
|
|
15
|
+
return handlers.resolve(ctx);
|
|
16
|
+
}
|
|
17
|
+
return handler(ctx, handlers);
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
start: enterWrapper(sourceHandlers.start),
|
|
22
|
+
network: enterWrapper(sourceHandlers.network),
|
|
23
|
+
afterNetwork: exitWrapper(sourceHandlers.afterNetwork),
|
|
24
|
+
end: exitWrapper(sourceHandlers.end),
|
|
25
|
+
catch: sourceHandlers.catch ? (ctx, handlers) => sourceHandlers.catch(ctx, handlers) : void 0,
|
|
26
|
+
cleanup: (...args) => sourceHandlers.cleanup?.(...args)
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
documentPlugin
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './documentPlugins';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./documentPlugins";
|
|
@@ -1,6 +1,7 @@
|
|
|
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
6
|
export declare function graphql(str: string | TemplateStringsArray): any;
|
|
6
7
|
export declare const cache: Cache<CacheTypeDef>;
|
|
@@ -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
|
|
@@ -140,4 +140,6 @@ export type ScalarSpec = {
|
|
|
140
140
|
};
|
|
141
141
|
export interface HoudiniPluginConfig {
|
|
142
142
|
}
|
|
143
|
+
export interface HoudiniClientPluginConfig {
|
|
144
|
+
}
|
|
143
145
|
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 { 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, }: {
|
|
7
|
+
export declare function marshalInputs<T>({ artifact, input, config, rootType, }: {
|
|
8
8
|
artifact: QueryArtifact | MutationArtifact | SubscriptionArtifact;
|
|
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,5 +1,5 @@
|
|
|
1
|
-
import { Cache as _Cache } from '../cache/cache';
|
|
2
|
-
import { SchemaManager, TypeInfo } from '../cache/schema';
|
|
1
|
+
import type { Cache as _Cache } from '../cache/cache';
|
|
2
|
+
import type { SchemaManager, TypeInfo } from '../cache/schema';
|
|
3
3
|
import { ListCollection } from './list';
|
|
4
4
|
import { Record } from './record';
|
|
5
5
|
import type { CacheTypeDef, IDFields, TypeNames, ValidLists } from './types';
|
|
@@ -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, }: {
|
package/build/test/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import type { CollectedGraphQLDocument } from '../lib';
|
|
2
|
+
import { Config } from '../lib';
|
|
3
|
+
import type { ConfigFile } from '../runtime/lib/config';
|
|
4
|
+
export declare function testConfigFile({ plugins, ...config }?: Partial<ConfigFile>): ConfigFile;
|
|
4
5
|
export declare function testConfig(config?: Partial<ConfigFile>): Config;
|
|
5
6
|
export type Partial<T> = {
|
|
6
7
|
[P in keyof T]?: T[P];
|