houdini-svelte 1.1.3 → 1.1.4-react.0

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 (46) hide show
  1. package/build/plugin-cjs/index.js +261 -225
  2. package/build/plugin-esm/index.js +261 -225
  3. package/build/preprocess-cjs/index.js +272 -225
  4. package/build/preprocess-esm/index.js +272 -225
  5. package/build/runtime/stores/index.d.ts +1 -1
  6. package/build/runtime/stores/pagination/fragment.d.ts +4 -7
  7. package/build/runtime/stores/pagination/query.d.ts +3 -4
  8. package/build/runtime/stores/query.d.ts +2 -54
  9. package/build/runtime/types.d.ts +40 -28
  10. package/build/runtime-cjs/stores/index.d.ts +1 -1
  11. package/build/runtime-cjs/stores/pagination/fragment.d.ts +4 -7
  12. package/build/runtime-cjs/stores/pagination/fragment.js +6 -9
  13. package/build/runtime-cjs/stores/pagination/query.d.ts +3 -4
  14. package/build/runtime-cjs/stores/pagination/query.js +10 -9
  15. package/build/runtime-cjs/stores/query.d.ts +2 -54
  16. package/build/runtime-cjs/types.d.ts +40 -28
  17. package/build/runtime-esm/stores/index.d.ts +1 -1
  18. package/build/runtime-esm/stores/pagination/fragment.d.ts +4 -7
  19. package/build/runtime-esm/stores/pagination/fragment.js +4 -7
  20. package/build/runtime-esm/stores/pagination/query.d.ts +3 -4
  21. package/build/runtime-esm/stores/pagination/query.js +5 -4
  22. package/build/runtime-esm/stores/query.d.ts +2 -54
  23. package/build/runtime-esm/types.d.ts +40 -28
  24. package/build/test-cjs/index.js +601 -491
  25. package/build/test-esm/index.js +601 -491
  26. package/package.json +2 -2
  27. package/build/runtime/stores/pagination/cursor.d.ts +0 -13
  28. package/build/runtime/stores/pagination/fetch.d.ts +0 -3
  29. package/build/runtime/stores/pagination/offset.d.ts +0 -20
  30. package/build/runtime/stores/pagination/pageInfo.d.ts +0 -13
  31. package/build/runtime-cjs/stores/pagination/cursor.d.ts +0 -13
  32. package/build/runtime-cjs/stores/pagination/cursor.js +0 -191
  33. package/build/runtime-cjs/stores/pagination/fetch.d.ts +0 -3
  34. package/build/runtime-cjs/stores/pagination/fetch.js +0 -16
  35. package/build/runtime-cjs/stores/pagination/offset.d.ts +0 -20
  36. package/build/runtime-cjs/stores/pagination/offset.js +0 -89
  37. package/build/runtime-cjs/stores/pagination/pageInfo.d.ts +0 -13
  38. package/build/runtime-cjs/stores/pagination/pageInfo.js +0 -79
  39. package/build/runtime-esm/stores/pagination/cursor.d.ts +0 -13
  40. package/build/runtime-esm/stores/pagination/cursor.js +0 -167
  41. package/build/runtime-esm/stores/pagination/fetch.d.ts +0 -3
  42. package/build/runtime-esm/stores/pagination/fetch.js +0 -0
  43. package/build/runtime-esm/stores/pagination/offset.d.ts +0 -20
  44. package/build/runtime-esm/stores/pagination/offset.js +0 -65
  45. package/build/runtime-esm/stores/pagination/pageInfo.d.ts +0 -13
  46. package/build/runtime-esm/stores/pagination/pageInfo.js +0 -52
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-svelte",
3
- "version": "1.1.3",
3
+ "version": "1.1.4-react.0",
4
4
  "description": "The svelte plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -32,7 +32,7 @@
32
32
  "rollup": "^3.7.4",
33
33
  "svelte": "^3.57.0",
