@mearie/core 0.1.2 → 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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { k as Source } from "./index-CrxalFAt.cjs";
2
- import { Artifact, Artifact as Artifact$1, ArtifactKind, ArtifactKind as ArtifactKind$1, DataOf, FragmentRefs, FragmentRefs as FragmentRefs$1, SchemaMeta, SchemaMeta as SchemaMeta$1, VariablesOf, VariablesOf as VariablesOf$1 } from "@mearie/shared";
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";
3
3
 
4
4
  //#region src/errors.d.ts
5
5
  /**
@@ -64,10 +64,19 @@ type ScalarTransformer<TExternal = unknown, TInternal = unknown> = {
64
64
  type ScalarsConfig<TMeta extends SchemaMeta$1 = SchemaMeta$1> = { [K in keyof TMeta['scalars']]: ScalarTransformer<TMeta['scalars'][K], unknown> };
65
65
  //#endregion
66
66
  //#region src/client.d.ts
67
- type QueryOptions = {};
68
- type MutationOptions = {};
69
- type SubscriptionOptions = {};
70
- type FragmentOptions = {};
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
+ };
71
80
  type ClientOptions<T extends SchemaMeta$1> = {
72
81
  schema: T;
73
82
  exchanges: Exchange[];
@@ -84,31 +93,43 @@ declare class Client<TMeta extends SchemaMeta$1 = SchemaMeta$1> {
84
93
  get schema(): TMeta;
85
94
  get scalars(): ScalarsConfig<TMeta> | undefined;
86
95
  private createOperationKey;
87
- createOperation(artifact: Artifact$1, variables?: unknown): Operation;
96
+ createOperation(artifact: Artifact$1, variables?: unknown, metadata?: OperationMetadata): Operation;
88
97
  executeOperation(operation: Operation): Source<OperationResult>;
89
- executeQuery<T extends Artifact$1<'query'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, QueryOptions?] : [VariablesOf$1<T>, QueryOptions?]): Source<OperationResult>;
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>;
90
99
  executeMutation<T extends Artifact$1<'mutation'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, MutationOptions?] : [VariablesOf$1<T>, MutationOptions?]): Source<OperationResult>;
91
100
  executeSubscription<T extends Artifact$1<'subscription'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, SubscriptionOptions?] : [VariablesOf$1<T>, SubscriptionOptions?]): Source<OperationResult>;
92
- executeFragment<T extends Artifact$1<'fragment'>>(artifact: T, fragmentRef: FragmentRefs$1<T['name']>, options?: FragmentOptions): Source<OperationResult>;
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;
93
113
  dispose(): void;
94
114
  }
95
115
  declare const createClient: <T extends SchemaMeta$1>(config: ClientOptions<T>) => Client<T>;
96
116
  //#endregion
97
117
  //#region src/exchange.d.ts
98
118
  interface OperationMetadataMap {}
119
+ type OperationMetadata = { [K in keyof OperationMetadataMap]?: OperationMetadataMap[K] } & Record<string, unknown>;
99
120
  type BaseOperation = {
100
121
  key: string;
101
122
  metadata: OperationMetadataMap & Record<string, unknown>;
102
123
  };
103
- type RequestOperation<K$1 extends ArtifactKind$1 = ArtifactKind$1> = BaseOperation & {
124
+ type RequestOperation<K extends ArtifactKind$1 = ArtifactKind$1> = BaseOperation & {
104
125
  variant: 'request';
105
- artifact: Artifact$1<K$1>;
106
- variables: VariablesOf$1<Artifact$1<K$1>>;
126
+ artifact: Artifact$1<K>;
127
+ variables: VariablesOf$1<Artifact$1<K>>;
107
128
  };
108
129
  type TeardownOperation = BaseOperation & {
109
130
  variant: 'teardown';
110
131
  };
111
- type Operation<K$1 extends ArtifactKind$1 = ArtifactKind$1> = RequestOperation<K$1> | TeardownOperation;
132
+ type Operation<K extends ArtifactKind$1 = ArtifactKind$1> = RequestOperation<K> | TeardownOperation;
112
133
  type OperationResult = {
113
134
  operation: Operation;
114
135
  data?: unknown;
@@ -121,16 +142,17 @@ type ExchangeInput<TMeta extends SchemaMeta$1 = SchemaMeta$1> = {
121
142
  client: Client<TMeta>;
122
143
  };
123
144
  type ExchangeIO = (operations: Source<Operation>) => Source<OperationResult>;
124
- type Exchange = <TMeta extends SchemaMeta$1 = SchemaMeta$1>(input: ExchangeInput<TMeta>) => ExchangeIO;
125
- //#endregion
126
- //#region src/exchanges/compose.d.ts
127
- type ComposeExchangeOptions = {
128
- exchanges: Exchange[];
129
- };
130
- declare const composeExchange: (options: ComposeExchangeOptions) => Exchange;
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>;
131
153
  //#endregion
132
154
  //#region src/exchanges/http.d.ts
133
- declare module '../errors.ts' {
155
+ declare module '@mearie/core' {
134
156
  interface ExchangeErrorExtensionsMap {
135
157
  http?: {
136
158
  statusCode?: number;
@@ -142,11 +164,12 @@ type HttpOptions = {
142
164
  headers?: HeadersInit;
143
165
  mode?: RequestMode;
144
166
  credentials?: RequestCredentials;
167
+ fetch?: typeof globalThis.fetch;
145
168
  };
146
169
  declare const httpExchange: (options: HttpOptions) => Exchange;
147
170
  //#endregion
148
171
  //#region src/exchanges/dedup.d.ts
149
- declare module '../exchange.ts' {
172
+ declare module '@mearie/core' {
150
173
  interface OperationMetadataMap {
151
174
  dedup?: {
152
175
  skip?: boolean;
@@ -170,14 +193,64 @@ declare module '../exchange.ts' {
170
193
  */
