adaptic-backend 1.0.285 → 1.0.286
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 +56 -34
- package/client.d.ts +15 -4
- package/esm/Account.js.map +1 -1
- package/esm/Action.js.map +1 -1
- package/esm/Alert.js.map +1 -1
- package/esm/AlpacaAccount.js.map +1 -1
- package/esm/Asset.js.map +1 -1
- package/esm/Authenticator.js.map +1 -1
- package/esm/Contract.js.map +1 -1
- package/esm/Customer.js.map +1 -1
- package/esm/Deliverable.js.map +1 -1
- package/esm/EconomicEvent.js.map +1 -1
- package/esm/MarketSentiment.js.map +1 -1
- package/esm/NewsArticle.js.map +1 -1
- package/esm/NewsArticleAssetSentiment.js.map +1 -1
- package/esm/Order.js.map +1 -1
- package/esm/Position.js.map +1 -1
- package/esm/ScheduledOptionOrder.js.map +1 -1
- package/esm/Session.js.map +1 -1
- package/esm/StopLoss.js.map +1 -1
- package/esm/TakeProfit.js.map +1 -1
- package/esm/Trade.js.map +1 -1
- package/esm/User.js.map +1 -1
- package/esm/VerificationToken.js.map +1 -1
- package/esm/client.d.ts +15 -4
- package/esm/client.d.ts.map +1 -1
- package/esm/client.js.map +1 -1
- package/esm/client.mjs +62 -71
- package/package.json +1 -1
- package/client-esm.d.ts +0 -21
- package/esm/client-esm.d.ts +0 -21
- package/esm/client-esm.d.ts.map +0 -1
- package/esm/client-esm.js.map +0 -1
package/client.cjs
CHANGED
@@ -1,44 +1,66 @@
|
|
1
1
|
"use strict";
|
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.
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
3
|
exports.split = exports.onError = exports.setContext = exports.HttpLink = exports.InMemoryCache = exports.gql = exports.ApolloError = exports.ApolloClient = exports.client = void 0;
|
7
4
|
exports.getApolloClient = getApolloClient;
|
5
|
+
// Statically import runtime implementations for the client (browser) environment.
|
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
|
+
// Detect if we are in a server-like environment (including AWS Lambda).
|
19
|
+
const isLambda = Boolean(process.env.AWS_EXECUTION_ENV);
|
8
20
|
const isServer = typeof window === "undefined";
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
// Conditional logic: on server (or AWS Lambda) use require(), on client use the static imports.
|
22
|
+
if (isServer || isLambda) {
|
23
|
+
// Server-side: 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
|
+
// Require the additional packages for context and error links.
|
32
|
+
const contextPkg = require("@apollo/client/link/context/context.cjs");
|
33
|
+
exports.setContext = setContext = contextPkg.setContext;
|
34
|
+
const errorPkg = require("@apollo/client/link/error/error.cjs");
|
35
|
+
exports.onError = onError = errorPkg.onError;
|
36
|
+
}
|
37
|
+
else {
|
38
|
+
// Client-side: 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;
|
29
47
|
}
|
30
|
-
//
|
31
|
-
const apolloExports = loadApolloClientCjs();
|
32
|
-
// Singleton Apollo Client instance.
|
48
|
+
// Singleton instance for the Apollo Client.
|
33
49
|
let apolloClient = null;
|
50
|
+
/**
|
51
|
+
* Initializes a new Apollo Client instance.
|
52
|
+
* @returns ApolloClient instance.
|
53
|
+
*/
|
34
54
|
function initializeApollo() {
|
35
|
-
const { ApolloClient, InMemoryCache, HttpLink, setContext, onError } = apolloExports;
|
36
55
|
const isProduction = process.env.NODE_ENV === "production";
|
37
|
-
const httpUrl = isProduction
|
56
|
+
const httpUrl = isProduction
|
38
57
|
? process.env.BACKEND_HTTPS_URL || "https://api.adaptic.ai/graphql"
|
39
58
|
: "http://localhost:4000/graphql";
|
59
|
+
// Create the HTTP link.
|
40
60
|
const httpLinkInstance = new HttpLink({ uri: httpUrl, fetch });
|
61
|
+
// Create the auth link.
|
41
62
|
const authLink = setContext((_, { headers }) => {
|
63
|
+
// Retrieve the token from environment variables or other secure storage.
|
42
64
|
const token = process.env.SERVER_AUTH_TOKEN || "";
|
43
65
|
return {
|
44
66
|
headers: {
|
@@ -48,23 +70,24 @@ function initializeApollo() {
|
|
48
70
|
},
|
49
71
|
};
|
50
72
|
});
|
73
|
+
// Create the error handling link.
|
51
74
|
const errorLink = onError(({ graphQLErrors, networkError }) => {
|
52
75
|
if (graphQLErrors) {
|
53
|
-
graphQLErrors.forEach(({ message, locations, path }) => {
|
54
|
-
console.error(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);
|
55
|
-
});
|
76
|
+
graphQLErrors.forEach(({ message, locations, path }) => console.error(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`));
|
56
77
|
}
|
57
78
|
if (networkError) {
|
58
79
|
console.error(`[Network error]: ${networkError}`);
|
59
80
|
}
|
60
81
|
});
|
82
|
+
// Combine the links and initialize the Apollo Client.
|
61
83
|
return new ApolloClient({
|
62
84
|
link: errorLink.concat(authLink.concat(httpLinkInstance)),
|
63
85
|
cache: new InMemoryCache(),
|
64
86
|
});
|
65
87
|
}
|
66
88
|
/**
|
67
|
-
*
|
89
|
+
* Retrieves the singleton Apollo Client instance.
|
90
|
+
* @returns ApolloClient instance.
|
68
91
|
*/
|
69
92
|
function getApolloClient() {
|
70
93
|
if (!apolloClient) {
|
@@ -72,7 +95,6 @@ function getApolloClient() {
|
|
72
95
|
}
|
73
96
|
return apolloClient;
|
74
97
|
}
|
98
|
+
// Export the singleton instance.
|
75
99
|
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;
|
78
100
|
//# sourceMappingURL=client.js.map
|
package/client.d.ts
CHANGED
@@ -1,10 +1,21 @@
|
|
1
1
|
import type { ApolloClient as ApolloClientType, InMemoryCache as InMemoryCacheType, HttpLink as HttpLinkType, NormalizedCacheObject } from "@apollo/client";
|
2
|
-
import
|
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;
|
3
13
|
/**
|
4
|
-
*
|
14
|
+
* Retrieves the singleton Apollo Client instance.
|
15
|
+
* @returns ApolloClient instance.
|
5
16
|
*/
|
6
17
|
export declare function getApolloClient(): ApolloClientType<NormalizedCacheObject>;
|
7
18
|
export declare const client: ApolloClientType<NormalizedCacheObject>;
|
8
|
-
export
|
9
|
-
export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject,
|
19
|
+
export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split, };
|
20
|
+
export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, };
|
10
21
|
//# sourceMappingURL=client.d.ts.map
|