adaptic-backend 1.0.283 → 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 +55 -28
- package/client.d.ts +4 -9
- package/esm/client.d.ts +4 -9
- package/esm/client.d.ts.map +1 -1
- package/esm/client.js.map +1 -1
- package/esm/client.mjs +49 -30
- package/package.json +1 -1
package/client.cjs
CHANGED
@@ -3,35 +3,61 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
4
|
exports.split = exports.onError = exports.setContext = exports.HttpLink = exports.InMemoryCache = exports.gql = exports.ApolloError = exports.ApolloClient = exports.client = void 0;
|
5
5
|
exports.getApolloClient = getApolloClient;
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
let
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
+
};
|
27
|
+
}
|
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;
|
32
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;
|
33
59
|
// --- Apollo Client Setup ---
|
34
|
-
// Use the type-only alias
|
60
|
+
// Use the type-only alias for type annotations.
|
35
61
|
let apolloClient = null;
|
36
62
|
/**
|
37
63
|
* Initializes a new Apollo Client instance.
|
@@ -46,6 +72,7 @@ function initializeApollo() {
|
|
46
72
|
const httpLinkInstance = new HttpLink({ uri: httpUrl, fetch });
|
47
73
|
// Create the auth link.
|
48
74
|
const authLink = setContext((_, { headers }) => {
|
75
|
+
// Retrieve the token from environment variables or other secure storage.
|
49
76
|
const token = process.env.SERVER_AUTH_TOKEN || "";
|
50
77
|
return {
|
51
78
|
headers: {
|
@@ -80,6 +107,6 @@ function getApolloClient() {
|
|
80
107
|
}
|
81
108
|
return apolloClient;
|
82
109
|
}
|
83
|
-
// Export the singleton instance.
|
110
|
+
// Export the singleton instance for convenience.
|
84
111
|
exports.client = getApolloClient();
|
85
112
|
//# sourceMappingURL=client.js.map
|
package/client.d.ts
CHANGED
@@ -1,18 +1,13 @@
|
|
1
1
|
import type { ApolloClient as ApolloClientType, InMemoryCache as InMemoryCacheType, HttpLink as HttpLinkType, NormalizedCacheObject } from "@apollo/client";
|
2
|
-
declare
|
3
|
-
declare
|
4
|
-
declare
|
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;
|
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;
|
10
5
|
/**
|
11
6
|
* Retrieves the singleton Apollo Client instance.
|
12
7
|
* @returns ApolloClient instance.
|
13
8
|
*/
|
14
9
|
export declare function getApolloClient(): ApolloClientType<NormalizedCacheObject>;
|
15
10
|
export declare const client: ApolloClientType<NormalizedCacheObject>;
|
16
|
-
export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split };
|
11
|
+
export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split, };
|
17
12
|
export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, };
|
18
13
|
//# sourceMappingURL=client.d.ts.map
|
package/esm/client.d.ts
CHANGED
@@ -1,18 +1,13 @@
|
|
1
1
|
import type { ApolloClient as ApolloClientType, InMemoryCache as InMemoryCacheType, HttpLink as HttpLinkType, NormalizedCacheObject } from "@apollo/client";
|
2
|
-
declare
|
3
|
-
declare
|
4
|
-
declare
|
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;
|
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;
|
10
5
|
/**
|
11
6
|
* Retrieves the singleton Apollo Client instance.
|
12
7
|
* @returns ApolloClient instance.
|
13
8
|
*/
|
14
9
|
export declare function getApolloClient(): ApolloClientType<NormalizedCacheObject>;
|
15
10
|
export declare const client: ApolloClientType<NormalizedCacheObject>;
|
16
|
-
export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split };
|
11
|
+
export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split, };
|
17
12
|
export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, };
|
18
13
|
//# sourceMappingURL=client.d.ts.map
|
package/esm/client.d.ts.map
CHANGED
@@ -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;
|
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"}
|
package/esm/client.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,YAAY;AAUZ,
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,YAAY;AAUZ;;;;;GAKG;AACH,SAAS,uBAAuB;IAC9B,6BAA6B;IAC7B,4CAA4C;IAC5C,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC;IAE3C,8EAA8E;IAC9E,MAAM,YAAY,GAAG,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;IACvC,OAAO;QACL,6DAA6D;QAC7D,YAAY,EAAE,GAAG,CAAC,YAAY,IAAI,YAAY,CAAC,YAAY;QAC3D,aAAa,EAAE,GAAG,CAAC,aAAa,IAAI,YAAY,CAAC,aAAa;QAC9D,QAAQ,EAAE,GAAG,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ;QAC/C,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,YAAY,CAAC,GAAG;QAChC,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,YAAY,CAAC,WAAW;QACxD,KAAK,EAAE,GA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EAA2E;AAC3E,OAAO,EACL,YAAY,EACZ,WAAW,EACX,GAAG,EACH,aAAa,EACb,QAAQ,EACR,UAAU,EACV,OAAO,EACP,KAAK,GACN,CAAC"}
|
package/esm/client.mjs
CHANGED
@@ -1,33 +1,51 @@
|
|
1
1
|
// client.ts
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
let
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
2
|
+
/**
|
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.
|
7
|
+
*/
|
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;
|
34
|
+
}
|
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;
|
28
42
|
}
|
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();
|
29
47
|
// --- Apollo Client Setup ---
|
30
|
-
// Use the type-only alias
|
48
|
+
// Use the type-only alias for type annotations.
|
31
49
|
let apolloClient = null;
|
32
50
|
/**
|
33
51
|
* Initializes a new Apollo Client instance.
|
@@ -42,6 +60,7 @@ function initializeApollo() {
|
|
42
60
|
const httpLinkInstance = new HttpLink({ uri: httpUrl, fetch });
|
43
61
|
// Create the auth link.
|
44
62
|
const authLink = setContext((_, { headers }) => {
|
63
|
+
// Retrieve the token from environment variables or other secure storage.
|
45
64
|
const token = process.env.SERVER_AUTH_TOKEN || "";
|
46
65
|
return {
|
47
66
|
headers: {
|
@@ -76,8 +95,8 @@ export function getApolloClient() {
|
|
76
95
|
}
|
77
96
|
return apolloClient;
|
78
97
|
}
|
79
|
-
// Export the singleton instance.
|
98
|
+
// Export the singleton instance for convenience.
|
80
99
|
export const client = getApolloClient();
|
81
|
-
// Re-export
|
82
|
-
export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split };
|
100
|
+
// Re-export runtime implementations so they can be imported in other code.
|
101
|
+
export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split, };
|
83
102
|
//# sourceMappingURL=client.js.map
|
package/package.json
CHANGED