adaptic-backend 1.0.286 → 1.0.288

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,12 +1,57 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.split = exports.onError = exports.setContext = exports.HttpLink = exports.InMemoryCache = exports.gql = exports.ApolloError = exports.ApolloClient = exports.client = void 0;
4
40
  exports.getApolloClient = getApolloClient;
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.
41
+ // ==========================
42
+ // 2. Static (Client-side) Imports
43
+ // Use default import and destructuring so that CommonJS modules export correctly in ESM.
44
+ // ==========================
45
+ const pkg = __importStar(require("@apollo/client"));
46
+ const { ApolloClient: ApolloClientImported, InMemoryCache: InMemoryCacheImported, HttpLink: HttpLinkImported, gql: gqlImported, ApolloError: ApolloErrorImported, split: splitImported, } = pkg;
47
+ const context_cjs_1 = __importDefault(require("@apollo/client/link/context/context.cjs"));
48
+ const { setContext: setContextImported } = context_cjs_1.default;
49
+ const error_cjs_1 = __importDefault(require("@apollo/client/link/error/error.cjs"));
50
+ const { onError: onErrorImported } = error_cjs_1.default;
51
+ // ==========================
52
+ // 3. Declare Runtime Variables
53
+ // These variables will eventually be assigned the proper implementations based on the runtime.
54
+ // ==========================
10
55
  let ApolloClient;
11
56
  let ApolloError;
12
57
  let gql;
@@ -15,12 +60,15 @@ let HttpLink;
15
60
  let setContext;
16
61
  let onError;
17
62
  let split;
18
- // Detect if we are in a server-like environment (including AWS Lambda).
63
+ // ==========================
64
+ // 4. Environment Detection & Conditional Assignment
65
+ // We check if we are in a server environment (including AWS Lambda)
66
+ // ==========================
19
67
  const isLambda = Boolean(process.env.AWS_EXECUTION_ENV);
20
68
  const isServer = typeof window === "undefined";
21
- // Conditional logic: on server (or AWS Lambda) use require(), on client use the static imports.
22
69
  if (isServer || isLambda) {
23
- // Server-side: Use require() to load the modules at runtime.
70
+ // --- Server-side (or AWS Lambda) ---
71
+ // Use require() to load the modules synchronously at runtime.
24
72
  const pkg = require("@apollo/client");
25
73
  exports.ApolloClient = ApolloClient = pkg.ApolloClient;
26
74
  exports.InMemoryCache = InMemoryCache = pkg.InMemoryCache;
@@ -28,24 +76,27 @@ if (isServer || isLambda) {
28
76
  exports.gql = gql = pkg.gql;
29
77
  exports.ApolloError = ApolloError = pkg.ApolloError;
30
78
  exports.split = split = pkg.split;
31
- // Require the additional packages for context and error links.
79
+ // Load additional submodules.
32
80
  const contextPkg = require("@apollo/client/link/context/context.cjs");
33
81
  exports.setContext = setContext = contextPkg.setContext;
34
82
  const errorPkg = require("@apollo/client/link/error/error.cjs");
35
83
  exports.onError = onError = errorPkg.onError;
36
84
  }
37
85
  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;
86
+ // --- Client-side ---
87
+ // Use the statically imported implementations.
88
+ exports.ApolloClient = ApolloClient = ApolloClientImported;
89
+ exports.InMemoryCache = InMemoryCache = InMemoryCacheImported;
90
+ exports.HttpLink = HttpLink = HttpLinkImported;
91
+ exports.gql = gql = gqlImported;
92
+ exports.ApolloError = ApolloError = ApolloErrorImported;
93
+ exports.setContext = setContext = setContextImported;
94
+ exports.onError = onError = onErrorImported;
95
+ exports.split = split = splitImported;
47
96
  }
48
- // Singleton instance for the Apollo Client.
97
+ // ==========================
98
+ // 5. Apollo Client Initialization & Singleton Pattern
99
+ // ==========================
49
100
  let apolloClient = null;
50
101
  /**
51
102
  * Initializes a new Apollo Client instance.
@@ -95,6 +146,8 @@ function getApolloClient() {
95
146
  }
96
147
  return apolloClient;
97
148
  }
98
- // Export the singleton instance.
149
+ // ==========================
150
+ // 6. Exports
151
+ // ==========================
99
152
  exports.client = getApolloClient();
100
153
  //# sourceMappingURL=client.js.map
package/client.d.ts CHANGED
@@ -1,7 +1,10 @@
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";
2
+ import * as pkg from "@apollo/client";
3
+ declare const ApolloClientImported: typeof ApolloClientType, InMemoryCacheImported: typeof InMemoryCacheType, HttpLinkImported: typeof HttpLinkType, gqlImported: typeof pkg.gql, ApolloErrorImported: typeof pkg.ApolloError, splitImported: typeof pkg.ApolloLink.split;
4
+ import contextPkg from "@apollo/client/link/context/context.cjs";
5
+ declare const setContextImported: typeof contextPkg.setContext;
6
+ import errorPkg from "@apollo/client/link/error/error.cjs";
7
+ declare const onErrorImported: typeof errorPkg.onError;
5
8
  declare let ApolloClient: typeof ApolloClientImported;
6
9
  declare let ApolloError: typeof ApolloErrorImported;
7
10
  declare let gql: typeof gqlImported;