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
@@ -82652,10 +82652,10 @@ function plugin_config(config) {
82652
82652
  mutation: "../runtime/stores/mutation.MutationStore",
82653
82653
  fragment: "../runtime/stores/fragment.FragmentStore",
82654
82654
  subscription: "../runtime/stores/subscription.SubscriptionStore",
82655
- queryCursor: "../runtime/stores/pagination/query.QueryStoreCursor",
82656
- queryOffset: "../runtime/stores/pagination/query.QueryStoreOffset",
82657
- fragmentCursor: "../runtime/stores/pagination/fragment.FragmentStoreCursor",
82658
- fragmentOffset: "../runtime/stores/pagination/fragment.FragmentStoreOffset",
82655
+ queryCursor: "../runtime/stores/query.QueryStoreCursor",
82656
+ queryOffset: "../runtime/stores/query.QueryStoreOffset",
82657
+ fragmentCursor: "../runtime/stores/fragment.FragmentStoreCursor",
82658
+ fragmentOffset: "../runtime/stores/fragment.FragmentStoreOffset",
82659
82659
  ...cfg?.customStores
82660
82660
  }
82661
82661
  };
@@ -82648,10 +82648,10 @@ function plugin_config(config) {
82648
82648
  mutation: "../runtime/stores/mutation.MutationStore",
82649
82649
  fragment: "../runtime/stores/fragment.FragmentStore",
82650
82650
  subscription: "../runtime/stores/subscription.SubscriptionStore",
82651
- queryCursor: "../runtime/stores/pagination/query.QueryStoreCursor",
82652
- queryOffset: "../runtime/stores/pagination/query.QueryStoreOffset",
82653
- fragmentCursor: "../runtime/stores/pagination/fragment.FragmentStoreCursor",
82654
- fragmentOffset: "../runtime/stores/pagination/fragment.FragmentStoreOffset",
82651
+ queryCursor: "../runtime/stores/query.QueryStoreCursor",
82652
+ queryOffset: "../runtime/stores/query.QueryStoreOffset",
82653
+ fragmentCursor: "../runtime/stores/fragment.FragmentStoreCursor",
82654
+ fragmentOffset: "../runtime/stores/fragment.FragmentStoreOffset",
82655
82655
  ...cfg?.customStores
82656
82656
  }
82657
82657
  };
@@ -86584,10 +86584,10 @@ function plugin_config(config) {
86584
86584
  mutation: "../runtime/stores/mutation.MutationStore",
86585
86585
  fragment: "../runtime/stores/fragment.FragmentStore",
86586
86586
  subscription: "../runtime/stores/subscription.SubscriptionStore",
86587
- queryCursor: "../runtime/stores/pagination/query.QueryStoreCursor",
86588
- queryOffset: "../runtime/stores/pagination/query.QueryStoreOffset",
86589
- fragmentCursor: "../runtime/stores/pagination/fragment.FragmentStoreCursor",
86590
- fragmentOffset: "../runtime/stores/pagination/fragment.FragmentStoreOffset",
86587
+ queryCursor: "../runtime/stores/query.QueryStoreCursor",
86588
+ queryOffset: "../runtime/stores/query.QueryStoreOffset",
86589
+ fragmentCursor: "../runtime/stores/fragment.FragmentStoreCursor",
86590
+ fragmentOffset: "../runtime/stores/fragment.FragmentStoreOffset",
86591
86591
  ...cfg?.customStores
86592
86592
  }
86593
86593
  };
@@ -86581,10 +86581,10 @@ function plugin_config(config) {
86581
86581
  mutation: "../runtime/stores/mutation.MutationStore",
86582
86582
  fragment: "../runtime/stores/fragment.FragmentStore",
86583
86583
  subscription: "../runtime/stores/subscription.SubscriptionStore",
86584
- queryCursor: "../runtime/stores/pagination/query.QueryStoreCursor",
86585
- queryOffset: "../runtime/stores/pagination/query.QueryStoreOffset",
86586
- fragmentCursor: "../runtime/stores/pagination/fragment.FragmentStoreCursor",
86587
- fragmentOffset: "../runtime/stores/pagination/fragment.FragmentStoreOffset",
86584
+ queryCursor: "../runtime/stores/query.QueryStoreCursor",
86585
+ queryOffset: "../runtime/stores/query.QueryStoreOffset",
86586
+ fragmentCursor: "../runtime/stores/fragment.FragmentStoreCursor",
86587
+ fragmentOffset: "../runtime/stores/fragment.FragmentStoreOffset",
86588
86588
  ...cfg?.customStores
86589
86589
  }
