@metamask-previews/core-backend 6.2.1-preview-bd0d4d2e9 → 6.2.1-preview-938a7fe
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/CHANGELOG.md +0 -8
- package/dist/index.cjs +1 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +0 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/api/ohlcv/OHLCVService-method-action-types.cjs +0 -7
- package/dist/api/ohlcv/OHLCVService-method-action-types.cjs.map +0 -1
- package/dist/api/ohlcv/OHLCVService-method-action-types.d.cts +0 -28
- package/dist/api/ohlcv/OHLCVService-method-action-types.d.cts.map +0 -1
- package/dist/api/ohlcv/OHLCVService-method-action-types.d.mts +0 -28
- package/dist/api/ohlcv/OHLCVService-method-action-types.d.mts.map +0 -1
- package/dist/api/ohlcv/OHLCVService-method-action-types.mjs +0 -6
- package/dist/api/ohlcv/OHLCVService-method-action-types.mjs.map +0 -1
- package/dist/api/ohlcv/OHLCVService.cjs +0 -294
- package/dist/api/ohlcv/OHLCVService.cjs.map +0 -1
- package/dist/api/ohlcv/OHLCVService.d.cts +0 -107
- package/dist/api/ohlcv/OHLCVService.d.cts.map +0 -1
- package/dist/api/ohlcv/OHLCVService.d.mts +0 -107
- package/dist/api/ohlcv/OHLCVService.d.mts.map +0 -1
- package/dist/api/ohlcv/OHLCVService.mjs +0 -290
- package/dist/api/ohlcv/OHLCVService.mjs.map +0 -1
- package/dist/api/ohlcv/index.cjs +0 -9
- package/dist/api/ohlcv/index.cjs.map +0 -1
- package/dist/api/ohlcv/index.d.cts +0 -5
- package/dist/api/ohlcv/index.d.cts.map +0 -1
- package/dist/api/ohlcv/index.d.mts +0 -5
- package/dist/api/ohlcv/index.d.mts.map +0 -1
- package/dist/api/ohlcv/index.mjs +0 -3
- package/dist/api/ohlcv/index.mjs.map +0 -1
- package/dist/api/ohlcv/types.cjs +0 -6
- package/dist/api/ohlcv/types.cjs.map +0 -1
- package/dist/api/ohlcv/types.d.cts +0 -32
- package/dist/api/ohlcv/types.d.cts.map +0 -1
- package/dist/api/ohlcv/types.d.mts +0 -32
- package/dist/api/ohlcv/types.d.mts.map +0 -1
- package/dist/api/ohlcv/types.mjs +0 -5
- package/dist/api/ohlcv/types.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,14 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
- Add `OHLCVService` for real-time OHLCV (candlestick) data streaming via WebSocket ([#8695](https://github.com/MetaMask/core/pull/8695))
|
|
13
|
-
- Wraps `BackendWebSocketService` through the messenger pattern to provide subscribe/unsubscribe semantics for market-data OHLCV channels
|
|
14
|
-
- Includes reference counting, grace-period unsubscribe, idempotency checks, chain-status forwarding, and automatic resubscription on reconnect
|
|
15
|
-
- Export new types `OHLCVBar`, `OHLCVSubscriptionOptions`, `OHLCVSystemNotificationData`, `OHLCVServiceOptions`, `OHLCVServiceActions`, `OHLCVServiceAllowedActions`, `OHLCVServiceBarUpdatedEvent`, `OHLCVServiceChainStatusChangedEvent`, `OHLCVServiceSubscriptionErrorEvent`, `OHLCVServiceEvents`, `OHLCVServiceAllowedEvents`, and `OHLCVServiceMessenger` ([#8695](https://github.com/MetaMask/core/pull/8695))
|
|
16
|
-
- Export new constants `OHLCV_SERVICE_ALLOWED_ACTIONS` and `OHLCV_SERVICE_ALLOWED_EVENTS` for configuring the messenger ([#8695](https://github.com/MetaMask/core/pull/8695))
|
|
17
|
-
|
|
18
10
|
### Changed
|
|
19
11
|
|
|
20
12
|
- Bump `@metamask/accounts-controller` from `^37.1.0` to `^38.0.0` ([#8325](https://github.com/MetaMask/core/pull/8325), [#8363](https://github.com/MetaMask/core/pull/8363), [#8665](https://github.com/MetaMask/core/pull/8665))
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Core Backend Package Exports
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.HttpError = exports.shouldRetry = exports.getQueryOptionsOverrides = exports.calculateRetryDelay = exports.GC_TIMES = exports.STALE_TIMES = exports.API_URLS = exports.TokensApiClient = exports.TokenApiClient = exports.PricesApiClient = exports.AccountsApiClient = exports.createApiPlatformClient = exports.ApiPlatformClient = exports.
|
|
4
|
+
exports.HttpError = exports.shouldRetry = exports.getQueryOptionsOverrides = exports.calculateRetryDelay = exports.GC_TIMES = exports.STALE_TIMES = exports.API_URLS = exports.TokensApiClient = exports.TokenApiClient = exports.PricesApiClient = exports.AccountsApiClient = exports.createApiPlatformClient = exports.ApiPlatformClient = exports.apiPlatformClientServiceName = exports.ApiPlatformClientService = exports.ACCOUNT_ACTIVITY_SERVICE_ALLOWED_EVENTS = exports.ACCOUNT_ACTIVITY_SERVICE_ALLOWED_ACTIONS = exports.AccountActivityService = exports.WebSocketEventType = exports.WebSocketState = exports.getCloseReason = exports.BackendWebSocketService = void 0;
|
|
5
5
|
// ============================================================================
|
|
6
6
|
// BACKEND WEBSOCKET SERVICE
|
|
7
7
|
// ============================================================================
|
|
@@ -24,13 +24,6 @@ var ApiPlatformClientService_1 = require("./ApiPlatformClientService.cjs");
|
|
|
24
24
|
Object.defineProperty(exports, "ApiPlatformClientService", { enumerable: true, get: function () { return ApiPlatformClientService_1.ApiPlatformClientService; } });
|
|
25
25
|
Object.defineProperty(exports, "apiPlatformClientServiceName", { enumerable: true, get: function () { return ApiPlatformClientService_1.apiPlatformClientServiceName; } });
|
|
26
26
|
// ============================================================================
|
|
27
|
-
// OHLCV SERVICE
|
|
28
|
-
// ============================================================================
|
|
29
|
-
var ohlcv_1 = require("./api/ohlcv/index.cjs");
|
|
30
|
-
Object.defineProperty(exports, "OHLCVService", { enumerable: true, get: function () { return ohlcv_1.OHLCVService; } });
|
|
31
|
-
Object.defineProperty(exports, "OHLCV_SERVICE_ALLOWED_ACTIONS", { enumerable: true, get: function () { return ohlcv_1.OHLCV_SERVICE_ALLOWED_ACTIONS; } });
|
|
32
|
-
Object.defineProperty(exports, "OHLCV_SERVICE_ALLOWED_EVENTS", { enumerable: true, get: function () { return ohlcv_1.OHLCV_SERVICE_ALLOWED_EVENTS; } });
|
|
33
|
-
// ============================================================================
|
|
34
27
|
// API PLATFORM CLIENT
|
|
35
28
|
// ============================================================================
|
|
36
29
|
var api_1 = require("./api/index.cjs");
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,+BAA+B;;;AAE/B,+EAA+E;AAC/E,4BAA4B;AAC5B,+EAA+E;AAE/E,yEAKmC;AAJjC,kIAAA,uBAAuB,OAAA;AACvB,yHAAA,cAAc,OAAA;AACd,yHAAA,cAAc,OAAA;AACd,6HAAA,kBAAkB,OAAA;AAkBpB,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E,uEAIkC;AAHhC,gIAAA,sBAAsB,OAAA;AACtB,kJAAA,wCAAwC,OAAA;AACxC,iJAAA,uCAAuC,OAAA;AA+BzC,+EAA+E;AAC/E,8BAA8B;AAC9B,+EAA+E;AAE/E,2EAGoC;AAFlC,oIAAA,wBAAwB,OAAA;AACxB,wIAAA,4BAA4B,OAAA;AAU9B,+EAA+E;AAC/E,
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,+BAA+B;;;AAE/B,+EAA+E;AAC/E,4BAA4B;AAC5B,+EAA+E;AAE/E,yEAKmC;AAJjC,kIAAA,uBAAuB,OAAA;AACvB,yHAAA,cAAc,OAAA;AACd,yHAAA,cAAc,OAAA;AACd,6HAAA,kBAAkB,OAAA;AAkBpB,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E,uEAIkC;AAHhC,gIAAA,sBAAsB,OAAA;AACtB,kJAAA,wCAAwC,OAAA;AACxC,iJAAA,uCAAuC,OAAA;AA+BzC,+EAA+E;AAC/E,8BAA8B;AAC9B,+EAA+E;AAE/E,2EAGoC;AAFlC,oIAAA,wBAAwB,OAAA;AACxB,wIAAA,4BAA4B,OAAA;AAU9B,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E,uCAkBe;AAjBb,wGAAA,iBAAiB,OAAA;AACjB,8GAAA,uBAAuB,OAAA;AACvB,yBAAyB;AACzB,wGAAA,iBAAiB,OAAA;AACjB,sGAAA,eAAe,OAAA;AACf,qGAAA,cAAc,OAAA;AACd,sGAAA,eAAe,OAAA;AACf,YAAY;AACZ,+FAAA,QAAQ,OAAA;AACR,kGAAA,WAAW,OAAA;AACX,+FAAA,QAAQ,OAAA;AACR,UAAU;AACV,0GAAA,mBAAmB,OAAA;AACnB,+GAAA,wBAAwB,OAAA;AACxB,kGAAA,WAAW,OAAA;AACX,SAAS;AACT,gGAAA,SAAS,OAAA","sourcesContent":["// Core Backend Package Exports\n\n// ============================================================================\n// BACKEND WEBSOCKET SERVICE\n// ============================================================================\n\nexport {\n BackendWebSocketService,\n getCloseReason,\n WebSocketState,\n WebSocketEventType,\n} from './BackendWebSocketService';\n\nexport type {\n BackendWebSocketServiceOptions,\n ClientRequestMessage,\n ServerResponseMessage,\n ServerNotificationMessage,\n WebSocketMessage,\n ChannelCallback,\n WebSocketSubscription,\n WebSocketConnectionInfo,\n BackendWebSocketServiceActions,\n BackendWebSocketServiceConnectionStateChangedEvent,\n BackendWebSocketServiceEvents,\n BackendWebSocketServiceMessenger,\n} from './BackendWebSocketService';\n\n// ============================================================================\n// ACCOUNT ACTIVITY SERVICE\n// ============================================================================\n\nexport {\n AccountActivityService,\n ACCOUNT_ACTIVITY_SERVICE_ALLOWED_ACTIONS,\n ACCOUNT_ACTIVITY_SERVICE_ALLOWED_EVENTS,\n} from './AccountActivityService';\n\nexport type {\n SystemNotificationData,\n SubscriptionOptions,\n AccountActivityServiceOptions,\n AccountActivityServiceActions,\n AllowedActions as AccountActivityServiceAllowedActions,\n AccountActivityServiceTransactionUpdatedEvent,\n AccountActivityServiceBalanceUpdatedEvent,\n AccountActivityServiceSubscriptionErrorEvent,\n AccountActivityServiceStatusChangedEvent,\n AccountActivityServiceEvents,\n AllowedEvents as AccountActivityServiceAllowedEvents,\n AccountActivityServiceMessenger,\n} from './AccountActivityService';\n\n// ============================================================================\n// SHARED TYPES\n// ============================================================================\n\nexport type {\n Transaction,\n Asset,\n Balance,\n Transfer,\n BalanceUpdate,\n AccountActivityMessage,\n} from './types';\n\n// ============================================================================\n// API PLATFORM CLIENT SERVICE\n// ============================================================================\n\nexport {\n ApiPlatformClientService,\n apiPlatformClientServiceName,\n} from './ApiPlatformClientService';\n\nexport type {\n ApiPlatformClientServiceOptions,\n ApiPlatformClientServiceActions,\n ApiPlatformClientServiceEvents,\n ApiPlatformClientServiceMessenger,\n} from './ApiPlatformClientService';\n\n// ============================================================================\n// API PLATFORM CLIENT\n// ============================================================================\n\nexport {\n ApiPlatformClient,\n createApiPlatformClient,\n // Individual API clients\n AccountsApiClient,\n PricesApiClient,\n TokenApiClient,\n TokensApiClient,\n // Constants\n API_URLS,\n STALE_TIMES,\n GC_TIMES,\n // Helpers\n calculateRetryDelay,\n getQueryOptionsOverrides,\n shouldRetry,\n // Errors\n HttpError,\n} from './api';\n\n// ============================================================================\n// API PLATFORM CLIENT TYPES\n// ============================================================================\n\nexport type {\n // Client options\n ApiPlatformClientOptions,\n FetchOptions,\n // Shared types\n PageInfo,\n SupportedCurrency,\n MarketDataDetails,\n // Accounts API types\n V5BalanceItem,\n V5BalancesResponse,\n V2BalanceItem,\n V2BalancesResponse,\n V4BalancesResponse,\n V1SupportedNetworksResponse,\n V2SupportedNetworksResponse,\n V2ActiveNetworksResponse,\n V1TransactionByHashResponse,\n V1AccountTransactionsResponse,\n V4MultiAccountTransactionsResponse,\n ValueTransfer,\n V1AccountRelationshipResult,\n NftItem,\n V2NftsResponse,\n TokenDiscoveryItem,\n V2TokensResponse,\n // Prices API types\n V3SpotPricesResponse,\n CoinGeckoSpotPrice,\n ExchangeRateInfo,\n V1ExchangeRatesResponse,\n PriceSupportedNetworksResponse,\n V1HistoricalPricesResponse,\n V3HistoricalPricesResponse,\n // Token API types\n TokenMetadata,\n V1TokenDescriptionResponse,\n NetworkInfo,\n TopAsset,\n TrendingSortBy,\n TrendingToken,\n TopGainersSortOption,\n TrendingSortOption,\n V1SuggestedOccurrenceFloorsResponse,\n // Tokens API types\n V1TokenSupportedNetworksResponse,\n V2TokenSupportedNetworksResponse,\n V3AssetResponse,\n} from './api';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -5,8 +5,6 @@ export type { SystemNotificationData, SubscriptionOptions, AccountActivityServic
|
|
|
5
5
|
export type { Transaction, Asset, Balance, Transfer, BalanceUpdate, AccountActivityMessage, } from "./types.cjs";
|
|
6
6
|
export { ApiPlatformClientService, apiPlatformClientServiceName, } from "./ApiPlatformClientService.cjs";
|
|
7
7
|
export type { ApiPlatformClientServiceOptions, ApiPlatformClientServiceActions, ApiPlatformClientServiceEvents, ApiPlatformClientServiceMessenger, } from "./ApiPlatformClientService.cjs";
|
|
8
|
-
export { OHLCVService, OHLCV_SERVICE_ALLOWED_ACTIONS, OHLCV_SERVICE_ALLOWED_EVENTS, } from "./api/ohlcv/index.cjs";
|
|
9
|
-
export type { OHLCVBar, OHLCVSubscriptionOptions, OHLCVSystemNotificationData, OHLCVServiceOptions, OHLCVServiceActions, OHLCVServiceAllowedActions, OHLCVServiceBarUpdatedEvent, OHLCVServiceChainStatusChangedEvent, OHLCVServiceSubscriptionErrorEvent, OHLCVServiceEvents, OHLCVServiceAllowedEvents, OHLCVServiceMessenger, } from "./api/ohlcv/index.cjs";
|
|
10
8
|
export { ApiPlatformClient, createApiPlatformClient, AccountsApiClient, PricesApiClient, TokenApiClient, TokensApiClient, API_URLS, STALE_TIMES, GC_TIMES, calculateRetryDelay, getQueryOptionsOverrides, shouldRetry, HttpError, } from "./api/index.cjs";
|
|
11
9
|
export type { ApiPlatformClientOptions, FetchOptions, PageInfo, SupportedCurrency, MarketDataDetails, V5BalanceItem, V5BalancesResponse, V2BalanceItem, V2BalancesResponse, V4BalancesResponse, V1SupportedNetworksResponse, V2SupportedNetworksResponse, V2ActiveNetworksResponse, V1TransactionByHashResponse, V1AccountTransactionsResponse, V4MultiAccountTransactionsResponse, ValueTransfer, V1AccountRelationshipResult, NftItem, V2NftsResponse, TokenDiscoveryItem, V2TokensResponse, V3SpotPricesResponse, CoinGeckoSpotPrice, ExchangeRateInfo, V1ExchangeRatesResponse, PriceSupportedNetworksResponse, V1HistoricalPricesResponse, V3HistoricalPricesResponse, TokenMetadata, V1TokenDescriptionResponse, NetworkInfo, TopAsset, TrendingSortBy, TrendingToken, TopGainersSortOption, TrendingSortOption, V1SuggestedOccurrenceFloorsResponse, V1TokenSupportedNetworksResponse, V2TokenSupportedNetworksResponse, V3AssetResponse, } from "./api/index.cjs";
|
|
12
10
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,sCAAkC;AAEnC,YAAY,EACV,8BAA8B,EAC9B,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,8BAA8B,EAC9B,kDAAkD,EAClD,6BAA6B,EAC7B,gCAAgC,GACjC,sCAAkC;AAMnC,OAAO,EACL,sBAAsB,EACtB,wCAAwC,EACxC,uCAAuC,GACxC,qCAAiC;AAElC,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,EAC7B,cAAc,IAAI,oCAAoC,EACtD,6CAA6C,EAC7C,yCAAyC,EACzC,4CAA4C,EAC5C,wCAAwC,EACxC,4BAA4B,EAC5B,aAAa,IAAI,mCAAmC,EACpD,+BAA+B,GAChC,qCAAiC;AAMlC,YAAY,EACV,WAAW,EACX,KAAK,EACL,OAAO,EACP,QAAQ,EACR,aAAa,EACb,sBAAsB,GACvB,oBAAgB;AAMjB,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAC7B,uCAAmC;AAEpC,YAAY,EACV,+BAA+B,EAC/B,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,GAClC,uCAAmC;AAMpC,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,sCAAkC;AAEnC,YAAY,EACV,8BAA8B,EAC9B,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,8BAA8B,EAC9B,kDAAkD,EAClD,6BAA6B,EAC7B,gCAAgC,GACjC,sCAAkC;AAMnC,OAAO,EACL,sBAAsB,EACtB,wCAAwC,EACxC,uCAAuC,GACxC,qCAAiC;AAElC,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,EAC7B,cAAc,IAAI,oCAAoC,EACtD,6CAA6C,EAC7C,yCAAyC,EACzC,4CAA4C,EAC5C,wCAAwC,EACxC,4BAA4B,EAC5B,aAAa,IAAI,mCAAmC,EACpD,+BAA+B,GAChC,qCAAiC;AAMlC,YAAY,EACV,WAAW,EACX,KAAK,EACL,OAAO,EACP,QAAQ,EACR,aAAa,EACb,sBAAsB,GACvB,oBAAgB;AAMjB,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAC7B,uCAAmC;AAEpC,YAAY,EACV,+BAA+B,EAC/B,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,GAClC,uCAAmC;AAMpC,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EAEvB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,eAAe,EAEf,QAAQ,EACR,WAAW,EACX,QAAQ,EAER,mBAAmB,EACnB,wBAAwB,EACxB,WAAW,EAEX,SAAS,GACV,wBAAc;AAMf,YAAY,EAEV,wBAAwB,EACxB,YAAY,EAEZ,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,EAEjB,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EACxB,2BAA2B,EAC3B,6BAA6B,EAC7B,kCAAkC,EAClC,aAAa,EACb,2BAA2B,EAC3B,OAAO,EACP,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAEhB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,8BAA8B,EAC9B,0BAA0B,EAC1B,0BAA0B,EAE1B,aAAa,EACb,0BAA0B,EAC1B,WAAW,EACX,QAAQ,EACR,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,mCAAmC,EAEnC,gCAAgC,EAChC,gCAAgC,EAChC,eAAe,GAChB,wBAAc"}
|
package/dist/index.d.mts
CHANGED
|
@@ -5,8 +5,6 @@ export type { SystemNotificationData, SubscriptionOptions, AccountActivityServic
|
|
|
5
5
|
export type { Transaction, Asset, Balance, Transfer, BalanceUpdate, AccountActivityMessage, } from "./types.mjs";
|
|
6
6
|
export { ApiPlatformClientService, apiPlatformClientServiceName, } from "./ApiPlatformClientService.mjs";
|
|
7
7
|
export type { ApiPlatformClientServiceOptions, ApiPlatformClientServiceActions, ApiPlatformClientServiceEvents, ApiPlatformClientServiceMessenger, } from "./ApiPlatformClientService.mjs";
|
|
8
|
-
export { OHLCVService, OHLCV_SERVICE_ALLOWED_ACTIONS, OHLCV_SERVICE_ALLOWED_EVENTS, } from "./api/ohlcv/index.mjs";
|
|
9
|
-
export type { OHLCVBar, OHLCVSubscriptionOptions, OHLCVSystemNotificationData, OHLCVServiceOptions, OHLCVServiceActions, OHLCVServiceAllowedActions, OHLCVServiceBarUpdatedEvent, OHLCVServiceChainStatusChangedEvent, OHLCVServiceSubscriptionErrorEvent, OHLCVServiceEvents, OHLCVServiceAllowedEvents, OHLCVServiceMessenger, } from "./api/ohlcv/index.mjs";
|
|
10
8
|
export { ApiPlatformClient, createApiPlatformClient, AccountsApiClient, PricesApiClient, TokenApiClient, TokensApiClient, API_URLS, STALE_TIMES, GC_TIMES, calculateRetryDelay, getQueryOptionsOverrides, shouldRetry, HttpError, } from "./api/index.mjs";
|
|
11
9
|
export type { ApiPlatformClientOptions, FetchOptions, PageInfo, SupportedCurrency, MarketDataDetails, V5BalanceItem, V5BalancesResponse, V2BalanceItem, V2BalancesResponse, V4BalancesResponse, V1SupportedNetworksResponse, V2SupportedNetworksResponse, V2ActiveNetworksResponse, V1TransactionByHashResponse, V1AccountTransactionsResponse, V4MultiAccountTransactionsResponse, ValueTransfer, V1AccountRelationshipResult, NftItem, V2NftsResponse, TokenDiscoveryItem, V2TokensResponse, V3SpotPricesResponse, CoinGeckoSpotPrice, ExchangeRateInfo, V1ExchangeRatesResponse, PriceSupportedNetworksResponse, V1HistoricalPricesResponse, V3HistoricalPricesResponse, TokenMetadata, V1TokenDescriptionResponse, NetworkInfo, TopAsset, TrendingSortBy, TrendingToken, TopGainersSortOption, TrendingSortOption, V1SuggestedOccurrenceFloorsResponse, V1TokenSupportedNetworksResponse, V2TokenSupportedNetworksResponse, V3AssetResponse, } from "./api/index.mjs";
|
|
12
10
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,sCAAkC;AAEnC,YAAY,EACV,8BAA8B,EAC9B,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,8BAA8B,EAC9B,kDAAkD,EAClD,6BAA6B,EAC7B,gCAAgC,GACjC,sCAAkC;AAMnC,OAAO,EACL,sBAAsB,EACtB,wCAAwC,EACxC,uCAAuC,GACxC,qCAAiC;AAElC,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,EAC7B,cAAc,IAAI,oCAAoC,EACtD,6CAA6C,EAC7C,yCAAyC,EACzC,4CAA4C,EAC5C,wCAAwC,EACxC,4BAA4B,EAC5B,aAAa,IAAI,mCAAmC,EACpD,+BAA+B,GAChC,qCAAiC;AAMlC,YAAY,EACV,WAAW,EACX,KAAK,EACL,OAAO,EACP,QAAQ,EACR,aAAa,EACb,sBAAsB,GACvB,oBAAgB;AAMjB,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAC7B,uCAAmC;AAEpC,YAAY,EACV,+BAA+B,EAC/B,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,GAClC,uCAAmC;AAMpC,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,sCAAkC;AAEnC,YAAY,EACV,8BAA8B,EAC9B,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,8BAA8B,EAC9B,kDAA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AAW,EACX,QAAQ,EACR,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,mCAAmC,EAEnC,gCAAgC,EAChC,gCAAgC,EAChC,eAAe,GAChB,wBAAc"}
|
package/dist/index.mjs
CHANGED
|
@@ -12,10 +12,6 @@ export { AccountActivityService, ACCOUNT_ACTIVITY_SERVICE_ALLOWED_ACTIONS, ACCOU
|
|
|
12
12
|
// ============================================================================
|
|
13
13
|
export { ApiPlatformClientService, apiPlatformClientServiceName } from "./ApiPlatformClientService.mjs";
|
|
14
14
|
// ============================================================================
|
|
15
|
-
// OHLCV SERVICE
|
|
16
|
-
// ============================================================================
|
|
17
|
-
export { OHLCVService, OHLCV_SERVICE_ALLOWED_ACTIONS, OHLCV_SERVICE_ALLOWED_EVENTS } from "./api/ohlcv/index.mjs";
|
|
18
|
-
// ============================================================================
|
|
19
15
|
// API PLATFORM CLIENT
|
|
20
16
|
// ============================================================================
|
|
21
17
|
export { ApiPlatformClient, createApiPlatformClient,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,+EAA+E;AAC/E,4BAA4B;AAC5B,+EAA+E;AAE/E,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,kBAAkB,EACnB,sCAAkC;AAiBnC,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E,OAAO,EACL,sBAAsB,EACtB,wCAAwC,EACxC,uCAAuC,EACxC,qCAAiC;AA8BlC,+EAA+E;AAC/E,8BAA8B;AAC9B,+EAA+E;AAE/E,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC7B,uCAAmC;AASpC,+EAA+E;AAC/E,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,+EAA+E;AAC/E,4BAA4B;AAC5B,+EAA+E;AAE/E,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,kBAAkB,EACnB,sCAAkC;AAiBnC,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E,OAAO,EACL,sBAAsB,EACtB,wCAAwC,EACxC,uCAAuC,EACxC,qCAAiC;AA8BlC,+EAA+E;AAC/E,8BAA8B;AAC9B,+EAA+E;AAE/E,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC7B,uCAAmC;AASpC,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E,OAAO,EACL,iBAAiB,EACjB,uBAAuB;AACvB,yBAAyB;AACzB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,eAAe;AACf,YAAY;AACZ,QAAQ,EACR,WAAW,EACX,QAAQ;AACR,UAAU;AACV,mBAAmB,EACnB,wBAAwB,EACxB,WAAW;AACX,SAAS;AACT,SAAS,EACV,wBAAc","sourcesContent":["// Core Backend Package Exports\n\n// ============================================================================\n// BACKEND WEBSOCKET SERVICE\n// ============================================================================\n\nexport {\n BackendWebSocketService,\n getCloseReason,\n WebSocketState,\n WebSocketEventType,\n} from './BackendWebSocketService';\n\nexport type {\n BackendWebSocketServiceOptions,\n ClientRequestMessage,\n ServerResponseMessage,\n ServerNotificationMessage,\n WebSocketMessage,\n ChannelCallback,\n WebSocketSubscription,\n WebSocketConnectionInfo,\n BackendWebSocketServiceActions,\n BackendWebSocketServiceConnectionStateChangedEvent,\n BackendWebSocketServiceEvents,\n BackendWebSocketServiceMessenger,\n} from './BackendWebSocketService';\n\n// ============================================================================\n// ACCOUNT ACTIVITY SERVICE\n// ============================================================================\n\nexport {\n AccountActivityService,\n ACCOUNT_ACTIVITY_SERVICE_ALLOWED_ACTIONS,\n ACCOUNT_ACTIVITY_SERVICE_ALLOWED_EVENTS,\n} from './AccountActivityService';\n\nexport type {\n SystemNotificationData,\n SubscriptionOptions,\n AccountActivityServiceOptions,\n AccountActivityServiceActions,\n AllowedActions as AccountActivityServiceAllowedActions,\n AccountActivityServiceTransactionUpdatedEvent,\n AccountActivityServiceBalanceUpdatedEvent,\n AccountActivityServiceSubscriptionErrorEvent,\n AccountActivityServiceStatusChangedEvent,\n AccountActivityServiceEvents,\n AllowedEvents as AccountActivityServiceAllowedEvents,\n AccountActivityServiceMessenger,\n} from './AccountActivityService';\n\n// ============================================================================\n// SHARED TYPES\n// ============================================================================\n\nexport type {\n Transaction,\n Asset,\n Balance,\n Transfer,\n BalanceUpdate,\n AccountActivityMessage,\n} from './types';\n\n// ============================================================================\n// API PLATFORM CLIENT SERVICE\n// ============================================================================\n\nexport {\n ApiPlatformClientService,\n apiPlatformClientServiceName,\n} from './ApiPlatformClientService';\n\nexport type {\n ApiPlatformClientServiceOptions,\n ApiPlatformClientServiceActions,\n ApiPlatformClientServiceEvents,\n ApiPlatformClientServiceMessenger,\n} from './ApiPlatformClientService';\n\n// ============================================================================\n// API PLATFORM CLIENT\n// ============================================================================\n\nexport {\n ApiPlatformClient,\n createApiPlatformClient,\n // Individual API clients\n AccountsApiClient,\n PricesApiClient,\n TokenApiClient,\n TokensApiClient,\n // Constants\n API_URLS,\n STALE_TIMES,\n GC_TIMES,\n // Helpers\n calculateRetryDelay,\n getQueryOptionsOverrides,\n shouldRetry,\n // Errors\n HttpError,\n} from './api';\n\n// ============================================================================\n// API PLATFORM CLIENT TYPES\n// ============================================================================\n\nexport type {\n // Client options\n ApiPlatformClientOptions,\n FetchOptions,\n // Shared types\n PageInfo,\n SupportedCurrency,\n MarketDataDetails,\n // Accounts API types\n V5BalanceItem,\n V5BalancesResponse,\n V2BalanceItem,\n V2BalancesResponse,\n V4BalancesResponse,\n V1SupportedNetworksResponse,\n V2SupportedNetworksResponse,\n V2ActiveNetworksResponse,\n V1TransactionByHashResponse,\n V1AccountTransactionsResponse,\n V4MultiAccountTransactionsResponse,\n ValueTransfer,\n V1AccountRelationshipResult,\n NftItem,\n V2NftsResponse,\n TokenDiscoveryItem,\n V2TokensResponse,\n // Prices API types\n V3SpotPricesResponse,\n CoinGeckoSpotPrice,\n ExchangeRateInfo,\n V1ExchangeRatesResponse,\n PriceSupportedNetworksResponse,\n V1HistoricalPricesResponse,\n V3HistoricalPricesResponse,\n // Token API types\n TokenMetadata,\n V1TokenDescriptionResponse,\n NetworkInfo,\n TopAsset,\n TrendingSortBy,\n TrendingToken,\n TopGainersSortOption,\n TrendingSortOption,\n V1SuggestedOccurrenceFloorsResponse,\n // Tokens API types\n V1TokenSupportedNetworksResponse,\n V2TokenSupportedNetworksResponse,\n V3AssetResponse,\n} from './api';\n"]}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OHLCVService-method-action-types.cjs","sourceRoot":"","sources":["../../../src/api/ohlcv/OHLCVService-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { OHLCVService } from './OHLCVService';\n\n/**\n * Subscribe to an OHLCV channel for real-time candlestick data.\n *\n * @param options - The subscription parameters (assetId, interval, currency).\n */\nexport type OHLCVServiceSubscribeAction = {\n type: `OHLCVService:subscribe`;\n handler: OHLCVService['subscribe'];\n};\n\n/**\n * Unsubscribe from an OHLCV channel.\n *\n * @param options - The subscription parameters to unsubscribe from.\n */\nexport type OHLCVServiceUnsubscribeAction = {\n type: `OHLCVService:unsubscribe`;\n handler: OHLCVService['unsubscribe'];\n};\n\n/**\n * Union of all OHLCVService action types.\n */\nexport type OHLCVServiceMethodActions =\n | OHLCVServiceSubscribeAction\n | OHLCVServiceUnsubscribeAction;\n"]}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is auto generated.
|
|
3
|
-
* Do not edit manually.
|
|
4
|
-
*/
|
|
5
|
-
import type { OHLCVService } from "./OHLCVService.cjs";
|
|
6
|
-
/**
|
|
7
|
-
* Subscribe to an OHLCV channel for real-time candlestick data.
|
|
8
|
-
*
|
|
9
|
-
* @param options - The subscription parameters (assetId, interval, currency).
|
|
10
|
-
*/
|
|
11
|
-
export type OHLCVServiceSubscribeAction = {
|
|
12
|
-
type: `OHLCVService:subscribe`;
|
|
13
|
-
handler: OHLCVService['subscribe'];
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Unsubscribe from an OHLCV channel.
|
|
17
|
-
*
|
|
18
|
-
* @param options - The subscription parameters to unsubscribe from.
|
|
19
|
-
*/
|
|
20
|
-
export type OHLCVServiceUnsubscribeAction = {
|
|
21
|
-
type: `OHLCVService:unsubscribe`;
|
|
22
|
-
handler: OHLCVService['unsubscribe'];
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Union of all OHLCVService action types.
|
|
26
|
-
*/
|
|
27
|
-
export type OHLCVServiceMethodActions = OHLCVServiceSubscribeAction | OHLCVServiceUnsubscribeAction;
|
|
28
|
-
//# sourceMappingURL=OHLCVService-method-action-types.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OHLCVService-method-action-types.d.cts","sourceRoot":"","sources":["../../../src/api/ohlcv/OHLCVService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,2BAAuB;AAEnD;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CACpC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,0BAA0B,CAAC;IACjC,OAAO,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;CACtC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GACjC,2BAA2B,GAC3B,6BAA6B,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is auto generated.
|
|
3
|
-
* Do not edit manually.
|
|
4
|
-
*/
|
|
5
|
-
import type { OHLCVService } from "./OHLCVService.mjs";
|
|
6
|
-
/**
|
|
7
|
-
* Subscribe to an OHLCV channel for real-time candlestick data.
|
|
8
|
-
*
|
|
9
|
-
* @param options - The subscription parameters (assetId, interval, currency).
|
|
10
|
-
*/
|
|
11
|
-
export type OHLCVServiceSubscribeAction = {
|
|
12
|
-
type: `OHLCVService:subscribe`;
|
|
13
|
-
handler: OHLCVService['subscribe'];
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Unsubscribe from an OHLCV channel.
|
|
17
|
-
*
|
|
18
|
-
* @param options - The subscription parameters to unsubscribe from.
|
|
19
|
-
*/
|
|
20
|
-
export type OHLCVServiceUnsubscribeAction = {
|
|
21
|
-
type: `OHLCVService:unsubscribe`;
|
|
22
|
-
handler: OHLCVService['unsubscribe'];
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Union of all OHLCVService action types.
|
|
26
|
-
*/
|
|
27
|
-
export type OHLCVServiceMethodActions = OHLCVServiceSubscribeAction | OHLCVServiceUnsubscribeAction;
|
|
28
|
-
//# sourceMappingURL=OHLCVService-method-action-types.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OHLCVService-method-action-types.d.mts","sourceRoot":"","sources":["../../../src/api/ohlcv/OHLCVService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,2BAAuB;AAEnD;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CACpC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,0BAA0B,CAAC;IACjC,OAAO,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;CACtC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GACjC,2BAA2B,GAC3B,6BAA6B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OHLCVService-method-action-types.mjs","sourceRoot":"","sources":["../../../src/api/ohlcv/OHLCVService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { OHLCVService } from './OHLCVService';\n\n/**\n * Subscribe to an OHLCV channel for real-time candlestick data.\n *\n * @param options - The subscription parameters (assetId, interval, currency).\n */\nexport type OHLCVServiceSubscribeAction = {\n type: `OHLCVService:subscribe`;\n handler: OHLCVService['subscribe'];\n};\n\n/**\n * Unsubscribe from an OHLCV channel.\n *\n * @param options - The subscription parameters to unsubscribe from.\n */\nexport type OHLCVServiceUnsubscribeAction = {\n type: `OHLCVService:unsubscribe`;\n handler: OHLCVService['unsubscribe'];\n};\n\n/**\n * Union of all OHLCVService action types.\n */\nexport type OHLCVServiceMethodActions =\n | OHLCVServiceSubscribeAction\n | OHLCVServiceUnsubscribeAction;\n"]}
|
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* OHLCV Service for real-time candlestick data streaming via WebSocket.
|
|
4
|
-
*
|
|
5
|
-
* Wraps {@link BackendWebSocketService} through the messenger pattern to
|
|
6
|
-
* provide subscribe/unsubscribe semantics for OHLCV market-data channels.
|
|
7
|
-
* Includes reference counting, grace-period unsubscribe, idempotency checks,
|
|
8
|
-
* chain-status forwarding, and automatic resubscription on reconnect.
|
|
9
|
-
*/
|
|
10
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
11
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
12
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
13
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
14
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
15
|
-
};
|
|
16
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
17
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
18
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
19
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
20
|
-
};
|
|
21
|
-
var _OHLCVService_instances, _OHLCVService_messenger, _OHLCVService_trace, _OHLCVService_channels, _OHLCVService_chainsUp, _OHLCVService_performUnsubscribe, _OHLCVService_resubscribeActiveChannels, _OHLCVService_handleBarUpdate, _OHLCVService_handleSystemNotification, _OHLCVService_handleWebSocketStateChange, _OHLCVService_buildChannel, _OHLCVService_forceReconnection;
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.OHLCVService = exports.OHLCV_SERVICE_ALLOWED_EVENTS = exports.OHLCV_SERVICE_ALLOWED_ACTIONS = void 0;
|
|
24
|
-
const BackendWebSocketService_1 = require("../../BackendWebSocketService.cjs");
|
|
25
|
-
const logger_1 = require("../../logger.cjs");
|
|
26
|
-
// =============================================================================
|
|
27
|
-
// Constants
|
|
28
|
-
// =============================================================================
|
|
29
|
-
const SERVICE_NAME = 'OHLCVService';
|
|
30
|
-
const log = (0, logger_1.createModuleLogger)(logger_1.projectLogger, SERVICE_NAME);
|
|
31
|
-
const MESSENGER_EXPOSED_METHODS = ['subscribe', 'unsubscribe'];
|
|
32
|
-
const SUBSCRIPTION_NAMESPACE = 'market-data.v1';
|
|
33
|
-
const SYSTEM_NOTIFICATIONS_CHANNEL = `system-notifications.v1.${SUBSCRIPTION_NAMESPACE}`;
|
|
34
|
-
/** Delay before actually unsubscribing from a channel after refCount reaches 0. */
|
|
35
|
-
const GRACE_PERIOD_MS = 3000;
|
|
36
|
-
exports.OHLCV_SERVICE_ALLOWED_ACTIONS = [
|
|
37
|
-
'BackendWebSocketService:connect',
|
|
38
|
-
'BackendWebSocketService:forceReconnection',
|
|
39
|
-
'BackendWebSocketService:subscribe',
|
|
40
|
-
'BackendWebSocketService:getConnectionInfo',
|
|
41
|
-
'BackendWebSocketService:channelHasSubscription',
|
|
42
|
-
'BackendWebSocketService:getSubscriptionsByChannel',
|
|
43
|
-
'BackendWebSocketService:findSubscriptionsByChannelPrefix',
|
|
44
|
-
'BackendWebSocketService:addChannelCallback',
|
|
45
|
-
'BackendWebSocketService:removeChannelCallback',
|
|
46
|
-
];
|
|
47
|
-
exports.OHLCV_SERVICE_ALLOWED_EVENTS = [
|
|
48
|
-
'BackendWebSocketService:connectionStateChanged',
|
|
49
|
-
];
|
|
50
|
-
// =============================================================================
|
|
51
|
-
// Main Service Class
|
|
52
|
-
// =============================================================================
|
|
53
|
-
/**
|
|
54
|
-
* Service for real-time OHLCV candlestick streaming via the backend WebSocket
|
|
55
|
-
* gateway. Communicates with {@link BackendWebSocketService} exclusively
|
|
56
|
-
* through the messenger — no direct import of the class.
|
|
57
|
-
*
|
|
58
|
-
* Features:
|
|
59
|
-
* - Reference counting: multiple UI consumers share one WebSocket subscription
|
|
60
|
-
* - Grace-period unsubscribe: avoids rapid unsub/resub during navigation
|
|
61
|
-
* - Idempotency: duplicate subscribe calls for the same channel are no-ops
|
|
62
|
-
* - Reconnect resilience: resubscribes all active channels on reconnect
|
|
63
|
-
* - Chain-status forwarding: listens to system-notifications for chain up/down
|
|
64
|
-
*
|
|
65
|
-
*/
|
|
66
|
-
class OHLCVService {
|
|
67
|
-
// =============================================================================
|
|
68
|
-
// Constructor
|
|
69
|
-
// =============================================================================
|
|
70
|
-
constructor(options) {
|
|
71
|
-
_OHLCVService_instances.add(this);
|
|
72
|
-
this.name = SERVICE_NAME;
|
|
73
|
-
_OHLCVService_messenger.set(this, void 0);
|
|
74
|
-
_OHLCVService_trace.set(this, void 0);
|
|
75
|
-
_OHLCVService_channels.set(this, new Map());
|
|
76
|
-
_OHLCVService_chainsUp.set(this, new Set());
|
|
77
|
-
__classPrivateFieldSet(this, _OHLCVService_messenger, options.messenger, "f");
|
|
78
|
-
__classPrivateFieldSet(this, _OHLCVService_trace, options.traceFn ??
|
|
79
|
-
((_request, fn) => fn?.()), "f");
|
|
80
|
-
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
81
|
-
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").subscribe('BackendWebSocketService:connectionStateChanged',
|
|
82
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
83
|
-
(connectionInfo) => __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_handleWebSocketStateChange).call(this, connectionInfo));
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Register the system-notifications channel callback.
|
|
87
|
-
*/
|
|
88
|
-
init() {
|
|
89
|
-
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:addChannelCallback', {
|
|
90
|
-
channelName: SYSTEM_NOTIFICATIONS_CHANNEL,
|
|
91
|
-
callback: (notification) => __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_handleSystemNotification).call(this, notification),
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
// =============================================================================
|
|
95
|
-
// Public — Subscribe / Unsubscribe
|
|
96
|
-
// =============================================================================
|
|
97
|
-
/**
|
|
98
|
-
* Subscribe to an OHLCV channel. If this is the first subscriber for the
|
|
99
|
-
* given asset/interval/currency combination a WebSocket subscription is
|
|
100
|
-
* created. Additional calls for the same combination only bump the reference
|
|
101
|
-
* count.
|
|
102
|
-
*
|
|
103
|
-
* @param options - The subscription parameters.
|
|
104
|
-
*/
|
|
105
|
-
async subscribe(options) {
|
|
106
|
-
const channel = __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_buildChannel).call(this, options);
|
|
107
|
-
const entry = __classPrivateFieldGet(this, _OHLCVService_channels, "f").get(channel);
|
|
108
|
-
if (entry?.gracePeriodTimer) {
|
|
109
|
-
clearTimeout(entry.gracePeriodTimer);
|
|
110
|
-
entry.gracePeriodTimer = undefined;
|
|
111
|
-
entry.refCount += 1;
|
|
112
|
-
log('Cancelled grace-period unsubscribe, bumped refCount', {
|
|
113
|
-
channel,
|
|
114
|
-
refCount: entry.refCount,
|
|
115
|
-
});
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (entry && entry.refCount > 0) {
|
|
119
|
-
entry.refCount += 1;
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
try {
|
|
123
|
-
await __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:connect');
|
|
124
|
-
if (__classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:channelHasSubscription', channel)) {
|
|
125
|
-
__classPrivateFieldGet(this, _OHLCVService_channels, "f").set(channel, { refCount: 1 });
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
await __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:subscribe', {
|
|
129
|
-
channels: [channel],
|
|
130
|
-
channelType: SUBSCRIPTION_NAMESPACE,
|
|
131
|
-
callback: (notification) => {
|
|
132
|
-
__classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_handleBarUpdate).call(this, channel, notification);
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
__classPrivateFieldGet(this, _OHLCVService_channels, "f").set(channel, { refCount: 1 });
|
|
136
|
-
}
|
|
137
|
-
catch (error) {
|
|
138
|
-
log('Subscription failed, forcing reconnection', { channel, error });
|
|
139
|
-
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").publish('OHLCVService:subscriptionError', {
|
|
140
|
-
channel,
|
|
141
|
-
error: String(error),
|
|
142
|
-
operation: 'subscribe',
|
|
143
|
-
});
|
|
144
|
-
await __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_forceReconnection).call(this);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Unsubscribe from an OHLCV channel. Decrements the reference count and,
|
|
149
|
-
* when it reaches zero, starts a grace-period timer before actually
|
|
150
|
-
* unsubscribing from the WebSocket to absorb rapid navigation patterns.
|
|
151
|
-
*
|
|
152
|
-
* @param options - The subscription parameters to unsubscribe from.
|
|
153
|
-
*/
|
|
154
|
-
async unsubscribe(options) {
|
|
155
|
-
const channel = __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_buildChannel).call(this, options);
|
|
156
|
-
const entry = __classPrivateFieldGet(this, _OHLCVService_channels, "f").get(channel);
|
|
157
|
-
if (!entry || entry.refCount <= 0) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
entry.refCount -= 1;
|
|
161
|
-
if (entry.refCount > 0) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
entry.gracePeriodTimer = setTimeout(() => {
|
|
165
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
166
|
-
__classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_performUnsubscribe).call(this, channel);
|
|
167
|
-
}, GRACE_PERIOD_MS);
|
|
168
|
-
}
|
|
169
|
-
// =============================================================================
|
|
170
|
-
// Public — Cleanup
|
|
171
|
-
// =============================================================================
|
|
172
|
-
/**
|
|
173
|
-
* Destroy the service and clean up all resources.
|
|
174
|
-
*/
|
|
175
|
-
destroy() {
|
|
176
|
-
for (const entry of __classPrivateFieldGet(this, _OHLCVService_channels, "f").values()) {
|
|
177
|
-
if (entry.gracePeriodTimer) {
|
|
178
|
-
clearTimeout(entry.gracePeriodTimer);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
__classPrivateFieldGet(this, _OHLCVService_channels, "f").clear();
|
|
182
|
-
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:removeChannelCallback', SYSTEM_NOTIFICATIONS_CHANNEL);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
exports.OHLCVService = OHLCVService;
|
|
186
|
-
_OHLCVService_messenger = new WeakMap(), _OHLCVService_trace = new WeakMap(), _OHLCVService_channels = new WeakMap(), _OHLCVService_chainsUp = new WeakMap(), _OHLCVService_instances = new WeakSet(), _OHLCVService_performUnsubscribe =
|
|
187
|
-
// =============================================================================
|
|
188
|
-
// Private — WebSocket Subscription Helpers
|
|
189
|
-
// =============================================================================
|
|
190
|
-
async function _OHLCVService_performUnsubscribe(channel) {
|
|
191
|
-
__classPrivateFieldGet(this, _OHLCVService_channels, "f").delete(channel);
|
|
192
|
-
try {
|
|
193
|
-
const subscriptions = __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:getSubscriptionsByChannel', channel);
|
|
194
|
-
for (const sub of subscriptions) {
|
|
195
|
-
await sub.unsubscribe();
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
catch (error) {
|
|
199
|
-
log('Unsubscription failed, forcing reconnection', { channel, error });
|
|
200
|
-
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").publish('OHLCVService:subscriptionError', {
|
|
201
|
-
channel,
|
|
202
|
-
error: String(error),
|
|
203
|
-
operation: 'unsubscribe',
|
|
204
|
-
});
|
|
205
|
-
await __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_forceReconnection).call(this);
|
|
206
|
-
}
|
|
207
|
-
}, _OHLCVService_resubscribeActiveChannels =
|
|
208
|
-
/**
|
|
209
|
-
* Resubscribe all channels that were active before a disconnect.
|
|
210
|
-
* Called when WebSocket transitions to CONNECTED.
|
|
211
|
-
*/
|
|
212
|
-
async function _OHLCVService_resubscribeActiveChannels() {
|
|
213
|
-
for (const [channel, entry] of __classPrivateFieldGet(this, _OHLCVService_channels, "f").entries()) {
|
|
214
|
-
if (entry.refCount <= 0 && !entry.gracePeriodTimer) {
|
|
215
|
-
continue;
|
|
216
|
-
}
|
|
217
|
-
try {
|
|
218
|
-
if (__classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:channelHasSubscription', channel)) {
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
await __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:subscribe', {
|
|
222
|
-
channels: [channel],
|
|
223
|
-
channelType: SUBSCRIPTION_NAMESPACE,
|
|
224
|
-
callback: (notification) => {
|
|
225
|
-
__classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_handleBarUpdate).call(this, channel, notification);
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
catch (error) {
|
|
230
|
-
log('Resubscription failed for channel', { channel, error });
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}, _OHLCVService_handleBarUpdate = function _OHLCVService_handleBarUpdate(channel, notification) {
|
|
234
|
-
const bar = notification.data;
|
|
235
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
236
|
-
__classPrivateFieldGet(this, _OHLCVService_trace, "f").call(this, {
|
|
237
|
-
name: `${SERVICE_NAME} Bar Update`,
|
|
238
|
-
data: { channel, timestamp: bar.timestamp },
|
|
239
|
-
tags: { service: SERVICE_NAME },
|
|
240
|
-
}, () => {
|
|
241
|
-
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").publish('OHLCVService:barUpdated', { channel, bar });
|
|
242
|
-
});
|
|
243
|
-
}, _OHLCVService_handleSystemNotification = function _OHLCVService_handleSystemNotification(notification) {
|
|
244
|
-
const data = notification.data;
|
|
245
|
-
const { timestamp } = notification;
|
|
246
|
-
if (!data.chainIds || !Array.isArray(data.chainIds) || !data.status) {
|
|
247
|
-
throw new Error('Invalid system notification data: missing chainIds or status');
|
|
248
|
-
}
|
|
249
|
-
if (data.status === 'up') {
|
|
250
|
-
for (const chainId of data.chainIds) {
|
|
251
|
-
__classPrivateFieldGet(this, _OHLCVService_chainsUp, "f").add(chainId);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
for (const chainId of data.chainIds) {
|
|
256
|
-
__classPrivateFieldGet(this, _OHLCVService_chainsUp, "f").delete(chainId);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").publish('OHLCVService:chainStatusChanged', {
|
|
260
|
-
chainIds: data.chainIds,
|
|
261
|
-
status: data.status,
|
|
262
|
-
timestamp,
|
|
263
|
-
});
|
|
264
|
-
log(`Chain status change: ${data.status}`, {
|
|
265
|
-
chains: data.chainIds,
|
|
266
|
-
status: data.status,
|
|
267
|
-
});
|
|
268
|
-
}, _OHLCVService_handleWebSocketStateChange = async function _OHLCVService_handleWebSocketStateChange(connectionInfo) {
|
|
269
|
-
const { state } = connectionInfo;
|
|
270
|
-
if (state === BackendWebSocketService_1.WebSocketState.CONNECTED) {
|
|
271
|
-
await __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_resubscribeActiveChannels).call(this);
|
|
272
|
-
}
|
|
273
|
-
else if (state === BackendWebSocketService_1.WebSocketState.DISCONNECTED) {
|
|
274
|
-
const chainsToMarkDown = Array.from(__classPrivateFieldGet(this, _OHLCVService_chainsUp, "f"));
|
|
275
|
-
if (chainsToMarkDown.length > 0) {
|
|
276
|
-
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").publish('OHLCVService:chainStatusChanged', {
|
|
277
|
-
chainIds: chainsToMarkDown,
|
|
278
|
-
status: 'down',
|
|
279
|
-
timestamp: Date.now(),
|
|
280
|
-
});
|
|
281
|
-
log('WebSocket disconnection - marked tracked chains as down', {
|
|
282
|
-
count: chainsToMarkDown.length,
|
|
283
|
-
chains: chainsToMarkDown,
|
|
284
|
-
});
|
|
285
|
-
__classPrivateFieldGet(this, _OHLCVService_chainsUp, "f").clear();
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}, _OHLCVService_buildChannel = function _OHLCVService_buildChannel(options) {
|
|
289
|
-
return `${SUBSCRIPTION_NAMESPACE}.${options.assetId}.${options.interval}.${options.currency}`;
|
|
290
|
-
}, _OHLCVService_forceReconnection = async function _OHLCVService_forceReconnection() {
|
|
291
|
-
log('Forcing WebSocket reconnection');
|
|
292
|
-
await __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:forceReconnection');
|
|
293
|
-
};
|
|
294
|
-
//# sourceMappingURL=OHLCVService.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OHLCVService.cjs","sourceRoot":"","sources":["../../../src/api/ohlcv/OHLCVService.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;AAcH,+EAA+D;AAE/D,6CAAiE;AAIjE,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,MAAM,GAAG,GAAG,IAAA,2BAAkB,EAAC,sBAAa,EAAE,YAAY,CAAC,CAAC;AAE5D,MAAM,yBAAyB,GAAG,CAAC,WAAW,EAAE,aAAa,CAAU,CAAC;AAExE,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AAEhD,MAAM,4BAA4B,GAAG,2BAA2B,sBAAsB,EAAE,CAAC;AAEzF,mFAAmF;AACnF,MAAM,eAAe,GAAG,IAAK,CAAC;AA0CjB,QAAA,6BAA6B,GAAG;IAC3C,iCAAiC;IACjC,2CAA2C;IAC3C,mCAAmC;IACnC,2CAA2C;IAC3C,gDAAgD;IAChD,mDAAmD;IACnD,0DAA0D;IAC1D,4CAA4C;IAC5C,+CAA+C;CACvC,CAAC;AAEE,QAAA,4BAA4B,GAAG;IAC1C,gDAAgD;CACxC,CAAC;AAkCX,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF;AAEhF;;;;;;;;;;;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AAU,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;AACH,CAAC,mEAMa,OAAiC;IAC7C,OAAO,GAAG,sBAAsB,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;AAChG,CAAC,oCAED,KAAK;IACH,GAAG,CAAC,gCAAgC,CAAC,CAAC;IACtC,MAAM,uBAAA,IAAI,+BAAW,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["/**\n * OHLCV Service for real-time candlestick data streaming via WebSocket.\n *\n * Wraps {@link BackendWebSocketService} through the messenger pattern to\n * provide subscribe/unsubscribe semantics for OHLCV market-data channels.\n * Includes reference counting, grace-period unsubscribe, idempotency checks,\n * chain-status forwarding, and automatic resubscription on reconnect.\n */\n\nimport type {\n TraceCallback,\n TraceContext,\n TraceRequest,\n} from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type {\n WebSocketConnectionInfo,\n BackendWebSocketServiceConnectionStateChangedEvent,\n ServerNotificationMessage,\n} from '../../BackendWebSocketService';\nimport { WebSocketState } from '../../BackendWebSocketService';\nimport type { BackendWebSocketServiceMethodActions } from '../../BackendWebSocketService-method-action-types';\nimport { projectLogger, createModuleLogger } from '../../logger';\nimport type { OHLCVServiceMethodActions } from './OHLCVService-method-action-types';\nimport type { OHLCVBar, OHLCVSubscriptionOptions } from './types';\n\n// =============================================================================\n// Constants\n// =============================================================================\n\nconst SERVICE_NAME = 'OHLCVService';\n\nconst log = createModuleLogger(projectLogger, SERVICE_NAME);\n\nconst MESSENGER_EXPOSED_METHODS = ['subscribe', 'unsubscribe'] as const;\n\nconst SUBSCRIPTION_NAMESPACE = 'market-data.v1';\n\nconst SYSTEM_NOTIFICATIONS_CHANNEL = `system-notifications.v1.${SUBSCRIPTION_NAMESPACE}`;\n\n/** Delay before actually unsubscribing from a channel after refCount reaches 0. */\nconst GRACE_PERIOD_MS = 3_000;\n\n// =============================================================================\n// Types — Channel Tracking\n// =============================================================================\n\ntype ChannelEntry = {\n refCount: number;\n gracePeriodTimer?: ReturnType<typeof setTimeout>;\n};\n\n// =============================================================================\n// Types — System Notifications\n// =============================================================================\n\n/**\n * System notification data for chain status updates on market-data channels.\n */\nexport type OHLCVSystemNotificationData = {\n chainIds: string[];\n status: 'down' | 'up';\n timestamp?: number;\n};\n\n// =============================================================================\n// Types — Service Options\n// =============================================================================\n\n/**\n * Configuration options for the OHLCV service.\n */\nexport type OHLCVServiceOptions = {\n /** Optional callback to trace performance of OHLCV operations (default: no-op) */\n traceFn?: TraceCallback;\n};\n\n// =============================================================================\n// Action and Event Types\n// =============================================================================\n\nexport type OHLCVServiceActions = OHLCVServiceMethodActions;\n\nexport const OHLCV_SERVICE_ALLOWED_ACTIONS = [\n 'BackendWebSocketService:connect',\n 'BackendWebSocketService:forceReconnection',\n 'BackendWebSocketService:subscribe',\n 'BackendWebSocketService:getConnectionInfo',\n 'BackendWebSocketService:channelHasSubscription',\n 'BackendWebSocketService:getSubscriptionsByChannel',\n 'BackendWebSocketService:findSubscriptionsByChannelPrefix',\n 'BackendWebSocketService:addChannelCallback',\n 'BackendWebSocketService:removeChannelCallback',\n] as const;\n\nexport const OHLCV_SERVICE_ALLOWED_EVENTS = [\n 'BackendWebSocketService:connectionStateChanged',\n] as const;\n\nexport type AllowedActions = BackendWebSocketServiceMethodActions;\n\n// Events published by OHLCVService\n\nexport type OHLCVServiceBarUpdatedEvent = {\n type: `OHLCVService:barUpdated`;\n payload: [{ channel: string; bar: OHLCVBar }];\n};\n\nexport type OHLCVServiceChainStatusChangedEvent = {\n type: `OHLCVService:chainStatusChanged`;\n payload: [{ chainIds: string[]; status: 'up' | 'down'; timestamp?: number }];\n};\n\nexport type OHLCVServiceSubscriptionErrorEvent = {\n type: `OHLCVService:subscriptionError`;\n payload: [{ channel: string; error: string; operation: string }];\n};\n\nexport type OHLCVServiceEvents =\n | OHLCVServiceBarUpdatedEvent\n | OHLCVServiceChainStatusChangedEvent\n | OHLCVServiceSubscriptionErrorEvent;\n\nexport type AllowedEvents = BackendWebSocketServiceConnectionStateChangedEvent;\n\nexport type OHLCVServiceMessenger = Messenger<\n typeof SERVICE_NAME,\n OHLCVServiceActions | AllowedActions,\n OHLCVServiceEvents | AllowedEvents\n>;\n\n// =============================================================================\n// Main Service Class\n// =============================================================================\n\n/**\n * Service for real-time OHLCV candlestick streaming via the backend WebSocket\n * gateway. Communicates with {@link BackendWebSocketService} exclusively\n * through the messenger — no direct import of the class.\n *\n * Features:\n * - Reference counting: multiple UI consumers share one WebSocket subscription\n * - Grace-period unsubscribe: avoids rapid unsub/resub during navigation\n * - Idempotency: duplicate subscribe calls for the same channel are no-ops\n * - Reconnect resilience: resubscribes all active channels on reconnect\n * - Chain-status forwarding: listens to system-notifications for chain up/down\n *\n */\nexport class OHLCVService {\n readonly name = SERVICE_NAME;\n\n readonly #messenger: OHLCVServiceMessenger;\n\n readonly #trace: TraceCallback;\n\n readonly #channels = new Map<string, ChannelEntry>();\n\n readonly #chainsUp = new Set<string>();\n\n // =============================================================================\n // Constructor\n // =============================================================================\n\n constructor(\n options: OHLCVServiceOptions & { messenger: OHLCVServiceMessenger },\n ) {\n this.#messenger = options.messenger;\n\n this.#trace =\n options.traceFn ??\n ((<Result>(\n _request: TraceRequest,\n fn?: (context?: TraceContext) => Result,\n ) => fn?.()) as TraceCallback);\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.#messenger.subscribe(\n 'BackendWebSocketService:connectionStateChanged',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n (connectionInfo: WebSocketConnectionInfo) =>\n this.#handleWebSocketStateChange(connectionInfo),\n );\n }\n\n /**\n * Register the system-notifications channel callback.\n */\n init(): void {\n this.#messenger.call('BackendWebSocketService:addChannelCallback', {\n channelName: SYSTEM_NOTIFICATIONS_CHANNEL,\n callback: (notification: ServerNotificationMessage) =>\n this.#handleSystemNotification(notification),\n });\n }\n\n // =============================================================================\n // Public — Subscribe / Unsubscribe\n // =============================================================================\n\n /**\n * Subscribe to an OHLCV channel. If this is the first subscriber for the\n * given asset/interval/currency combination a WebSocket subscription is\n * created. Additional calls for the same combination only bump the reference\n * count.\n *\n * @param options - The subscription parameters.\n */\n async subscribe(options: OHLCVSubscriptionOptions): Promise<void> {\n const channel = this.#buildChannel(options);\n const entry = this.#channels.get(channel);\n\n if (entry?.gracePeriodTimer) {\n clearTimeout(entry.gracePeriodTimer);\n entry.gracePeriodTimer = undefined;\n entry.refCount += 1;\n log('Cancelled grace-period unsubscribe, bumped refCount', {\n channel,\n refCount: entry.refCount,\n });\n return;\n }\n\n if (entry && entry.refCount > 0) {\n entry.refCount += 1;\n return;\n }\n\n try {\n await this.#messenger.call('BackendWebSocketService:connect');\n\n if (\n this.#messenger.call(\n 'BackendWebSocketService:channelHasSubscription',\n channel,\n )\n ) {\n this.#channels.set(channel, { refCount: 1 });\n return;\n }\n\n await this.#messenger.call('BackendWebSocketService:subscribe', {\n channels: [channel],\n channelType: SUBSCRIPTION_NAMESPACE,\n callback: (notification: ServerNotificationMessage) => {\n this.#handleBarUpdate(channel, notification);\n },\n });\n\n this.#channels.set(channel, { refCount: 1 });\n } catch (error) {\n log('Subscription failed, forcing reconnection', { channel, error });\n this.#messenger.publish('OHLCVService:subscriptionError', {\n channel,\n error: String(error),\n operation: 'subscribe',\n });\n await this.#forceReconnection();\n }\n }\n\n /**\n * Unsubscribe from an OHLCV channel. Decrements the reference count and,\n * when it reaches zero, starts a grace-period timer before actually\n * unsubscribing from the WebSocket to absorb rapid navigation patterns.\n *\n * @param options - The subscription parameters to unsubscribe from.\n */\n async unsubscribe(options: OHLCVSubscriptionOptions): Promise<void> {\n const channel = this.#buildChannel(options);\n const entry = this.#channels.get(channel);\n\n if (!entry || entry.refCount <= 0) {\n return;\n }\n\n entry.refCount -= 1;\n\n if (entry.refCount > 0) {\n return;\n }\n\n entry.gracePeriodTimer = setTimeout(() => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#performUnsubscribe(channel);\n }, GRACE_PERIOD_MS);\n }\n\n // =============================================================================\n // Private — WebSocket Subscription Helpers\n // =============================================================================\n\n async #performUnsubscribe(channel: string): Promise<void> {\n this.#channels.delete(channel);\n\n try {\n const subscriptions = this.#messenger.call(\n 'BackendWebSocketService:getSubscriptionsByChannel',\n channel,\n );\n\n for (const sub of subscriptions) {\n await sub.unsubscribe();\n }\n } catch (error) {\n log('Unsubscription failed, forcing reconnection', { channel, error });\n this.#messenger.publish('OHLCVService:subscriptionError', {\n channel,\n error: String(error),\n operation: 'unsubscribe',\n });\n await this.#forceReconnection();\n }\n }\n\n /**\n * Resubscribe all channels that were active before a disconnect.\n * Called when WebSocket transitions to CONNECTED.\n */\n async #resubscribeActiveChannels(): Promise<void> {\n for (const [channel, entry] of this.#channels.entries()) {\n if (entry.refCount <= 0 && !entry.gracePeriodTimer) {\n continue;\n }\n\n try {\n if (\n this.#messenger.call(\n 'BackendWebSocketService:channelHasSubscription',\n channel,\n )\n ) {\n continue;\n }\n\n await this.#messenger.call('BackendWebSocketService:subscribe', {\n channels: [channel],\n channelType: SUBSCRIPTION_NAMESPACE,\n callback: (notification: ServerNotificationMessage) => {\n this.#handleBarUpdate(channel, notification);\n },\n });\n } catch (error) {\n log('Resubscription failed for channel', { channel, error });\n }\n }\n }\n\n // =============================================================================\n // Private — Message Handlers\n // =============================================================================\n\n #handleBarUpdate(\n channel: string,\n notification: ServerNotificationMessage,\n ): void {\n const bar = notification.data as OHLCVBar;\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#trace(\n {\n name: `${SERVICE_NAME} Bar Update`,\n data: { channel, timestamp: bar.timestamp },\n tags: { service: SERVICE_NAME },\n },\n () => {\n this.#messenger.publish('OHLCVService:barUpdated', { channel, bar });\n },\n );\n }\n\n #handleSystemNotification(notification: ServerNotificationMessage): void {\n const data = notification.data as OHLCVSystemNotificationData;\n const { timestamp } = notification;\n\n if (!data.chainIds || !Array.isArray(data.chainIds) || !data.status) {\n throw new Error(\n 'Invalid system notification data: missing chainIds or status',\n );\n }\n\n if (data.status === 'up') {\n for (const chainId of data.chainIds) {\n this.#chainsUp.add(chainId);\n }\n } else {\n for (const chainId of data.chainIds) {\n this.#chainsUp.delete(chainId);\n }\n }\n\n this.#messenger.publish('OHLCVService:chainStatusChanged', {\n chainIds: data.chainIds,\n status: data.status,\n timestamp,\n });\n\n log(`Chain status change: ${data.status}`, {\n chains: data.chainIds,\n status: data.status,\n });\n }\n\n async #handleWebSocketStateChange(\n connectionInfo: WebSocketConnectionInfo,\n ): Promise<void> {\n const { state } = connectionInfo;\n\n if (state === WebSocketState.CONNECTED) {\n await this.#resubscribeActiveChannels();\n } else if (state === WebSocketState.DISCONNECTED) {\n const chainsToMarkDown = Array.from(this.#chainsUp);\n\n if (chainsToMarkDown.length > 0) {\n this.#messenger.publish('OHLCVService:chainStatusChanged', {\n chainIds: chainsToMarkDown,\n status: 'down',\n timestamp: Date.now(),\n });\n\n log('WebSocket disconnection - marked tracked chains as down', {\n count: chainsToMarkDown.length,\n chains: chainsToMarkDown,\n });\n\n this.#chainsUp.clear();\n }\n }\n }\n\n // =============================================================================\n // Private — Utility\n // =============================================================================\n\n #buildChannel(options: OHLCVSubscriptionOptions): string {\n return `${SUBSCRIPTION_NAMESPACE}.${options.assetId}.${options.interval}.${options.currency}`;\n }\n\n async #forceReconnection(): Promise<void> {\n log('Forcing WebSocket reconnection');\n await this.#messenger.call('BackendWebSocketService:forceReconnection');\n }\n\n // =============================================================================\n // Public — Cleanup\n // =============================================================================\n\n /**\n * Destroy the service and clean up all resources.\n */\n destroy(): void {\n for (const entry of this.#channels.values()) {\n if (entry.gracePeriodTimer) {\n clearTimeout(entry.gracePeriodTimer);\n }\n }\n this.#channels.clear();\n\n this.#messenger.call(\n 'BackendWebSocketService:removeChannelCallback',\n SYSTEM_NOTIFICATIONS_CHANNEL,\n );\n }\n}\n"]}
|