adaptic-backend 1.0.290 → 1.0.291
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 +21 -82
- package/client.d.ts +4 -5
- package/esm/client.d.ts +4 -5
- package/esm/client.d.ts.map +1 -1
- package/esm/client.js.map +1 -1
- package/esm/client.mjs +15 -42
- package/package.json +1 -1
package/client.cjs
CHANGED
@@ -1,64 +1,12 @@
|
|
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
36
3
|
exports.split = exports.onError = exports.setContext = exports.HttpLink = exports.InMemoryCache = exports.gql = exports.ApolloError = exports.ApolloClient = exports.client = void 0;
|
37
4
|
exports.getApolloClient = getApolloClient;
|
38
|
-
//
|
39
|
-
|
40
|
-
|
41
|
-
const
|
42
|
-
//
|
43
|
-
// otherwise (in an ES module) use createRequire(import.meta.url).
|
44
|
-
const requireFromESM = (typeof require !== "undefined")
|
45
|
-
? require
|
46
|
-
// @ts-ignore
|
47
|
-
: (0, module_1.createRequire)(import.meta.url);
|
48
|
-
// ====================================================
|
49
|
-
// 3. Client-side Static Imports
|
50
|
-
// For the browser (client-side) we import from the standard ESM entry points.
|
51
|
-
// ====================================================
|
52
|
-
// Import the core module as a namespace to extract its members.
|
53
|
-
const pkg = __importStar(require("@apollo/client"));
|
54
|
-
const { ApolloClient: ApolloClientImported, InMemoryCache: InMemoryCacheImported, HttpLink: HttpLinkImported, gql: gqlImported, ApolloError: ApolloErrorImported, split: splitImported, } = pkg;
|
55
|
-
// Import link utilities from their ESM paths.
|
56
|
-
const context_1 = require("@apollo/client/link/context");
|
57
|
-
const error_1 = require("@apollo/client/link/error");
|
58
|
-
// ====================================================
|
59
|
-
// 4. Declare Runtime Variables
|
60
|
-
// These variables will be assigned the proper implementations based on the runtime.
|
61
|
-
// ====================================================
|
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.
|
62
10
|
let ApolloClient;
|
63
11
|
let ApolloError;
|
64
12
|
let gql;
|
@@ -67,44 +15,37 @@ let HttpLink;
|
|
67
15
|
let setContext;
|
68
16
|
let onError;
|
69
17
|
let split;
|
70
|
-
// ====================================================
|
71
|
-
// 5. Environment Detection & Conditional Assignment
|
72
|
-
// We check if we are in a server-like environment (including AWS Lambda).
|
73
|
-
// ====================================================
|
74
18
|
const isLambda = Boolean(process.env.AWS_EXECUTION_ENV);
|
75
19
|
const isServer = typeof window === "undefined";
|
20
|
+
// Conditional logic: on server use require(), on client use the static imports.
|
76
21
|
if (isServer || isLambda) {
|
77
|
-
// --- Server-side
|
78
|
-
// Use
|
79
|
-
const pkg =
|
22
|
+
// --- Server-side ---
|
23
|
+
// Use require() to load the modules at runtime.
|
24
|
+
const pkg = require("@apollo/client");
|
80
25
|
exports.ApolloClient = ApolloClient = pkg.ApolloClient;
|
81
26
|
exports.InMemoryCache = InMemoryCache = pkg.InMemoryCache;
|
82
27
|
exports.HttpLink = HttpLink = pkg.HttpLink;
|
83
28
|
exports.gql = gql = pkg.gql;
|
84
29
|
exports.ApolloError = ApolloError = pkg.ApolloError;
|
85
30
|
exports.split = split = pkg.split;
|
86
|
-
|
87
|
-
const contextPkg = requireFromESM("@apollo/client/link/context/context.cjs");
|
88
|
-
// (Note: if you prefer and if it’s supported in your version, you might also try the ESM path.)
|
31
|
+
const contextPkg = require("@apollo/client/link/context/context.cjs");
|
89
32
|
exports.setContext = setContext = contextPkg.setContext;
|
90
|
-
const errorPkg =
|
33
|
+
const errorPkg = require("@apollo/client/link/error/error.cjs");
|
91
34
|
exports.onError = onError = errorPkg.onError;
|
92
35
|
}
|
93
36
|
else {
|
94
37
|
// --- Client-side ---
|
95
38
|
// Use the statically imported implementations.
|
96
|
-
exports.ApolloClient = ApolloClient =
|
97
|
-
exports.InMemoryCache = InMemoryCache =
|
98
|
-
exports.HttpLink = HttpLink =
|
99
|
-
exports.gql = gql =
|
100
|
-
exports.ApolloError = ApolloError =
|
101
|
-
exports.setContext = setContext =
|
102
|
-
exports.onError = onError =
|
103
|
-
exports.split = split =
|
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;
|
104
47
|
}
|
105
|
-
//
|
106
|
-
// 6. Apollo Client Initialization & Singleton Pattern
|
107
|
-
// ====================================================
|
48
|
+
// Use the type-only alias (ApolloClientType) for type annotations.
|
108
49
|
let apolloClient = null;
|
109
50
|
/**
|
110
51
|
* Initializes a new Apollo Client instance.
|
@@ -154,8 +95,6 @@ function getApolloClient() {
|
|
154
95
|
}
|
155
96
|
return apolloClient;
|
156
97
|
}
|
157
|
-
//
|
158
|
-
// 7. Exports
|
159
|
-
// ====================================================
|
98
|
+
// Export the singleton instance.
|
160
99
|
exports.client = getApolloClient();
|
161
100
|
//# sourceMappingURL=client.js.map
|
package/client.d.ts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
import type { ApolloClient as ApolloClientType, InMemoryCache as InMemoryCacheType, HttpLink as HttpLinkType, NormalizedCacheObject } from "@apollo/client";
|
2
|
-
import
|
3
|
-
|
4
|
-
import {
|
5
|
-
import { onError as onErrorImported } from "@apollo/client/link/error";
|
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";
|
6
5
|
declare let ApolloClient: typeof ApolloClientImported;
|
7
6
|
declare let ApolloError: typeof ApolloErrorImported;
|
8
7
|
declare let gql: typeof gqlImported;
|
@@ -17,6 +16,6 @@ declare let split: typeof splitImported;
|
|
17
16
|
*/
|
18
17
|
export declare function getApolloClient(): ApolloClientType<NormalizedCacheObject>;
|
19
18
|
export declare const client: ApolloClientType<NormalizedCacheObject>;
|
20
|
-
export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split
|
19
|
+
export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split };
|
21
20
|
export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, };
|
22
21
|
//# sourceMappingURL=client.d.ts.map
|
package/esm/client.d.ts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
import type { ApolloClient as ApolloClientType, InMemoryCache as InMemoryCacheType, HttpLink as HttpLinkType, NormalizedCacheObject } from "@apollo/client";
|
2
|
-
import
|
3
|
-
|
4
|
-
import {
|
5
|
-
import { onError as onErrorImported } from "@apollo/client/link/error";
|
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";
|
6
5
|
declare let ApolloClient: typeof ApolloClientImported;
|
7
6
|
declare let ApolloError: typeof ApolloErrorImported;
|
8
7
|
declare let gql: typeof gqlImported;
|
@@ -17,6 +16,6 @@ declare let split: typeof splitImported;
|
|
17
16
|
*/
|
18
17
|
export declare function getApolloClient(): ApolloClientType<NormalizedCacheObject>;
|
19
18
|
export declare const client: ApolloClientType<NormalizedCacheObject>;
|
20
|
-
export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split
|
19
|
+
export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split };
|
21
20
|
export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, };
|
22
21
|
//# 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":"
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,aAAa,IAAI,iBAAiB,EAClC,QAAQ,IAAI,YAAY,EACxB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,YAAY,IAAI,oBAAoB,EACpC,aAAa,IAAI,qBAAqB,EACtC,QAAQ,IAAI,gBAAgB,EAC5B,GAAG,IAAI,WAAW,EAClB,WAAW,IAAI,mBAAmB,EAClC,KAAK,IAAI,aAAa,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC3F,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAGjF,QAAA,IAAI,YAAY,EAAE,OAAO,oBAAoB,CAAC;AAC9C,QAAA,IAAI,WAAW,EAAE,OAAO,mBAAmB,CAAC;AAC5C,QAAA,IAAI,GAAG,EAAE,OAAO,WAAW,CAAC;AAC5B,QAAA,IAAI,aAAa,EAAE,OAAO,qBAAqB,CAAC;AAChD,QAAA,IAAI,QAAQ,EAAE,OAAO,gBAAgB,CAAC;AACtC,QAAA,IAAI,UAAU,EAAE,OAAO,kBAAkB,CAAC;AAC1C,QAAA,IAAI,OAAO,EAAE,OAAO,eAAe,CAAC;AACpC,QAAA,IAAI,KAAK,EAAE,OAAO,aAAa,CAAC;AAqFhC;;;GAGG;AACH,wBAAgB,eAAe,IAAI,gBAAgB,CAAC,qBAAqB,CAAC,CAKzE;AAGD,eAAO,MAAM,MAAM,yCAAoB,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAG/F,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":"
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAQA,kCAAkC;AAClC,OAAO,EACL,YAAY,IAAI,oBAAoB,EACpC,aAAa,IAAI,qBAAqB,EACtC,QAAQ,IAAI,gBAAgB,EAC5B,GAAG,IAAI,WAAW,EAClB,WAAW,IAAI,mBAAmB,EAClC,KAAK,IAAI,aAAa,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC3F,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAEjF,kFAAkF;AAClF,IAAI,YAAyC,CAAC;AAC9C,IAAI,WAAuC,CAAC;AAC5C,IAAI,GAAuB,CAAC;AAC5B,IAAI,aAA2C,CAAC;AAChD,IAAI,QAAiC,CAAC;AACtC,IAAI,UAAqC,CAAC;AAC1C,IAAI,OAA+B,CAAC;AACpC,IAAI,KAA2B,CAAC;AAEhC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AACxD,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAE/C,gFAAgF;AAChF,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;IACzB,sBAAsB;IACtB,gDAAgD;IAChD,MAAM,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACtC,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC;IAChC,aAAa,GAAG,GAAG,CAAC,aAAa,CAAC;IAClC,QAAQ,GAAG,GAAG,CAAC,QAAQ,C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package/esm/client.mjs
CHANGED
@@ -1,27 +1,8 @@
|
|
1
|
-
//
|
2
|
-
|
3
|
-
|
4
|
-
import {
|
5
|
-
//
|
6
|
-
// otherwise (in an ES module) use createRequire(import.meta.url).
|
7
|
-
const requireFromESM = (typeof require !== "undefined")
|
8
|
-
? require
|
9
|
-
// @ts-ignore
|
10
|
-
: createRequire(import.meta.url);
|
11
|
-
// ====================================================
|
12
|
-
// 3. Client-side Static Imports
|
13
|
-
// For the browser (client-side) we import from the standard ESM entry points.
|
14
|
-
// ====================================================
|
15
|
-
// Import the core module as a namespace to extract its members.
|
16
|
-
import * as pkg from "@apollo/client";
|
17
|
-
const { ApolloClient: ApolloClientImported, InMemoryCache: InMemoryCacheImported, HttpLink: HttpLinkImported, gql: gqlImported, ApolloError: ApolloErrorImported, split: splitImported, } = pkg;
|
18
|
-
// Import link utilities from their ESM paths.
|
19
|
-
import { setContext as setContextImported } from "@apollo/client/link/context";
|
20
|
-
import { onError as onErrorImported } from "@apollo/client/link/error";
|
21
|
-
// ====================================================
|
22
|
-
// 4. Declare Runtime Variables
|
23
|
-
// These variables will be assigned the proper implementations based on the runtime.
|
24
|
-
// ====================================================
|
1
|
+
// Import runtime implementations.
|
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 runtime variables that will eventually hold the proper implementations.
|
25
6
|
let ApolloClient;
|
26
7
|
let ApolloError;
|
27
8
|
let gql;
|
@@ -30,27 +11,22 @@ let HttpLink;
|
|
30
11
|
let setContext;
|
31
12
|
let onError;
|
32
13
|
let split;
|
33
|
-
// ====================================================
|
34
|
-
// 5. Environment Detection & Conditional Assignment
|
35
|
-
// We check if we are in a server-like environment (including AWS Lambda).
|
36
|
-
// ====================================================
|
37
14
|
const isLambda = Boolean(process.env.AWS_EXECUTION_ENV);
|
38
15
|
const isServer = typeof window === "undefined";
|
16
|
+
// Conditional logic: on server use require(), on client use the static imports.
|
39
17
|
if (isServer || isLambda) {
|
40
|
-
// --- Server-side
|
41
|
-
// Use
|
42
|
-
const pkg =
|
18
|
+
// --- Server-side ---
|
19
|
+
// Use require() to load the modules at runtime.
|
20
|
+
const pkg = require("@apollo/client");
|
43
21
|
ApolloClient = pkg.ApolloClient;
|
44
22
|
InMemoryCache = pkg.InMemoryCache;
|
45
23
|
HttpLink = pkg.HttpLink;
|
46
24
|
gql = pkg.gql;
|
47
25
|
ApolloError = pkg.ApolloError;
|
48
26
|
split = pkg.split;
|
49
|
-
|
50
|
-
const contextPkg = requireFromESM("@apollo/client/link/context/context.cjs");
|
51
|
-
// (Note: if you prefer and if it’s supported in your version, you might also try the ESM path.)
|
27
|
+
const contextPkg = require("@apollo/client/link/context/context.cjs");
|
52
28
|
setContext = contextPkg.setContext;
|
53
|
-
const errorPkg =
|
29
|
+
const errorPkg = require("@apollo/client/link/error/error.cjs");
|
54
30
|
onError = errorPkg.onError;
|
55
31
|
}
|
56
32
|
else {
|
@@ -65,9 +41,7 @@ else {
|
|
65
41
|
onError = onErrorImported;
|
66
42
|
split = splitImported;
|
67
43
|
}
|
68
|
-
//
|
69
|
-
// 6. Apollo Client Initialization & Singleton Pattern
|
70
|
-
// ====================================================
|
44
|
+
// Use the type-only alias (ApolloClientType) for type annotations.
|
71
45
|
let apolloClient = null;
|
72
46
|
/**
|
73
47
|
* Initializes a new Apollo Client instance.
|
@@ -117,9 +91,8 @@ export function getApolloClient() {
|
|
117
91
|
}
|
118
92
|
return apolloClient;
|
119
93
|
}
|
120
|
-
//
|
121
|
-
// 7. Exports
|
122
|
-
// ====================================================
|
94
|
+
// Export the singleton instance.
|
123
95
|
export const client = getApolloClient();
|
124
|
-
export
|
96
|
+
// Re-export the runtime implementations so they can be imported elsewhere.
|
97
|
+
export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split };
|
125
98
|
//# sourceMappingURL=client.js.map
|
package/package.json
CHANGED