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