houdini-svelte 2.1.9 → 2.1.10

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.
Files changed (40) hide show
  1. package/build/plugin-cjs/index.js +4 -4
  2. package/build/plugin-esm/index.js +4 -4
  3. package/build/preprocess-cjs/index.js +4 -4
  4. package/build/preprocess-esm/index.js +4 -4
  5. package/build/runtime/fragments.d.ts +1 -1
  6. package/build/runtime/stores/fragment.d.ts +58 -2
  7. package/build/runtime/stores/index.d.ts +2 -3
  8. package/build/runtime/stores/query.d.ts +27 -1
  9. package/build/runtime-cjs/fragments.d.ts +1 -1
  10. package/build/runtime-cjs/stores/fragment.d.ts +58 -2
  11. package/build/runtime-cjs/stores/fragment.js +180 -2
  12. package/build/runtime-cjs/stores/index.d.ts +2 -3
  13. package/build/runtime-cjs/stores/index.js +8 -2
  14. package/build/runtime-cjs/stores/query.d.ts +27 -1
  15. package/build/runtime-cjs/stores/query.js +118 -0
  16. package/build/runtime-esm/fragments.d.ts +1 -1
  17. package/build/runtime-esm/stores/fragment.d.ts +58 -2
  18. package/build/runtime-esm/stores/fragment.js +179 -3
  19. package/build/runtime-esm/stores/index.d.ts +2 -3
  20. package/build/runtime-esm/stores/index.js +6 -3
  21. package/build/runtime-esm/stores/query.d.ts +27 -1
  22. package/build/runtime-esm/stores/query.js +118 -2
  23. package/build/test-cjs/index.js +4 -4
  24. package/build/test-esm/index.js +4 -4
  25. package/package.json +1 -1
  26. package/build/runtime/stores/pagination/fragment.d.ts +0 -58
  27. package/build/runtime/stores/pagination/index.d.ts +0 -2
  28. package/build/runtime/stores/pagination/query.d.ts +0 -30
  29. package/build/runtime-cjs/stores/pagination/fragment.d.ts +0 -58
  30. package/build/runtime-cjs/stores/pagination/fragment.js +0 -207
  31. package/build/runtime-cjs/stores/pagination/index.d.ts +0 -2
  32. package/build/runtime-cjs/stores/pagination/index.js +0 -35
  33. package/build/runtime-cjs/stores/pagination/query.d.ts +0 -30
  34. package/build/runtime-cjs/stores/pagination/query.js +0 -147
  35. package/build/runtime-esm/stores/pagination/fragment.d.ts +0 -58
  36. package/build/runtime-esm/stores/pagination/fragment.js +0 -182
  37. package/build/runtime-esm/stores/pagination/index.d.ts +0 -2
  38. package/build/runtime-esm/stores/pagination/index.js +0 -8
  39. package/build/runtime-esm/stores/pagination/query.d.ts +0 -30
  40. package/build/runtime-esm/stores/pagination/query.js +0 -122
