adaptic-backend 1.0.285 → 1.0.287
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 +109 -34
- package/client.d.ts +18 -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 +18 -4
- package/esm/client.d.ts.map +1 -1
- package/esm/client.js.map +1 -1
- package/esm/client.mjs +79 -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,117 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
37
|
+
};
|
5
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
39
|
exports.split = exports.onError = exports.setContext = exports.HttpLink = exports.InMemoryCache = exports.gql = exports.ApolloError = exports.ApolloClient = exports.client = void 0;
|
7
40
|
exports.getApolloClient = getApolloClient;
|
41
|
+
// ==========================
|
42
|
+
// 2. Static (Client-side) Imports
|
43
|
+
// Use default import and destructuring so that CommonJS modules export correctly in ESM.
|
44
|
+
// ==========================
|
45
|
+
const pkg = __importStar(require("@apollo/client"));
|
46
|
+
const { ApolloClient: ApolloClientImported, InMemoryCache: InMemoryCacheImported, HttpLink: HttpLinkImported, gql: gqlImported, ApolloError: ApolloErrorImported, split: splitImported, } = pkg;
|
47
|
+
const context_cjs_1 = __importDefault(require("@apollo/client/link/context/context.cjs"));
|
48
|
+
const { setContext: setContextImported } = context_cjs_1.default;
|
49
|
+
const error_cjs_1 = __importDefault(require("@apollo/client/link/error/error.cjs"));
|
50
|
+
const { onError: onErrorImported } = error_cjs_1.default;
|
51
|
+
// ==========================
|
52
|
+
// 3. Declare Runtime Variables
|
53
|
+
// These variables will eventually be assigned the proper implementations based on the runtime.
|
54
|
+
// ==========================
|
55
|
+
let ApolloClient;
|
56
|
+
let ApolloError;
|
57
|
+
let gql;
|
58
|
+
let InMemoryCache;
|
59
|
+
let HttpLink;
|
60
|
+
let setContext;
|
61
|
+
let onError;
|
62
|
+
let split;
|
63
|
+
// ==========================
|
64
|
+
// 4. Environment Detection & Conditional Assignment
|
65
|
+
// We check if we are in a server environment (including AWS Lambda)
|
66
|
+
// ==========================
|
67
|
+
const isLambda = Boolean(process.env.AWS_EXECUTION_ENV);
|
8
68
|
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
|
-
|
69
|
+
if (isServer || isLambda) {
|
70
|
+
// --- Server-side (or AWS Lambda) ---
|
71
|
+
// Use require() to load the modules synchronously at runtime.
|
72
|
+
const pkg = require("@apollo/client");
|
73
|
+
exports.ApolloClient = ApolloClient = pkg.ApolloClient;
|
74
|
+
exports.InMemoryCache = InMemoryCache = pkg.InMemoryCache;
|
75
|
+
exports.HttpLink = HttpLink = pkg.HttpLink;
|
76
|
+
exports.gql = gql = pkg.gql;
|
77
|
+
exports.ApolloError = ApolloError = pkg.ApolloError;
|
78
|
+
exports.split = split = pkg.split;
|
79
|
+
// Load additional submodules.
|
80
|
+
const contextPkg = require("@apollo/client/link/context/context.cjs");
|
81
|
+
exports.setContext = setContext = contextPkg.setContext;
|
82
|
+
const errorPkg = require("@apollo/client/link/error/error.cjs");
|
83
|
+
exports.onError = onError = errorPkg.onError;
|
84
|
+
}
|
85
|
+
else {
|
86
|
+
// --- Client-side ---
|
87
|
+
// Use the statically imported implementations.
|
88
|
+
exports.ApolloClient = ApolloClient = ApolloClientImported;
|
89
|
+
exports.InMemoryCache = InMemoryCache = InMemoryCacheImported;
|
90
|
+
exports.HttpLink = HttpLink = HttpLinkImported;
|
91
|
+
exports.gql = gql = gqlImported;
|
92
|
+
exports.ApolloError = ApolloError = ApolloErrorImported;
|
93
|
+
exports.setContext = setContext = setContextImported;
|
94
|
+
exports.onError = onError = onErrorImported;
|
95
|
+
exports.split = split = splitImported;
|
29
96
|
}
|
30
|
-
//
|
31
|
-
|
32
|
-
//
|
97
|
+
// ==========================
|
98
|
+
// 5. Apollo Client Initialization & Singleton Pattern
|
99
|
+
// ==========================
|
33
100
|
let apolloClient = null;
|
101
|
+
/**
|
102
|
+
* Initializes a new Apollo Client instance.
|
103
|
+
* @returns ApolloClient instance.
|
104
|
+
*/
|
34
105
|
function initializeApollo() {
|
35
|
-
const { ApolloClient, InMemoryCache, HttpLink, setContext, onError } = apolloExports;
|
36
106
|
const isProduction = process.env.NODE_ENV === "production";
|
37
|
-
const httpUrl = isProduction
|
107
|
+
const httpUrl = isProduction
|
38
108
|
? process.env.BACKEND_HTTPS_URL || "https://api.adaptic.ai/graphql"
|
39
109
|
: "http://localhost:4000/graphql";
|
110
|
+
// Create the HTTP link.
|
40
111
|
const httpLinkInstance = new HttpLink({ uri: httpUrl, fetch });
|
112
|
+
// Create the auth link.
|
41
113
|
const authLink = setContext((_, { headers }) => {
|
114
|
+
// Retrieve the token from environment variables or other secure storage.
|
42
115
|
const token = process.env.SERVER_AUTH_TOKEN || "";
|
43
116
|
return {
|
44
117
|
headers: {
|
@@ -48,23 +121,24 @@ function initializeApollo() {
|
|
48
121
|
},
|
49
122
|
};
|
50
123
|
});
|
124
|
+
// Create the error handling link.
|
51
125
|
const errorLink = onError(({ graphQLErrors, networkError }) => {
|
52
126
|
if (graphQLErrors) {
|
53
|
-
graphQLErrors.forEach(({ message, locations, path }) => {
|
54
|
-
console.error(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);
|
55
|
-
});
|
127
|
+
graphQLErrors.forEach(({ message, locations, path }) => console.error(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`));
|
56
128
|
}
|
57
129
|
if (networkError) {
|
58
130
|
console.error(`[Network error]: ${networkError}`);
|
59
131
|
}
|
60
132
|
});
|
133
|
+
// Combine the links and initialize the Apollo Client.
|
61
134
|
return new ApolloClient({
|
62
135
|
link: errorLink.concat(authLink.concat(httpLinkInstance)),
|
63
136
|
cache: new InMemoryCache(),
|
64
137
|
});
|
65
138
|
}
|
66
139
|
/**
|
67
|
-
*
|
140
|
+
* Retrieves the singleton Apollo Client instance.
|
141
|
+
* @returns ApolloClient instance.
|
68
142
|
*/
|
69
143
|
function getApolloClient() {
|
70
144
|
if (!apolloClient) {
|
@@ -72,7 +146,8 @@ function getApolloClient() {
|
|
72
146
|
}
|
73
147
|
return apolloClient;
|
74
148
|
}
|
149
|
+
// ==========================
|
150
|
+
// 6. Exports
|
151
|
+
// ==========================
|
75
152
|
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
153
|
//# sourceMappingURL=client.js.map
|
package/client.d.ts
CHANGED
@@ -1,10 +1,24 @@
|
|
1
1
|
import type { ApolloClient as ApolloClientType, InMemoryCache as InMemoryCacheType, HttpLink as HttpLinkType, NormalizedCacheObject } from "@apollo/client";
|
2
|
-
import
|
2
|
+
import * as pkg from "@apollo/client";
|
3
|
+
declare const ApolloClientImported: typeof ApolloClientType, InMemoryCacheImported: typeof InMemoryCacheType, HttpLinkImported: typeof HttpLinkType, gqlImported: typeof pkg.gql, ApolloErrorImported: typeof pkg.ApolloError, splitImported: typeof pkg.ApolloLink.split;
|
4
|
+
import contextPkg from "@apollo/client/link/context/context.cjs";
|
5
|
+
declare const setContextImported: typeof contextPkg.setContext;
|
6
|
+
import errorPkg from "@apollo/client/link/error/error.cjs";
|
7
|
+
declare const onErrorImported: typeof errorPkg.onError;
|
8
|
+
declare let ApolloClient: typeof ApolloClientImported;
|
9
|
+
declare let ApolloError: typeof ApolloErrorImported;
|
10
|
+
declare let gql: typeof gqlImported;
|
11
|
+
declare let InMemoryCache: typeof InMemoryCacheImported;
|
12
|
+
declare let HttpLink: typeof HttpLinkImported;
|
13
|
+
declare let setContext: typeof setContextImported;
|
14
|
+
declare let onError: typeof onErrorImported;
|
15
|
+
declare let split: typeof splitImported;
|
3
16
|
/**
|
4
|
-
*
|
17
|
+
* Retrieves the singleton Apollo Client instance.
|
18
|
+
* @returns ApolloClient instance.
|
5
19
|
*/
|
6
20
|
export declare function getApolloClient(): ApolloClientType<NormalizedCacheObject>;
|
7
21
|
export declare const client: ApolloClientType<NormalizedCacheObject>;
|
8
|
-
export
|
9
|
-
export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject,
|
22
|
+
export { ApolloClient, ApolloError, gql, InMemoryCache, HttpLink, setContext, onError, split, };
|
23
|
+
export type { ApolloClientType, InMemoryCacheType, HttpLinkType, NormalizedCacheObject, };
|
10
24
|
//# sourceMappingURL=client.d.ts.map
|