adaptic-backend 1.0.292 → 1.0.294

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.
Files changed (116) hide show
  1. package/Account.cjs +75 -21
  2. package/Action.cjs +75 -21
  3. package/Alert.cjs +75 -21
  4. package/AlpacaAccount.cjs +75 -21
  5. package/Asset.cjs +75 -21
  6. package/Authenticator.cjs +75 -21
  7. package/Contract.cjs +75 -21
  8. package/Customer.cjs +75 -21
  9. package/Deliverable.cjs +75 -21
  10. package/EconomicEvent.cjs +75 -21
  11. package/MarketSentiment.cjs +75 -21
  12. package/NewsArticle.cjs +75 -21
  13. package/NewsArticleAssetSentiment.cjs +75 -21
  14. package/Order.cjs +75 -21
  15. package/Position.cjs +75 -21
  16. package/ScheduledOptionOrder.cjs +75 -21
  17. package/Session.cjs +75 -21
  18. package/StopLoss.cjs +75 -21
  19. package/TakeProfit.cjs +75 -21
  20. package/Trade.cjs +75 -21
  21. package/User.cjs +75 -21
  22. package/VerificationToken.cjs +75 -21
  23. package/apollo-client.client.cjs +17 -0
  24. package/apollo-client.client.d.ts +7 -0
  25. package/apollo-client.server.cjs +21 -0
  26. package/apollo-client.server.d.ts +7 -0
  27. package/client.cjs +80 -59
  28. package/client.d.ts +26 -17
  29. package/esm/Account.d.ts.map +1 -1
  30. package/esm/Account.js.map +1 -1
  31. package/esm/Account.mjs +64 -10
  32. package/esm/Action.d.ts.map +1 -1
  33. package/esm/Action.js.map +1 -1
  34. package/esm/Action.mjs +64 -10
  35. package/esm/Alert.d.ts.map +1 -1
  36. package/esm/Alert.js.map +1 -1
  37. package/esm/Alert.mjs +64 -10
  38. package/esm/AlpacaAccount.d.ts.map +1 -1
  39. package/esm/AlpacaAccount.js.map +1 -1
  40. package/esm/AlpacaAccount.mjs +64 -10
  41. package/esm/Asset.d.ts.map +1 -1
  42. package/esm/Asset.js.map +1 -1
  43. package/esm/Asset.mjs +64 -10
  44. package/esm/Authenticator.d.ts.map +1 -1
  45. package/esm/Authenticator.js.map +1 -1
  46. package/esm/Authenticator.mjs +64 -10
  47. package/esm/Contract.d.ts.map +1 -1
  48. package/esm/Contract.js.map +1 -1
  49. package/esm/Contract.mjs +64 -10
  50. package/esm/Customer.d.ts.map +1 -1
  51. package/esm/Customer.js.map +1 -1
  52. package/esm/Customer.mjs +64 -10
  53. package/esm/Deliverable.d.ts.map +1 -1
  54. package/esm/Deliverable.js.map +1 -1
  55. package/esm/Deliverable.mjs +64 -10
  56. package/esm/EconomicEvent.d.ts.map +1 -1
  57. package/esm/EconomicEvent.js.map +1 -1
  58. package/esm/EconomicEvent.mjs +64 -10
  59. package/esm/MarketSentiment.d.ts.map +1 -1
  60. package/esm/MarketSentiment.js.map +1 -1
  61. package/esm/MarketSentiment.mjs +64 -10
  62. package/esm/NewsArticle.d.ts.map +1 -1
  63. package/esm/NewsArticle.js.map +1 -1
  64. package/esm/NewsArticle.mjs +64 -10
  65. package/esm/NewsArticleAssetSentiment.d.ts.map +1 -1
  66. package/esm/NewsArticleAssetSentiment.js.map +1 -1
  67. package/esm/NewsArticleAssetSentiment.mjs +64 -10
  68. package/esm/Order.d.ts.map +1 -1
  69. package/esm/Order.js.map +1 -1
  70. package/esm/Order.mjs +64 -10
  71. package/esm/Position.d.ts.map +1 -1
  72. package/esm/Position.js.map +1 -1
  73. package/esm/Position.mjs +64 -10
  74. package/esm/ScheduledOptionOrder.d.ts.map +1 -1
  75. package/esm/ScheduledOptionOrder.js.map +1 -1
  76. package/esm/ScheduledOptionOrder.mjs +64 -10
  77. package/esm/Session.d.ts.map +1 -1
  78. package/esm/Session.js.map +1 -1
  79. package/esm/Session.mjs +64 -10
  80. package/esm/StopLoss.d.ts.map +1 -1
  81. package/esm/StopLoss.js.map +1 -1
  82. package/esm/StopLoss.mjs +64 -10
  83. package/esm/TakeProfit.d.ts.map +1 -1
  84. package/esm/TakeProfit.js.map +1 -1
  85. package/esm/TakeProfit.mjs +64 -10
  86. package/esm/Trade.d.ts.map +1 -1
  87. package/esm/Trade.js.map +1 -1
  88. package/esm/Trade.mjs +64 -10
  89. package/esm/User.d.ts.map +1 -1
  90. package/esm/User.js.map +1 -1
  91. package/esm/User.mjs +64 -10
  92. package/esm/VerificationToken.d.ts.map +1 -1
  93. package/esm/VerificationToken.js.map +1 -1
  94. package/esm/VerificationToken.mjs +64 -10
  95. package/esm/apollo-client.client.d.ts +7 -0
  96. package/esm/apollo-client.client.d.ts.map +1 -0
  97. package/esm/apollo-client.client.js.map +1 -0
  98. package/esm/apollo-client.client.mjs +8 -0
  99. package/esm/apollo-client.server.d.ts +7 -0
  100. package/esm/apollo-client.server.d.ts.map +1 -0
  101. package/esm/apollo-client.server.js.map +1 -0
  102. package/esm/apollo-client.server.mjs +12 -0
  103. package/esm/client.d.ts +26 -17
  104. package/esm/client.d.ts.map +1 -1
  105. package/esm/client.js.map +1 -1
  106. package/esm/client.mjs +45 -60
  107. package/generated/typegraphql-prisma/enhance.cjs +7 -7
  108. package/generated/typegraphql-prisma/index.cjs +10 -10
  109. package/generated/typegraphql-prisma/resolvers/crud/args.index.cjs +22 -22
  110. package/generated/typegraphql-prisma/resolvers/crud/index.cjs +3 -3
  111. package/generated/typegraphql-prisma/resolvers/outputs/index.cjs +1 -1
  112. package/generated/typegraphql-prisma/resolvers/relations/args.index.cjs +11 -11
  113. package/generated/typegraphql-prisma/resolvers/relations/index.cjs +2 -2
  114. package/index.cjs +1 -1
  115. package/package.json +1 -1
  116. package/server.cjs +1 -1
