@nadohq/mobile-client 0.63.0 → 0.65.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/README.md +20 -2
  2. package/dist/{MobileClient-aDxiM_Kf.cjs → MobileClient-CfVZXTcz.cjs} +298 -1
  3. package/dist/MobileClient-CfVZXTcz.cjs.map +1 -0
  4. package/dist/MobileClient.cjs +1 -1
  5. package/dist/MobileClient.d.cts +173 -7
  6. package/dist/MobileClient.d.cts.map +1 -1
  7. package/dist/MobileClient.d.ts +173 -7
  8. package/dist/MobileClient.d.ts.map +1 -1
  9. package/dist/MobileClient.js +298 -1
  10. package/dist/MobileClient.js.map +1 -1
  11. package/dist/{MobileServerFailureError-Dd3c6P_Z.d.ts → MobileServerFailureError-BZVwlsMg.d.ts} +3 -3
  12. package/dist/{MobileServerFailureError-Dd3c6P_Z.d.ts.map → MobileServerFailureError-BZVwlsMg.d.ts.map} +1 -1
  13. package/dist/{MobileServerFailureError-Bpa_WA9f.d.cts → MobileServerFailureError-CbtK8kD4.d.cts} +3 -3
  14. package/dist/{MobileServerFailureError-Bpa_WA9f.d.cts.map → MobileServerFailureError-CbtK8kD4.d.cts.map} +1 -1
  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/{buildSignedMobileRequest-NHbMAPzd.d.cts → buildSignedMobileRequest-C1v0flCR.d.cts} +2 -2
  20. package/dist/{buildSignedMobileRequest-NHbMAPzd.d.cts.map → buildSignedMobileRequest-C1v0flCR.d.cts.map} +1 -1
  21. package/dist/{buildSignedMobileRequest-Cb1T74xV.d.ts → buildSignedMobileRequest-UeeWdYGU.d.ts} +2 -2
  22. package/dist/{buildSignedMobileRequest-Cb1T74xV.d.ts.map → buildSignedMobileRequest-UeeWdYGU.d.ts.map} +1 -1
  23. package/dist/{canonicalize-BBYGh17w.d.ts → canonicalize-5eeZrkzQ.d.ts} +2 -2
  24. package/dist/canonicalize-5eeZrkzQ.d.ts.map +1 -0
  25. package/dist/{canonicalize-BF_SiNvO.d.cts → canonicalize-CBaZprTo.d.cts} +2 -2
  26. package/dist/canonicalize-CBaZprTo.d.cts.map +1 -0
  27. package/dist/{clientTypes-BWFKo9oE.d.cts → clientTypes-C9dJufxk.d.ts} +569 -25
  28. package/dist/clientTypes-C9dJufxk.d.ts.map +1 -0
  29. package/dist/{clientTypes-DCTiUV0H.d.ts → clientTypes-_mEgzmNs.d.cts} +569 -25
  30. package/dist/clientTypes-_mEgzmNs.d.cts.map +1 -0
  31. package/dist/dataMappers.cjs +488 -9
  32. package/dist/dataMappers.cjs.map +1 -1
  33. package/dist/dataMappers.d.cts +190 -7
  34. package/dist/dataMappers.d.cts.map +1 -1
  35. package/dist/dataMappers.d.ts +190 -7
  36. package/dist/dataMappers.d.ts.map +1 -1
  37. package/dist/dataMappers.js +460 -10
  38. package/dist/dataMappers.js.map +1 -1
  39. package/dist/{eip712MethodByType-BSx11xG-.d.cts → eip712MethodByType-D8jLoxDu.d.cts} +2 -2
  40. package/dist/eip712MethodByType-D8jLoxDu.d.cts.map +1 -0
  41. package/dist/{eip712MethodByType-DkiAjCLs.d.ts → eip712MethodByType-DcUh8h-l.d.ts} +2 -2
  42. package/dist/eip712MethodByType-DcUh8h-l.d.ts.map +1 -0
  43. package/dist/index.cjs +3 -1
  44. package/dist/index.d.cts +16 -15
  45. package/dist/index.d.ts +16 -15
  46. package/dist/index.js +2 -1
  47. package/dist/{mobileErrorCodes-3LtreeZM.d.ts → mobileErrorCodes-CmjYEIYm.d.cts} +18 -4
  48. package/dist/mobileErrorCodes-CmjYEIYm.d.cts.map +1 -0
  49. package/dist/{mobileErrorCodes-3LtreeZM.d.cts → mobileErrorCodes-CmjYEIYm.d.ts} +18 -4
  50. package/dist/mobileErrorCodes-CmjYEIYm.d.ts.map +1 -0
  51. package/dist/{payloadHash-BOWGjqdb.d.cts → payloadHash-DhHmgRqL.d.cts} +2 -2
  52. package/dist/payloadHash-DhHmgRqL.d.cts.map +1 -0
  53. package/dist/{payloadHash-Bzf4CtjV.d.ts → payloadHash-E1_8fpLW.d.ts} +2 -2
  54. package/dist/payloadHash-E1_8fpLW.d.ts.map +1 -0
  55. package/dist/{serverBaseTypes-KREDe2M9.d.cts → serverBaseTypes-B5J1_TyC.d.cts} +2 -2
  56. package/dist/{serverBaseTypes-KREDe2M9.d.cts.map → serverBaseTypes-B5J1_TyC.d.cts.map} +1 -1
  57. package/dist/{serverBaseTypes-DWf3iGWy.d.ts → serverBaseTypes-DnLzsdm-.d.ts} +2 -2
  58. package/dist/{serverBaseTypes-DWf3iGWy.d.ts.map → serverBaseTypes-DnLzsdm-.d.ts.map} +1 -1
  59. package/dist/serverExecuteTypes-B-OJok19.d.cts +162 -0
  60. package/dist/serverExecuteTypes-B-OJok19.d.cts.map +1 -0
  61. package/dist/serverExecuteTypes-BwWGspOg.d.ts +162 -0
  62. package/dist/serverExecuteTypes-BwWGspOg.d.ts.map +1 -0
  63. package/dist/{serverModelTypes-DAqEyYtB.d.cts → serverModelTypes-CiA-dy1R.d.cts} +299 -24
  64. package/dist/serverModelTypes-CiA-dy1R.d.cts.map +1 -0
  65. package/dist/{serverModelTypes-DAqEyYtB.d.ts → serverModelTypes-CiA-dy1R.d.ts} +299 -24
  66. package/dist/serverModelTypes-CiA-dy1R.d.ts.map +1 -0
  67. package/dist/{serverQueryTypes-DNdMpmDr.d.cts → serverQueryTypes-CJcjLB7n.d.ts} +117 -5
  68. package/dist/serverQueryTypes-CJcjLB7n.d.ts.map +1 -0
  69. package/dist/{serverQueryTypes-BFdwq0Z2.d.ts → serverQueryTypes-V1f9yE7L.d.cts} +117 -5
  70. package/dist/serverQueryTypes-V1f9yE7L.d.cts.map +1 -0
  71. package/dist/{serverRequestTypes-CxDRFKfv.d.cts → serverRequestTypes-CRlkNSu5.d.cts} +77 -7
  72. package/dist/serverRequestTypes-CRlkNSu5.d.cts.map +1 -0
  73. package/dist/{serverRequestTypes-BNA7FCY6.d.ts → serverRequestTypes-DZoOhV2o.d.ts} +77 -7
  74. package/dist/serverRequestTypes-DZoOhV2o.d.ts.map +1 -0
  75. package/dist/{serverResponseGuards-Dkdok0Sm.d.cts → serverResponseGuards-BW69PS7O.d.cts} +2 -2
  76. package/dist/{serverResponseGuards-Dkdok0Sm.d.cts.map → serverResponseGuards-BW69PS7O.d.cts.map} +1 -1
  77. package/dist/{serverResponseGuards-BU1Xv_tG.d.ts → serverResponseGuards-CShiXpHT.d.ts} +2 -2
  78. package/dist/{serverResponseGuards-BU1Xv_tG.d.ts.map → serverResponseGuards-CShiXpHT.d.ts.map} +1 -1
  79. package/dist/signing/buildSignedMobileRequest.d.cts +1 -1
  80. package/dist/signing/buildSignedMobileRequest.d.ts +1 -1
  81. package/dist/signing/canonicalize.cjs +37 -0
  82. package/dist/signing/canonicalize.cjs.map +1 -1
  83. package/dist/signing/canonicalize.d.cts +1 -1
  84. package/dist/signing/canonicalize.d.ts +1 -1
  85. package/dist/signing/canonicalize.js +37 -0
  86. package/dist/signing/canonicalize.js.map +1 -1
  87. package/dist/signing/eip712MethodByType.cjs +5 -0
  88. package/dist/signing/eip712MethodByType.cjs.map +1 -1
  89. package/dist/signing/eip712MethodByType.d.cts +1 -1
  90. package/dist/signing/eip712MethodByType.d.ts +1 -1
  91. package/dist/signing/eip712MethodByType.js +5 -0
  92. package/dist/signing/eip712MethodByType.js.map +1 -1
  93. package/dist/signing/index.d.cts +5 -5
  94. package/dist/signing/index.d.ts +5 -5
  95. package/dist/signing/payloadHash.d.cts +1 -1
  96. package/dist/signing/payloadHash.d.ts +1 -1
  97. package/dist/signing/types.d.cts +1 -1
  98. package/dist/signing/types.d.ts +1 -1
  99. package/dist/types/MobileServerFailureError.d.cts +1 -1
  100. package/dist/types/MobileServerFailureError.d.ts +1 -1
  101. package/dist/types/MobileUnsupportedFeedItemError.cjs +19 -0
  102. package/dist/types/MobileUnsupportedFeedItemError.cjs.map +1 -0
  103. package/dist/types/MobileUnsupportedFeedItemError.d.cts +2 -0
  104. package/dist/types/MobileUnsupportedFeedItemError.d.ts +2 -0
  105. package/dist/types/MobileUnsupportedFeedItemError.js +18 -0
  106. package/dist/types/MobileUnsupportedFeedItemError.js.map +1 -0
  107. package/dist/types/clientTypes.d.cts +2 -2
  108. package/dist/types/clientTypes.d.ts +2 -2
  109. package/dist/types/index.cjs +2 -0
  110. package/dist/types/index.d.cts +10 -9
  111. package/dist/types/index.d.ts +10 -9
  112. package/dist/types/index.js +2 -1
  113. package/dist/types/mobileErrorCodes.cjs +28 -0
  114. package/dist/types/mobileErrorCodes.cjs.map +1 -1
  115. package/dist/types/mobileErrorCodes.d.cts +1 -1
  116. package/dist/types/mobileErrorCodes.d.ts +1 -1
  117. package/dist/types/mobileErrorCodes.js +28 -0
  118. package/dist/types/mobileErrorCodes.js.map +1 -1
  119. package/dist/types/serverBaseTypes.d.cts +1 -1
  120. package/dist/types/serverBaseTypes.d.ts +1 -1
  121. package/dist/types/serverExecuteTypes.d.cts +2 -2
  122. package/dist/types/serverExecuteTypes.d.ts +2 -2
  123. package/dist/types/serverModelTypes.cjs.map +1 -1
  124. package/dist/types/serverModelTypes.d.cts +2 -2
  125. package/dist/types/serverModelTypes.d.ts +2 -2
  126. package/dist/types/serverModelTypes.js.map +1 -1
  127. package/dist/types/serverQueryTypes.d.cts +2 -2
  128. package/dist/types/serverQueryTypes.d.ts +2 -2
  129. package/dist/types/serverRequestTypes.d.cts +1 -1
  130. package/dist/types/serverRequestTypes.d.ts +1 -1
  131. package/dist/{types-BCr2G5gS.d.cts → types-BiRmH5Iv.d.cts} +31 -7
  132. package/dist/types-BiRmH5Iv.d.cts.map +1 -0
  133. package/dist/{types-C18k-9Vy.d.ts → types-DoJuq0Ij.d.ts} +31 -7
  134. package/dist/types-DoJuq0Ij.d.ts.map +1 -0
  135. package/dist/utils/index.d.cts +1 -1
  136. package/dist/utils/index.d.ts +1 -1
  137. package/dist/utils/serverResponseGuards.d.cts +1 -1
  138. package/dist/utils/serverResponseGuards.d.ts +1 -1
  139. package/package.json +3 -3
  140. package/src/MobileClient.ts +409 -4
  141. package/src/dataMappers.test.ts +742 -0
  142. package/src/dataMappers.ts +671 -12
  143. package/src/signing/canonicalize.ts +53 -0
  144. package/src/signing/eip712MethodByType.ts +5 -0
  145. package/src/signing/signing.test.ts +347 -0
  146. package/src/signing/types.ts +57 -4
  147. package/src/types/MobileUnsupportedFeedItemError.ts +18 -0
  148. package/src/types/clientTypes.ts +645 -23
  149. package/src/types/index.ts +1 -0
  150. package/src/types/mobileErrorCodes.ts +28 -0
  151. package/src/types/serverExecuteTypes.ts +92 -3
  152. package/src/types/serverModelTypes.ts +376 -22
  153. package/src/types/serverQueryTypes.ts +138 -0
  154. package/src/types/serverRequestTypes.ts +115 -4
  155. package/dist/MobileClient-aDxiM_Kf.cjs.map +0 -1
  156. package/dist/canonicalize-BBYGh17w.d.ts.map +0 -1
  157. package/dist/canonicalize-BF_SiNvO.d.cts.map +0 -1
  158. package/dist/clientTypes-BWFKo9oE.d.cts.map +0 -1
  159. package/dist/clientTypes-DCTiUV0H.d.ts.map +0 -1
  160. package/dist/eip712MethodByType-BSx11xG-.d.cts.map +0 -1
  161. package/dist/eip712MethodByType-DkiAjCLs.d.ts.map +0 -1
  162. package/dist/mobileErrorCodes-3LtreeZM.d.cts.map +0 -1
  163. package/dist/mobileErrorCodes-3LtreeZM.d.ts.map +0 -1
  164. package/dist/payloadHash-BOWGjqdb.d.cts.map +0 -1
  165. package/dist/payloadHash-Bzf4CtjV.d.ts.map +0 -1
  166. package/dist/serverExecuteTypes-DVRa6ifu.d.cts +0 -89
  167. package/dist/serverExecuteTypes-DVRa6ifu.d.cts.map +0 -1
  168. package/dist/serverExecuteTypes-DlYZCp1f.d.ts +0 -89
  169. package/dist/serverExecuteTypes-DlYZCp1f.d.ts.map +0 -1
  170. package/dist/serverModelTypes-DAqEyYtB.d.cts.map +0 -1
  171. package/dist/serverModelTypes-DAqEyYtB.d.ts.map +0 -1
  172. package/dist/serverQueryTypes-BFdwq0Z2.d.ts.map +0 -1
  173. package/dist/serverQueryTypes-DNdMpmDr.d.cts.map +0 -1
  174. package/dist/serverRequestTypes-BNA7FCY6.d.ts.map +0 -1
  175. package/dist/serverRequestTypes-CxDRFKfv.d.cts.map +0 -1
  176. package/dist/types-BCr2G5gS.d.cts.map +0 -1
  177. package/dist/types-C18k-9Vy.d.ts.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { MobileUnsupportedFeedItemError } from "./types/MobileUnsupportedFeedItemError.js";
