houdini-svelte 1.0.1 → 1.0.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/plugin-cjs/index.js +49 -16
- package/build/plugin-esm/index.js +49 -16
- package/build/preprocess-cjs/index.js +4 -4
- package/build/preprocess-esm/index.js +4 -4
- package/build/runtime/stores/base.d.ts +7 -3
- package/build/runtime/stores/fragment.d.ts +2 -5
- package/build/runtime/stores/mutation.d.ts +0 -2
- package/build/runtime/stores/pagination/cursor.d.ts +2 -20
- package/build/runtime/stores/pagination/fragment.d.ts +2 -14
- package/build/runtime/stores/pagination/offset.d.ts +0 -9
- package/build/runtime/stores/pagination/query.d.ts +2 -3
- package/build/runtime/stores/query.d.ts +0 -5
- package/build/runtime/stores/subscription.d.ts +0 -2
- package/build/runtime/types.d.ts +51 -1
- package/build/runtime-cjs/stores/base.d.ts +7 -3
- package/build/runtime-cjs/stores/base.js +56 -5
- package/build/runtime-cjs/stores/fragment.d.ts +2 -5
- package/build/runtime-cjs/stores/mutation.d.ts +0 -2
- package/build/runtime-cjs/stores/mutation.js +0 -3
- package/build/runtime-cjs/stores/pagination/cursor.d.ts +2 -20
- package/build/runtime-cjs/stores/pagination/cursor.js +1 -1
- package/build/runtime-cjs/stores/pagination/fragment.d.ts +2 -14
- package/build/runtime-cjs/stores/pagination/offset.d.ts +0 -9
- package/build/runtime-cjs/stores/pagination/query.d.ts +2 -3
- package/build/runtime-cjs/stores/query.d.ts +0 -5
- package/build/runtime-cjs/stores/query.js +3 -48
- package/build/runtime-cjs/stores/subscription.d.ts +0 -2
- package/build/runtime-cjs/stores/subscription.js +0 -3
- package/build/runtime-cjs/types.d.ts +51 -1
- package/build/runtime-esm/stores/base.d.ts +7 -3
- package/build/runtime-esm/stores/base.js +55 -4
- package/build/runtime-esm/stores/fragment.d.ts +2 -5
- package/build/runtime-esm/stores/mutation.d.ts +0 -2
- package/build/runtime-esm/stores/mutation.js +0 -3
- package/build/runtime-esm/stores/pagination/cursor.d.ts +2 -20
- package/build/runtime-esm/stores/pagination/cursor.js +1 -1
- package/build/runtime-esm/stores/pagination/fragment.d.ts +2 -14
- package/build/runtime-esm/stores/pagination/offset.d.ts +0 -9
- package/build/runtime-esm/stores/pagination/query.d.ts +2 -3
- package/build/runtime-esm/stores/query.d.ts +0 -5
- package/build/runtime-esm/stores/query.js +2 -47
- package/build/runtime-esm/stores/subscription.d.ts +0 -2
- package/build/runtime-esm/stores/subscription.js +0 -3
- package/build/runtime-esm/types.d.ts +51 -1
- package/build/test-cjs/index.js +53 -19
- package/build/test-esm/index.js +53 -19
- package/package.json +2 -2
|
@@ -84643,11 +84643,11 @@ var require_esprima2 = __commonJS2({
|
|
|
84643
84643
|
case "}":
|
|
84644
84644
|
regex2 = false;
|
|
84645
84645
|
if (this.values[this.curly - 3] === "function") {
|
|
84646
|
-
var
|
|
84647
|
-
regex2 =
|
|
84646
|
+
var check2 = this.values[this.curly - 4];
|
|
84647
|
+
regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
|
|
84648
84648
|
} else if (this.values[this.curly - 4] === "function") {
|
|
84649
|
-
var
|
|
84650
|
-
regex2 =
|
|
84649
|
+
var check2 = this.values[this.curly - 5];
|
|
84650
|
+
regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
|
|
84651
84651
|
}
|
|
84652
84652
|
break;
|
|
84653
84653
|
default:
|
|
@@ -186275,21 +186275,56 @@ async function fragmentTypedefs(input) {
|
|
|
186275
186275
|
document_input.typeAnnotation = AST15.tsTypeAnnotation(
|
|
186276
186276
|
AST15.tsTypeReference(AST15.identifier(store))
|
|
186277
186277
|
);
|
|
186278
|
-
|
|
186279
|
-
|
|
186280
|
-
|
|
186281
|
-
|
|
186282
|
-
|
|
186283
|
-
|
|
186284
|
-
|
|
186285
|
-
|
|
186286
|
-
|
|
186278
|
+
let store_type = "FragmentStoreInstance";
|
|
186279
|
+
if (doc.refetch?.paginated) {
|
|
186280
|
+
if (doc.refetch.method === "cursor") {
|
|
186281
|
+
store_type = "CursorFragmentStoreInstance";
|
|
186282
|
+
} else {
|
|
186283
|
+
store_type = "OffsetFragmentStoreInstance";
|
|
186284
|
+
}
|
|
186285
|
+
}
|
|
186286
|
+
ensureImports({
|
|
186287
|
+
config: input.config,
|
|
186288
|
+
body: contents.script.body,
|
|
186289
|
+
sourceModule: "./types",
|
|
186290
|
+
import: [store_type],
|
|
186291
|
+
importKind: "type"
|
|
186292
|
+
});
|
|
186287
186293
|
ensureImports({
|
|
186288
186294
|
config: input.config,
|
|
186289
186295
|
body: contents.script.body,
|
|
186290
186296
|
sourceModule: import_path,
|
|
186291
186297
|
import: [store]
|
|
186292
186298
|
});
|
|
186299
|
+
const shapeID = `${doc.name}$data`;
|
|
186300
|
+
const inputID = `${doc.name}$input`;
|
|
186301
|
+
ensureImports({
|
|
186302
|
+
config: input.config,
|
|
186303
|
+
body: contents.script.body,
|
|
186304
|
+
sourceModule: "../../../artifacts/" + doc.name,
|
|
186305
|
+
import: [inputID, shapeID]
|
|
186306
|
+
});
|
|
186307
|
+
const typeParams = [];
|
|
186308
|
+
if (doc.refetch?.paginated) {
|
|
186309
|
+
typeParams.push(AST15.tsTypeReference(AST15.identifier(inputID)));
|
|
186310
|
+
}
|
|
186311
|
+
const return_value = AST15.tsTypeReference(
|
|
186312
|
+
AST15.identifier(store_type),
|
|
186313
|
+
AST15.tsTypeParameterInstantiation([
|
|
186314
|
+
AST15.tsTypeReference(AST15.identifier(shapeID)),
|
|
186315
|
+
...typeParams
|
|
186316
|
+
])
|
|
186317
|
+
);
|
|
186318
|
+
const null_return_value = AST15.tsTypeReference(
|
|
186319
|
+
AST15.identifier(store_type),
|
|
186320
|
+
AST15.tsTypeParameterInstantiation([
|
|
186321
|
+
AST15.tsUnionType([
|
|
186322
|
+
AST15.tsTypeReference(AST15.identifier(shapeID)),
|
|
186323
|
+
AST15.tsNullKeyword()
|
|
186324
|
+
]),
|
|
186325
|
+
...typeParams
|
|
186326
|
+
])
|
|
186327
|
+
);
|
|
186293
186328
|
return [
|
|
186294
186329
|
AST15.exportNamedDeclaration(
|
|
186295
186330
|
AST15.tsDeclareFunction(
|
|
@@ -186302,9 +186337,7 @@ async function fragmentTypedefs(input) {
|
|
|
186302
186337
|
AST15.tsDeclareFunction(
|
|
186303
186338
|
AST15.identifier(which),
|
|
186304
186339
|
[initial_value_or_null_input, document_input],
|
|
186305
|
-
AST15.tsTypeAnnotation(
|
|
186306
|
-
AST15.tsUnionType([return_value, AST15.tsNullKeyword()])
|
|
186307
|
-
)
|
|
186340
|
+
AST15.tsTypeAnnotation(null_return_value)
|
|
186308
186341
|
)
|
|
186309
186342
|
)
|
|
186310
186343
|
];
|
|
@@ -84638,11 +84638,11 @@ var require_esprima2 = __commonJS2({
|
|
|
84638
84638
|
case "}":
|
|
84639
84639
|
regex2 = false;
|
|
84640
84640
|
if (this.values[this.curly - 3] === "function") {
|
|
84641
|
-
var
|
|
84642
|
-
regex2 =
|
|
84641
|
+
var check2 = this.values[this.curly - 4];
|
|
84642
|
+
regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
|
|
84643
84643
|
} else if (this.values[this.curly - 4] === "function") {
|
|
84644
|
-
var
|
|
84645
|
-
regex2 =
|
|
84644
|
+
var check2 = this.values[this.curly - 5];
|
|
84645
|
+
regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
|
|
84646
84646
|
}
|
|
84647
84647
|
break;
|
|
84648
84648
|
default:
|
|
@@ -186269,21 +186269,56 @@ async function fragmentTypedefs(input) {
|
|
|
186269
186269
|
document_input.typeAnnotation = AST15.tsTypeAnnotation(
|
|
186270
186270
|
AST15.tsTypeReference(AST15.identifier(store))
|
|
186271
186271
|
);
|
|
186272
|
-
|
|
186273
|
-
|
|
186274
|
-
|
|
186275
|
-
|
|
186276
|
-
|
|
186277
|
-
|
|
186278
|
-
|
|
186279
|
-
|
|
186280
|
-
|
|
186272
|
+
let store_type = "FragmentStoreInstance";
|
|
186273
|
+
if (doc.refetch?.paginated) {
|
|
186274
|
+
if (doc.refetch.method === "cursor") {
|
|
186275
|
+
store_type = "CursorFragmentStoreInstance";
|
|
186276
|
+
} else {
|
|
186277
|
+
store_type = "OffsetFragmentStoreInstance";
|
|
186278
|
+
}
|
|
186279
|
+
}
|
|
186280
|
+
ensureImports({
|
|
186281
|
+
config: input.config,
|
|
186282
|
+
body: contents.script.body,
|
|
186283
|
+
sourceModule: "./types",
|
|
186284
|
+
import: [store_type],
|
|
186285
|
+
importKind: "type"
|
|
186286
|
+
});
|
|
186281
186287
|
ensureImports({
|
|
186282
186288
|
config: input.config,
|
|
186283
186289
|
body: contents.script.body,
|
|
186284
186290
|
sourceModule: import_path,
|
|
186285
186291
|
import: [store]
|
|
186286
186292
|
});
|
|
186293
|
+
const shapeID = `${doc.name}$data`;
|
|
186294
|
+
const inputID = `${doc.name}$input`;
|
|
186295
|
+
ensureImports({
|
|
186296
|
+
config: input.config,
|
|
186297
|
+
body: contents.script.body,
|
|
186298
|
+
sourceModule: "../../../artifacts/" + doc.name,
|
|
186299
|
+
import: [inputID, shapeID]
|
|
186300
|
+
});
|
|
186301
|
+
const typeParams = [];
|
|
186302
|
+
if (doc.refetch?.paginated) {
|
|
186303
|
+
typeParams.push(AST15.tsTypeReference(AST15.identifier(inputID)));
|
|
186304
|
+
}
|
|
186305
|
+
const return_value = AST15.tsTypeReference(
|
|
186306
|
+
AST15.identifier(store_type),
|
|
186307
|
+
AST15.tsTypeParameterInstantiation([
|
|
186308
|
+
AST15.tsTypeReference(AST15.identifier(shapeID)),
|
|
186309
|
+
...typeParams
|
|
186310
|
+
])
|
|
186311
|
+
);
|
|
186312
|
+
const null_return_value = AST15.tsTypeReference(
|
|
186313
|
+
AST15.identifier(store_type),
|
|
186314
|
+
AST15.tsTypeParameterInstantiation([
|
|
186315
|
+
AST15.tsUnionType([
|
|
186316
|
+
AST15.tsTypeReference(AST15.identifier(shapeID)),
|
|
186317
|
+
AST15.tsNullKeyword()
|
|
186318
|
+
]),
|
|
186319
|
+
...typeParams
|
|
186320
|
+
])
|
|
186321
|
+
);
|
|
186287
186322
|
return [
|
|
186288
186323
|
AST15.exportNamedDeclaration(
|
|
186289
186324
|
AST15.tsDeclareFunction(
|
|
@@ -186296,9 +186331,7 @@ async function fragmentTypedefs(input) {
|
|
|
186296
186331
|
AST15.tsDeclareFunction(
|
|
186297
186332
|
AST15.identifier(which),
|
|
186298
186333
|
[initial_value_or_null_input, document_input],
|
|
186299
|
-
AST15.tsTypeAnnotation(
|
|
186300
|
-
AST15.tsUnionType([return_value, AST15.tsNullKeyword()])
|
|
186301
|
-
)
|
|
186334
|
+
AST15.tsTypeAnnotation(null_return_value)
|
|
186302
186335
|
)
|
|
186303
186336
|
)
|
|
186304
186337
|
];
|
|
@@ -84544,11 +84544,11 @@ var require_esprima2 = __commonJS2({
|
|
|
84544
84544
|
case "}":
|
|
84545
84545
|
regex2 = false;
|
|
84546
84546
|
if (this.values[this.curly - 3] === "function") {
|
|
84547
|
-
var
|
|
84548
|
-
regex2 =
|
|
84547
|
+
var check2 = this.values[this.curly - 4];
|
|
84548
|
+
regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
|
|
84549
84549
|
} else if (this.values[this.curly - 4] === "function") {
|
|
84550
|
-
var
|
|
84551
|
-
regex2 =
|
|
84550
|
+
var check2 = this.values[this.curly - 5];
|
|
84551
|
+
regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
|
|
84552
84552
|
}
|
|
84553
84553
|
break;
|
|
84554
84554
|
default:
|
|
@@ -84537,11 +84537,11 @@ var require_esprima2 = __commonJS2({
|
|
|
84537
84537
|
case "}":
|
|
84538
84538
|
regex2 = false;
|
|
84539
84539
|
if (this.values[this.curly - 3] === "function") {
|
|
84540
|
-
var
|
|
84541
|
-
regex2 =
|
|
84540
|
+
var check2 = this.values[this.curly - 4];
|
|
84541
|
+
regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
|
|
84542
84542
|
} else if (this.values[this.curly - 4] === "function") {
|
|
84543
|
-
var
|
|
84544
|
-
regex2 =
|
|
84543
|
+
var check2 = this.values[this.curly - 5];
|
|
84544
|
+
regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
|
|
84545
84545
|
}
|
|
84546
84546
|
break;
|
|
84547
84547
|
default:
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { GraphQLObject, DocumentArtifact } from '$houdini/runtime/lib/types';
|
|
1
|
+
import { DocumentStore, type ObserveParams } from '$houdini/runtime/client';
|
|
2
|
+
import type { GraphQLObject, DocumentArtifact, QueryResult } from '$houdini/runtime/lib/types';
|
|
3
|
+
import type { Readable } from 'svelte/store';
|
|
3
4
|
export declare class BaseStore<_Data extends GraphQLObject, _Input extends {}, _Artifact extends DocumentArtifact = DocumentArtifact> {
|
|
4
5
|
#private;
|
|
5
|
-
constructor(params: ObserveParams<_Data, _Artifact>);
|
|
6
6
|
get artifact(): _Artifact;
|
|
7
|
+
get name(): string;
|
|
8
|
+
constructor(params: ObserveParams<_Data, _Artifact>);
|
|
7
9
|
protected get observer(): DocumentStore<_Data, _Input>;
|
|
10
|
+
subscribe(...args: Parameters<Readable<QueryResult<_Data, _Input>>['subscribe']>): () => void;
|
|
11
|
+
setup(init?: boolean): void;
|
|
8
12
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GraphQLObject, FragmentArtifact, HoudiniFetchContext } from '$houdini/runtime/lib/types';
|
|
2
|
+
import type { FragmentStoreInstance } from '../types';
|
|
2
3
|
export declare class FragmentStore<_Data extends GraphQLObject, _Input = {}> {
|
|
3
4
|
artifact: FragmentArtifact;
|
|
4
5
|
name: string;
|
|
@@ -8,9 +9,5 @@ export declare class FragmentStore<_Data extends GraphQLObject, _Input = {}> {
|
|
|
8
9
|
artifact: FragmentArtifact;
|
|
9
10
|
storeName: string;
|
|
10
11
|
});
|
|
11
|
-
get(initialValue: _Data | null):
|
|
12
|
-
kind: "HoudiniFragment";
|
|
13
|
-
subscribe: (run: import("svelte/store").Subscriber<_Data | null>, invalidate?: ((value?: _Data | null | undefined) => void) | undefined) => import("svelte/store").Unsubscriber;
|
|
14
|
-
update: (val: _Data | null) => void;
|
|
15
|
-
};
|
|
12
|
+
get(initialValue: _Data | null): FragmentStoreInstance<_Data | null>;
|
|
16
13
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { DocumentStore } from '$houdini/runtime/client';
|
|
2
1
|
import type { MutationArtifact, GraphQLObject, QueryResult } from '$houdini/runtime/lib/types';
|
|
3
2
|
import type { RequestEvent } from '@sveltejs/kit';
|
|
4
3
|
import { BaseStore } from './base';
|
|
@@ -9,7 +8,6 @@ export declare class MutationStore<_Data extends GraphQLObject, _Input extends {
|
|
|
9
8
|
fetch?: typeof globalThis.fetch;
|
|
10
9
|
event?: RequestEvent;
|
|
11
10
|
} & MutationConfig<_Data, _Input, _Optimistic>): Promise<QueryResult<_Data, _Input>>;
|
|
12
|
-
subscribe(...args: Parameters<DocumentStore<_Data, _Input>['subscribe']>): import("$houdini/runtime/lib").Unsubscriber;
|
|
13
11
|
}
|
|
14
12
|
export type MutationConfig<_Result, _Input, _Optimistic> = {
|
|
15
13
|
optimisticResponse?: _Optimistic;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { DocumentStore } from '$houdini/runtime/client';
|
|
2
2
|
import type { SendParams } from '$houdini/runtime/client/documentStore';
|
|
3
|
-
import type { GraphQLObject, QueryArtifact
|
|
4
|
-
import type {
|
|
5
|
-
import type { QueryStoreFetchParams } from '../query';
|
|
3
|
+
import type { GraphQLObject, QueryArtifact } from '$houdini/runtime/lib/types';
|
|
4
|
+
import type { CursorHandlers } from '../../types';
|
|
6
5
|
import type { FetchFn } from './fetch';
|
|
7
|
-
import type { PageInfo } from './pageInfo';
|
|
8
6
|
export declare function cursorHandlers<_Data extends GraphQLObject, _Input extends Record<string, any>>({ artifact, storeName, observer, fetchUpdate: parentFetchUpdate, fetch: parentFetch, }: {
|
|
9
7
|
artifact: QueryArtifact;
|
|
10
8
|
storeName: string;
|
|
@@ -12,19 +10,3 @@ export declare function cursorHandlers<_Data extends GraphQLObject, _Input exten
|
|
|
12
10
|
fetch: FetchFn<_Data, _Input>;
|
|
13
11
|
fetchUpdate: (arg: SendParams, updates: string[]) => ReturnType<FetchFn<_Data, _Input>>;
|
|
14
12
|
}): CursorHandlers<_Data, _Input>;
|
|
15
|
-
export type CursorHandlers<_Data extends GraphQLObject, _Input> = {
|
|
16
|
-
loadNextPage: (args?: {
|
|
17
|
-
first?: number;
|
|
18
|
-
after?: string;
|
|
19
|
-
fetch?: typeof globalThis.fetch;
|
|
20
|
-
metadata: {};
|
|
21
|
-
}) => Promise<void>;
|
|
22
|
-
loadPreviousPage: (args?: {
|
|
23
|
-
last?: number;
|
|
24
|
-
before?: string;
|
|
25
|
-
fetch?: typeof globalThis.fetch;
|
|
26
|
-
metadata?: {};
|
|
27
|
-
}) => Promise<void>;
|
|
28
|
-
pageInfo: Writable<PageInfo>;
|
|
29
|
-
fetch(args?: QueryStoreFetchParams<_Data, _Input> | undefined): Promise<QueryResult<_Data, _Input>>;
|
|
30
|
-
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DocumentStore } from '$houdini/runtime/client';
|
|
2
2
|
import type { FragmentArtifact, GraphQLObject, HoudiniFetchContext, QueryArtifact } from '$houdini/runtime/lib/types';
|
|
3
3
|
import type { Readable, Subscriber } from 'svelte/store';
|
|
4
|
+
import type { CursorHandlers, OffsetFragmentStoreInstance } from '../../types';
|
|
4
5
|
import type { StoreConfig } from '../query';
|
|
5
|
-
import type { CursorHandlers } from './cursor';
|
|
6
6
|
import { type PageInfo } from './pageInfo';
|
|
7
7
|
type FragmentStoreConfig<_Data extends GraphQLObject, _Input> = StoreConfig<_Data, _Input, FragmentArtifact> & {
|
|
8
8
|
paginationArtifact: QueryArtifact;
|
|
@@ -43,19 +43,7 @@ export declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input ext
|
|
|
43
43
|
protected storeHandlers(observer: DocumentStore<_Data, _Input>): CursorHandlers<_Data, _Input>;
|
|
44
44
|
}
|
|
45
45
|
export declare class FragmentStoreOffset<_Data extends GraphQLObject, _Input extends Record<string, any>> extends BasePaginatedFragmentStore<_Data, _Input> {
|
|
46
|
-
get(initialValue: _Data | null):
|
|
47
|
-
kind: "HoudiniFragment";
|
|
48
|
-
data: Readable<_Data | null>;
|
|
49
|
-
subscribe: (run: import("$houdini/runtime/lib").Subscriber<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>, invalidate?: (value?: import("$houdini/runtime/lib/types").QueryResult<_Data, _Input> | undefined) => void) => import("$houdini/runtime/lib").Unsubscriber;
|
|
50
|
-
fetch: (args?: import("../query").QueryStoreFetchParams<_Data, _Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
|
|
51
|
-
loadNextPage: ({ limit, offset, fetch, metadata, }?: {
|
|
52
|
-
limit?: number | undefined;
|
|
53
|
-
offset?: number | undefined;
|
|
54
|
-
fetch?: typeof fetch | undefined;
|
|
55
|
-
metadata?: {} | undefined;
|
|
56
|
-
}) => Promise<void>;
|
|
57
|
-
fetching: Readable<boolean>;
|
|
58
|
-
};
|
|
46
|
+
get(initialValue: _Data | null): OffsetFragmentStoreInstance<_Data, _Input>;
|
|
59
47
|
}
|
|
60
48
|
export type FragmentStorePaginated<_Data extends GraphQLObject, _Input> = Readable<{
|
|
61
49
|
data: _Data;
|
|
@@ -18,12 +18,3 @@ export declare function offsetHandlers<_Data extends GraphQLObject, _Input exten
|
|
|
18
18
|
}) => Promise<void>;
|
|
19
19
|
fetch(args?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
20
20
|
};
|
|
21
|
-
export type OffsetHandlers<_Data extends GraphQLObject, _Input, _ReturnType> = {
|
|
22
|
-
loadNextPage: (args?: {
|
|
23
|
-
limit?: number;
|
|
24
|
-
offset?: number;
|
|
25
|
-
metadata?: {};
|
|
26
|
-
fetch?: typeof globalThis.fetch;
|
|
27
|
-
}) => Promise<void>;
|
|
28
|
-
fetch(args?: QueryStoreFetchParams<_Data, _Input> | undefined): Promise<_ReturnType>;
|
|
29
|
-
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { GraphQLObject, QueryArtifact, QueryResult } from '$houdini/runtime/lib/types';
|
|
2
2
|
import type { Subscriber } from 'svelte/store';
|
|
3
|
+
import type { CursorHandlers, OffsetHandlers } from '../../types';
|
|
3
4
|
import type { ClientFetchParams, LoadEventFetchParams, QueryStoreFetchParams, RequestEventFetchParams, StoreConfig } from '../query';
|
|
4
5
|
import { QueryStore } from '../query';
|
|
5
|
-
import type { CursorHandlers } from './cursor';
|
|
6
|
-
import type { OffsetHandlers } from './offset';
|
|
7
6
|
import { type PageInfo } from './pageInfo';
|
|
8
7
|
export type CursorStoreResult<_Data extends GraphQLObject, _Input extends {}> = QueryResult<_Data, _Input> & {
|
|
9
8
|
pageInfo: PageInfo;
|
|
@@ -23,7 +22,7 @@ export declare class QueryStoreCursor<_Data extends GraphQLObject, _Input extend
|
|
|
23
22
|
export declare class QueryStoreOffset<_Data extends GraphQLObject, _Input extends {}> extends QueryStore<_Data, _Input> {
|
|
24
23
|
#private;
|
|
25
24
|
paginated: boolean;
|
|
26
|
-
loadNextPage(args?: Parameters<OffsetHandlers<_Data, _Input
|
|
25
|
+
loadNextPage(args?: Parameters<OffsetHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<void>;
|
|
27
26
|
fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
28
27
|
fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
29
28
|
fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import type { FetchContext } from '$houdini/runtime/client/plugins/fetch';
|
|
2
2
|
import type { GraphQLObject, HoudiniFetchContext, MutationArtifact, QueryArtifact, QueryResult, CachePolicies } from '$houdini/runtime/lib/types';
|
|
3
3
|
import type { LoadEvent, RequestEvent } from '@sveltejs/kit';
|
|
4
|
-
import type { Readable } from 'svelte/store';
|
|
5
4
|
import type { PluginArtifactData } from '../../plugin/artifactData';
|
|
6
5
|
import { BaseStore } from './base';
|
|
7
6
|
export declare class QueryStore<_Data extends GraphQLObject, _Input extends {}> extends BaseStore<_Data, _Input, QueryArtifact> {
|
|
8
|
-
#private;
|
|
9
7
|
variables: boolean;
|
|
10
8
|
kind: "HoudiniQuery";
|
|
11
9
|
protected loadPending: boolean;
|
|
12
|
-
protected subscriberCount: number;
|
|
13
10
|
protected storeName: string;
|
|
14
11
|
constructor({ artifact, storeName, variables }: StoreConfig<_Data, _Input, QueryArtifact>);
|
|
15
12
|
/**
|
|
@@ -19,8 +16,6 @@ export declare class QueryStore<_Data extends GraphQLObject, _Input extends {}>
|
|
|
19
16
|
fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
20
17
|
fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
21
18
|
fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
22
|
-
get name(): string;
|
|
23
|
-
subscribe(...args: Parameters<Readable<QueryResult<_Data, _Input>>['subscribe']>): () => void;
|
|
24
19
|
}
|
|
25
20
|
export type StoreConfig<_Data extends GraphQLObject, _Input, _Artifact> = {
|
|
26
21
|
artifact: _Artifact & {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { DocumentStore } from '$houdini/runtime/client';
|
|
2
1
|
import type { SubscriptionArtifact } from '$houdini/runtime/lib/types';
|
|
3
2
|
import type { GraphQLObject } from 'houdini';
|
|
4
3
|
import { BaseStore } from './base';
|
|
@@ -7,7 +6,6 @@ export declare class SubscriptionStore<_Data extends GraphQLObject, _Input exten
|
|
|
7
6
|
constructor({ artifact }: {
|
|
8
7
|
artifact: SubscriptionArtifact;
|
|
9
8
|
});
|
|
10
|
-
subscribe(...args: Parameters<DocumentStore<_Data, _Input>['subscribe']>): import("$houdini/runtime/lib").Unsubscriber;
|
|
11
9
|
listen(variables?: _Input, args?: {
|
|
12
10
|
metadata: App.Metadata;
|
|
13
11
|
}): Promise<void>;
|
package/build/runtime/types.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import type { FetchQueryResult } from '$houdini/runtime/lib/types';
|
|
1
|
+
import type { FetchQueryResult, CompiledFragmentKind, QueryResult, GraphQLObject } from '$houdini/runtime/lib/types';
|
|
2
2
|
import type { LoadEvent } from '@sveltejs/kit';
|
|
3
|
+
import type { Readable, Writable } from 'svelte/store';
|
|
4
|
+
import type { QueryStoreFetchParams } from './stores';
|
|
5
|
+
import type { PageInfo } from './stores/pagination/pageInfo';
|
|
3
6
|
export type QueryInputs<_Data> = FetchQueryResult<_Data> & {
|
|
4
7
|
variables: {
|
|
5
8
|
[key: string]: any;
|
|
@@ -30,3 +33,50 @@ export type KitLoadResponse = {
|
|
|
30
33
|
context?: Record<string, any>;
|
|
31
34
|
maxage?: number;
|
|
32
35
|
};
|
|
36
|
+
export type FragmentStoreInstance<_Data> = Readable<_Data> & {
|
|
37
|
+
kind: typeof CompiledFragmentKind;
|
|
38
|
+
update: Writable<_Data>['set'];
|
|
39
|
+
};
|
|
40
|
+
type Reshape<_Data, _Input> = Omit<QueryResult<_Data, _Input>, 'data'> & {
|
|
41
|
+
data: _Data;
|
|
42
|
+
};
|
|
43
|
+
export type CursorFragmentStoreInstance<_Data extends GraphQLObject, _Input> = {
|
|
44
|
+
kind: typeof CompiledFragmentKind;
|
|
45
|
+
data: Readable<_Data>;
|
|
46
|
+
subscribe: Readable<Reshape<_Data, _Input> & {
|
|
47
|
+
pageInfo: PageInfo;
|
|
48
|
+
}>['subscribe'];
|
|
49
|
+
fetching: Readable<boolean>;
|
|
50
|
+
} & CursorHandlers<_Data, _Input>;
|
|
51
|
+
export type OffsetFragmentStoreInstance<_Data extends GraphQLObject, _Input> = {
|
|
52
|
+
kind: typeof CompiledFragmentKind;
|
|
53
|
+
data: Readable<_Data>;
|
|
54
|
+
subscribe: Readable<Reshape<_Data, _Input>>['subscribe'];
|
|
55
|
+
fetching: Readable<boolean>;
|
|
56
|
+
} & OffsetHandlers<_Data, _Input>;
|
|
57
|
+
export type CursorHandlers<_Data extends GraphQLObject, _Input> = {
|
|
58
|
+
loadNextPage: (args?: {
|
|
59
|
+
first?: number;
|
|
60
|
+
after?: string;
|
|
61
|
+
fetch?: typeof globalThis.fetch;
|
|
62
|
+
metadata: {};
|
|
63
|
+
}) => Promise<void>;
|
|
64
|
+
loadPreviousPage: (args?: {
|
|
65
|
+
last?: number;
|
|
66
|
+
before?: string;
|
|
67
|
+
fetch?: typeof globalThis.fetch;
|
|
68
|
+
metadata?: {};
|
|
69
|
+
}) => Promise<void>;
|
|
70
|
+
pageInfo: Writable<PageInfo>;
|
|
71
|
+
fetch(args?: QueryStoreFetchParams<_Data, _Input> | undefined): Promise<QueryResult<_Data, _Input>>;
|
|
72
|
+
};
|
|
73
|
+
export type OffsetHandlers<_Data extends GraphQLObject, _Input> = {
|
|
74
|
+
loadNextPage: (args?: {
|
|
75
|
+
limit?: number;
|
|
76
|
+
offset?: number;
|
|
77
|
+
metadata?: {};
|
|
78
|
+
fetch?: typeof globalThis.fetch;
|
|
79
|
+
}) => Promise<void>;
|
|
80
|
+
fetch(args?: QueryStoreFetchParams<_Data, _Input> | undefined): Promise<QueryResult<_Data, _Input>>;
|
|
81
|
+
};
|
|
82
|
+
export {};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { GraphQLObject, DocumentArtifact } from '$houdini/runtime/lib/types';
|
|
1
|
+
import { DocumentStore, type ObserveParams } from '$houdini/runtime/client';
|
|
2
|
+
import type { GraphQLObject, DocumentArtifact, QueryResult } from '$houdini/runtime/lib/types';
|
|
3
|
+
import type { Readable } from 'svelte/store';
|
|
3
4
|
export declare class BaseStore<_Data extends GraphQLObject, _Input extends {}, _Artifact extends DocumentArtifact = DocumentArtifact> {
|
|
4
5
|
#private;
|
|
5
|
-
constructor(params: ObserveParams<_Data, _Artifact>);
|
|
6
6
|
get artifact(): _Artifact;
|
|
7
|
+
get name(): string;
|
|
8
|
+
constructor(params: ObserveParams<_Data, _Artifact>);
|
|
7
9
|
protected get observer(): DocumentStore<_Data, _Input>;
|
|
10
|
+
subscribe(...args: Parameters<Readable<QueryResult<_Data, _Input>>['subscribe']>): () => void;
|
|
11
|
+
setup(init?: boolean): void;
|
|
8
12
|
}
|
|
@@ -21,23 +21,74 @@ __export(base_exports, {
|
|
|
21
21
|
BaseStore: () => BaseStore
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(base_exports);
|
|
24
|
-
var import_client = require("
|
|
24
|
+
var import_client = require("$houdini/runtime/client");
|
|
25
|
+
var import_store = require("svelte/store");
|
|
26
|
+
var import_adapter = require("../adapter");
|
|
27
|
+
var import_client2 = require("../client");
|
|
25
28
|
class BaseStore {
|
|
26
29
|
#params;
|
|
27
|
-
constructor(params) {
|
|
28
|
-
this.#params = params;
|
|
29
|
-
}
|
|
30
30
|
get artifact() {
|
|
31
31
|
return this.#params.artifact;
|
|
32
32
|
}
|
|
33
|
+
get name() {
|
|
34
|
+
return this.artifact.name;
|
|
35
|
+
}
|
|
36
|
+
#store;
|
|
37
|
+
#unsubscribe = null;
|
|
38
|
+
constructor(params) {
|
|
39
|
+
this.#store = new import_client.DocumentStore({
|
|
40
|
+
artifact: params.artifact,
|
|
41
|
+
client: null,
|
|
42
|
+
fetching: params.fetching
|
|
43
|
+
});
|
|
44
|
+
this.#params = params;
|
|
45
|
+
}
|
|
33
46
|
#observer = null;
|
|
34
47
|
get observer() {
|
|
35
48
|
if (this.#observer) {
|
|
36
49
|
return this.#observer;
|
|
37
50
|
}
|
|
38
|
-
this.#observer = (0,
|
|
51
|
+
this.#observer = (0, import_client2.getClient)().observe(this.#params);
|
|
39
52
|
return this.#observer;
|
|
40
53
|
}
|
|
54
|
+
subscribe(...args) {
|
|
55
|
+
const bubbleUp = this.#store.subscribe(...args);
|
|
56
|
+
if (import_adapter.isBrowser && (this.#subscriberCount === 0 || !this.#unsubscribe)) {
|
|
57
|
+
this.setup();
|
|
58
|
+
}
|
|
59
|
+
this.#subscriberCount = (this.#subscriberCount ?? 0) + 1;
|
|
60
|
+
return () => {
|
|
61
|
+
this.#subscriberCount--;
|
|
62
|
+
if (this.#subscriberCount <= 0) {
|
|
63
|
+
this.#unsubscribe?.();
|
|
64
|
+
this.#unsubscribe = null;
|
|
65
|
+
bubbleUp();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
#subscriberCount = 0;
|
|
70
|
+
setup(init = true) {
|
|
71
|
+
let initPromise = Promise.resolve();
|
|
72
|
+
try {
|
|
73
|
+
(0, import_client2.getClient)();
|
|
74
|
+
} catch {
|
|
75
|
+
initPromise = (0, import_client2.initClient)();
|
|
76
|
+
}
|
|
77
|
+
initPromise.then(() => {
|
|
78
|
+
if (this.#unsubscribe) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
this.#unsubscribe = this.observer.subscribe((value) => {
|
|
82
|
+
this.#store.set(value);
|
|
83
|
+
});
|
|
84
|
+
if (init) {
|
|
85
|
+
return this.observer.send({
|
|
86
|
+
setup: true,
|
|
87
|
+
variables: (0, import_store.get)(this.observer).variables
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
41
92
|
}
|
|
42
93
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
94
|
0 && (module.exports = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GraphQLObject, FragmentArtifact, HoudiniFetchContext } from '$houdini/runtime/lib/types';
|
|
2
|
+
import type { FragmentStoreInstance } from '../types';
|
|
2
3
|
export declare class FragmentStore<_Data extends GraphQLObject, _Input = {}> {
|
|
3
4
|
artifact: FragmentArtifact;
|
|
4
5
|
name: string;
|
|
@@ -8,9 +9,5 @@ export declare class FragmentStore<_Data extends GraphQLObject, _Input = {}> {
|
|
|
8
9
|
artifact: FragmentArtifact;
|
|
9
10
|
storeName: string;
|
|
10
11
|
});
|
|
11
|
-
get(initialValue: _Data | null):
|
|
12
|
-
kind: "HoudiniFragment";
|
|
13
|
-
subscribe: (run: import("svelte/store").Subscriber<_Data | null>, invalidate?: ((value?: _Data | null | undefined) => void) | undefined) => import("svelte/store").Unsubscriber;
|
|
14
|
-
update: (val: _Data | null) => void;
|
|
15
|
-
};
|
|
12
|
+
get(initialValue: _Data | null): FragmentStoreInstance<_Data | null>;
|
|
16
13
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { DocumentStore } from '$houdini/runtime/client';
|
|
2
1
|
import type { MutationArtifact, GraphQLObject, QueryResult } from '$houdini/runtime/lib/types';
|
|
3
2
|
import type { RequestEvent } from '@sveltejs/kit';
|
|
4
3
|
import { BaseStore } from './base';
|
|
@@ -9,7 +8,6 @@ export declare class MutationStore<_Data extends GraphQLObject, _Input extends {
|
|
|
9
8
|
fetch?: typeof globalThis.fetch;
|
|
10
9
|
event?: RequestEvent;
|
|
11
10
|
} & MutationConfig<_Data, _Input, _Optimistic>): Promise<QueryResult<_Data, _Input>>;
|
|
12
|
-
subscribe(...args: Parameters<DocumentStore<_Data, _Input>['subscribe']>): import("$houdini/runtime/lib").Unsubscriber;
|
|
13
11
|
}
|
|
14
12
|
export type MutationConfig<_Result, _Input, _Optimistic> = {
|
|
15
13
|
optimisticResponse?: _Optimistic;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { DocumentStore } from '$houdini/runtime/client';
|
|
2
2
|
import type { SendParams } from '$houdini/runtime/client/documentStore';
|
|
3
|
-
import type { GraphQLObject, QueryArtifact
|
|
4
|
-
import type {
|
|
5
|
-
import type { QueryStoreFetchParams } from '../query';
|
|
3
|
+
import type { GraphQLObject, QueryArtifact } from '$houdini/runtime/lib/types';
|
|
4
|
+
import type { CursorHandlers } from '../../types';
|
|
6
5
|
import type { FetchFn } from './fetch';
|
|
7
|
-
import type { PageInfo } from './pageInfo';
|
|
8
6
|
export declare function cursorHandlers<_Data extends GraphQLObject, _Input extends Record<string, any>>({ artifact, storeName, observer, fetchUpdate: parentFetchUpdate, fetch: parentFetch, }: {
|
|
9
7
|
artifact: QueryArtifact;
|
|
10
8
|
storeName: string;
|
|
@@ -12,19 +10,3 @@ export declare function cursorHandlers<_Data extends GraphQLObject, _Input exten
|
|
|
12
10
|
fetch: FetchFn<_Data, _Input>;
|
|
13
11
|
fetchUpdate: (arg: SendParams, updates: string[]) => ReturnType<FetchFn<_Data, _Input>>;
|
|
14
12
|
}): CursorHandlers<_Data, _Input>;
|
|
15
|
-
export type CursorHandlers<_Data extends GraphQLObject, _Input> = {
|
|
16
|
-
loadNextPage: (args?: {
|
|
17
|
-
first?: number;
|
|
18
|
-
after?: string;
|
|
19
|
-
fetch?: typeof globalThis.fetch;
|
|
20
|
-
metadata: {};
|
|
21
|
-
}) => Promise<void>;
|
|
22
|
-
loadPreviousPage: (args?: {
|
|
23
|
-
last?: number;
|
|
24
|
-
before?: string;
|
|
25
|
-
fetch?: typeof globalThis.fetch;
|
|
26
|
-
metadata?: {};
|
|
27
|
-
}) => Promise<void>;
|
|
28
|
-
pageInfo: Writable<PageInfo>;
|
|
29
|
-
fetch(args?: QueryStoreFetchParams<_Data, _Input> | undefined): Promise<QueryResult<_Data, _Input>>;
|
|
30
|
-
};
|
|
@@ -154,7 +154,7 @@ If you think this is an error, please open an issue on GitHub`);
|
|
|
154
154
|
if (count && count > artifact.refetch.pageSize) {
|
|
155
155
|
if (currentPageInfo.hasPreviousPage && currentPageInfo.hasNextPage && !(variables?.["first"] && variables?.["after"] || variables?.["last"] && variables?.["before"])) {
|
|
156
156
|
console.warn(`\u26A0\uFE0F Encountered a fetch() in the middle of the connection.
|
|
157
|
-
Make sure to pass a cursor value by hand that includes the current set (ie the entry before startCursor)
|
|
157
|
+
Make sure to pass a cursor value by hand that includes the current set (ie the entry before startCursor)
|
|
158
158
|
`);
|
|
159
159
|
return observer.state;
|
|
160
160
|
}
|