@mearie/core 0.5.1 → 0.6.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 +1015 -234
- package/dist/index.d.cts +53 -2
- package/dist/index.d.mts +53 -2
- package/dist/index.mjs +1013 -236
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -195,6 +195,29 @@ declare module '@mearie/core' {
|
|
|
195
195
|
declare const dedupExchange: () => Exchange;
|
|
196
196
|
//#endregion
|
|
197
197
|
//#region src/cache/types.d.ts
|
|
198
|
+
/**
|
|
199
|
+
* Path into a denormalized query result tree.
|
|
200
|
+
*/
|
|
201
|
+
type PropertyPath = (string | number)[];
|
|
202
|
+
/**
|
|
203
|
+
* Describes a targeted mutation to a denormalized query result.
|
|
204
|
+
*/
|
|
205
|
+
type Patch = {
|
|
206
|
+
type: 'set';
|
|
207
|
+
path: PropertyPath;
|
|
208
|
+
value: unknown;
|
|
209
|
+
} | {
|
|
210
|
+
type: 'splice';
|
|
211
|
+
path: PropertyPath;
|
|
212
|
+
index: number;
|
|
213
|
+
deleteCount: number;
|
|
214
|
+
items: unknown[];
|
|
215
|
+
} | {
|
|
216
|
+
type: 'swap';
|
|
217
|
+
path: PropertyPath;
|
|
218
|
+
i: number;
|
|
219
|
+
j: number;
|
|
220
|
+
};
|
|
198
221
|
type EntityTypes<TMeta extends SchemaMeta$1> = NonNullable<TMeta[' $entityTypes']>;
|
|
199
222
|
type QueryFields<TMeta extends SchemaMeta$1> = NonNullable<TMeta[' $queryFields']>;
|
|
200
223
|
type KeyFieldsOf<E> = E extends {
|
|
@@ -255,7 +278,8 @@ declare module '@mearie/core' {
|
|
|
255
278
|
}
|
|
256
279
|
interface OperationResultMetadataMap {
|
|
257
280
|
cache?: {
|
|
258
|
-
stale
|
|
281
|
+
stale?: boolean;
|
|
282
|
+
patches?: Patch[];
|
|
259
283
|
};
|
|
260
284
|
}
|
|
261
285
|
}
|
|
@@ -264,6 +288,33 @@ type CacheOptions = {
|
|
|
264
288
|
};
|
|
265
289
|
declare const cacheExchange: (options?: CacheOptions) => Exchange<"cache">;
|
|
266
290
|
//#endregion
|
|
291
|
+
//#region src/cache/patch.d.ts
|
|
292
|
+
/**
|
|
293
|
+
* Sets a value at a nested path within an object.
|
|
294
|
+
* @param obj - The object to modify.
|
|
295
|
+
* @param path - The path to the target location.
|
|
296
|
+
* @param value - The value to set.
|
|
297
|
+
*/
|
|
298
|
+
declare const setPath: (obj: unknown, path: PropertyPath, value: unknown) => void;
|
|
299
|
+
/**
|
|
300
|
+
* Gets a value at a nested path within an object.
|
|
301
|
+
* @param obj - The object to read from.
|
|
302
|
+
* @param path - The path to the target location.
|
|
303
|
+
* @returns The value at the path, or the object itself if path is empty.
|
|
304
|
+
*/
|
|
305
|
+
declare const getPath: (obj: unknown, path: PropertyPath) => unknown;
|
|
306
|
+
/**
|
|
307
|
+
* Applies cache patches to data immutably, shallow-copying only along changed paths.
|
|
308
|
+
*/
|
|
309
|
+
declare const applyPatchesImmutable: <T>(data: T, patches: Patch[]) => T;
|
|
310
|
+
/**
|
|
311
|
+
* Applies cache patches to a mutable target object in place.
|
|
312
|
+
* @param target - The mutable object to apply patches to.
|
|
313
|
+
* @param patches - The patches to apply.
|
|
314
|
+
* @returns The new root value if a root-level set patch was applied, otherwise undefined.
|
|
315
|
+
*/
|
|
316
|
+
declare const applyPatchesMutable: (target: unknown, patches: Patch[]) => unknown;
|
|
317
|
+
//#endregion
|
|
267
318
|
//#region src/exchanges/retry.d.ts
|
|
268
319
|
declare module '@mearie/core' {
|
|
269
320
|
interface OperationMetadataMap {
|
|
@@ -362,4 +413,4 @@ declare class RequiredFieldError extends Error {
|
|
|
362
413
|
*/
|
|
363
414
|
declare const stringify: (value: unknown) => string;
|
|
364
415
|
//#endregion
|
|
365
|
-
export { AggregatedError, type Artifact, type ArtifactKind, type CacheOperations, 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 InvalidateTarget, type MutationOptions, type Operation, type OperationError, type OperationMetadata, type OperationMetadataMap, type OperationResult, type OperationResultMetadataMap, 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 };
|
|
416
|
+
export { AggregatedError, type Artifact, type ArtifactKind, type CacheOperations, 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 InvalidateTarget, type MutationOptions, type Operation, type OperationError, type OperationMetadata, type OperationMetadataMap, type OperationResult, type OperationResultMetadataMap, type Patch, type PropertyPath, type QueryOptions, type RequiredAction, RequiredFieldError, type RetryOptions, type SchemaMeta, type SubscriptionClient, type SubscriptionExchangeOptions, type SubscriptionOptions, type VariablesOf, applyPatchesImmutable, applyPatchesMutable, cacheExchange, createClient, dedupExchange, fragmentExchange, getPath, httpExchange, isAggregatedError, isExchangeError, isGraphQLError, requiredExchange, retryExchange, setPath, stringify, subscriptionExchange };
|
package/dist/index.d.mts
CHANGED
|
@@ -195,6 +195,29 @@ declare module '@mearie/core' {
|
|
|
195
195
|
declare const dedupExchange: () => Exchange;
|
|
196
196
|
//#endregion
|
|
197
197
|
//#region src/cache/types.d.ts
|
|
198
|
+
/**
|
|
199
|
+
* Path into a denormalized query result tree.
|
|
200
|
+
*/
|
|
201
|
+
type PropertyPath = (string | number)[];
|
|
202
|
+
/**
|
|
203
|
+
* Describes a targeted mutation to a denormalized query result.
|
|
204
|
+
*/
|
|
205
|
+
type Patch = {
|
|
206
|
+
type: 'set';
|
|
207
|
+
path: PropertyPath;
|
|
208
|
+
value: unknown;
|
|
209
|
+
} | {
|
|
210
|
+
type: 'splice';
|
|
211
|
+
path: PropertyPath;
|
|
212
|
+
index: number;
|
|
213
|
+
deleteCount: number;
|
|
214
|
+
items: unknown[];
|
|
215
|
+
} | {
|
|
216
|
+
type: 'swap';
|
|
217
|
+
path: PropertyPath;
|
|
218
|
+
i: number;
|
|
219
|
+
j: number;
|
|
220
|
+
};
|
|
198
221
|
type EntityTypes<TMeta extends SchemaMeta$1> = NonNullable<TMeta[' $entityTypes']>;
|
|
199
222
|
type QueryFields<TMeta extends SchemaMeta$1> = NonNullable<TMeta[' $queryFields']>;
|
|
200
223
|
type KeyFieldsOf<E> = E extends {
|
|
@@ -255,7 +278,8 @@ declare module '@mearie/core' {
|
|
|
255
278
|
}
|
|
256
279
|
interface OperationResultMetadataMap {
|
|
257
280
|
cache?: {
|
|
258
|
-
stale
|
|
281
|
+
stale?: boolean;
|
|
282
|
+
patches?: Patch[];
|
|
259
283
|
};
|
|
260
284
|
}
|
|
261
285
|
}
|
|
@@ -264,6 +288,33 @@ type CacheOptions = {
|
|
|
264
288
|
};
|
|
265
289
|
declare const cacheExchange: (options?: CacheOptions) => Exchange<"cache">;
|
|
266
290
|
//#endregion
|
|
291
|
+
//#region src/cache/patch.d.ts
|
|
292
|
+
/**
|
|
293
|
+
* Sets a value at a nested path within an object.
|
|
294
|
+
* @param obj - The object to modify.
|
|
295
|
+
* @param path - The path to the target location.
|
|
296
|
+
* @param value - The value to set.
|
|
297
|
+
*/
|
|
298
|
+
declare const setPath: (obj: unknown, path: PropertyPath, value: unknown) => void;
|
|
299
|
+
/**
|
|
300
|
+
* Gets a value at a nested path within an object.
|
|
301
|
+
* @param obj - The object to read from.
|
|
302
|
+
* @param path - The path to the target location.
|
|
303
|
+
* @returns The value at the path, or the object itself if path is empty.
|
|
304
|
+
*/
|
|
305
|
+
declare const getPath: (obj: unknown, path: PropertyPath) => unknown;
|
|
306
|
+
/**
|
|
307
|
+
* Applies cache patches to data immutably, shallow-copying only along changed paths.
|
|
308
|
+
*/
|
|
309
|
+
declare const applyPatchesImmutable: <T>(data: T, patches: Patch[]) => T;
|
|
310
|
+
/**
|
|
311
|
+
* Applies cache patches to a mutable target object in place.
|
|
312
|
+
* @param target - The mutable object to apply patches to.
|
|
313
|
+
* @param patches - The patches to apply.
|
|
314
|
+
* @returns The new root value if a root-level set patch was applied, otherwise undefined.
|
|
315
|
+
*/
|
|
316
|
+
declare const applyPatchesMutable: (target: unknown, patches: Patch[]) => unknown;
|
|
317
|
+
//#endregion
|
|
267
318
|
//#region src/exchanges/retry.d.ts
|
|
268
319
|
declare module '@mearie/core' {
|
|
269
320
|
interface OperationMetadataMap {
|
|
@@ -362,4 +413,4 @@ declare class RequiredFieldError extends Error {
|
|
|
362
413
|
*/
|
|
363
414
|
declare const stringify: (value: unknown) => string;
|
|
364
415
|
//#endregion
|
|
365
|
-
export { AggregatedError, type Artifact, type ArtifactKind, type CacheOperations, 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 InvalidateTarget, type MutationOptions, type Operation, type OperationError, type OperationMetadata, type OperationMetadataMap, type OperationResult, type OperationResultMetadataMap, 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 };
|
|
416
|
+
export { AggregatedError, type Artifact, type ArtifactKind, type CacheOperations, 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 InvalidateTarget, type MutationOptions, type Operation, type OperationError, type OperationMetadata, type OperationMetadataMap, type OperationResult, type OperationResultMetadataMap, type Patch, type PropertyPath, type QueryOptions, type RequiredAction, RequiredFieldError, type RetryOptions, type SchemaMeta, type SubscriptionClient, type SubscriptionExchangeOptions, type SubscriptionOptions, type VariablesOf, applyPatchesImmutable, applyPatchesMutable, cacheExchange, createClient, dedupExchange, fragmentExchange, getPath, httpExchange, isAggregatedError, isExchangeError, isGraphQLError, requiredExchange, retryExchange, setPath, stringify, subscriptionExchange };
|