1
2
  import { removeDecimals, subaccountToHex, toBigNumber } from "@nadohq/shared";
2
3
  //#region src/dataMappers.ts
3
4
  /**
@@ -310,7 +311,8 @@ function mapMobileSocialFeedPositionPatch(server) {
310
311
  marginMode: server.margin_mode,
311
312
  leverage: server.leverage,
312
313
  leverageAtMs: server.leverage_at_ms,
313
- pnl: mapMobileSocialFeedPnl(server.pnl)
314
+ pnl: mapMobileSocialFeedPnl(server.pnl),
315
+ ...server.current_position === void 0 ? {} : { currentPosition: mapMobileSocialFeedHistoryMetrics(server.current_position) }
314
316
  };
315
317
  }
316
318
  /**
@@ -348,7 +350,7 @@ function mapMobileSocialFeedItemBase(server) {
348
350
  return {
349
351
  id: server.id,
350
352
  hasAnalysis: server.has_analysis,
351
- drawing: server.drawing,
353
+ drawing: server.drawing === null ? null : mapMobileSocialFeedDrawing(server.drawing),
352
354
  author: mapMobileSocialFeedAuthor(server.author),
353
355
  createdAtMs: server.created_at_ms,
354
356
  displayAtMs: server.display_at_ms,
@@ -362,27 +364,37 @@ function mapMobileSocialFeedItemBase(server) {
362
364
  };
363
365
  }
364
366
  /**
365
- * Maps an automatic trade card and its position and interaction metadata.
367
+ * Maps the content, position, interaction, and comment preview shared by posts and trade cards.
366
368
  * @param server - The service response.
367
- * @returns The mapped social trade card.
369
+ * @returns The mapped shared content fields.
368
370
  */