@@ -22,8 +22,14 @@ exports.VerificationToken = {
22
22
  * @returns The created VerificationToken or null.
23
23
  */
24
24
  async create(props, globalClient) {
25
- const client = globalClient || client_1.client;
26
- const CREATE_ONE_VERIFICATIONTOKEN = (0, client_1.gql) `
25
+ const [modules, client] = await Promise.all([
26
+ (0, client_1.getApolloModules)(),
27
+ globalClient
28
+ ? Promise.resolve(globalClient)
29
+ : client_1.client
30
+ ]);
31
+ const { gql, ApolloError } = modules;
32
+ const CREATE_ONE_VERIFICATIONTOKEN = gql `
27
33
  mutation createOneVerificationToken($data: VerificationTokenCreateInput!) {
28
34
  createOneVerificationToken(data: $data) {
29
35
  ${selectionSet}
@@ -61,8 +67,14 @@ exports.VerificationToken = {
61
67
  * @returns The count of created records or null.
62
68
  */
63
69
  async createMany(props, globalClient) {
64
- const client = globalClient || client_1.client;
65
- const CREATE_MANY_VERIFICATIONTOKEN = (0, client_1.gql) `
70
+ const [modules, client] = await Promise.all([
71
+ (0, client_1.getApolloModules)(),
72
+ globalClient
73
+ ? Promise.resolve(globalClient)
74
+ : client_1.client
75
+ ]);
76
+ const { gql, ApolloError } = modules;
77
+ const CREATE_MANY_VERIFICATIONTOKEN = gql `
66
78
  mutation createManyVerificationToken($data: [VerificationTokenCreateManyInput!]!) {
67
79
  createManyVerificationToken(data: $data) {
68
80
  count
@@ -99,8 +111,14 @@ exports.VerificationToken = {
99
111
  * @returns The updated VerificationToken or null.
100
112
  */
101
113
  async update(props, globalClient) {
102
- const client = globalClient || client_1.client;
103
- const UPDATE_ONE_VERIFICATIONTOKEN = (0, client_1.gql) `
114
+ const [modules, client] = await Promise.all([
115
+ (0, client_1.getApolloModules)(),
116
+ globalClient
117
+ ? Promise.resolve(globalClient)
118
+ : client_1.client
119
+ ]);
120
+ const { gql, ApolloError } = modules;
121
+ const UPDATE_ONE_VERIFICATIONTOKEN = gql `
104
122
  mutation updateOneVerificationToken($data: VerificationTokenUpdateInput!, $where: VerificationTokenWhereUniqueInput!) {
105
123
  updateOneVerificationToken(data: $data, where: $where) {
106
124
  ${selectionSet}
@@ -149,8 +167,14 @@ exports.VerificationToken = {
149
167
  * @returns The updated VerificationToken or null.
150
168
  */
151
169
  async upsert(props, globalClient) {
152
- const client = globalClient || client_1.client;
153
- const UPSERT_ONE_VERIFICATIONTOKEN = (0, client_1.gql) `
170
+ const [modules, client] = await Promise.all([
171
+ (0, client_1.getApolloModules)(),
172
+ globalClient
173
+ ? Promise.resolve(globalClient)
174
+ : client_1.client
175
+ ]);
176
+ const { gql, ApolloError } = modules;
177
+ const UPSERT_ONE_VERIFICATIONTOKEN = gql `
154
178
  mutation upsertOneVerificationToken($where: VerificationTokenWhereUniqueInput!, $create: VerificationTokenCreateInput!, $update: VerificationTokenUpdateInput!) {
155
179
  upsertOneVerificationToken(where: $where, create: $create, update: $update) {
156
180
  ${selectionSet}
@@ -201,8 +225,14 @@ exports.VerificationToken = {
201
225
  * @returns The count of created records or null.
202
226
  */
203
227
  async updateMany(props, globalClient) {
204
- const client = globalClient || client_1.client;
205
- const UPDATE_MANY_VERIFICATIONTOKEN = (0, client_1.gql) `
228
+ const [modules, client] = await Promise.all([
229
+ (0, client_1.getApolloModules)(),
230
+ globalClient
231
+ ? Promise.resolve(globalClient)
232
+ : client_1.client
233
+ ]);
234
+ const { gql, ApolloError } = modules;
235
+ const UPDATE_MANY_VERIFICATIONTOKEN = gql `
206
236
  mutation updateManyVerificationToken($data: [VerificationTokenCreateManyInput!]!) {
207
237
  updateManyVerificationToken(data: $data) {
208
238
  count
@@ -251,8 +281,14 @@ exports.VerificationToken = {
251
281
  * @returns The deleted VerificationToken or null.
252
282
  */
253
283
  async delete(props, globalClient) {
254
- const client = globalClient || client_1.client;
255
- const DELETE_ONE_VERIFICATIONTOKEN = (0, client_1.gql) `
284
+ const [modules, client] = await Promise.all([
285
+ (0, client_1.getApolloModules)(),
286
+ globalClient
287
+ ? Promise.resolve(globalClient)
288
+ : client_1.client
289
+ ]);
290
+ const { gql, ApolloError } = modules;
291
+ const DELETE_ONE_VERIFICATIONTOKEN = gql `
256
292
  mutation deleteOneVerificationToken($where: VerificationTokenWhereUniqueInput!) {
257
293
  deleteOneVerificationToken(where: $where) {
258
294
  ${selectionSet}
@@ -288,8 +324,14 @@ exports.VerificationToken = {
288
324
  */
289
325
  async get(props, globalClient) {
290
326
  var _a, _b;
291
- const client = globalClient || client_1.client;
292
- const GET_VERIFICATIONTOKEN = (0, client_1.gql) `
327
+ const [modules, client] = await Promise.all([
328
+ (0, client_1.getApolloModules)(),
329
+ globalClient
330
+ ? Promise.resolve(globalClient)
331
+ : client_1.client
332
+ ]);
333
+ const { gql, ApolloError } = modules;
334
+ const GET_VERIFICATIONTOKEN = gql `
293
335
  query getVerificationToken($where: VerificationTokenWhereUniqueInput!) {
294
336
  getVerificationToken(where: $where) {
295
337
  ${selectionSet}
@@ -308,7 +350,7 @@ exports.VerificationToken = {
308
350
  return (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.getVerificationToken) !== null && _b !== void 0 ? _b : null;
309
351
  }
310
352
  catch (error) {
311
- if (error instanceof client_1.ApolloError && error.message === 'No VerificationToken found') {
353
+ if (error instanceof ApolloError && error.message === 'No VerificationToken found') {
312
354
  return null;
313
355
  }
314
356
  else {
@@ -324,8 +366,14 @@ exports.VerificationToken = {
324
366
  */
325
367
  async getAll(globalClient) {
326
368
  var _a, _b;
327
- const client = globalClient || client_1.client;
328
- const GET_ALL_VERIFICATIONTOKEN = (0, client_1.gql) `
369
+ const [modules, client] = await Promise.all([
370
+ (0, client_1.getApolloModules)(),
371
+ globalClient
372
+ ? Promise.resolve(globalClient)
373
+ : client_1.client
374
+ ]);
375
+ const { gql, ApolloError } = modules;
376
+ const GET_ALL_VERIFICATIONTOKEN = gql `
329
377
  query getAllVerificationToken {
330
378
  verificationTokens {
331
379
  ${selectionSet}
@@ -338,7 +386,7 @@ exports.VerificationToken = {
338
386
  return (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.verificationTokens) !== null && _b !== void 0 ? _b : null;
339
387
  }
340
388
  catch (error) {
341
- if (error instanceof client_1.ApolloError && error.message === 'No VerificationToken found') {
389
+ if (error instanceof ApolloError && error.message === 'No VerificationToken found') {
342
390
  return null;
343
391
  }
344
392
  else {
@@ -354,8 +402,14 @@ exports.VerificationToken = {
354
402
  * @returns An array of found VerificationToken records or null.
355
403
  */
356
404
  async findMany(props, globalClient) {
357
- const client = globalClient || client_1.client;
358
- const FIND_MANY_VERIFICATIONTOKEN = (0, client_1.gql) `
405
+ const [modules, client] = await Promise.all([
406
+ (0, client_1.getApolloModules)(),
407
+ globalClient
408
+ ? Promise.resolve(globalClient)
409
+ : client_1.client
410
+ ]);
411
+ const { gql, ApolloError } = modules;
412
+ const FIND_MANY_VERIFICATIONTOKEN = gql `
359
413
  query findManyVerificationToken($where: VerificationTokenWhereInput!) {
360
414
  verificationTokens(where: $where) {
361
415
  ${selectionSet}
@@ -381,7 +435,7 @@ exports.VerificationToken = {
381
435
  }
382
436
  }
383
437
  catch (error) {
384
- if (error instanceof client_1.ApolloError && error.message === 'No VerificationToken found') {
438
+ if (error instanceof ApolloError && error.message === 'No VerificationToken found') {
385
439
  return null;
386
440
  }
387
441
  else {
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ // apollo-client.client.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.onError = exports.setContext = exports.split = exports.ApolloError = exports.gql = exports.HttpLink = exports.InMemoryCache = exports.ApolloClient = void 0;
5
+ // Import runtime implementations.
6
+ const client_1 = require("@apollo/client");
7
+ Object.defineProperty(exports, "ApolloClient", { enumerable: true, get: function () { return client_1.ApolloClient; } });
8
+ Object.defineProperty(exports, "InMemoryCache", { enumerable: true, get: function () { return client_1.InMemoryCache; } });
9
+ Object.defineProperty(exports, "HttpLink", { enumerable: true, get: function () { return client_1.HttpLink; } });
10
+ Object.defineProperty(exports, "gql", { enumerable: true, get: function () { return client_1.gql; } });
11
+ Object.defineProperty(exports, "ApolloError", { enumerable: true, get: function () { return client_1.ApolloError; } });
12
+ Object.defineProperty(exports, "split", { enumerable: true, get: function () { return client_1.split; } });
13
+ const context_1 = require("@apollo/client/link/context");
14
+ Object.defineProperty(exports, "setContext", { enumerable: true, get: function () { return context_1.setContext; } });
15
+ const error_1 = require("@apollo/client/link/error");
16
+ Object.defineProperty(exports, "onError", { enumerable: true, get: function () { return error_1.onError; } });
17
+ //# sourceMappingURL=apollo-client.client.js.map
@@ -0,0 +1,7 @@
1
+ import type { ApolloClient as ApolloClientType, InMemoryCache as InMemoryCacheType, HttpLink as HttpLinkType, NormalizedCacheObject } from "@apollo/client";
2
+ import { ApolloClient, InMemoryCache, HttpLink, gql, ApolloError, split } from "@apollo/client";
3
+ import { setContext } from "@apollo/client/link/context";
4
+ import { onError } from "@apollo/client/link/error";
5
+ export { ApolloClient, InMemoryCache, HttpLink, gql, ApolloError, split, setContext, onError, };
6
+ export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, };
7
+ //# sourceMappingURL=apollo-client.client.d.ts.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ // apollo-client.server.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.onError = exports.setContext = exports.split = exports.ApolloError = exports.gql = exports.HttpLink = exports.InMemoryCache = exports.ApolloClient = void 0;
5
+ // Use require() to load the runtime implementations.
6
+ const pkg = require("@apollo/client");
7
+ const { ApolloClient, InMemoryCache, HttpLink, gql, ApolloError, split, } = pkg;
8
+ exports.ApolloClient = ApolloClient;
9
+ exports.InMemoryCache = InMemoryCache;
10
+ exports.HttpLink = HttpLink;
11
+ exports.gql = gql;
12
+ exports.ApolloError = ApolloError;
13
+ exports.split = split;
14
+ // Some sub‑modules require a different path.
15
+ const contextPkg = require("@apollo/client/link/context/context.cjs");
16
+ const { setContext } = contextPkg;
17
+ exports.setContext = setContext;
18
+ const errorPkg = require("@apollo/client/link/error/error.cjs");
19
+ const { onError } = errorPkg;
20
+ exports.onError = onError;
21
+ //# sourceMappingURL=apollo-client.server.js.map
@@ -0,0 +1,7 @@
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;
5
+ export { ApolloClient, InMemoryCache, HttpLink, gql, ApolloError, split, setContext, onError, };
6
+ export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, };
7
+ //# sourceMappingURL=apollo-client.server.d.ts.map
package/client.cjs CHANGED
@@ -1,65 +1,81 @@
1
1
  "use strict";
2
+ // client.ts
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
2
36
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.split = exports.onError = exports.setContext = exports.HttpLink = exports.InMemoryCache = exports.gql = exports.ApolloError = exports.ApolloClient = exports.client = void 0;
37
+ exports.client = void 0;
4
38
  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.
10
- let ApolloClient;
11
- let ApolloError;
12
- let gql;
13
- let InMemoryCache;
14
- let HttpLink;
15
- let setContext;
16
- let onError;
17
- let split;
18
- const isLambda = Boolean(process.env.AWS_EXECUTION_ENV);
19
- const isServer = typeof window === "undefined";
20
- // Conditional logic: on server use require(), on client use the static imports.
21
- if (isServer || isLambda) {
22
- // --- Server-side ---
23
- // Use require() to load the modules at runtime.
24
- const pkg = require("@apollo/client");
25
- exports.ApolloClient = ApolloClient = pkg.ApolloClient;
26
- exports.InMemoryCache = InMemoryCache = pkg.InMemoryCache;
27
- exports.HttpLink = HttpLink = pkg.HttpLink;
28
- exports.gql = gql = pkg.gql;
29
- exports.ApolloError = ApolloError = pkg.ApolloError;
30
- exports.split = split = pkg.split;
31
- const contextPkg = require("@apollo/client/link/context/context.cjs");
32
- exports.setContext = setContext = contextPkg.setContext;
33
- const errorPkg = require("@apollo/client/link/error/error.cjs");
34
- exports.onError = onError = errorPkg.onError;
35
- }
36
- else {
37
- // --- Client-side ---
38
- // 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;
39
+ exports.getApolloModules = getApolloModules;
40
+ // === Internal state ===
41
+ let apolloModules;
42
+ let apolloClient;
43
+ /**
44
+ * Dynamically loads the correct Apollo modules based on the runtime environment.
45
+ */
46
+ async function loadApolloModules() {
47
+ if (typeof window === "undefined" || process.env.AWS_EXECUTION_ENV) {
48
+ // Server-side (or Lambda): load the CommonJS‑based implementation.
49
+ return (await Promise.resolve().then(() => __importStar(require("./apollo-client.server.cjs"))));
50
+ }
51
+ else {
52
+ // Client-side: load the ESM‑based implementation.
53
+ return (await Promise.resolve().then(() => __importStar(require("./apollo-client.client.cjs"))));
54
+ }
47
55
  }
48
- // Use the type-only alias (ApolloClientType) for type annotations.
49
- let apolloClient = null;
50
56
  /**
51
- * Initializes a new Apollo Client instance.
52
- * @returns ApolloClient instance.
57
+ * Returns a singleton Apollo Client instance.
58
+ * **IMPORTANT:** Because module loading is asynchronous,
59
+ * make sure to await this function before using the client.
53
60
  */
54
- function initializeApollo() {
61
+ async function getApolloClient() {
62
+ if (apolloClient) {
63
+ return apolloClient;
64
+ }
65
+ if (!apolloModules) {
66
+ apolloModules = await loadApolloModules();
67
+ }
68
+ const { ApolloClient, InMemoryCache, HttpLink, setContext, onError } = apolloModules;
69
+ // Determine the GraphQL endpoint.
55
70
  const isProduction = process.env.NODE_ENV === "production";
56
71
  const httpUrl = isProduction
57
72
  ? process.env.BACKEND_HTTPS_URL || "https://api.adaptic.ai/graphql"
58
73
  : "http://localhost:4000/graphql";
59
- // Create the HTTP link.
74
+ // Create the HTTP link. (Ensure that a global fetch is available.)
60
75
  const httpLinkInstance = new HttpLink({ uri: httpUrl, fetch });
61
76
  // Create the auth link.
62
- const authLink = setContext((_, { headers }) => {
77
+ const authLink = setContext((request, prevContext) => {
78
+ const headers = prevContext.headers || {};
63
79
  // Retrieve the token from environment variables or other secure storage.
64
80
  const token = process.env.SERVER_AUTH_TOKEN || "";
65
81
  return {
@@ -79,22 +95,27 @@ function initializeApollo() {
79
95
  console.error(`[Network error]: ${networkError}`);
80
96
  }
81
97
  });
82
- // Combine the links and initialize the Apollo Client.
83
- return new ApolloClient({
98
+ // Initialize the Apollo Client.
99
+ apolloClient = new ApolloClient({
84
100
  link: errorLink.concat(authLink.concat(httpLinkInstance)),
85
101
  cache: new InMemoryCache(),
86
102
  });
103
+ return apolloClient;
87
104
  }
88
105
  /**
89
- * Retrieves the singleton Apollo Client instance.
90
- * @returns ApolloClient instance.
106
+ * Returns the underlying runtime exports.
107
+ *
108
+ * **Note:** Because the exports are loaded dynamically,
109
+ * they are not available as named (synchronous) exports from this module.
91
110
  */
92
- function getApolloClient() {
93
- if (!apolloClient) {
94
- apolloClient = initializeApollo();
111
+ async function getApolloModules() {
112
+ if (!apolloModules) {
113
+ apolloModules = await loadApolloModules();
95
114
  }
96
- return apolloClient;
115
+ return apolloModules;
97
116
  }
98
- // Export the singleton instance.
117
+ /**
118
+ * For convenience, you may also export a promise that resolves to the Apollo Client.
119
+ */
99
120
  exports.client = getApolloClient();
100
121
  //# sourceMappingURL=client.js.map
package/client.d.ts CHANGED
@@ -1,21 +1,30 @@
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
+ export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, };
3
+ export interface ApolloModules {
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: typeof import("@apollo/client").ApolloError;
9
+ split: typeof import("@apollo/client").split;
10
+ setContext: typeof import("@apollo/client/link/context").setContext;
11
+ onError: typeof import("@apollo/client/link/error").onError;
12
+ }
13
13
  /**
14
- * Retrieves the singleton Apollo Client instance.
15
- * @returns ApolloClient instance.
14
+ * Returns a singleton Apollo Client instance.
15
+ * **IMPORTANT:** Because module loading is asynchronous,
16
+ * make sure to await this function before using the client.
16
17
  */
17
- export declare function getApolloClient(): ApolloClientType<NormalizedCacheObject>;
18
- export declare const client: ApolloClientType<NormalizedCacheObject>;
19
- export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split };
20
- export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, };
18
+ export declare function getApolloClient(): Promise<ApolloClientType<NormalizedCacheObject>>;
19
+ /**
20
+ * Returns the underlying runtime exports.
21
+ *
22
+ * **Note:** Because the exports are loaded dynamically,
23
+ * they are not available as named (synchronous) exports from this module.
24
+ */
25
+ export declare function getApolloModules(): Promise<ApolloModules>;
26
+ /**
27
+ * For convenience, you may also export a promise that resolves to the Apollo Client.
28
+ */
29
+ export declare const client: Promise<ApolloClientType<NormalizedCacheObject>>;
21
30
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../../src/Account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AA4M7G,eAAO,MAAM,OAAO;IAElB;;;;;OAKG;kBAEiB,WAAW,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IA2ThH;;;;;OAKG;sBACqB,WAAW,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IA2CjI;;;;;OAKG;kBACiB,WAAW,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,W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