86590
86590
  };
@@ -2,7 +2,7 @@
2
2
  import type { Fragment, FragmentArtifact } from '$houdini/runtime/lib/types';
3
3
  import type { Readable } from 'svelte/store';
4
4
  import type { FragmentStore } from './stores';
5
- import type { FragmentStorePaginated } from './stores/pagination/fragment';
5
+ import type { FragmentStorePaginated } from './stores/fragment';
6
6
  export declare function fragment<_Fragment extends Fragment<any>>(ref: _Fragment, fragment: FragmentStore<_Fragment['shape'], {}>): Readable<Exclude<_Fragment['shape'], undefined>> & {
7
7
  data: Readable<_Fragment>;
8
8
  artifact: FragmentArtifact;
@@ -1,6 +1,10 @@
1
- import type { GraphQLObject, FragmentArtifact, HoudiniFetchContext, GraphQLVariables } from '$houdini/runtime/lib/types';
1
+ /// <reference types="svelte" />
2
+ import type { DocumentStore } from '$houdini/runtime/client';
3
+ import type { GraphQLObject, FragmentArtifact, HoudiniFetchContext, GraphQLVariables, QueryArtifact, PageInfo, CursorHandlers } from '$houdini/runtime/lib/types';
2
4
  import { fragmentKey } from '$houdini/runtime/lib/types';
3
- import type { FragmentStoreInstance } from '../types';
5
+ import type { Readable, Subscriber } from 'svelte/store';
6
+ import type { FragmentStoreInstance, OffsetFragmentStoreInstance } from '../types';
7
+ import type { StoreConfig } from './query';
4
8
  export declare class FragmentStore<_Data extends GraphQLObject, _ReferenceType extends {}, _Input extends GraphQLVariables = GraphQLVariables> {
5
9
  artifact: FragmentArtifact;
6
10
  name: string;
@@ -16,3 +20,55 @@ export declare class FragmentStore<_Data extends GraphQLObject, _ReferenceType e
16
20
  initialValue: _Data | null;
17
21
  };
18
22
  }