369
- function mapMobileSocialFeedTradeCard(server) {
371
+ function mapMobileSocialFeedContentBase(server) {
370
372
  return {
371
373
  ...mapMobileSocialFeedItemBase(server),
372
- kind: server.kind,
373
- action: server.action,
374
374
  text: server.text,
375
375
  mentions: server.mentions,
376
376
  position: mapMobileSocialFeedPositionCard(server.position),
377
377
  interaction: mapMobileSocialFeedInteraction(server.interaction),
378
378
  commentPreview: {
379
- items: server.comment_preview.items,
379
+ items: server.comment_preview.items.map(mapMobileSocialFeedReply),
380
380
  totalCount: server.comment_preview.total_count,
381
381
  nextCursor: server.comment_preview.next_cursor
382
382
  }
383
383
  };
384
384
  }
385
385
  /**
386
+ * Maps a trade card, authored content, and position and interaction metadata.
387
+ * @param server - The service response.
388
+ * @returns The mapped social trade card.
389
+ */
390
+ function mapMobileSocialFeedTradeCard(server) {
391
+ return {
392
+ ...mapMobileSocialFeedContentBase(server),
393
+ kind: server.kind,
394
+ action: server.action
395
+ };
396
+ }
397
+ /**
386
398
  * Maps historical trade facts with decimal execution prices and x18 quantities.
387
399
  * @param server - The service response.
388
400
  * @returns The mapped social trade row base.
@@ -427,9 +439,17 @@ function mapMobileSocialFeedTradeRow(server) {
427
439
  * Maps the item variant without mixing card and row fields.
428
440
  * @param server - The service response.
429
441
  * @returns The mapped social feed item.
442
+ * @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
430
443
  */
431
444
  function mapMobileSocialFeedItem(server) {
432
- return server.kind === "trade_card" ? mapMobileSocialFeedTradeCard(server) : mapMobileSocialFeedTradeRow(server);
445
+ const kind = server.kind;
446
+ switch (kind) {
447
+ case "trade_card": return mapMobileSocialFeedTradeCard(server);
448
+ case "trade_row": return mapMobileSocialFeedTradeRow(server);
449
+ case "post": return mapMobileSocialFeedPost(server);
450
+ case "reply": return mapMobileSocialFeedReply(server);
451
+ default: throw new MobileUnsupportedFeedItemError(kind);
452
+ }
433
453
  }
434
454
  /**
435
455
  * Maps a fixed reading session, preserving opaque credentials and cursors.
@@ -453,6 +473,7 @@ function mapMobileSocialFeedReadSession(server) {
453
473
  * Maps a fixed feed page without changing item order or pagination.
454
474
  * @param server - The service response.
455
475
  * @returns The mapped social feed page.
476
+ * @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
456
477
  */
457
478
  function mapMobileSocialFeedPage(server) {
458
479
  return {
@@ -466,6 +487,7 @@ function mapMobileSocialFeedPage(server) {
466
487
  * Maps a main feed page and its ranking version.
467
488
  * @param server - The service response.
468
489
  * @returns The mapped ranked feed page.
490
+ * @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
469
491
  */
470
492
  function mapMobileSocialFeedRankedPage(server) {
471
493
  return {
@@ -477,6 +499,7 @@ function mapMobileSocialFeedRankedPage(server) {
477
499
  * Maps qualified trader items and their shared eligibility snapshot.
478
500
  * @param server - The service response.
479
501
  * @returns The mapped top traders feed page.
502
+ * @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
480
503
  */
481
504
  function mapMobileSocialFeedTopTradersPage(server) {
482
505
  return {
@@ -497,6 +520,7 @@ function mapMobileSocialFeedTopTradersPage(server) {
497
520
  * Maps item details and the authorized reading session.
498
521
  * @param server - The service response.
499
522
  * @returns The mapped social feed item response.
523
+ * @throws {MobileUnsupportedFeedItemError} If an item kind is not supported by this SDK.
500
524
  */
501
525
  function mapMobileSocialFeedItemResponse(server) {
502
526
  return {
@@ -513,6 +537,8 @@ function mapMobileSocialFeedItemPatch(server) {
513
537
  return {
514
538
  itemId: server.item_id,
515
539
  version: server.version,
540
+ ...server.attached_position === void 0 ? {} : { attachedPosition: server.attached_position === null ? null : mapMobileSocialFeedPositionCard(server.attached_position) },
541
+ ...server.attachment_status === void 0 ? {} : { attachmentStatus: server.attachment_status },
516
542
  author: mapMobileSocialFeedAuthor(server.author),
517
543
  displayAtMs: server.display_at_ms,
518
544
  ...server.interaction === void 0 ? {} : { interaction: mapMobileSocialFeedInteraction(server.interaction) },
@@ -570,7 +596,431 @@ function mapMobileSocialFeedReadParamsToServer(params) {
570
596
  viewer_token: params.viewerToken
571
597
  };
572
598
  }
599
+ /**
600
+ * Maps a mention for signing without changing the text or offsets.
601
+ * @param params - Caller-provided mention and original text offsets.
602
+ * @returns The wire-format mention, preserving the original label and code-point offsets.
603
+ * @throws {Error} If the owner is not a 20-byte address or the subaccount name cannot be encoded in 12 bytes.
604
+ */
605
+ function mapMobileSocialFeedMentionToServer(params) {
606
+ return {
607
+ subaccount: subaccountToHex(params.subaccount),
608
+ start: params.start,
609
+ end: params.end,
610
+ label: params.label
611
+ };
612
+ }
613
+ /**
614
+ * Preserves parsed drawing data, including false and zero.
615
+ * @param server - Service payload with its original wire fields.
616
+ * @returns The original parsed drawing data and its creation/update timestamps in milliseconds.
617
+ */
618
+ function mapMobileSocialFeedDrawing(server) {
619
+ return {
620
+ data: server.data,
621
+ createdAtMs: server.created_at_ms,
622
+ updatedAtMs: server.updated_at_ms
623
+ };
624
+ }
625
+ /**
626
+ * Maps a nonrecursive root preview, retaining nullable position visibility.
627
+ * @param server - Service payload with its original wire fields.
628
+ * @returns A nonrecursive preview with a nullable position and notional retained as an x18 BigNumber.
629
+ */
630
+ function mapMobileSocialFeedCompactCard(server) {
631
+ return {
632
+ id: server.id,
633
+ author: mapMobileSocialFeedAuthor(server.author),
634
+ textExcerpt: server.text_excerpt,
635
+ position: server.position === null ? null : {
636
+ positionId: server.position.position_id,
637
+ market: mapMobileSocialFeedMarket(server.position.market),
638
+ direction: server.position.direction,
639
+ state: server.position.state,
640
+ notional: toBigNumber(server.position.notional_x18)
641
+ },
642
+ hasAnalysis: server.has_analysis
643
+ };
644
+ }
645
+ /**
646
+ * Maps an authored post and its readable comments and drawing.
647
+ * @param server - Service payload with its original wire fields.
648
+ * @returns A post with its unchanged text and mentions, mapped position, drawing, interactions, and reply preview.
649
+ */
650
+ function mapMobileSocialFeedPost(server) {
651
+ return {
652
+ ...mapMobileSocialFeedContentBase(server),
653
+ kind: server.kind
654
+ };
655
+ }
656
+ /**
657
+ * Maps reply visibility without treating an unavailable attachment as an absent one.
658
+ * @param server - Service payload with its original wire fields.
659
+ * @returns A reply preserving omitted reply targets, nullable attachments, and the separate attachment visibility status.
660
+ */
661
+ function mapMobileSocialFeedReply(server) {
662
+ return {
663
+ ...mapMobileSocialFeedItemBase(server),
664
+ kind: server.kind,
665
+ text: server.text,
666
+ mentions: server.mentions,
667
+ rootItemId: server.root_item_id,
668
+ ...server.reply_to_item_id === void 0 ? {} : { replyToItemId: server.reply_to_item_id },
669
+ replyToAuthor: server.reply_to_author === null ? null : mapMobileSocialFeedAuthor(server.reply_to_author),
670
+ attachedPosition: server.attached_position === null ? null : mapMobileSocialFeedPositionCard(server.attached_position),
671
+ attachmentStatus: server.attachment_status,
672
+ original: mapMobileSocialFeedCompactCard(server.original),
673
+ interaction: mapMobileSocialFeedInteraction(server.interaction)
674
+ };
675
+ }
676
+ /**
677
+ * Maps current eligibility hints without implying caller ownership.
678
+ * @param server - Service payload with its original wire fields.
679
+ * @returns A position with current publication, attachment, and drawing eligibility hints and an unavailable reason.
680
+ */
681
+ function mapMobileSocialFeedPublishablePosition(server) {
682
+ return {
683
+ position: mapMobileSocialFeedPositionCard(server.position),
684
+ canPublish: server.can_publish,
685
+ canAttachToComment: server.can_attach_to_comment,
686
+ canDrawAnalysis: server.can_draw_analysis,
687
+ unavailableReason: server.unavailable_reason
688
+ };
689
+ }
690
+ /**
691
+ * Maps all order action identifiers and eligibility hints.
692
+ * @param server - Service payload with its original wire fields.
693
+ * @returns Trusted action and position identifiers, action kind, publication eligibility, and an unavailable reason.
694
+ */
695
+ function mapMobileSocialFeedActionCandidate(server) {
696
+ return {
697
+ actionId: server.action_id,
698
+ positionId: server.position_id,
699
+ action: server.action,
700
+ canPublish: server.can_publish,
701
+ unavailableReason: server.unavailable_reason
702
+ };
703
+ }
704
+ /**
705
+ * Maps history risk prices to decimals while retaining funding amounts in x18 units.
706
+ * @param server - Service payload with its original wire fields.
707
+ * @returns Nullable decimal liquidation price and x18 funding PnL, with their independent quality and observation metadata.
708
+ */
709
+ function mapMobileSocialFeedHistoryMetrics(server) {
710
+ return {
711
+ estimatedLiquidationPrice: removeDecimals(server.estimated_liquidation_price_x18),
712
+ liquidationPriceQuality: server.liquidation_price_quality,
713
+ liquidationPriceAsOfMs: server.liquidation_price_as_of_ms,
714
+ fundingPnl: server.funding_pnl_x18 === null ? null : toBigNumber(server.funding_pnl_x18),
715
+ fundingQuality: server.funding_quality,
716
+ fundingAsOfMs: server.funding_as_of_ms
717
+ };
718
+ }
719
+ /**
720
+ * Maps action prices independently; all amounts and quantities retain x18 units.
721
+ * @param server - Service payload with its original wire fields.
722
+ * @returns An action with decimal prices, x18 quantities/amounts, and independently nullable financial facts.
723
+ */
724
+ function mapMobileSocialFeedPositionAction(server) {
725
+ return {
726
+ id: server.id,
727
+ positionId: server.position_id,
728
+ action: server.action,
729
+ direction: server.direction,
730
+ marginMode: server.margin_mode,
731
+ quantityBefore: toBigNumber(server.quantity_before_x18),
732
+ quantityAfter: toBigNumber(server.quantity_after_x18),
733
+ executedQuantity: toBigNumber(server.executed_quantity_x18),
734
+ executedNotional: server.executed_notional_x18 === null ? null : toBigNumber(server.executed_notional_x18),
735
+ averagePrice: removeDecimals(server.average_price_x18),
736
+ entryPriceBefore: removeDecimals(server.entry_price_before_x18),
737
+ liquidationOraclePrice: removeDecimals(server.liquidation_oracle_price_x18),
738
+ liquidationNotional: server.liquidation_notional_x18 === null ? null : toBigNumber(server.liquidation_notional_x18),
739
+ realizedPnlDelta: server.realized_pnl_delta_x18 === null ? null : toBigNumber(server.realized_pnl_delta_x18),
740
+ leverage: server.leverage,
741
+ leverageAtMs: server.leverage_at_ms,
742
+ firstEventAtMs: server.first_event_at_ms,
743
+ lastEventAtMs: server.last_event_at_ms,
744
+ version: server.version
745
+ };
746
+ }
747
+ /**
748
+ * Maps a trusted target without treating the viewing account as authenticated.
749
+ * @param server - Service payload with its original wire fields.
750
+ * @returns A trading target retaining distinct identity/trading subaccounts, margin mode, and observation time.
751
+ */
752
+ function mapMobileSocialFeedTradingTarget(server) {
753
+ return {
754
+ positionId: server.position_id,
755
+ identitySubaccount: server.identity_subaccount,
756
+ tradingSubaccount: server.trading_subaccount,
757
+ productId: server.product_id,
758
+ marginMode: server.margin_mode,
759
+ isoSubaccountName: server.iso_subaccount_name,
760
+ direction: server.direction,
761
+ stateAsOfMs: server.state_as_of_ms
762
+ };
763
+ }
764
+ /**
765
+ * Maps viewing-account trading hints.
766
+ * @param server - Service payload with its original wire fields.
767
+ * @returns Trading hints with ordered target candidates, nullable viewer position, and the current reduction hint.
768
+ */
769
+ function mapMobileSocialFeedTradingContext(server) {
770
+ return {
771
+ productId: server.product_id,
772
+ suggestedDirection: server.suggested_direction,
773
+ resolution: server.resolution,
774
+ candidates: server.candidates.map(mapMobileSocialFeedTradingTarget),
775
+ viewerPositionId: server.viewer_position_id,
776
+ canReduce: server.can_reduce
777
+ };
778
+ }
779
+ /**
780
+ * Converts OHLC prices to decimals but preserves base-asset volume in x18.
781
+ * @param server - Service payload with its original wire fields.
782
+ * @returns A candle with decimal OHLC BigNumbers, base-asset volume retained in x18, and its timestamp in milliseconds.
783
+ */
784
+ function mapMobileSocialFeedCandle(server) {
785
+ return {
786
+ timestampMs: server.timestamp_ms,
787
+ open: removeDecimals(server.open_x18),
788
+ high: removeDecimals(server.high_x18),
789
+ low: removeDecimals(server.low_x18),
790
+ close: removeDecimals(server.close_x18),
791
+ volume: toBigNumber(server.volume_x18)
792
+ };
793
+ }
794
+ /**
795
+ * Maps markers without replacing unknown Oracle prices with execution prices.
796
+ * @param server - Service payload with its original wire fields.
797
+ * @returns An action marker with its original price basis and a nullable decimal price, without substituting another source.
798
+ */
799
+ function mapMobileSocialFeedActionMarker(server) {
800
+ return {
801
+ actionId: server.action_id,
802
+ timestampMs: server.timestamp_ms,
803
+ price: removeDecimals(server.price_x18),
804
+ action: server.action,
805
+ direction: server.direction,
806
+ priceBasis: server.price_basis
807
+ };
808
+ }
809
+ /**
810
+ * Maps selected-account open positions.
811
+ * @param server - Service payload with its original wire fields.
812
+ * @returns Mapped position candidates with the original nullable cursor and observation time.
813
+ */
814
+ function mapMobileSocialFeedPositionsPage(server) {
815
+ return {
816
+ positions: server.positions.map(mapMobileSocialFeedPublishablePosition),
817
+ nextCursor: server.next_cursor,
818
+ asOfMs: server.as_of_ms
819
+ };
820
+ }
821
+ /**
822
+ * Maps normal empty and ambiguous command results.
823
+ * @param server - Service payload with its original wire fields.
824
+ * @returns The command resolution, nullable market, position candidates, and original reason for an empty result.
825
+ */
826
+ function mapMobileSocialFeedPositionResolutionResult(server) {
827
+ return {
828
+ resolution: server.resolution,
829
+ product: server.product === null ? null : mapMobileSocialFeedMarket(server.product),
830
+ candidates: server.candidates.map(mapMobileSocialFeedPublishablePosition),
831
+ reason: server.reason
832
+ };
833
+ }
834
+ /**
835
+ * Preserves pending order projection without inventing action candidates.
836
+ * @param server - Service payload with its original wire fields.
837
+ * @returns The original order digest, ready/pending state, mapped actions, and observation time.
838
+ */
839
+ function mapMobileSocialFeedActionResolutionResult(server) {
840
+ return {
841
+ orderDigest: server.order_digest,
842
+ resolution: server.resolution,
843
+ actions: server.actions.map(mapMobileSocialFeedActionCandidate),
844
+ asOfMs: server.as_of_ms
845
+ };
846
+ }
847
+ /**
848
+ * Distinguishes no drawing from falsy drawing data.
849
+ * @param server - Service payload with its original wire fields.
850
+ * @returns The parent item ID/version and a nullable drawing, retaining false or zero drawing data.
851
+ */
852
+ function mapMobileSocialFeedDrawingResult(server) {
853
+ return {
854
+ itemId: server.item_id,
855
+ itemVersion: server.item_version,
856
+ drawing: server.drawing === null ? null : mapMobileSocialFeedDrawing(server.drawing)
857
+ };
858
+ }
859
+ /**
860
+ * Maps a saved drawing after creation or replacement.
861
+ * @param server - Successful drawing mutation response.
862
+ * @returns The parent item ID/version and non-null saved drawing.
863
+ */
864
+ function mapMobileSocialFeedDrawingMutationResult(server) {
865
+ return {
866
+ itemId: server.item_id,
867
+ itemVersion: server.item_version,
868
+ drawing: mapMobileSocialFeedDrawing(server.drawing)
869
+ };
870
+ }
871
+ /**
872
+ * Maps bidirectional comments and the actual returned session.
873
+ * @param server - Service payload with its original wire fields.
874
+ * @returns Mapped replies, total count, bidirectional cursors, nullable anchor, and the actual reading session.
875
+ */
876
+ function mapMobileSocialFeedCommentsPage(server) {
877
+ return {
878
+ comments: server.comments.map(mapMobileSocialFeedReply),
879
+ totalCount: server.total_count,
880
+ nextCursor: server.next_cursor,
881
+ previousCursor: server.previous_cursor,
882
+ anchorReplyId: server.anchor_reply_id,
883
+ readSession: mapMobileSocialFeedReadSession(server.read_session)
884
+ };
885
+ }
886
+ /**
887
+ * Maps atomic reply publication without inventing a reading session.
888
+ * @param server - Service payload with its original wire fields.
889
+ * @returns The created reply and authoritative root comment count, without a fabricated reading session.
890
+ */
891
+ function mapMobileSocialFeedCommentResult(server) {
892
+ return {
893
+ comment: mapMobileSocialFeedReply(server.comment),
894
+ rootCommentCount: server.root_comment_count
895
+ };
896
+ }
897
+ /**
898
+ * Maps authoritative like state and count.
899
+ * @param server - Service payload with its original wire fields.
900
+ * @returns The applied like state, authoritative count, and item ID/version after the mutation.
901
+ */
902
+ function mapMobileSocialFeedLikeResult(server) {
903
+ return {
904
+ itemId: server.item_id,
905
+ isLiked: server.is_liked,
906
+ likeCount: server.like_count,
907
+ version: server.version
908
+ };
909
+ }
910
+ /**
911
+ * Maps exposure deduplication results without adding timestamps.
912
+ * @param server - Service payload with its original wire fields.
913
+ * @returns Newly accepted and duplicate item ID lists without inventing an observation timestamp.
914
+ */
915
+ function mapMobileSocialFeedViewsResult(server) {
916
+ return {
917
+ acceptedItemIds: server.accepted_item_ids,
918
+ duplicateItemIds: server.duplicate_item_ids
919
+ };
920
+ }
921
+ /**
922
+ * Maps a published history take without treating unknown kinds as posts.
923
+ * @param server - The published service item.
924
+ * @returns The mapped post or trade card.
925
+ * @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported take kind.
926
+ */
927
+ function mapMobileSocialFeedHistoryTake(server) {
928
+ const kind = server.kind;
929
+ switch (kind) {
930
+ case "trade_card": return mapMobileSocialFeedTradeCard(server);
931
+ case "post": return mapMobileSocialFeedPost(server);
932
+ default: throw new MobileUnsupportedFeedItemError(kind);
933
+ }
934
+ }
935
+ /**
936
+ * Maps a historical action or published take while preserving its discriminant.
937
+ * @param server - The service timeline entry.
938
+ * @returns The mapped action or take entry.
939
+ * @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported entry or take kind.
940
+ */
941
+ function mapMobileSocialFeedTimelineEntry(server) {
942
+ const kind = server.kind;
943
+ switch (kind) {
944
+ case "action": return {
945
+ kind,
946
+ action: mapMobileSocialFeedPositionAction(server.action),
947
+ relatedItemId: server.related_item_id,
948
+ relatedTake: server.related_take === null ? null : mapMobileSocialFeedTradeCard(server.related_take)
949
+ };
950
+ case "take": return {
951
+ kind,
952
+ item: mapMobileSocialFeedHistoryTake(server.item)
953
+ };
954
+ default: throw new MobileUnsupportedFeedItemError(kind);
955
+ }
956
+ }
957
+ /**
958
+ * Maps full history, preserving action/take order, association, and null facts.
959
+ * @param server - Service payload with its original wire fields.
960
+ * @returns Position metrics, ordered action/take timeline, summary, cursor, quality, reading session, and trading hints.
961
+ * @throws {MobileUnsupportedFeedItemError} If a timeline entry or take has an unsupported kind.
962
+ */
963
+ function mapMobileSocialFeedPositionHistory(server) {
964
+ return {
965
+ position: {
966
+ ...mapMobileSocialFeedPositionCard(server.position),
967
+ ...mapMobileSocialFeedHistoryMetrics(server.position)
968
+ },
969
+ summary: {
970
+ actionCount: server.summary.action_count,
971
+ takeCount: server.summary.take_count
972
+ },
973
+ timeline: server.timeline.map(mapMobileSocialFeedTimelineEntry),
974
+ nextCursor: server.next_cursor,
975
+ historyQuality: server.history_quality,
976
+ readSession: mapMobileSocialFeedReadSession(server.read_session),
977
+ tradingContext: mapMobileSocialFeedTradingContext(server.trading_context)
978
+ };
979
+ }
980
+ /**
981
+ * Maps candles and independent price sources, preserving explicit nulls.
982
+ * @param server - Service payload with its original wire fields.
983
+ * @returns Decimal-price candles and markers with x18 volume, a nullable liquidation line, and paging/quality metadata.
984
+ */
985
+ function mapMobileSocialFeedPositionChart(server) {
986
+ return {
987
+ candles: server.candles.map(mapMobileSocialFeedCandle),
988
+ actionMarkers: server.action_markers.map(mapMobileSocialFeedActionMarker),
989
+ estimatedLiquidationLine: server.estimated_liquidation_line === null ? null : {
990
+ price: removeDecimals(server.estimated_liquidation_line.price_x18),
991
+ asOfMs: server.estimated_liquidation_line.as_of_ms
992
+ },
993
+ nextBeforeMs: server.next_before_ms,
994
+ asOfMs: server.as_of_ms,
995
+ dataQuality: server.data_quality
996
+ };
997
+ }
998
+ /**
999
+ * Maps watcher observations; account previews are self-reported, not authenticated.
1000
+ * @param server - Service payload with its original wire fields.
1001
+ * @returns The visitor count, self-reported public account previews, and observation time.
1002
+ */
1003
+ function mapMobileSocialFeedWatchers(server) {
1004
+ return {
1005
+ watcherCount: server.watcher_count,
1006
+ watcherPreview: server.watcher_preview.map(mapMobileSocialFeedAuthor),
1007
+ asOfMs: server.as_of_ms
1008
+ };
1009
+ }
1010
+ /**
1011
+ * Maps a page lease without inventing an observation timestamp.
1012
+ * @param server - Service payload with its original wire fields.
1013
+ * @returns Visitor count and public previews with heartbeat/lease durations in seconds, without an observation timestamp.
1014
+ */
1015
+ function mapMobileSocialFeedPresence(server) {
1016
+ return {
1017
+ watcherCount: server.watcher_count,
1018
+ watcherPreview: server.watcher_preview.map(mapMobileSocialFeedAuthor),
1019
+ heartbeatIntervalSeconds: server.heartbeat_interval_seconds,
1020
+ expiresInSeconds: server.expires_in_seconds
1021
+ };
1022
+ }
573
1023
  //#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 };
1024
+ export { mapMobileAvatarPreset, mapMobileAvatarSelectionToServer, mapMobileAvatarUpload, mapMobileFeedPage, mapMobileFollowBatchResult, mapMobileFollowListPage, mapMobileFollowListParamsToServer, mapMobileFollowMutationResult, mapMobileNotificationPreferences, mapMobileNotificationPreferencesToServer, mapMobileProfileSearchPage, mapMobileProfileSearchParamsToServer, mapMobileProfilesIncludeToServer, mapMobilePublicProfile, mapMobileRegisteredWallet, mapMobileSocialFeedActionCandidate, mapMobileSocialFeedActionMarker, mapMobileSocialFeedActionResolutionResult, mapMobileSocialFeedAuthor, mapMobileSocialFeedCandle, mapMobileSocialFeedCommentResult, mapMobileSocialFeedCommentsPage, mapMobileSocialFeedCompactCard, mapMobileSocialFeedContentBase, mapMobileSocialFeedDrawing, mapMobileSocialFeedDrawingMutationResult, mapMobileSocialFeedDrawingResult, mapMobileSocialFeedHistoryMetrics, mapMobileSocialFeedHistoryTake, 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
1025
 
576
1026
  //# sourceMappingURL=dataMappers.js.map