adaptic-backend 1.0.282 → 1.0.284

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/client.cjs CHANGED
@@ -1,49 +1,63 @@
1
1
  "use strict";
2
+ // client.ts
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.split = exports.onError = exports.setContext = exports.HttpLink = exports.InMemoryCache = exports.gql = exports.ApolloError = exports.ApolloClient = exports.client = void 0;
4
5
  exports.getApolloClient = getApolloClient;
5
- // Import runtime implementations.
6
- const client_1 = require("@apollo/client");
7
- const context_cjs_1 = require("@apollo/client/link/context/context.cjs");
8
- const error_cjs_1 = require("@apollo/client/link/error/error.cjs");
9
- // Declare runtime variables that will eventually hold the proper implementations.
10
- let ApolloClient;
11
- let ApolloError;
12
- let gql;
13
- let InMemoryCache;
14
- let HttpLink;
15
- let setContext;
16
- let onError;
17
- let split;
18
- // Conditional logic: on server use require(), on client use the static imports.
19
- if (typeof window === "undefined") {
20
- // --- Server-side ---
21
- // Use require() to load the modules at runtime.
22
- const pkg = require("@apollo/client");
23
- exports.ApolloClient = ApolloClient = pkg.ApolloClient;
24
- exports.InMemoryCache = InMemoryCache = pkg.InMemoryCache;
25
- exports.HttpLink = HttpLink = pkg.HttpLink;
26
- exports.gql = gql = pkg.gql;
27
- exports.ApolloError = ApolloError = pkg.ApolloError;
28
- exports.split = split = pkg.split;
29
- const contextPkg = require("@apollo/client/link/context/context.cjs");
30
- exports.setContext = setContext = contextPkg.setContext;
31
- const errorPkg = require("@apollo/client/link/error/error.cjs");
32
- exports.onError = onError = errorPkg.onError;
6
+ /**
7
+ * A helper that loads the @apollo/client package via require, handling both
8
+ * pure CJS and potential ESM interop. We also do string concatenation to
9
+ * hide the import path from bundlers (like Next.js) that might do static
10
+ * analysis on it.
11
+ */
12
+ function loadApolloClientPackage() {
13
+ // Hide from static analysis:
14
+ // e.g. let cjs = require("@apollo/client");
15
+ const cjs = require("@apollo/" + "client");
16
+ // If it's an ESM interop wrapper, the real exports might be on `cjs.default`.
17
+ const maybeDefault = cjs.default || {};
18
+ return {
19
+ // Fallback to either top-level export or cjs.default export:
20
+ ApolloClient: cjs.ApolloClient || maybeDefault.ApolloClient,
21
+ InMemoryCache: cjs.InMemoryCache || maybeDefault.InMemoryCache,
22
+ HttpLink: cjs.HttpLink || maybeDefault.HttpLink,
23
+ gql: cjs.gql || maybeDefault.gql,
24
+ ApolloError: cjs.ApolloError || maybeDefault.ApolloError,
25
+ split: cjs.split || maybeDefault.split,
26
+ };
33
27
  }
34
- else {
35
- // --- Client-side ---
36
- // Use the statically imported implementations.
37
- exports.ApolloClient = ApolloClient = client_1.ApolloClient;
38
- exports.InMemoryCache = InMemoryCache = client_1.InMemoryCache;
39
- exports.HttpLink = HttpLink = client_1.HttpLink;
40
- exports.gql = gql = client_1.gql;
41
- exports.ApolloError = ApolloError = client_1.ApolloError;
42
- exports.setContext = setContext = context_cjs_1.setContext;
43
- exports.onError = onError = error_cjs_1.onError;
44
- exports.split = split = client_1.split;
28
+ /**
29
+ * Similarly, load setContext from @apollo/client/link/context/context.cjs,
30
+ * again hiding the path from bundlers with string concatenation.
31
+ */
32
+ function loadSetContext() {
33
+ const contextCjs = require("@apollo/client/link/context/" + "context.cjs");
34
+ // If there's an ESM interop, it could be on contextCjs.default:
35
+ const maybeDefault = contextCjs.default || {};
36
+ // setContext might be on the top or on a default export:
37
+ return contextCjs.setContext || maybeDefault.setContext;
38
+ }
39
+ /**
40
+ * Similarly, load onError from @apollo/client/link/error/error.cjs
41
+ */
42
+ function loadOnError() {
43
+ const errorCjs = require("@apollo/client/link/error/" + "error.cjs");
44
+ const maybeDefault = errorCjs.default || {};
45
+ return errorCjs.onError || maybeDefault.onError;
45
46
  }
46
- // Use the type-only alias (ApolloClientType) for type annotations.
47
+ // Dynamically load all the runtime exports from @apollo/client and its submodules.
48
+ const { ApolloClient, InMemoryCache, HttpLink, gql, ApolloError, split, } = loadApolloClientPackage();
49
+ exports.ApolloClient = ApolloClient;
50
+ exports.InMemoryCache = InMemoryCache;
51
+ exports.HttpLink = HttpLink;
52
+ exports.gql = gql;
53
+ exports.ApolloError = ApolloError;
54
+ exports.split = split;
55
+ const setContext = loadSetContext();
56
+ exports.setContext = setContext;
57
+ const onError = loadOnError();
58
+ exports.onError = onError;
59
+ // --- Apollo Client Setup ---
60
+ // Use the type-only alias for type annotations.
47
61
  let apolloClient = null;
48
62
  /**
49
63
  * Initializes a new Apollo Client instance.
@@ -93,6 +107,6 @@ function getApolloClient() {
93
107
  }
94
108
  return apolloClient;
95
109
  }
96
- // Export the singleton instance.
110
+ // Export the singleton instance for convenience.
97
111
  exports.client = getApolloClient();
98
112
  //# sourceMappingURL=client.js.map
package/client.d.ts CHANGED
@@ -1,21 +1,13 @@
1
1
  import type { ApolloClient as ApolloClientType, InMemoryCache as InMemoryCacheType, HttpLink as HttpLinkType, NormalizedCacheObject } from "@apollo/client";
2
- import { ApolloClient as ApolloClientImported, InMemoryCache as InMemoryCacheImported, HttpLink as HttpLinkImported, gql as gqlImported, ApolloError as ApolloErrorImported, split as splitImported } from "@apollo/client";
3
- import { setContext as setContextImported } from "@apollo/client/link/context/context.cjs";
4
- import { onError as onErrorImported } from "@apollo/client/link/error/error.cjs";
5
- declare let ApolloClient: typeof ApolloClientImported;
6
- declare let ApolloError: typeof ApolloErrorImported;
7
- declare let gql: typeof gqlImported;
8
- declare let InMemoryCache: typeof InMemoryCacheImported;
9
- declare let HttpLink: typeof HttpLinkImported;
10
- declare let setContext: typeof setContextImported;
11
- declare let onError: typeof onErrorImported;
12
- declare let split: typeof splitImported;
2
+ declare const ApolloClient: any, InMemoryCache: any, HttpLink: any, gql: any, ApolloError: any, split: any;
3
+ declare const setContext: any;
4
+ declare const onError: any;
13
5
  /**
14
6
  * Retrieves the singleton Apollo Client instance.
15
7
  * @returns ApolloClient instance.
16
8
  */
17
9
  export declare function getApolloClient(): ApolloClientType<NormalizedCacheObject>;
18
10
  export declare const client: ApolloClientType<NormalizedCacheObject>;
19
- export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split };
11
+ export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split, };
20
12
  export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, };
21
13
  //# sourceMappingURL=client.d.ts.map