adaptic-backend 1.0.284 → 1.0.285

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.
@@ -0,0 +1,21 @@
1
+ import type { ApolloClient as ApolloClientType, InMemoryCache as InMemoryCacheType, HttpLink as HttpLinkType, NormalizedCacheObject } from "@apollo/client";
2
+ import type { DocumentNode } from "graphql";
3
+ interface ApolloRuntimeExports {
4
+ ApolloClient: typeof import("@apollo/client").ApolloClient;
5
+ InMemoryCache: typeof import("@apollo/client").InMemoryCache;
6
+ HttpLink: typeof import("@apollo/client").HttpLink;
7
+ gql: typeof import("@apollo/client").gql;
8
+ ApolloError: any;
9
+ split: typeof import("@apollo/client").split;
10
+ setContext: any;
11
+ onError: any;
12
+ }
13
+ /**
14
+ * Returns the singleton Apollo Client.
15
+ * (You must await this call in your code.)
16
+ */
17
+ export declare function getApolloClient(): Promise<ApolloClientType<NormalizedCacheObject>>;
18
+ export declare const clientPromise: Promise<ApolloClientType<NormalizedCacheObject>>;
19
+ export declare function getApolloRuntime(): Promise<ApolloRuntimeExports>;
20
+ export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, DocumentNode, };
21
+ //# sourceMappingURL=client-esm.d.ts.map
package/client.cjs CHANGED
@@ -1,78 +1,44 @@
1
1
  "use strict";
2
- // client.ts
2
+ // src/client-cjs.ts
3
+ // This file is written in TypeScript and intended to be compiled as a CommonJS module.
4
+ // It uses synchronous require() to load runtime modules and handles both server and client environments.
3
5
  Object.defineProperty(exports, "__esModule", { value: true });
4
6
  exports.split = exports.onError = exports.setContext = exports.HttpLink = exports.InMemoryCache = exports.gql = exports.ApolloError = exports.ApolloClient = exports.client = void 0;
5
7
  exports.getApolloClient = getApolloClient;
8
+ const isServer = typeof window === "undefined";
6
9
  /**
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.
10
+ * Synchronously loads the Apollo Client package and its submodules using require.
11
+ * We use string concatenation to “hide” the literal path from bundler static analysis.
11
12
  */
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 || {};
13
+ function loadApolloClientCjs() {
14
+ let pkg = require("@apollo/" + "client");
15
+ // No interop check is done here because we expect a pure CommonJS export.
16
+ const { ApolloClient, InMemoryCache, HttpLink, gql, ApolloError, split } = pkg;
17
+ const contextPkg = require("@apollo/client/link/context/" + "context.cjs");
18
+ const errorPkg = require("@apollo/client/link/error/" + "error.cjs");
18
19
  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,
20
+ ApolloClient,
21
+ InMemoryCache,
22
+ HttpLink,
23
+ gql,
24
+ ApolloError,
25
+ split,
26
+ setContext: contextPkg.setContext,
27
+ onError: errorPkg.onError,
26
28
  };
27
29
  }
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;
46
- }
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.
30
+ // Synchronously load and cache the runtime exports.
31
+ const apolloExports = loadApolloClientCjs();
32
+ // Singleton Apollo Client instance.
61
33
  let apolloClient = null;
