@nadohq/mobile-client 0.64.0 → 0.66.0
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/README.md +124 -7
- package/dist/MobileClient-M4oC4lrX.cjs +1101 -0
- package/dist/MobileClient-M4oC4lrX.cjs.map +1 -0
- package/dist/MobileClient.cjs +1 -1
- package/dist/MobileClient.d.cts +306 -10
- package/dist/MobileClient.d.cts.map +1 -1
- package/dist/MobileClient.d.ts +306 -10
- package/dist/MobileClient.d.ts.map +1 -1
- package/dist/MobileClient.js +544 -5
- package/dist/MobileClient.js.map +1 -1
- package/dist/{MobileServerFailureError-Dd3c6P_Z.d.ts → MobileServerFailureError-C9iqNsxI.d.ts} +2 -3
- package/dist/MobileServerFailureError-C9iqNsxI.d.ts.map +1 -0
- package/dist/{MobileServerFailureError-Bpa_WA9f.d.cts → MobileServerFailureError-MtS2reel.d.cts} +2 -3
- package/dist/MobileServerFailureError-MtS2reel.d.cts.map +1 -0
- package/dist/MobileUnsupportedFeedItemError-BsZvW8i2.d.cts +15 -0
- package/dist/MobileUnsupportedFeedItemError-BsZvW8i2.d.cts.map +1 -0
- package/dist/MobileUnsupportedFeedItemError-BsZvW8i2.d.ts +15 -0
- package/dist/MobileUnsupportedFeedItemError-BsZvW8i2.d.ts.map +1 -0
- package/dist/MobileUnsupportedNotificationRouteError-DpiNBvvY.d.cts +15 -0
- package/dist/MobileUnsupportedNotificationRouteError-DpiNBvvY.d.cts.map +1 -0
- package/dist/MobileUnsupportedNotificationRouteError-DpiNBvvY.d.ts +15 -0
- package/dist/MobileUnsupportedNotificationRouteError-DpiNBvvY.d.ts.map +1 -0
- package/dist/{buildSignedMobileRequest-Cb1T74xV.d.ts → buildSignedMobileRequest-BR-KJhIF.d.ts} +2 -2
- package/dist/{buildSignedMobileRequest-Cb1T74xV.d.ts.map → buildSignedMobileRequest-BR-KJhIF.d.ts.map} +1 -1
- package/dist/{buildSignedMobileRequest-NHbMAPzd.d.cts → buildSignedMobileRequest-DyKCK34Y.d.cts} +2 -2
- package/dist/{buildSignedMobileRequest-NHbMAPzd.d.cts.map → buildSignedMobileRequest-DyKCK34Y.d.cts.map} +1 -1
- package/dist/{canonicalize-BBYGh17w.d.ts → canonicalize-Bv6UIAbR.d.ts} +2 -2
- package/dist/canonicalize-Bv6UIAbR.d.ts.map +1 -0
- package/dist/{canonicalize-BF_SiNvO.d.cts → canonicalize-CWh3XZzj.d.cts} +2 -2
- package/dist/canonicalize-CWh3XZzj.d.cts.map +1 -0
- package/dist/clientTypes-BUn5_OzK.d.ts +1665 -0
- package/dist/clientTypes-BUn5_OzK.d.ts.map +1 -0
- package/dist/clientTypes-DOpUcu80.d.cts +1665 -0
- package/dist/clientTypes-DOpUcu80.d.cts.map +1 -0
- package/dist/dataMappers.cjs +691 -14
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.d.cts +254 -8
- package/dist/dataMappers.d.cts.map +1 -1
- package/dist/dataMappers.d.ts +254 -8
- package/dist/dataMappers.d.ts.map +1 -1
- package/dist/dataMappers.js +651 -15
- package/dist/dataMappers.js.map +1 -1
- package/dist/{eip712MethodByType-BSx11xG-.d.cts → eip712MethodByType-CJ6BoayT.d.cts} +2 -2
- package/dist/eip712MethodByType-CJ6BoayT.d.cts.map +1 -0
- package/dist/{eip712MethodByType-DkiAjCLs.d.ts → eip712MethodByType-Dx4mvgni.d.ts} +2 -2
- package/dist/eip712MethodByType-Dx4mvgni.d.ts.map +1 -0
- package/dist/{feed-DTJlsg8W.d.ts → feed-DErOLaoY.d.cts} +4 -2
- package/dist/feed-DErOLaoY.d.cts.map +1 -0
- package/dist/{feed-DTJlsg8W.d.cts → feed-DErOLaoY.d.ts} +4 -2
- package/dist/feed-DErOLaoY.d.ts.map +1 -0
- package/dist/index.cjs +9 -2
- package/dist/index.d.cts +15 -16
- package/dist/index.d.ts +15 -16
- package/dist/index.js +5 -3
- package/dist/{mobileErrorCodes-3LtreeZM.d.ts → mobileErrorCodes-vD6rbFuF.d.cts} +25 -6
- package/dist/mobileErrorCodes-vD6rbFuF.d.cts.map +1 -0
- package/dist/{mobileErrorCodes-3LtreeZM.d.cts → mobileErrorCodes-vD6rbFuF.d.ts} +25 -6
- package/dist/mobileErrorCodes-vD6rbFuF.d.ts.map +1 -0
- package/dist/{payloadHash-BOWGjqdb.d.cts → payloadHash-CdkF2Ocr.d.cts} +2 -2
- package/dist/payloadHash-CdkF2Ocr.d.cts.map +1 -0
- package/dist/{payloadHash-Bzf4CtjV.d.ts → payloadHash-HD29K77M.d.ts} +2 -2
- package/dist/payloadHash-HD29K77M.d.ts.map +1 -0
- package/dist/serverExecuteTypes-5JyyIXRK.d.ts +178 -0
- package/dist/serverExecuteTypes-5JyyIXRK.d.ts.map +1 -0
- package/dist/serverExecuteTypes-CHrQ9Rtq.d.cts +178 -0
- package/dist/serverExecuteTypes-CHrQ9Rtq.d.cts.map +1 -0
- package/dist/serverModelTypes-CGUZCi0y.d.cts +938 -0
- package/dist/serverModelTypes-CGUZCi0y.d.cts.map +1 -0
- package/dist/serverModelTypes-CGUZCi0y.d.ts +938 -0
- package/dist/serverModelTypes-CGUZCi0y.d.ts.map +1 -0
- package/dist/{serverResponseGuards-BU1Xv_tG.d.ts → serverResponseGuards-Bvw8ltYJ.d.ts} +2 -2
- package/dist/{serverResponseGuards-BU1Xv_tG.d.ts.map → serverResponseGuards-Bvw8ltYJ.d.ts.map} +1 -1
- package/dist/{serverResponseGuards-Dkdok0Sm.d.cts → serverResponseGuards-i1njcYKN.d.cts} +2 -2
- package/dist/{serverResponseGuards-Dkdok0Sm.d.cts.map → serverResponseGuards-i1njcYKN.d.cts.map} +1 -1
- package/dist/signing/buildSignedMobileRequest.d.cts +1 -1
- package/dist/signing/buildSignedMobileRequest.d.ts +1 -1
- package/dist/signing/canonicalize.cjs +86 -0
- package/dist/signing/canonicalize.cjs.map +1 -1
- package/dist/signing/canonicalize.d.cts +1 -1
- package/dist/signing/canonicalize.d.ts +1 -1
- package/dist/signing/canonicalize.js +86 -0
- package/dist/signing/canonicalize.js.map +1 -1
- package/dist/signing/eip712MethodByType.cjs +12 -0
- package/dist/signing/eip712MethodByType.cjs.map +1 -1
- package/dist/signing/eip712MethodByType.d.cts +1 -1
- package/dist/signing/eip712MethodByType.d.ts +1 -1
- package/dist/signing/eip712MethodByType.js +12 -0
- package/dist/signing/eip712MethodByType.js.map +1 -1
- package/dist/signing/index.d.cts +5 -5
- package/dist/signing/index.d.ts +5 -5
- package/dist/signing/payloadHash.cjs +1 -1
- package/dist/signing/payloadHash.d.cts +1 -1
- package/dist/signing/payloadHash.d.ts +1 -1
- package/dist/signing/payloadHash.js +1 -1
- package/dist/signing/types.d.cts +1 -1
- package/dist/signing/types.d.ts +1 -1
- package/dist/types/MobileServerFailureError.d.cts +1 -1
- package/dist/types/MobileServerFailureError.d.ts +1 -1
- package/dist/types/MobileUnsupportedFeedItemError.cjs +19 -0
- package/dist/types/MobileUnsupportedFeedItemError.cjs.map +1 -0
- package/dist/types/MobileUnsupportedFeedItemError.d.cts +2 -0
- package/dist/types/MobileUnsupportedFeedItemError.d.ts +2 -0
- package/dist/types/MobileUnsupportedFeedItemError.js +18 -0
- package/dist/types/MobileUnsupportedFeedItemError.js.map +1 -0
- package/dist/types/MobileUnsupportedNotificationRouteError.cjs +19 -0
- package/dist/types/MobileUnsupportedNotificationRouteError.cjs.map +1 -0
- package/dist/types/MobileUnsupportedNotificationRouteError.d.cts +2 -0
- package/dist/types/MobileUnsupportedNotificationRouteError.d.ts +2 -0
- package/dist/types/MobileUnsupportedNotificationRouteError.js +18 -0
- package/dist/types/MobileUnsupportedNotificationRouteError.js.map +1 -0
- package/dist/types/clientTypes.d.cts +2 -2
- package/dist/types/clientTypes.d.ts +2 -2
- package/dist/types/index.cjs +6 -0
- package/dist/types/index.d.cts +9 -9
- package/dist/types/index.d.ts +9 -9
- package/dist/types/index.js +4 -2
- package/dist/types/mobileErrorCodes.cjs +39 -1
- package/dist/types/mobileErrorCodes.cjs.map +1 -1
- package/dist/types/mobileErrorCodes.d.cts +1 -1
- package/dist/types/mobileErrorCodes.d.ts +1 -1
- package/dist/types/mobileErrorCodes.js +39 -1
- package/dist/types/mobileErrorCodes.js.map +1 -1
- package/dist/types/serverBaseTypes.d.cts +1 -1
- package/dist/types/serverBaseTypes.d.ts +1 -1
- package/dist/types/serverExecuteTypes.d.cts +2 -2
- package/dist/types/serverExecuteTypes.d.ts +2 -2
- package/dist/types/serverModelTypes.cjs +15 -0
- package/dist/types/serverModelTypes.cjs.map +1 -1
- package/dist/types/serverModelTypes.d.cts +2 -2
- package/dist/types/serverModelTypes.d.ts +2 -2
- package/dist/types/serverModelTypes.js +14 -1
- package/dist/types/serverModelTypes.js.map +1 -1
- package/dist/types/serverQueryTypes.d.cts +2 -2
- package/dist/types/serverQueryTypes.d.ts +2 -2
- package/dist/types/serverRequestTypes.d.cts +2 -2
- package/dist/types/serverRequestTypes.d.ts +2 -2
- package/dist/types-C9YE4EIt.d.cts +794 -0
- package/dist/types-C9YE4EIt.d.cts.map +1 -0
- package/dist/types-Cwy1y_9x.d.ts +794 -0
- package/dist/types-Cwy1y_9x.d.ts.map +1 -0
- package/dist/utils/buildMobileFeedImageMultipart.cjs +31 -0
- package/dist/utils/buildMobileFeedImageMultipart.cjs.map +1 -0
- package/dist/utils/buildMobileFeedImageMultipart.d.cts +15 -0
- package/dist/utils/buildMobileFeedImageMultipart.d.cts.map +1 -0
- package/dist/utils/buildMobileFeedImageMultipart.d.ts +15 -0
- package/dist/utils/buildMobileFeedImageMultipart.d.ts.map +1 -0
- package/dist/utils/buildMobileFeedImageMultipart.js +30 -0
- package/dist/utils/buildMobileFeedImageMultipart.js.map +1 -0
- package/dist/utils/feed.cjs +3 -0
- package/dist/utils/feed.cjs.map +1 -1
- package/dist/utils/feed.d.cts +2 -2
- package/dist/utils/feed.d.ts +2 -2
- package/dist/utils/feed.js +3 -1
- package/dist/utils/feed.js.map +1 -1
- package/dist/utils/index.cjs +2 -1
- package/dist/utils/index.d.cts +3 -3
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +2 -2
- package/dist/utils/serverResponseGuards.d.cts +1 -1
- package/dist/utils/serverResponseGuards.d.ts +1 -1
- package/package.json +3 -3
- package/src/MobileClient.ts +789 -7
- package/src/dataMappers.test.ts +848 -0
- package/src/dataMappers.ts +924 -17
- package/src/feedImages.test.ts +309 -0
- package/src/notifications.test.ts +950 -0
- package/src/signing/canonicalize.ts +119 -0
- package/src/signing/eip712MethodByType.ts +15 -0
- package/src/signing/signing.test.ts +362 -0
- package/src/signing/types.ts +108 -13
- package/src/socialFeed.test.ts +38 -2
- package/src/types/MobileUnsupportedFeedItemError.ts +18 -0
- package/src/types/MobileUnsupportedNotificationRouteError.ts +16 -0
- package/src/types/clientTypes.ts +1012 -34
- package/src/types/index.ts +2 -0
- package/src/types/mobileErrorCodes.ts +38 -0
- package/src/types/serverExecuteTypes.ts +112 -3
- package/src/types/serverModelTypes.ts +581 -28
- package/src/types/serverQueryTypes.ts +212 -5
- package/src/types/serverRequestTypes.ts +213 -13
- package/src/utils/buildMobileFeedImageMultipart.test.ts +45 -0
- package/src/utils/buildMobileFeedImageMultipart.ts +36 -0
- package/src/utils/feed.ts +3 -0
- package/dist/MobileClient-aDxiM_Kf.cjs +0 -562
- package/dist/MobileClient-aDxiM_Kf.cjs.map +0 -1
- package/dist/MobileServerFailureError-Bpa_WA9f.d.cts.map +0 -1
- package/dist/MobileServerFailureError-Dd3c6P_Z.d.ts.map +0 -1
- package/dist/canonicalize-BBYGh17w.d.ts.map +0 -1
- package/dist/canonicalize-BF_SiNvO.d.cts.map +0 -1
- package/dist/clientTypes-BWFKo9oE.d.cts +0 -844
- package/dist/clientTypes-BWFKo9oE.d.cts.map +0 -1
- package/dist/clientTypes-DCTiUV0H.d.ts +0 -844
- package/dist/clientTypes-DCTiUV0H.d.ts.map +0 -1
- package/dist/eip712MethodByType-BSx11xG-.d.cts.map +0 -1
- package/dist/eip712MethodByType-DkiAjCLs.d.ts.map +0 -1
- package/dist/feed-DTJlsg8W.d.cts.map +0 -1
- package/dist/feed-DTJlsg8W.d.ts.map +0 -1
- package/dist/mobileErrorCodes-3LtreeZM.d.cts.map +0 -1
- package/dist/mobileErrorCodes-3LtreeZM.d.ts.map +0 -1
- package/dist/payloadHash-BOWGjqdb.d.cts.map +0 -1
- package/dist/payloadHash-Bzf4CtjV.d.ts.map +0 -1
- package/dist/serverBaseTypes-DWf3iGWy.d.ts +0 -25
- package/dist/serverBaseTypes-DWf3iGWy.d.ts.map +0 -1
- package/dist/serverBaseTypes-KREDe2M9.d.cts +0 -25
- package/dist/serverBaseTypes-KREDe2M9.d.cts.map +0 -1
- package/dist/serverExecuteTypes-DVRa6ifu.d.cts +0 -89
- package/dist/serverExecuteTypes-DVRa6ifu.d.cts.map +0 -1
- package/dist/serverExecuteTypes-DlYZCp1f.d.ts +0 -89
- package/dist/serverExecuteTypes-DlYZCp1f.d.ts.map +0 -1
- package/dist/serverModelTypes-DAqEyYtB.d.cts +0 -508
- package/dist/serverModelTypes-DAqEyYtB.d.cts.map +0 -1
- package/dist/serverModelTypes-DAqEyYtB.d.ts +0 -508
- package/dist/serverModelTypes-DAqEyYtB.d.ts.map +0 -1
- package/dist/serverQueryTypes-BFdwq0Z2.d.ts +0 -171
- package/dist/serverQueryTypes-BFdwq0Z2.d.ts.map +0 -1
- package/dist/serverQueryTypes-DNdMpmDr.d.cts +0 -171
- package/dist/serverQueryTypes-DNdMpmDr.d.cts.map +0 -1
- package/dist/serverRequestTypes-BNA7FCY6.d.ts +0 -200
- package/dist/serverRequestTypes-BNA7FCY6.d.ts.map +0 -1
- package/dist/serverRequestTypes-CxDRFKfv.d.cts +0 -200
- package/dist/serverRequestTypes-CxDRFKfv.d.cts.map +0 -1
- package/dist/types-BCr2G5gS.d.cts +0 -84
- package/dist/types-BCr2G5gS.d.cts.map +0 -1
- package/dist/types-C18k-9Vy.d.ts +0 -84
- package/dist/types-C18k-9Vy.d.ts.map +0 -1
package/dist/dataMappers.cjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_types_MobileUnsupportedFeedItemError = require("./types/MobileUnsupportedFeedItemError.cjs");
|
|
3
|
+
const require_types_MobileUnsupportedNotificationRouteError = require("./types/MobileUnsupportedNotificationRouteError.cjs");
|
|
2
4
|
let _nadohq_shared = require("@nadohq/shared");
|
|
3
5
|
//#region src/dataMappers.ts
|
|
4
6
|
/**
|
|
@@ -21,6 +23,172 @@ function mapMobileAvatarUpload(server) {
|
|
|
21
23
|
expiresInSeconds: server.expires_in_seconds
|
|
22
24
|
};
|
|
23
25
|
}
|
|
26
|
+
/** Maps a saved notification registration to the client model without the response envelope.
|
|
27
|
+
* @param server - Registration payload.
|
|
28
|
+
* @returns Saved generation and capabilities.
|
|
29
|
+
*/
|
|
30
|
+
function mapMobileNotificationRegistrationV2(server) {
|
|
31
|
+
return {
|
|
32
|
+
registrationGeneration: server.registration_generation,
|
|
33
|
+
capabilities: {
|
|
34
|
+
payloadVersions: server.capabilities.payload_versions,
|
|
35
|
+
typeIds: server.capabilities.type_ids,
|
|
36
|
+
routes: server.capabilities.routes
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Maps a v2 capability declaration to the registration wire format.
|
|
41
|
+
* @param capabilities - Device-supported features.
|
|
42
|
+
* @returns V2-only registration capabilities.
|
|
43
|
+
*/
|
|
44
|
+
function mapMobileNotificationCapabilitiesToServer(capabilities) {
|
|
45
|
+
return {
|
|
46
|
+
payload_versions: capabilities.payloadVersions,
|
|
47
|
+
type_ids: capabilities.typeIds,
|
|
48
|
+
routes: capabilities.routes
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Maps complete notification settings to the client model.
|
|
52
|
+
* @param server - Saved settings.
|
|
53
|
+
* @returns CamelCase settings.
|
|
54
|
+
*/
|
|
55
|
+
function mapMobileNotificationSettings(server) {
|
|
56
|
+
return {
|
|
57
|
+
myPositions: server.my_positions,
|
|
58
|
+
positionThresholds: server.position_thresholds,
|
|
59
|
+
myOrders: server.my_orders,
|
|
60
|
+
followingTrades: server.following_trades,
|
|
61
|
+
followingPosts: server.following_posts,
|
|
62
|
+
minTradeSizeUsd: server.min_trade_size_usd,
|
|
63
|
+
newFollowers: server.new_followers,
|
|
64
|
+
announcements: server.announcements,
|
|
65
|
+
discovery: server.discovery
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** Maps a complete replacement settings document to wire format.
|
|
69
|
+
* @param settings - Complete client settings.
|
|
70
|
+
* @returns Settings accepted by the service.
|
|
71
|
+
*/
|
|
72
|
+
function mapMobileNotificationSettingsToServer(settings) {
|
|
73
|
+
return {
|
|
74
|
+
my_positions: settings.myPositions,
|
|
75
|
+
position_thresholds: settings.positionThresholds,
|
|
76
|
+
my_orders: settings.myOrders,
|
|
77
|
+
following_trades: settings.followingTrades,
|
|
78
|
+
following_posts: settings.followingPosts,
|
|
79
|
+
min_trade_size_usd: settings.minTradeSizeUsd,
|
|
80
|
+
new_followers: settings.newFollowers,
|
|
81
|
+
announcements: settings.announcements,
|
|
82
|
+
discovery: settings.discovery
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** Maps a revisioned settings response without the response envelope.
|
|
86
|
+
* @param server - Versioned settings payload.
|
|
87
|
+
* @returns Client settings and their revision.
|
|
88
|
+
*/
|
|
89
|
+
function mapMobileNotificationSettingsV2(server) {
|
|
90
|
+
return {
|
|
91
|
+
schemaVersion: server.schema_version,
|
|
92
|
+
revision: server.revision,
|
|
93
|
+
settings: mapMobileNotificationSettings(server.settings)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/** Maps wallet market subscriptions and Identity bells.
|
|
97
|
+
* @param server - Subscription payload.
|
|
98
|
+
* @returns Client subscription state without the response envelope.
|
|
99
|
+
*/
|
|
100
|
+
function mapMobileNotificationSubscriptions(server) {
|
|
101
|
+
return {
|
|
102
|
+
revision: server.revision,
|
|
103
|
+
favoritesImported: server.favorites_imported,
|
|
104
|
+
marketIds: server.market_ids,
|
|
105
|
+
traderBells: server.trader_bells
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** Maps one subscription operation, explicitly nulling unused wire operations.
|
|
109
|
+
* @param update - Exactly one revision-guarded operation.
|
|
110
|
+
* @returns The complete signed inner operation fields.
|
|
111
|
+
*/
|
|
112
|
+
function mapMobileNotificationSubscriptionsUpdateToServer(update) {
|
|
113
|
+
return {
|
|
114
|
+
expected_revision: update.expectedRevision,
|
|
115
|
+
trader_bell: update.traderBell == null ? null : {
|
|
116
|
+
subaccount: (0, _nadohq_shared.subaccountToHex)(update.traderBell.subaccount),
|
|
117
|
+
enabled: update.traderBell.enabled
|
|
118
|
+
},
|
|
119
|
+
market: update.market == null ? null : {
|
|
120
|
+
product_id: update.market.productId,
|
|
121
|
+
subscribed: update.market.subscribed
|
|
122
|
+
},
|
|
123
|
+
import_markets: update.importMarkets ?? null
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/** Maps an allowlisted notification destination.
|
|
127
|
+
* @param server - Named backend destination.
|
|
128
|
+
* @returns Client navigation data, never an arbitrary URL.
|
|
129
|
+
* @throws {MobileUnsupportedNotificationRouteError} If the service returns an unsupported route name.
|
|
130
|
+
*/
|
|
131
|
+
function mapMobileNotificationRoute(server) {
|
|
132
|
+
const name = server.name;
|
|
133
|
+
switch (name) {
|
|
134
|
+
case "market": return {
|
|
135
|
+
name: server.name,
|
|
136
|
+
productId: server.product_id
|
|
137
|
+
};
|
|
138
|
+
case "profile": return {
|
|
139
|
+
name: server.name,
|
|
140
|
+
subaccount: server.subaccount
|
|
141
|
+
};
|
|
142
|
+
case "portfolio": return { name: server.name };
|
|
143
|
+
default: throw new require_types_MobileUnsupportedNotificationRouteError.MobileUnsupportedNotificationRouteError(name);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/** Maps v2 push or inbox navigation data.
|
|
147
|
+
* @param server - Wire-format notification payload.
|
|
148
|
+
* @returns Client notification data.
|
|
149
|
+
* @throws {MobileUnsupportedNotificationRouteError} If the service returns an unsupported route name.
|
|
150
|
+
*/
|
|
151
|
+
function mapMobileNotificationPayloadV2(server) {
|
|
152
|
+
return {
|
|
153
|
+
payloadVersion: server.payload_version,
|
|
154
|
+
notificationId: server.notification_id,
|
|
155
|
+
recipientWallet: server.recipient_wallet,
|
|
156
|
+
typeId: server.type_id,
|
|
157
|
+
templateVersion: server.template_version,
|
|
158
|
+
route: mapMobileNotificationRoute(server.route)
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/** Maps a private notification page without the response envelope.
|
|
162
|
+
* @param server - Newest-first inbox payload.
|
|
163
|
+
* @returns Client items, attribution flags, and the next cursor.
|
|
164
|
+
* @throws {MobileUnsupportedNotificationRouteError} If a notification has an unsupported route name.
|
|
165
|
+
*/
|
|
166
|
+
function mapMobileNotificationInboxV2(server) {
|
|
167
|
+
return {
|
|
168
|
+
notifications: server.notifications.map((item) => ({
|
|
169
|
+
notificationId: item.notification_id,
|
|
170
|
+
typeId: item.type_id,
|
|
171
|
+
data: mapMobileNotificationPayloadV2(item.data),
|
|
172
|
+
createdAt: item.created_at,
|
|
173
|
+
tradeWithin24h: item.trade_within_24h
|
|
174
|
+
})),
|
|
175
|
+
nextCursor: server.next_cursor
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/** Maps a typed analytics interaction, nulling unused wire fields.
|
|
179
|
+
* @param event - Event-specific client data.
|
|
180
|
+
* @returns Complete signed wire event.
|
|
181
|
+
*/
|
|
182
|
+
function mapMobileProductEventToServer(event) {
|
|
183
|
+
return {
|
|
184
|
+
client_event_id: event.clientEventId,
|
|
185
|
+
event_name: event.eventName,
|
|
186
|
+
notification_id: event.notificationId ?? null,
|
|
187
|
+
occurred_at: event.occurredAt,
|
|
188
|
+
product_id: event.productId ?? null,
|
|
189
|
+
query: event.query ?? null
|
|
190
|
+
};
|
|
191
|
+
}
|
|
24
192
|
/**
|
|
25
193
|
* Maps a client-side avatar selection to the signed wire payload; null clears the saved avatar.
|
|
26
194
|
*/
|
|
@@ -311,7 +479,8 @@ function mapMobileSocialFeedPositionPatch(server) {
|
|
|
311
479
|
marginMode: server.margin_mode,
|
|
312
480
|
leverage: server.leverage,
|
|
313
481
|
leverageAtMs: server.leverage_at_ms,
|
|
314
|
-
pnl: mapMobileSocialFeedPnl(server.pnl)
|
|
482
|
+
pnl: mapMobileSocialFeedPnl(server.pnl),
|
|
483
|
+
...server.current_position === void 0 ? {} : { currentPosition: mapMobileSocialFeedHistoryMetrics(server.current_position) }
|
|
315
484
|
};
|
|
316
485
|
}
|
|
317
486
|
/**
|
|
@@ -341,6 +510,26 @@ function mapMobileSocialFeedInteraction(server) {
|
|
|
341
510
|
};
|
|
342
511
|
}
|
|
343
512
|
/**
|
|
513
|
+
* Maps uploaded image metadata; bytes remain behind a protected GET.
|
|
514
|
+
* @param server - The service response.
|
|
515
|
+
* @returns The mapped feed image.
|
|
516
|
+
*/
|
|
517
|
+
function mapMobileSocialFeedImage(server) {
|
|
518
|
+
return {
|
|
519
|
+
imageId: server.image_id,
|
|
520
|
+
url: server.url,
|
|
521
|
+
width: server.width,
|
|
522
|
+
height: server.height,
|
|
523
|
+
contentType: server.content_type,
|
|
524
|
+
byteSize: server.byte_size,
|
|
525
|
+
thumbnail: {
|
|
526
|
+
url: server.thumbnail.url,
|
|
527
|
+
width: server.thumbnail.width,
|
|
528
|
+
height: server.thumbnail.height
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
344
533
|
* Maps common item metadata and server capabilities.
|
|
345
534
|
* @param server - The service response.
|
|
346
535
|
* @returns The mapped social feed item base.
|
|
@@ -349,7 +538,7 @@ function mapMobileSocialFeedItemBase(server) {
|
|
|
349
538
|
return {
|
|
350
539
|
id: server.id,
|
|
351
540
|
hasAnalysis: server.has_analysis,
|
|
352
|
-
drawing: server.drawing,
|
|
541
|
+
drawing: server.drawing === null ? null : mapMobileSocialFeedDrawing(server.drawing),
|
|
353
542
|
author: mapMobileSocialFeedAuthor(server.author),
|
|
354
543
|
createdAtMs: server.created_at_ms,
|
|
355
544
|
displayAtMs: server.display_at_ms,
|
|
@@ -363,27 +552,38 @@ function mapMobileSocialFeedItemBase(server) {
|
|
|
363
552
|
};
|
|
364
553
|
}
|
|
365
554
|
/**
|
|
366
|
-
* Maps
|
|
555
|
+
* Maps the content, position, interaction, and comment preview shared by posts and trade cards.
|
|
367
556
|
* @param server - The service response.
|
|
368
|
-
* @returns The mapped
|
|
557
|
+
* @returns The mapped shared content fields.
|
|
369
558
|
*/
|
|
370
|
-
function
|
|
559
|
+
function mapMobileSocialFeedContentBase(server) {
|
|
371
560
|
return {
|
|
372
561
|
...mapMobileSocialFeedItemBase(server),
|
|
373
|
-
|
|
374
|
-
action: server.action,
|
|
562
|
+
images: server.images.map(mapMobileSocialFeedImage),
|
|
375
563
|
text: server.text,
|
|
376
564
|
mentions: server.mentions,
|
|
377
565
|
position: mapMobileSocialFeedPositionCard(server.position),
|
|
378
566
|
interaction: mapMobileSocialFeedInteraction(server.interaction),
|
|
379
567
|
commentPreview: {
|
|
380
|
-
items: server.comment_preview.items,
|
|
568
|
+
items: server.comment_preview.items.map(mapMobileSocialFeedReply),
|
|
381
569
|
totalCount: server.comment_preview.total_count,
|
|
382
570
|
nextCursor: server.comment_preview.next_cursor
|
|
383
571
|
}
|
|
384
572
|
};
|
|
385
573
|
}
|
|
386
574
|
/**
|
|
575
|
+
* Maps a trade card, authored content, and position and interaction metadata.
|
|
576
|
+
* @param server - The service response.
|
|
577
|
+
* @returns The mapped social trade card.
|
|
578
|
+
*/
|
|
579
|
+
function mapMobileSocialFeedTradeCard(server) {
|
|
580
|
+
return {
|
|
581
|
+
...mapMobileSocialFeedContentBase(server),
|
|
582
|
+
kind: server.kind,
|
|
583
|
+
action: server.action
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
387
587
|
* Maps historical trade facts with decimal execution prices and x18 quantities.
|
|
388
588
|
* @param server - The service response.
|
|
389
589
|
* @returns The mapped social trade row base.
|
|
@@ -428,12 +628,20 @@ function mapMobileSocialFeedTradeRow(server) {
|
|
|
428
628
|
* Maps the item variant without mixing card and row fields.
|
|
429
629
|
* @param server - The service response.
|
|
430
630
|
* @returns The mapped social feed item.
|
|
631
|
+
* @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
|
|
431
632
|
*/
|
|
432
633
|
function mapMobileSocialFeedItem(server) {
|
|
433
|
-
|
|
634
|
+
const kind = server.kind;
|
|
635
|
+
switch (kind) {
|
|
636
|
+
case "trade_card": return mapMobileSocialFeedTradeCard(server);
|
|
637
|
+
case "trade_row": return mapMobileSocialFeedTradeRow(server);
|
|
638
|
+
case "post": return mapMobileSocialFeedPost(server);
|
|
639
|
+
case "reply": return mapMobileSocialFeedReply(server);
|
|
640
|
+
default: throw new require_types_MobileUnsupportedFeedItemError.MobileUnsupportedFeedItemError(kind);
|
|
641
|
+
}
|
|
434
642
|
}
|
|
435
643
|
/**
|
|
436
|
-
* Maps a
|
|
644
|
+
* Maps a reading session and its current idle expiration, preserving opaque credentials and cursors.
|
|
437
645
|
* @param server - The service response.
|
|
438
646
|
* @returns The mapped feed read session.
|
|
439
647
|
*/
|
|
@@ -442,10 +650,7 @@ function mapMobileSocialFeedReadSession(server) {
|
|
|
442
650
|
sessionId: server.session_id,
|
|
443
651
|
mode: server.mode,
|
|
444
652
|
expiresAtMs: server.expires_at_ms,
|
|
445
|
-
viewTracking: {
|
|
446
|
-
minVisibleRatio: server.view_tracking.min_visible_ratio,
|
|
447
|
-
minDurationMs: server.view_tracking.min_duration_ms
|
|
448
|
-
},
|
|
653
|
+
viewTracking: { mode: server.view_tracking.mode },
|
|
449
654
|
updateCursor: server.update_cursor,
|
|
450
655
|
viewerToken: server.viewer_token
|
|
451
656
|
};
|
|
@@ -454,6 +659,7 @@ function mapMobileSocialFeedReadSession(server) {
|
|
|
454
659
|
* Maps a fixed feed page without changing item order or pagination.
|
|
455
660
|
* @param server - The service response.
|
|
456
661
|
* @returns The mapped social feed page.
|
|
662
|
+
* @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
|
|
457
663
|
*/
|
|
458
664
|
function mapMobileSocialFeedPage(server) {
|
|
459
665
|
return {
|
|
@@ -467,6 +673,7 @@ function mapMobileSocialFeedPage(server) {
|
|
|
467
673
|
* Maps a main feed page and its ranking version.
|
|
468
674
|
* @param server - The service response.
|
|
469
675
|
* @returns The mapped ranked feed page.
|
|
676
|
+
* @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
|
|
470
677
|
*/
|
|
471
678
|
function mapMobileSocialFeedRankedPage(server) {
|
|
472
679
|
return {
|
|
@@ -478,6 +685,7 @@ function mapMobileSocialFeedRankedPage(server) {
|
|
|
478
685
|
* Maps qualified trader items and their shared eligibility snapshot.
|
|
479
686
|
* @param server - The service response.
|
|
480
687
|
* @returns The mapped top traders feed page.
|
|
688
|
+
* @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
|
|
481
689
|
*/
|
|
482
690
|
function mapMobileSocialFeedTopTradersPage(server) {
|
|
483
691
|
return {
|
|
@@ -498,6 +706,7 @@ function mapMobileSocialFeedTopTradersPage(server) {
|
|
|
498
706
|
* Maps item details and the authorized reading session.
|
|
499
707
|
* @param server - The service response.
|
|
500
708
|
* @returns The mapped social feed item response.
|
|
709
|
+
* @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
|
|
501
710
|
*/
|
|
502
711
|
function mapMobileSocialFeedItemResponse(server) {
|
|
503
712
|
return {
|
|
@@ -514,6 +723,8 @@ function mapMobileSocialFeedItemPatch(server) {
|
|
|
514
723
|
return {
|
|
515
724
|
itemId: server.item_id,
|
|
516
725
|
version: server.version,
|
|
726
|
+
...server.attached_position === void 0 ? {} : { attachedPosition: server.attached_position === null ? null : mapMobileSocialFeedPositionCard(server.attached_position) },
|
|
727
|
+
...server.attachment_status === void 0 ? {} : { attachmentStatus: server.attachment_status },
|
|
517
728
|
author: mapMobileSocialFeedAuthor(server.author),
|
|
518
729
|
displayAtMs: server.display_at_ms,
|
|
519
730
|
...server.interaction === void 0 ? {} : { interaction: mapMobileSocialFeedInteraction(server.interaction) },
|
|
@@ -571,6 +782,431 @@ function mapMobileSocialFeedReadParamsToServer(params) {
|
|
|
571
782
|
viewer_token: params.viewerToken
|
|
572
783
|
};
|
|
573
784
|
}
|
|
785
|
+
/**
|
|
786
|
+
* Maps a mention for signing without changing the text or offsets.
|
|
787
|
+
* @param params - Caller-provided mention and original text offsets.
|
|
788
|
+
* @returns The wire-format mention, preserving the original label and code-point offsets.
|
|
789
|
+
* @throws {Error} If the owner is not a 20-byte address or the subaccount name cannot be encoded in 12 bytes.
|
|
790
|
+
*/
|
|
791
|
+
function mapMobileSocialFeedMentionToServer(params) {
|
|
792
|
+
return {
|
|
793
|
+
subaccount: (0, _nadohq_shared.subaccountToHex)(params.subaccount),
|
|
794
|
+
start: params.start,
|
|
795
|
+
end: params.end,
|
|
796
|
+
label: params.label
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Preserves parsed drawing data, including false and zero.
|
|
801
|
+
* @param server - Service payload with its original wire fields.
|
|
802
|
+
* @returns The original parsed drawing data and its creation/update timestamps in milliseconds.
|
|
803
|
+
*/
|
|
804
|
+
function mapMobileSocialFeedDrawing(server) {
|
|
805
|
+
return {
|
|
806
|
+
data: server.data,
|
|
807
|
+
createdAtMs: server.created_at_ms,
|
|
808
|
+
updatedAtMs: server.updated_at_ms
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Maps a nonrecursive root preview, retaining nullable position visibility.
|
|
813
|
+
* @param server - Service payload with its original wire fields.
|
|
814
|
+
* @returns A nonrecursive preview with a nullable position and notional retained as an x18 BigNumber.
|
|
815
|
+
*/
|
|
816
|
+
function mapMobileSocialFeedCompactCard(server) {
|
|
817
|
+
return {
|
|
818
|
+
id: server.id,
|
|
819
|
+
author: mapMobileSocialFeedAuthor(server.author),
|
|
820
|
+
textExcerpt: server.text_excerpt,
|
|
821
|
+
position: server.position === null ? null : {
|
|
822
|
+
positionId: server.position.position_id,
|
|
823
|
+
market: mapMobileSocialFeedMarket(server.position.market),
|
|
824
|
+
direction: server.position.direction,
|
|
825
|
+
state: server.position.state,
|
|
826
|
+
notional: (0, _nadohq_shared.toBigNumber)(server.position.notional_x18)
|
|
827
|
+
},
|
|
828
|
+
hasAnalysis: server.has_analysis
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Maps an authored post and its readable comments and drawing.
|
|
833
|
+
* @param server - Service payload with its original wire fields.
|
|
834
|
+
* @returns A post with its unchanged text and mentions, mapped position, drawing, interactions, and reply preview.
|
|
835
|
+
*/
|
|
836
|
+
function mapMobileSocialFeedPost(server) {
|
|
837
|
+
return {
|
|
838
|
+
...mapMobileSocialFeedContentBase(server),
|
|
839
|
+
kind: server.kind
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Maps reply visibility without treating an unavailable attachment as an absent one.
|
|
844
|
+
* @param server - Service payload with its original wire fields.
|
|
845
|
+
* @returns A reply preserving omitted reply targets, nullable attachments, and the separate attachment visibility status.
|
|
846
|
+
*/
|
|
847
|
+
function mapMobileSocialFeedReply(server) {
|
|
848
|
+
return {
|
|
849
|
+
...mapMobileSocialFeedItemBase(server),
|
|
850
|
+
kind: server.kind,
|
|
851
|
+
images: server.images.map(mapMobileSocialFeedImage),
|
|
852
|
+
text: server.text,
|
|
853
|
+
mentions: server.mentions,
|
|
854
|
+
rootItemId: server.root_item_id,
|
|
855
|
+
...server.reply_to_item_id === void 0 ? {} : { replyToItemId: server.reply_to_item_id },
|
|
856
|
+
replyToAuthor: server.reply_to_author === null ? null : mapMobileSocialFeedAuthor(server.reply_to_author),
|
|
857
|
+
attachedPosition: server.attached_position === null ? null : mapMobileSocialFeedPositionCard(server.attached_position),
|
|
858
|
+
attachmentStatus: server.attachment_status,
|
|
859
|
+
original: mapMobileSocialFeedCompactCard(server.original),
|
|
860
|
+
interaction: mapMobileSocialFeedInteraction(server.interaction)
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Maps current eligibility hints without implying caller ownership.
|
|
865
|
+
* @param server - Service payload with its original wire fields.
|
|
866
|
+
* @returns A position with current publication, attachment, and drawing eligibility hints and an unavailable reason.
|
|
867
|
+
*/
|
|
868
|
+
function mapMobileSocialFeedPublishablePosition(server) {
|
|
869
|
+
return {
|
|
870
|
+
position: mapMobileSocialFeedPositionCard(server.position),
|
|
871
|
+
canPublish: server.can_publish,
|
|
872
|
+
canAttachToComment: server.can_attach_to_comment,
|
|
873
|
+
canDrawAnalysis: server.can_draw_analysis,
|
|
874
|
+
unavailableReason: server.unavailable_reason
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Maps all order action identifiers and eligibility hints.
|
|
879
|
+
* @param server - Service payload with its original wire fields.
|
|
880
|
+
* @returns Trusted action and position identifiers, action kind, publication eligibility, and an unavailable reason.
|
|
881
|
+
*/
|
|
882
|
+
function mapMobileSocialFeedActionCandidate(server) {
|
|
883
|
+
return {
|
|
884
|
+
actionId: server.action_id,
|
|
885
|
+
positionId: server.position_id,
|
|
886
|
+
action: server.action,
|
|
887
|
+
canPublish: server.can_publish,
|
|
888
|
+
unavailableReason: server.unavailable_reason
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Maps history risk prices to decimals while retaining funding amounts in x18 units.
|
|
893
|
+
* @param server - Service payload with its original wire fields.
|
|
894
|
+
* @returns Nullable decimal liquidation price and x18 funding PnL, with their independent quality and observation metadata.
|
|
895
|
+
*/
|
|
896
|
+
function mapMobileSocialFeedHistoryMetrics(server) {
|
|
897
|
+
return {
|
|
898
|
+
estimatedLiquidationPrice: (0, _nadohq_shared.removeDecimals)(server.estimated_liquidation_price_x18),
|
|
899
|
+
liquidationPriceQuality: server.liquidation_price_quality,
|
|
900
|
+
liquidationPriceAsOfMs: server.liquidation_price_as_of_ms,
|
|
901
|
+
fundingPnl: server.funding_pnl_x18 === null ? null : (0, _nadohq_shared.toBigNumber)(server.funding_pnl_x18),
|
|
902
|
+
fundingQuality: server.funding_quality,
|
|
903
|
+
fundingAsOfMs: server.funding_as_of_ms
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Maps action prices independently; all amounts and quantities retain x18 units.
|
|
908
|
+
* @param server - Service payload with its original wire fields.
|
|
909
|
+
* @returns An action with decimal prices, x18 quantities/amounts, and independently nullable financial facts.
|
|
910
|
+
*/
|
|
911
|
+
function mapMobileSocialFeedPositionAction(server) {
|
|
912
|
+
return {
|
|
913
|
+
id: server.id,
|
|
914
|
+
positionId: server.position_id,
|
|
915
|
+
action: server.action,
|
|
916
|
+
direction: server.direction,
|
|
917
|
+
marginMode: server.margin_mode,
|
|
918
|
+
quantityBefore: (0, _nadohq_shared.toBigNumber)(server.quantity_before_x18),
|
|
919
|
+
quantityAfter: (0, _nadohq_shared.toBigNumber)(server.quantity_after_x18),
|
|
920
|
+
executedQuantity: (0, _nadohq_shared.toBigNumber)(server.executed_quantity_x18),
|
|
921
|
+
executedNotional: server.executed_notional_x18 === null ? null : (0, _nadohq_shared.toBigNumber)(server.executed_notional_x18),
|
|
922
|
+
averagePrice: (0, _nadohq_shared.removeDecimals)(server.average_price_x18),
|
|
923
|
+
entryPriceBefore: (0, _nadohq_shared.removeDecimals)(server.entry_price_before_x18),
|
|
924
|
+
liquidationOraclePrice: (0, _nadohq_shared.removeDecimals)(server.liquidation_oracle_price_x18),
|
|
925
|
+
liquidationNotional: server.liquidation_notional_x18 === null ? null : (0, _nadohq_shared.toBigNumber)(server.liquidation_notional_x18),
|
|
926
|
+
realizedPnlDelta: server.realized_pnl_delta_x18 === null ? null : (0, _nadohq_shared.toBigNumber)(server.realized_pnl_delta_x18),
|
|
927
|
+
leverage: server.leverage,
|
|
928
|
+
leverageAtMs: server.leverage_at_ms,
|
|
929
|
+
firstEventAtMs: server.first_event_at_ms,
|
|
930
|
+
lastEventAtMs: server.last_event_at_ms,
|
|
931
|
+
version: server.version
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Maps a trusted target without treating the viewing account as authenticated.
|
|
936
|
+
* @param server - Service payload with its original wire fields.
|
|
937
|
+
* @returns A trading target retaining distinct identity/trading subaccounts, margin mode, and observation time.
|
|
938
|
+
*/
|
|
939
|
+
function mapMobileSocialFeedTradingTarget(server) {
|
|
940
|
+
return {
|
|
941
|
+
positionId: server.position_id,
|
|
942
|
+
identitySubaccount: server.identity_subaccount,
|
|
943
|
+
tradingSubaccount: server.trading_subaccount,
|
|
944
|
+
productId: server.product_id,
|
|
945
|
+
marginMode: server.margin_mode,
|
|
946
|
+
isoSubaccountName: server.iso_subaccount_name,
|
|
947
|
+
direction: server.direction,
|
|
948
|
+
stateAsOfMs: server.state_as_of_ms
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Maps viewing-account trading hints.
|
|
953
|
+
* @param server - Service payload with its original wire fields.
|
|
954
|
+
* @returns Trading hints with ordered target candidates, nullable viewer position, and the current reduction hint.
|
|
955
|
+
*/
|
|
956
|
+
function mapMobileSocialFeedTradingContext(server) {
|
|
957
|
+
return {
|
|
958
|
+
productId: server.product_id,
|
|
959
|
+
suggestedDirection: server.suggested_direction,
|
|
960
|
+
resolution: server.resolution,
|
|
961
|
+
candidates: server.candidates.map(mapMobileSocialFeedTradingTarget),
|
|
962
|
+
viewerPositionId: server.viewer_position_id,
|
|
963
|
+
canReduce: server.can_reduce
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Converts OHLC prices to decimals but preserves base-asset volume in x18.
|
|
968
|
+
* @param server - Service payload with its original wire fields.
|
|
969
|
+
* @returns A candle with decimal OHLC BigNumbers, base-asset volume retained in x18, and its timestamp in milliseconds.
|
|
970
|
+
*/
|
|
971
|
+
function mapMobileSocialFeedCandle(server) {
|
|
972
|
+
return {
|
|
973
|
+
timestampMs: server.timestamp_ms,
|
|
974
|
+
open: (0, _nadohq_shared.removeDecimals)(server.open_x18),
|
|
975
|
+
high: (0, _nadohq_shared.removeDecimals)(server.high_x18),
|
|
976
|
+
low: (0, _nadohq_shared.removeDecimals)(server.low_x18),
|
|
977
|
+
close: (0, _nadohq_shared.removeDecimals)(server.close_x18),
|
|
978
|
+
volume: (0, _nadohq_shared.toBigNumber)(server.volume_x18)
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* Maps markers without replacing unknown Oracle prices with execution prices.
|
|
983
|
+
* @param server - Service payload with its original wire fields.
|
|
984
|
+
* @returns An action marker with its original price basis and a nullable decimal price, without substituting another source.
|
|
985
|
+
*/
|
|
986
|
+
function mapMobileSocialFeedActionMarker(server) {
|
|
987
|
+
return {
|
|
988
|
+
actionId: server.action_id,
|
|
989
|
+
timestampMs: server.timestamp_ms,
|
|
990
|
+
price: (0, _nadohq_shared.removeDecimals)(server.price_x18),
|
|
991
|
+
action: server.action,
|
|
992
|
+
direction: server.direction,
|
|
993
|
+
priceBasis: server.price_basis
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Maps selected-account open positions.
|
|
998
|
+
* @param server - Service payload with its original wire fields.
|
|
999
|
+
* @returns Mapped position candidates with the original nullable cursor and observation time.
|
|
1000
|
+
*/
|
|
1001
|
+
function mapMobileSocialFeedPositionsPage(server) {
|
|
1002
|
+
return {
|
|
1003
|
+
positions: server.positions.map(mapMobileSocialFeedPublishablePosition),
|
|
1004
|
+
nextCursor: server.next_cursor,
|
|
1005
|
+
asOfMs: server.as_of_ms
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Maps normal empty and ambiguous command results.
|
|
1010
|
+
* @param server - Service payload with its original wire fields.
|
|
1011
|
+
* @returns The command resolution, nullable market, position candidates, and original reason for an empty result.
|
|
1012
|
+
*/
|
|
1013
|
+
function mapMobileSocialFeedPositionResolutionResult(server) {
|
|
1014
|
+
return {
|
|
1015
|
+
resolution: server.resolution,
|
|
1016
|
+
product: server.product === null ? null : mapMobileSocialFeedMarket(server.product),
|
|
1017
|
+
candidates: server.candidates.map(mapMobileSocialFeedPublishablePosition),
|
|
1018
|
+
reason: server.reason
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Preserves pending order projection without inventing action candidates.
|
|
1023
|
+
* @param server - Service payload with its original wire fields.
|
|
1024
|
+
* @returns The original order digest, ready/pending state, mapped actions, and observation time.
|
|
1025
|
+
*/
|
|
1026
|
+
function mapMobileSocialFeedActionResolutionResult(server) {
|
|
1027
|
+
return {
|
|
1028
|
+
orderDigest: server.order_digest,
|
|
1029
|
+
resolution: server.resolution,
|
|
1030
|
+
actions: server.actions.map(mapMobileSocialFeedActionCandidate),
|
|
1031
|
+
asOfMs: server.as_of_ms
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Distinguishes no drawing from falsy drawing data.
|
|
1036
|
+
* @param server - Service payload with its original wire fields.
|
|
1037
|
+
* @returns The parent item ID/version and a nullable drawing, retaining false or zero drawing data.
|
|
1038
|
+
*/
|
|
1039
|
+
function mapMobileSocialFeedDrawingResult(server) {
|
|
1040
|
+
return {
|
|
1041
|
+
itemId: server.item_id,
|
|
1042
|
+
itemVersion: server.item_version,
|
|
1043
|
+
drawing: server.drawing === null ? null : mapMobileSocialFeedDrawing(server.drawing)
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Maps a saved drawing after creation or replacement.
|
|
1048
|
+
* @param server - Successful drawing mutation response.
|
|
1049
|
+
* @returns The parent item ID/version and non-null saved drawing.
|
|
1050
|
+
*/
|
|
1051
|
+
function mapMobileSocialFeedDrawingMutationResult(server) {
|
|
1052
|
+
return {
|
|
1053
|
+
itemId: server.item_id,
|
|
1054
|
+
itemVersion: server.item_version,
|
|
1055
|
+
drawing: mapMobileSocialFeedDrawing(server.drawing)
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Maps bidirectional comments and the actual returned session.
|
|
1060
|
+
* @param server - Service payload with its original wire fields.
|
|
1061
|
+
* @returns Mapped replies, total count, bidirectional cursors, nullable anchor, and the actual reading session.
|
|
1062
|
+
*/
|
|
1063
|
+
function mapMobileSocialFeedCommentsPage(server) {
|
|
1064
|
+
return {
|
|
1065
|
+
comments: server.comments.map(mapMobileSocialFeedReply),
|
|
1066
|
+
totalCount: server.total_count,
|
|
1067
|
+
nextCursor: server.next_cursor,
|
|
1068
|
+
previousCursor: server.previous_cursor,
|
|
1069
|
+
anchorReplyId: server.anchor_reply_id,
|
|
1070
|
+
readSession: mapMobileSocialFeedReadSession(server.read_session)
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Maps atomic reply publication without inventing a reading session.
|
|
1075
|
+
* @param server - Service payload with its original wire fields.
|
|
1076
|
+
* @returns The created reply and authoritative root comment count, without a fabricated reading session.
|
|
1077
|
+
*/
|
|
1078
|
+
function mapMobileSocialFeedCommentResult(server) {
|
|
1079
|
+
return {
|
|
1080
|
+
comment: mapMobileSocialFeedReply(server.comment),
|
|
1081
|
+
rootCommentCount: server.root_comment_count
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Maps authoritative like state and count.
|
|
1086
|
+
* @param server - Service payload with its original wire fields.
|
|
1087
|
+
* @returns The applied like state, authoritative count, and item ID/version after the mutation.
|
|
1088
|
+
*/
|
|
1089
|
+
function mapMobileSocialFeedLikeResult(server) {
|
|
1090
|
+
return {
|
|
1091
|
+
itemId: server.item_id,
|
|
1092
|
+
isLiked: server.is_liked,
|
|
1093
|
+
likeCount: server.like_count,
|
|
1094
|
+
version: server.version
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Maps exposure deduplication results without adding timestamps.
|
|
1099
|
+
* @param server - Service payload with its original wire fields.
|
|
1100
|
+
* @returns Newly accepted and duplicate item ID lists without inventing an observation timestamp.
|
|
1101
|
+
*/
|
|
1102
|
+
function mapMobileSocialFeedViewsResult(server) {
|
|
1103
|
+
return {
|
|
1104
|
+
acceptedItemIds: server.accepted_item_ids,
|
|
1105
|
+
duplicateItemIds: server.duplicate_item_ids
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Maps a published history take without treating unknown kinds as posts.
|
|
1110
|
+
* @param server - The published service item.
|
|
1111
|
+
* @returns The mapped post or trade card.
|
|
1112
|
+
* @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported take kind.
|
|
1113
|
+
*/
|
|
1114
|
+
function mapMobileSocialFeedHistoryTake(server) {
|
|
1115
|
+
const kind = server.kind;
|
|
1116
|
+
switch (kind) {
|
|
1117
|
+
case "trade_card": return mapMobileSocialFeedTradeCard(server);
|
|
1118
|
+
case "post": return mapMobileSocialFeedPost(server);
|
|
1119
|
+
default: throw new require_types_MobileUnsupportedFeedItemError.MobileUnsupportedFeedItemError(kind);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Maps a historical action or published take while preserving its discriminant.
|
|
1124
|
+
* @param server - The service timeline entry.
|
|
1125
|
+
* @returns The mapped action or take entry.
|
|
1126
|
+
* @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported entry or take kind.
|
|
1127
|
+
*/
|
|
1128
|
+
function mapMobileSocialFeedTimelineEntry(server) {
|
|
1129
|
+
const kind = server.kind;
|
|
1130
|
+
switch (kind) {
|
|
1131
|
+
case "action": return {
|
|
1132
|
+
kind,
|
|
1133
|
+
action: mapMobileSocialFeedPositionAction(server.action),
|
|
1134
|
+
relatedItemId: server.related_item_id,
|
|
1135
|
+
relatedTake: server.related_take === null ? null : mapMobileSocialFeedTradeCard(server.related_take)
|
|
1136
|
+
};
|
|
1137
|
+
case "take": return {
|
|
1138
|
+
kind,
|
|
1139
|
+
item: mapMobileSocialFeedHistoryTake(server.item)
|
|
1140
|
+
};
|
|
1141
|
+
default: throw new require_types_MobileUnsupportedFeedItemError.MobileUnsupportedFeedItemError(kind);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Maps full history, preserving action/take order, association, and null facts.
|
|
1146
|
+
* @param server - Service payload with its original wire fields.
|
|
1147
|
+
* @returns Position metrics, ordered action/take timeline, summary, cursor, quality, reading session, and trading hints.
|
|
1148
|
+
* @throws {MobileUnsupportedFeedItemError} If a timeline entry or take has an unsupported kind.
|
|
1149
|
+
*/
|
|
1150
|
+
function mapMobileSocialFeedPositionHistory(server) {
|
|
1151
|
+
return {
|
|
1152
|
+
position: {
|
|
1153
|
+
...mapMobileSocialFeedPositionCard(server.position),
|
|
1154
|
+
...mapMobileSocialFeedHistoryMetrics(server.position)
|
|
1155
|
+
},
|
|
1156
|
+
summary: {
|
|
1157
|
+
actionCount: server.summary.action_count,
|
|
1158
|
+
takeCount: server.summary.take_count
|
|
1159
|
+
},
|
|
1160
|
+
timeline: server.timeline.map(mapMobileSocialFeedTimelineEntry),
|
|
1161
|
+
nextCursor: server.next_cursor,
|
|
1162
|
+
historyQuality: server.history_quality,
|
|
1163
|
+
readSession: mapMobileSocialFeedReadSession(server.read_session),
|
|
1164
|
+
tradingContext: mapMobileSocialFeedTradingContext(server.trading_context)
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Maps candles and independent price sources, preserving explicit nulls.
|
|
1169
|
+
* @param server - Service payload with its original wire fields.
|
|
1170
|
+
* @returns Decimal-price candles and markers with x18 volume, a nullable liquidation line, and paging/quality metadata.
|
|
1171
|
+
*/
|
|
1172
|
+
function mapMobileSocialFeedPositionChart(server) {
|
|
1173
|
+
return {
|
|
1174
|
+
candles: server.candles.map(mapMobileSocialFeedCandle),
|
|
1175
|
+
actionMarkers: server.action_markers.map(mapMobileSocialFeedActionMarker),
|
|
1176
|
+
estimatedLiquidationLine: server.estimated_liquidation_line === null ? null : {
|
|
1177
|
+
price: (0, _nadohq_shared.removeDecimals)(server.estimated_liquidation_line.price_x18),
|
|
1178
|
+
asOfMs: server.estimated_liquidation_line.as_of_ms
|
|
1179
|
+
},
|
|
1180
|
+
nextBeforeMs: server.next_before_ms,
|
|
1181
|
+
asOfMs: server.as_of_ms,
|
|
1182
|
+
dataQuality: server.data_quality
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Maps watcher observations; account previews are self-reported, not authenticated.
|
|
1187
|
+
* @param server - Service payload with its original wire fields.
|
|
1188
|
+
* @returns The visitor count, self-reported public account previews, and observation time.
|
|
1189
|
+
*/
|
|
1190
|
+
function mapMobileSocialFeedWatchers(server) {
|
|
1191
|
+
return {
|
|
1192
|
+
watcherCount: server.watcher_count,
|
|
1193
|
+
watcherPreview: server.watcher_preview.map(mapMobileSocialFeedAuthor),
|
|
1194
|
+
asOfMs: server.as_of_ms
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Maps a page lease without inventing an observation timestamp.
|
|
1199
|
+
* @param server - Service payload with its original wire fields.
|
|
1200
|
+
* @returns Visitor count and public previews with heartbeat/lease durations in seconds, without an observation timestamp.
|
|
1201
|
+
*/
|
|
1202
|
+
function mapMobileSocialFeedPresence(server) {
|
|
1203
|
+
return {
|
|
1204
|
+
watcherCount: server.watcher_count,
|
|
1205
|
+
watcherPreview: server.watcher_preview.map(mapMobileSocialFeedAuthor),
|
|
1206
|
+
heartbeatIntervalSeconds: server.heartbeat_interval_seconds,
|
|
1207
|
+
expiresInSeconds: server.expires_in_seconds
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
574
1210
|
//#endregion
|
|
575
1211
|
exports.mapMobileAvatarPreset = mapMobileAvatarPreset;
|
|
576
1212
|
exports.mapMobileAvatarSelectionToServer = mapMobileAvatarSelectionToServer;
|
|
@@ -580,33 +1216,74 @@ exports.mapMobileFollowBatchResult = mapMobileFollowBatchResult;
|
|
|
580
1216
|
exports.mapMobileFollowListPage = mapMobileFollowListPage;
|
|
581
1217
|
exports.mapMobileFollowListParamsToServer = mapMobileFollowListParamsToServer;
|
|
582
1218
|
exports.mapMobileFollowMutationResult = mapMobileFollowMutationResult;
|
|
1219
|
+
exports.mapMobileNotificationCapabilitiesToServer = mapMobileNotificationCapabilitiesToServer;
|
|
1220
|
+
exports.mapMobileNotificationInboxV2 = mapMobileNotificationInboxV2;
|
|
1221
|
+
exports.mapMobileNotificationPayloadV2 = mapMobileNotificationPayloadV2;
|
|
583
1222
|
exports.mapMobileNotificationPreferences = mapMobileNotificationPreferences;
|
|
584
1223
|
exports.mapMobileNotificationPreferencesToServer = mapMobileNotificationPreferencesToServer;
|
|
1224
|
+
exports.mapMobileNotificationRegistrationV2 = mapMobileNotificationRegistrationV2;
|
|
1225
|
+
exports.mapMobileNotificationRoute = mapMobileNotificationRoute;
|
|
1226
|
+
exports.mapMobileNotificationSettings = mapMobileNotificationSettings;
|
|
1227
|
+
exports.mapMobileNotificationSettingsToServer = mapMobileNotificationSettingsToServer;
|
|
1228
|
+
exports.mapMobileNotificationSettingsV2 = mapMobileNotificationSettingsV2;
|
|
1229
|
+
exports.mapMobileNotificationSubscriptions = mapMobileNotificationSubscriptions;
|
|
1230
|
+
exports.mapMobileNotificationSubscriptionsUpdateToServer = mapMobileNotificationSubscriptionsUpdateToServer;
|
|
1231
|
+
exports.mapMobileProductEventToServer = mapMobileProductEventToServer;
|
|
585
1232
|
exports.mapMobileProfileSearchPage = mapMobileProfileSearchPage;
|
|
586
1233
|
exports.mapMobileProfileSearchParamsToServer = mapMobileProfileSearchParamsToServer;
|
|
587
1234
|
exports.mapMobileProfilesIncludeToServer = mapMobileProfilesIncludeToServer;
|
|
588
1235
|
exports.mapMobilePublicProfile = mapMobilePublicProfile;
|
|
589
1236
|
exports.mapMobileRegisteredWallet = mapMobileRegisteredWallet;
|
|
1237
|
+
exports.mapMobileSocialFeedActionCandidate = mapMobileSocialFeedActionCandidate;
|
|
1238
|
+
exports.mapMobileSocialFeedActionMarker = mapMobileSocialFeedActionMarker;
|
|
1239
|
+
exports.mapMobileSocialFeedActionResolutionResult = mapMobileSocialFeedActionResolutionResult;
|
|
590
1240
|
exports.mapMobileSocialFeedAuthor = mapMobileSocialFeedAuthor;
|
|
1241
|
+
exports.mapMobileSocialFeedCandle = mapMobileSocialFeedCandle;
|
|
1242
|
+
exports.mapMobileSocialFeedCommentResult = mapMobileSocialFeedCommentResult;
|
|
1243
|
+
exports.mapMobileSocialFeedCommentsPage = mapMobileSocialFeedCommentsPage;
|
|
1244
|
+
exports.mapMobileSocialFeedCompactCard = mapMobileSocialFeedCompactCard;
|
|
1245
|
+
exports.mapMobileSocialFeedContentBase = mapMobileSocialFeedContentBase;
|
|
1246
|
+
exports.mapMobileSocialFeedDrawing = mapMobileSocialFeedDrawing;
|
|
1247
|
+
exports.mapMobileSocialFeedDrawingMutationResult = mapMobileSocialFeedDrawingMutationResult;
|
|
1248
|
+
exports.mapMobileSocialFeedDrawingResult = mapMobileSocialFeedDrawingResult;
|
|
1249
|
+
exports.mapMobileSocialFeedHistoryMetrics = mapMobileSocialFeedHistoryMetrics;
|
|
1250
|
+
exports.mapMobileSocialFeedHistoryTake = mapMobileSocialFeedHistoryTake;
|
|
1251
|
+
exports.mapMobileSocialFeedImage = mapMobileSocialFeedImage;
|
|
591
1252
|
exports.mapMobileSocialFeedInteraction = mapMobileSocialFeedInteraction;
|
|
592
1253
|
exports.mapMobileSocialFeedItem = mapMobileSocialFeedItem;
|
|
593
1254
|
exports.mapMobileSocialFeedItemBase = mapMobileSocialFeedItemBase;
|
|
594
1255
|
exports.mapMobileSocialFeedItemPatch = mapMobileSocialFeedItemPatch;
|
|
595
1256
|
exports.mapMobileSocialFeedItemResponse = mapMobileSocialFeedItemResponse;
|
|
1257
|
+
exports.mapMobileSocialFeedLikeResult = mapMobileSocialFeedLikeResult;
|
|
596
1258
|
exports.mapMobileSocialFeedListParamsToServer = mapMobileSocialFeedListParamsToServer;
|
|
597
1259
|
exports.mapMobileSocialFeedMarket = mapMobileSocialFeedMarket;
|
|
1260
|
+
exports.mapMobileSocialFeedMentionToServer = mapMobileSocialFeedMentionToServer;
|
|
598
1261
|
exports.mapMobileSocialFeedPage = mapMobileSocialFeedPage;
|
|
599
1262
|
exports.mapMobileSocialFeedPnl = mapMobileSocialFeedPnl;
|
|
1263
|
+
exports.mapMobileSocialFeedPositionAction = mapMobileSocialFeedPositionAction;
|
|
600
1264
|
exports.mapMobileSocialFeedPositionCard = mapMobileSocialFeedPositionCard;
|
|
1265
|
+
exports.mapMobileSocialFeedPositionChart = mapMobileSocialFeedPositionChart;
|
|
1266
|
+
exports.mapMobileSocialFeedPositionHistory = mapMobileSocialFeedPositionHistory;
|
|
601
1267
|
exports.mapMobileSocialFeedPositionPatch = mapMobileSocialFeedPositionPatch;
|
|
1268
|
+
exports.mapMobileSocialFeedPositionResolutionResult = mapMobileSocialFeedPositionResolutionResult;
|
|
1269
|
+
exports.mapMobileSocialFeedPositionsPage = mapMobileSocialFeedPositionsPage;
|
|
1270
|
+
exports.mapMobileSocialFeedPost = mapMobileSocialFeedPost;
|
|
1271
|
+
exports.mapMobileSocialFeedPresence = mapMobileSocialFeedPresence;
|
|
1272
|
+
exports.mapMobileSocialFeedPublishablePosition = mapMobileSocialFeedPublishablePosition;
|
|
602
1273
|
exports.mapMobileSocialFeedRankedPage = mapMobileSocialFeedRankedPage;
|
|
603
1274
|
exports.mapMobileSocialFeedReadParamsToServer = mapMobileSocialFeedReadParamsToServer;
|
|
604
1275
|
exports.mapMobileSocialFeedReadSession = mapMobileSocialFeedReadSession;
|
|
1276
|
+
exports.mapMobileSocialFeedReply = mapMobileSocialFeedReply;
|
|
1277
|
+
exports.mapMobileSocialFeedTimelineEntry = mapMobileSocialFeedTimelineEntry;
|
|
605
1278
|
exports.mapMobileSocialFeedTopTradersPage = mapMobileSocialFeedTopTradersPage;
|
|
606
1279
|
exports.mapMobileSocialFeedTradeCard = mapMobileSocialFeedTradeCard;
|
|
607
1280
|
exports.mapMobileSocialFeedTradeRow = mapMobileSocialFeedTradeRow;
|
|
608
1281
|
exports.mapMobileSocialFeedTradeRowBase = mapMobileSocialFeedTradeRowBase;
|
|
609
1282
|
exports.mapMobileSocialFeedTraderBadge = mapMobileSocialFeedTraderBadge;
|
|
1283
|
+
exports.mapMobileSocialFeedTradingContext = mapMobileSocialFeedTradingContext;
|
|
1284
|
+
exports.mapMobileSocialFeedTradingTarget = mapMobileSocialFeedTradingTarget;
|
|
610
1285
|
exports.mapMobileSocialFeedUpdates = mapMobileSocialFeedUpdates;
|
|
1286
|
+
exports.mapMobileSocialFeedViewsResult = mapMobileSocialFeedViewsResult;
|
|
1287
|
+
exports.mapMobileSocialFeedWatchers = mapMobileSocialFeedWatchers;
|
|
611
1288
|
|
|
612
1289
|
//# sourceMappingURL=dataMappers.cjs.map
|