adaptic-backend 1.0.284 → 1.0.286

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,63 +1,51 @@
1
1
  "use strict";
2
- // client.ts
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.split = exports.onError = exports.setContext = exports.HttpLink = exports.InMemoryCache = exports.gql = exports.ApolloError = exports.ApolloClient = exports.client = void 0;
5
4
  exports.getApolloClient = getApolloClient;
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
- };
5
+ // Statically import runtime implementations for the client (browser) environment.
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
+ // Detect if we are in a server-like environment (including AWS Lambda).
19
+ const isLambda = Boolean(process.env.AWS_EXECUTION_ENV);
20
+ const isServer = typeof window === "undefined";
21
+ // Conditional logic: on server (or AWS Lambda) use require(), on client use the static imports.
22
+ if (isServer || isLambda) {
23
+ // Server-side: Use require() to load the modules at runtime.
24
+ const pkg = require("@apollo/client");
25
+ exports.ApolloClient = ApolloClient = pkg.ApolloClient;
26
+ exports.InMemoryCache = InMemoryCache = pkg.InMemoryCache;
27
+ exports.HttpLink = HttpLink = pkg.HttpLink;
28
+ exports.gql = gql = pkg.gql;
29
+ exports.ApolloError = ApolloError = pkg.ApolloError;
30
+ exports.split = split = pkg.split;
31
+ // Require the additional packages for context and error links.
32
+ const contextPkg = require("@apollo/client/link/context/context.cjs");
33
+ exports.setContext = setContext = contextPkg.setContext;
34
+ const errorPkg = require("@apollo/client/link/error/error.cjs");
35
+ exports.onError = onError = errorPkg.onError;
27
36
  }
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;
37
+ else {
38
+ // Client-side: Use the statically imported implementations.
39
+ exports.ApolloClient = ApolloClient = client_1.ApolloClient;
40
+ exports.InMemoryCache = InMemoryCache = client_1.InMemoryCache;
41
+ exports.HttpLink = HttpLink = client_1.HttpLink;
42
+ exports.gql = gql = client_1.gql;
43
+ exports.ApolloError = ApolloError = client_1.ApolloError;
44
+ exports.setContext = setContext = context_cjs_1.setContext;
45
+ exports.onError = onError = error_cjs_1.onError;
46
+ exports.split = split = client_1.split;
46
47
  }
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.
48
+ // Singleton instance for the Apollo Client.
61
49
  let apolloClient = null;
62
50
  /**
63
51
  * Initializes a new Apollo Client instance.
@@ -107,6 +95,6 @@ function getApolloClient() {
107
95
  }
108
96
  return apolloClient;
109
97
  }
110
- // Export the singleton instance for convenience.
98
+ // Export the singleton instance.
111
99
  exports.client = getApolloClient();
112
100
  //# sourceMappingURL=client.js.map
package/client.d.ts CHANGED
@@ -1,7 +1,15 @@
1
1
  import type { ApolloClient as ApolloClientType, InMemoryCache as InMemoryCacheType, HttpLink as HttpLinkType, NormalizedCacheObject } from "@apollo/client";
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;
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;
5
13
  /**
6
14
  * Retrieves the singleton Apollo Client instance.
7
15
  * @returns ApolloClient instance.