62
- /**
63
- * Initializes a new Apollo Client instance.
64
- * @returns ApolloClient instance.
65
- */
66
34
  function initializeApollo() {
35
+ const { ApolloClient, InMemoryCache, HttpLink, setContext, onError } = apolloExports;
67
36
  const isProduction = process.env.NODE_ENV === "production";
68
- const httpUrl = isProduction
37
+ const httpUrl = isProduction || process.env.BACKEND_HTTPS_URL
69
38
  ? process.env.BACKEND_HTTPS_URL || "https://api.adaptic.ai/graphql"
70
39
  : "http://localhost:4000/graphql";
71
- // Create the HTTP link.
72
40
  const httpLinkInstance = new HttpLink({ uri: httpUrl, fetch });
73
- // Create the auth link.
74
41
  const authLink = setContext((_, { headers }) => {
75
- // Retrieve the token from environment variables or other secure storage.
76
42
  const token = process.env.SERVER_AUTH_TOKEN || "";
77
43
  return {
78
44
  headers: {
@@ -82,24 +48,23 @@ function initializeApollo() {
82
48
  },
83
49
  };
84
50
  });
85
- // Create the error handling link.
86
51
  const errorLink = onError(({ graphQLErrors, networkError }) => {
87
52
  if (graphQLErrors) {
88
- graphQLErrors.forEach(({ message, locations, path }) => console.error(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`));
53
+ graphQLErrors.forEach(({ message, locations, path }) => {
54
+ console.error(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);
55
+ });
89
56
  }
90
57
  if (networkError) {
91
58
  console.error(`[Network error]: ${networkError}`);
92
59
  }
93
60
  });
94
- // Combine the links and initialize the Apollo Client.
95
61
  return new ApolloClient({
96
62
  link: errorLink.concat(authLink.concat(httpLinkInstance)),
97
63
  cache: new InMemoryCache(),
98
64
  });
99
65
  }
100
66
  /**
101
- * Retrieves the singleton Apollo Client instance.
102
- * @returns ApolloClient instance.
67
+ * Returns the singleton Apollo Client (synchronously).
103
68
  */
104
69
  function getApolloClient() {
105
70
  if (!apolloClient) {
@@ -107,6 +72,7 @@ function getApolloClient() {
107
72
  }
108
73
  return apolloClient;
109
74
  }
110
- // Export the singleton instance for convenience.
111
75
  exports.client = getApolloClient();
76
+ // Re-export the runtime implementations so they can be imported by other modules.
77
+ exports.ApolloClient = apolloExports.ApolloClient, exports.ApolloError = apolloExports.ApolloError, exports.gql = apolloExports.gql, exports.InMemoryCache = apolloExports.InMemoryCache, exports.HttpLink = apolloExports.HttpLink, exports.setContext = apolloExports.setContext, exports.onError = apolloExports.onError, exports.split = apolloExports.split;
112
78
  //# sourceMappingURL=client.js.map
package/client.d.ts CHANGED
@@ -1,13 +1,10 @@
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 type { DocumentNode } from "graphql";
5
3
  /**
6
- * Retrieves the singleton Apollo Client instance.
7
- * @returns ApolloClient instance.
4
+ * Returns the singleton Apollo Client (synchronously).
8
5
  */
9
6
  export declare function getApolloClient(): ApolloClientType<NormalizedCacheObject>;
10
7
  export declare const client: ApolloClientType<NormalizedCacheObject>;
11
- export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split, };
12
- export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, };
8
+ export declare const ApolloClient: typeof ApolloClientType, ApolloError: any, gql: typeof import("graphql-tag").gql, InMemoryCache: typeof InMemoryCacheType, HttpLink: typeof HttpLinkType, setContext: any, onError: any, split: typeof import("@apollo/client").ApolloLink.split;
9
+ export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, DocumentNode, };
13
10
  //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1,21 @@
1
+ import type { ApolloClient as ApolloClientType, InMemoryCache as InMemoryCacheType, HttpLink as HttpLinkType, NormalizedCacheObject } from "@apollo/client";
2
+ import type { DocumentNode } from "graphql";
3
+ interface ApolloRuntimeExports {
4
+ ApolloClient: typeof import("@apollo/client").ApolloClient;
5
+ InMemoryCache: typeof import("@apollo/client").InMemoryCache;
6
+ HttpLink: typeof import("@apollo/client").HttpLink;
7
+ gql: typeof import("@apollo/client").gql;
8
+ ApolloError: any;
9
+ split: typeof import("@apollo/client").split;
10
+ setContext: any;
11
+ onError: any;
12
+ }
13
+ /**
14
+ * Returns the singleton Apollo Client.
15
+ * (You must await this call in your code.)
16
+ */
17
+ export declare function getApolloClient(): Promise<ApolloClientType<NormalizedCacheObject>>;
18
+ export declare const clientPromise: Promise<ApolloClientType<NormalizedCacheObject>>;
19
+ export declare function getApolloRuntime(): Promise<ApolloRuntimeExports>;
20
+ export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, DocumentNode, };
21
+ //# sourceMappingURL=client-esm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-esm.d.ts","sourceRoot":"","sources":["../../src/client-esm.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,aAAa,IAAI,iBAAiB,EAClC,QAAQ,IAAI,YAAY,EACxB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI5C,UAAU,oBAA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AAC,CAAC;QACzD,KAAK,EAAE,IAAI,aAAa,EAAE;KAC3B,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,YAAY,GAAG,MAAM,gBAAgB,EAAE,CAAC;IAC1C,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,iEAAiE;AACjE,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,EAAE,CAAC;AAE/C,4DAA4D;AAC5D,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,OAAO,gBAAgB,EAAE,CAAC;AAC5B,CAAC"}
package/esm/client.d.ts CHANGED
@@ -1,13 +1,10 @@
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 type { DocumentNode } from "graphql";
5
3
  /**
6
- * Retrieves the singleton Apollo Client instance.
7
- * @returns ApolloClient instance.
4
+ * Returns the singleton Apollo Client (synchronously).
8
5
  */
9
6
  export declare function getApolloClient(): ApolloClientType<NormalizedCacheObject>;
10
7
  export declare const client: ApolloClientType<NormalizedCacheObject>;
11
- export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split, };
12
- export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, };
8
+ export declare const ApolloClient: typeof ApolloClientType, ApolloError: any, gql: typeof import("graphql-tag").gql, InMemoryCache: typeof InMemoryCacheType, HttpLink: typeof HttpLinkType, setContext: any, onError: any, split: typeof import("@apollo/client").ApolloLink.split;
9
+ export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, DocumentNode, };
13
10
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,aAAa,IAAI,iBAAiB,EAClC,QAAQ,IAAI,YAAY,EACxB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAgDxB,QAAA,MACE,YAAY,OACZ,aAAa,OACb,QAAQ,OACR,GAAG,OACH,WAAW,OACX,KAAK,KACsB,CAAC;AAC9B,QAAA,MAAM,UAAU,KAAmB,CAAC;AACpC,QAAA,MAAM,OAAO,KAAgB,CAAC;AAsD9B;;;GAGG;AACH,wBAAgB,eAAe,IAAI,gBAAgB,CAAC,qBAAqB,CAAC,CAKzE;AAGD,eAAO,MAAM,MAAM,yCAAoB,CAAC;AAGxC,OAAO,EACL,YAAY,EACZ,WAAW,EACX,GAAG,EACH,aAAa,EACb,QAAQ,EACR,UAAU,EACV,OAAO,EACP,KAAK,GACN,CAAC;AAGF,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,GACtB,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,aAAa,IAAI,iBAAiB,EAClC,QAAQ,IAAI,YAAY,EACxB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AA8E5C;;GAEG;AACH,wBAAgB,eAAe,IAAI,gBAAgB,CAAC,qBAAqB,CAAC,CAKzE;AAED,eAAO,MAAM,MAAM,yCAAoB,CAAC;AAGxC,eAAO,MACL,YAAY,2BACZ,WAAW,OACX,GAAG,oCACH,aAAa,4BACb,QAAQ,uBACR,UAAU,OACV,OAAO,OACP,KAAK,kDACU,CAAC;AAGlB,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACrB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AM,SAAS,GAAG,OAAO,CAAC,CAAC,EAAE,aAAa,EAAE,YAAY,EAAO,EAAE,EAAE;QACjE,IAAI,aAAa,EAAE,CAAC;YAClB,aAAa,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAO,EAAE,EAAE;gBAC1D,OAAO,CAAC,KAAK,CAAC,6BAA6B,OAAO,eAAe,SAAS,WAAW,IAAI,EAAE,CAAC,CAAC;YAC/F,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,CAAC,KAAK,CAAC,oBAAoB,YAAY,EAAE,CAAC,CAAC;QACpD,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,YAAY,CAAC;QACtB,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACzD,KAAK,EAAE,IAAI,aAAa,EAAE;KAC3B,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,YAAY,GAAG,gBAAgB,EAAE,CAAC;IACpC,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;AAExC,kFAAkF;AAClF,MAAM,CAAC,MAAM,EACX,YAAY,EACZ,WAAW,EACX,GAAG,EACH,aAAa,EACb,QAAQ,EACR,UAAU,EACV,OAAO,EACP,KAAK,GACN,GAAG,aAAa,CAAC"}
package/esm/client.mjs CHANGED
@@ -1,66 +1,69 @@
1
- // client.ts
1
+ // client-esm.ts
2
+ // This file avoids createRequire(import.meta.url) by using a simple if-check
3
+ // for server vs. client. On the server, we do a require() if it's available.
4
+ // On the client, we do a dynamic import(). We also do string concatenation
5
+ // to hide the literal import path from bundlers like Next.js.
6
+ const isServer = typeof window === "undefined";
2
7
  /**
3
- * A helper that loads the @apollo/client package via require, handling both
4
- * pure CJS and potential ESM interop. We also do string concatenation to
5
- * hide the import path from bundlers (like Next.js) that might do static
6
- * analysis on it.
8
+ * Loads the Apollo Client package and its submodules.
9
+ * - On the server (if require is available): uses require().
10
+ * - On the client (browser): uses dynamic import().
7
11
  */
8
- function loadApolloClientPackage() {
9
- // Hide from static analysis:
10
- // e.g. let cjs = require("@apollo/client");
11
- const cjs = require("@apollo/" + "client");
12
- // If it's an ESM interop wrapper, the real exports might be on `cjs.default`.
13
- const maybeDefault = cjs.default || {};
14
- return {
15
- // Fallback to either top-level export or cjs.default export:
16
- ApolloClient: cjs.ApolloClient || maybeDefault.ApolloClient,
17
- InMemoryCache: cjs.InMemoryCache || maybeDefault.InMemoryCache,
18
- HttpLink: cjs.HttpLink || maybeDefault.HttpLink,
19
- gql: cjs.gql || maybeDefault.gql,
20
- ApolloError: cjs.ApolloError || maybeDefault.ApolloError,
21
- split: cjs.split || maybeDefault.split,
22
- };
23
- }
24
- /**
25
- * Similarly, load setContext from @apollo/client/link/context/context.cjs,
26
- * again hiding the path from bundlers with string concatenation.
27
- */
28
- function loadSetContext() {
29
- const contextCjs = require("@apollo/client/link/context/" + "context.cjs");
30
- // If there's an ESM interop, it could be on contextCjs.default:
31
- const maybeDefault = contextCjs.default || {};
32
- // setContext might be on the top or on a default export:
33
- return contextCjs.setContext || maybeDefault.setContext;
12
+ async function loadApolloClientEsm() {
13
+ if (isServer && typeof require !== "undefined") {
14
+ // --- Server path: require()
15
+ let pkg = require("@apollo/" + "client");
16
+ // We assume it's CommonJS. If there's an ESM interop wrapper, you might check pkg.default.
17
+ const { ApolloClient, InMemoryCache, HttpLink, gql, ApolloError, split } = pkg;
18
+ const contextPkg = require("@apollo/client/link/context/" + "context.cjs");
19
+ const errorPkg = require("@apollo/client/link/error/" + "error.cjs");
20
+ return {
21
+ ApolloClient,
22
+ InMemoryCache,
23
+ HttpLink,
24
+ gql,
25
+ ApolloError,
26
+ split,
27
+ setContext: contextPkg.setContext,
28
+ onError: errorPkg.onError,
29
+ };
30
+ }
31
+ else {
32
+ // --- Client path: dynamic import
33
+ let pkg = await import("@apollo/client");
34
+ const { ApolloClient, InMemoryCache, HttpLink, gql, ApolloError, split } = pkg;
35
+ const contextPkg = await import("@apollo/client/link/context/" + "context.cjs");
36
+ const errorPkg = await import("@apollo/client/link/error/" + "error.cjs");
37
+ return {
38
+ ApolloClient,
39
+ InMemoryCache,
40
+ HttpLink,
41
+ gql,
42
+ ApolloError,
43
+ split,
44
+ setContext: contextPkg.setContext,
45
+ onError: errorPkg.onError,
46
+ };
47
+ }
34
48
  }
35
- /**
36
- * Similarly, load onError from @apollo/client/link/error/error.cjs
37
- */
38
- function loadOnError() {
39
- const errorCjs = require("@apollo/client/link/error/" + "error.cjs");
40
- const maybeDefault = errorCjs.default || {};
41
- return errorCjs.onError || maybeDefault.onError;
49
+ // Cache the loaded runtime exports.
50
+ let apolloExports = null;
51
+ async function getApolloExports() {
52
+ if (!apolloExports) {
53
+ apolloExports = await loadApolloClientEsm();
54
+ }
55
+ return apolloExports;
42
56
  }
43
- // Dynamically load all the runtime exports from @apollo/client and its submodules.
44
- const { ApolloClient, InMemoryCache, HttpLink, gql, ApolloError, split, } = loadApolloClientPackage();
45
- const setContext = loadSetContext();
46
- const onError = loadOnError();
47
- // --- Apollo Client Setup ---
48
- // Use the type-only alias for type annotations.
57
+ // Singleton Apollo Client instance (asynchronous in this version).
49
58
  let apolloClient = null;
50
- /**
51
- * Initializes a new Apollo Client instance.
52
- * @returns ApolloClient instance.
53
- */
54
- function initializeApollo() {
59
+ async function initializeApollo() {
60
+ const { ApolloClient, InMemoryCache, HttpLink, setContext, onError } = await getApolloExports();
55
61
  const isProduction = process.env.NODE_ENV === "production";
56
- const httpUrl = isProduction
62
+ const httpUrl = isProduction || process.env.BACKEND_HTTPS_URL
57
63
  ? process.env.BACKEND_HTTPS_URL || "https://api.adaptic.ai/graphql"
58
64
  : "http://localhost:4000/graphql";
59
- // Create the HTTP link.
60
65
  const httpLinkInstance = new HttpLink({ uri: httpUrl, fetch });
61
- // Create the auth link.
62
66
  const authLink = setContext((_, { headers }) => {
63
- // Retrieve the token from environment variables or other secure storage.
64
67
  const token = process.env.SERVER_AUTH_TOKEN || "";
65
68
  return {
66
69
  headers: {
@@ -70,33 +73,35 @@ function initializeApollo() {
70
73
  },
71
74
  };
72
75
  });
73
- // Create the error handling link.
74
76
  const errorLink = onError(({ graphQLErrors, networkError }) => {
75
77
  if (graphQLErrors) {
76
- graphQLErrors.forEach(({ message, locations, path }) => console.error(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`));
78
+ graphQLErrors.forEach(({ message, locations, path }) => {
79
+ console.error(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);
80
+ });
77
81
  }
78
82
  if (networkError) {
79
83
  console.error(`[Network error]: ${networkError}`);
80
84
  }
81
85
  });
82
- // Combine the links and initialize the Apollo Client.
83
86
  return new ApolloClient({
84
87
  link: errorLink.concat(authLink.concat(httpLinkInstance)),
85
88
  cache: new InMemoryCache(),
86
89
  });
87
90
  }
88
91
  /**
89
- * Retrieves the singleton Apollo Client instance.
90
- * @returns ApolloClient instance.
92
+ * Returns the singleton Apollo Client.
93
+ * (You must await this call in your code.)
91
94
  */
92
- export function getApolloClient() {
95
+ export async function getApolloClient() {
93
96
  if (!apolloClient) {
94
- apolloClient = initializeApollo();
97
+ apolloClient = await initializeApollo();
95
98
  }
96
99
  return apolloClient;
97
100
  }
98
- // Export the singleton instance for convenience.
99
- export const client = getApolloClient();
100
- // Re-export runtime implementations so they can be imported in other code.
101
- export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split, };
102
- //# sourceMappingURL=client.js.map
101
+ // For convenience, export a promise that resolves to the client.
102
+ export const clientPromise = getApolloClient();
103
+ // Expose a helper to get all the runtime exports if needed.
104
+ export async function getApolloRuntime() {
105
+ return getApolloExports();
106
+ }
107
+ //# sourceMappingURL=client-esm.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adaptic-backend",
3
- "version": "1.0.284",
3
+ "version": "1.0.285",
4
4
  "description": "Backend executable CRUD functions with dynamic variables construction, and type definitions for the Adaptic AI platform.",
5
5
  "type": "module",
6
6
  "types": "index.d.ts",