@nadohq/mobile-client 0.63.0 → 0.65.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 +20 -2
- package/dist/{MobileClient-aDxiM_Kf.cjs → MobileClient-CfVZXTcz.cjs} +298 -1
- package/dist/MobileClient-CfVZXTcz.cjs.map +1 -0
- package/dist/MobileClient.cjs +1 -1
- package/dist/MobileClient.d.cts +173 -7
- package/dist/MobileClient.d.cts.map +1 -1
- package/dist/MobileClient.d.ts +173 -7
- package/dist/MobileClient.d.ts.map +1 -1
- package/dist/MobileClient.js +298 -1
- package/dist/MobileClient.js.map +1 -1
- package/dist/{MobileServerFailureError-Dd3c6P_Z.d.ts → MobileServerFailureError-BZVwlsMg.d.ts} +3 -3
- package/dist/{MobileServerFailureError-Dd3c6P_Z.d.ts.map → MobileServerFailureError-BZVwlsMg.d.ts.map} +1 -1
- package/dist/{MobileServerFailureError-Bpa_WA9f.d.cts → MobileServerFailureError-CbtK8kD4.d.cts} +3 -3
- package/dist/{MobileServerFailureError-Bpa_WA9f.d.cts.map → MobileServerFailureError-CbtK8kD4.d.cts.map} +1 -1
- 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/{buildSignedMobileRequest-NHbMAPzd.d.cts → buildSignedMobileRequest-C1v0flCR.d.cts} +2 -2
- package/dist/{buildSignedMobileRequest-NHbMAPzd.d.cts.map → buildSignedMobileRequest-C1v0flCR.d.cts.map} +1 -1
- package/dist/{buildSignedMobileRequest-Cb1T74xV.d.ts → buildSignedMobileRequest-UeeWdYGU.d.ts} +2 -2
- package/dist/{buildSignedMobileRequest-Cb1T74xV.d.ts.map → buildSignedMobileRequest-UeeWdYGU.d.ts.map} +1 -1
- package/dist/{canonicalize-BBYGh17w.d.ts → canonicalize-5eeZrkzQ.d.ts} +2 -2
- package/dist/canonicalize-5eeZrkzQ.d.ts.map +1 -0
- package/dist/{canonicalize-BF_SiNvO.d.cts → canonicalize-CBaZprTo.d.cts} +2 -2
- package/dist/canonicalize-CBaZprTo.d.cts.map +1 -0
- package/dist/{clientTypes-BWFKo9oE.d.cts → clientTypes-C9dJufxk.d.ts} +569 -25
- package/dist/clientTypes-C9dJufxk.d.ts.map +1 -0
- package/dist/{clientTypes-DCTiUV0H.d.ts → clientTypes-_mEgzmNs.d.cts} +569 -25
- package/dist/clientTypes-_mEgzmNs.d.cts.map +1 -0
- package/dist/dataMappers.cjs +488 -9
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.d.cts +190 -7
- package/dist/dataMappers.d.cts.map +1 -1
- package/dist/dataMappers.d.ts +190 -7
- package/dist/dataMappers.d.ts.map +1 -1
- package/dist/dataMappers.js +460 -10
- package/dist/dataMappers.js.map +1 -1
- package/dist/{eip712MethodByType-BSx11xG-.d.cts → eip712MethodByType-D8jLoxDu.d.cts} +2 -2
- package/dist/eip712MethodByType-D8jLoxDu.d.cts.map +1 -0
- package/dist/{eip712MethodByType-DkiAjCLs.d.ts → eip712MethodByType-DcUh8h-l.d.ts} +2 -2
- package/dist/eip712MethodByType-DcUh8h-l.d.ts.map +1 -0
- package/dist/index.cjs +3 -1
- package/dist/index.d.cts +16 -15
- package/dist/index.d.ts +16 -15
- package/dist/index.js +2 -1
- package/dist/{mobileErrorCodes-3LtreeZM.d.ts → mobileErrorCodes-CmjYEIYm.d.cts} +18 -4
- package/dist/mobileErrorCodes-CmjYEIYm.d.cts.map +1 -0
- package/dist/{mobileErrorCodes-3LtreeZM.d.cts → mobileErrorCodes-CmjYEIYm.d.ts} +18 -4
- package/dist/mobileErrorCodes-CmjYEIYm.d.ts.map +1 -0
- package/dist/{payloadHash-BOWGjqdb.d.cts → payloadHash-DhHmgRqL.d.cts} +2 -2
- package/dist/payloadHash-DhHmgRqL.d.cts.map +1 -0
- package/dist/{payloadHash-Bzf4CtjV.d.ts → payloadHash-E1_8fpLW.d.ts} +2 -2
- package/dist/payloadHash-E1_8fpLW.d.ts.map +1 -0
- package/dist/{serverBaseTypes-KREDe2M9.d.cts → serverBaseTypes-B5J1_TyC.d.cts} +2 -2
- package/dist/{serverBaseTypes-KREDe2M9.d.cts.map → serverBaseTypes-B5J1_TyC.d.cts.map} +1 -1
- package/dist/{serverBaseTypes-DWf3iGWy.d.ts → serverBaseTypes-DnLzsdm-.d.ts} +2 -2
- package/dist/{serverBaseTypes-DWf3iGWy.d.ts.map → serverBaseTypes-DnLzsdm-.d.ts.map} +1 -1
- package/dist/serverExecuteTypes-B-OJok19.d.cts +162 -0
- package/dist/serverExecuteTypes-B-OJok19.d.cts.map +1 -0
- package/dist/serverExecuteTypes-BwWGspOg.d.ts +162 -0
- package/dist/serverExecuteTypes-BwWGspOg.d.ts.map +1 -0
- package/dist/{serverModelTypes-DAqEyYtB.d.cts → serverModelTypes-CiA-dy1R.d.cts} +299 -24
- package/dist/serverModelTypes-CiA-dy1R.d.cts.map +1 -0
- package/dist/{serverModelTypes-DAqEyYtB.d.ts → serverModelTypes-CiA-dy1R.d.ts} +299 -24
- package/dist/serverModelTypes-CiA-dy1R.d.ts.map +1 -0
- package/dist/{serverQueryTypes-DNdMpmDr.d.cts → serverQueryTypes-CJcjLB7n.d.ts} +117 -5
- package/dist/serverQueryTypes-CJcjLB7n.d.ts.map +1 -0
- package/dist/{serverQueryTypes-BFdwq0Z2.d.ts → serverQueryTypes-V1f9yE7L.d.cts} +117 -5
- package/dist/serverQueryTypes-V1f9yE7L.d.cts.map +1 -0
- package/dist/{serverRequestTypes-CxDRFKfv.d.cts → serverRequestTypes-CRlkNSu5.d.cts} +77 -7
- package/dist/serverRequestTypes-CRlkNSu5.d.cts.map +1 -0
- package/dist/{serverRequestTypes-BNA7FCY6.d.ts → serverRequestTypes-DZoOhV2o.d.ts} +77 -7
- package/dist/serverRequestTypes-DZoOhV2o.d.ts.map +1 -0
- package/dist/{serverResponseGuards-Dkdok0Sm.d.cts → serverResponseGuards-BW69PS7O.d.cts} +2 -2
- package/dist/{serverResponseGuards-Dkdok0Sm.d.cts.map → serverResponseGuards-BW69PS7O.d.cts.map} +1 -1
- package/dist/{serverResponseGuards-BU1Xv_tG.d.ts → serverResponseGuards-CShiXpHT.d.ts} +2 -2
- package/dist/{serverResponseGuards-BU1Xv_tG.d.ts.map → serverResponseGuards-CShiXpHT.d.ts.map} +1 -1
- package/dist/signing/buildSignedMobileRequest.d.cts +1 -1
- package/dist/signing/buildSignedMobileRequest.d.ts +1 -1
- package/dist/signing/canonicalize.cjs +37 -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 +37 -0
- package/dist/signing/canonicalize.js.map +1 -1
- package/dist/signing/eip712MethodByType.cjs +5 -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 +5 -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.d.cts +1 -1
- package/dist/signing/payloadHash.d.ts +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/clientTypes.d.cts +2 -2
- package/dist/types/clientTypes.d.ts +2 -2
- package/dist/types/index.cjs +2 -0
- package/dist/types/index.d.cts +10 -9
- package/dist/types/index.d.ts +10 -9
- package/dist/types/index.js +2 -1
- package/dist/types/mobileErrorCodes.cjs +28 -0
- 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 +28 -0
- 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.map +1 -1
- package/dist/types/serverModelTypes.d.cts +2 -2
- package/dist/types/serverModelTypes.d.ts +2 -2
- 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 +1 -1
- package/dist/types/serverRequestTypes.d.ts +1 -1
- package/dist/{types-BCr2G5gS.d.cts → types-BiRmH5Iv.d.cts} +31 -7
- package/dist/types-BiRmH5Iv.d.cts.map +1 -0
- package/dist/{types-C18k-9Vy.d.ts → types-DoJuq0Ij.d.ts} +31 -7
- package/dist/types-DoJuq0Ij.d.ts.map +1 -0
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- 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 +409 -4
- package/src/dataMappers.test.ts +742 -0
- package/src/dataMappers.ts +671 -12
- package/src/signing/canonicalize.ts +53 -0
- package/src/signing/eip712MethodByType.ts +5 -0
- package/src/signing/signing.test.ts +347 -0
- package/src/signing/types.ts +57 -4
- package/src/types/MobileUnsupportedFeedItemError.ts +18 -0
- package/src/types/clientTypes.ts +645 -23
- package/src/types/index.ts +1 -0
- package/src/types/mobileErrorCodes.ts +28 -0
- package/src/types/serverExecuteTypes.ts +92 -3
- package/src/types/serverModelTypes.ts +376 -22
- package/src/types/serverQueryTypes.ts +138 -0
- package/src/types/serverRequestTypes.ts +115 -4
- package/dist/MobileClient-aDxiM_Kf.cjs.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.map +0 -1
- 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/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/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.map +0 -1
- package/dist/serverModelTypes-DAqEyYtB.d.ts.map +0 -1
- package/dist/serverQueryTypes-BFdwq0Z2.d.ts.map +0 -1
- package/dist/serverQueryTypes-DNdMpmDr.d.cts.map +0 -1
- package/dist/serverRequestTypes-BNA7FCY6.d.ts.map +0 -1
- package/dist/serverRequestTypes-CxDRFKfv.d.cts.map +0 -1
- package/dist/types-BCr2G5gS.d.cts.map +0 -1
- package/dist/types-C18k-9Vy.d.ts.map +0 -1
package/src/dataMappers.ts
CHANGED
|
@@ -17,33 +17,68 @@ import {
|
|
|
17
17
|
MobileProfilesInclude,
|
|
18
18
|
MobilePublicProfile,
|
|
19
19
|
MobileRegisteredWallet,
|
|
20
|
+
MobileSocialFeedActionCandidate,
|
|
21
|
+
MobileSocialFeedActionMarker,
|
|
22
|
+
MobileSocialFeedActionResolutionResult,
|
|
20
23
|
MobileSocialFeedAuthor,
|
|
24
|
+
MobileSocialFeedCandle,
|
|
25
|
+
MobileSocialFeedCommentResult,
|
|
26
|
+
MobileSocialFeedCommentsPage,
|
|
27
|
+
MobileSocialFeedCompactCard,
|
|
28
|
+
MobileSocialFeedContentBase,
|
|
29
|
+
MobileSocialFeedDrawing,
|
|
30
|
+
MobileSocialFeedDrawingMutationResult,
|
|
31
|
+
MobileSocialFeedDrawingResult,
|
|
32
|
+
MobileSocialFeedHistoryMetrics,
|
|
33
|
+
MobileSocialFeedHistoryTake,
|
|
21
34
|
MobileSocialFeedInteraction,
|
|
22
35
|
MobileSocialFeedItem,
|
|
23
36
|
MobileSocialFeedItemBase,
|
|
24
37
|
MobileSocialFeedItemPatch,
|
|
25
38
|
MobileSocialFeedItemResponse,
|
|
39
|
+
MobileSocialFeedLikeResult,
|
|
26
40
|
MobileSocialFeedListParams,
|
|
27
41
|
MobileSocialFeedMarket,
|
|
42
|
+
MobileSocialFeedMentionParams,
|
|
28
43
|
MobileSocialFeedPage,
|
|
29
44
|
MobileSocialFeedPnl,
|
|
45
|
+
MobileSocialFeedPositionAction,
|
|
30
46
|
MobileSocialFeedPositionCard,
|
|
47
|
+
MobileSocialFeedPositionChart,
|
|
48
|
+
MobileSocialFeedPositionHistory,
|
|
31
49
|
MobileSocialFeedPositionPatch,
|
|
50
|
+
MobileSocialFeedPositionResolutionResult,
|
|
51
|
+
MobileSocialFeedPositionsPage,
|
|
52
|
+
MobileSocialFeedPost,
|
|
53
|
+
MobileSocialFeedPresence,
|
|
54
|
+
MobileSocialFeedPublishablePosition,
|
|
32
55
|
MobileSocialFeedRankedPage,
|
|
33
56
|
MobileSocialFeedReadParams,
|
|
34
57
|
MobileSocialFeedReadSession,
|
|
58
|
+
MobileSocialFeedReply,
|
|
59
|
+
MobileSocialFeedTimelineEntry,
|
|
35
60
|
MobileSocialFeedTopTradersPage,
|
|
36
61
|
MobileSocialFeedTradeCard,
|
|
37
62
|
MobileSocialFeedTradeRow,
|
|
38
63
|
MobileSocialFeedTradeRowBase,
|
|
39
64
|
MobileSocialFeedTraderBadge,
|
|
65
|
+
MobileSocialFeedTradingContext,
|
|
66
|
+
MobileSocialFeedTradingTarget,
|
|
40
67
|
MobileSocialFeedUpdates,
|
|
68
|
+
MobileSocialFeedViewsResult,
|
|
69
|
+
MobileSocialFeedWatchers,
|
|
41
70
|
SearchMobileProfilesParams,
|
|
42
71
|
} from './types/clientTypes';
|
|
72
|
+
import { MobileUnsupportedFeedItemError } from './types/MobileUnsupportedFeedItemError';
|
|
43
73
|
import {
|
|
44
74
|
MobileServerAvatarUploadResponse,
|
|
45
75
|
MobileServerFollowBatchResponse,
|
|
46
76
|
MobileServerFollowMutationResponse,
|
|
77
|
+
MobileServerSocialFeedCommentResponse,
|
|
78
|
+
MobileServerSocialFeedDrawingMutationResponse,
|
|
79
|
+
MobileServerSocialFeedLikeResponse,
|
|
80
|
+
MobileServerSocialFeedPresenceResponse,
|
|
81
|
+
MobileServerSocialFeedViewsResponse,
|
|
47
82
|
} from './types/serverExecuteTypes';
|
|
48
83
|
import {
|
|
49
84
|
MobileServerAvatarPreset,
|
|
@@ -54,31 +89,55 @@ import {
|
|
|
54
89
|
MobileServerNotificationPreferenceScope,
|
|
55
90
|
MobileServerNotificationPreferences,
|
|
56
91
|
MobileServerProfile,
|
|
92
|
+
MobileServerSocialFeedActionCandidate,
|
|
93
|
+
MobileServerSocialFeedActionMarker,
|
|
57
94
|
MobileServerSocialFeedAuthor,
|
|
95
|
+
MobileServerSocialFeedCandle,
|
|
96
|
+
MobileServerSocialFeedCompactCard,
|
|
97
|
+
MobileServerSocialFeedContentBase,
|
|
98
|
+
MobileServerSocialFeedDrawing,
|
|
99
|
+
MobileServerSocialFeedHistoryMetrics,
|
|
100
|
+
MobileServerSocialFeedHistoryTake,
|
|
58
101
|
MobileServerSocialFeedInteraction,
|
|
59
102
|
MobileServerSocialFeedItem,
|
|
60
103
|
MobileServerSocialFeedItemBase,
|
|
61
104
|
MobileServerSocialFeedItemPatch,
|
|
62
105
|
MobileServerSocialFeedMarket,
|
|
63
106
|
MobileServerSocialFeedPnl,
|
|
107
|
+
MobileServerSocialFeedPositionAction,
|
|
64
108
|
MobileServerSocialFeedPositionCard,
|
|
65
109
|
MobileServerSocialFeedPositionPatch,
|
|
110
|
+
MobileServerSocialFeedPost,
|
|
111
|
+
MobileServerSocialFeedPublishablePosition,
|
|
66
112
|
MobileServerSocialFeedReadSession,
|
|
113
|
+
MobileServerSocialFeedReply,
|
|
114
|
+
MobileServerSocialFeedTimelineEntry,
|
|
67
115
|
MobileServerSocialFeedTradeCard,
|
|
68
116
|
MobileServerSocialFeedTradeRow,
|
|
69
117
|
MobileServerSocialFeedTradeRowBase,
|
|
70
118
|
MobileServerSocialFeedTraderBadge,
|
|
119
|
+
MobileServerSocialFeedTradingContext,
|
|
120
|
+
MobileServerSocialFeedTradingTarget,
|
|
121
|
+
MobileSocialFeedMention,
|
|
71
122
|
} from './types/serverModelTypes';
|
|
72
123
|
import {
|
|
73
124
|
MobileServerFeedResponse,
|
|
74
125
|
MobileServerFollowListResponse,
|
|
75
126
|
MobileServerRegisteredWalletResponse,
|
|
76
127
|
MobileServerSearchProfilesResponse,
|
|
128
|
+
MobileServerSocialFeedActionResolutionResponse,
|
|
129
|
+
MobileServerSocialFeedCommentsResponse,
|
|
130
|
+
MobileServerSocialFeedDrawingResponse,
|
|
77
131
|
MobileServerSocialFeedItemResponse,
|
|
132
|
+
MobileServerSocialFeedPositionChartResponse,
|
|
133
|
+
MobileServerSocialFeedPositionHistoryResponse,
|
|
134
|
+
MobileServerSocialFeedPositionResolutionResponse,
|
|
135
|
+
MobileServerSocialFeedPositionsResponse,
|
|
78
136
|
MobileServerSocialFeedRankedResponse,
|
|
79
137
|
MobileServerSocialFeedResponse,
|
|
80
138
|
MobileServerSocialFeedTopTradersResponse,
|
|
81
139
|
MobileServerSocialFeedUpdatesResponse,
|
|
140
|
+
MobileServerSocialFeedWatchersResponse,
|
|
82
141
|
} from './types/serverQueryTypes';
|
|
83
142
|
import {
|
|
84
143
|
MobileServerFollowListRequest,
|
|
@@ -467,6 +526,13 @@ export function mapMobileSocialFeedPositionPatch(
|
|
|
467
526
|
leverage: server.leverage,
|
|
468
527
|
leverageAtMs: server.leverage_at_ms,
|
|
469
528
|
pnl: mapMobileSocialFeedPnl(server.pnl),
|
|
529
|
+
...(server.current_position === undefined
|
|
530
|
+
? {}
|
|
531
|
+
: {
|
|
532
|
+
currentPosition: mapMobileSocialFeedHistoryMetrics(
|
|
533
|
+
server.current_position,
|
|
534
|
+
),
|
|
535
|
+
}),
|
|
470
536
|
};
|
|
471
537
|
}
|
|
472
538
|
|
|
@@ -513,7 +579,10 @@ export function mapMobileSocialFeedItemBase(
|
|
|
513
579
|
return {
|
|
514
580
|
id: server.id,
|
|
515
581
|
hasAnalysis: server.has_analysis,
|
|
516
|
-
drawing:
|
|
582
|
+
drawing:
|
|
583
|
+
server.drawing === null
|
|
584
|
+
? null
|
|
585
|
+
: mapMobileSocialFeedDrawing(server.drawing),
|
|
517
586
|
author: mapMobileSocialFeedAuthor(server.author),
|
|
518
587
|
createdAtMs: server.created_at_ms,
|
|
519
588
|
displayAtMs: server.display_at_ms,
|
|
@@ -528,29 +597,42 @@ export function mapMobileSocialFeedItemBase(
|
|
|
528
597
|
}
|
|
529
598
|
|
|
530
599
|
/**
|
|
531
|
-
* Maps
|
|
600
|
+
* Maps the content, position, interaction, and comment preview shared by posts and trade cards.
|
|
532
601
|
* @param server - The service response.
|
|
533
|
-
* @returns The mapped
|
|
602
|
+
* @returns The mapped shared content fields.
|
|
534
603
|
*/
|
|
535
|
-
export function
|
|
536
|
-
server:
|
|
537
|
-
):
|
|
604
|
+
export function mapMobileSocialFeedContentBase(
|
|
605
|
+
server: MobileServerSocialFeedContentBase,
|
|
606
|
+
): MobileSocialFeedContentBase {
|
|
538
607
|
return {
|
|
539
608
|
...mapMobileSocialFeedItemBase(server),
|
|
540
|
-
kind: server.kind,
|
|
541
|
-
action: server.action,
|
|
542
609
|
text: server.text,
|
|
543
610
|
mentions: server.mentions,
|
|
544
611
|
position: mapMobileSocialFeedPositionCard(server.position),
|
|
545
612
|
interaction: mapMobileSocialFeedInteraction(server.interaction),
|
|
546
613
|
commentPreview: {
|
|
547
|
-
items: server.comment_preview.items,
|
|
614
|
+
items: server.comment_preview.items.map(mapMobileSocialFeedReply),
|
|
548
615
|
totalCount: server.comment_preview.total_count,
|
|
549
616
|
nextCursor: server.comment_preview.next_cursor,
|
|
550
617
|
},
|
|
551
618
|
};
|
|
552
619
|
}
|
|
553
620
|
|
|
621
|
+
/**
|
|
622
|
+
* Maps a trade card, authored content, and position and interaction metadata.
|
|
623
|
+
* @param server - The service response.
|
|
624
|
+
* @returns The mapped social trade card.
|
|
625
|
+
*/
|
|
626
|
+
export function mapMobileSocialFeedTradeCard(
|
|
627
|
+
server: MobileServerSocialFeedTradeCard,
|
|
628
|
+
): MobileSocialFeedTradeCard {
|
|
629
|
+
return {
|
|
630
|
+
...mapMobileSocialFeedContentBase(server),
|
|
631
|
+
kind: server.kind,
|
|
632
|
+
action: server.action,
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
|
|
554
636
|
/**
|
|
555
637
|
* Maps historical trade facts with decimal execution prices and x18 quantities.
|
|
556
638
|
* @param server - The service response.
|
|
@@ -612,13 +694,24 @@ export function mapMobileSocialFeedTradeRow(
|
|
|
612
694
|
* Maps the item variant without mixing card and row fields.
|
|
613
695
|
* @param server - The service response.
|
|
614
696
|
* @returns The mapped social feed item.
|
|
697
|
+
* @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
|
|
615
698
|
*/
|
|
616
699
|
export function mapMobileSocialFeedItem(
|
|
617
700
|
server: MobileServerSocialFeedItem,
|
|
618
701
|
): MobileSocialFeedItem {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
:
|
|
702
|
+
const kind = server.kind;
|
|
703
|
+
switch (kind) {
|
|
704
|
+
case 'trade_card':
|
|
705
|
+
return mapMobileSocialFeedTradeCard(server);
|
|
706
|
+
case 'trade_row':
|
|
707
|
+
return mapMobileSocialFeedTradeRow(server);
|
|
708
|
+
case 'post':
|
|
709
|
+
return mapMobileSocialFeedPost(server);
|
|
710
|
+
case 'reply':
|
|
711
|
+
return mapMobileSocialFeedReply(server);
|
|
712
|
+
default:
|
|
713
|
+
throw new MobileUnsupportedFeedItemError(kind satisfies never);
|
|
714
|
+
}
|
|
622
715
|
}
|
|
623
716
|
|
|
624
717
|
/**
|
|
@@ -646,6 +739,7 @@ export function mapMobileSocialFeedReadSession(
|
|
|
646
739
|
* Maps a fixed feed page without changing item order or pagination.
|
|
647
740
|
* @param server - The service response.
|
|
648
741
|
* @returns The mapped social feed page.
|
|
742
|
+
* @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
|
|
649
743
|
*/
|
|
650
744
|
export function mapMobileSocialFeedPage(
|
|
651
745
|
server: MobileServerSocialFeedResponse,
|
|
@@ -662,6 +756,7 @@ export function mapMobileSocialFeedPage(
|
|
|
662
756
|
* Maps a main feed page and its ranking version.
|
|
663
757
|
* @param server - The service response.
|
|
664
758
|
* @returns The mapped ranked feed page.
|
|
759
|
+
* @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
|
|
665
760
|
*/
|
|
666
761
|
export function mapMobileSocialFeedRankedPage(
|
|
667
762
|
server: MobileServerSocialFeedRankedResponse,
|
|
@@ -676,6 +771,7 @@ export function mapMobileSocialFeedRankedPage(
|
|
|
676
771
|
* Maps qualified trader items and their shared eligibility snapshot.
|
|
677
772
|
* @param server - The service response.
|
|
678
773
|
* @returns The mapped top traders feed page.
|
|
774
|
+
* @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
|
|
679
775
|
*/
|
|
680
776
|
export function mapMobileSocialFeedTopTradersPage(
|
|
681
777
|
server: MobileServerSocialFeedTopTradersResponse,
|
|
@@ -699,6 +795,7 @@ export function mapMobileSocialFeedTopTradersPage(
|
|
|
699
795
|
* Maps item details and the authorized reading session.
|
|
700
796
|
* @param server - The service response.
|
|
701
797
|
* @returns The mapped social feed item response.
|
|
798
|
+
* @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
|
|
702
799
|
*/
|
|
703
800
|
export function mapMobileSocialFeedItemResponse(
|
|
704
801
|
server: MobileServerSocialFeedItemResponse,
|
|
@@ -720,6 +817,17 @@ export function mapMobileSocialFeedItemPatch(
|
|
|
720
817
|
return {
|
|
721
818
|
itemId: server.item_id,
|
|
722
819
|
version: server.version,
|
|
820
|
+
...(server.attached_position === undefined
|
|
821
|
+
? {}
|
|
822
|
+
: {
|
|
823
|
+
attachedPosition:
|
|
824
|
+
server.attached_position === null
|
|
825
|
+
? null
|
|
826
|
+
: mapMobileSocialFeedPositionCard(server.attached_position),
|
|
827
|
+
}),
|
|
828
|
+
...(server.attachment_status === undefined
|
|
829
|
+
? {}
|
|
830
|
+
: { attachmentStatus: server.attachment_status }),
|
|
723
831
|
author: mapMobileSocialFeedAuthor(server.author),
|
|
724
832
|
displayAtMs: server.display_at_ms,
|
|
725
833
|
...(server.interaction === undefined
|
|
@@ -831,3 +939,554 @@ export function mapMobileSocialFeedReadParamsToServer(
|
|
|
831
939
|
viewer_token: params.viewerToken,
|
|
832
940
|
};
|
|
833
941
|
}
|
|
942
|
+
|
|
943
|
+
/**
|
|
944
|
+
* Maps a mention for signing without changing the text or offsets.
|
|
945
|
+
* @param params - Caller-provided mention and original text offsets.
|
|
946
|
+
* @returns The wire-format mention, preserving the original label and code-point offsets.
|
|
947
|
+
* @throws {Error} If the owner is not a 20-byte address or the subaccount name cannot be encoded in 12 bytes.
|
|
948
|
+
*/
|
|
949
|
+
export function mapMobileSocialFeedMentionToServer(
|
|
950
|
+
params: MobileSocialFeedMentionParams,
|
|
951
|
+
): MobileSocialFeedMention {
|
|
952
|
+
return {
|
|
953
|
+
subaccount: subaccountToHex(params.subaccount),
|
|
954
|
+
start: params.start,
|
|
955
|
+
end: params.end,
|
|
956
|
+
label: params.label,
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* Preserves parsed drawing data, including false and zero.
|
|
962
|
+
* @param server - Service payload with its original wire fields.
|
|
963
|
+
* @returns The original parsed drawing data and its creation/update timestamps in milliseconds.
|
|
964
|
+
*/
|
|
965
|
+
export function mapMobileSocialFeedDrawing(
|
|
966
|
+
server: MobileServerSocialFeedDrawing,
|
|
967
|
+
): MobileSocialFeedDrawing {
|
|
968
|
+
return {
|
|
969
|
+
data: server.data,
|
|
970
|
+
createdAtMs: server.created_at_ms,
|
|
971
|
+
updatedAtMs: server.updated_at_ms,
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* Maps a nonrecursive root preview, retaining nullable position visibility.
|
|
977
|
+
* @param server - Service payload with its original wire fields.
|
|
978
|
+
* @returns A nonrecursive preview with a nullable position and notional retained as an x18 BigNumber.
|
|
979
|
+
*/
|
|
980
|
+
export function mapMobileSocialFeedCompactCard(
|
|
981
|
+
server: MobileServerSocialFeedCompactCard,
|
|
982
|
+
): MobileSocialFeedCompactCard {
|
|
983
|
+
return {
|
|
984
|
+
id: server.id,
|
|
985
|
+
author: mapMobileSocialFeedAuthor(server.author),
|
|
986
|
+
textExcerpt: server.text_excerpt,
|
|
987
|
+
position:
|
|
988
|
+
server.position === null
|
|
989
|
+
? null
|
|
990
|
+
: {
|
|
991
|
+
positionId: server.position.position_id,
|
|
992
|
+
market: mapMobileSocialFeedMarket(server.position.market),
|
|
993
|
+
direction: server.position.direction,
|
|
994
|
+
state: server.position.state,
|
|
995
|
+
notional: toBigNumber(server.position.notional_x18),
|
|
996
|
+
},
|
|
997
|
+
hasAnalysis: server.has_analysis,
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* Maps an authored post and its readable comments and drawing.
|
|
1003
|
+
* @param server - Service payload with its original wire fields.
|
|
1004
|
+
* @returns A post with its unchanged text and mentions, mapped position, drawing, interactions, and reply preview.
|
|
1005
|
+
*/
|
|
1006
|
+
export function mapMobileSocialFeedPost(
|
|
1007
|
+
server: MobileServerSocialFeedPost,
|
|
1008
|
+
): MobileSocialFeedPost {
|
|
1009
|
+
return {
|
|
1010
|
+
...mapMobileSocialFeedContentBase(server),
|
|
1011
|
+
kind: server.kind,
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
/**
|
|
1016
|
+
* Maps reply visibility without treating an unavailable attachment as an absent one.
|
|
1017
|
+
* @param server - Service payload with its original wire fields.
|
|
1018
|
+
* @returns A reply preserving omitted reply targets, nullable attachments, and the separate attachment visibility status.
|
|
1019
|
+
*/
|
|
1020
|
+
export function mapMobileSocialFeedReply(
|
|
1021
|
+
server: MobileServerSocialFeedReply,
|
|
1022
|
+
): MobileSocialFeedReply {
|
|
1023
|
+
return {
|
|
1024
|
+
...mapMobileSocialFeedItemBase(server),
|
|
1025
|
+
kind: server.kind,
|
|
1026
|
+
text: server.text,
|
|
1027
|
+
mentions: server.mentions,
|
|
1028
|
+
rootItemId: server.root_item_id,
|
|
1029
|
+
...(server.reply_to_item_id === undefined
|
|
1030
|
+
? {}
|
|
1031
|
+
: { replyToItemId: server.reply_to_item_id }),
|
|
1032
|
+
replyToAuthor:
|
|
1033
|
+
server.reply_to_author === null
|
|
1034
|
+
? null
|
|
1035
|
+
: mapMobileSocialFeedAuthor(server.reply_to_author),
|
|
1036
|
+
attachedPosition:
|
|
1037
|
+
server.attached_position === null
|
|
1038
|
+
? null
|
|
1039
|
+
: mapMobileSocialFeedPositionCard(server.attached_position),
|
|
1040
|
+
attachmentStatus: server.attachment_status,
|
|
1041
|
+
original: mapMobileSocialFeedCompactCard(server.original),
|
|
1042
|
+
interaction: mapMobileSocialFeedInteraction(server.interaction),
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* Maps current eligibility hints without implying caller ownership.
|
|
1048
|
+
* @param server - Service payload with its original wire fields.
|
|
1049
|
+
* @returns A position with current publication, attachment, and drawing eligibility hints and an unavailable reason.
|
|
1050
|
+
*/
|
|
1051
|
+
export function mapMobileSocialFeedPublishablePosition(
|
|
1052
|
+
server: MobileServerSocialFeedPublishablePosition,
|
|
1053
|
+
): MobileSocialFeedPublishablePosition {
|
|
1054
|
+
return {
|
|
1055
|
+
position: mapMobileSocialFeedPositionCard(server.position),
|
|
1056
|
+
canPublish: server.can_publish,
|
|
1057
|
+
canAttachToComment: server.can_attach_to_comment,
|
|
1058
|
+
canDrawAnalysis: server.can_draw_analysis,
|
|
1059
|
+
unavailableReason: server.unavailable_reason,
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* Maps all order action identifiers and eligibility hints.
|
|
1065
|
+
* @param server - Service payload with its original wire fields.
|
|
1066
|
+
* @returns Trusted action and position identifiers, action kind, publication eligibility, and an unavailable reason.
|
|
1067
|
+
*/
|
|
1068
|
+
export function mapMobileSocialFeedActionCandidate(
|
|
1069
|
+
server: MobileServerSocialFeedActionCandidate,
|
|
1070
|
+
): MobileSocialFeedActionCandidate {
|
|
1071
|
+
return {
|
|
1072
|
+
actionId: server.action_id,
|
|
1073
|
+
positionId: server.position_id,
|
|
1074
|
+
action: server.action,
|
|
1075
|
+
canPublish: server.can_publish,
|
|
1076
|
+
unavailableReason: server.unavailable_reason,
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
/**
|
|
1081
|
+
* Maps history risk prices to decimals while retaining funding amounts in x18 units.
|
|
1082
|
+
* @param server - Service payload with its original wire fields.
|
|
1083
|
+
* @returns Nullable decimal liquidation price and x18 funding PnL, with their independent quality and observation metadata.
|
|
1084
|
+
*/
|
|
1085
|
+
export function mapMobileSocialFeedHistoryMetrics(
|
|
1086
|
+
server: MobileServerSocialFeedHistoryMetrics,
|
|
1087
|
+
): MobileSocialFeedHistoryMetrics {
|
|
1088
|
+
return {
|
|
1089
|
+
estimatedLiquidationPrice: removeDecimals(
|
|
1090
|
+
server.estimated_liquidation_price_x18,
|
|
1091
|
+
),
|
|
1092
|
+
liquidationPriceQuality: server.liquidation_price_quality,
|
|
1093
|
+
liquidationPriceAsOfMs: server.liquidation_price_as_of_ms,
|
|
1094
|
+
fundingPnl:
|
|
1095
|
+
server.funding_pnl_x18 === null
|
|
1096
|
+
? null
|
|
1097
|
+
: toBigNumber(server.funding_pnl_x18),
|
|
1098
|
+
fundingQuality: server.funding_quality,
|
|
1099
|
+
fundingAsOfMs: server.funding_as_of_ms,
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
/**
|
|
1104
|
+
* Maps action prices independently; all amounts and quantities retain x18 units.
|
|
1105
|
+
* @param server - Service payload with its original wire fields.
|
|
1106
|
+
* @returns An action with decimal prices, x18 quantities/amounts, and independently nullable financial facts.
|
|
1107
|
+
*/
|
|
1108
|
+
export function mapMobileSocialFeedPositionAction(
|
|
1109
|
+
server: MobileServerSocialFeedPositionAction,
|
|
1110
|
+
): MobileSocialFeedPositionAction {
|
|
1111
|
+
return {
|
|
1112
|
+
id: server.id,
|
|
1113
|
+
positionId: server.position_id,
|
|
1114
|
+
action: server.action,
|
|
1115
|
+
direction: server.direction,
|
|
1116
|
+
marginMode: server.margin_mode,
|
|
1117
|
+
quantityBefore: toBigNumber(server.quantity_before_x18),
|
|
1118
|
+
quantityAfter: toBigNumber(server.quantity_after_x18),
|
|
1119
|
+
executedQuantity: toBigNumber(server.executed_quantity_x18),
|
|
1120
|
+
executedNotional:
|
|
1121
|
+
server.executed_notional_x18 === null
|
|
1122
|
+
? null
|
|
1123
|
+
: toBigNumber(server.executed_notional_x18),
|
|
1124
|
+
averagePrice: removeDecimals(server.average_price_x18),
|
|
1125
|
+
entryPriceBefore: removeDecimals(server.entry_price_before_x18),
|
|
1126
|
+
liquidationOraclePrice: removeDecimals(server.liquidation_oracle_price_x18),
|
|
1127
|
+
liquidationNotional:
|
|
1128
|
+
server.liquidation_notional_x18 === null
|
|
1129
|
+
? null
|
|
1130
|
+
: toBigNumber(server.liquidation_notional_x18),
|
|
1131
|
+
realizedPnlDelta:
|
|
1132
|
+
server.realized_pnl_delta_x18 === null
|
|
1133
|
+
? null
|
|
1134
|
+
: toBigNumber(server.realized_pnl_delta_x18),
|
|
1135
|
+
leverage: server.leverage,
|
|
1136
|
+
leverageAtMs: server.leverage_at_ms,
|
|
1137
|
+
firstEventAtMs: server.first_event_at_ms,
|
|
1138
|
+
lastEventAtMs: server.last_event_at_ms,
|
|
1139
|
+
version: server.version,
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* Maps a trusted target without treating the viewing account as authenticated.
|
|
1145
|
+
* @param server - Service payload with its original wire fields.
|
|
1146
|
+
* @returns A trading target retaining distinct identity/trading subaccounts, margin mode, and observation time.
|
|
1147
|
+
*/
|
|
1148
|
+
export function mapMobileSocialFeedTradingTarget(
|
|
1149
|
+
server: MobileServerSocialFeedTradingTarget,
|
|
1150
|
+
): MobileSocialFeedTradingTarget {
|
|
1151
|
+
return {
|
|
1152
|
+
positionId: server.position_id,
|
|
1153
|
+
identitySubaccount: server.identity_subaccount,
|
|
1154
|
+
tradingSubaccount: server.trading_subaccount,
|
|
1155
|
+
productId: server.product_id,
|
|
1156
|
+
marginMode: server.margin_mode,
|
|
1157
|
+
isoSubaccountName: server.iso_subaccount_name,
|
|
1158
|
+
direction: server.direction,
|
|
1159
|
+
stateAsOfMs: server.state_as_of_ms,
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* Maps viewing-account trading hints.
|
|
1165
|
+
* @param server - Service payload with its original wire fields.
|
|
1166
|
+
* @returns Trading hints with ordered target candidates, nullable viewer position, and the current reduction hint.
|
|
1167
|
+
*/
|
|
1168
|
+
export function mapMobileSocialFeedTradingContext(
|
|
1169
|
+
server: MobileServerSocialFeedTradingContext,
|
|
1170
|
+
): MobileSocialFeedTradingContext {
|
|
1171
|
+
return {
|
|
1172
|
+
productId: server.product_id,
|
|
1173
|
+
suggestedDirection: server.suggested_direction,
|
|
1174
|
+
resolution: server.resolution,
|
|
1175
|
+
candidates: server.candidates.map(mapMobileSocialFeedTradingTarget),
|
|
1176
|
+
viewerPositionId: server.viewer_position_id,
|
|
1177
|
+
canReduce: server.can_reduce,
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* Converts OHLC prices to decimals but preserves base-asset volume in x18.
|
|
1183
|
+
* @param server - Service payload with its original wire fields.
|
|
1184
|
+
* @returns A candle with decimal OHLC BigNumbers, base-asset volume retained in x18, and its timestamp in milliseconds.
|
|
1185
|
+
*/
|
|
1186
|
+
export function mapMobileSocialFeedCandle(
|
|
1187
|
+
server: MobileServerSocialFeedCandle,
|
|
1188
|
+
): MobileSocialFeedCandle {
|
|
1189
|
+
return {
|
|
1190
|
+
timestampMs: server.timestamp_ms,
|
|
1191
|
+
open: removeDecimals(server.open_x18),
|
|
1192
|
+
high: removeDecimals(server.high_x18),
|
|
1193
|
+
low: removeDecimals(server.low_x18),
|
|
1194
|
+
close: removeDecimals(server.close_x18),
|
|
1195
|
+
volume: toBigNumber(server.volume_x18),
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* Maps markers without replacing unknown Oracle prices with execution prices.
|
|
1201
|
+
* @param server - Service payload with its original wire fields.
|
|
1202
|
+
* @returns An action marker with its original price basis and a nullable decimal price, without substituting another source.
|
|
1203
|
+
*/
|
|
1204
|
+
export function mapMobileSocialFeedActionMarker(
|
|
1205
|
+
server: MobileServerSocialFeedActionMarker,
|
|
1206
|
+
): MobileSocialFeedActionMarker {
|
|
1207
|
+
return {
|
|
1208
|
+
actionId: server.action_id,
|
|
1209
|
+
timestampMs: server.timestamp_ms,
|
|
1210
|
+
price: removeDecimals(server.price_x18),
|
|
1211
|
+
action: server.action,
|
|
1212
|
+
direction: server.direction,
|
|
1213
|
+
priceBasis: server.price_basis,
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
/**
|
|
1218
|
+
* Maps selected-account open positions.
|
|
1219
|
+
* @param server - Service payload with its original wire fields.
|
|
1220
|
+
* @returns Mapped position candidates with the original nullable cursor and observation time.
|
|
1221
|
+
*/
|
|
1222
|
+
export function mapMobileSocialFeedPositionsPage(
|
|
1223
|
+
server: MobileServerSocialFeedPositionsResponse,
|
|
1224
|
+
): MobileSocialFeedPositionsPage {
|
|
1225
|
+
return {
|
|
1226
|
+
positions: server.positions.map(mapMobileSocialFeedPublishablePosition),
|
|
1227
|
+
nextCursor: server.next_cursor,
|
|
1228
|
+
asOfMs: server.as_of_ms,
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
/**
|
|
1233
|
+
* Maps normal empty and ambiguous command results.
|
|
1234
|
+
* @param server - Service payload with its original wire fields.
|
|
1235
|
+
* @returns The command resolution, nullable market, position candidates, and original reason for an empty result.
|
|
1236
|
+
*/
|
|
1237
|
+
export function mapMobileSocialFeedPositionResolutionResult(
|
|
1238
|
+
server: MobileServerSocialFeedPositionResolutionResponse,
|
|
1239
|
+
): MobileSocialFeedPositionResolutionResult {
|
|
1240
|
+
return {
|
|
1241
|
+
resolution: server.resolution,
|
|
1242
|
+
product:
|
|
1243
|
+
server.product === null
|
|
1244
|
+
? null
|
|
1245
|
+
: mapMobileSocialFeedMarket(server.product),
|
|
1246
|
+
candidates: server.candidates.map(mapMobileSocialFeedPublishablePosition),
|
|
1247
|
+
reason: server.reason,
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
/**
|
|
1252
|
+
* Preserves pending order projection without inventing action candidates.
|
|
1253
|
+
* @param server - Service payload with its original wire fields.
|
|
1254
|
+
* @returns The original order digest, ready/pending state, mapped actions, and observation time.
|
|
1255
|
+
*/
|
|
1256
|
+
export function mapMobileSocialFeedActionResolutionResult(
|
|
1257
|
+
server: MobileServerSocialFeedActionResolutionResponse,
|
|
1258
|
+
): MobileSocialFeedActionResolutionResult {
|
|
1259
|
+
return {
|
|
1260
|
+
orderDigest: server.order_digest,
|
|
1261
|
+
resolution: server.resolution,
|
|
1262
|
+
actions: server.actions.map(mapMobileSocialFeedActionCandidate),
|
|
1263
|
+
asOfMs: server.as_of_ms,
|
|
1264
|
+
};
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* Distinguishes no drawing from falsy drawing data.
|
|
1269
|
+
* @param server - Service payload with its original wire fields.
|
|
1270
|
+
* @returns The parent item ID/version and a nullable drawing, retaining false or zero drawing data.
|
|
1271
|
+
*/
|
|
1272
|
+
export function mapMobileSocialFeedDrawingResult(
|
|
1273
|
+
server: MobileServerSocialFeedDrawingResponse,
|
|
1274
|
+
): MobileSocialFeedDrawingResult {
|
|
1275
|
+
return {
|
|
1276
|
+
itemId: server.item_id,
|
|
1277
|
+
itemVersion: server.item_version,
|
|
1278
|
+
drawing:
|
|
1279
|
+
server.drawing === null
|
|
1280
|
+
? null
|
|
1281
|
+
: mapMobileSocialFeedDrawing(server.drawing),
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
/**
|
|
1286
|
+
* Maps a saved drawing after creation or replacement.
|
|
1287
|
+
* @param server - Successful drawing mutation response.
|
|
1288
|
+
* @returns The parent item ID/version and non-null saved drawing.
|
|
1289
|
+
*/
|
|
1290
|
+
export function mapMobileSocialFeedDrawingMutationResult(
|
|
1291
|
+
server: MobileServerSocialFeedDrawingMutationResponse,
|
|
1292
|
+
): MobileSocialFeedDrawingMutationResult {
|
|
1293
|
+
return {
|
|
1294
|
+
itemId: server.item_id,
|
|
1295
|
+
itemVersion: server.item_version,
|
|
1296
|
+
drawing: mapMobileSocialFeedDrawing(server.drawing),
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
/**
|
|
1301
|
+
* Maps bidirectional comments and the actual returned session.
|
|
1302
|
+
* @param server - Service payload with its original wire fields.
|
|
1303
|
+
* @returns Mapped replies, total count, bidirectional cursors, nullable anchor, and the actual reading session.
|
|
1304
|
+
*/
|
|
1305
|
+
export function mapMobileSocialFeedCommentsPage(
|
|
1306
|
+
server: MobileServerSocialFeedCommentsResponse,
|
|
1307
|
+
): MobileSocialFeedCommentsPage {
|
|
1308
|
+
return {
|
|
1309
|
+
comments: server.comments.map(mapMobileSocialFeedReply),
|
|
1310
|
+
totalCount: server.total_count,
|
|
1311
|
+
nextCursor: server.next_cursor,
|
|
1312
|
+
previousCursor: server.previous_cursor,
|
|
1313
|
+
anchorReplyId: server.anchor_reply_id,
|
|
1314
|
+
readSession: mapMobileSocialFeedReadSession(server.read_session),
|
|
1315
|
+
};
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
* Maps atomic reply publication without inventing a reading session.
|
|
1320
|
+
* @param server - Service payload with its original wire fields.
|
|
1321
|
+
* @returns The created reply and authoritative root comment count, without a fabricated reading session.
|
|
1322
|
+
*/
|
|
1323
|
+
export function mapMobileSocialFeedCommentResult(
|
|
1324
|
+
server: MobileServerSocialFeedCommentResponse,
|
|
1325
|
+
): MobileSocialFeedCommentResult {
|
|
1326
|
+
return {
|
|
1327
|
+
comment: mapMobileSocialFeedReply(server.comment),
|
|
1328
|
+
rootCommentCount: server.root_comment_count,
|
|
1329
|
+
};
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
/**
|
|
1333
|
+
* Maps authoritative like state and count.
|
|
1334
|
+
* @param server - Service payload with its original wire fields.
|
|
1335
|
+
* @returns The applied like state, authoritative count, and item ID/version after the mutation.
|
|
1336
|
+
*/
|
|
1337
|
+
export function mapMobileSocialFeedLikeResult(
|
|
1338
|
+
server: MobileServerSocialFeedLikeResponse,
|
|
1339
|
+
): MobileSocialFeedLikeResult {
|
|
1340
|
+
return {
|
|
1341
|
+
itemId: server.item_id,
|
|
1342
|
+
isLiked: server.is_liked,
|
|
1343
|
+
likeCount: server.like_count,
|
|
1344
|
+
version: server.version,
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
/**
|
|
1349
|
+
* Maps exposure deduplication results without adding timestamps.
|
|
1350
|
+
* @param server - Service payload with its original wire fields.
|
|
1351
|
+
* @returns Newly accepted and duplicate item ID lists without inventing an observation timestamp.
|
|
1352
|
+
*/
|
|
1353
|
+
export function mapMobileSocialFeedViewsResult(
|
|
1354
|
+
server: MobileServerSocialFeedViewsResponse,
|
|
1355
|
+
): MobileSocialFeedViewsResult {
|
|
1356
|
+
return {
|
|
1357
|
+
acceptedItemIds: server.accepted_item_ids,
|
|
1358
|
+
duplicateItemIds: server.duplicate_item_ids,
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
/**
|
|
1363
|
+
* Maps a published history take without treating unknown kinds as posts.
|
|
1364
|
+
* @param server - The published service item.
|
|
1365
|
+
* @returns The mapped post or trade card.
|
|
1366
|
+
* @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported take kind.
|
|
1367
|
+
*/
|
|
1368
|
+
export function mapMobileSocialFeedHistoryTake(
|
|
1369
|
+
server: MobileServerSocialFeedHistoryTake,
|
|
1370
|
+
): MobileSocialFeedHistoryTake {
|
|
1371
|
+
const kind = server.kind;
|
|
1372
|
+
switch (kind) {
|
|
1373
|
+
case 'trade_card':
|
|
1374
|
+
return mapMobileSocialFeedTradeCard(server);
|
|
1375
|
+
case 'post':
|
|
1376
|
+
return mapMobileSocialFeedPost(server);
|
|
1377
|
+
default:
|
|
1378
|
+
throw new MobileUnsupportedFeedItemError(kind satisfies never);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* Maps a historical action or published take while preserving its discriminant.
|
|
1384
|
+
* @param server - The service timeline entry.
|
|
1385
|
+
* @returns The mapped action or take entry.
|
|
1386
|
+
* @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported entry or take kind.
|
|
1387
|
+
*/
|
|
1388
|
+
export function mapMobileSocialFeedTimelineEntry(
|
|
1389
|
+
server: MobileServerSocialFeedTimelineEntry,
|
|
1390
|
+
): MobileSocialFeedTimelineEntry {
|
|
1391
|
+
const kind = server.kind;
|
|
1392
|
+
switch (kind) {
|
|
1393
|
+
case 'action':
|
|
1394
|
+
return {
|
|
1395
|
+
kind,
|
|
1396
|
+
action: mapMobileSocialFeedPositionAction(server.action),
|
|
1397
|
+
relatedItemId: server.related_item_id,
|
|
1398
|
+
relatedTake:
|
|
1399
|
+
server.related_take === null
|
|
1400
|
+
? null
|
|
1401
|
+
: mapMobileSocialFeedTradeCard(server.related_take),
|
|
1402
|
+
};
|
|
1403
|
+
case 'take':
|
|
1404
|
+
return {
|
|
1405
|
+
kind,
|
|
1406
|
+
item: mapMobileSocialFeedHistoryTake(server.item),
|
|
1407
|
+
};
|
|
1408
|
+
default:
|
|
1409
|
+
throw new MobileUnsupportedFeedItemError(kind satisfies never);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
/**
|
|
1414
|
+
* Maps full history, preserving action/take order, association, and null facts.
|
|
1415
|
+
* @param server - Service payload with its original wire fields.
|
|
1416
|
+
* @returns Position metrics, ordered action/take timeline, summary, cursor, quality, reading session, and trading hints.
|
|
1417
|
+
* @throws {MobileUnsupportedFeedItemError} If a timeline entry or take has an unsupported kind.
|
|
1418
|
+
*/
|
|
1419
|
+
export function mapMobileSocialFeedPositionHistory(
|
|
1420
|
+
server: MobileServerSocialFeedPositionHistoryResponse,
|
|
1421
|
+
): MobileSocialFeedPositionHistory {
|
|
1422
|
+
return {
|
|
1423
|
+
position: {
|
|
1424
|
+
...mapMobileSocialFeedPositionCard(server.position),
|
|
1425
|
+
...mapMobileSocialFeedHistoryMetrics(server.position),
|
|
1426
|
+
},
|
|
1427
|
+
summary: {
|
|
1428
|
+
actionCount: server.summary.action_count,
|
|
1429
|
+
takeCount: server.summary.take_count,
|
|
1430
|
+
},
|
|
1431
|
+
timeline: server.timeline.map(mapMobileSocialFeedTimelineEntry),
|
|
1432
|
+
nextCursor: server.next_cursor,
|
|
1433
|
+
historyQuality: server.history_quality,
|
|
1434
|
+
readSession: mapMobileSocialFeedReadSession(server.read_session),
|
|
1435
|
+
tradingContext: mapMobileSocialFeedTradingContext(server.trading_context),
|
|
1436
|
+
};
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* Maps candles and independent price sources, preserving explicit nulls.
|
|
1441
|
+
* @param server - Service payload with its original wire fields.
|
|
1442
|
+
* @returns Decimal-price candles and markers with x18 volume, a nullable liquidation line, and paging/quality metadata.
|
|
1443
|
+
*/
|
|
1444
|
+
export function mapMobileSocialFeedPositionChart(
|
|
1445
|
+
server: MobileServerSocialFeedPositionChartResponse,
|
|
1446
|
+
): MobileSocialFeedPositionChart {
|
|
1447
|
+
return {
|
|
1448
|
+
candles: server.candles.map(mapMobileSocialFeedCandle),
|
|
1449
|
+
actionMarkers: server.action_markers.map(mapMobileSocialFeedActionMarker),
|
|
1450
|
+
estimatedLiquidationLine:
|
|
1451
|
+
server.estimated_liquidation_line === null
|
|
1452
|
+
? null
|
|
1453
|
+
: {
|
|
1454
|
+
price: removeDecimals(server.estimated_liquidation_line.price_x18),
|
|
1455
|
+
asOfMs: server.estimated_liquidation_line.as_of_ms,
|
|
1456
|
+
},
|
|
1457
|
+
nextBeforeMs: server.next_before_ms,
|
|
1458
|
+
asOfMs: server.as_of_ms,
|
|
1459
|
+
dataQuality: server.data_quality,
|
|
1460
|
+
};
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
/**
|
|
1464
|
+
* Maps watcher observations; account previews are self-reported, not authenticated.
|
|
1465
|
+
* @param server - Service payload with its original wire fields.
|
|
1466
|
+
* @returns The visitor count, self-reported public account previews, and observation time.
|
|
1467
|
+
*/
|
|
1468
|
+
export function mapMobileSocialFeedWatchers(
|
|
1469
|
+
server: MobileServerSocialFeedWatchersResponse,
|
|
1470
|
+
): MobileSocialFeedWatchers {
|
|
1471
|
+
return {
|
|
1472
|
+
watcherCount: server.watcher_count,
|
|
1473
|
+
watcherPreview: server.watcher_preview.map(mapMobileSocialFeedAuthor),
|
|
1474
|
+
asOfMs: server.as_of_ms,
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
/**
|
|
1479
|
+
* Maps a page lease without inventing an observation timestamp.
|
|
1480
|
+
* @param server - Service payload with its original wire fields.
|
|
1481
|
+
* @returns Visitor count and public previews with heartbeat/lease durations in seconds, without an observation timestamp.
|
|
1482
|
+
*/
|
|
1483
|
+
export function mapMobileSocialFeedPresence(
|
|
1484
|
+
server: MobileServerSocialFeedPresenceResponse,
|
|
1485
|
+
): MobileSocialFeedPresence {
|
|
1486
|
+
return {
|
|
1487
|
+
watcherCount: server.watcher_count,
|
|
1488
|
+
watcherPreview: server.watcher_preview.map(mapMobileSocialFeedAuthor),
|
|
1489
|
+
heartbeatIntervalSeconds: server.heartbeat_interval_seconds,
|
|
1490
|
+
expiresInSeconds: server.expires_in_seconds,
|
|
1491
|
+
};
|
|
1492
|
+
}
|