houdini-svelte 1.0.0 → 1.0.2

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.
@@ -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
  }
@@ -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, QueryResult<_Data, _Input>>['loadNextPage']>[0]): Promise<void>;
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,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,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,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, QueryResult } from '$houdini/runtime/lib/types';
4
- import type { Writable } from 'svelte/store';
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
- };
@@ -131,7 +131,7 @@ If you think this is an error, please open an issue on GitHub`);
131
131
  if (count && count > artifact.refetch.pageSize) {
132
132
  if (currentPageInfo.hasPreviousPage && currentPageInfo.hasNextPage && !(variables?.["first"] && variables?.["after"] || variables?.["last"] && variables?.["before"])) {
133
133
  console.warn(`\u26A0\uFE0F Encountered a fetch() in the middle of the connection.
134
- Make sure to pass a cursor value by hand that includes the current set (ie the entry before startCursor)
134
+ Make sure to pass a cursor value by hand that includes the current set (ie the entry before startCursor)
135
135
  `);
136
136
  return observer.state;
137
137
  }
@@ -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, QueryResult<_Data, _Input>>['loadNextPage']>[0]): Promise<void>;
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,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 {};