@adaptic/utils 0.0.960 → 0.0.961
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/dist/index.cjs +20 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +21 -3
- package/dist/index.mjs.map +1 -1
- package/dist/types/adaptic.d.ts +9 -0
- package/dist/types/adaptic.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/price-utils.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -309,6 +309,22 @@ const fetchAssetOverview = async (symbol) => {
|
|
|
309
309
|
};
|
|
310
310
|
}
|
|
311
311
|
};
|
|
312
|
+
/**
|
|
313
|
+
* Gracefully disconnects the shared Apollo client and releases its resources.
|
|
314
|
+
* Call this during process shutdown to close keep-alive HTTP connections
|
|
315
|
+
* and drain in-flight operations.
|
|
316
|
+
*
|
|
317
|
+
* After calling `disconnectClient()`, the next call to `getSharedApolloClient()`
|
|
318
|
+
* will create a fresh instance.
|
|
319
|
+
*/
|
|
320
|
+
const disconnectClient = () => {
|
|
321
|
+
if (apolloClientInstance) {
|
|
322
|
+
apolloClientInstance = null;
|
|
323
|
+
getLogger().info("[adaptic] Shared Apollo client reference cleared");
|
|
324
|
+
}
|
|
325
|
+
// Delegate to backend-legacy's stopClient() which calls .stop() on the underlying singleton
|
|
326
|
+
adaptic$1.stopClient();
|
|
327
|
+
};
|
|
312
328
|
|
|
313
329
|
const ANSI_BACKGROUND_OFFSET = 10;
|
|
314
330
|
|
|
@@ -8840,10 +8856,11 @@ const calculateFees = async (action, trade, alpacaAccount) => {
|
|
|
8840
8856
|
};
|
|
8841
8857
|
const computeTotalFees = async (trade) => {
|
|
8842
8858
|
let totalFees = 0;
|
|
8843
|
-
//
|
|
8859
|
+
// Use the shared singleton Apollo client to avoid creating orphaned connections
|
|
8860
|
+
const client = await getSharedApolloClient();
|
|
8844
8861
|
const alpacaAccount = (await adaptic$1.alpacaAccount.get({
|
|
8845
8862
|
id: trade.alpacaAccountId,
|
|
8846
|
-
}));
|
|
8863
|
+
}, client));
|
|
8847
8864
|
if (!alpacaAccount)
|
|
8848
8865
|
return totalFees;
|
|
8849
8866
|
const feePromises = trade?.actions?.map((action) => calculateFees(action, trade, alpacaAccount));
|
|
@@ -67898,6 +67915,7 @@ const adaptic = {
|
|
|
67898
67915
|
getApolloClient: getSharedApolloClient,
|
|
67899
67916
|
configureAuth: configureAuth,
|
|
67900
67917
|
isAuthConfigured: isAuthConfigured,
|
|
67918
|
+
disconnectClient: disconnectClient,
|
|
67901
67919
|
},
|
|
67902
67920
|
alpaca: {
|
|
67903
67921
|
// New SDK-based client factory (RECOMMENDED)
|