adaptic-backend 1.0.282 → 1.0.283

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,10 @@
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.
6
+ // We do NOT statically import runtime implementations because @apollo/client is CommonJS.
7
+ // Instead, we’ll load them dynamically.
10
8
  let ApolloClient;
11
9
  let ApolloError;
12
10
  let gql;
@@ -15,34 +13,24 @@ let HttpLink;
15
13
  let setContext;
16
14
  let onError;
17
15
  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.
16
+ {
17
+ // Whether on the server or the client, load the module via require.
18
+ // (If you want to differentiate, you can—but in this case we use require() in both branches.)
22
19
  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;
20
+ // If the package was imported via ESM interop, it might be on the .default property.
21
+ const clientPkg = pkg && pkg.__esModule ? pkg.default : pkg;
22
+ exports.ApolloClient = ApolloClient = clientPkg.ApolloClient;
23
+ exports.InMemoryCache = InMemoryCache = clientPkg.InMemoryCache;
24
+ exports.HttpLink = HttpLink = clientPkg.HttpLink;
25
+ exports.gql = gql = clientPkg.gql;
26
+ exports.ApolloError = ApolloError = clientPkg.ApolloError;
27
+ exports.split = split = clientPkg.split;
29
28
  const contextPkg = require("@apollo/client/link/context/context.cjs");
30
29
  exports.setContext = setContext = contextPkg.setContext;
31
30
  const errorPkg = require("@apollo/client/link/error/error.cjs");
32
31
  exports.onError = onError = errorPkg.onError;
33
32
  }
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;
45
- }
33
+ // --- Apollo Client Setup ---
46
34
  // Use the type-only alias (ApolloClientType) for type annotations.
47
35
  let apolloClient = null;
48
36
  /**
@@ -58,7 +46,6 @@ function initializeApollo() {
58
46
  const httpLinkInstance = new HttpLink({ uri: httpUrl, fetch });
59
47
  // Create the auth link.
60
48
  const authLink = setContext((_, { headers }) => {
61
- // Retrieve the token from environment variables or other secure storage.
62
49
  const token = process.env.SERVER_AUTH_TOKEN || "";
63
50
  return {
64
51
  headers: {
package/client.d.ts CHANGED
@@ -1,15 +1,12 @@
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 let ApolloClient: typeof ApolloClientType<any>;
3
+ declare let ApolloError: any;
4
+ declare let gql: any;
5
+ declare let InMemoryCache: any;
6
+ declare let HttpLink: any;
7
+ declare let setContext: any;
8
+ declare let onError: any;
9
+ declare let split: any;
13
10
  /**
14
11
  * Retrieves the singleton Apollo Client instance.
15
12
  * @returns ApolloClient instance.