@mearie/core 0.1.0 → 0.2.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.
- package/dist/index.cjs +611 -718
- package/dist/index.d.cts +117 -56
- package/dist/{index.d.ts → index.d.mts} +117 -56
- package/dist/{index.js → index.mjs} +588 -696
- package/dist/make-BhxZYW3l.d.cts +405 -0
- package/dist/make-C7I1YIXm.mjs +712 -0
- package/dist/make-DxW2Pxe-.cjs +856 -0
- package/dist/make-Ve8TkMHJ.d.mts +405 -0
- package/dist/stream/index.cjs +27 -0
- package/dist/stream/index.d.cts +2 -0
- package/dist/stream/index.d.mts +2 -0
- package/dist/stream/index.mjs +3 -0
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,36 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as Source } from "./make-BhxZYW3l.cjs";
|
|
2
|
+
import { Artifact, Artifact as Artifact$1, ArtifactKind, ArtifactKind as ArtifactKind$1, DataOf, DataOf as DataOf$1, FragmentRefs, FragmentRefs as FragmentRefs$1, SchemaMeta, SchemaMeta as SchemaMeta$1, VariablesOf, VariablesOf as VariablesOf$1 } from "@mearie/shared";
|
|
2
3
|
|
|
3
|
-
//#region src/stream/types.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Subscription allows cancelling a stream and cleaning up resources.
|
|
6
|
-
*/
|
|
7
|
-
type Subscription = {
|
|
8
|
-
/**
|
|
9
|
-
* Cancel the stream and clean up resources.
|
|
10
|
-
*/
|
|
11
|
-
unsubscribe(): void;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Sink receives values from a Source.
|
|
15
|
-
*/
|
|
16
|
-
type Sink<T> = {
|
|
17
|
-
/**
|
|
18
|
-
* Receive a data value.
|
|
19
|
-
* @param value - The data value.
|
|
20
|
-
*/
|
|
21
|
-
next(value: T): void;
|
|
22
|
-
/**
|
|
23
|
-
* Receive completion signal.
|
|
24
|
-
*/
|
|
25
|
-
complete(): void;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Source is a function that accepts a Sink and returns a Subscription.
|
|
29
|
-
* When called, it starts pushing values to the sink.
|
|
30
|
-
* @returns A subscription that can be used to cancel the stream.
|
|
31
|
-
*/
|
|
32
|
-
type Source<T> = (sink: Sink<T>) => Subscription;
|
|
33
|
-
//#endregion
|
|
34
4
|
//#region src/errors.d.ts
|
|
35
5
|
/**
|
|
36
6
|
*
|
|
@@ -94,10 +64,19 @@ type ScalarTransformer<TExternal = unknown, TInternal = unknown> = {
|
|
|
94
64
|
type ScalarsConfig<TMeta extends SchemaMeta$1 = SchemaMeta$1> = { [K in keyof TMeta['scalars']]: ScalarTransformer<TMeta['scalars'][K], unknown> };
|
|
95
65
|
//#endregion
|
|
96
66
|
//#region src/client.d.ts
|
|
97
|
-
type QueryOptions = {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
67
|
+
type QueryOptions<T extends Artifact$1<'query'> = Artifact$1<'query'>> = {
|
|
68
|
+
initialData?: DataOf$1<T>;
|
|
69
|
+
metadata?: OperationMetadata;
|
|
70
|
+
};
|
|
71
|
+
type MutationOptions = {
|
|
72
|
+
metadata?: OperationMetadata;
|
|
73
|
+
};
|
|
74
|
+
type SubscriptionOptions = {
|
|
75
|
+
metadata?: OperationMetadata;
|
|
76
|
+
};
|
|
77
|
+
type FragmentOptions = {
|
|
78
|
+
metadata?: OperationMetadata;
|
|
79
|
+
};
|
|
101
80
|
type ClientOptions<T extends SchemaMeta$1> = {
|
|
102
81
|
schema: T;
|
|
103
82
|
exchanges: Exchange[];
|
|
@@ -114,31 +93,43 @@ declare class Client<TMeta extends SchemaMeta$1 = SchemaMeta$1> {
|
|
|
114
93
|
get schema(): TMeta;
|
|
115
94
|
get scalars(): ScalarsConfig<TMeta> | undefined;
|
|
116
95
|
private createOperationKey;
|
|
117
|
-
createOperation(artifact: Artifact$1, variables?: unknown): Operation;
|
|
96
|
+
createOperation(artifact: Artifact$1, variables?: unknown, metadata?: OperationMetadata): Operation;
|
|
118
97
|
executeOperation(operation: Operation): Source<OperationResult>;
|
|
119
|
-
executeQuery<T extends Artifact$1<'query'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, QueryOptions
|
|
98
|
+
executeQuery<T extends Artifact$1<'query'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, QueryOptions<T>?] : [VariablesOf$1<T>, QueryOptions<T>?]): Source<OperationResult>;
|
|
120
99
|
executeMutation<T extends Artifact$1<'mutation'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, MutationOptions?] : [VariablesOf$1<T>, MutationOptions?]): Source<OperationResult>;
|
|
121
100
|
executeSubscription<T extends Artifact$1<'subscription'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, SubscriptionOptions?] : [VariablesOf$1<T>, SubscriptionOptions?]): Source<OperationResult>;
|
|
122
|
-
executeFragment<T extends Artifact$1<'fragment'>>(artifact: T, fragmentRef: FragmentRefs$1<T['name']
|
|
101
|
+
executeFragment<T extends Artifact$1<'fragment'>>(artifact: T, fragmentRef: FragmentRefs$1<T['name']> | FragmentRefs$1<T['name']>[], options?: FragmentOptions): Source<OperationResult>;
|
|
102
|
+
query<T extends Artifact$1<'query'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, QueryOptions<T>?] : [VariablesOf$1<T>, QueryOptions<T>?]): Promise<DataOf$1<T>>;
|
|
103
|
+
mutation<T extends Artifact$1<'mutation'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, MutationOptions?] : [VariablesOf$1<T>, MutationOptions?]): Promise<DataOf$1<T>>;
|
|
104
|
+
/**
|
|
105
|
+
* Returns the extension registered by a named exchange.
|
|
106
|
+
* @param name - The exchange name.
|
|
107
|
+
* @returns The extension object provided by the exchange.
|
|
108
|
+
*/
|
|
109
|
+
extension<TName extends keyof ExchangeExtensionMap>(name: TName): ExchangeExtensionMap[TName];
|
|
110
|
+
extension(name: string): unknown;
|
|
111
|
+
maybeExtension<TName extends keyof ExchangeExtensionMap>(name: TName): ExchangeExtensionMap[TName] | undefined;
|
|
112
|
+
maybeExtension(name: string): unknown;
|
|
123
113
|
dispose(): void;
|
|
124
114
|
}
|
|
125
115
|
declare const createClient: <T extends SchemaMeta$1>(config: ClientOptions<T>) => Client<T>;
|
|
126
116
|
//#endregion
|
|
127
117
|
//#region src/exchange.d.ts
|
|
128
118
|
interface OperationMetadataMap {}
|
|
119
|
+
type OperationMetadata = { [K in keyof OperationMetadataMap]?: OperationMetadataMap[K] } & Record<string, unknown>;
|
|
129
120
|
type BaseOperation = {
|
|
130
121
|
key: string;
|
|
131
122
|
metadata: OperationMetadataMap & Record<string, unknown>;
|
|
132
123
|
};
|
|
133
|
-
type RequestOperation<K
|
|
124
|
+
type RequestOperation<K extends ArtifactKind$1 = ArtifactKind$1> = BaseOperation & {
|
|
134
125
|
variant: 'request';
|
|
135
|
-
artifact: Artifact$1<K
|
|
136
|
-
variables: VariablesOf$1<Artifact$1<K
|
|
126
|
+
artifact: Artifact$1<K>;
|
|
127
|
+
variables: VariablesOf$1<Artifact$1<K>>;
|
|
137
128
|
};
|
|
138
129
|
type TeardownOperation = BaseOperation & {
|
|
139
130
|
variant: 'teardown';
|
|
140
131
|
};
|
|
141
|
-
type Operation<K
|
|
132
|
+
type Operation<K extends ArtifactKind$1 = ArtifactKind$1> = RequestOperation<K> | TeardownOperation;
|
|
142
133
|
type OperationResult = {
|
|
143
134
|
operation: Operation;
|
|
144
135
|
data?: unknown;
|
|
@@ -151,16 +142,17 @@ type ExchangeInput<TMeta extends SchemaMeta$1 = SchemaMeta$1> = {
|
|
|
151
142
|
client: Client<TMeta>;
|
|
152
143
|
};
|
|
153
144
|
type ExchangeIO = (operations: Source<Operation>) => Source<OperationResult>;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
145
|
+
interface ExchangeExtensionMap {}
|
|
146
|
+
type ExchangeResult<TName extends keyof ExchangeExtensionMap | (string & {}) = string> = {
|
|
147
|
+
name: TName;
|
|
148
|
+
io: ExchangeIO;
|
|
149
|
+
} & (TName extends keyof ExchangeExtensionMap ? {
|
|
150
|
+
extension: ExchangeExtensionMap[TName];
|
|
151
|
+
} : {});
|
|
152
|
+
type Exchange<TName extends keyof ExchangeExtensionMap | (string & {}) = string> = <TMeta extends SchemaMeta$1 = SchemaMeta$1>(input: ExchangeInput<TMeta>) => ExchangeResult<TName>;
|
|
161
153
|
//#endregion
|
|
162
154
|
//#region src/exchanges/http.d.ts
|
|
163
|
-
declare module '
|
|
155
|
+
declare module '@mearie/core' {
|
|
164
156
|
interface ExchangeErrorExtensionsMap {
|
|
165
157
|
http?: {
|
|
166
158
|
statusCode?: number;
|
|
@@ -172,11 +164,12 @@ type HttpOptions = {
|
|
|
172
164
|
headers?: HeadersInit;
|
|
173
165
|
mode?: RequestMode;
|
|
174
166
|
credentials?: RequestCredentials;
|
|
167
|
+
fetch?: typeof globalThis.fetch;
|
|
175
168
|
};
|
|
176
169
|
declare const httpExchange: (options: HttpOptions) => Exchange;
|
|
177
170
|
//#endregion
|
|
178
171
|
//#region src/exchanges/dedup.d.ts
|
|
179
|
-
declare module '
|
|
172
|
+
declare module '@mearie/core' {
|
|
180
173
|
interface OperationMetadataMap {
|
|
181
174
|
dedup?: {
|
|
182
175
|
skip?: boolean;
|
|
@@ -200,14 +193,64 @@ declare module '../exchange.ts' {
|
|
|
200
193
|
*/
|
|
201
194
|
declare const dedupExchange: () => Exchange;
|
|
202
195
|
//#endregion
|
|
196
|
+
//#region src/cache/types.d.ts
|
|
197
|
+
/**
|
|
198
|
+
* Identifier for a single entity, supporting simple or composite keys.
|
|
199
|
+
*/
|
|
200
|
+
type EntityId = string | number | Record<string, string | number>;
|
|
201
|
+
/**
|
|
202
|
+
* Target specification for cache invalidation operations.
|
|
203
|
+
*/
|
|
204
|
+
type InvalidateTarget = {
|
|
205
|
+
__typename: string;
|
|
206
|
+
id: EntityId;
|
|
207
|
+
} | {
|
|
208
|
+
__typename: string;
|
|
209
|
+
id: EntityId;
|
|
210
|
+
field: string;
|
|
211
|
+
args?: Record<string, unknown>;
|
|
212
|
+
} | {
|
|
213
|
+
__typename: 'Query';
|
|
214
|
+
} | {
|
|
215
|
+
__typename: 'Query';
|
|
216
|
+
field: string;
|
|
217
|
+
args?: Record<string, unknown>;
|
|
218
|
+
} | {
|
|
219
|
+
__typename: string;
|
|
220
|
+
} | {
|
|
221
|
+
__typename: string;
|
|
222
|
+
field: string;
|
|
223
|
+
args?: Record<string, unknown>;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Opaque type representing a serializable cache snapshot.
|
|
227
|
+
*/
|
|
228
|
+
type CacheSnapshot = {
|
|
229
|
+
readonly __brand: unique symbol;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Operations available for programmatic cache manipulation.
|
|
233
|
+
*/
|
|
234
|
+
type CacheOperations = {
|
|
235
|
+
extract(): CacheSnapshot;
|
|
236
|
+
hydrate(data: CacheSnapshot): void;
|
|
237
|
+
invalidate(...targets: InvalidateTarget[]): void;
|
|
238
|
+
clear(): void;
|
|
239
|
+
};
|
|
240
|
+
//#endregion
|
|
203
241
|
//#region src/exchanges/cache.d.ts
|
|
242
|
+
declare module '@mearie/core' {
|
|
243
|
+
interface ExchangeExtensionMap {
|
|
244
|
+
cache: CacheOperations;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
204
247
|
type CacheOptions = {
|
|
205
248
|
fetchPolicy?: 'cache-first' | 'cache-and-network' | 'network-only' | 'cache-only';
|
|
206
249
|
};
|
|
207
|
-
declare const cacheExchange: (options?: CacheOptions) => Exchange
|
|
250
|
+
declare const cacheExchange: (options?: CacheOptions) => Exchange<"cache">;
|
|
208
251
|
//#endregion
|
|
209
252
|
//#region src/exchanges/retry.d.ts
|
|
210
|
-
declare module '
|
|
253
|
+
declare module '@mearie/core' {
|
|
211
254
|
interface OperationMetadataMap {
|
|
212
255
|
retry?: {
|
|
213
256
|
attempt: number;
|
|
@@ -223,13 +266,16 @@ type RetryOptions = {
|
|
|
223
266
|
declare const retryExchange: (options?: RetryOptions) => Exchange;
|
|
224
267
|
//#endregion
|
|
225
268
|
//#region src/exchanges/fragment.d.ts
|
|
226
|
-
declare module '
|
|
269
|
+
declare module '@mearie/core' {
|
|
227
270
|
interface OperationMetadataMap {
|
|
228
271
|
fragmentRef?: unknown;
|
|
229
272
|
}
|
|
230
273
|
}
|
|
231
274
|
declare const fragmentExchange: () => Exchange;
|
|
232
275
|
//#endregion
|
|
276
|
+
//#region src/exchanges/required.d.ts
|
|
277
|
+
declare const requiredExchange: () => Exchange;
|
|
278
|
+
//#endregion
|
|
233
279
|
//#region src/exchanges/subscription.d.ts
|
|
234
280
|
interface SubscriptionClient {
|
|
235
281
|
subscribe(payload: {
|
|
@@ -244,6 +290,13 @@ interface SubscriptionClient {
|
|
|
244
290
|
type SubscriptionExchangeOptions = {
|
|
245
291
|
client: SubscriptionClient;
|
|
246
292
|
};
|
|
293
|
+
declare module '@mearie/core' {
|
|
294
|
+
interface OperationMetadataMap {
|
|
295
|
+
subscription?: {
|
|
296
|
+
transport?: boolean;
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
}
|
|
247
300
|
/**
|
|
248
301
|
* Creates an exchange for handling GraphQL subscriptions using a subscription client.
|
|
249
302
|
*
|
|
@@ -273,6 +326,14 @@ type SubscriptionExchangeOptions = {
|
|
|
273
326
|
*/
|
|
274
327
|
declare const subscriptionExchange: (options: SubscriptionExchangeOptions) => Exchange;
|
|
275
328
|
//#endregion
|
|
329
|
+
//#region src/required.d.ts
|
|
330
|
+
type RequiredAction = 'THROW' | 'CASCADE';
|
|
331
|
+
declare class RequiredFieldError extends Error {
|
|
332
|
+
fieldPath: string[];
|
|
333
|
+
fieldName: string;
|
|
334
|
+
constructor(fieldPath: string[], fieldName: string);
|
|
335
|
+
}
|
|
336
|
+
//#endregion
|
|
276
337
|
//#region src/utils.d.ts
|
|
277
338
|
/**
|
|
278
339
|
* Stable JSON serialization with sorted keys.
|
|
@@ -283,4 +344,4 @@ declare const subscriptionExchange: (options: SubscriptionExchangeOptions) => Ex
|
|
|
283
344
|
*/
|
|
284
345
|
declare const stringify: (value: unknown) => string;
|
|
285
346
|
//#endregion
|
|
286
|
-
export { AggregatedError, type Artifact, type ArtifactKind, type CacheOptions, Client, type ClientOptions, type
|
|
347
|
+
export { AggregatedError, type Artifact, type ArtifactKind, type CacheOptions, type CacheSnapshot, Client, type ClientOptions, type DataOf, type Exchange, ExchangeError, type ExchangeErrorExtensionsMap, type ExchangeExtensionMap, type ExchangeIO, type ExchangeResult, type FragmentOptions, type FragmentRefs, GraphQLError, type HttpOptions, type MutationOptions, type Operation, type OperationError, type OperationMetadata, type OperationMetadataMap, type OperationResult, type QueryOptions, type RequiredAction, RequiredFieldError, type RetryOptions, type SchemaMeta, type SubscriptionClient, type SubscriptionExchangeOptions, type SubscriptionOptions, type VariablesOf, cacheExchange, createClient, dedupExchange, fragmentExchange, httpExchange, isAggregatedError, isExchangeError, isGraphQLError, requiredExchange, retryExchange, stringify, subscriptionExchange };
|
|
@@ -1,36 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as Source } from "./make-Ve8TkMHJ.mjs";
|
|
2
|
+
import { Artifact, Artifact as Artifact$1, ArtifactKind, ArtifactKind as ArtifactKind$1, DataOf, DataOf as DataOf$1, FragmentRefs, FragmentRefs as FragmentRefs$1, SchemaMeta, SchemaMeta as SchemaMeta$1, VariablesOf, VariablesOf as VariablesOf$1 } from "@mearie/shared";
|
|
2
3
|
|
|
3
|
-
//#region src/stream/types.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Subscription allows cancelling a stream and cleaning up resources.
|
|
6
|
-
*/
|
|
7
|
-
type Subscription = {
|
|
8
|
-
/**
|
|
9
|
-
* Cancel the stream and clean up resources.
|
|
10
|
-
*/
|
|
11
|
-
unsubscribe(): void;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Sink receives values from a Source.
|
|
15
|
-
*/
|
|
16
|
-
type Sink<T> = {
|
|
17
|
-
/**
|
|
18
|
-
* Receive a data value.
|
|
19
|
-
* @param value - The data value.
|
|
20
|
-
*/
|
|
21
|
-
next(value: T): void;
|
|
22
|
-
/**
|
|
23
|
-
* Receive completion signal.
|
|
24
|
-
*/
|
|
25
|
-
complete(): void;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Source is a function that accepts a Sink and returns a Subscription.
|
|
29
|
-
* When called, it starts pushing values to the sink.
|
|
30
|
-
* @returns A subscription that can be used to cancel the stream.
|
|
31
|
-
*/
|
|
32
|
-
type Source<T> = (sink: Sink<T>) => Subscription;
|
|
33
|
-
//#endregion
|
|
34
4
|
//#region src/errors.d.ts
|
|
35
5
|
/**
|
|
36
6
|
*
|
|
@@ -94,10 +64,19 @@ type ScalarTransformer<TExternal = unknown, TInternal = unknown> = {
|
|
|
94
64
|
type ScalarsConfig<TMeta extends SchemaMeta$1 = SchemaMeta$1> = { [K in keyof TMeta['scalars']]: ScalarTransformer<TMeta['scalars'][K], unknown> };
|
|
95
65
|
//#endregion
|
|
96
66
|
//#region src/client.d.ts
|
|
97
|
-
type QueryOptions = {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
67
|
+
type QueryOptions<T extends Artifact$1<'query'> = Artifact$1<'query'>> = {
|
|
68
|
+
initialData?: DataOf$1<T>;
|
|
69
|
+
metadata?: OperationMetadata;
|
|
70
|
+
};
|
|
71
|
+
type MutationOptions = {
|
|
72
|
+
metadata?: OperationMetadata;
|
|
73
|
+
};
|
|
74
|
+
type SubscriptionOptions = {
|
|
75
|
+
metadata?: OperationMetadata;
|
|
76
|
+
};
|
|
77
|
+
type FragmentOptions = {
|
|
78
|
+
metadata?: OperationMetadata;
|
|
79
|
+
};
|
|
101
80
|
type ClientOptions<T extends SchemaMeta$1> = {
|
|
102
81
|
schema: T;
|
|
103
82
|
exchanges: Exchange[];
|
|
@@ -114,31 +93,43 @@ declare class Client<TMeta extends SchemaMeta$1 = SchemaMeta$1> {
|
|
|
114
93
|
get schema(): TMeta;
|
|
115
94
|
get scalars(): ScalarsConfig<TMeta> | undefined;
|
|
116
95
|
private createOperationKey;
|
|
117
|
-
createOperation(artifact: Artifact$1, variables?: unknown): Operation;
|
|
96
|
+
createOperation(artifact: Artifact$1, variables?: unknown, metadata?: OperationMetadata): Operation;
|
|
118
97
|
executeOperation(operation: Operation): Source<OperationResult>;
|
|
119
|
-
executeQuery<T extends Artifact$1<'query'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, QueryOptions
|
|
98
|
+
executeQuery<T extends Artifact$1<'query'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, QueryOptions<T>?] : [VariablesOf$1<T>, QueryOptions<T>?]): Source<OperationResult>;
|
|
120
99
|
executeMutation<T extends Artifact$1<'mutation'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, MutationOptions?] : [VariablesOf$1<T>, MutationOptions?]): Source<OperationResult>;
|
|
121
100
|
executeSubscription<T extends Artifact$1<'subscription'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, SubscriptionOptions?] : [VariablesOf$1<T>, SubscriptionOptions?]): Source<OperationResult>;
|
|
122
|
-
executeFragment<T extends Artifact$1<'fragment'>>(artifact: T, fragmentRef: FragmentRefs$1<T['name']
|
|
101
|
+
executeFragment<T extends Artifact$1<'fragment'>>(artifact: T, fragmentRef: FragmentRefs$1<T['name']> | FragmentRefs$1<T['name']>[], options?: FragmentOptions): Source<OperationResult>;
|
|
102
|
+
query<T extends Artifact$1<'query'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, QueryOptions<T>?] : [VariablesOf$1<T>, QueryOptions<T>?]): Promise<DataOf$1<T>>;
|
|
103
|
+
mutation<T extends Artifact$1<'mutation'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, MutationOptions?] : [VariablesOf$1<T>, MutationOptions?]): Promise<DataOf$1<T>>;
|
|
104
|
+
/**
|
|
105
|
+
* Returns the extension registered by a named exchange.
|
|
106
|
+
* @param name - The exchange name.
|
|
107
|
+
* @returns The extension object provided by the exchange.
|
|
108
|
+
*/
|
|
109
|
+
extension<TName extends keyof ExchangeExtensionMap>(name: TName): ExchangeExtensionMap[TName];
|
|
110
|
+
extension(name: string): unknown;
|
|
111
|
+
maybeExtension<TName extends keyof ExchangeExtensionMap>(name: TName): ExchangeExtensionMap[TName] | undefined;
|
|
112
|
+
maybeExtension(name: string): unknown;
|
|
123
113
|
dispose(): void;
|
|
124
114
|
}
|
|
125
115
|
declare const createClient: <T extends SchemaMeta$1>(config: ClientOptions<T>) => Client<T>;
|
|
126
116
|
//#endregion
|
|
127
117
|
//#region src/exchange.d.ts
|
|
128
118
|
interface OperationMetadataMap {}
|
|
119
|
+
type OperationMetadata = { [K in keyof OperationMetadataMap]?: OperationMetadataMap[K] } & Record<string, unknown>;
|
|
129
120
|
type BaseOperation = {
|
|
130
121
|
key: string;
|
|
131
122
|
metadata: OperationMetadataMap & Record<string, unknown>;
|
|
132
123
|
};
|
|
133
|
-
type RequestOperation<K
|
|
124
|
+
type RequestOperation<K extends ArtifactKind$1 = ArtifactKind$1> = BaseOperation & {
|
|
134
125
|
variant: 'request';
|
|
135
|
-
artifact: Artifact$1<K
|
|
136
|
-
variables: VariablesOf$1<Artifact$1<K
|
|
126
|
+
artifact: Artifact$1<K>;
|
|
127
|
+
variables: VariablesOf$1<Artifact$1<K>>;
|
|
137
128
|
};
|
|
138
129
|
type TeardownOperation = BaseOperation & {
|
|
139
130
|
variant: 'teardown';
|
|
140
131
|
};
|
|
141
|
-
type Operation<K
|
|
132
|
+
type Operation<K extends ArtifactKind$1 = ArtifactKind$1> = RequestOperation<K> | TeardownOperation;
|
|
142
133
|
type OperationResult = {
|
|
143
134
|
operation: Operation;
|
|
144
135
|
data?: unknown;
|
|
@@ -151,16 +142,17 @@ type ExchangeInput<TMeta extends SchemaMeta$1 = SchemaMeta$1> = {
|
|
|
151
142
|
client: Client<TMeta>;
|
|
152
143
|
};
|
|
153
144
|
type ExchangeIO = (operations: Source<Operation>) => Source<OperationResult>;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
145
|
+
interface ExchangeExtensionMap {}
|
|
146
|
+
type ExchangeResult<TName extends keyof ExchangeExtensionMap | (string & {}) = string> = {
|
|
147
|
+
name: TName;
|
|
148
|
+
io: ExchangeIO;
|
|
149
|
+
} & (TName extends keyof ExchangeExtensionMap ? {
|
|
150
|
+
extension: ExchangeExtensionMap[TName];
|
|
151
|
+
} : {});
|
|
152
|
+
type Exchange<TName extends keyof ExchangeExtensionMap | (string & {}) = string> = <TMeta extends SchemaMeta$1 = SchemaMeta$1>(input: ExchangeInput<TMeta>) => ExchangeResult<TName>;
|
|
161
153
|
//#endregion
|
|
162
154
|
//#region src/exchanges/http.d.ts
|
|
163
|
-
declare module '
|
|
155
|
+
declare module '@mearie/core' {
|
|
164
156
|
interface ExchangeErrorExtensionsMap {
|
|
165
157
|
http?: {
|
|
166
158
|
statusCode?: number;
|
|
@@ -172,11 +164,12 @@ type HttpOptions = {
|
|
|
172
164
|
headers?: HeadersInit;
|
|
173
165
|
mode?: RequestMode;
|
|
174
166
|
credentials?: RequestCredentials;
|
|
167
|
+
fetch?: typeof globalThis.fetch;
|
|
175
168
|
};
|
|
176
169
|
declare const httpExchange: (options: HttpOptions) => Exchange;
|
|
177
170
|
//#endregion
|
|
178
171
|
//#region src/exchanges/dedup.d.ts
|
|
179
|
-
declare module '
|
|
172
|
+
declare module '@mearie/core' {
|
|
180
173
|
interface OperationMetadataMap {
|
|
181
174
|
dedup?: {
|
|
182
175
|
skip?: boolean;
|
|
@@ -200,14 +193,64 @@ declare module '../exchange.ts' {
|
|
|
200
193
|
*/
|
|
201
194
|
declare const dedupExchange: () => Exchange;
|
|
202
195
|
//#endregion
|
|
196
|
+
//#region src/cache/types.d.ts
|
|
197
|
+
/**
|
|
198
|
+
* Identifier for a single entity, supporting simple or composite keys.
|
|
199
|
+
*/
|
|
200
|
+
type EntityId = string | number | Record<string, string | number>;
|
|
201
|
+
/**
|
|
202
|
+
* Target specification for cache invalidation operations.
|
|
203
|
+
*/
|
|
204
|
+
type InvalidateTarget = {
|
|
205
|
+
__typename: string;
|
|
206
|
+
id: EntityId;
|
|
207
|
+
} | {
|
|
208
|
+
__typename: string;
|
|
209
|
+
id: EntityId;
|
|
210
|
+
field: string;
|
|
211
|
+
args?: Record<string, unknown>;
|
|
212
|
+
} | {
|
|
213
|
+
__typename: 'Query';
|
|
214
|
+
} | {
|
|
215
|
+
__typename: 'Query';
|
|
216
|
+
field: string;
|
|
217
|
+
args?: Record<string, unknown>;
|
|
218
|
+
} | {
|
|
219
|
+
__typename: string;
|
|
220
|
+
} | {
|
|
221
|
+
__typename: string;
|
|
222
|
+
field: string;
|
|
223
|
+
args?: Record<string, unknown>;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Opaque type representing a serializable cache snapshot.
|
|
227
|
+
*/
|
|
228
|
+
type CacheSnapshot = {
|
|
229
|
+
readonly __brand: unique symbol;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Operations available for programmatic cache manipulation.
|
|
233
|
+
*/
|
|
234
|
+
type CacheOperations = {
|
|
235
|
+
extract(): CacheSnapshot;
|
|
236
|
+
hydrate(data: CacheSnapshot): void;
|
|
237
|
+
invalidate(...targets: InvalidateTarget[]): void;
|
|
238
|
+
clear(): void;
|
|
239
|
+
};
|
|
240
|
+
//#endregion
|
|
203
241
|
//#region src/exchanges/cache.d.ts
|
|
242
|
+
declare module '@mearie/core' {
|
|
243
|
+
interface ExchangeExtensionMap {
|
|
244
|
+
cache: CacheOperations;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
204
247
|
type CacheOptions = {
|
|
205
248
|
fetchPolicy?: 'cache-first' | 'cache-and-network' | 'network-only' | 'cache-only';
|
|
206
249
|
};
|
|
207
|
-
declare const cacheExchange: (options?: CacheOptions) => Exchange
|
|
250
|
+
declare const cacheExchange: (options?: CacheOptions) => Exchange<"cache">;
|
|
208
251
|
//#endregion
|
|
209
252
|
//#region src/exchanges/retry.d.ts
|
|
210
|
-
declare module '
|
|
253
|
+
declare module '@mearie/core' {
|
|
211
254
|
interface OperationMetadataMap {
|
|
212
255
|
retry?: {
|
|
213
256
|
attempt: number;
|
|
@@ -223,13 +266,16 @@ type RetryOptions = {
|
|
|
223
266
|
declare const retryExchange: (options?: RetryOptions) => Exchange;
|
|
224
267
|
//#endregion
|
|
225
268
|
//#region src/exchanges/fragment.d.ts
|
|
226
|
-
declare module '
|
|
269
|
+
declare module '@mearie/core' {
|
|
227
270
|
interface OperationMetadataMap {
|
|
228
271
|
fragmentRef?: unknown;
|
|
229
272
|
}
|
|
230
273
|
}
|
|
231
274
|
declare const fragmentExchange: () => Exchange;
|
|
232
275
|
//#endregion
|
|
276
|
+
//#region src/exchanges/required.d.ts
|
|
277
|
+
declare const requiredExchange: () => Exchange;
|
|
278
|
+
//#endregion
|
|
233
279
|
//#region src/exchanges/subscription.d.ts
|
|
234
280
|
interface SubscriptionClient {
|
|
235
281
|
subscribe(payload: {
|
|
@@ -244,6 +290,13 @@ interface SubscriptionClient {
|
|
|
244
290
|
type SubscriptionExchangeOptions = {
|
|
245
291
|
client: SubscriptionClient;
|
|
246
292
|
};
|
|
293
|
+
declare module '@mearie/core' {
|
|
294
|
+
interface OperationMetadataMap {
|
|
295
|
+
subscription?: {
|
|
296
|
+
transport?: boolean;
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
}
|
|
247
300
|
/**
|
|
248
301
|
* Creates an exchange for handling GraphQL subscriptions using a subscription client.
|
|
249
302
|
*
|
|
@@ -273,6 +326,14 @@ type SubscriptionExchangeOptions = {
|
|
|
273
326
|
*/
|
|
274
327
|
declare const subscriptionExchange: (options: SubscriptionExchangeOptions) => Exchange;
|
|
275
328
|
//#endregion
|
|
329
|
+
//#region src/required.d.ts
|
|
330
|
+
type RequiredAction = 'THROW' | 'CASCADE';
|
|
331
|
+
declare class RequiredFieldError extends Error {
|
|
332
|
+
fieldPath: string[];
|
|
333
|
+
fieldName: string;
|
|
334
|
+
constructor(fieldPath: string[], fieldName: string);
|
|
335
|
+
}
|
|
336
|
+
//#endregion
|
|
276
337
|
//#region src/utils.d.ts
|
|
277
338
|
/**
|
|
278
339
|
* Stable JSON serialization with sorted keys.
|
|
@@ -283,4 +344,4 @@ declare const subscriptionExchange: (options: SubscriptionExchangeOptions) => Ex
|
|
|
283
344
|
*/
|
|
284
345
|
declare const stringify: (value: unknown) => string;
|
|
285
346
|
//#endregion
|
|
286
|
-
export { AggregatedError, type Artifact, type ArtifactKind, type CacheOptions, Client, type ClientOptions, type
|
|
347
|
+
export { AggregatedError, type Artifact, type ArtifactKind, type CacheOptions, type CacheSnapshot, Client, type ClientOptions, type DataOf, type Exchange, ExchangeError, type ExchangeErrorExtensionsMap, type ExchangeExtensionMap, type ExchangeIO, type ExchangeResult, type FragmentOptions, type FragmentRefs, GraphQLError, type HttpOptions, type MutationOptions, type Operation, type OperationError, type OperationMetadata, type OperationMetadataMap, type OperationResult, type QueryOptions, type RequiredAction, RequiredFieldError, type RetryOptions, type SchemaMeta, type SubscriptionClient, type SubscriptionExchangeOptions, type SubscriptionOptions, type VariablesOf, cacheExchange, createClient, dedupExchange, fragmentExchange, httpExchange, isAggregatedError, isExchangeError, isGraphQLError, requiredExchange, retryExchange, stringify, subscriptionExchange };
|