23
+ type FragmentStoreConfig<_Data extends GraphQLObject, _Input> = StoreConfig<_Data, _Input, FragmentArtifact> & {
24
+ paginationArtifact: QueryArtifact;
25
+ };
26
+ declare class BasePaginatedFragmentStore<_Data extends GraphQLObject, _Input> {
27
+ paginated: boolean;
28
+ protected paginationArtifact: QueryArtifact;
29
+ name: string;
30
+ kind: "HoudiniFragment";
31
+ artifact: FragmentArtifact;
32
+ constructor(config: FragmentStoreConfig<_Data, _Input>);
33
+ protected queryVariables(getState: () => _Data | null): _Input;
34
+ }
35
+ export declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends BasePaginatedFragmentStore<_Data, _Input> {
36
+ get(initialValue: _Data | null): {
37
+ kind: "HoudiniFragment";
38
+ subscribe: (run: Subscriber<FragmentPaginatedResult<_Data, {
39
+ pageInfo: PageInfo;
40
+ }>>, invalidate?: ((value?: FragmentPaginatedResult<_Data, {
41
+ pageInfo: PageInfo;
42
+ }> | undefined) => void) | undefined) => (() => void);
43
+ fetch: (args?: import("$houdini/runtime/lib/types").FetchParams<_Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
44
+ loadNextPage: (args?: {
45
+ first?: number | undefined;
46
+ after?: string | undefined;
47
+ fetch?: typeof fetch | undefined;
48
+ metadata?: {} | undefined;
49
+ } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
50
+ loadPreviousPage: (args?: {
51
+ last?: number | undefined;
52
+ before?: string | undefined;
53
+ fetch?: typeof fetch | undefined;
54
+ metadata?: {} | undefined;
55
+ } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
56
+ };
57
+ protected storeHandlers(observer: DocumentStore<_Data, _Input>, initialValue: _Data | null, getState: () => _Data | null, getVariables: () => NonNullable<_Input>): CursorHandlers<_Data, _Input>;
58
+ }
59
+ export declare class FragmentStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends BasePaginatedFragmentStore<_Data, _Input> {
60
+ get(initialValue: _Data | null): OffsetFragmentStoreInstance<_Data, _Input>;
61
+ }
62
+ export type FragmentStorePaginated<_Data extends GraphQLObject, _Input> = Readable<{
63
+ data: _Data;
64
+ fetching: boolean;
65
+ pageInfo: PageInfo;
66
+ }> & {
67
+ loadNextPage(pageCount?: number, after?: string | number, houdiniContext?: HoudiniFetchContext): Promise<void>;
68
+ loadPreviousPage(pageCount?: number, before?: string, houdiniContext?: HoudiniFetchContext): Promise<void>;
69
+ };
70
+ export type FragmentPaginatedResult<_Data, _ExtraFields = {}> = {
71
+ data: _Data | null;
72
+ fetching: boolean;
73
+ } & _ExtraFields;
74
+ export {};
@@ -1,5 +1,4 @@
1
- export * from './pagination';
2
- export { FragmentStore } from './fragment';
1
+ export { FragmentStore, FragmentStoreCursor, FragmentStoreOffset } from './fragment';
3
2
  export { SubscriptionStore } from './subscription';
4
3
  export { MutationStore, type MutationConfig } from './mutation';
5
- export { QueryStore } from './query';
4
+ export { QueryStore, QueryStoreCursor, QueryStoreOffset } from './query';
@@ -1,5 +1,7 @@
1
+ /// <reference types="svelte" />
1
2
  import type { FetchContext } from '$houdini/runtime/client/plugins/fetch';
2
- import type { CachePolicies, GraphQLVariables, GraphQLObject, MutationArtifact, QueryArtifact, QueryResult } from '$houdini/runtime/lib/types';
3
+ import type { CachePolicies, GraphQLVariables, GraphQLObject, MutationArtifact, QueryArtifact, QueryResult, CursorHandlers, OffsetHandlers, PageInfo } from '$houdini/runtime/lib/types';
4
+ import type { Subscriber } from 'svelte/store';
3
5
  import type { PluginArtifactData } from '../../plugin/artifactData';
4
6
  import type { ClientFetchParams, LoadEventFetchParams, QueryStoreFetchParams, RequestEventFetchParams } from '../types';
5
7
  import { BaseStore } from './base';
@@ -31,3 +33,27 @@ export declare function fetchParams<_Data extends GraphQLObject, _Input>(artifac
31
33
  policy: CachePolicies | undefined;
32
34
  params: QueryStoreFetchParams<_Data, _Input>;
33
35
  }>;
36
+ export type CursorStoreResult<_Data extends GraphQLObject, _Input extends GraphQLVariables> = QueryResult<_Data, _Input> & {
37
+ pageInfo: PageInfo;
38
+ };
39
+ export declare class QueryStoreCursor<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
40
+ #private;
41
+ paginated: boolean;
42
+ constructor(config: StoreConfig<_Data, _Input, QueryArtifact>);
43
+ fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
44
+ fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
45
+ fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
46
+ fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
47
+ loadPreviousPage(args?: Parameters<Required<CursorHandlers<_Data, _Input>>['loadPreviousPage']>[0]): Promise<QueryResult<_Data, _Input>>;
48
+ loadNextPage(args?: Parameters<CursorHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<QueryResult<_Data, _Input>>;
49
+ subscribe(run: Subscriber<CursorStoreResult<_Data, _Input>>, invalidate?: ((value?: CursorStoreResult<_Data, _Input> | undefined) => void) | undefined): () => void;
50
+ }
51
+ export declare class QueryStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
52
+ #private;
53
+ paginated: boolean;
54
+ loadNextPage(args?: Parameters<OffsetHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<void>;
55
+ fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
56
+ fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
57
+ fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
58
+ fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
59
+ }
@@ -2,7 +2,7 @@
2
2
  import type { Fragment, FragmentArtifact } from '$houdini/runtime/lib/types';
3
3
  import type { Readable } from 'svelte/store';
4
4
  import type { FragmentStore } from './stores';
5
- import type { FragmentStorePaginated } from './stores/pagination/fragment';
5
+ import type { FragmentStorePaginated } from './stores/fragment';
6
6
  export declare function fragment<_Fragment extends Fragment<any>>(ref: _Fragment, fragment: FragmentStore<_Fragment['shape'], {}>): Readable<Exclude<_Fragment['shape'], undefined>> & {
7
7
  data: Readable<_Fragment>;
8
8
  artifact: FragmentArtifact;
@@ -1,6 +1,10 @@
1
- import type { GraphQLObject, FragmentArtifact, HoudiniFetchContext, GraphQLVariables } from '$houdini/runtime/lib/types';
1
+ /// <reference types="svelte" />
2
+ import type { DocumentStore } from '$houdini/runtime/client';
3
+ import type { GraphQLObject, FragmentArtifact, HoudiniFetchContext, GraphQLVariables, QueryArtifact, PageInfo, CursorHandlers } from '$houdini/runtime/lib/types';
2
4
  import { fragmentKey } from '$houdini/runtime/lib/types';
3
- import type { FragmentStoreInstance } from '../types';
5
+ import type { Readable, Subscriber } from 'svelte/store';
6
+ import type { FragmentStoreInstance, OffsetFragmentStoreInstance } from '../types';
7
+ import type { StoreConfig } from './query';
4
8
  export declare class FragmentStore<_Data extends GraphQLObject, _ReferenceType extends {}, _Input extends GraphQLVariables = GraphQLVariables> {
5
9
  artifact: FragmentArtifact;
6
10
  name: string;
@@ -16,3 +20,55 @@ export declare class FragmentStore<_Data extends GraphQLObject, _ReferenceType e
16
20
  initialValue: _Data | null;
17
21
  };
18
22
  }
23
+ type FragmentStoreConfig<_Data extends GraphQLObject, _Input> = StoreConfig<_Data, _Input, FragmentArtifact> & {
24
+ paginationArtifact: QueryArtifact;
25
+ };
26
+ declare class BasePaginatedFragmentStore<_Data extends GraphQLObject, _Input> {
27
+ paginated: boolean;
28
+ protected paginationArtifact: QueryArtifact;
29
+ name: string;
30
+ kind: "HoudiniFragment";
31
+ artifact: FragmentArtifact;
32
+ constructor(config: FragmentStoreConfig<_Data, _Input>);
33
+ protected queryVariables(getState: () => _Data | null): _Input;
34
+ }
35
+ export declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends BasePaginatedFragmentStore<_Data, _Input> {
36
+ get(initialValue: _Data | null): {
37
+ kind: "HoudiniFragment";
38
+ subscribe: (run: Subscriber<FragmentPaginatedResult<_Data, {
39
+ pageInfo: PageInfo;
40
+ }>>, invalidate?: ((value?: FragmentPaginatedResult<_Data, {
41
+ pageInfo: PageInfo;
42
+ }> | undefined) => void) | undefined) => (() => void);
43
+ fetch: (args?: import("$houdini/runtime/lib/types").FetchParams<_Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
44
+ loadNextPage: (args?: {
45
+ first?: number | undefined;
46
+ after?: string | undefined;
47
+ fetch?: typeof fetch | undefined;
48
+ metadata?: {} | undefined;
49
+ } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
50
+ loadPreviousPage: (args?: {
51
+ last?: number | undefined;
52
+ before?: string | undefined;
53
+ fetch?: typeof fetch | undefined;
54
+ metadata?: {} | undefined;
55
+ } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
56
+ };
57
+ protected storeHandlers(observer: DocumentStore<_Data, _Input>, initialValue: _Data | null, getState: () => _Data | null, getVariables: () => NonNullable<_Input>): CursorHandlers<_Data, _Input>;
58
+ }
59
+ export declare class FragmentStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends BasePaginatedFragmentStore<_Data, _Input> {
60
+ get(initialValue: _Data | null): OffsetFragmentStoreInstance<_Data, _Input>;
61
+ }
62
+ export type FragmentStorePaginated<_Data extends GraphQLObject, _Input> = Readable<{
63
+ data: _Data;
64
+ fetching: boolean;
65
+ pageInfo: PageInfo;
66
+ }> & {
67
+ loadNextPage(pageCount?: number, after?: string | number, houdiniContext?: HoudiniFetchContext): Promise<void>;
68
+ loadPreviousPage(pageCount?: number, before?: string, houdiniContext?: HoudiniFetchContext): Promise<void>;
69
+ };
70
+ export type FragmentPaginatedResult<_Data, _ExtraFields = {}> = {
71
+ data: _Data | null;
72
+ fetching: boolean;
73
+ } & _ExtraFields;
74
+ export {};
@@ -24,15 +24,22 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
25
  var fragment_exports = {};
26
26
  __export(fragment_exports, {
27
- FragmentStore: () => FragmentStore
27
+ FragmentStore: () => FragmentStore,
28
+ FragmentStoreCursor: () => FragmentStoreCursor,
29
+ FragmentStoreOffset: () => FragmentStoreOffset
28
30
  });
29
31
  module.exports = __toCommonJS(fragment_exports);
30
32
  var import_cache = __toESM(require("$houdini/runtime/cache"), 1);
31
33
  var import_config = require("$houdini/runtime/lib/config");
34
+ var import_constants = require("$houdini/runtime/lib/constants");
35
+ var import_pageInfo = require("$houdini/runtime/lib/pageInfo");
36
+ var import_pagination = require("$houdini/runtime/lib/pagination");
32
37
  var import_scalars = require("$houdini/runtime/lib/scalars");
33
38
  var import_types = require("$houdini/runtime/lib/types");
34
39
  var import_store = require("svelte/store");
35
40
  var import_adapter = require("../adapter");
41
+ var import_client = require("../client");
42
+ var import_session = require("../session");
36
43
  var import_base = require("./base");
37
44
  class FragmentStore {
38
45
  artifact;
@@ -81,7 +88,178 @@ Please ensure that you have passed a record that has ${this.artifact.name} mixed
81
88
  };
82
89
  }
83
90
  }
91
+ class BasePaginatedFragmentStore {
92
+ paginated = true;
93
+ paginationArtifact;
94
+ name;
95
+ kind = import_types.CompiledFragmentKind;
96
+ artifact;
97
+ constructor(config) {
98
+ this.paginationArtifact = config.paginationArtifact;
99
+ this.name = config.storeName;
100
+ this.artifact = config.artifact;
101
+ }
102
+ queryVariables(getState) {
103
+ const config = (0, import_config.getCurrentConfig)();
104
+ const { targetType } = this.paginationArtifact.refetch || {};
105
+ const typeConfig = config.types?.[targetType || ""];
106
+ if (!typeConfig) {
107
+ throw new Error(
108
+ `Missing type refetch configuration for ${targetType}. For more information, see ${import_constants.siteURL}/guides/pagination#paginated-fragments`
109
+ );
110
+ }
111
+ let idVariables = {};
112
+ const value = getState();
113
+ if (typeConfig.resolve?.arguments) {
114
+ idVariables = typeConfig.resolve.arguments?.(value) || {};
115
+ } else {
116
+ const keys = (0, import_config.keyFieldsForType)(config, targetType || "");
117
+ idVariables = Object.fromEntries(keys.map((key) => [key, value[key]]));
118
+ }
119
+ return {
120
+ ...idVariables
121
+ };
122
+ }
123
+ }
124
+ class FragmentStoreCursor extends BasePaginatedFragmentStore {
125
+ get(initialValue) {
126
+ const base = new FragmentStore({
127
+ artifact: this.artifact,
128
+ storeName: this.name
129
+ });
130
+ const store = base.get(initialValue);
131
+ const paginationStore = (0, import_client.getClient)().observe({
132
+ artifact: this.paginationArtifact,
133
+ initialValue: store.initialValue
134
+ });
135
+ const handlers = this.storeHandlers(
136
+ paginationStore,
137
+ initialValue,
138
+ () => (0, import_store.get)(store),
139
+ () => store.variables
140
+ );
141
+ const subscribe = (run, invalidate) => {
142
+ const combined = (0, import_store.derived)([store, paginationStore], ([$parent, $pagination]) => {
143
+ return {
144
+ ...$pagination,
145
+ data: $parent,
146
+ pageInfo: (0, import_pageInfo.extractPageInfo)($parent, this.paginationArtifact.refetch.path)
147
+ };
148
+ });
149
+ return combined.subscribe(run, invalidate);
150
+ };
151
+ return {
152
+ kind: import_types.CompiledFragmentKind,
153
+ subscribe,
154
+ fetch: handlers.fetch,
155
+ loadNextPage: handlers.loadNextPage,
156
+ loadPreviousPage: handlers.loadPreviousPage
157
+ };
158
+ }
159
+ storeHandlers(observer, initialValue, getState, getVariables) {
160
+ return (0, import_pagination.cursorHandlers)({
161
+ getState,
162
+ getVariables,
163
+ artifact: this.paginationArtifact,
164
+ fetchUpdate: async (args, updates) => {
165
+ return observer.send({
166
+ session: await (0, import_session.getSession)(),
167
+ ...args,
168
+ variables: {
169
+ ...args?.variables,
170
+ ...this.queryVariables(getState)
171
+ },
172
+ cacheParams: {
173
+ applyUpdates: updates,
174
+ disableSubscriptions: true
175
+ }
176
+ });
177
+ },
178
+ fetch: async (args) => {
179
+ return await observer.send({
180
+ session: await (0, import_session.getSession)(),
181
+ ...args,
182
+ variables: {
183
+ ...args?.variables,
184
+ ...this.queryVariables(getState)
185
+ },
186
+ cacheParams: {
187
+ disableSubscriptions: true
188
+ }
189
+ });
190
+ },
191
+ getSession: import_session.getSession
192
+ });
193
+ }
194
+ }
195
+ class FragmentStoreOffset extends BasePaginatedFragmentStore {
196
+ get(initialValue) {
197
+ const base = new FragmentStore({
198
+ artifact: this.artifact,
199
+ storeName: this.name
200
+ });
201
+ const store = base.get(initialValue);
202
+ const paginationStore = (0, import_client.getClient)().observe({
203
+ artifact: this.paginationArtifact,
204
+ initialValue: store.initialValue
205
+ });
206
+ const getState = () => (0, import_store.get)(store);
207
+ const handlers = (0, import_pagination.offsetHandlers)({
208
+ getState,
209
+ getVariables: () => store.variables,
210
+ artifact: this.paginationArtifact,
211
+ fetch: async (args) => {
212
+ return paginationStore.send({
213
+ ...args,
214
+ session: await (0, import_session.getSession)(),
215
+ variables: {
216
+ ...this.queryVariables(getState),
217
+ ...args?.variables
218
+ },
219
+ cacheParams: {
220
+ disableSubscriptions: true
221
+ }
222
+ });
223
+ },
224
+ fetchUpdate: async (args) => {
225
+ return paginationStore.send({
226
+ session: await (0, import_session.getSession)(),
227
+ ...args,
228
+ variables: {
229
+ ...this.queryVariables(getState),
230
+ ...args?.variables
231
+ },
232
+ cacheParams: {
233
+ disableSubscriptions: true,
234
+ applyUpdates: ["append"]
235
+ }
236
+ });
237
+ },
238
+ getSession: import_session.getSession,
239
+ storeName: this.name
240
+ });
241
+ const subscribe = (run, invalidate) => {
242
+ const combined = (0, import_store.derived)([store, paginationStore], ([$parent, $pagination]) => {
243
+ return {
244
+ ...$pagination,
245
+ data: $parent
246
+ };
247
+ });
248
+ return combined.subscribe(run, invalidate);
249
+ };
250
+ return {
251
+ kind: import_types.CompiledFragmentKind,
252
+ data: (0, import_store.derived)(paginationStore, ($value) => $value.data),
253
+ subscribe,
254
+ fetch: handlers.fetch,
255
+ loadNextPage: handlers.loadNextPage,
256
+ fetching: (0, import_store.derived)(paginationStore, ($store) => $store.fetching)
257
+ };
258
+ }
259
+ }
84
260
  // Annotate the CommonJS export names for ESM import in node:
85
261
  0 && (module.exports = {
86
- FragmentStore
262
+ FragmentStore,
263
+ FragmentStoreCursor,
264
+ FragmentStoreOffset
87
265
  });
@@ -1,5 +1,4 @@
1
- export * from './pagination';
2
- export { FragmentStore } from './fragment';
1
+ export { FragmentStore, FragmentStoreCursor, FragmentStoreOffset } from './fragment';
3
2
  export { SubscriptionStore } from './subscription';
4
3
  export { MutationStore, type MutationConfig } from './mutation';
5
- export { QueryStore } from './query';
4
+ export { QueryStore, QueryStoreCursor, QueryStoreOffset } from './query';
@@ -15,17 +15,19 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
19
  var stores_exports = {};
21
20
  __export(stores_exports, {
22
21
  FragmentStore: () => import_fragment.FragmentStore,
22
+ FragmentStoreCursor: () => import_fragment.FragmentStoreCursor,
23
+ FragmentStoreOffset: () => import_fragment.FragmentStoreOffset,
23
24
  MutationStore: () => import_mutation.MutationStore,
24
25
  QueryStore: () => import_query.QueryStore,
26
+ QueryStoreCursor: () => import_query.QueryStoreCursor,
27
+ QueryStoreOffset: () => import_query.QueryStoreOffset,
25
28
  SubscriptionStore: () => import_subscription.SubscriptionStore
26
29
  });
27
30
  module.exports = __toCommonJS(stores_exports);
28
- __reExport(stores_exports, require("./pagination"), module.exports);
29
31
  var import_fragment = require("./fragment");
30
32
  var import_subscription = require("./subscription");
31
33
  var import_mutation = require("./mutation");
@@ -33,7 +35,11 @@ var import_query = require("./query");
33
35
  // Annotate the CommonJS export names for ESM import in node:
34
36
  0 && (module.exports = {
35
37
  FragmentStore,
38
+ FragmentStoreCursor,
39
+ FragmentStoreOffset,
36
40
  MutationStore,
37
41
  QueryStore,
42
+ QueryStoreCursor,
43
+ QueryStoreOffset,
38
44
  SubscriptionStore
39
45
  });
@@ -1,5 +1,7 @@
1
+ /// <reference types="svelte" />
1
2
  import type { FetchContext } from '$houdini/runtime/client/plugins/fetch';
2
- import type { CachePolicies, GraphQLVariables, GraphQLObject, MutationArtifact, QueryArtifact, QueryResult } from '$houdini/runtime/lib/types';
3
+ import type { CachePolicies, GraphQLVariables, GraphQLObject, MutationArtifact, QueryArtifact, QueryResult, CursorHandlers, OffsetHandlers, PageInfo } from '$houdini/runtime/lib/types';
4
+ import type { Subscriber } from 'svelte/store';
3
5
  import type { PluginArtifactData } from '../../plugin/artifactData';
4
6
  import type { ClientFetchParams, LoadEventFetchParams, QueryStoreFetchParams, RequestEventFetchParams } from '../types';
5
7
  import { BaseStore } from './base';
@@ -31,3 +33,27 @@ export declare function fetchParams<_Data extends GraphQLObject, _Input>(artifac
31
33
  policy: CachePolicies | undefined;
32
34
  params: QueryStoreFetchParams<_Data, _Input>;
33
35
  }>;
36
+ export type CursorStoreResult<_Data extends GraphQLObject, _Input extends GraphQLVariables> = QueryResult<_Data, _Input> & {
37
+ pageInfo: PageInfo;
38
+ };
39
+ export declare class QueryStoreCursor<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
40
+ #private;
41
+ paginated: boolean;
42
+ constructor(config: StoreConfig<_Data, _Input, QueryArtifact>);
43
+ fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
44
+ fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
45
+ fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
46
+ fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
47
+ loadPreviousPage(args?: Parameters<Required<CursorHandlers<_Data, _Input>>['loadPreviousPage']>[0]): Promise<QueryResult<_Data, _Input>>;
48
+ loadNextPage(args?: Parameters<CursorHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<QueryResult<_Data, _Input>>;
49
+ subscribe(run: Subscriber<CursorStoreResult<_Data, _Input>>, invalidate?: ((value?: CursorStoreResult<_Data, _Input> | undefined) => void) | undefined): () => void;
50
+ }
51
+ export declare class QueryStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
52
+ #private;
53
+ paginated: boolean;
54
+ loadNextPage(args?: Parameters<OffsetHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<void>;
55
+ fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
56
+ fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
57
+ fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
58
+ fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
59
+ }