@mearie/core 0.0.0 → 0.0.1-next.3

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.js CHANGED
@@ -1,5 +1,682 @@
1
+ import { configureSync, getAnsiColorFormatter, getConsoleSink, getLogger } from "@logtape/logtape";
2
+ import pc from "picocolors";
3
+
4
+ //#region src/errors.ts
5
+ /**
6
+ * Custom error class for Mearie-specific errors.
7
+ */
8
+ var MearieError = class MearieError extends Error {
9
+ filePath;
10
+ line;
11
+ column;
12
+ constructor(message, filePath, line, column) {
13
+ super(message);
14
+ this.name = "MearieError";
15
+ this.filePath = filePath;
16
+ this.line = line;
17
+ this.column = column;
18
+ }
19
+ static fromNative(data) {
20
+ if (!data || typeof data !== "object") throw new TypeError("Invalid native error data");
21
+ const error = data;
22
+ const filePath = error.location?.file_path;
23
+ const line = error.location?.line;
24
+ const column = error.location?.column;
25
+ return new MearieError(error.message, filePath, line, column);
26
+ }
27
+ };
28
+ /**
29
+ * Aggregate error for multiple Mearie errors.
30
+ */
31
+ var MearieAggregateError = class extends Error {
32
+ errors;
33
+ constructor(errors, message) {
34
+ super(message ?? `${errors.length} error${errors.length > 1 ? "s" : ""} occurred`);
35
+ this.name = "MearieAggregateError";
36
+ this.errors = errors;
37
+ }
38
+ };
39
+
40
+ //#endregion
41
+ //#region src/utils.ts
42
+ /**
43
+ * Stable JSON serialization with sorted keys.
44
+ * Used for both variables and field arguments.
45
+ * @internal
46
+ * @param value - The value to stringify.
47
+ * @returns The stable JSON string.
48
+ */
49
+ const stableStringify = (value) => {
50
+ if (value === null) return "null";
51
+ if (value === void 0) return "undefined";
52
+ const type = typeof value;
53
+ if (type === "string") return JSON.stringify(value);
54
+ if (type === "number" || type === "boolean") return String(value);
55
+ if (Array.isArray(value)) return "[" + value.map((v) => stableStringify(v)).join(",") + "]";
56
+ if (type === "object") {
57
+ const obj = value;
58
+ return "{" + Object.keys(obj).toSorted().map((k) => `"${k}":${stableStringify(obj[k])}`).join(",") + "}";
59
+ }
60
+ return JSON.stringify(value) ?? "";
61
+ };
62
+ /**
63
+ * Hash a string using FNV-1a algorithm.
64
+ * @internal
65
+ * @param str - The string to hash.
66
+ * @returns The hash value.
67
+ */
68
+ const hashString = (str) => {
69
+ const FNV_OFFSET = 2166136261;
70
+ const FNV_PRIME = 16777619;
71
+ let hash = FNV_OFFSET;
72
+ for (let i = 0; i < str.length; i++) {
73
+ hash ^= str.codePointAt(i) ?? 0;
74
+ hash = Math.imul(hash, FNV_PRIME);
75
+ }
76
+ return hash >>> 0;
77
+ };
78
+ /**
79
+ * Combine two hashes using FNV-1a algorithm.
80
+ * Used for query key generation.
81
+ * @internal
82
+ * @param hash1 - The first hash.
83
+ * @param hash2 - The second hash.
84
+ * @returns The combined hash.
85
+ */
86
+ const combineHashes = (hash1, hash2) => {
87
+ const FNV_PRIME = 16777619;
88
+ let hash = hash1;
89
+ for (let i = 0; i < 4; i++) {
90
+ hash ^= hash2 >> i * 8 & 255;
91
+ hash = Math.imul(hash, FNV_PRIME);
92
+ }
93
+ return hash >>> 0;
94
+ };
95
+
96
+ //#endregion
97
+ //#region src/logger.ts
98
+ configureSync({
99
+ sinks: { console: getConsoleSink({ formatter: getAnsiColorFormatter({
100
+ level: "FULL",
101
+ timestamp: "time",
102
+ category: (category) => `💬 ${category.join("·")}`
103
+ }) }) },
104
+ loggers: [{
105
+ category: "mearie",
106
+ lowestLevel: "info",
107
+ sinks: ["console"]
108
+ }, {
109
+ category: ["logtape", "meta"],
110
+ lowestLevel: "warning",
111
+ sinks: ["console"]
112
+ }]
113
+ });
114
+ const logger = getLogger(["mearie"]);
115
+ const formatMearieError = (error) => {
116
+ const parts = [
117
+ error.filePath,
118
+ error.line,
119
+ error.column
120
+ ].filter((part) => part !== void 0 && part !== null).map(String);
121
+ const location = parts.length > 0 ? parts.join(":") : "";
122
+ if (location) return `${pc.bold(error.message)} ${pc.cyan(pc.underline(location))}`;
123
+ return pc.bold(error.message);
124
+ };
125
+ /**
126
+ * Reports an error using the provided logger.
127
+ * @param logger - The logger to use.
128
+ * @param error - The error to report.
129
+ */
130
+ const report = (logger$1, error) => {
131
+ if (error instanceof MearieAggregateError) for (const err of error.errors) logger$1.error(formatMearieError(err));
132
+ else if (error instanceof MearieError) logger$1.error(formatMearieError(error));
133
+ else logger$1.error("{error}", { error });
134
+ };
135
+
136
+ //#endregion
137
+ //#region src/link.ts
138
+ /**
139
+ * @param links - The chain of links to execute.
140
+ * @param ctx - The link context.
141
+ * @param finalHandler - The final handler function.
142
+ * @returns The link result.
143
+ */
144
+ const executeLinks = (links, ctx, finalHandler) => {
145
+ let index = 0;
146
+ const dispatch = async () => {
147
+ if (index >= links.length) return await finalHandler(ctx);
148
+ const link = links[index++];
149
+ if (!link) throw new Error("Link is undefined");
150
+ return link.execute(ctx, dispatch);
151
+ };
152
+ return dispatch();
153
+ };
154
+
155
+ //#endregion
156
+ //#region src/links/dedup.ts
157
+ /**
158
+ * @returns The deduplication link.
159
+ */
160
+ const createDedupLink = () => {
161
+ const pending = /* @__PURE__ */ new Map();
162
+ return {
163
+ name: "dedup",
164
+ async execute(ctx, next) {
165
+ const { document, variables } = ctx.operation;
166
+ const queryHash = document.hash;
167
+ const key = combineHashes(queryHash, variables ? hashString(stableStringify(variables)) : 0);
168
+ const existing = pending.get(key);
169
+ if (existing) return existing;
170
+ const promise = next();
171
+ pending.set(key, promise);
172
+ try {
173
+ return await promise;
174
+ } finally {
175
+ pending.delete(key);
176
+ }
177
+ }
178
+ };
179
+ };
180
+ const dedupLink = createDedupLink;
181
+
182
+ //#endregion
183
+ //#region src/links/retry.ts
184
+ /**
185
+ * @param options - The retry options.
186
+ * @returns The retry link.
187
+ */
188
+ const createRetryLink = (options = {}) => {
189
+ const { maxAttempts = 3, backoff = (attempt) => Math.min(1e3 * 2 ** attempt, 3e4), shouldRetry = () => true } = options;
190
+ return {
191
+ name: "retry",
192
+ async execute(ctx, next) {
193
+ let lastError;
194
+ for (let attempt = 0; attempt < maxAttempts; attempt++) try {
195
+ return await next();
196
+ } catch (error) {
197
+ lastError = error;
198
+ if (attempt === maxAttempts - 1 || !shouldRetry(error)) throw error;
199
+ const delay = backoff(attempt);
200
+ await new Promise((resolve) => setTimeout(resolve, delay));
201
+ }
202
+ throw lastError;
203
+ }
204
+ };
205
+ };
206
+ const retryLink = createRetryLink;
207
+
208
+ //#endregion
209
+ //#region src/links/fetch.ts
210
+ /**
211
+ * @param options - The HTTP options.
212
+ * @returns The HTTP link.
213
+ */
214
+ const createHttpLink = (options) => {
215
+ const { url, credentials = "same-origin", headers = {} } = options;
216
+ return {
217
+ name: "http",
218
+ async execute(ctx) {
219
+ const { document, variables, headers: operationHeaders } = ctx.operation;
220
+ const response = await fetch(url, {
221
+ method: "POST",
222
+ credentials,
223
+ headers: {
224
+ "Content-Type": "application/json",
225
+ ...headers,
226
+ ...operationHeaders
227
+ },
228
+ body: JSON.stringify({
229
+ query: document.body,
230
+ variables
231
+ }),
232
+ signal: ctx.signal
233
+ });
234
+ if (!response.ok) throw new Error(`HTTP ${response.status}: ${response.statusText}`);
235
+ return response.json();
236
+ }
237
+ };
238
+ };
239
+ const httpLink = createHttpLink;
240
+
241
+ //#endregion
242
+ //#region src/links/auth.ts
243
+ /**
244
+ * @param options - The authentication options.
245
+ * @returns The authentication link.
246
+ */
247
+ const createAuthLink = (options) => {
248
+ const { getToken, refreshToken, header = "Authorization" } = options;
249
+ return {
250
+ name: "auth",
251
+ async execute(ctx, next) {
252
+ const token = await getToken();
253
+ if (token) ctx.operation.headers = {
254
+ ...ctx.operation.headers,
255
+ [header]: `Bearer ${token}`
256
+ };
257
+ try {
258
+ return await next();
259
+ } catch (error) {
260
+ if (refreshToken && typeof error === "object" && error !== null && "response" in error && typeof error.response === "object" && error.response !== null && "status" in error.response && error.response.status === 401) {
261
+ const newToken = await refreshToken();
262
+ ctx.operation.headers = {
263
+ ...ctx.operation.headers,
264
+ [header]: `Bearer ${newToken}`
265
+ };
266
+ return next();
267
+ }
268
+ throw error;
269
+ }
270
+ }
271
+ };
272
+ };
273
+ const authLink = createAuthLink;
274
+
275
+ //#endregion
276
+ //#region src/links/cache.ts
277
+ /**
278
+ * @param options - The cache options.
279
+ * @returns The cache link.
280
+ */
281
+ const createCacheLink = (options) => {
282
+ const { cache, fetchPolicy = "cache-first" } = options;
283
+ return {
284
+ name: "cache",
285
+ async execute(ctx, next) {
286
+ const { document, variables, kind } = ctx.operation;
287
+ if (kind === "mutation" || kind === "subscription") {
288
+ const result$1 = await next();
289
+ if (kind === "mutation" && result$1.data) cache.writeQuery(document, variables, result$1.data);
290
+ return result$1;
291
+ }
292
+ if (fetchPolicy === "network-only") {
293
+ const result$1 = await next();
294
+ if (result$1.data) cache.writeQuery(document, variables, result$1.data);
295
+ return result$1;
296
+ }
297
+ const cached = cache.readQuery(document, variables);
298
+ if (fetchPolicy === "cache-only") return { data: cached ?? void 0 };
299
+ if (fetchPolicy === "cache-first" && cached) return { data: cached };
300
+ const result = await next();
301
+ if (result.data) cache.writeQuery(document, variables, result.data);
302
+ return result;
303
+ }
304
+ };
305
+ };
306
+ const cacheLink = createCacheLink;
307
+
308
+ //#endregion
309
+ //#region src/cache/constants.ts
310
+ /**
311
+ * Special key used to mark normalized entity references in the cache.
312
+ * When an entity is normalized, it's replaced with an object containing this key
313
+ * with the entity key as the value.
314
+ * @internal
315
+ */
316
+ const EntityLinkKey = "__ref";
317
+ /**
318
+ * Special key for storing root query fields.
319
+ * @internal
320
+ */
321
+ const RootFieldKey = "__root";
322
+
323
+ //#endregion
324
+ //#region src/cache/utils.ts
325
+ /**
326
+ * Generates a unique cache key for an entity based on its typename and key field values.
327
+ * @internal
328
+ * @param typename - The GraphQL typename of the entity.
329
+ * @param keyValues - Array of key field values used to identify the entity.
330
+ * @returns A unique entity key in the format "typename:value1:value2:...".
331
+ */
332
+ const makeEntityKey = (typename, keyValues) => {
333
+ return `${typename}:${keyValues.join(":")}`;
334
+ };
335
+ /**
336
+ * Resolves GraphQL arguments by replacing variable references with their actual values.
337
+ * @internal
338
+ * @param args - Argument definitions from the query, containing either literal values or variable references.
339
+ * @param variables - Object containing the actual variable values.
340
+ * @returns Object with all arguments resolved to their actual values.
341
+ */
342
+ const resolveArguments = (args, variables) => {
343
+ const resolved = {};
344
+ for (const [key, value] of Object.entries(args)) resolved[key] = value.kind === "literal" ? value.value : variables[value.name];
345
+ return resolved;
346
+ };
347
+ /**
348
+ * Generates a cache key for a GraphQL field selection.
349
+ * Always uses the actual field name (not alias) with a hash of the arguments.
350
+ * @internal
351
+ * @param selection - The selection node containing field information.
352
+ * @param variables - Variable values for resolving argument references.
353
+ * @returns Field cache key string in "fieldName@argsHash" format.
354
+ */
355
+ const makeFieldKey = (selection, variables) => {
356
+ const argsHash = hashString(stableStringify(selection.args ? resolveArguments(selection.args, variables) : {}));
357
+ return `${selection.name}@${argsHash}`;
358
+ };
359
+ /**
360
+ * Retrieves entity metadata from the schema for a given typename.
361
+ * @internal
362
+ * @param typename - The GraphQL typename to look up.
363
+ * @param schemaMetadata - The schema metadata containing entity configurations.
364
+ * @returns Entity metadata if found, undefined otherwise.
365
+ */
366
+ const getEntityMetadata = (typename, schemaMetadata) => {
367
+ return typename ? schemaMetadata.entities[typename] : void 0;
368
+ };
369
+ /**
370
+ * Creates a unique query key combining document hash and variables.
371
+ * @internal
372
+ * @param hash - Document hash.
373
+ * @param variables - Query variables.
374
+ * @returns Unique query key.
375
+ */
376
+ const makeQueryKey = (hash, variables) => {
377
+ if (!variables || typeof variables === "object" && Object.keys(variables).length === 0) return hash;
378
+ return combineHashes(hash, hashString(stableStringify(variables)));
379
+ };
380
+ /**
381
+ * Gets a unique key for tracking a field dependency.
382
+ * @internal
383
+ * @param storageKey Storage key (entity or root query key).
384
+ * @param fieldKey Field key.
385
+ * @returns Unique dependency key in the format "storageKey.field".
386
+ */
387
+ const makeDependencyKey = (storageKey, fieldKey) => {
388
+ return `${storageKey}.${fieldKey}`;
389
+ };
390
+ /**
391
+ * Type guard to check if a value is an entity link.
392
+ * @internal
393
+ * @param value - Value to check.
394
+ * @returns True if the value is an EntityLink.
395
+ */
396
+ const isEntityLink = (value) => {
397
+ return typeof value === "object" && value !== null && EntityLinkKey in value;
398
+ };
399
+
400
+ //#endregion
401
+ //#region src/cache/normalize.ts
402
+ /**
403
+ * @param data - The data to normalize.
404
+ * @param selections - The selection nodes.
405
+ * @param schemaMetadata - The schema metadata.
406
+ * @param storage - The normalized storage map.
407
+ * @param variables - The variable values.
408
+ * @param accessor - Callback invoked when a field dependency is encountered.
409
+ */
410
+ const normalize = (data, selections, schemaMetadata, storage, variables, accessor) => {
411
+ const normalizeField = (parentKey, selections$1, value) => {
412
+ if (value === null || value === void 0) return value;
413
+ if (typeof value !== "object" || Array.isArray(value)) return value;
414
+ const data$1 = value;
415
+ const fields = {};
416
+ for (const selection of selections$1) {
417
+ const fieldKey = makeFieldKey(selection, variables);
418
+ const fieldValue = data$1[selection.alias ?? selection.name];
419
+ accessor(parentKey, fieldKey);
420
+ if (fieldValue === void 0) continue;
421
+ if (Array.isArray(fieldValue)) fields[fieldKey] = fieldValue.map((item) => selection.selections ? normalizeField(parentKey, selection.selections, item) : item);
422
+ else if (selection.selections) fields[fieldKey] = normalizeField(parentKey, selection.selections, fieldValue);
423
+ else fields[fieldKey] = fieldValue;
424
+ }
425
+ const typename = data$1.__typename;
426
+ const entityMetadata = typename ? getEntityMetadata(typename, schemaMetadata) : void 0;
427
+ if (entityMetadata) {
428
+ const keyValues = [];
429
+ for (const field of entityMetadata.keyFields) {
430
+ const fieldValue = data$1[field];
431
+ if (fieldValue == null) return fields;
432
+ keyValues.push(fieldValue);
433
+ }
434
+ const entityKey = makeEntityKey(typename, keyValues);
435
+ const normalized = {
436
+ ...storage.get(entityKey) ?? {},
437
+ ...fields
438
+ };
439
+ storage.set(entityKey, normalized);
440
+ return { [EntityLinkKey]: entityKey };
441
+ }
442
+ return fields;
443
+ };
444
+ if (data === null || typeof data !== "object") return;
445
+ const existingRoot = storage.get(RootFieldKey) ?? {};
446
+ const result = normalizeField(RootFieldKey, selections, data);
447
+ storage.set(RootFieldKey, {
448
+ ...existingRoot,
449
+ ...result
450
+ });
451
+ };
452
+
453
+ //#endregion
454
+ //#region src/cache/denormalize.ts
455
+ /**
456
+ * @param value - The value to denormalize.
457
+ * @param selection - The selection node.
458
+ * @param storage - The normalized storage map.
459
+ * @param variables - The variable values.
460
+ * @param sourceData - The source data object.
461
+ * @returns The denormalized value.
462
+ */
463
+ const denormalizeValue = (value, selection, storage, variables, sourceData) => {
464
+ if (value === null || value === void 0) return value;
465
+ if (selection.array && Array.isArray(value)) return value.map((item) => denormalizeValue(item, selection, storage, variables, sourceData));
466
+ if (typeof value !== "object" || Array.isArray(value)) return value;
467
+ const data = value;
468
+ let source = sourceData ?? data;
469
+ if (isEntityLink(data)) {
470
+ const entity = storage.get(data[EntityLinkKey]);
471
+ if (!entity || !selection.selections) return value;
472
+ source = entity;
473
+ sourceData = entity;
474
+ }
475
+ if (!selection.selections) return value;
476
+ const result = {};
477
+ for (const childSelection of selection.selections) {
478
+ const fieldKey = sourceData ? makeFieldKey(childSelection, variables) : childSelection.alias ?? childSelection.name;
479
+ const responseKey = childSelection.alias ?? childSelection.name;
480
+ const fieldValue = source[fieldKey];
481
+ if (fieldValue !== void 0) result[responseKey] = denormalizeValue(fieldValue, childSelection, storage, variables, sourceData);
482
+ }
483
+ return result;
484
+ };
485
+ /**
486
+ * @param selections - The selection nodes.
487
+ * @param storage - The normalized storage map.
488
+ * @param variables - The variable values.
489
+ * @returns The denormalized data.
490
+ */
491
+ const denormalize = (selections, storage, variables) => {
492
+ const queryRoot = storage.get(RootFieldKey);
493
+ if (!queryRoot) return null;
494
+ const result = {};
495
+ for (const selection of selections) {
496
+ const fieldKey = makeFieldKey(selection, variables);
497
+ const responseKey = selection.alias ?? selection.name;
498
+ const fieldValue = queryRoot[fieldKey];
499
+ if (fieldValue !== void 0) result[responseKey] = denormalizeValue(fieldValue, selection, storage, variables, queryRoot);
500
+ }
501
+ return Object.keys(result).length === 0 ? null : result;
502
+ };
503
+
504
+ //#endregion
505
+ //#region src/cache/cache.ts
506
+ /**
507
+ * A normalized cache that stores and manages GraphQL query results and entities.
508
+ * Supports entity normalization, cache invalidation, and reactive updates through subscriptions.
509
+ */
510
+ var Cache = class {
511
+ #storage = /* @__PURE__ */ new Map();
512
+ #dependencies = /* @__PURE__ */ new Map();
513
+ #listeners = /* @__PURE__ */ new Map();
514
+ #schemaMetadata;
515
+ constructor(schemaMetadata) {
516
+ this.#schemaMetadata = schemaMetadata;
517
+ }
518
+ /**
519
+ * Writes a query result to the cache, normalizing entities and tracking dependencies.
520
+ * @param document - GraphQL document node.
521
+ * @param variables - Query variables.
522
+ * @param result - Query result data.
523
+ */
524
+ writeQuery(document, variables, result) {
525
+ const queryKey = makeQueryKey(document.hash, variables);
526
+ normalize(result, document.selections, this.#schemaMetadata, this.#storage, variables, (storageKey, fieldKey) => {
527
+ this.#trackDependency(queryKey, storageKey, fieldKey);
528
+ });
529
+ this.#notifyListeners(queryKey);
530
+ }
531
+ /**
532
+ * Reads a query result from the cache, denormalizing entities if available.
533
+ * @param document - GraphQL document node.
534
+ * @param variables - Query variables.
535
+ * @returns Denormalized query result or null if not found.
536
+ */
537
+ readQuery(document, variables) {
538
+ return denormalize(document.selections, this.#storage, variables);
539
+ }
540
+ /**
541
+ * Subscribes to cache invalidations for a specific query.
542
+ * @param document - GraphQL document node.
543
+ * @param variables - Query variables.
544
+ * @param callback - Callback function to invoke on cache invalidation.
545
+ * @returns Unsubscribe function.
546
+ */
547
+ subscribe(document, variables, callback) {
548
+ const queryKey = makeQueryKey(document.hash, variables);
549
+ let listeners = this.#listeners.get(queryKey);
550
+ if (!listeners) {
551
+ listeners = /* @__PURE__ */ new Set();
552
+ this.#listeners.set(queryKey, listeners);
553
+ }
554
+ listeners.add(callback);
555
+ return () => {
556
+ listeners.delete(callback);
557
+ if (listeners.size === 0) this.#listeners.delete(queryKey);
558
+ };
559
+ }
560
+ /**
561
+ * Evicts a query from the cache and notifies listeners.
562
+ * @param document - GraphQL document node.
563
+ * @param variables - Query variables.
564
+ */
565
+ evictQuery(document, variables) {
566
+ const queryKey = makeQueryKey(document.hash, variables);
567
+ const queryRoot = this.#storage.get(RootFieldKey);
568
+ if (queryRoot) for (const selection of document.selections) {
569
+ const fieldKey = makeFieldKey(selection, variables);
570
+ delete queryRoot[fieldKey];
571
+ }
572
+ this.#notifyListeners(queryKey);
573
+ }
574
+ /**
575
+ * Clears all cache data.
576
+ */
577
+ clear() {
578
+ this.#storage.clear();
579
+ this.#dependencies.clear();
580
+ this.#listeners.clear();
581
+ }
582
+ /**
583
+ * Tracks dependency between a query and a storage field.
584
+ * @param queryKey - Query key to track.
585
+ * @param storageKey - Storage key (entity or root).
586
+ * @param fieldKey - Field key.
587
+ */
588
+ #trackDependency(queryKey, storageKey, fieldKey) {
589
+ const dependencyKey = makeDependencyKey(storageKey, fieldKey);
590
+ let queryKeys = this.#dependencies.get(dependencyKey);
591
+ if (!queryKeys) {
592
+ queryKeys = /* @__PURE__ */ new Set();
593
+ this.#dependencies.set(dependencyKey, queryKeys);
594
+ }
595
+ queryKeys.add(queryKey);
596
+ }
597
+ /**
598
+ * Notifies all listeners subscribed to a query.
599
+ * @param queryKey - Query key to notify listeners for.
600
+ */
601
+ #notifyListeners(queryKey) {
602
+ const listeners = this.#listeners.get(queryKey);
603
+ if (listeners) for (const listener of listeners) listener();
604
+ }
605
+ };
606
+
607
+ //#endregion
608
+ //#region src/client.ts
609
+ /**
610
+ * GraphQL client for executing queries and mutations.
611
+ */
612
+ var Client = class {
613
+ links;
614
+ cache;
615
+ /**
616
+ * @param config - The client configuration.
617
+ */
618
+ constructor(config) {
619
+ this.links = config.links.map((link) => typeof link === "function" ? link() : link);
620
+ this.cache = config.cache;
621
+ }
622
+ /**
623
+ * @param document - The query document.
624
+ * @param variables - The query variables.
625
+ * @returns The query result.
626
+ */
627
+ async query(document, variables) {
628
+ return { data: {} };
629
+ }
630
+ /**
631
+ * @param document - The mutation document.
632
+ * @param variables - The mutation variables.
633
+ * @returns The mutation result.
634
+ */
635
+ async mutate(document, variables) {
636
+ return { data: {} };
637
+ }
638
+ /**
639
+ * @param document - The mutation document.
640
+ * @param variables - The mutation variables.
641
+ * @returns The mutation result.
642
+ */
643
+ async mutation(document, variables) {
644
+ return { data: {} };
645
+ }
646
+ /**
647
+ * @param document - The subscription document.
648
+ * @param variables - The subscription variables.
649
+ * @returns An observable of subscription results.
650
+ */
651
+ subscription(document, variables) {
652
+ return { subscribe: () => ({ unsubscribe: () => {} }) };
653
+ }
654
+ /**
655
+ * @param fragment - The fragment document.
656
+ * @param fragmentRef - The fragment reference data.
657
+ * @returns The fragment data.
658
+ */
659
+ readFragment(fragment, fragmentRef) {
660
+ return {};
661
+ }
662
+ /**
663
+ * @returns The normalized cache instance.
664
+ */
665
+ getCache() {
666
+ return this.cache;
667
+ }
668
+ };
669
+ /**
670
+ * @param config - The client configuration.
671
+ * @returns A new client instance.
672
+ */
673
+ const createClient = (config) => {
674
+ return new Client(config);
675
+ };
676
+
677
+ //#endregion
1
678
  //#region src/index.ts
2
- var src_default = {};
679
+ const graphql = () => {};
3
680
 
4
681
  //#endregion
5
- export { src_default as default };
682
+ export { Client, MearieAggregateError, MearieError, Cache as NormalizedCache, authLink, cacheLink, combineHashes, createClient, dedupLink, executeLinks, graphql, hashString, httpLink, logger, report, retryLink, stableStringify };