@@ -1,58 +0,0 @@
1
- /// <reference types="svelte" />
2
- import type { DocumentStore } from '$houdini/runtime/client';
3
- import type { FragmentArtifact, GraphQLObject, HoudiniFetchContext, QueryArtifact, PageInfo, CursorHandlers, GraphQLVariables } from '$houdini/runtime/lib/types';
4
- import type { Readable, Subscriber } from 'svelte/store';
5
- import type { OffsetFragmentStoreInstance } from '../../types';
6
- import type { StoreConfig } from '../query';
7
- type FragmentStoreConfig<_Data extends GraphQLObject, _Input> = StoreConfig<_Data, _Input, FragmentArtifact> & {
8
- paginationArtifact: QueryArtifact;
9
- };
10
- declare class BasePaginatedFragmentStore<_Data extends GraphQLObject, _Input> {
11
- paginated: boolean;
12
- protected paginationArtifact: QueryArtifact;
13
- name: string;
14
- kind: "HoudiniFragment";
15
- artifact: FragmentArtifact;
16
- constructor(config: FragmentStoreConfig<_Data, _Input>);
17
- protected queryVariables(getState: () => _Data | null): _Input;
18
- }
19
- export declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends BasePaginatedFragmentStore<_Data, _Input> {
20
- get(initialValue: _Data | null): {
21
- kind: "HoudiniFragment";
22
- subscribe: (run: Subscriber<FragmentPaginatedResult<_Data, {
23
- pageInfo: PageInfo;
24
- }>>, invalidate?: ((value?: FragmentPaginatedResult<_Data, {
25
- pageInfo: PageInfo;
26
- }> | undefined) => void) | undefined) => (() => void);
27
- fetch: (args?: import("$houdini/runtime/lib/types").FetchParams<_Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
28
- loadNextPage: (args?: {
29
- first?: number | undefined;
30
- after?: string | undefined;
31
- fetch?: typeof fetch | undefined;
32
- metadata?: {} | undefined;
33
- } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
34
- loadPreviousPage: (args?: {
35
- last?: number | undefined;
36
- before?: string | undefined;
37
- fetch?: typeof fetch | undefined;
38
- metadata?: {} | undefined;
39
- } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
40
- };
41
- protected storeHandlers(observer: DocumentStore<_Data, _Input>, initialValue: _Data | null, getState: () => _Data | null, getVariables: () => NonNullable<_Input>): CursorHandlers<_Data, _Input>;
42
- }
43
- export declare class FragmentStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends BasePaginatedFragmentStore<_Data, _Input> {
44
- get(initialValue: _Data | null): OffsetFragmentStoreInstance<_Data, _Input>;
45
- }
46
- export type FragmentStorePaginated<_Data extends GraphQLObject, _Input> = Readable<{
47
- data: _Data;
48
- fetching: boolean;
49
- pageInfo: PageInfo;
50
- }> & {
51
- loadNextPage(pageCount?: number, after?: string | number, houdiniContext?: HoudiniFetchContext): Promise<void>;
52
- loadPreviousPage(pageCount?: number, before?: string, houdiniContext?: HoudiniFetchContext): Promise<void>;
53
- };
54
- export type FragmentPaginatedResult<_Data, _ExtraFields = {}> = {
55
- data: _Data | null;
56
- fetching: boolean;
57
- } & _ExtraFields;
58
- export {};
@@ -1,2 +0,0 @@
1
- export { FragmentStoreCursor, FragmentStoreOffset } from './fragment';
2
- export { QueryStoreCursor, QueryStoreOffset } from './query';
@@ -1,30 +0,0 @@
1
- /// <reference types="svelte" />
2
- import type { GraphQLObject, QueryArtifact, QueryResult, CursorHandlers, OffsetHandlers, PageInfo, GraphQLVariables } from '$houdini/runtime/lib/types';
3
- import type { Subscriber } from 'svelte/store';
4
- import type { ClientFetchParams, LoadEventFetchParams, QueryStoreFetchParams, RequestEventFetchParams } from '../../types';
5
- import type { StoreConfig } from '../query';
6
- import { QueryStore } from '../query';
7
- export type CursorStoreResult<_Data extends GraphQLObject, _Input extends GraphQLVariables> = QueryResult<_Data, _Input> & {
8
- pageInfo: PageInfo;
9
- };
10
- export declare class QueryStoreCursor<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
11
- #private;
12
- paginated: boolean;
13
- constructor(config: StoreConfig<_Data, _Input, QueryArtifact>);
14
- fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
15
- fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
16
- fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
17
- fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
18
- loadPreviousPage(args?: Parameters<Required<CursorHandlers<_Data, _Input>>['loadPreviousPage']>[0]): Promise<QueryResult<_Data, _Input>>;
19
- loadNextPage(args?: Parameters<CursorHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<QueryResult<_Data, _Input>>;
20
- subscribe(run: Subscriber<CursorStoreResult<_Data, _Input>>, invalidate?: ((value?: CursorStoreResult<_Data, _Input> | undefined) => void) | undefined): () => void;
21
- }
22
- export declare class QueryStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
23
- #private;
24
- paginated: boolean;
25
- loadNextPage(args?: Parameters<OffsetHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<void>;
26
- fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
27
- fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
28
- fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
29
- fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
30
- }
@@ -1,58 +0,0 @@
1
- /// <reference types="svelte" />
2
- import type { DocumentStore } from '$houdini/runtime/client';
3
- import type { FragmentArtifact, GraphQLObject, HoudiniFetchContext, QueryArtifact, PageInfo, CursorHandlers, GraphQLVariables } from '$houdini/runtime/lib/types';
4
- import type { Readable, Subscriber } from 'svelte/store';
5
- import type { OffsetFragmentStoreInstance } from '../../types';
6
- import type { StoreConfig } from '../query';
7
- type FragmentStoreConfig<_Data extends GraphQLObject, _Input> = StoreConfig<_Data, _Input, FragmentArtifact> & {
8
- paginationArtifact: QueryArtifact;
9
- };
10
- declare class BasePaginatedFragmentStore<_Data extends GraphQLObject, _Input> {
11
- paginated: boolean;
12
- protected paginationArtifact: QueryArtifact;
13
- name: string;
14
- kind: "HoudiniFragment";
15
- artifact: FragmentArtifact;
16
- constructor(config: FragmentStoreConfig<_Data, _Input>);
17
- protected queryVariables(getState: () => _Data | null): _Input;
18
- }
19
- export declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends BasePaginatedFragmentStore<_Data, _Input> {
20
- get(initialValue: _Data | null): {
21
- kind: "HoudiniFragment";
22
- subscribe: (run: Subscriber<FragmentPaginatedResult<_Data, {
23
- pageInfo: PageInfo;
24
- }>>, invalidate?: ((value?: FragmentPaginatedResult<_Data, {
25
- pageInfo: PageInfo;
26
- }> | undefined) => void) | undefined) => (() => void);
27
- fetch: (args?: import("$houdini/runtime/lib/types").FetchParams<_Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
28
- loadNextPage: (args?: {
29
- first?: number | undefined;
30
- after?: string | undefined;
31
- fetch?: typeof fetch | undefined;
32
- metadata?: {} | undefined;
33
- } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
34
- loadPreviousPage: (args?: {
35
- last?: number | undefined;
36
- before?: string | undefined;
37
- fetch?: typeof fetch | undefined;
38
- metadata?: {} | undefined;
39
- } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
40
- };
41
- protected storeHandlers(observer: DocumentStore<_Data, _Input>, initialValue: _Data | null, getState: () => _Data | null, getVariables: () => NonNullable<_Input>): CursorHandlers<_Data, _Input>;
42
- }
43
- export declare class FragmentStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends BasePaginatedFragmentStore<_Data, _Input> {
44
- get(initialValue: _Data | null): OffsetFragmentStoreInstance<_Data, _Input>;
45
- }
46
- export type FragmentStorePaginated<_Data extends GraphQLObject, _Input> = Readable<{
47
- data: _Data;
48
- fetching: boolean;
49
- pageInfo: PageInfo;
50
- }> & {
51
- loadNextPage(pageCount?: number, after?: string | number, houdiniContext?: HoudiniFetchContext): Promise<void>;
52
- loadPreviousPage(pageCount?: number, before?: string, houdiniContext?: HoudiniFetchContext): Promise<void>;
53
- };
54
- export type FragmentPaginatedResult<_Data, _ExtraFields = {}> = {
55
- data: _Data | null;
56
- fetching: boolean;
57
- } & _ExtraFields;
58
- export {};
@@ -1,207 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var fragment_exports = {};
20
- __export(fragment_exports, {
21
- FragmentStoreCursor: () => FragmentStoreCursor,
22
- FragmentStoreOffset: () => FragmentStoreOffset
23
- });
24
- module.exports = __toCommonJS(fragment_exports);
25
- var import_config = require("$houdini/runtime/lib/config");
26
- var import_constants = require("$houdini/runtime/lib/constants");
27
- var import_pageInfo = require("$houdini/runtime/lib/pageInfo");
28
- var import_pagination = require("$houdini/runtime/lib/pagination");
29
- var import_types = require("$houdini/runtime/lib/types");
30
- var import_store = require("svelte/store");
31
- var import_client = require("../../client");
32
- var import_session = require("../../session");
33
- var import_fragment = require("../fragment");
34
- class BasePaginatedFragmentStore {
35
- paginated = true;
36
- paginationArtifact;
37
- name;
38
- kind = import_types.CompiledFragmentKind;
39
- artifact;
40
- constructor(config) {
41
- this.paginationArtifact = config.paginationArtifact;
42
- this.name = config.storeName;
43
- this.artifact = config.artifact;
44
- }
45
- queryVariables(getState) {
46
- const config = (0, import_config.getCurrentConfig)();
47
- const { targetType } = this.paginationArtifact.refetch || {};
48
- const typeConfig = config.types?.[targetType || ""];
49
- if (!typeConfig) {
50
- throw new Error(
51
- `Missing type refetch configuration for ${targetType}. For more information, see ${import_constants.siteURL}/guides/pagination#paginated-fragments`
52
- );
53
- }
54
- let idVariables = {};
55
- const value = getState();
56
- if (typeConfig.resolve?.arguments) {
57
- idVariables = typeConfig.resolve.arguments?.(value) || {};
58
- } else {
59
- const keys = (0, import_config.keyFieldsForType)(config, targetType || "");
60
- idVariables = Object.fromEntries(keys.map((key) => [key, value[key]]));
61
- }
62
- return {
63
- ...idVariables
64
- };
65
- }
66
- }
67
- class FragmentStoreCursor extends BasePaginatedFragmentStore {
68
- get(initialValue) {
69
- const base = new import_fragment.FragmentStore({
70
- artifact: this.artifact,
71
- storeName: this.name
72
- });
73
- const store = base.get(initialValue);
74
- const paginationStore = (0, import_client.getClient)().observe({
75
- artifact: this.paginationArtifact,
76
- initialValue: store.initialValue
77
- });
78
- const handlers = this.storeHandlers(
79
- paginationStore,
80
- initialValue,
81
- () => (0, import_store.get)(store),
82
- () => store.variables
83
- );
84
- const subscribe = (run, invalidate) => {
85
- const combined = (0, import_store.derived)([store, paginationStore], ([$parent, $pagination]) => {
86
- return {
87
- ...$pagination,
88
- data: $parent,
89
- pageInfo: (0, import_pageInfo.extractPageInfo)($parent, this.paginationArtifact.refetch.path)
90
- };
91
- });
92
- return combined.subscribe(run, invalidate);
93
- };
94
- return {
95
- kind: import_types.CompiledFragmentKind,
96
- subscribe,
97
- fetch: handlers.fetch,
98
- loadNextPage: handlers.loadNextPage,
99
- loadPreviousPage: handlers.loadPreviousPage
100
- };
101
- }
102
- storeHandlers(observer, initialValue, getState, getVariables) {
103
- return (0, import_pagination.cursorHandlers)({
104
- getState,
105
- getVariables,
106
- artifact: this.paginationArtifact,
107
- fetchUpdate: async (args, updates) => {
108
- return observer.send({
109
- session: await (0, import_session.getSession)(),
110
- ...args,
111
- variables: {
112
- ...args?.variables,
113
- ...this.queryVariables(getState)
114
- },
115
- cacheParams: {
116
- applyUpdates: updates,
117
- disableSubscriptions: true
118
- }
119
- });
120
- },
121
- fetch: async (args) => {
122
- return await observer.send({
123
- session: await (0, import_session.getSession)(),
124
- ...args,
125
- variables: {
126
- ...args?.variables,
127
- ...this.queryVariables(getState)
128
- },
129
- cacheParams: {
130
- disableSubscriptions: true
131
- }
132
- });
133
- },
134
- getSession: import_session.getSession
135
- });
136
- }
137
- }
138
- class FragmentStoreOffset extends BasePaginatedFragmentStore {
139
- get(initialValue) {
140
- const base = new import_fragment.FragmentStore({
141
- artifact: this.artifact,
142
- storeName: this.name
143
- });
144
- const store = base.get(initialValue);
145
- const paginationStore = (0, import_client.getClient)().observe({
146
- artifact: this.paginationArtifact,
147
- initialValue: store.initialValue
148
- });
149
- const getState = () => (0, import_store.get)(store);
150
- const handlers = (0, import_pagination.offsetHandlers)({
151
- getState,
152
- getVariables: () => store.variables,
153
- artifact: this.paginationArtifact,
154
- fetch: async (args) => {
155
- return paginationStore.send({
156
- ...args,
157
- session: await (0, import_session.getSession)(),
158
- variables: {
159
- ...this.queryVariables(getState),
160
- ...args?.variables
161
- },
162
- cacheParams: {
163
- disableSubscriptions: true
164
- }
165
- });
166
- },
167
- fetchUpdate: async (args) => {
168
- return paginationStore.send({
169
- session: await (0, import_session.getSession)(),
170
- ...args,
171
- variables: {
172
- ...this.queryVariables(getState),
173
- ...args?.variables
174
- },
175
- cacheParams: {
176
- disableSubscriptions: true,
177
- applyUpdates: ["append"]
178
- }
179
- });
180
- },
181
- getSession: import_session.getSession,
182
- storeName: this.name
183
- });
184
- const subscribe = (run, invalidate) => {
185
- const combined = (0, import_store.derived)([store, paginationStore], ([$parent, $pagination]) => {
186
- return {
187
- ...$pagination,
188
- data: $parent
189
- };
190
- });
191
- return combined.subscribe(run, invalidate);
192
- };
193
- return {
194
- kind: import_types.CompiledFragmentKind,
195
- data: (0, import_store.derived)(paginationStore, ($value) => $value.data),
196
- subscribe,
197
- fetch: handlers.fetch,
198
- loadNextPage: handlers.loadNextPage,
199
- fetching: (0, import_store.derived)(paginationStore, ($store) => $store.fetching)
200
- };
201
- }
202
- }
203
- // Annotate the CommonJS export names for ESM import in node:
204
- 0 && (module.exports = {
205
- FragmentStoreCursor,
206
- FragmentStoreOffset
207
- });
@@ -1,2 +0,0 @@
1
- export { FragmentStoreCursor, FragmentStoreOffset } from './fragment';
2
- export { QueryStoreCursor, QueryStoreOffset } from './query';
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var pagination_exports = {};
20
- __export(pagination_exports, {
21
- FragmentStoreCursor: () => import_fragment.FragmentStoreCursor,
22
- FragmentStoreOffset: () => import_fragment.FragmentStoreOffset,
23
- QueryStoreCursor: () => import_query.QueryStoreCursor,
24
- QueryStoreOffset: () => import_query.QueryStoreOffset
25
- });
26
- module.exports = __toCommonJS(pagination_exports);
27
- var import_fragment = require("./fragment");
28
- var import_query = require("./query");
29
- // Annotate the CommonJS export names for ESM import in node:
30
- 0 && (module.exports = {
31
- FragmentStoreCursor,
32
- FragmentStoreOffset,
33
- QueryStoreCursor,
34
- QueryStoreOffset
35
- });
@@ -1,30 +0,0 @@
1
- /// <reference types="svelte" />
2
- import type { GraphQLObject, QueryArtifact, QueryResult, CursorHandlers, OffsetHandlers, PageInfo, GraphQLVariables } from '$houdini/runtime/lib/types';
3
- import type { Subscriber } from 'svelte/store';
4
- import type { ClientFetchParams, LoadEventFetchParams, QueryStoreFetchParams, RequestEventFetchParams } from '../../types';
5
- import type { StoreConfig } from '../query';
6
- import { QueryStore } from '../query';
7
- export type CursorStoreResult<_Data extends GraphQLObject, _Input extends GraphQLVariables> = QueryResult<_Data, _Input> & {
8
- pageInfo: PageInfo;
9
- };
10
- export declare class QueryStoreCursor<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
11
- #private;
12
- paginated: boolean;
13
- constructor(config: StoreConfig<_Data, _Input, QueryArtifact>);
14
- fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
15
- fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
16
- fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
17
- fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
18
- loadPreviousPage(args?: Parameters<Required<CursorHandlers<_Data, _Input>>['loadPreviousPage']>[0]): Promise<QueryResult<_Data, _Input>>;
19
- loadNextPage(args?: Parameters<CursorHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<QueryResult<_Data, _Input>>;
20
- subscribe(run: Subscriber<CursorStoreResult<_Data, _Input>>, invalidate?: ((value?: CursorStoreResult<_Data, _Input> | undefined) => void) | undefined): () => void;
21
- }
22
- export declare class QueryStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
23
- #private;
24
- paginated: boolean;
25
- loadNextPage(args?: Parameters<OffsetHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<void>;
26
- fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
27
- fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
28
- fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
29
- fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
30
- }
@@ -1,147 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var query_exports = {};
20
- __export(query_exports, {
21
- QueryStoreCursor: () => QueryStoreCursor,
22
- QueryStoreOffset: () => QueryStoreOffset
23
- });
24
- module.exports = __toCommonJS(query_exports);
25
- var import_pageInfo = require("$houdini/runtime/lib/pageInfo");
26
- var import_pagination = require("$houdini/runtime/lib/pagination");
27
- var import_store = require("svelte/store");
28
- var import_client = require("../../client");
29
- var import_session = require("../../session");
30
- var import_query = require("../query");
31
- class QueryStoreCursor extends import_query.QueryStore {
32
- paginated = true;
33
- constructor(config) {
34
- super(config);
35
- }
36
- #_handlers = null;
37
- async #handlers() {
38
- if (this.#_handlers) {
39
- return this.#_handlers;
40
- }
41
- const paginationObserver = (0, import_client.getClient)().observe({
42
- artifact: this.artifact
43
- });
44
- this.#_handlers = (0, import_pagination.cursorHandlers)({
45
- artifact: this.artifact,
46
- getState: () => (0, import_store.get)(this.observer).data,
47
- getVariables: () => (0, import_store.get)(this.observer).variables,
48
- fetch: super.fetch.bind(this),
49
- getSession: import_session.getSession,
50
- fetchUpdate: async (args, updates) => {
51
- return paginationObserver.send({
52
- ...args,
53
- cacheParams: {
54
- applyUpdates: updates,
55
- disableSubscriptions: true,
56
- ...args?.cacheParams
57
- }
58
- });
59
- }
60
- });
61
- return this.#_handlers;
62
- }
63
- async fetch(args) {
64
- const handlers = await this.#handlers();
65
- return await handlers.fetch.call(this, args);
66
- }
67
- async loadPreviousPage(args) {
68
- const handlers = await this.#handlers();
69
- try {
70
- return await handlers.loadPreviousPage(args);
71
- } catch (e) {
72
- const err = e;
73
- if (err.name === "AbortError") {
74
- return (0, import_store.get)(this.observer);
75
- } else {
76
- throw err;
77
- }
78
- }
79
- }
80
- async loadNextPage(args) {
81
- const handlers = await this.#handlers();
82
- try {
83
- return await handlers.loadNextPage(args);
84
- } catch (e) {
85
- const err = e;
86
- if (err.name === "AbortError") {
87
- return (0, import_store.get)(this.observer);
88
- } else {
89
- throw err;
90
- }
91
- }
92
- }
93
- subscribe(run, invalidate) {
94
- const combined = (0, import_store.derived)([{ subscribe: super.subscribe.bind(this) }], ([$parent]) => {
95
- return {
96
- ...$parent,
97
- pageInfo: (0, import_pageInfo.extractPageInfo)($parent.data, this.artifact.refetch.path)
98
- };
99
- });
100
- return combined.subscribe(run, invalidate);
101
- }
102
- }
103
- class QueryStoreOffset extends import_query.QueryStore {
104
- paginated = true;
105
- async loadNextPage(args) {
106
- const handlers = await this.#handlers();
107
- return await handlers.loadNextPage.call(this, args);
108
- }
109
- async fetch(args) {
110
- const handlers = await this.#handlers();
111
- return await handlers.fetch.call(this, args);
112
- }
113
- #_handlers = null;
114
- async #handlers() {
115
- if (this.#_handlers) {
116
- return this.#_handlers;
117
- }
118
- const paginationObserver = (0, import_client.getClient)().observe({
119
- artifact: this.artifact
120
- });
121
- this.#_handlers = (0, import_pagination.offsetHandlers)({
122
- artifact: this.artifact,
123
- storeName: this.name,
124
- fetch: super.fetch.bind(this),
125
- getState: () => (0, import_store.get)(this.observer).data,
126
- getVariables: () => (0, import_store.get)(this.observer).variables,
127
- getSession: import_session.getSession,
128
- fetchUpdate: async (args) => {
129
- return paginationObserver.send({
130
- ...args,
131
- variables: {
132
- ...args?.variables
133
- },
134
- cacheParams: {
135
- applyUpdates: ["append"]
136
- }
137
- });
138
- }
139
- });
140
- return this.#_handlers;
141
- }
142
- }
143
- // Annotate the CommonJS export names for ESM import in node:
144
- 0 && (module.exports = {
145
- QueryStoreCursor,
146
- QueryStoreOffset
147
- });
@@ -1,58 +0,0 @@
1
- /// <reference types="svelte" />
2
- import type { DocumentStore } from '$houdini/runtime/client';
3
- import type { FragmentArtifact, GraphQLObject, HoudiniFetchContext, QueryArtifact, PageInfo, CursorHandlers, GraphQLVariables } from '$houdini/runtime/lib/types';
4
- import type { Readable, Subscriber } from 'svelte/store';
5
- import type { OffsetFragmentStoreInstance } from '../../types';
6
- import type { StoreConfig } from '../query';
7
- type FragmentStoreConfig<_Data extends GraphQLObject, _Input> = StoreConfig<_Data, _Input, FragmentArtifact> & {
8
- paginationArtifact: QueryArtifact;
9
- };
10
- declare class BasePaginatedFragmentStore<_Data extends GraphQLObject, _Input> {
11
- paginated: boolean;
12
- protected paginationArtifact: QueryArtifact;
13
- name: string;
14
- kind: "HoudiniFragment";
15
- artifact: FragmentArtifact;
16
- constructor(config: FragmentStoreConfig<_Data, _Input>);
17
- protected queryVariables(getState: () => _Data | null): _Input;
18
- }
19
- export declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends BasePaginatedFragmentStore<_Data, _Input> {
20
- get(initialValue: _Data | null): {
21
- kind: "HoudiniFragment";
22
- subscribe: (run: Subscriber<FragmentPaginatedResult<_Data, {
23
- pageInfo: PageInfo;
24
- }>>, invalidate?: ((value?: FragmentPaginatedResult<_Data, {
25
- pageInfo: PageInfo;
26
- }> | undefined) => void) | undefined) => (() => void);
27
- fetch: (args?: import("$houdini/runtime/lib/types").FetchParams<_Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
28
- loadNextPage: (args?: {
29
- first?: number | undefined;
30
- after?: string | undefined;
31
- fetch?: typeof fetch | undefined;
32
- metadata?: {} | undefined;
33
- } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
34
- loadPreviousPage: (args?: {
35
- last?: number | undefined;
36
- before?: string | undefined;
37
- fetch?: typeof fetch | undefined;
38
- metadata?: {} | undefined;
39
- } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
40
- };
41
- protected storeHandlers(observer: DocumentStore<_Data, _Input>, initialValue: _Data | null, getState: () => _Data | null, getVariables: () => NonNullable<_Input>): CursorHandlers<_Data, _Input>;
42
- }
43
- export declare class FragmentStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends BasePaginatedFragmentStore<_Data, _Input> {
44
- get(initialValue: _Data | null): OffsetFragmentStoreInstance<_Data, _Input>;
45
- }
46
- export type FragmentStorePaginated<_Data extends GraphQLObject, _Input> = Readable<{
47
- data: _Data;
48
- fetching: boolean;
49
- pageInfo: PageInfo;
50
- }> & {
51
- loadNextPage(pageCount?: number, after?: string | number, houdiniContext?: HoudiniFetchContext): Promise<void>;
52
- loadPreviousPage(pageCount?: number, before?: string, houdiniContext?: HoudiniFetchContext): Promise<void>;
53
- };
54
- export type FragmentPaginatedResult<_Data, _ExtraFields = {}> = {
55
- data: _Data | null;
56
- fetching: boolean;
57
- } & _ExtraFields;
58
- export {};