34
34
  "vite": "^4.1.1",
35
- "houdini": "^1.1.3"
35
+ "houdini": "^1.1.4-react.0"
36
36
  },
37
37
  "files": [
38
38
  "build"
@@ -1,13 +0,0 @@
1
- import type { SendParams } from '$houdini/runtime/client/documentStore';
2
- import type { GraphQLObject, QueryArtifact } from '$houdini/runtime/lib/types';
3
- import type { CursorHandlers } from '../../types';
4
- import type { FetchFn } from './fetch';
5
- export declare function cursorHandlers<_Data extends GraphQLObject, _Input extends Record<string, any>>({ artifact, storeName, initialValue, fetchUpdate: parentFetchUpdate, fetch: parentFetch, getState, getVariables, }: {
6
- artifact: QueryArtifact;
7
- storeName: string;
8
- fetch: FetchFn<_Data, _Input>;
9
- getState: () => _Data | null;
10
- getVariables: () => _Input;
11
- initialValue: _Data | null;
12
- fetchUpdate: (arg: SendParams, updates: string[]) => ReturnType<FetchFn<_Data, _Input>>;
13
- }): CursorHandlers<_Data, _Input>;
@@ -1,3 +0,0 @@
1
- import type { GraphQLObject, QueryResult } from '$houdini/runtime/lib/types';
2
- import type { QueryStoreFetchParams } from '../query';
3
- export type FetchFn<_Data extends GraphQLObject, _Input = any> = (params?: QueryStoreFetchParams<_Data, _Input>) => Promise<QueryResult<_Data, _Input>>;
@@ -1,20 +0,0 @@
1
- import type { SendParams } from '$houdini/runtime/client/documentStore';
2
- import type { GraphQLObject, QueryArtifact, QueryResult } from '$houdini/runtime/lib/types';
3
- import type { QueryStoreFetchParams } from '../query';
4
- import type { FetchFn } from './fetch';
5
- export declare function offsetHandlers<_Data extends GraphQLObject, _Input extends {}>({ artifact, storeName, getState, getVariables, fetch: parentFetch, fetchUpdate: parentFetchUpdate, }: {
6
- artifact: QueryArtifact;
7
- fetch: FetchFn<_Data, _Input>;
8
- fetchUpdate: (arg: SendParams) => ReturnType<FetchFn<_Data, _Input>>;
9
- storeName: string;
10
- getState: () => _Data | null;
11
- getVariables: () => _Input;
12
- }): {
13
- loadNextPage: ({ limit, offset, fetch, metadata, }?: {
14
- limit?: number | undefined;
15
- offset?: number | undefined;
16
- fetch?: typeof fetch | undefined;
17
- metadata?: {} | undefined;
18
- }) => Promise<void>;
19
- fetch(args?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
20
- };
@@ -1,13 +0,0 @@
1
- import type { GraphQLObject } from '$houdini/runtime/lib/types';
2
- export declare function nullPageInfo(): PageInfo;
3
- export type PageInfo = {
4
- startCursor: string | null;
5
- endCursor: string | null;
6
- hasNextPage: boolean;
7
- hasPreviousPage: boolean;
8
- };
9
- export declare function missingPageSizeError(fnName: string): {
10
- message: string;
11
- };
12
- export declare function extractPageInfo(data: any, path: string[]): PageInfo;
13
- export declare function countPage<_Data extends GraphQLObject>(source: string[], value: _Data | null): number;
@@ -1,13 +0,0 @@
1
- import type { SendParams } from '$houdini/runtime/client/documentStore';
2
- import type { GraphQLObject, QueryArtifact } from '$houdini/runtime/lib/types';
3
- import type { CursorHandlers } from '../../types';
4
- import type { FetchFn } from './fetch';
5
- export declare function cursorHandlers<_Data extends GraphQLObject, _Input extends Record<string, any>>({ artifact, storeName, initialValue, fetchUpdate: parentFetchUpdate, fetch: parentFetch, getState, getVariables, }: {
6
- artifact: QueryArtifact;
7
- storeName: string;
8
- fetch: FetchFn<_Data, _Input>;
9
- getState: () => _Data | null;
10
- getVariables: () => _Input;
11
- initialValue: _Data | null;
12
- fetchUpdate: (arg: SendParams, updates: string[]) => ReturnType<FetchFn<_Data, _Input>>;
13
- }): CursorHandlers<_Data, _Input>;
@@ -1,191 +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 cursor_exports = {};
20
- __export(cursor_exports, {
21
- cursorHandlers: () => cursorHandlers
22
- });
23
- module.exports = __toCommonJS(cursor_exports);
24
- var import_lib = require("$houdini/runtime/lib");
25
- var import_config = require("$houdini/runtime/lib/config");
26
- var import_constants = require("$houdini/runtime/lib/constants");
27
- var import_deepEquals = require("$houdini/runtime/lib/deepEquals");
28
- var import_store = require("svelte/store");
29
- var import_session = require("../../session");
30
- var import_query = require("../query");
31
- var import_pageInfo = require("./pageInfo");
32
- function cursorHandlers({
33
- artifact,
34
- storeName,
35
- initialValue,
36
- fetchUpdate: parentFetchUpdate,
37
- fetch: parentFetch,
38
- getState,
39
- getVariables
40
- }) {
41
- const pageInfo = (0, import_store.writable)((0, import_pageInfo.extractPageInfo)(initialValue, artifact.refetch.path));
42
- const loadPage = async ({
43
- pageSizeVar,
44
- input,
45
- functionName,
46
- metadata = {},
47
- fetch,
48
- where
49
- }) => {
50
- const config = (0, import_config.getCurrentConfig)();
51
- const loadVariables = {
52
- ...getVariables(),
53
- ...input
54
- };
55
- if (!loadVariables[pageSizeVar] && !artifact.refetch.pageSize) {
56
- throw (0, import_pageInfo.missingPageSizeError)(functionName);
57
- }
58
- let isSinglePage = artifact.refetch?.mode === "SinglePage";
59
- const targetFetch = isSinglePage ? parentFetch : parentFetchUpdate;
60
- const { data } = await targetFetch(
61
- {
62
- variables: loadVariables,
63
- fetch,
64
- metadata,
65
- policy: isSinglePage ? artifact.policy : import_lib.CachePolicy.NetworkOnly,
66
- session: await (0, import_session.getSession)()
67
- },
68
- isSinglePage ? [] : [where === "start" ? "prepend" : "append"]
69
- );
70
- const resultPath = [...artifact.refetch.path];
71
- if (artifact.refetch.embedded) {
72
- const { targetType } = artifact.refetch;
73
- if (!config.types?.[targetType]?.resolve) {
74
- throw new Error(
75
- `Missing type resolve configuration for ${targetType}. For more information, see ${import_constants.siteURL}/guides/pagination#paginated-fragments`
76
- );
77
- }
78
- resultPath.unshift(config.types[targetType].resolve.queryField);
79
- }
80
- pageInfo.set((0, import_pageInfo.extractPageInfo)(data, resultPath));
81
- };
82
- const getPageInfo = () => {
83
- return (0, import_pageInfo.extractPageInfo)(getState(), artifact.refetch?.path ?? []);
84
- };
85
- return {
86
- loadNextPage: async ({
87
- first,
88
- after,
89
- fetch,
90
- metadata
91
- } = {}) => {
92
- if (artifact.refetch?.direction === "backward") {
93
- console.warn(`\u26A0\uFE0F ${storeName}.loadNextPage was called but it does not support forwards pagination.
94
- If you think this is an error, please open an issue on GitHub`);
95
- return;
96
- }
97
- const currentPageInfo = getPageInfo();
98
- if (!currentPageInfo.hasNextPage) {
99
- return;
100
- }
101
- const input = {
102
- first: first ?? artifact.refetch.pageSize,
103
- after: after ?? currentPageInfo.endCursor,
104
- before: null,
105
- last: null
106
- };
107
- return await loadPage({
108
- pageSizeVar: "first",
109
- functionName: "loadNextPage",
110
- input,
111
- fetch,
112
- metadata,
113
- where: "end"
114
- });
115
- },
116
- loadPreviousPage: async ({
117
- last,
118
- before,
119
- fetch,
120
- metadata
121
- } = {}) => {
122
- if (artifact.refetch?.direction === "forward") {
123
- console.warn(`\u26A0\uFE0F ${storeName}.loadPreviousPage was called but it does not support backwards pagination.
124
- If you think this is an error, please open an issue on GitHub`);
125
- return;
126
- }
127
- const currentPageInfo = getPageInfo();
128
- if (!currentPageInfo.hasPreviousPage) {
129
- return;
130
- }
131
- const input = {
132
- before: before ?? currentPageInfo.startCursor,
133
- last: last ?? artifact.refetch.pageSize,
134
- first: null,
135
- after: null
136
- };
137
- return await loadPage({
138
- pageSizeVar: "last",
139
- functionName: "loadPreviousPage",
140
- input,
141
- fetch,
142
- metadata,
143
- where: "start"
144
- });
145
- },
146
- pageInfo,
147
- async fetch(args) {
148
- const { params } = await (0, import_query.fetchParams)(artifact, storeName, args);
149
- const { variables } = params ?? {};
150
- if (variables && !(0, import_deepEquals.deepEquals)(getVariables(), variables)) {
151
- return await parentFetch(params);
152
- }
153
- try {
154
- var currentPageInfo = (0, import_pageInfo.extractPageInfo)(getState(), artifact.refetch.path);
155
- } catch {
156
- return await parentFetch(params);
157
- }
158
- const queryVariables = {};
159
- const count = (0, import_pageInfo.countPage)(artifact.refetch.path.concat("edges"), getState()) || artifact.refetch.pageSize;
160
- if (count && count > artifact.refetch.pageSize) {
161
- if (currentPageInfo.hasPreviousPage && currentPageInfo.hasNextPage && !(variables?.["first"] && variables?.["after"] || variables?.["last"] && variables?.["before"])) {
162
- console.warn(`\u26A0\uFE0F Encountered a fetch() in the middle of the connection.
163
- Make sure to pass a cursor value by hand that includes the current set (ie the entry before startCursor)
164
- `);
165
- }
166
- if (!currentPageInfo.hasPreviousPage) {
167
- queryVariables["first"] = count;
168
- queryVariables["after"] = null;
169
- queryVariables["last"] = null;
170
- queryVariables["before"] = null;
171
- } else if (!currentPageInfo.hasNextPage) {
172
- queryVariables["last"] = count;
173
- queryVariables["first"] = null;
174
- queryVariables["after"] = null;
175
- queryVariables["before"] = null;
176
- }
177
- }
178
- Object.assign(queryVariables, variables ?? {});
179
- const result = await parentFetch({
180
- ...params,
181
- variables: queryVariables
182
- });
183
- pageInfo.set((0, import_pageInfo.extractPageInfo)(result.data, artifact.refetch.path));
184
- return result;
185
- }
186
- };
187
- }
188
- // Annotate the CommonJS export names for ESM import in node:
189
- 0 && (module.exports = {
190
- cursorHandlers
191
- });
@@ -1,3 +0,0 @@
1
- import type { GraphQLObject, QueryResult } from '$houdini/runtime/lib/types';
2
- import type { QueryStoreFetchParams } from '../query';
3
- export type FetchFn<_Data extends GraphQLObject, _Input = any> = (params?: QueryStoreFetchParams<_Data, _Input>) => Promise<QueryResult<_Data, _Input>>;
@@ -1,16 +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 __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var fetch_exports = {};
16
- module.exports = __toCommonJS(fetch_exports);
@@ -1,20 +0,0 @@
1
- import type { SendParams } from '$houdini/runtime/client/documentStore';
2
- import type { GraphQLObject, QueryArtifact, QueryResult } from '$houdini/runtime/lib/types';
3
- import type { QueryStoreFetchParams } from '../query';
4
- import type { FetchFn } from './fetch';
5
- export declare function offsetHandlers<_Data extends GraphQLObject, _Input extends {}>({ artifact, storeName, getState, getVariables, fetch: parentFetch, fetchUpdate: parentFetchUpdate, }: {
6
- artifact: QueryArtifact;
7
- fetch: FetchFn<_Data, _Input>;
8
- fetchUpdate: (arg: SendParams) => ReturnType<FetchFn<_Data, _Input>>;
9
- storeName: string;
10
- getState: () => _Data | null;
11
- getVariables: () => _Input;
12
- }): {
13
- loadNextPage: ({ limit, offset, fetch, metadata, }?: {
14
- limit?: number | undefined;
15
- offset?: number | undefined;
16
- fetch?: typeof fetch | undefined;
17
- metadata?: {} | undefined;
18
- }) => Promise<void>;
19
- fetch(args?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
20
- };
@@ -1,89 +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 offset_exports = {};
20
- __export(offset_exports, {
21
- offsetHandlers: () => offsetHandlers
22
- });
23
- module.exports = __toCommonJS(offset_exports);
24
- var import_lib = require("$houdini/runtime/lib");
25
- var import_deepEquals = require("$houdini/runtime/lib/deepEquals");
26
- var import_session = require("../../session");
27
- var import_query = require("../query");
28
- var import_pageInfo = require("./pageInfo");
29
- function offsetHandlers({
30
- artifact,
31
- storeName,
32
- getState,
33
- getVariables,
34
- fetch: parentFetch,
35
- fetchUpdate: parentFetchUpdate
36
- }) {
37
- let getOffset = () => artifact.refetch?.start || (0, import_pageInfo.countPage)(artifact.refetch.path, getState()) || artifact.refetch.pageSize;
38
- let currentOffset = getOffset() ?? 0;
39
- return {
40
- loadNextPage: async ({
41
- limit,
42
- offset,
43
- fetch,
44
- metadata
45
- } = {}) => {
46
- const queryVariables = {
47
- ...getVariables(),
48
- offset: offset ?? getOffset()
49
- };
50
- if (limit || limit === 0) {
51
- queryVariables.limit = limit;
52
- }
53
- if (!queryVariables.limit && !artifact.refetch.pageSize) {
54
- throw (0, import_pageInfo.missingPageSizeError)("loadNextPage");
55
- }
56
- let isSinglePage = artifact.refetch?.mode === "SinglePage";
57
- const targetFetch = isSinglePage ? parentFetch : parentFetchUpdate;
58
- await targetFetch({
59
- variables: queryVariables,
60
- fetch,
61
- metadata,
62
- policy: isSinglePage ? artifact.policy : import_lib.CachePolicy.NetworkOnly,
63
- session: await (0, import_session.getSession)()
64
- });
65
- const pageSize = queryVariables.limit || artifact.refetch.pageSize;
66
- currentOffset = offset + pageSize;
67
- },
68
- async fetch(args) {
69
- const { params } = await (0, import_query.fetchParams)(artifact, storeName, args);
70
- const { variables } = params ?? {};
71
- if (variables && !(0, import_deepEquals.deepEquals)(getVariables(), variables)) {
72
- return parentFetch.call(this, params);
73
- }
74
- const count = currentOffset || getOffset();
75
- const queryVariables = {};
76
- if (!artifact.refetch.pageSize || count > artifact.refetch.pageSize) {
77
- queryVariables.limit = count;
78
- }
79
- return await parentFetch.call(this, {
80
- ...params,
81
- variables: queryVariables
82
- });
83
- }
84
- };
85
- }
86
- // Annotate the CommonJS export names for ESM import in node:
87
- 0 && (module.exports = {
88
- offsetHandlers
89
- });
@@ -1,13 +0,0 @@
1
- import type { GraphQLObject } from '$houdini/runtime/lib/types';
2
- export declare function nullPageInfo(): PageInfo;
3
- export type PageInfo = {
4
- startCursor: string | null;
5
- endCursor: string | null;
6
- hasNextPage: boolean;
7
- hasPreviousPage: boolean;
8
- };
9
- export declare function missingPageSizeError(fnName: string): {
10
- message: string;
11
- };
12
- export declare function extractPageInfo(data: any, path: string[]): PageInfo;
13
- export declare function countPage<_Data extends GraphQLObject>(source: string[], value: _Data | null): number;
@@ -1,79 +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 pageInfo_exports = {};
20
- __export(pageInfo_exports, {
21
- countPage: () => countPage,
22
- extractPageInfo: () => extractPageInfo,
23
- missingPageSizeError: () => missingPageSizeError,
24
- nullPageInfo: () => nullPageInfo
25
- });
26
- module.exports = __toCommonJS(pageInfo_exports);
27
- var import_constants = require("$houdini/runtime/lib/constants");
28
- function nullPageInfo() {
29
- return { startCursor: null, endCursor: null, hasNextPage: false, hasPreviousPage: false };
30
- }
31
- function missingPageSizeError(fnName) {
32
- return {
33
- message: `${fnName} is missing the required page arguments. For more information, please visit this link: ${import_constants.siteURL}/guides/pagination`
34
- };
35
- }
36
- function extractPageInfo(data, path) {
37
- if (!data) {
38
- return {
39
- startCursor: null,
40
- endCursor: null,
41
- hasNextPage: false,
42
- hasPreviousPage: false
43
- };
44
- }
45
- let localPath = [...path];
46
- let current = data;
47
- while (localPath.length > 0) {
48
- if (!current) {
49
- break;
50
- }
51
- current = current[localPath.shift()];
52
- }
53
- return current?.pageInfo ?? nullPageInfo();
54
- }
55
- function countPage(source, value) {
56
- let data = value;
57
- if (value === null || data === null || data === void 0) {
58
- return 0;
59
- }
60
- for (const field of source) {
61
- const obj = data[field];
62
- if (obj && !Array.isArray(obj)) {
63
- data = obj;
64
- } else if (!data) {
65
- throw new Error("Could not count page size");
66
- }
67
- if (Array.isArray(obj)) {
68
- return obj.length;
69
- }
70
- }
71
- return 0;
72
- }
73
- // Annotate the CommonJS export names for ESM import in node:
74
- 0 && (module.exports = {
75
- countPage,
76
- extractPageInfo,
77
- missingPageSizeError,
78
- nullPageInfo
79
- });
@@ -1,13 +0,0 @@
1
- import type { SendParams } from '$houdini/runtime/client/documentStore';
2
- import type { GraphQLObject, QueryArtifact } from '$houdini/runtime/lib/types';
3
- import type { CursorHandlers } from '../../types';
4
- import type { FetchFn } from './fetch';
5
- export declare function cursorHandlers<_Data extends GraphQLObject, _Input extends Record<string, any>>({ artifact, storeName, initialValue, fetchUpdate: parentFetchUpdate, fetch: parentFetch, getState, getVariables, }: {
6
- artifact: QueryArtifact;
7
- storeName: string;
8
- fetch: FetchFn<_Data, _Input>;
9
- getState: () => _Data | null;
10
- getVariables: () => _Input;
11
- initialValue: _Data | null;
12
- fetchUpdate: (arg: SendParams, updates: string[]) => ReturnType<FetchFn<_Data, _Input>>;
13
- }): CursorHandlers<_Data, _Input>;