@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/src/dataMappers.ts
CHANGED
|
@@ -11,39 +11,86 @@ import {
|
|
|
11
11
|
MobileFollowMutationResult,
|
|
12
12
|
MobileFollowSummary,
|
|
13
13
|
MobileIdentitySummary,
|
|
14
|
+
MobileNotificationCapabilities,
|
|
15
|
+
MobileNotificationInboxV2,
|
|
16
|
+
MobileNotificationPayloadV2,
|
|
14
17
|
MobileNotificationPreferenceScope,
|
|
15
18
|
MobileNotificationPreferences,
|
|
19
|
+
MobileNotificationRegistrationV2,
|
|
20
|
+
MobileNotificationRoute,
|
|
21
|
+
MobileNotificationSettings,
|
|
22
|
+
MobileNotificationSettingsV2,
|
|
23
|
+
MobileNotificationSubscriptions,
|
|
24
|
+
MobileNotificationSubscriptionsUpdate,
|
|
25
|
+
MobileProductEvent,
|
|
16
26
|
MobileProfileSearchPage,
|
|
17
27
|
MobileProfilesInclude,
|
|
18
28
|
MobilePublicProfile,
|
|
19
29
|
MobileRegisteredWallet,
|
|
30
|
+
MobileSocialFeedActionCandidate,
|
|
31
|
+
MobileSocialFeedActionMarker,
|
|
32
|
+
MobileSocialFeedActionResolutionResult,
|
|
20
33
|
MobileSocialFeedAuthor,
|
|
34
|
+
MobileSocialFeedCandle,
|
|
35
|
+
MobileSocialFeedCommentResult,
|
|
36
|
+
MobileSocialFeedCommentsPage,
|
|
37
|
+
MobileSocialFeedCompactCard,
|
|
38
|
+
MobileSocialFeedContentBase,
|
|
39
|
+
MobileSocialFeedDrawing,
|
|
40
|
+
MobileSocialFeedDrawingMutationResult,
|
|
41
|
+
MobileSocialFeedDrawingResult,
|
|
42
|
+
MobileSocialFeedHistoryMetrics,
|
|
43
|
+
MobileSocialFeedHistoryTake,
|
|
44
|
+
MobileSocialFeedImage,
|
|
21
45
|
MobileSocialFeedInteraction,
|
|
22
46
|
MobileSocialFeedItem,
|
|
23
47
|
MobileSocialFeedItemBase,
|
|
24
48
|
MobileSocialFeedItemPatch,
|
|
25
49
|
MobileSocialFeedItemResponse,
|
|
50
|
+
MobileSocialFeedLikeResult,
|
|
26
51
|
MobileSocialFeedListParams,
|
|
27
52
|
MobileSocialFeedMarket,
|
|
53
|
+
MobileSocialFeedMentionParams,
|
|
28
54
|
MobileSocialFeedPage,
|
|
29
55
|
MobileSocialFeedPnl,
|
|
56
|
+
MobileSocialFeedPositionAction,
|
|
30
57
|
MobileSocialFeedPositionCard,
|
|
58
|
+
MobileSocialFeedPositionChart,
|
|
59
|
+
MobileSocialFeedPositionHistory,
|
|
31
60
|
MobileSocialFeedPositionPatch,
|
|
61
|
+
MobileSocialFeedPositionResolutionResult,
|
|
62
|
+
MobileSocialFeedPositionsPage,
|
|
63
|
+
MobileSocialFeedPost,
|
|
64
|
+
MobileSocialFeedPresence,
|
|
65
|
+
MobileSocialFeedPublishablePosition,
|
|
32
66
|
MobileSocialFeedRankedPage,
|
|
33
67
|
MobileSocialFeedReadParams,
|
|
34
68
|
MobileSocialFeedReadSession,
|
|
69
|
+
MobileSocialFeedReply,
|
|
70
|
+
MobileSocialFeedTimelineEntry,
|
|
35
71
|
MobileSocialFeedTopTradersPage,
|
|
36
72
|
MobileSocialFeedTradeCard,
|
|
37
73
|
MobileSocialFeedTradeRow,
|
|
38
74
|
MobileSocialFeedTradeRowBase,
|
|
39
75
|
MobileSocialFeedTraderBadge,
|
|
76
|
+
MobileSocialFeedTradingContext,
|
|
77
|
+
MobileSocialFeedTradingTarget,
|
|
40
78
|
MobileSocialFeedUpdates,
|
|
79
|
+
MobileSocialFeedViewsResult,
|
|
80
|
+
MobileSocialFeedWatchers,
|
|
41
81
|
SearchMobileProfilesParams,
|
|
42
82
|
} from './types/clientTypes';
|
|
83
|
+
import { MobileUnsupportedFeedItemError } from './types/MobileUnsupportedFeedItemError';
|
|
84
|
+
import { MobileUnsupportedNotificationRouteError } from './types/MobileUnsupportedNotificationRouteError';
|
|
43
85
|
import {
|
|
44
86
|
MobileServerAvatarUploadResponse,
|
|
45
87
|
MobileServerFollowBatchResponse,
|
|
46
88
|
MobileServerFollowMutationResponse,
|
|
89
|
+
MobileServerSocialFeedCommentResponse,
|
|
90
|
+
MobileServerSocialFeedDrawingMutationResponse,
|
|
91
|
+
MobileServerSocialFeedLikeResponse,
|
|
92
|
+
MobileServerSocialFeedPresenceResponse,
|
|
93
|
+
MobileServerSocialFeedViewsResponse,
|
|
47
94
|
} from './types/serverExecuteTypes';
|
|
48
95
|
import {
|
|
49
96
|
MobileServerAvatarPreset,
|
|
@@ -51,38 +98,73 @@ import {
|
|
|
51
98
|
MobileServerFeedTrade,
|
|
52
99
|
MobileServerFollowSummary,
|
|
53
100
|
MobileServerIdentitySummary,
|
|
101
|
+
MobileServerNotificationPayloadV2,
|
|
54
102
|
MobileServerNotificationPreferenceScope,
|
|
55
103
|
MobileServerNotificationPreferences,
|
|
104
|
+
MobileServerNotificationRoute,
|
|
105
|
+
MobileServerNotificationSettings,
|
|
106
|
+
MobileServerProductEvent,
|
|
56
107
|
MobileServerProfile,
|
|
108
|
+
MobileServerSocialFeedActionCandidate,
|
|
109
|
+
MobileServerSocialFeedActionMarker,
|
|
57
110
|
MobileServerSocialFeedAuthor,
|
|
111
|
+
MobileServerSocialFeedCandle,
|
|
112
|
+
MobileServerSocialFeedCompactCard,
|
|
113
|
+
MobileServerSocialFeedContentBase,
|
|
114
|
+
MobileServerSocialFeedDrawing,
|
|
115
|
+
MobileServerSocialFeedHistoryMetrics,
|
|
116
|
+
MobileServerSocialFeedHistoryTake,
|
|
117
|
+
MobileServerSocialFeedImage,
|
|
58
118
|
MobileServerSocialFeedInteraction,
|
|
59
119
|
MobileServerSocialFeedItem,
|
|
60
120
|
MobileServerSocialFeedItemBase,
|
|
61
121
|
MobileServerSocialFeedItemPatch,
|
|
62
122
|
MobileServerSocialFeedMarket,
|
|
63
123
|
MobileServerSocialFeedPnl,
|
|
124
|
+
MobileServerSocialFeedPositionAction,
|
|
64
125
|
MobileServerSocialFeedPositionCard,
|
|
65
126
|
MobileServerSocialFeedPositionPatch,
|
|
127
|
+
MobileServerSocialFeedPost,
|
|
128
|
+
MobileServerSocialFeedPublishablePosition,
|
|
66
129
|
MobileServerSocialFeedReadSession,
|
|
130
|
+
MobileServerSocialFeedReply,
|
|
131
|
+
MobileServerSocialFeedTimelineEntry,
|
|
67
132
|
MobileServerSocialFeedTradeCard,
|
|
68
133
|
MobileServerSocialFeedTradeRow,
|
|
69
134
|
MobileServerSocialFeedTradeRowBase,
|
|
70
135
|
MobileServerSocialFeedTraderBadge,
|
|
136
|
+
MobileServerSocialFeedTradingContext,
|
|
137
|
+
MobileServerSocialFeedTradingTarget,
|
|
138
|
+
MobileSocialFeedMention,
|
|
71
139
|
} from './types/serverModelTypes';
|
|
72
140
|
import {
|
|
73
141
|
MobileServerFeedResponse,
|
|
74
142
|
MobileServerFollowListResponse,
|
|
143
|
+
MobileServerNotificationInboxV2Response,
|
|
144
|
+
MobileServerNotificationRegistrationV2Response,
|
|
145
|
+
MobileServerNotificationSettingsV2Response,
|
|
146
|
+
MobileServerNotificationSubscriptionsResponse,
|
|
75
147
|
MobileServerRegisteredWalletResponse,
|
|
76
148
|
MobileServerSearchProfilesResponse,
|
|
149
|
+
MobileServerSocialFeedActionResolutionResponse,
|
|
150
|
+
MobileServerSocialFeedCommentsResponse,
|
|
151
|
+
MobileServerSocialFeedDrawingResponse,
|
|
77
152
|
MobileServerSocialFeedItemResponse,
|
|
153
|
+
MobileServerSocialFeedPositionChartResponse,
|
|
154
|
+
MobileServerSocialFeedPositionHistoryResponse,
|
|
155
|
+
MobileServerSocialFeedPositionResolutionResponse,
|
|
156
|
+
MobileServerSocialFeedPositionsResponse,
|
|
78
157
|
MobileServerSocialFeedRankedResponse,
|
|
79
158
|
MobileServerSocialFeedResponse,
|
|
80
159
|
MobileServerSocialFeedTopTradersResponse,
|
|
81
160
|
MobileServerSocialFeedUpdatesResponse,
|
|
161
|
+
MobileServerSocialFeedWatchersResponse,
|
|
82
162
|
} from './types/serverQueryTypes';
|
|
83
163
|
import {
|
|
84
164
|
MobileServerFollowListRequest,
|
|
165
|
+
MobileServerNotificationSubscriptionsUpdate,
|
|
85
166
|
MobileServerProfilesInclude,
|
|
167
|
+
MobileServerRegisterExpoTokenV2Params,
|
|
86
168
|
MobileServerSearchProfilesRequest,
|
|
87
169
|
MobileServerSocialFeedListParams,
|
|
88
170
|
MobileServerSocialFeedReadParams,
|
|
@@ -111,6 +193,209 @@ export function mapMobileAvatarUpload(
|
|
|
111
193
|
};
|
|
112
194
|
}
|
|
113
195
|
|
|
196
|
+
/** Maps a saved notification registration to the client model without the response envelope.
|
|
197
|
+
* @param server - Registration payload.
|
|
198
|
+
* @returns Saved generation and capabilities.
|
|
199
|
+
*/
|
|
200
|
+
export function mapMobileNotificationRegistrationV2(
|
|
201
|
+
server: MobileServerNotificationRegistrationV2Response,
|
|
202
|
+
): MobileNotificationRegistrationV2 {
|
|
203
|
+
return {
|
|
204
|
+
registrationGeneration: server.registration_generation,
|
|
205
|
+
capabilities: {
|
|
206
|
+
payloadVersions: server.capabilities.payload_versions,
|
|
207
|
+
typeIds: server.capabilities.type_ids,
|
|
208
|
+
routes: server.capabilities.routes,
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** Maps a v2 capability declaration to the registration wire format.
|
|
214
|
+
* @param capabilities - Device-supported features.
|
|
215
|
+
* @returns V2-only registration capabilities.
|
|
216
|
+
*/
|
|
217
|
+
export function mapMobileNotificationCapabilitiesToServer(
|
|
218
|
+
capabilities: MobileNotificationCapabilities,
|
|
219
|
+
): MobileServerRegisterExpoTokenV2Params['capabilities'] {
|
|
220
|
+
return {
|
|
221
|
+
payload_versions: capabilities.payloadVersions,
|
|
222
|
+
type_ids: capabilities.typeIds,
|
|
223
|
+
routes: capabilities.routes,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** Maps complete notification settings to the client model.
|
|
228
|
+
* @param server - Saved settings.
|
|
229
|
+
* @returns CamelCase settings.
|
|
230
|
+
*/
|
|
231
|
+
export function mapMobileNotificationSettings(
|
|
232
|
+
server: MobileServerNotificationSettings,
|
|
233
|
+
): MobileNotificationSettings {
|
|
234
|
+
return {
|
|
235
|
+
myPositions: server.my_positions,
|
|
236
|
+
positionThresholds: server.position_thresholds,
|
|
237
|
+
myOrders: server.my_orders,
|
|
238
|
+
followingTrades: server.following_trades,
|
|
239
|
+
followingPosts: server.following_posts,
|
|
240
|
+
minTradeSizeUsd: server.min_trade_size_usd,
|
|
241
|
+
newFollowers: server.new_followers,
|
|
242
|
+
announcements: server.announcements,
|
|
243
|
+
discovery: server.discovery,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** Maps a complete replacement settings document to wire format.
|
|
248
|
+
* @param settings - Complete client settings.
|
|
249
|
+
* @returns Settings accepted by the service.
|
|
250
|
+
*/
|
|
251
|
+
export function mapMobileNotificationSettingsToServer(
|
|
252
|
+
settings: MobileNotificationSettings,
|
|
253
|
+
): MobileServerNotificationSettings {
|
|
254
|
+
return {
|
|
255
|
+
my_positions: settings.myPositions,
|
|
256
|
+
position_thresholds: settings.positionThresholds,
|
|
257
|
+
my_orders: settings.myOrders,
|
|
258
|
+
following_trades: settings.followingTrades,
|
|
259
|
+
following_posts: settings.followingPosts,
|
|
260
|
+
min_trade_size_usd: settings.minTradeSizeUsd,
|
|
261
|
+
new_followers: settings.newFollowers,
|
|
262
|
+
announcements: settings.announcements,
|
|
263
|
+
discovery: settings.discovery,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** Maps a revisioned settings response without the response envelope.
|
|
268
|
+
* @param server - Versioned settings payload.
|
|
269
|
+
* @returns Client settings and their revision.
|
|
270
|
+
*/
|
|
271
|
+
export function mapMobileNotificationSettingsV2(
|
|
272
|
+
server: MobileServerNotificationSettingsV2Response,
|
|
273
|
+
): MobileNotificationSettingsV2 {
|
|
274
|
+
return {
|
|
275
|
+
schemaVersion: server.schema_version,
|
|
276
|
+
revision: server.revision,
|
|
277
|
+
settings: mapMobileNotificationSettings(server.settings),
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** Maps wallet market subscriptions and Identity bells.
|
|
282
|
+
* @param server - Subscription payload.
|
|
283
|
+
* @returns Client subscription state without the response envelope.
|
|
284
|
+
*/
|
|
285
|
+
export function mapMobileNotificationSubscriptions(
|
|
286
|
+
server: MobileServerNotificationSubscriptionsResponse,
|
|
287
|
+
): MobileNotificationSubscriptions {
|
|
288
|
+
return {
|
|
289
|
+
revision: server.revision,
|
|
290
|
+
favoritesImported: server.favorites_imported,
|
|
291
|
+
marketIds: server.market_ids,
|
|
292
|
+
traderBells: server.trader_bells,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** Maps one subscription operation, explicitly nulling unused wire operations.
|
|
297
|
+
* @param update - Exactly one revision-guarded operation.
|
|
298
|
+
* @returns The complete signed inner operation fields.
|
|
299
|
+
*/
|
|
300
|
+
export function mapMobileNotificationSubscriptionsUpdateToServer(
|
|
301
|
+
update: MobileNotificationSubscriptionsUpdate,
|
|
302
|
+
): MobileServerNotificationSubscriptionsUpdate {
|
|
303
|
+
return {
|
|
304
|
+
expected_revision: update.expectedRevision,
|
|
305
|
+
trader_bell:
|
|
306
|
+
update.traderBell == null
|
|
307
|
+
? null
|
|
308
|
+
: {
|
|
309
|
+
subaccount: subaccountToHex(update.traderBell.subaccount),
|
|
310
|
+
enabled: update.traderBell.enabled,
|
|
311
|
+
},
|
|
312
|
+
market:
|
|
313
|
+
update.market == null
|
|
314
|
+
? null
|
|
315
|
+
: {
|
|
316
|
+
product_id: update.market.productId,
|
|
317
|
+
subscribed: update.market.subscribed,
|
|
318
|
+
},
|
|
319
|
+
import_markets: update.importMarkets ?? null,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** Maps an allowlisted notification destination.
|
|
324
|
+
* @param server - Named backend destination.
|
|
325
|
+
* @returns Client navigation data, never an arbitrary URL.
|
|
326
|
+
* @throws {MobileUnsupportedNotificationRouteError} If the service returns an unsupported route name.
|
|
327
|
+
*/
|
|
328
|
+
export function mapMobileNotificationRoute(
|
|
329
|
+
server: MobileServerNotificationRoute,
|
|
330
|
+
): MobileNotificationRoute {
|
|
331
|
+
const name = server.name;
|
|
332
|
+
switch (name) {
|
|
333
|
+
case 'market':
|
|
334
|
+
return { name: server.name, productId: server.product_id };
|
|
335
|
+
case 'profile':
|
|
336
|
+
return { name: server.name, subaccount: server.subaccount };
|
|
337
|
+
case 'portfolio':
|
|
338
|
+
return { name: server.name };
|
|
339
|
+
default:
|
|
340
|
+
throw new MobileUnsupportedNotificationRouteError(name satisfies never);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** Maps v2 push or inbox navigation data.
|
|
345
|
+
* @param server - Wire-format notification payload.
|
|
346
|
+
* @returns Client notification data.
|
|
347
|
+
* @throws {MobileUnsupportedNotificationRouteError} If the service returns an unsupported route name.
|
|
348
|
+
*/
|
|
349
|
+
export function mapMobileNotificationPayloadV2(
|
|
350
|
+
server: MobileServerNotificationPayloadV2,
|
|
351
|
+
): MobileNotificationPayloadV2 {
|
|
352
|
+
return {
|
|
353
|
+
payloadVersion: server.payload_version,
|
|
354
|
+
notificationId: server.notification_id,
|
|
355
|
+
recipientWallet: server.recipient_wallet,
|
|
356
|
+
typeId: server.type_id,
|
|
357
|
+
templateVersion: server.template_version,
|
|
358
|
+
route: mapMobileNotificationRoute(server.route),
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** Maps a private notification page without the response envelope.
|
|
363
|
+
* @param server - Newest-first inbox payload.
|
|
364
|
+
* @returns Client items, attribution flags, and the next cursor.
|
|
365
|
+
* @throws {MobileUnsupportedNotificationRouteError} If a notification has an unsupported route name.
|
|
366
|
+
*/
|
|
367
|
+
export function mapMobileNotificationInboxV2(
|
|
368
|
+
server: MobileServerNotificationInboxV2Response,
|
|
369
|
+
): MobileNotificationInboxV2 {
|
|
370
|
+
return {
|
|
371
|
+
notifications: server.notifications.map((item) => ({
|
|
372
|
+
notificationId: item.notification_id,
|
|
373
|
+
typeId: item.type_id,
|
|
374
|
+
data: mapMobileNotificationPayloadV2(item.data),
|
|
375
|
+
createdAt: item.created_at,
|
|
376
|
+
tradeWithin24h: item.trade_within_24h,
|
|
377
|
+
})),
|
|
378
|
+
nextCursor: server.next_cursor,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** Maps a typed analytics interaction, nulling unused wire fields.
|
|
383
|
+
* @param event - Event-specific client data.
|
|
384
|
+
* @returns Complete signed wire event.
|
|
385
|
+
*/
|
|
386
|
+
export function mapMobileProductEventToServer(
|
|
387
|
+
event: MobileProductEvent,
|
|
388
|
+
): MobileServerProductEvent {
|
|
389
|
+
return {
|
|
390
|
+
client_event_id: event.clientEventId,
|
|
391
|
+
event_name: event.eventName,
|
|
392
|
+
notification_id: event.notificationId ?? null,
|
|
393
|
+
occurred_at: event.occurredAt,
|
|
394
|
+
product_id: event.productId ?? null,
|
|
395
|
+
query: event.query ?? null,
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
|
|
114
399
|
/**
|
|
115
400
|
* Maps a client-side avatar selection to the signed wire payload; null clears the saved avatar.
|
|
116
401
|
*/
|
|
@@ -467,6 +752,13 @@ export function mapMobileSocialFeedPositionPatch(
|
|
|
467
752
|
leverage: server.leverage,
|
|
468
753
|
leverageAtMs: server.leverage_at_ms,
|
|
469
754
|
pnl: mapMobileSocialFeedPnl(server.pnl),
|
|
755
|
+
...(server.current_position === undefined
|
|
756
|
+
? {}
|
|
757
|
+
: {
|
|
758
|
+
currentPosition: mapMobileSocialFeedHistoryMetrics(
|
|
759
|
+
server.current_position,
|
|
760
|
+
),
|
|
761
|
+
}),
|
|
470
762
|
};
|
|
471
763
|
}
|
|
472
764
|
|
|
@@ -502,6 +794,29 @@ export function mapMobileSocialFeedInteraction(
|
|
|
502
794
|
};
|
|
503
795
|
}
|
|
504
796
|
|
|
797
|
+
/**
|
|
798
|
+
* Maps uploaded image metadata; bytes remain behind a protected GET.
|
|
799
|
+
* @param server - The service response.
|
|
800
|
+
* @returns The mapped feed image.
|
|
801
|
+
*/
|
|
802
|
+
export function mapMobileSocialFeedImage(
|
|
803
|
+
server: MobileServerSocialFeedImage,
|
|
804
|
+
): MobileSocialFeedImage {
|
|
805
|
+
return {
|
|
806
|
+
imageId: server.image_id,
|
|
807
|
+
url: server.url,
|
|
808
|
+
width: server.width,
|
|
809
|
+
height: server.height,
|
|
810
|
+
contentType: server.content_type,
|
|
811
|
+
byteSize: server.byte_size,
|
|
812
|
+
thumbnail: {
|
|
813
|
+
url: server.thumbnail.url,
|
|
814
|
+
width: server.thumbnail.width,
|
|
815
|
+
height: server.thumbnail.height,
|
|
816
|
+
},
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
|
|
505
820
|
/**
|
|
506
821
|
* Maps common item metadata and server capabilities.
|
|
507
822
|
* @param server - The service response.
|
|
@@ -513,7 +828,10 @@ export function mapMobileSocialFeedItemBase(
|
|
|
513
828
|
return {
|
|
514
829
|
id: server.id,
|
|
515
830
|
hasAnalysis: server.has_analysis,
|
|
516
|
-
drawing:
|
|
831
|
+
drawing:
|
|
832
|
+
server.drawing === null
|
|
833
|
+
? null
|
|
834
|
+
: mapMobileSocialFeedDrawing(server.drawing),
|
|
517
835
|
author: mapMobileSocialFeedAuthor(server.author),
|
|
518
836
|
createdAtMs: server.created_at_ms,
|
|
519
837
|
displayAtMs: server.display_at_ms,
|
|
@@ -528,29 +846,43 @@ export function mapMobileSocialFeedItemBase(
|
|
|
528
846
|
}
|
|
529
847
|
|
|
530
848
|
/**
|
|
531
|
-
* Maps
|
|
849
|
+
* Maps the content, position, interaction, and comment preview shared by posts and trade cards.
|
|
532
850
|
* @param server - The service response.
|
|
533
|
-
* @returns The mapped
|
|
851
|
+
* @returns The mapped shared content fields.
|
|
534
852
|
*/
|
|
535
|
-
export function
|
|
536
|
-
server:
|
|
537
|
-
):
|
|
853
|
+
export function mapMobileSocialFeedContentBase(
|
|
854
|
+
server: MobileServerSocialFeedContentBase,
|
|
855
|
+
): MobileSocialFeedContentBase {
|
|
538
856
|
return {
|
|
539
857
|
...mapMobileSocialFeedItemBase(server),
|
|
540
|
-
|
|
541
|
-
action: server.action,
|
|
858
|
+
images: server.images.map(mapMobileSocialFeedImage),
|
|
542
859
|
text: server.text,
|
|
543
860
|
mentions: server.mentions,
|
|
544
861
|
position: mapMobileSocialFeedPositionCard(server.position),
|
|
545
862
|
interaction: mapMobileSocialFeedInteraction(server.interaction),
|
|
546
863
|
commentPreview: {
|
|
547
|
-
items: server.comment_preview.items,
|
|
864
|
+
items: server.comment_preview.items.map(mapMobileSocialFeedReply),
|
|
548
865
|
totalCount: server.comment_preview.total_count,
|
|
549
866
|
nextCursor: server.comment_preview.next_cursor,
|
|
550
867
|
},
|
|
551
868
|
};
|
|
552
869
|
}
|
|
553
870
|
|
|
871
|
+
/**
|
|
872
|
+
* Maps a trade card, authored content, and position and interaction metadata.
|
|
873
|
+
* @param server - The service response.
|
|
874
|
+
* @returns The mapped social trade card.
|
|
875
|
+
*/
|
|
876
|
+
export function mapMobileSocialFeedTradeCard(
|
|
877
|
+
server: MobileServerSocialFeedTradeCard,
|
|
878
|
+
): MobileSocialFeedTradeCard {
|
|
879
|
+
return {
|
|
880
|
+
...mapMobileSocialFeedContentBase(server),
|
|
881
|
+
kind: server.kind,
|
|
882
|
+
action: server.action,
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
|
|
554
886
|
/**
|
|
555
887
|
* Maps historical trade facts with decimal execution prices and x18 quantities.
|
|
556
888
|
* @param server - The service response.
|
|
@@ -612,17 +944,28 @@ export function mapMobileSocialFeedTradeRow(
|
|
|
612
944
|
* Maps the item variant without mixing card and row fields.
|
|
613
945
|
* @param server - The service response.
|
|
614
946
|
* @returns The mapped social feed item.
|
|
947
|
+
* @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
|
|
615
948
|
*/
|
|
616
949
|
export function mapMobileSocialFeedItem(
|
|
617
950
|
server: MobileServerSocialFeedItem,
|
|
618
951
|
): MobileSocialFeedItem {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
:
|
|
952
|
+
const kind = server.kind;
|
|
953
|
+
switch (kind) {
|
|
954
|
+
case 'trade_card':
|
|
955
|
+
return mapMobileSocialFeedTradeCard(server);
|
|
956
|
+
case 'trade_row':
|
|
957
|
+
return mapMobileSocialFeedTradeRow(server);
|
|
958
|
+
case 'post':
|
|
959
|
+
return mapMobileSocialFeedPost(server);
|
|
960
|
+
case 'reply':
|
|
961
|
+
return mapMobileSocialFeedReply(server);
|
|
962
|
+
default:
|
|
963
|
+
throw new MobileUnsupportedFeedItemError(kind satisfies never);
|
|
964
|
+
}
|
|
622
965
|
}
|
|
623
966
|
|
|
624
967
|
/**
|
|
625
|
-
* Maps a
|
|
968
|
+
* Maps a reading session and its current idle expiration, preserving opaque credentials and cursors.
|
|
626
969
|
* @param server - The service response.
|
|
627
970
|
* @returns The mapped feed read session.
|
|
628
971
|
*/
|
|
@@ -633,10 +976,7 @@ export function mapMobileSocialFeedReadSession(
|
|
|
633
976
|
sessionId: server.session_id,
|
|
634
977
|
mode: server.mode,
|
|
635
978
|
expiresAtMs: server.expires_at_ms,
|
|
636
|
-
viewTracking: {
|
|
637
|
-
minVisibleRatio: server.view_tracking.min_visible_ratio,
|
|
638
|
-
minDurationMs: server.view_tracking.min_duration_ms,
|
|
639
|
-
},
|
|
979
|
+
viewTracking: { mode: server.view_tracking.mode },
|
|
640
980
|
updateCursor: server.update_cursor,
|
|
641
981
|
viewerToken: server.viewer_token,
|
|
642
982
|
};
|
|
@@ -646,6 +986,7 @@ export function mapMobileSocialFeedReadSession(
|
|
|
646
986
|
* Maps a fixed feed page without changing item order or pagination.
|
|
647
987
|
* @param server - The service response.
|
|
648
988
|
* @returns The mapped social feed page.
|
|
989
|
+
* @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
|
|
649
990
|
*/
|
|
650
991
|
export function mapMobileSocialFeedPage(
|
|
651
992
|
server: MobileServerSocialFeedResponse,
|
|
@@ -662,6 +1003,7 @@ export function mapMobileSocialFeedPage(
|
|
|
662
1003
|
* Maps a main feed page and its ranking version.
|
|
663
1004
|
* @param server - The service response.
|
|
664
1005
|
* @returns The mapped ranked feed page.
|
|
1006
|
+
* @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
|
|
665
1007
|
*/
|
|
666
1008
|
export function mapMobileSocialFeedRankedPage(
|
|
667
1009
|
server: MobileServerSocialFeedRankedResponse,
|
|
@@ -676,6 +1018,7 @@ export function mapMobileSocialFeedRankedPage(
|
|
|
676
1018
|
* Maps qualified trader items and their shared eligibility snapshot.
|
|
677
1019
|
* @param server - The service response.
|
|
678
1020
|
* @returns The mapped top traders feed page.
|
|
1021
|
+
* @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
|
|
679
1022
|
*/
|
|
680
1023
|
export function mapMobileSocialFeedTopTradersPage(
|
|
681
1024
|
server: MobileServerSocialFeedTopTradersResponse,
|
|
@@ -699,6 +1042,7 @@ export function mapMobileSocialFeedTopTradersPage(
|
|
|
699
1042
|
* Maps item details and the authorized reading session.
|
|
700
1043
|
* @param server - The service response.
|
|
701
1044
|
* @returns The mapped social feed item response.
|
|
1045
|
+
* @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
|
|
702
1046
|
*/
|
|
703
1047
|
export function mapMobileSocialFeedItemResponse(
|
|
704
1048
|
server: MobileServerSocialFeedItemResponse,
|
|
@@ -720,6 +1064,17 @@ export function mapMobileSocialFeedItemPatch(
|
|
|
720
1064
|
return {
|
|
721
1065
|
itemId: server.item_id,
|
|
722
1066
|
version: server.version,
|
|
1067
|
+
...(server.attached_position === undefined
|
|
1068
|
+
? {}
|
|
1069
|
+
: {
|
|
1070
|
+
attachedPosition:
|
|
1071
|
+
server.attached_position === null
|
|
1072
|
+
? null
|
|
1073
|
+
: mapMobileSocialFeedPositionCard(server.attached_position),
|
|
1074
|
+
}),
|
|
1075
|
+
...(server.attachment_status === undefined
|
|
1076
|
+
? {}
|
|
1077
|
+
: { attachmentStatus: server.attachment_status }),
|
|
723
1078
|
author: mapMobileSocialFeedAuthor(server.author),
|
|
724
1079
|
displayAtMs: server.display_at_ms,
|
|
725
1080
|
...(server.interaction === undefined
|
|
@@ -831,3 +1186,555 @@ export function mapMobileSocialFeedReadParamsToServer(
|
|
|
831
1186
|
viewer_token: params.viewerToken,
|
|
832
1187
|
};
|
|
833
1188
|
}
|
|
1189
|
+
|
|
1190
|
+
/**
|
|
1191
|
+
* Maps a mention for signing without changing the text or offsets.
|
|
1192
|
+
* @param params - Caller-provided mention and original text offsets.
|
|
1193
|
+
* @returns The wire-format mention, preserving the original label and code-point offsets.
|
|
1194
|
+
* @throws {Error} If the owner is not a 20-byte address or the subaccount name cannot be encoded in 12 bytes.
|
|
1195
|
+
*/
|
|
1196
|
+
export function mapMobileSocialFeedMentionToServer(
|
|
1197
|
+
params: MobileSocialFeedMentionParams,
|
|
1198
|
+
): MobileSocialFeedMention {
|
|
1199
|
+
return {
|
|
1200
|
+
subaccount: subaccountToHex(params.subaccount),
|
|
1201
|
+
start: params.start,
|
|
1202
|
+
end: params.end,
|
|
1203
|
+
label: params.label,
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
/**
|
|
1208
|
+
* Preserves parsed drawing data, including false and zero.
|
|
1209
|
+
* @param server - Service payload with its original wire fields.
|
|
1210
|
+
* @returns The original parsed drawing data and its creation/update timestamps in milliseconds.
|
|
1211
|
+
*/
|
|
1212
|
+
export function mapMobileSocialFeedDrawing(
|
|
1213
|
+
server: MobileServerSocialFeedDrawing,
|
|
1214
|
+
): MobileSocialFeedDrawing {
|
|
1215
|
+
return {
|
|
1216
|
+
data: server.data,
|
|
1217
|
+
createdAtMs: server.created_at_ms,
|
|
1218
|
+
updatedAtMs: server.updated_at_ms,
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* Maps a nonrecursive root preview, retaining nullable position visibility.
|
|
1224
|
+
* @param server - Service payload with its original wire fields.
|
|
1225
|
+
* @returns A nonrecursive preview with a nullable position and notional retained as an x18 BigNumber.
|
|
1226
|
+
*/
|
|
1227
|
+
export function mapMobileSocialFeedCompactCard(
|
|
1228
|
+
server: MobileServerSocialFeedCompactCard,
|
|
1229
|
+
): MobileSocialFeedCompactCard {
|
|
1230
|
+
return {
|
|
1231
|
+
id: server.id,
|
|
1232
|
+
author: mapMobileSocialFeedAuthor(server.author),
|
|
1233
|
+
textExcerpt: server.text_excerpt,
|
|
1234
|
+
position:
|
|
1235
|
+
server.position === null
|
|
1236
|
+
? null
|
|
1237
|
+
: {
|
|
1238
|
+
positionId: server.position.position_id,
|
|
1239
|
+
market: mapMobileSocialFeedMarket(server.position.market),
|
|
1240
|
+
direction: server.position.direction,
|
|
1241
|
+
state: server.position.state,
|
|
1242
|
+
notional: toBigNumber(server.position.notional_x18),
|
|
1243
|
+
},
|
|
1244
|
+
hasAnalysis: server.has_analysis,
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
/**
|
|
1249
|
+
* Maps an authored post and its readable comments and drawing.
|
|
1250
|
+
* @param server - Service payload with its original wire fields.
|
|
1251
|
+
* @returns A post with its unchanged text and mentions, mapped position, drawing, interactions, and reply preview.
|
|
1252
|
+
*/
|
|
1253
|
+
export function mapMobileSocialFeedPost(
|
|
1254
|
+
server: MobileServerSocialFeedPost,
|
|
1255
|
+
): MobileSocialFeedPost {
|
|
1256
|
+
return {
|
|
1257
|
+
...mapMobileSocialFeedContentBase(server),
|
|
1258
|
+
kind: server.kind,
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
/**
|
|
1263
|
+
* Maps reply visibility without treating an unavailable attachment as an absent one.
|
|
1264
|
+
* @param server - Service payload with its original wire fields.
|
|
1265
|
+
* @returns A reply preserving omitted reply targets, nullable attachments, and the separate attachment visibility status.
|
|
1266
|
+
*/
|
|
1267
|
+
export function mapMobileSocialFeedReply(
|
|
1268
|
+
server: MobileServerSocialFeedReply,
|
|
1269
|
+
): MobileSocialFeedReply {
|
|
1270
|
+
return {
|
|
1271
|
+
...mapMobileSocialFeedItemBase(server),
|
|
1272
|
+
kind: server.kind,
|
|
1273
|
+
images: server.images.map(mapMobileSocialFeedImage),
|
|
1274
|
+
text: server.text,
|
|
1275
|
+
mentions: server.mentions,
|
|
1276
|
+
rootItemId: server.root_item_id,
|
|
1277
|
+
...(server.reply_to_item_id === undefined
|
|
1278
|
+
? {}
|
|
1279
|
+
: { replyToItemId: server.reply_to_item_id }),
|
|
1280
|
+
replyToAuthor:
|
|
1281
|
+
server.reply_to_author === null
|
|
1282
|
+
? null
|
|
1283
|
+
: mapMobileSocialFeedAuthor(server.reply_to_author),
|
|
1284
|
+
attachedPosition:
|
|
1285
|
+
server.attached_position === null
|
|
1286
|
+
? null
|
|
1287
|
+
: mapMobileSocialFeedPositionCard(server.attached_position),
|
|
1288
|
+
attachmentStatus: server.attachment_status,
|
|
1289
|
+
original: mapMobileSocialFeedCompactCard(server.original),
|
|
1290
|
+
interaction: mapMobileSocialFeedInteraction(server.interaction),
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
/**
|
|
1295
|
+
* Maps current eligibility hints without implying caller ownership.
|
|
1296
|
+
* @param server - Service payload with its original wire fields.
|
|
1297
|
+
* @returns A position with current publication, attachment, and drawing eligibility hints and an unavailable reason.
|
|
1298
|
+
*/
|
|
1299
|
+
export function mapMobileSocialFeedPublishablePosition(
|
|
1300
|
+
server: MobileServerSocialFeedPublishablePosition,
|
|
1301
|
+
): MobileSocialFeedPublishablePosition {
|
|
1302
|
+
return {
|
|
1303
|
+
position: mapMobileSocialFeedPositionCard(server.position),
|
|
1304
|
+
canPublish: server.can_publish,
|
|
1305
|
+
canAttachToComment: server.can_attach_to_comment,
|
|
1306
|
+
canDrawAnalysis: server.can_draw_analysis,
|
|
1307
|
+
unavailableReason: server.unavailable_reason,
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* Maps all order action identifiers and eligibility hints.
|
|
1313
|
+
* @param server - Service payload with its original wire fields.
|
|
1314
|
+
* @returns Trusted action and position identifiers, action kind, publication eligibility, and an unavailable reason.
|
|
1315
|
+
*/
|
|
1316
|
+
export function mapMobileSocialFeedActionCandidate(
|
|
1317
|
+
server: MobileServerSocialFeedActionCandidate,
|
|
1318
|
+
): MobileSocialFeedActionCandidate {
|
|
1319
|
+
return {
|
|
1320
|
+
actionId: server.action_id,
|
|
1321
|
+
positionId: server.position_id,
|
|
1322
|
+
action: server.action,
|
|
1323
|
+
canPublish: server.can_publish,
|
|
1324
|
+
unavailableReason: server.unavailable_reason,
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
/**
|
|
1329
|
+
* Maps history risk prices to decimals while retaining funding amounts in x18 units.
|
|
1330
|
+
* @param server - Service payload with its original wire fields.
|
|
1331
|
+
* @returns Nullable decimal liquidation price and x18 funding PnL, with their independent quality and observation metadata.
|
|
1332
|
+
*/
|
|
1333
|
+
export function mapMobileSocialFeedHistoryMetrics(
|
|
1334
|
+
server: MobileServerSocialFeedHistoryMetrics,
|
|
1335
|
+
): MobileSocialFeedHistoryMetrics {
|
|
1336
|
+
return {
|
|
1337
|
+
estimatedLiquidationPrice: removeDecimals(
|
|
1338
|
+
server.estimated_liquidation_price_x18,
|
|
1339
|
+
),
|
|
1340
|
+
liquidationPriceQuality: server.liquidation_price_quality,
|
|
1341
|
+
liquidationPriceAsOfMs: server.liquidation_price_as_of_ms,
|
|
1342
|
+
fundingPnl:
|
|
1343
|
+
server.funding_pnl_x18 === null
|
|
1344
|
+
? null
|
|
1345
|
+
: toBigNumber(server.funding_pnl_x18),
|
|
1346
|
+
fundingQuality: server.funding_quality,
|
|
1347
|
+
fundingAsOfMs: server.funding_as_of_ms,
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
/**
|
|
1352
|
+
* Maps action prices independently; all amounts and quantities retain x18 units.
|
|
1353
|
+
* @param server - Service payload with its original wire fields.
|
|
1354
|
+
* @returns An action with decimal prices, x18 quantities/amounts, and independently nullable financial facts.
|
|
1355
|
+
*/
|
|
1356
|
+
export function mapMobileSocialFeedPositionAction(
|
|
1357
|
+
server: MobileServerSocialFeedPositionAction,
|
|
1358
|
+
): MobileSocialFeedPositionAction {
|
|
1359
|
+
return {
|
|
1360
|
+
id: server.id,
|
|
1361
|
+
positionId: server.position_id,
|
|
1362
|
+
action: server.action,
|
|
1363
|
+
direction: server.direction,
|
|
1364
|
+
marginMode: server.margin_mode,
|
|
1365
|
+
quantityBefore: toBigNumber(server.quantity_before_x18),
|
|
1366
|
+
quantityAfter: toBigNumber(server.quantity_after_x18),
|
|
1367
|
+
executedQuantity: toBigNumber(server.executed_quantity_x18),
|
|
1368
|
+
executedNotional:
|
|
1369
|
+
server.executed_notional_x18 === null
|
|
1370
|
+
? null
|
|
1371
|
+
: toBigNumber(server.executed_notional_x18),
|
|
1372
|
+
averagePrice: removeDecimals(server.average_price_x18),
|
|
1373
|
+
entryPriceBefore: removeDecimals(server.entry_price_before_x18),
|
|
1374
|
+
liquidationOraclePrice: removeDecimals(server.liquidation_oracle_price_x18),
|
|
1375
|
+
liquidationNotional:
|
|
1376
|
+
server.liquidation_notional_x18 === null
|
|
1377
|
+
? null
|
|
1378
|
+
: toBigNumber(server.liquidation_notional_x18),
|
|
1379
|
+
realizedPnlDelta:
|
|
1380
|
+
server.realized_pnl_delta_x18 === null
|
|
1381
|
+
? null
|
|
1382
|
+
: toBigNumber(server.realized_pnl_delta_x18),
|
|
1383
|
+
leverage: server.leverage,
|
|
1384
|
+
leverageAtMs: server.leverage_at_ms,
|
|
1385
|
+
firstEventAtMs: server.first_event_at_ms,
|
|
1386
|
+
lastEventAtMs: server.last_event_at_ms,
|
|
1387
|
+
version: server.version,
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
/**
|
|
1392
|
+
* Maps a trusted target without treating the viewing account as authenticated.
|
|
1393
|
+
* @param server - Service payload with its original wire fields.
|
|
1394
|
+
* @returns A trading target retaining distinct identity/trading subaccounts, margin mode, and observation time.
|
|
1395
|
+
*/
|
|
1396
|
+
export function mapMobileSocialFeedTradingTarget(
|
|
1397
|
+
server: MobileServerSocialFeedTradingTarget,
|
|
1398
|
+
): MobileSocialFeedTradingTarget {
|
|
1399
|
+
return {
|
|
1400
|
+
positionId: server.position_id,
|
|
1401
|
+
identitySubaccount: server.identity_subaccount,
|
|
1402
|
+
tradingSubaccount: server.trading_subaccount,
|
|
1403
|
+
productId: server.product_id,
|
|
1404
|
+
marginMode: server.margin_mode,
|
|
1405
|
+
isoSubaccountName: server.iso_subaccount_name,
|
|
1406
|
+
direction: server.direction,
|
|
1407
|
+
stateAsOfMs: server.state_as_of_ms,
|
|
1408
|
+
};
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
/**
|
|
1412
|
+
* Maps viewing-account trading hints.
|
|
1413
|
+
* @param server - Service payload with its original wire fields.
|
|
1414
|
+
* @returns Trading hints with ordered target candidates, nullable viewer position, and the current reduction hint.
|
|
1415
|
+
*/
|
|
1416
|
+
export function mapMobileSocialFeedTradingContext(
|
|
1417
|
+
server: MobileServerSocialFeedTradingContext,
|
|
1418
|
+
): MobileSocialFeedTradingContext {
|
|
1419
|
+
return {
|
|
1420
|
+
productId: server.product_id,
|
|
1421
|
+
suggestedDirection: server.suggested_direction,
|
|
1422
|
+
resolution: server.resolution,
|
|
1423
|
+
candidates: server.candidates.map(mapMobileSocialFeedTradingTarget),
|
|
1424
|
+
viewerPositionId: server.viewer_position_id,
|
|
1425
|
+
canReduce: server.can_reduce,
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
/**
|
|
1430
|
+
* Converts OHLC prices to decimals but preserves base-asset volume in x18.
|
|
1431
|
+
* @param server - Service payload with its original wire fields.
|
|
1432
|
+
* @returns A candle with decimal OHLC BigNumbers, base-asset volume retained in x18, and its timestamp in milliseconds.
|
|
1433
|
+
*/
|
|
1434
|
+
export function mapMobileSocialFeedCandle(
|
|
1435
|
+
server: MobileServerSocialFeedCandle,
|
|
1436
|
+
): MobileSocialFeedCandle {
|
|
1437
|
+
return {
|
|
1438
|
+
timestampMs: server.timestamp_ms,
|
|
1439
|
+
open: removeDecimals(server.open_x18),
|
|
1440
|
+
high: removeDecimals(server.high_x18),
|
|
1441
|
+
low: removeDecimals(server.low_x18),
|
|
1442
|
+
close: removeDecimals(server.close_x18),
|
|
1443
|
+
volume: toBigNumber(server.volume_x18),
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
/**
|
|
1448
|
+
* Maps markers without replacing unknown Oracle prices with execution prices.
|
|
1449
|
+
* @param server - Service payload with its original wire fields.
|
|
1450
|
+
* @returns An action marker with its original price basis and a nullable decimal price, without substituting another source.
|
|
1451
|
+
*/
|
|
1452
|
+
export function mapMobileSocialFeedActionMarker(
|
|
1453
|
+
server: MobileServerSocialFeedActionMarker,
|
|
1454
|
+
): MobileSocialFeedActionMarker {
|
|
1455
|
+
return {
|
|
1456
|
+
actionId: server.action_id,
|
|
1457
|
+
timestampMs: server.timestamp_ms,
|
|
1458
|
+
price: removeDecimals(server.price_x18),
|
|
1459
|
+
action: server.action,
|
|
1460
|
+
direction: server.direction,
|
|
1461
|
+
priceBasis: server.price_basis,
|
|
1462
|
+
};
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
/**
|
|
1466
|
+
* Maps selected-account open positions.
|
|
1467
|
+
* @param server - Service payload with its original wire fields.
|
|
1468
|
+
* @returns Mapped position candidates with the original nullable cursor and observation time.
|
|
1469
|
+
*/
|
|
1470
|
+
export function mapMobileSocialFeedPositionsPage(
|
|
1471
|
+
server: MobileServerSocialFeedPositionsResponse,
|
|
1472
|
+
): MobileSocialFeedPositionsPage {
|
|
1473
|
+
return {
|
|
1474
|
+
positions: server.positions.map(mapMobileSocialFeedPublishablePosition),
|
|
1475
|
+
nextCursor: server.next_cursor,
|
|
1476
|
+
asOfMs: server.as_of_ms,
|
|
1477
|
+
};
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
/**
|
|
1481
|
+
* Maps normal empty and ambiguous command results.
|
|
1482
|
+
* @param server - Service payload with its original wire fields.
|
|
1483
|
+
* @returns The command resolution, nullable market, position candidates, and original reason for an empty result.
|
|
1484
|
+
*/
|
|
1485
|
+
export function mapMobileSocialFeedPositionResolutionResult(
|
|
1486
|
+
server: MobileServerSocialFeedPositionResolutionResponse,
|
|
1487
|
+
): MobileSocialFeedPositionResolutionResult {
|
|
1488
|
+
return {
|
|
1489
|
+
resolution: server.resolution,
|
|
1490
|
+
product:
|
|
1491
|
+
server.product === null
|
|
1492
|
+
? null
|
|
1493
|
+
: mapMobileSocialFeedMarket(server.product),
|
|
1494
|
+
candidates: server.candidates.map(mapMobileSocialFeedPublishablePosition),
|
|
1495
|
+
reason: server.reason,
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
/**
|
|
1500
|
+
* Preserves pending order projection without inventing action candidates.
|
|
1501
|
+
* @param server - Service payload with its original wire fields.
|
|
1502
|
+
* @returns The original order digest, ready/pending state, mapped actions, and observation time.
|
|
1503
|
+
*/
|
|
1504
|
+
export function mapMobileSocialFeedActionResolutionResult(
|
|
1505
|
+
server: MobileServerSocialFeedActionResolutionResponse,
|
|
1506
|
+
): MobileSocialFeedActionResolutionResult {
|
|
1507
|
+
return {
|
|
1508
|
+
orderDigest: server.order_digest,
|
|
1509
|
+
resolution: server.resolution,
|
|
1510
|
+
actions: server.actions.map(mapMobileSocialFeedActionCandidate),
|
|
1511
|
+
asOfMs: server.as_of_ms,
|
|
1512
|
+
};
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
/**
|
|
1516
|
+
* Distinguishes no drawing from falsy drawing data.
|
|
1517
|
+
* @param server - Service payload with its original wire fields.
|
|
1518
|
+
* @returns The parent item ID/version and a nullable drawing, retaining false or zero drawing data.
|
|
1519
|
+
*/
|
|
1520
|
+
export function mapMobileSocialFeedDrawingResult(
|
|
1521
|
+
server: MobileServerSocialFeedDrawingResponse,
|
|
1522
|
+
): MobileSocialFeedDrawingResult {
|
|
1523
|
+
return {
|
|
1524
|
+
itemId: server.item_id,
|
|
1525
|
+
itemVersion: server.item_version,
|
|
1526
|
+
drawing:
|
|
1527
|
+
server.drawing === null
|
|
1528
|
+
? null
|
|
1529
|
+
: mapMobileSocialFeedDrawing(server.drawing),
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
/**
|
|
1534
|
+
* Maps a saved drawing after creation or replacement.
|
|
1535
|
+
* @param server - Successful drawing mutation response.
|
|
1536
|
+
* @returns The parent item ID/version and non-null saved drawing.
|
|
1537
|
+
*/
|
|
1538
|
+
export function mapMobileSocialFeedDrawingMutationResult(
|
|
1539
|
+
server: MobileServerSocialFeedDrawingMutationResponse,
|
|
1540
|
+
): MobileSocialFeedDrawingMutationResult {
|
|
1541
|
+
return {
|
|
1542
|
+
itemId: server.item_id,
|
|
1543
|
+
itemVersion: server.item_version,
|
|
1544
|
+
drawing: mapMobileSocialFeedDrawing(server.drawing),
|
|
1545
|
+
};
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
/**
|
|
1549
|
+
* Maps bidirectional comments and the actual returned session.
|
|
1550
|
+
* @param server - Service payload with its original wire fields.
|
|
1551
|
+
* @returns Mapped replies, total count, bidirectional cursors, nullable anchor, and the actual reading session.
|
|
1552
|
+
*/
|
|
1553
|
+
export function mapMobileSocialFeedCommentsPage(
|
|
1554
|
+
server: MobileServerSocialFeedCommentsResponse,
|
|
1555
|
+
): MobileSocialFeedCommentsPage {
|
|
1556
|
+
return {
|
|
1557
|
+
comments: server.comments.map(mapMobileSocialFeedReply),
|
|
1558
|
+
totalCount: server.total_count,
|
|
1559
|
+
nextCursor: server.next_cursor,
|
|
1560
|
+
previousCursor: server.previous_cursor,
|
|
1561
|
+
anchorReplyId: server.anchor_reply_id,
|
|
1562
|
+
readSession: mapMobileSocialFeedReadSession(server.read_session),
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
/**
|
|
1567
|
+
* Maps atomic reply publication without inventing a reading session.
|
|
1568
|
+
* @param server - Service payload with its original wire fields.
|
|
1569
|
+
* @returns The created reply and authoritative root comment count, without a fabricated reading session.
|
|
1570
|
+
*/
|
|
1571
|
+
export function mapMobileSocialFeedCommentResult(
|
|
1572
|
+
server: MobileServerSocialFeedCommentResponse,
|
|
1573
|
+
): MobileSocialFeedCommentResult {
|
|
1574
|
+
return {
|
|
1575
|
+
comment: mapMobileSocialFeedReply(server.comment),
|
|
1576
|
+
rootCommentCount: server.root_comment_count,
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
/**
|
|
1581
|
+
* Maps authoritative like state and count.
|
|
1582
|
+
* @param server - Service payload with its original wire fields.
|
|
1583
|
+
* @returns The applied like state, authoritative count, and item ID/version after the mutation.
|
|
1584
|
+
*/
|
|
1585
|
+
export function mapMobileSocialFeedLikeResult(
|
|
1586
|
+
server: MobileServerSocialFeedLikeResponse,
|
|
1587
|
+
): MobileSocialFeedLikeResult {
|
|
1588
|
+
return {
|
|
1589
|
+
itemId: server.item_id,
|
|
1590
|
+
isLiked: server.is_liked,
|
|
1591
|
+
likeCount: server.like_count,
|
|
1592
|
+
version: server.version,
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
/**
|
|
1597
|
+
* Maps exposure deduplication results without adding timestamps.
|
|
1598
|
+
* @param server - Service payload with its original wire fields.
|
|
1599
|
+
* @returns Newly accepted and duplicate item ID lists without inventing an observation timestamp.
|
|
1600
|
+
*/
|
|
1601
|
+
export function mapMobileSocialFeedViewsResult(
|
|
1602
|
+
server: MobileServerSocialFeedViewsResponse,
|
|
1603
|
+
): MobileSocialFeedViewsResult {
|
|
1604
|
+
return {
|
|
1605
|
+
acceptedItemIds: server.accepted_item_ids,
|
|
1606
|
+
duplicateItemIds: server.duplicate_item_ids,
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
/**
|
|
1611
|
+
* Maps a published history take without treating unknown kinds as posts.
|
|
1612
|
+
* @param server - The published service item.
|
|
1613
|
+
* @returns The mapped post or trade card.
|
|
1614
|
+
* @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported take kind.
|
|
1615
|
+
*/
|
|
1616
|
+
export function mapMobileSocialFeedHistoryTake(
|
|
1617
|
+
server: MobileServerSocialFeedHistoryTake,
|
|
1618
|
+
): MobileSocialFeedHistoryTake {
|
|
1619
|
+
const kind = server.kind;
|
|
1620
|
+
switch (kind) {
|
|
1621
|
+
case 'trade_card':
|
|
1622
|
+
return mapMobileSocialFeedTradeCard(server);
|
|
1623
|
+
case 'post':
|
|
1624
|
+
return mapMobileSocialFeedPost(server);
|
|
1625
|
+
default:
|
|
1626
|
+
throw new MobileUnsupportedFeedItemError(kind satisfies never);
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
/**
|
|
1631
|
+
* Maps a historical action or published take while preserving its discriminant.
|
|
1632
|
+
* @param server - The service timeline entry.
|
|
1633
|
+
* @returns The mapped action or take entry.
|
|
1634
|
+
* @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported entry or take kind.
|
|
1635
|
+
*/
|
|
1636
|
+
export function mapMobileSocialFeedTimelineEntry(
|
|
1637
|
+
server: MobileServerSocialFeedTimelineEntry,
|
|
1638
|
+
): MobileSocialFeedTimelineEntry {
|
|
1639
|
+
const kind = server.kind;
|
|
1640
|
+
switch (kind) {
|
|
1641
|
+
case 'action':
|
|
1642
|
+
return {
|
|
1643
|
+
kind,
|
|
1644
|
+
action: mapMobileSocialFeedPositionAction(server.action),
|
|
1645
|
+
relatedItemId: server.related_item_id,
|
|
1646
|
+
relatedTake:
|
|
1647
|
+
server.related_take === null
|
|
1648
|
+
? null
|
|
1649
|
+
: mapMobileSocialFeedTradeCard(server.related_take),
|
|
1650
|
+
};
|
|
1651
|
+
case 'take':
|
|
1652
|
+
return {
|
|
1653
|
+
kind,
|
|
1654
|
+
item: mapMobileSocialFeedHistoryTake(server.item),
|
|
1655
|
+
};
|
|
1656
|
+
default:
|
|
1657
|
+
throw new MobileUnsupportedFeedItemError(kind satisfies never);
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
/**
|
|
1662
|
+
* Maps full history, preserving action/take order, association, and null facts.
|
|
1663
|
+
* @param server - Service payload with its original wire fields.
|
|
1664
|
+
* @returns Position metrics, ordered action/take timeline, summary, cursor, quality, reading session, and trading hints.
|
|
1665
|
+
* @throws {MobileUnsupportedFeedItemError} If a timeline entry or take has an unsupported kind.
|
|
1666
|
+
*/
|
|
1667
|
+
export function mapMobileSocialFeedPositionHistory(
|
|
1668
|
+
server: MobileServerSocialFeedPositionHistoryResponse,
|
|
1669
|
+
): MobileSocialFeedPositionHistory {
|
|
1670
|
+
return {
|
|
1671
|
+
position: {
|
|
1672
|
+
...mapMobileSocialFeedPositionCard(server.position),
|
|
1673
|
+
...mapMobileSocialFeedHistoryMetrics(server.position),
|
|
1674
|
+
},
|
|
1675
|
+
summary: {
|
|
1676
|
+
actionCount: server.summary.action_count,
|
|
1677
|
+
takeCount: server.summary.take_count,
|
|
1678
|
+
},
|
|
1679
|
+
timeline: server.timeline.map(mapMobileSocialFeedTimelineEntry),
|
|
1680
|
+
nextCursor: server.next_cursor,
|
|
1681
|
+
historyQuality: server.history_quality,
|
|
1682
|
+
readSession: mapMobileSocialFeedReadSession(server.read_session),
|
|
1683
|
+
tradingContext: mapMobileSocialFeedTradingContext(server.trading_context),
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
/**
|
|
1688
|
+
* Maps candles and independent price sources, preserving explicit nulls.
|
|
1689
|
+
* @param server - Service payload with its original wire fields.
|
|
1690
|
+
* @returns Decimal-price candles and markers with x18 volume, a nullable liquidation line, and paging/quality metadata.
|
|
1691
|
+
*/
|
|
1692
|
+
export function mapMobileSocialFeedPositionChart(
|
|
1693
|
+
server: MobileServerSocialFeedPositionChartResponse,
|
|
1694
|
+
): MobileSocialFeedPositionChart {
|
|
1695
|
+
return {
|
|
1696
|
+
candles: server.candles.map(mapMobileSocialFeedCandle),
|
|
1697
|
+
actionMarkers: server.action_markers.map(mapMobileSocialFeedActionMarker),
|
|
1698
|
+
estimatedLiquidationLine:
|
|
1699
|
+
server.estimated_liquidation_line === null
|
|
1700
|
+
? null
|
|
1701
|
+
: {
|
|
1702
|
+
price: removeDecimals(server.estimated_liquidation_line.price_x18),
|
|
1703
|
+
asOfMs: server.estimated_liquidation_line.as_of_ms,
|
|
1704
|
+
},
|
|
1705
|
+
nextBeforeMs: server.next_before_ms,
|
|
1706
|
+
asOfMs: server.as_of_ms,
|
|
1707
|
+
dataQuality: server.data_quality,
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
/**
|
|
1712
|
+
* Maps watcher observations; account previews are self-reported, not authenticated.
|
|
1713
|
+
* @param server - Service payload with its original wire fields.
|
|
1714
|
+
* @returns The visitor count, self-reported public account previews, and observation time.
|
|
1715
|
+
*/
|
|
1716
|
+
export function mapMobileSocialFeedWatchers(
|
|
1717
|
+
server: MobileServerSocialFeedWatchersResponse,
|
|
1718
|
+
): MobileSocialFeedWatchers {
|
|
1719
|
+
return {
|
|
1720
|
+
watcherCount: server.watcher_count,
|
|
1721
|
+
watcherPreview: server.watcher_preview.map(mapMobileSocialFeedAuthor),
|
|
1722
|
+
asOfMs: server.as_of_ms,
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
/**
|
|
1727
|
+
* Maps a page lease without inventing an observation timestamp.
|
|
1728
|
+
* @param server - Service payload with its original wire fields.
|
|
1729
|
+
* @returns Visitor count and public previews with heartbeat/lease durations in seconds, without an observation timestamp.
|
|
1730
|
+
*/
|
|
1731
|
+
export function mapMobileSocialFeedPresence(
|
|
1732
|
+
server: MobileServerSocialFeedPresenceResponse,
|
|
1733
|
+
): MobileSocialFeedPresence {
|
|
1734
|
+
return {
|
|
1735
|
+
watcherCount: server.watcher_count,
|
|
1736
|
+
watcherPreview: server.watcher_preview.map(mapMobileSocialFeedAuthor),
|
|
1737
|
+
heartbeatIntervalSeconds: server.heartbeat_interval_seconds,
|
|
1738
|
+
expiresInSeconds: server.expires_in_seconds,
|
|
1739
|
+
};
|
|
1740
|
+
}
|