houdini 1.2.44 → 1.2.45
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-cjs/index.js +651 -844
- package/build/cmd-esm/index.js +501 -694
- package/build/codegen/generators/comments/jsdoc.d.ts +2 -0
- package/build/codegen-cjs/index.js +649 -842
- package/build/codegen-esm/index.js +499 -692
- package/build/lib/graphql.d.ts +1 -1
- package/build/lib/index.d.ts +1 -0
- package/build/lib/typescript.d.ts +19 -0
- package/build/lib-cjs/index.js +667 -464
- package/build/lib-esm/index.js +661 -464
- package/build/runtime/client/index.d.ts +7 -1
- package/build/runtime/client/plugins/fragment.d.ts +2 -2
- package/build/runtime/client/plugins/mutation.d.ts +2 -1
- package/build/runtime/client/plugins/query.d.ts +2 -2
- package/build/runtime/lib/scalars.d.ts +1 -1
- package/build/runtime/lib/types.d.ts +13 -2
- package/build/runtime/router/types.d.ts +3 -1
- package/build/runtime-cjs/client/index.d.ts +7 -1
- package/build/runtime-cjs/client/index.js +26 -11
- package/build/runtime-cjs/client/plugins/fragment.d.ts +2 -2
- package/build/runtime-cjs/client/plugins/fragment.js +4 -11
- package/build/runtime-cjs/client/plugins/mutation.d.ts +2 -1
- package/build/runtime-cjs/client/plugins/mutation.js +8 -15
- package/build/runtime-cjs/client/plugins/query.d.ts +2 -2
- package/build/runtime-cjs/client/plugins/query.js +4 -11
- package/build/runtime-cjs/lib/scalars.d.ts +1 -1
- package/build/runtime-cjs/lib/scalars.js +4 -0
- package/build/runtime-cjs/lib/types.d.ts +13 -2
- package/build/runtime-cjs/router/types.d.ts +3 -1
- package/build/runtime-esm/client/index.d.ts +7 -1
- package/build/runtime-esm/client/index.js +26 -11
- package/build/runtime-esm/client/plugins/fragment.d.ts +2 -2
- package/build/runtime-esm/client/plugins/fragment.js +1 -2
- package/build/runtime-esm/client/plugins/mutation.d.ts +2 -1
- package/build/runtime-esm/client/plugins/mutation.js +1 -2
- package/build/runtime-esm/client/plugins/query.d.ts +2 -2
- package/build/runtime-esm/client/plugins/query.js +1 -2
- package/build/runtime-esm/lib/scalars.d.ts +1 -1
- package/build/runtime-esm/lib/scalars.js +6 -0
- package/build/runtime-esm/lib/types.d.ts +13 -2
- package/build/runtime-esm/router/types.d.ts +3 -1
- package/build/test-cjs/index.js +664 -840
- package/build/test-esm/index.js +514 -690
- package/build/vite-cjs/index.js +761 -852
- package/build/vite-esm/index.js +611 -702
- package/package.json +1 -1
- package/build/codegen/generators/typescript/typeReference.d.ts +0 -8
- package/build/codegen/generators/typescript/types.d.ts +0 -10
|
@@ -23,8 +23,12 @@ export type ObserveParams<_Data extends GraphQLObject, _Artifact extends Documen
|
|
|
23
23
|
};
|
|
24
24
|
export declare class HoudiniClient {
|
|
25
25
|
url: string;
|
|
26
|
-
readonly plugins: ClientPlugin[];
|
|
27
26
|
readonly throwOnError_operations: ThrowOnErrorOperations[];
|
|
27
|
+
private cache;
|
|
28
|
+
private throwOnError;
|
|
29
|
+
private fetchParams;
|
|
30
|
+
private pipeline;
|
|
31
|
+
private extraPlugins;
|
|
28
32
|
proxies: Record<string, (operation: {
|
|
29
33
|
query: string;
|
|
30
34
|
variables: any;
|
|
@@ -32,7 +36,9 @@ export declare class HoudiniClient {
|
|
|
32
36
|
session: App.Session | null | undefined;
|
|
33
37
|
}) => Promise<any>>;
|
|
34
38
|
componentCache: Record<string, any>;
|
|
39
|
+
setCache(cache: Cache): void;
|
|
35
40
|
constructor({ url, fetchParams, plugins, pipeline, throwOnError, }?: HoudiniClientConstructorArgs);
|
|
41
|
+
get plugins(): ClientPlugin[];
|
|
36
42
|
observe<_Data extends GraphQLObject, _Input extends GraphQLVariables>({ enableCache, fetching, ...rest }: ObserveParams<_Data, DocumentArtifact, _Input>): DocumentStore<_Data, _Input>;
|
|
37
43
|
registerProxy(url: string, handler: (operation: {
|
|
38
44
|
query: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const fragment: ClientPlugin;
|
|
1
|
+
import type { Cache } from '../../cache/cache';
|
|
2
|
+
export declare const fragment: (cache: Cache) => import("..").ClientPlugin;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Cache } from '../../cache/cache';
|
|
2
|
+
export declare const mutation: (cache: Cache) => import("..").ClientPlugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const query: ClientPlugin;
|
|
1
|
+
import type { Cache } from '../../cache/cache';
|
|
2
|
+
export declare const query: (cache: Cache) => import("..").ClientPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConfigFile } from './config';
|
|
2
|
-
import type
|
|
2
|
+
import { type FragmentArtifact, type MutationArtifact, type QueryArtifact, type SubscriptionArtifact, type SubscriptionSelection } from './types';
|
|
3
3
|
export declare function marshalSelection({ selection, data, }: {
|
|
4
4
|
selection: SubscriptionSelection;
|
|
5
5
|
data: any;
|
|
@@ -367,6 +367,14 @@ export type PageManifest = {
|
|
|
367
367
|
layouts: string[];
|
|
368
368
|
/** The filepath of the unit */
|
|
369
369
|
path: string;
|
|
370
|
+
/**
|
|
371
|
+
* The name and type of every route paramter that this page can use.
|
|
372
|
+
* null indicates the type is unknown (not constrained by a query)
|
|
373
|
+
**/
|
|
374
|
+
params: Record<string, {
|
|
375
|
+
type: string;
|
|
376
|
+
wrappers: string[];
|
|
377
|
+
} | null>;
|
|
370
378
|
};
|
|
371
379
|
export type QueryManifest = {
|
|
372
380
|
/** the name of the query */
|
|
@@ -377,6 +385,9 @@ export type QueryManifest = {
|
|
|
377
385
|
loading: boolean;
|
|
378
386
|
/** The filepath of the unit */
|
|
379
387
|
path: string;
|
|
380
|
-
/** The
|
|
381
|
-
variables: string
|
|
388
|
+
/** The name and GraphQL type for the variables that this query cares about */
|
|
389
|
+
variables: Record<string, {
|
|
390
|
+
wrappers: string[];
|
|
391
|
+
type: string;
|
|
392
|
+
}>;
|
|
382
393
|
};
|
|
@@ -16,7 +16,9 @@ export type RouterPageManifest<_ComponentType> = {
|
|
|
16
16
|
default: QueryArtifact;
|
|
17
17
|
}>;
|
|
18
18
|
loading: boolean;
|
|
19
|
-
variables: string
|
|
19
|
+
variables: Record<string, {
|
|
20
|
+
type: string;
|
|
21
|
+
}>;
|
|
20
22
|
}>;
|
|
21
23
|
component: () => Promise<{
|
|
22
24
|
default: (props: any) => _ComponentType;
|
|
@@ -23,8 +23,12 @@ export type ObserveParams<_Data extends GraphQLObject, _Artifact extends Documen
|
|
|
23
23
|
};
|
|
24
24
|
export declare class HoudiniClient {
|
|
25
25
|
url: string;
|
|
26
|
-
readonly plugins: ClientPlugin[];
|
|
27
26
|
readonly throwOnError_operations: ThrowOnErrorOperations[];
|
|
27
|
+
private cache;
|
|
28
|
+
private throwOnError;
|
|
29
|
+
private fetchParams;
|
|
30
|
+
private pipeline;
|
|
31
|
+
private extraPlugins;
|
|
28
32
|
proxies: Record<string, (operation: {
|
|
29
33
|
query: string;
|
|
30
34
|
variables: any;
|
|
@@ -32,7 +36,9 @@ export declare class HoudiniClient {
|
|
|
32
36
|
session: App.Session | null | undefined;
|
|
33
37
|
}) => Promise<any>>;
|
|
34
38
|
componentCache: Record<string, any>;
|
|
39
|
+
setCache(cache: Cache): void;
|
|
35
40
|
constructor({ url, fetchParams, plugins, pipeline, throwOnError, }?: HoudiniClientConstructorArgs);
|
|
41
|
+
get plugins(): ClientPlugin[];
|
|
36
42
|
observe<_Data extends GraphQLObject, _Input extends GraphQLVariables>({ enableCache, fetching, ...rest }: ObserveParams<_Data, DocumentArtifact, _Input>): DocumentStore<_Data, _Input>;
|
|
37
43
|
registerProxy(url: string, handler: (operation: {
|
|
38
44
|
query: string;
|
|
@@ -33,6 +33,7 @@ __export(client_exports, {
|
|
|
33
33
|
subscription: () => import_plugins2.subscription
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(client_exports);
|
|
36
|
+
var import_cache = __toESM(require("../cache"), 1);
|
|
36
37
|
var import_lib = require("../lib");
|
|
37
38
|
var import_flatten = require("../lib/flatten");
|
|
38
39
|
var import_documentStore = require("./documentStore");
|
|
@@ -42,10 +43,17 @@ var import_documentStore2 = require("./documentStore");
|
|
|
42
43
|
var import_plugins2 = require("./plugins");
|
|
43
44
|
class HoudiniClient {
|
|
44
45
|
url;
|
|
45
|
-
plugins;
|
|
46
46
|
throwOnError_operations;
|
|
47
|
+
cache = null;
|
|
48
|
+
throwOnError;
|
|
49
|
+
fetchParams;
|
|
50
|
+
pipeline;
|
|
51
|
+
extraPlugins;
|
|
47
52
|
proxies = {};
|
|
48
53
|
componentCache = {};
|
|
54
|
+
setCache(cache) {
|
|
55
|
+
this.cache = cache;
|
|
56
|
+
}
|
|
49
57
|
constructor({
|
|
50
58
|
url,
|
|
51
59
|
fetchParams,
|
|
@@ -59,23 +67,29 @@ class HoudiniClient {
|
|
|
59
67
|
);
|
|
60
68
|
}
|
|
61
69
|
this.throwOnError_operations = throwOnError?.operations ?? [];
|
|
62
|
-
|
|
70
|
+
let serverPort = globalThis.process?.env?.HOUDINI_PORT ?? "5173";
|
|
71
|
+
this.url = url ?? (globalThis.window ? "" : `https://localhost:${serverPort}`) + (0, import_lib.localApiEndpoint)((0, import_lib.getCurrentConfig)());
|
|
72
|
+
this.throwOnError = throwOnError;
|
|
73
|
+
this.fetchParams = fetchParams;
|
|
74
|
+
this.pipeline = pipeline;
|
|
75
|
+
this.extraPlugins = plugins;
|
|
76
|
+
}
|
|
77
|
+
get plugins() {
|
|
78
|
+
return (0, import_flatten.flatten)(
|
|
63
79
|
[].concat(
|
|
64
|
-
throwOnError ? [(0, import_plugins.throwOnError)(throwOnError)] : [],
|
|
65
|
-
(0, import_plugins.fetchParams)(fetchParams),
|
|
66
|
-
pipeline ?? [
|
|
67
|
-
import_plugins.query,
|
|
68
|
-
import_plugins.mutation,
|
|
69
|
-
import_plugins.fragment
|
|
80
|
+
this.throwOnError ? [(0, import_plugins.throwOnError)(this.throwOnError)] : [],
|
|
81
|
+
(0, import_plugins.fetchParams)(this.fetchParams),
|
|
82
|
+
this.pipeline ?? [
|
|
83
|
+
(0, import_plugins.query)(this.cache ?? import_cache.default),
|
|
84
|
+
(0, import_plugins.mutation)(this.cache ?? import_cache.default),
|
|
85
|
+
(0, import_plugins.fragment)(this.cache ?? import_cache.default)
|
|
70
86
|
].concat(
|
|
71
|
-
|
|
87
|
+
this.extraPlugins ?? [],
|
|
72
88
|
import_injectedPlugins.default,
|
|
73
89
|
(0, import_plugins.fetch)()
|
|
74
90
|
)
|
|
75
91
|
)
|
|
76
92
|
);
|
|
77
|
-
let serverPort = globalThis.process?.env?.HOUDINI_PORT ?? "5173";
|
|
78
|
-
this.url = url ?? (globalThis.window ? "" : `https://localhost:${serverPort}`) + (0, import_lib.localApiEndpoint)((0, import_lib.getCurrentConfig)());
|
|
79
93
|
}
|
|
80
94
|
observe({
|
|
81
95
|
enableCache = true,
|
|
@@ -87,6 +101,7 @@ class HoudiniClient {
|
|
|
87
101
|
plugins: createPluginHooks(this.plugins),
|
|
88
102
|
fetching,
|
|
89
103
|
enableCache,
|
|
104
|
+
cache: this.cache ?? void 0,
|
|
90
105
|
...rest
|
|
91
106
|
});
|
|
92
107
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const fragment: ClientPlugin;
|
|
1
|
+
import type { Cache } from '../../cache/cache';
|
|
2
|
+
export declare const fragment: (cache: Cache) => import("..").ClientPlugin;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,21 +15,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
19
|
var fragment_exports = {};
|
|
26
20
|
__export(fragment_exports, {
|
|
27
21
|
fragment: () => fragment
|
|
28
22
|
});
|
|
29
23
|
module.exports = __toCommonJS(fragment_exports);
|
|
30
|
-
var import_cache = __toESM(require("../../cache"), 1);
|
|
31
24
|
var import_deepEquals = require("../../lib/deepEquals");
|
|
32
25
|
var import_types = require("../../lib/types");
|
|
33
26
|
var import_utils = require("../utils");
|
|
34
|
-
const fragment = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Fragment, function() {
|
|
27
|
+
const fragment = (cache) => (0, import_utils.documentPlugin)(import_types.ArtifactKind.Fragment, function() {
|
|
35
28
|
let subscriptionSpec = null;
|
|
36
29
|
let lastReference = null;
|
|
37
30
|
return {
|
|
@@ -45,7 +38,7 @@ const fragment = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Frag
|
|
|
45
38
|
};
|
|
46
39
|
if (!ctx.cacheParams?.disableSubscriptions && (!(0, import_deepEquals.deepEquals)(lastReference, currentReference) || variablesChanged(ctx))) {
|
|
47
40
|
if (subscriptionSpec) {
|
|
48
|
-
|
|
41
|
+
cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
49
42
|
}
|
|
50
43
|
const variables = marshalVariables(ctx);
|
|
51
44
|
subscriptionSpec = {
|
|
@@ -65,14 +58,14 @@ const fragment = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Frag
|
|
|
65
58
|
});
|
|
66
59
|
}
|
|
67
60
|
};
|
|
68
|
-
|
|
61
|
+
cache.subscribe(subscriptionSpec, variables);
|
|
69
62
|
lastReference = currentReference;
|
|
70
63
|
}
|
|
71
64
|
next(ctx);
|
|
72
65
|
},
|
|
73
66
|
cleanup() {
|
|
74
67
|
if (subscriptionSpec) {
|
|
75
|
-
|
|
68
|
+
cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
76
69
|
}
|
|
77
70
|
}
|
|
78
71
|
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Cache } from '../../cache/cache';
|
|
2
|
+
export declare const mutation: (cache: Cache) => import("..").ClientPlugin;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,28 +15,23 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
19
|
var mutation_exports = {};
|
|
26
20
|
__export(mutation_exports, {
|
|
27
21
|
mutation: () => mutation
|
|
28
22
|
});
|
|
29
23
|
module.exports = __toCommonJS(mutation_exports);
|
|
30
|
-
var import_cache = __toESM(require("../../cache"), 1);
|
|
31
24
|
var import_scalars = require("../../lib/scalars");
|
|
32
25
|
var import_types = require("../../lib/types");
|
|
33
26
|
var import_utils = require("../utils");
|
|
34
|
-
const mutation = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Mutation, () => {
|
|
27
|
+
const mutation = (cache) => (0, import_utils.documentPlugin)(import_types.ArtifactKind.Mutation, () => {
|
|
35
28
|
return {
|
|
36
29
|
async start(ctx, { next, marshalVariables }) {
|
|
37
|
-
const layerOptimistic =
|
|
30
|
+
const layerOptimistic = cache._internal_unstable.storage.createLayer(true);
|
|
38
31
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
39
32
|
let toNotify = [];
|
|
40
33
|
if (optimisticResponse) {
|
|
41
|
-
toNotify =
|
|
34
|
+
toNotify = cache.write({
|
|
42
35
|
selection: ctx.artifact.selection,
|
|
43
36
|
data: await (0, import_scalars.marshalSelection)({
|
|
44
37
|
selection: ctx.artifact.selection,
|
|
@@ -58,7 +51,7 @@ const mutation = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Muta
|
|
|
58
51
|
},
|
|
59
52
|
afterNetwork(ctx, { resolve }) {
|
|
60
53
|
if (ctx.cacheParams?.layer) {
|
|
61
|
-
|
|
54
|
+
cache.clearLayer(ctx.cacheParams.layer.id);
|
|
62
55
|
}
|
|
63
56
|
resolve(ctx);
|
|
64
57
|
},
|
|
@@ -66,19 +59,19 @@ const mutation = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Muta
|
|
|
66
59
|
const hasErrors = value.errors && value.errors.length > 0;
|
|
67
60
|
if (hasErrors) {
|
|
68
61
|
if (ctx.cacheParams?.layer) {
|
|
69
|
-
|
|
62
|
+
cache.clearLayer(ctx.cacheParams.layer.id);
|
|
70
63
|
}
|
|
71
64
|
}
|
|
72
65
|
if (ctx.cacheParams?.layer) {
|
|
73
|
-
|
|
66
|
+
cache._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
74
67
|
}
|
|
75
68
|
resolve(ctx);
|
|
76
69
|
},
|
|
77
70
|
catch(ctx, { error }) {
|
|
78
71
|
if (ctx.cacheParams?.layer) {
|
|
79
72
|
const { layer } = ctx.cacheParams;
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
cache.clearLayer(layer.id);
|
|
74
|
+
cache._internal_unstable.storage.resolveLayer(layer.id);
|
|
82
75
|
}
|
|
83
76
|
throw error;
|
|
84
77
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const query: ClientPlugin;
|
|
1
|
+
import type { Cache } from '../../cache/cache';
|
|
2
|
+
export declare const query: (cache: Cache) => import("..").ClientPlugin;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,20 +15,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
19
|
var query_exports = {};
|
|
26
20
|
__export(query_exports, {
|
|
27
21
|
query: () => query
|
|
28
22
|
});
|
|
29
23
|
module.exports = __toCommonJS(query_exports);
|
|
30
|
-
var import_cache = __toESM(require("../../cache"), 1);
|
|
31
24
|
var import_types = require("../../lib/types");
|
|
32
25
|
var import_utils = require("../utils");
|
|
33
|
-
const query = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query, function() {
|
|
26
|
+
const query = (cache) => (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query, function() {
|
|
34
27
|
let subscriptionSpec = null;
|
|
35
28
|
let lastVariables = null;
|
|
36
29
|
return {
|
|
@@ -58,7 +51,7 @@ const query = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query,
|
|
|
58
51
|
end(ctx, { resolve, marshalVariables, variablesChanged }) {
|
|
59
52
|
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
60
53
|
if (subscriptionSpec) {
|
|
61
|
-
|
|
54
|
+
cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
62
55
|
}
|
|
63
56
|
lastVariables = { ...marshalVariables(ctx) };
|
|
64
57
|
const variables = lastVariables;
|
|
@@ -78,13 +71,13 @@ const query = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query,
|
|
|
78
71
|
});
|
|
79
72
|
}
|
|
80
73
|
};
|
|
81
|
-
|
|
74
|
+
cache.subscribe(subscriptionSpec, lastVariables);
|
|
82
75
|
}
|
|
83
76
|
resolve(ctx);
|
|
84
77
|
},
|
|
85
78
|
cleanup() {
|
|
86
79
|
if (subscriptionSpec) {
|
|
87
|
-
|
|
80
|
+
cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
88
81
|
lastVariables = null;
|
|
89
82
|
}
|
|
90
83
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConfigFile } from './config';
|
|
2
|
-
import type
|
|
2
|
+
import { type FragmentArtifact, type MutationArtifact, type QueryArtifact, type SubscriptionArtifact, type SubscriptionSelection } from './types';
|
|
3
3
|
export declare function marshalSelection({ selection, data, }: {
|
|
4
4
|
selection: SubscriptionSelection;
|
|
5
5
|
data: any;
|
|
@@ -26,6 +26,7 @@ __export(scalars_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(scalars_exports);
|
|
27
27
|
var import_config = require("./config");
|
|
28
28
|
var import_selection = require("./selection");
|
|
29
|
+
var import_types = require("./types");
|
|
29
30
|
async function marshalSelection({
|
|
30
31
|
selection,
|
|
31
32
|
data
|
|
@@ -41,6 +42,9 @@ async function marshalSelection({
|
|
|
41
42
|
return Object.fromEntries(
|
|
42
43
|
await Promise.all(
|
|
43
44
|
Object.entries(data).map(async ([fieldName, value]) => {
|
|
45
|
+
if (fieldName === import_types.fragmentKey) {
|
|
46
|
+
return [fieldName, value];
|
|
47
|
+
}
|
|
44
48
|
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
45
49
|
if (!type) {
|
|
46
50
|
return [fieldName, value];
|
|
@@ -367,6 +367,14 @@ export type PageManifest = {
|
|
|
367
367
|
layouts: string[];
|
|
368
368
|
/** The filepath of the unit */
|
|
369
369
|
path: string;
|
|
370
|
+
/**
|
|
371
|
+
* The name and type of every route paramter that this page can use.
|
|
372
|
+
* null indicates the type is unknown (not constrained by a query)
|
|
373
|
+
**/
|
|
374
|
+
params: Record<string, {
|
|
375
|
+
type: string;
|
|
376
|
+
wrappers: string[];
|
|
377
|
+
} | null>;
|
|
370
378
|
};
|
|
371
379
|
export type QueryManifest = {
|
|
372
380
|
/** the name of the query */
|
|
@@ -377,6 +385,9 @@ export type QueryManifest = {
|
|
|
377
385
|
loading: boolean;
|
|
378
386
|
/** The filepath of the unit */
|
|
379
387
|
path: string;
|
|
380
|
-
/** The
|
|
381
|
-
variables: string
|
|
388
|
+
/** The name and GraphQL type for the variables that this query cares about */
|
|
389
|
+
variables: Record<string, {
|
|
390
|
+
wrappers: string[];
|
|
391
|
+
type: string;
|
|
392
|
+
}>;
|
|
382
393
|
};
|
|
@@ -16,7 +16,9 @@ export type RouterPageManifest<_ComponentType> = {
|
|
|
16
16
|
default: QueryArtifact;
|
|
17
17
|
}>;
|
|
18
18
|
loading: boolean;
|
|
19
|
-
variables: string
|
|
19
|
+
variables: Record<string, {
|
|
20
|
+
type: string;
|
|
21
|
+
}>;
|
|
20
22
|
}>;
|
|
21
23
|
component: () => Promise<{
|
|
22
24
|
default: (props: any) => _ComponentType;
|
|
@@ -23,8 +23,12 @@ export type ObserveParams<_Data extends GraphQLObject, _Artifact extends Documen
|
|
|
23
23
|
};
|
|
24
24
|
export declare class HoudiniClient {
|
|
25
25
|
url: string;
|
|
26
|
-
readonly plugins: ClientPlugin[];
|
|
27
26
|
readonly throwOnError_operations: ThrowOnErrorOperations[];
|
|
27
|
+
private cache;
|
|
28
|
+
private throwOnError;
|
|
29
|
+
private fetchParams;
|
|
30
|
+
private pipeline;
|
|
31
|
+
private extraPlugins;
|
|
28
32
|
proxies: Record<string, (operation: {
|
|
29
33
|
query: string;
|
|
30
34
|
variables: any;
|
|
@@ -32,7 +36,9 @@ export declare class HoudiniClient {
|
|
|
32
36
|
session: App.Session | null | undefined;
|
|
33
37
|
}) => Promise<any>>;
|
|
34
38
|
componentCache: Record<string, any>;
|
|
39
|
+
setCache(cache: Cache): void;
|
|
35
40
|
constructor({ url, fetchParams, plugins, pipeline, throwOnError, }?: HoudiniClientConstructorArgs);
|
|
41
|
+
get plugins(): ClientPlugin[];
|
|
36
42
|
observe<_Data extends GraphQLObject, _Input extends GraphQLVariables>({ enableCache, fetching, ...rest }: ObserveParams<_Data, DocumentArtifact, _Input>): DocumentStore<_Data, _Input>;
|
|
37
43
|
registerProxy(url: string, handler: (operation: {
|
|
38
44
|
query: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import cacheRef from "../cache";
|
|
1
2
|
import { getCurrentConfig, localApiEndpoint } from "../lib";
|
|
2
3
|
import { flatten } from "../lib/flatten";
|
|
3
4
|
import { DocumentStore } from "./documentStore";
|
|
@@ -14,10 +15,17 @@ import { DocumentStore as DocumentStore2 } from "./documentStore";
|
|
|
14
15
|
import { fetch, mutation, query, subscription } from "./plugins";
|
|
15
16
|
class HoudiniClient {
|
|
16
17
|
url;
|
|
17
|
-
plugins;
|
|
18
18
|
throwOnError_operations;
|
|
19
|
+
cache = null;
|
|
20
|
+
throwOnError;
|
|
21
|
+
fetchParams;
|
|
22
|
+
pipeline;
|
|
23
|
+
extraPlugins;
|
|
19
24
|
proxies = {};
|
|
20
25
|
componentCache = {};
|
|
26
|
+
setCache(cache) {
|
|
27
|
+
this.cache = cache;
|
|
28
|
+
}
|
|
21
29
|
constructor({
|
|
22
30
|
url,
|
|
23
31
|
fetchParams,
|
|
@@ -31,23 +39,29 @@ class HoudiniClient {
|
|
|
31
39
|
);
|
|
32
40
|
}
|
|
33
41
|
this.throwOnError_operations = throwOnError?.operations ?? [];
|
|
34
|
-
|
|
42
|
+
let serverPort = globalThis.process?.env?.HOUDINI_PORT ?? "5173";
|
|
43
|
+
this.url = url ?? (globalThis.window ? "" : `https://localhost:${serverPort}`) + localApiEndpoint(getCurrentConfig());
|
|
44
|
+
this.throwOnError = throwOnError;
|
|
45
|
+
this.fetchParams = fetchParams;
|
|
46
|
+
this.pipeline = pipeline;
|
|
47
|
+
this.extraPlugins = plugins;
|
|
48
|
+
}
|
|
49
|
+
get plugins() {
|
|
50
|
+
return flatten(
|
|
35
51
|
[].concat(
|
|
36
|
-
throwOnError ? [throwOnErrorPlugin(throwOnError)] : [],
|
|
37
|
-
fetchParamsPlugin(fetchParams),
|
|
38
|
-
pipeline ?? [
|
|
39
|
-
queryPlugin,
|
|
40
|
-
mutationPlugin,
|
|
41
|
-
fragmentPlugin
|
|
52
|
+
this.throwOnError ? [throwOnErrorPlugin(this.throwOnError)] : [],
|
|
53
|
+
fetchParamsPlugin(this.fetchParams),
|
|
54
|
+
this.pipeline ?? [
|
|
55
|
+
queryPlugin(this.cache ?? cacheRef),
|
|
56
|
+
mutationPlugin(this.cache ?? cacheRef),
|
|
57
|
+
fragmentPlugin(this.cache ?? cacheRef)
|
|
42
58
|
].concat(
|
|
43
|
-
|
|
59
|
+
this.extraPlugins ?? [],
|
|
44
60
|
pluginsFromPlugins,
|
|
45
61
|
fetchPlugin()
|
|
46
62
|
)
|
|
47
63
|
)
|
|
48
64
|
);
|
|
49
|
-
let serverPort = globalThis.process?.env?.HOUDINI_PORT ?? "5173";
|
|
50
|
-
this.url = url ?? (globalThis.window ? "" : `https://localhost:${serverPort}`) + localApiEndpoint(getCurrentConfig());
|
|
51
65
|
}
|
|
52
66
|
observe({
|
|
53
67
|
enableCache = true,
|
|
@@ -59,6 +73,7 @@ class HoudiniClient {
|
|
|
59
73
|
plugins: createPluginHooks(this.plugins),
|
|
60
74
|
fetching,
|
|
61
75
|
enableCache,
|
|
76
|
+
cache: this.cache ?? void 0,
|
|
62
77
|
...rest
|
|
63
78
|
});
|
|
64
79
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const fragment: ClientPlugin;
|
|
1
|
+
import type { Cache } from '../../cache/cache';
|
|
2
|
+
export declare const fragment: (cache: Cache) => import("..").ClientPlugin;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import cache from "../../cache";
|
|
2
1
|
import { deepEquals } from "../../lib/deepEquals";
|
|
3
2
|
import { ArtifactKind, DataSource } from "../../lib/types";
|
|
4
3
|
import { documentPlugin } from "../utils";
|
|
5
|
-
const fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
4
|
+
const fragment = (cache) => documentPlugin(ArtifactKind.Fragment, function() {
|
|
6
5
|
let subscriptionSpec = null;
|
|
7
6
|
let lastReference = null;
|
|
8
7
|
return {
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Cache } from '../../cache/cache';
|
|
2
|
+
export declare const mutation: (cache: Cache) => import("..").ClientPlugin;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import cache from "../../cache";
|
|
2
1
|
import { marshalSelection } from "../../lib/scalars";
|
|
3
2
|
import { ArtifactKind } from "../../lib/types";
|
|
4
3
|
import { documentPlugin } from "../utils";
|
|
5
|
-
const mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
4
|
+
const mutation = (cache) => documentPlugin(ArtifactKind.Mutation, () => {
|
|
6
5
|
return {
|
|
7
6
|
async start(ctx, { next, marshalVariables }) {
|
|
8
7
|
const layerOptimistic = cache._internal_unstable.storage.createLayer(true);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const query: ClientPlugin;
|
|
1
|
+
import type { Cache } from '../../cache/cache';
|
|
2
|
+
export declare const query: (cache: Cache) => import("..").ClientPlugin;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import cache from "../../cache";
|
|
2
1
|
import { ArtifactKind, DataSource } from "../../lib/types";
|
|
3
2
|
import { documentPlugin } from "../utils";
|
|
4
|
-
const query = documentPlugin(ArtifactKind.Query, function() {
|
|
3
|
+
const query = (cache) => documentPlugin(ArtifactKind.Query, function() {
|
|
5
4
|
let subscriptionSpec = null;
|
|
6
5
|
let lastVariables = null;
|
|
7
6
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConfigFile } from './config';
|
|
2
|
-
import type
|
|
2
|
+
import { type FragmentArtifact, type MutationArtifact, type QueryArtifact, type SubscriptionArtifact, type SubscriptionSelection } from './types';
|
|
3
3
|
export declare function marshalSelection({ selection, data, }: {
|
|
4
4
|
selection: SubscriptionSelection;
|
|
5
5
|
data: any;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { getCurrentConfig } from "./config";
|
|
2
2
|
import { getFieldsForType } from "./selection";
|
|
3
|
+
import {
|
|
4
|
+
fragmentKey
|
|
5
|
+
} from "./types";
|
|
3
6
|
async function marshalSelection({
|
|
4
7
|
selection,
|
|
5
8
|
data
|
|
@@ -15,6 +18,9 @@ async function marshalSelection({
|
|
|
15
18
|
return Object.fromEntries(
|
|
16
19
|
await Promise.all(
|
|
17
20
|
Object.entries(data).map(async ([fieldName, value]) => {
|
|
21
|
+
if (fieldName === fragmentKey) {
|
|
22
|
+
return [fieldName, value];
|
|
23
|
+
}
|
|
18
24
|
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
19
25
|
if (!type) {
|
|
20
26
|
return [fieldName, value];
|