171
194
  declare const dedupExchange: () => Exchange;
172
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
173
241
  //#region src/exchanges/cache.d.ts
242
+ declare module '@mearie/core' {
243
+ interface ExchangeExtensionMap {
244
+ cache: CacheOperations;
245
+ }
246
+ }
174
247
  type CacheOptions = {
175
248
  fetchPolicy?: 'cache-first' | 'cache-and-network' | 'network-only' | 'cache-only';
176
249
  };
177
- declare const cacheExchange: (options?: CacheOptions) => Exchange;
250
+ declare const cacheExchange: (options?: CacheOptions) => Exchange<"cache">;
178
251
  //#endregion
179
252
  //#region src/exchanges/retry.d.ts
180
- declare module '../exchange.ts' {
253
+ declare module '@mearie/core' {
181
254
  interface OperationMetadataMap {
182
255
  retry?: {
183
256
  attempt: number;
@@ -193,13 +266,16 @@ type RetryOptions = {
193
266
  declare const retryExchange: (options?: RetryOptions) => Exchange;
194
267
  //#endregion
195
268
  //#region src/exchanges/fragment.d.ts
196
- declare module '../exchange.ts' {
269
+ declare module '@mearie/core' {
197
270
  interface OperationMetadataMap {
198
271
  fragmentRef?: unknown;
199
272
  }
200
273
  }
201
274
  declare const fragmentExchange: () => Exchange;
202
275
  //#endregion
276
+ //#region src/exchanges/required.d.ts
277
+ declare const requiredExchange: () => Exchange;
278
+ //#endregion
203
279
  //#region src/exchanges/subscription.d.ts
204
280
  interface SubscriptionClient {
205
281
  subscribe(payload: {
@@ -214,6 +290,13 @@ interface SubscriptionClient {
214
290
  type SubscriptionExchangeOptions = {
215
291
  client: SubscriptionClient;
216
292
  };
293
+ declare module '@mearie/core' {
294
+ interface OperationMetadataMap {
295
+ subscription?: {
296
+ transport?: boolean;
297
+ };
298
+ }
299
+ }
217
300
  /**
218
301
  * Creates an exchange for handling GraphQL subscriptions using a subscription client.
219
302
  *
@@ -243,6 +326,14 @@ type SubscriptionExchangeOptions = {
243
326
  */
244
327
  declare const subscriptionExchange: (options: SubscriptionExchangeOptions) => Exchange;
245
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
246
337
  //#region src/utils.d.ts
247
338
  /**
248
339
  * Stable JSON serialization with sorted keys.
@@ -253,4 +344,4 @@ declare const subscriptionExchange: (options: SubscriptionExchangeOptions) => Ex
253
344
  */
254
345
  declare const stringify: (value: unknown) => string;
255
346
  //#endregion
256
- export { AggregatedError, type Artifact, type ArtifactKind, type CacheOptions, Client, type ClientOptions, type ComposeExchangeOptions, type DataOf, type Exchange, ExchangeError, type ExchangeErrorExtensionsMap, type ExchangeIO, type FragmentOptions, type FragmentRefs, GraphQLError, type HttpOptions, type MutationOptions, type Operation, type OperationError, type OperationMetadataMap, type OperationResult, type QueryOptions, type RetryOptions, type SchemaMeta, type SubscriptionClient, type SubscriptionExchangeOptions, type SubscriptionOptions, type VariablesOf, cacheExchange, composeExchange, createClient, dedupExchange, fragmentExchange, httpExchange, isAggregatedError, isExchangeError, isGraphQLError, retryExchange, stringify, subscriptionExchange };
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,5 +1,5 @@
1
- import { k as Source } from "./index-BJ3Ktp8q.js";
2
- import { Artifact, Artifact as Artifact$1, ArtifactKind, ArtifactKind as ArtifactKind$1, DataOf, FragmentRefs, FragmentRefs as FragmentRefs$1, SchemaMeta, SchemaMeta as SchemaMeta$1, VariablesOf, VariablesOf as VariablesOf$1 } from "@mearie/shared";
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";
3
3
 
4
4
  //#region src/errors.d.ts
5
5
  /**
@@ -64,10 +64,19 @@ type ScalarTransformer<TExternal = unknown, TInternal = unknown> = {
64
64
  type ScalarsConfig<TMeta extends SchemaMeta$1 = SchemaMeta$1> = { [K in keyof TMeta['scalars']]: ScalarTransformer<TMeta['scalars'][K], unknown> };
65
65
  //#endregion
66
66
  //#region src/client.d.ts
67
- type QueryOptions = {};
68
- type MutationOptions = {};
69
- type SubscriptionOptions = {};
70
- type FragmentOptions = {};
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
+ };
71
80
  type ClientOptions<T extends SchemaMeta$1> = {
72
81
  schema: T;
73
82
  exchanges: Exchange[];
@@ -84,31 +93,43 @@ declare class Client<TMeta extends SchemaMeta$1 = SchemaMeta$1> {
84
93
  get schema(): TMeta;
85
94
  get scalars(): ScalarsConfig<TMeta> | undefined;
86
95
  private createOperationKey;
87
- createOperation(artifact: Artifact$1, variables?: unknown): Operation;
96
+ createOperation(artifact: Artifact$1, variables?: unknown, metadata?: OperationMetadata): Operation;
88
97
  executeOperation(operation: Operation): Source<OperationResult>;
89
- executeQuery<T extends Artifact$1<'query'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, QueryOptions?] : [VariablesOf$1<T>, QueryOptions?]): Source<OperationResult>;
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>;
90
99
  executeMutation<T extends Artifact$1<'mutation'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, MutationOptions?] : [VariablesOf$1<T>, MutationOptions?]): Source<OperationResult>;
91
100
  executeSubscription<T extends Artifact$1<'subscription'>>(artifact: T, ...[variables, options]: VariablesOf$1<T> extends undefined ? [undefined?, SubscriptionOptions?] : [VariablesOf$1<T>, SubscriptionOptions?]): Source<OperationResult>;
92
- executeFragment<T extends Artifact$1<'fragment'>>(artifact: T, fragmentRef: FragmentRefs$1<T['name']>, options?: FragmentOptions): Source<OperationResult>;
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;
93
113
  dispose(): void;
94
114
  }
95
115
  declare const createClient: <T extends SchemaMeta$1>(config: ClientOptions<T>) => Client<T>;
96
116
  //#endregion
97
117
  //#region src/exchange.d.ts
98
118
  interface OperationMetadataMap {}
119
+ type OperationMetadata = { [K in keyof OperationMetadataMap]?: OperationMetadataMap[K] } & Record<string, unknown>;
99
120
  type BaseOperation = {
100
121
  key: string;
101
122
  metadata: OperationMetadataMap & Record<string, unknown>;
102
123
  };
103
- type RequestOperation<K$1 extends ArtifactKind$1 = ArtifactKind$1> = BaseOperation & {
124
+ type RequestOperation<K extends ArtifactKind$1 = ArtifactKind$1> = BaseOperation & {
104
125
  variant: 'request';
105
- artifact: Artifact$1<K$1>;
106
- variables: VariablesOf$1<Artifact$1<K$1>>;
126
+ artifact: Artifact$1<K>;
127
+ variables: VariablesOf$1<Artifact$1<K>>;
107
128
  };
108
129
  type TeardownOperation = BaseOperation & {
109
130
  variant: 'teardown';
110
131
  };
111
- type Operation<K$1 extends ArtifactKind$1 = ArtifactKind$1> = RequestOperation<K$1> | TeardownOperation;
132
+ type Operation<K extends ArtifactKind$1 = ArtifactKind$1> = RequestOperation<K> | TeardownOperation;
112
133
  type OperationResult = {
113
134
  operation: Operation;
114
135
  data?: unknown;
@@ -121,16 +142,17 @@ type ExchangeInput<TMeta extends SchemaMeta$1 = SchemaMeta$1> = {
121
142
  client: Client<TMeta>;
122
143
  };
123
144
  type ExchangeIO = (operations: Source<Operation>) => Source<OperationResult>;
124
- type Exchange = <TMeta extends SchemaMeta$1 = SchemaMeta$1>(input: ExchangeInput<TMeta>) => ExchangeIO;
125
- //#endregion
126
- //#region src/exchanges/compose.d.ts
127
- type ComposeExchangeOptions = {
128
- exchanges: Exchange[];
129
- };
130
- declare const composeExchange: (options: ComposeExchangeOptions) => Exchange;
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>;
131
153
  //#endregion
132
154
  //#region src/exchanges/http.d.ts
133
- declare module '../errors.ts' {
155
+ declare module '@mearie/core' {
134
156
  interface ExchangeErrorExtensionsMap {
135
157
  http?: {
136
158
  statusCode?: number;
@@ -142,11 +164,12 @@ type HttpOptions = {
142
164
  headers?: HeadersInit;
143
165
  mode?: RequestMode;
144
166
  credentials?: RequestCredentials;
167
+ fetch?: typeof globalThis.fetch;
145
168
  };
146
169
  declare const httpExchange: (options: HttpOptions) => Exchange;
147
170
  //#endregion
148
171
  //#region src/exchanges/dedup.d.ts
149
- declare module '../exchange.ts' {
172
+ declare module '@mearie/core' {
150
173
  interface OperationMetadataMap {
151
174
  dedup?: {
152
175
  skip?: boolean;
@@ -170,14 +193,64 @@ declare module '../exchange.ts' {
170
193
  */
171
194
  declare const dedupExchange: () => Exchange;
172
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
173
241
  //#region src/exchanges/cache.d.ts
242
+ declare module '@mearie/core' {
243
+ interface ExchangeExtensionMap {
244
+ cache: CacheOperations;
245
+ }
246
+ }
174
247
  type CacheOptions = {
175
248
  fetchPolicy?: 'cache-first' | 'cache-and-network' | 'network-only' | 'cache-only';
176
249
  };
177
- declare const cacheExchange: (options?: CacheOptions) => Exchange;
250
+ declare const cacheExchange: (options?: CacheOptions) => Exchange<"cache">;
178
251
  //#endregion
179
252
  //#region src/exchanges/retry.d.ts
180
- declare module '../exchange.ts' {
253
+ declare module '@mearie/core' {
181
254
  interface OperationMetadataMap {
182
255
  retry?: {
183
256
  attempt: number;
@@ -193,13 +266,16 @@ type RetryOptions = {
193
266
  declare const retryExchange: (options?: RetryOptions) => Exchange;
194
267
  //#endregion
195
268
  //#region src/exchanges/fragment.d.ts
196
- declare module '../exchange.ts' {
269
+ declare module '@mearie/core' {
197
270
  interface OperationMetadataMap {
198
271
  fragmentRef?: unknown;
199
272
  }
200
273
  }
201
274
  declare const fragmentExchange: () => Exchange;
202
275
  //#endregion
276
+ //#region src/exchanges/required.d.ts
277
+ declare const requiredExchange: () => Exchange;
278
+ //#endregion
203
279
  //#region src/exchanges/subscription.d.ts
204
280
  interface SubscriptionClient {
205
281
  subscribe(payload: {
@@ -214,6 +290,13 @@ interface SubscriptionClient {
214
290
  type SubscriptionExchangeOptions = {
215
291
  client: SubscriptionClient;
216
292
  };
293
+ declare module '@mearie/core' {
294
+ interface OperationMetadataMap {
295
+ subscription?: {
296
+ transport?: boolean;
297
+ };
298
+ }
299
+ }
217
300
  /**
218
301
  * Creates an exchange for handling GraphQL subscriptions using a subscription client.
219
302
  *
@@ -243,6 +326,14 @@ type SubscriptionExchangeOptions = {
243
326
  */
244
327
  declare const subscriptionExchange: (options: SubscriptionExchangeOptions) => Exchange;
245
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
246
337
  //#region src/utils.d.ts
247
338
  /**
248
339
  * Stable JSON serialization with sorted keys.
@@ -253,4 +344,4 @@ declare const subscriptionExchange: (options: SubscriptionExchangeOptions) => Ex
253
344
  */
254
345
  declare const stringify: (value: unknown) => string;
255
346
  //#endregion
256
- export { AggregatedError, type Artifact, type ArtifactKind, type CacheOptions, Client, type ClientOptions, type ComposeExchangeOptions, type DataOf, type Exchange, ExchangeError, type ExchangeErrorExtensionsMap, type ExchangeIO, type FragmentOptions, type FragmentRefs, GraphQLError, type HttpOptions, type MutationOptions, type Operation, type OperationError, type OperationMetadataMap, type OperationResult, type QueryOptions, type RetryOptions, type SchemaMeta, type SubscriptionClient, type SubscriptionExchangeOptions, type SubscriptionOptions, type VariablesOf, cacheExchange, composeExchange, createClient, dedupExchange, fragmentExchange, httpExchange, isAggregatedError, isExchangeError, isGraphQLError, retryExchange, stringify, subscriptionExchange };
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 };