@polyester/sdk 0.35.0-devnet-20261111140253 → 0.35.0-devnet-20261112024759

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 (152) hide show
  1. package/CHANGELOG.md +12 -2
  2. package/dist/client.d.ts +6 -0
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +6 -0
  5. package/dist/client.js.map +1 -1
  6. package/dist/gen/ai/v1/assistant_pb.d.ts +2 -2
  7. package/dist/gen/ai/v1/assistant_pb.js +2 -2
  8. package/dist/gen/index.d.ts +11 -11
  9. package/dist/gen/index.js +9 -9
  10. package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +1 -1
  11. package/dist/gen/orders/v1/orders_read_pb.d.ts +1 -1
  12. package/dist/index.d.ts +10 -2
  13. package/dist/services/accounts/accounts.d.ts +1 -1
  14. package/dist/services/accounts/accounts.js +1 -1
  15. package/dist/services/accounts/accounts.js.map +1 -1
  16. package/dist/services/address-book/address-book.schemas.d.ts +2 -2
  17. package/dist/services/api-keys/api-keys.d.ts +18 -3
  18. package/dist/services/api-keys/api-keys.d.ts.map +1 -1
  19. package/dist/services/api-keys/api-keys.js +27 -3
  20. package/dist/services/api-keys/api-keys.js.map +1 -1
  21. package/dist/services/api-keys/api-keys.schemas.d.ts +112 -1
  22. package/dist/services/api-keys/api-keys.schemas.d.ts.map +1 -1
  23. package/dist/services/api-keys/api-keys.schemas.js +26 -2
  24. package/dist/services/api-keys/api-keys.schemas.js.map +1 -1
  25. package/dist/services/api-keys/api-keys.types.d.ts +2 -2
  26. package/dist/services/api-keys/index.d.ts +2 -2
  27. package/dist/services/assistant/assistant-events.schemas.d.ts +4646 -0
  28. package/dist/services/assistant/assistant-events.schemas.d.ts.map +1 -0
  29. package/dist/services/assistant/assistant-events.schemas.js +485 -0
  30. package/dist/services/assistant/assistant-events.schemas.js.map +1 -0
  31. package/dist/services/assistant/assistant.codecs.d.ts +24 -0
  32. package/dist/services/assistant/assistant.codecs.d.ts.map +1 -0
  33. package/dist/services/assistant/assistant.codecs.js +88 -0
  34. package/dist/services/assistant/assistant.codecs.js.map +1 -0
  35. package/dist/services/assistant/assistant.d.ts +76 -0
  36. package/dist/services/assistant/assistant.d.ts.map +1 -0
  37. package/dist/services/assistant/assistant.js +133 -0
  38. package/dist/services/assistant/assistant.js.map +1 -0
  39. package/dist/services/assistant/assistant.schemas.d.ts +184 -0
  40. package/dist/services/assistant/assistant.schemas.d.ts.map +1 -0
  41. package/dist/services/assistant/assistant.schemas.js +135 -0
  42. package/dist/services/assistant/assistant.schemas.js.map +1 -0
  43. package/dist/services/assistant/assistant.types.d.ts +4 -0
  44. package/dist/services/assistant/service.d.ts +8 -0
  45. package/dist/services/assistant/service.d.ts.map +1 -0
  46. package/dist/services/assistant/service.js +9 -0
  47. package/dist/services/assistant/service.js.map +1 -0
  48. package/dist/services/auth/profile/profile.d.ts +2 -2
  49. package/dist/services/auth/profile/profile.js +2 -2
  50. package/dist/services/auth/profile/profile.js.map +1 -1
  51. package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts +19 -19
  52. package/dist/services/auto-withdraw/auto-withdraw.schemas.js +1 -1
  53. package/dist/services/balances/balances.js +1 -1
  54. package/dist/services/candles/candles.js +1 -1
  55. package/dist/services/candles/candles.schemas.js +5 -2
  56. package/dist/services/candles/candles.schemas.js.map +1 -1
  57. package/dist/services/changelog/changelog.schemas.d.ts +17 -17
  58. package/dist/services/checkpoints/checkpoints.d.ts +2 -2
  59. package/dist/services/checkpoints/checkpoints.js +2 -2
  60. package/dist/services/checkpoints/checkpoints.js.map +1 -1
  61. package/dist/services/checkpoints/checkpoints.schemas.d.ts +2 -2
  62. package/dist/services/deposit/deposit.d.ts +2 -2
  63. package/dist/services/deposit/deposit.js +2 -2
  64. package/dist/services/deposit/deposit.js.map +1 -1
  65. package/dist/services/guard-signer/guard-signer.d.ts +1 -1
  66. package/dist/services/guard-signer/guard-signer.js +1 -1
  67. package/dist/services/guard-signer/guard-signer.js.map +1 -1
  68. package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
  69. package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +3 -3
  70. package/dist/services/lifecycle/lifecycle.schemas.d.ts +54 -54
  71. package/dist/services/market-data/market-data.js +1 -1
  72. package/dist/services/market-overview/market-overview.schemas.d.ts +1 -1
  73. package/dist/services/orderbook/orderbook.schemas.d.ts +1 -1
  74. package/dist/services/orders/order-errors.schemas.d.ts +1 -1
  75. package/dist/services/orders/orders-batch.schemas.d.ts +32 -32
  76. package/dist/services/orders/orders-input.schemas.d.ts +4 -4
  77. package/dist/services/orders/orders-input.schemas.js +1 -1
  78. package/dist/services/orders/orders-modify.schemas.js +1 -1
  79. package/dist/services/orders/orders-output.schemas.d.ts +25 -25
  80. package/dist/services/orders/orders-output.schemas.js +3 -3
  81. package/dist/services/orders/orders-risk.schemas.js +1 -1
  82. package/dist/services/orders/orders.codecs.js +1 -1
  83. package/dist/services/orders/orders.js +3 -3
  84. package/dist/services/policies/api-key-policies/api-key-policies.d.ts +2 -2
  85. package/dist/services/policies/api-key-policies/api-key-policies.js +2 -2
  86. package/dist/services/policies/api-key-policies/api-key-policies.js.map +1 -1
  87. package/dist/services/policies/subaccount-policies/subaccount-policies.d.ts +2 -2
  88. package/dist/services/policies/subaccount-policies/subaccount-policies.js +2 -2
  89. package/dist/services/policies/subaccount-policies/subaccount-policies.js.map +1 -1
  90. package/dist/services/price-alerts/price-alerts.codecs.d.ts +20 -0
  91. package/dist/services/price-alerts/price-alerts.codecs.d.ts.map +1 -0
  92. package/dist/services/price-alerts/price-alerts.codecs.js +66 -0
  93. package/dist/services/price-alerts/price-alerts.codecs.js.map +1 -0
  94. package/dist/services/price-alerts/price-alerts.d.ts +38 -0
  95. package/dist/services/price-alerts/price-alerts.d.ts.map +1 -0
  96. package/dist/services/price-alerts/price-alerts.js +60 -0
  97. package/dist/services/price-alerts/price-alerts.js.map +1 -0
  98. package/dist/services/price-alerts/price-alerts.schemas.d.ts +309 -0
  99. package/dist/services/price-alerts/price-alerts.schemas.d.ts.map +1 -0
  100. package/dist/services/price-alerts/price-alerts.schemas.js +130 -0
  101. package/dist/services/price-alerts/price-alerts.schemas.js.map +1 -0
  102. package/dist/services/price-alerts/price-alerts.types.d.ts +3 -0
  103. package/dist/services/price-alerts/service.d.ts +8 -0
  104. package/dist/services/price-alerts/service.d.ts.map +1 -0
  105. package/dist/services/price-alerts/service.js +9 -0
  106. package/dist/services/price-alerts/service.js.map +1 -0
  107. package/dist/services/rewards/rewards.schemas.d.ts +4 -4
  108. package/dist/services/social-verification/social-verification.d.ts +1 -1
  109. package/dist/services/social-verification/social-verification.js +1 -1
  110. package/dist/services/social-verification/social-verification.js.map +1 -1
  111. package/dist/services/subaccounts/subaccounts.d.ts +6 -6
  112. package/dist/services/subaccounts/subaccounts.js +6 -6
  113. package/dist/services/subaccounts/subaccounts.js.map +1 -1
  114. package/dist/services/subaccounts/subaccounts.schemas.d.ts +21 -21
  115. package/dist/services/system/service.d.ts +8 -0
  116. package/dist/services/system/service.d.ts.map +1 -0
  117. package/dist/services/system/service.js +9 -0
  118. package/dist/services/system/service.js.map +1 -0
  119. package/dist/services/system/system.d.ts +25 -0
  120. package/dist/services/system/system.d.ts.map +1 -0
  121. package/dist/services/system/system.js +24 -0
  122. package/dist/services/system/system.js.map +1 -0
  123. package/dist/services/trades/trades.js +1 -1
  124. package/dist/services/trades/trades.schemas.d.ts +2 -2
  125. package/dist/services/trades/trades.schemas.js +1 -1
  126. package/dist/services/trading-withdraws/trading-withdraws.d.ts +1 -1
  127. package/dist/services/trading-withdraws/trading-withdraws.js +1 -1
  128. package/dist/services/trading-withdraws/trading-withdraws.js.map +1 -1
  129. package/dist/services/triggers/trigger-child-order.schemas.js +1 -1
  130. package/dist/services/triggers/trigger-input.schemas.d.ts +1 -1
  131. package/dist/services/triggers/trigger-input.schemas.js +1 -1
  132. package/dist/services/triggers/triggers-output.schemas.d.ts +63 -63
  133. package/dist/services/triggers/triggers.codecs.js +1 -1
  134. package/dist/services/triggers/triggers.js +2 -2
  135. package/dist/services/vip/vip.d.ts +1 -1
  136. package/dist/services/vip/vip.js +1 -1
  137. package/dist/services/vip/vip.js.map +1 -1
  138. package/dist/shared/connect-error-mapping.d.ts.map +1 -1
  139. package/dist/shared/connect-error-mapping.js +1 -0
  140. package/dist/shared/connect-error-mapping.js.map +1 -1
  141. package/dist/shared/error-detail.d.ts +18 -10
  142. package/dist/shared/error-detail.d.ts.map +1 -1
  143. package/dist/shared/error-detail.js +2 -0
  144. package/dist/shared/error-detail.js.map +1 -1
  145. package/dist/shared/error-details/alerts.js +15 -0
  146. package/dist/shared/error-details/alerts.js.map +1 -0
  147. package/dist/shared/error-details/assistant.js +15 -0
  148. package/dist/shared/error-details/assistant.js.map +1 -0
  149. package/dist/wired-services.d.ts.map +1 -1
  150. package/dist/wired-services.js +11 -5
  151. package/dist/wired-services.js.map +1 -1
  152. package/package.json +1 -1
@@ -0,0 +1,135 @@
1
+ import { formatId } from "../../utils/base58-id.js";
2
+ import { tsObjToMs } from "../../utils/time.js";
3
+ import { idInputSchema, optionalSubaccountIdInputSchema } from "../../shared/schemas.js";
4
+ import { enumLabel } from "../../shared/proto-enum-codec.js";
5
+ import { ASSISTANT_APPROVAL_DECISION_VALUES, ApprovalDecisionCodec, AssistantKeyStateCodec, MemoryKindCodec, MessageRoleCodec } from "./assistant.codecs.js";
6
+ import { bytesToHex } from "@noble/hashes/utils.js";
7
+ import * as v from "valibot";
8
+ //#region src/services/assistant/assistant.schemas.ts
9
+ const IdempotencyKeySchema = v.pipe(v.string(), v.trim(), v.minLength(1));
10
+ function pageInputEntries(maxLimit) {
11
+ return {
12
+ /** Page size; omit for the server default. */
13
+ limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(maxLimit))),
14
+ /** The previous page's `nextPageToken`. */
15
+ pageToken: v.optional(v.pipe(v.string(), v.trim()))
16
+ };
17
+ }
18
+ const DestinationInputSchema = v.strictObject({
19
+ /** The client's id for the place, e.g. `"page-subaccounts"`: lowercase letters, digits and hyphens. */
20
+ id: v.pipe(v.string(), v.regex(/^[a-z0-9-]{1,64}$/, "destination id must be 1-64 of a-z, 0-9, -")),
21
+ /** Its name as the client shows it, 1 to 80 characters. */
22
+ title: v.pipe(v.string(), v.minLength(1), v.maxLength(80)),
23
+ /** What the user does there, at most 200 characters. */
24
+ description: v.optional(v.pipe(v.string(), v.maxLength(200)), "")
25
+ });
26
+ const SendAssistantMessageInputSchema = v.pipe(v.strictObject({
27
+ /** Conversation to continue; omit to start a new one. */
28
+ conversationId: v.optional(idInputSchema("conversationId")),
29
+ /** Message text, plain text or Markdown, 1 to 16000 characters. */
30
+ text: v.pipe(v.string(), v.minLength(1), v.maxLength(16e3)),
31
+ /** Client-chosen key, unique per caller. Repeat the request unchanged to resolve an unknown outcome. */
32
+ idempotencyKey: IdempotencyKeySchema,
33
+ /**
34
+ * Trading account the run reads and acts on. Omit to answer without account data: the
35
+ * run then has no account tools.
36
+ */
37
+ subaccountId: optionalSubaccountIdInputSchema(),
38
+ /** Places in the client the run may suggest, at most 100, each id once. */
39
+ destinations: v.optional(v.pipe(v.array(DestinationInputSchema), v.maxLength(100, "At most 100 destinations are allowed."), v.check((items) => new Set(items.map((d) => d.id)).size === items.length, "Destination ids must be distinct.")))
40
+ }));
41
+ const AssistantRunIdInputSchema = v.strictObject({ runId: idInputSchema("runId") });
42
+ const WatchAssistantRunInputSchema = v.pipe(v.strictObject({
43
+ runId: idInputSchema("runId"),
44
+ /** Return events after this seq. 0 (default) replays the run; pass the last seq received to resume. */
45
+ afterSeq: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(Number.MAX_SAFE_INTEGER)), 0)
46
+ }), v.transform(({ runId, afterSeq }) => ({
47
+ runId,
48
+ afterSeq: BigInt(afterSeq)
49
+ })));
50
+ const DecideAssistantApprovalInputSchema = v.pipe(v.strictObject({
51
+ approvalId: idInputSchema("approvalId"),
52
+ decision: v.picklist(ASSISTANT_APPROVAL_DECISION_VALUES)
53
+ }), v.transform(({ approvalId, decision }) => ({
54
+ approvalId,
55
+ decision: ApprovalDecisionCodec.inputToProto[decision]
56
+ })));
57
+ const ListAssistantConversationsInputSchema = v.strictObject(pageInputEntries(100));
58
+ const ListAssistantMessagesInputSchema = v.strictObject({
59
+ conversationId: idInputSchema("conversationId"),
60
+ ...pageInputEntries(200)
61
+ });
62
+ const ListAssistantMemoriesInputSchema = v.strictObject(pageInputEntries(200));
63
+ const DeleteAssistantMemoryInputSchema = v.strictObject({ memoryId: idInputSchema("memoryId") });
64
+ const PrepareAssistantKeysInputSchema = v.pipe(v.strictObject({
65
+ /** 1 to 64 accounts, each once. An entry without `subaccountId` is the main account. */
66
+ accounts: v.pipe(v.array(v.strictObject({ subaccountId: optionalSubaccountIdInputSchema() })), v.minLength(1, "At least one account is required."), v.maxLength(64, "At most 64 accounts are allowed.")) }), v.check(({ accounts }) => new Set(accounts.map((a) => a.subaccountId ?? 0n)).size === accounts.length, "Each account may be named only once."));
67
+ const CompleteAssistantKeysInputSchema = v.strictObject({ setupId: idInputSchema("setupId") });
68
+ function optionalId(id) {
69
+ return id ? formatId(id) : void 0;
70
+ }
71
+ function formatConversation(c) {
72
+ return {
73
+ conversationId: formatId(c.conversationId),
74
+ /** Empty until a title is available. */
75
+ title: c.title,
76
+ createdAt: tsObjToMs(c.createdAt),
77
+ updatedAt: tsObjToMs(c.updatedAt)
78
+ };
79
+ }
80
+ function formatMessage(m) {
81
+ return {
82
+ messageId: formatId(m.messageId),
83
+ role: enumLabel(MessageRoleCodec.protoToOutput, m.role),
84
+ /** Markdown. For an assistant message, its run's final text. */
85
+ text: m.text,
86
+ createdAt: tsObjToMs(m.createdAt),
87
+ /** Replay this run with `watchRun` from `afterSeq: 0` to show its tool activity and views. */
88
+ runId: formatId(m.runId)
89
+ };
90
+ }
91
+ function formatMemory(m) {
92
+ return {
93
+ memoryId: formatId(m.memoryId),
94
+ text: m.text,
95
+ createdAt: tsObjToMs(m.createdAt),
96
+ /** Omitted when the conversation it was learned in is unknown. */
97
+ conversationId: optionalId(m.conversationId),
98
+ kind: enumLabel(MemoryKindCodec.protoToOutput, m.kind)
99
+ };
100
+ }
101
+ function formatAssistantKey(k) {
102
+ return {
103
+ /** Omitted for the main account. */
104
+ subaccountId: optionalId(k.subaccountId),
105
+ keyId: k.keyId,
106
+ publicKeyEd25519: k.publicKeyEd25519,
107
+ publicKeyHex: bytesToHex(k.publicKeyEd25519),
108
+ state: enumLabel(AssistantKeyStateCodec.protoToOutput, k.state)
109
+ };
110
+ }
111
+ function formatPreparedAssistantKey(k) {
112
+ return {
113
+ /** Omitted for the main account. */
114
+ subaccountId: optionalId(k.subaccountId),
115
+ publicKeyEd25519: k.publicKeyEd25519,
116
+ publicKeyHex: bytesToHex(k.publicKeyEd25519),
117
+ /** Pass unchanged to `apiKeys.setAssistantKeys`. */
118
+ registrationProof: k.registrationProof,
119
+ /** Epoch ms; pass unchanged to `apiKeys.setAssistantKeys`. */
120
+ registrationDeadline: tsObjToMs(k.registrationDeadline)
121
+ };
122
+ }
123
+ function formatPrepareAssistantKeysResult(r) {
124
+ return {
125
+ setupId: formatId(r.setupId),
126
+ /** One key per requested account, in request order. */
127
+ keys: r.keys.map(formatPreparedAssistantKey),
128
+ /** Epoch ms after which the keys can no longer be registered. */
129
+ expiresAt: tsObjToMs(r.expiresAt)
130
+ };
131
+ }
132
+ //#endregion
133
+ export { AssistantRunIdInputSchema, CompleteAssistantKeysInputSchema, DecideAssistantApprovalInputSchema, DeleteAssistantMemoryInputSchema, ListAssistantConversationsInputSchema, ListAssistantMemoriesInputSchema, ListAssistantMessagesInputSchema, PrepareAssistantKeysInputSchema, SendAssistantMessageInputSchema, WatchAssistantRunInputSchema, formatAssistantKey, formatConversation, formatMemory, formatMessage, formatPrepareAssistantKeysResult, formatPreparedAssistantKey };
134
+
135
+ //# sourceMappingURL=assistant.schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assistant.schemas.js","names":[],"sources":["../../../src/services/assistant/assistant.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { bytesToHex } from \"@noble/hashes/utils.js\";\nimport type * as Proto from \"../../gen/ai/v1/assistant_pb.js\";\nimport { enumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { idInputSchema, optionalSubaccountIdInputSchema } from \"../../shared/schemas.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport { tsObjToMs } from \"../../utils/time.js\";\nimport {\n ASSISTANT_APPROVAL_DECISION_VALUES,\n ApprovalDecisionCodec,\n AssistantKeyStateCodec,\n MemoryKindCodec,\n MessageRoleCodec,\n} from \"./assistant.codecs.js\";\n\nconst IdempotencyKeySchema = v.pipe(v.string(), v.trim(), v.minLength(1));\n\nfunction pageInputEntries(maxLimit: number) {\n return {\n /** Page size; omit for the server default. */\n limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(maxLimit))),\n /** The previous page's `nextPageToken`. */\n pageToken: v.optional(v.pipe(v.string(), v.trim())),\n };\n}\n\nconst DestinationInputSchema = v.strictObject({\n /** The client's id for the place, e.g. `\"page-subaccounts\"`: lowercase letters, digits and hyphens. */\n id: v.pipe(\n v.string(),\n v.regex(/^[a-z0-9-]{1,64}$/, \"destination id must be 1-64 of a-z, 0-9, -\"),\n ),\n /** Its name as the client shows it, 1 to 80 characters. */\n title: v.pipe(v.string(), v.minLength(1), v.maxLength(80)),\n /** What the user does there, at most 200 characters. */\n description: v.optional(v.pipe(v.string(), v.maxLength(200)), \"\"),\n});\n\nexport const SendAssistantMessageInputSchema = v.pipe(\n v.strictObject({\n /** Conversation to continue; omit to start a new one. */\n conversationId: v.optional(idInputSchema(\"conversationId\")),\n /** Message text, plain text or Markdown, 1 to 16000 characters. */\n text: v.pipe(v.string(), v.minLength(1), v.maxLength(16_000)),\n /** Client-chosen key, unique per caller. Repeat the request unchanged to resolve an unknown outcome. */\n idempotencyKey: IdempotencyKeySchema,\n /**\n * Trading account the run reads and acts on. Omit to answer without account data: the\n * run then has no account tools.\n */\n subaccountId: optionalSubaccountIdInputSchema(),\n /** Places in the client the run may suggest, at most 100, each id once. */\n destinations: v.optional(\n v.pipe(\n v.array(DestinationInputSchema),\n v.maxLength(100, \"At most 100 destinations are allowed.\"),\n v.check(\n (items) => new Set(items.map((d) => d.id)).size === items.length,\n \"Destination ids must be distinct.\",\n ),\n ),\n ),\n }),\n);\n\nexport type SendAssistantMessageInput = v.InferInput<typeof SendAssistantMessageInputSchema>;\n\nexport const AssistantRunIdInputSchema = v.strictObject({ runId: idInputSchema(\"runId\") });\n\nexport type AssistantRunIdInput = v.InferInput<typeof AssistantRunIdInputSchema>;\n\nexport const WatchAssistantRunInputSchema = v.pipe(\n v.strictObject({\n runId: idInputSchema(\"runId\"),\n /** Return events after this seq. 0 (default) replays the run; pass the last seq received to resume. */\n afterSeq: v.optional(\n v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(Number.MAX_SAFE_INTEGER)),\n 0,\n ),\n }),\n v.transform(({ runId, afterSeq }) => ({ runId, afterSeq: BigInt(afterSeq) })),\n);\n\nexport type WatchAssistantRunInput = v.InferInput<typeof WatchAssistantRunInputSchema>;\n\nexport const DecideAssistantApprovalInputSchema = v.pipe(\n v.strictObject({\n approvalId: idInputSchema(\"approvalId\"),\n decision: v.picklist(ASSISTANT_APPROVAL_DECISION_VALUES),\n }),\n v.transform(({ approvalId, decision }) => ({\n approvalId,\n decision: ApprovalDecisionCodec.inputToProto[decision],\n })),\n);\n\nexport type DecideAssistantApprovalInput = v.InferInput<typeof DecideAssistantApprovalInputSchema>;\n\nexport const ListAssistantConversationsInputSchema = v.strictObject(pageInputEntries(100));\n\nexport type ListAssistantConversationsInput = v.InferInput<\n typeof ListAssistantConversationsInputSchema\n>;\n\nexport const ListAssistantMessagesInputSchema = v.strictObject({\n conversationId: idInputSchema(\"conversationId\"),\n ...pageInputEntries(200),\n});\n\nexport type ListAssistantMessagesInput = v.InferInput<typeof ListAssistantMessagesInputSchema>;\n\nexport const ListAssistantMemoriesInputSchema = v.strictObject(pageInputEntries(200));\n\nexport type ListAssistantMemoriesInput = v.InferInput<typeof ListAssistantMemoriesInputSchema>;\n\nexport const DeleteAssistantMemoryInputSchema = v.strictObject({\n memoryId: idInputSchema(\"memoryId\"),\n});\n\nexport type DeleteAssistantMemoryInput = v.InferInput<typeof DeleteAssistantMemoryInputSchema>;\n\nexport const PrepareAssistantKeysInputSchema = v.pipe(\n v.strictObject({\n /** 1 to 64 accounts, each once. An entry without `subaccountId` is the main account. */\n accounts: v.pipe(\n v.array(v.strictObject({ subaccountId: optionalSubaccountIdInputSchema() })),\n v.minLength(1, \"At least one account is required.\"),\n v.maxLength(64, \"At most 64 accounts are allowed.\"),\n ),\n }),\n v.check(\n ({ accounts }) =>\n new Set(accounts.map((a) => a.subaccountId ?? 0n)).size === accounts.length,\n \"Each account may be named only once.\",\n ),\n);\n\nexport type PrepareAssistantKeysInput = v.InferInput<typeof PrepareAssistantKeysInputSchema>;\n\nexport const CompleteAssistantKeysInputSchema = v.strictObject({\n setupId: idInputSchema(\"setupId\"),\n});\n\nexport type CompleteAssistantKeysInput = v.InferInput<typeof CompleteAssistantKeysInputSchema>;\n\n/* ---------- outputs ---------- */\n\nfunction optionalId(id: bigint | undefined): string | undefined {\n return id ? formatId(id) : undefined;\n}\n\nexport function formatConversation(c: Proto.Conversation) {\n return {\n conversationId: formatId(c.conversationId),\n /** Empty until a title is available. */\n title: c.title,\n createdAt: tsObjToMs(c.createdAt),\n updatedAt: tsObjToMs(c.updatedAt),\n };\n}\n\nexport type AssistantConversation = ReturnType<typeof formatConversation>;\n\nexport function formatMessage(m: Proto.Message) {\n return {\n messageId: formatId(m.messageId),\n role: enumLabel(MessageRoleCodec.protoToOutput, m.role),\n /** Markdown. For an assistant message, its run's final text. */\n text: m.text,\n createdAt: tsObjToMs(m.createdAt),\n /** Replay this run with `watchRun` from `afterSeq: 0` to show its tool activity and views. */\n runId: formatId(m.runId),\n };\n}\n\nexport type AssistantMessage = ReturnType<typeof formatMessage>;\n\nexport function formatMemory(m: Proto.Memory) {\n return {\n memoryId: formatId(m.memoryId),\n text: m.text,\n createdAt: tsObjToMs(m.createdAt),\n /** Omitted when the conversation it was learned in is unknown. */\n conversationId: optionalId(m.conversationId),\n kind: enumLabel(MemoryKindCodec.protoToOutput, m.kind),\n };\n}\n\nexport type AssistantMemory = ReturnType<typeof formatMemory>;\n\nexport function formatAssistantKey(k: Proto.AssistantKey) {\n return {\n /** Omitted for the main account. */\n subaccountId: optionalId(k.subaccountId),\n keyId: k.keyId,\n publicKeyEd25519: k.publicKeyEd25519,\n publicKeyHex: bytesToHex(k.publicKeyEd25519),\n state: enumLabel(AssistantKeyStateCodec.protoToOutput, k.state),\n };\n}\n\nexport type AssistantKey = ReturnType<typeof formatAssistantKey>;\n\nexport function formatPreparedAssistantKey(k: Proto.PreparedAssistantKey) {\n return {\n /** Omitted for the main account. */\n subaccountId: optionalId(k.subaccountId),\n publicKeyEd25519: k.publicKeyEd25519,\n publicKeyHex: bytesToHex(k.publicKeyEd25519),\n /** Pass unchanged to `apiKeys.setAssistantKeys`. */\n registrationProof: k.registrationProof,\n /** Epoch ms; pass unchanged to `apiKeys.setAssistantKeys`. */\n registrationDeadline: tsObjToMs(k.registrationDeadline),\n };\n}\n\nexport type PreparedAssistantKey = ReturnType<typeof formatPreparedAssistantKey>;\n\nexport function formatPrepareAssistantKeysResult(r: Proto.PrepareAssistantKeysResponse) {\n return {\n setupId: formatId(r.setupId),\n /** One key per requested account, in request order. */\n keys: r.keys.map(formatPreparedAssistantKey),\n /** Epoch ms after which the keys can no longer be registered. */\n expiresAt: tsObjToMs(r.expiresAt),\n };\n}\n\nexport type PrepareAssistantKeysResult = ReturnType<typeof formatPrepareAssistantKeysResult>;\n\n/** `nextPageToken` is empty when no more results exist. */\nexport type ListAssistantConversationsResult = {\n conversations: AssistantConversation[];\n nextPageToken: string;\n};\nexport type ListAssistantMessagesResult = { messages: AssistantMessage[]; nextPageToken: string };\nexport type ListAssistantMemoriesResult = { memories: AssistantMemory[]; nextPageToken: string };\n"],"mappings":";;;;;;;;AAeA,MAAM,uBAAuB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;AAExE,SAAS,iBAAiB,UAAkB;CACxC,OAAO;;EAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,SAAS,QAAQ,CAAC,CAAC;;EAEtF,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,CAAC;CACtD;AACJ;AAEA,MAAM,yBAAyB,EAAE,aAAa;;CAE1C,IAAI,EAAE,KACF,EAAE,OAAO,GACT,EAAE,MAAM,qBAAqB,4CAA4C,CAC7E;;CAEA,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,UAAU,EAAE,CAAC;;CAEzD,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,GAAG,CAAC,GAAG,EAAE;AACpE,CAAC;AAED,MAAa,kCAAkC,EAAE,KAC7C,EAAE,aAAa;;CAEX,gBAAgB,EAAE,SAAS,cAAc,gBAAgB,CAAC;;CAE1D,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,UAAU,IAAM,CAAC;;CAE5D,gBAAgB;;;;;CAKhB,cAAc,gCAAgC;;CAE9C,cAAc,EAAE,SACZ,EAAE,KACE,EAAE,MAAM,sBAAsB,GAC9B,EAAE,UAAU,KAAK,uCAAuC,GACxD,EAAE,OACG,UAAU,IAAI,IAAI,MAAM,KAAK,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,MAAM,QAC1D,mCACJ,CACJ,CACJ;AACJ,CAAC,CACL;AAIA,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CACpC;AACJ"}
@@ -0,0 +1,4 @@
1
+ import { AssistantApprovalPreview, AssistantOrderPreview, AssistantRunEvent, AssistantView } from "./assistant-events.schemas.js";
2
+ import { AssistantApprovalDecision, AssistantApprovalStatus, AssistantFailureCategory, AssistantKeyState, AssistantMemoryKind, AssistantMessageRole, AssistantOrderPriceField, AssistantPriceOffsetDirection, AssistantPriceRounding, AssistantReferencePriceSource, AssistantTriggerChangeAction, AssistantTriggerDirection, AssistantUnfilledSlicePolicy } from "./assistant.codecs.js";
3
+ import { AssistantConversation, AssistantKey, AssistantMemory, AssistantMessage, AssistantRunIdInput, CompleteAssistantKeysInput, DecideAssistantApprovalInput, DeleteAssistantMemoryInput, ListAssistantConversationsInput, ListAssistantConversationsResult, ListAssistantMemoriesInput, ListAssistantMemoriesResult, ListAssistantMessagesInput, ListAssistantMessagesResult, PrepareAssistantKeysInput, PrepareAssistantKeysResult, PreparedAssistantKey, SendAssistantMessageInput, WatchAssistantRunInput } from "./assistant.schemas.js";
4
+ export type { AssistantApprovalDecision, AssistantApprovalPreview, AssistantApprovalStatus, AssistantConversation, AssistantFailureCategory, AssistantKey, AssistantKeyState, AssistantMemory, AssistantMemoryKind, AssistantMessage, AssistantMessageRole, AssistantOrderPreview, AssistantOrderPriceField, AssistantPriceOffsetDirection, AssistantPriceRounding, AssistantReferencePriceSource, AssistantRunEvent, AssistantRunIdInput, AssistantTriggerChangeAction, AssistantTriggerDirection, AssistantUnfilledSlicePolicy, AssistantView, CompleteAssistantKeysInput, DecideAssistantApprovalInput, DeleteAssistantMemoryInput, ListAssistantConversationsInput, ListAssistantConversationsResult, ListAssistantMemoriesInput, ListAssistantMemoriesResult, ListAssistantMessagesInput, ListAssistantMessagesResult, PrepareAssistantKeysInput, PrepareAssistantKeysResult, PreparedAssistantKey, SendAssistantMessageInput, WatchAssistantRunInput };
@@ -0,0 +1,8 @@
1
+ import { AssistantService } from "./assistant.js";
2
+ import { PolyesterCore } from "../../core-client.js";
3
+ //#region src/services/assistant/service.d.ts
4
+ /** Returns the client's AssistantService, creating it on first use. */
5
+ declare const assistantService: (client: PolyesterCore) => AssistantService;
6
+ //#endregion
7
+ export { assistantService };
8
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","names":[],"sources":["../../../src/services/assistant/service.ts"],"mappings":";;;;cAIa,mBAAgB,QAAhB,kBAAgB"}
@@ -0,0 +1,9 @@
1
+ import { defineService } from "../../core-client.js";
2
+ import { AssistantService } from "./assistant.js";
3
+ //#region src/services/assistant/service.ts
4
+ /** Returns the client's AssistantService, creating it on first use. */
5
+ const assistantService = defineService((context) => new AssistantService(context.transports, context.scales));
6
+ //#endregion
7
+ export { assistantService };
8
+
9
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","names":[],"sources":["../../../src/services/assistant/service.ts"],"sourcesContent":["import { defineService } from \"../../core-client.js\";\nimport { AssistantService } from \"./assistant.js\";\n\n/** Returns the client's AssistantService, creating it on first use. */\nexport const assistantService = defineService(\n (context) => new AssistantService(context.transports, context.scales),\n);\n"],"mappings":";;;;AAIA,MAAa,mBAAmB,eAC3B,YAAY,IAAI,iBAAiB,QAAQ,YAAY,QAAQ,MAAM,CACxE"}
@@ -14,7 +14,7 @@ declare class ProfileService {
14
14
  #private;
15
15
  constructor(transports: AuthApiTransports, realtime: PolyesterRealtime);
16
16
  /**
17
- * Fetches the caller's public profile, including username eligibility/cooldown, verified social handles, avatar, VIP tier, and account creation timestamp.
17
+ * Fetches the caller's public profile, including username eligibility/cooldown, verified social handles, avatar, VIP tier, and account creation timestamp. API keys need `read-profile` and must be scoped to the main account.
18
18
  */
19
19
  get(options?: PolyesterRequestOptions): Promise<Profile>;
20
20
  /**
@@ -22,7 +22,7 @@ declare class ProfileService {
22
22
  */
23
23
  update(input: v.InferInput<typeof UpdateProfileInputSchema>, options?: PolyesterMutationOptions): Promise<Profile>;
24
24
  /**
25
- * Returns the caller's recent username changes, newest first, capped at 20 entries.
25
+ * Returns the caller's recent username changes, newest first, capped at 20 entries. API keys need `read-profile` and must be scoped to the main account.
26
26
  */
27
27
  getUsernameHistory(options?: PolyesterRequestOptions): Promise<UsernameHistoryEntry[]>;
28
28
  /**
@@ -17,7 +17,7 @@ var ProfileService = class {
17
17
  this.#realtime = realtime;
18
18
  }
19
19
  /**
20
- * Fetches the caller's public profile, including username eligibility/cooldown, verified social handles, avatar, VIP tier, and account creation timestamp.
20
+ * Fetches the caller's public profile, including username eligibility/cooldown, verified social handles, avatar, VIP tier, and account creation timestamp. API keys need `read-profile` and must be scoped to the main account.
21
21
  */
22
22
  async get(options) {
23
23
  const res = await this.#client.getProfile({}, toConnectCallOptions(options));
@@ -33,7 +33,7 @@ var ProfileService = class {
33
33
  return parse(ProfileSchema, res);
34
34
  }
35
35
  /**
36
- * Returns the caller's recent username changes, newest first, capped at 20 entries.
36
+ * Returns the caller's recent username changes, newest first, capped at 20 entries. API keys need `read-profile` and must be scoped to the main account.
37
37
  */
38
38
  async getUsernameHistory(options) {
39
39
  const res = await this.#client.getUsernameHistory({}, toConnectCallOptions(options));
@@ -1 +1 @@
1
- {"version":3,"file":"profile.js","names":["#client","Proto.ProfileService","#realtime","Proto.AccountIdentitySchema","AccountIdentitySchema"],"sources":["../../../../src/services/auth/profile/profile.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../../gen/auth/v1/profile_pb.js\";\nimport type { AuthApiTransports } from \"../../../shared/transports.js\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../../shared/validation.js\";\nimport { removeUndefined } from \"../../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../../shared/request-options.js\";\nimport {\n AccountIdentitySchema,\n ClaimGeneratedUsernameInputSchema,\n GeneratedUsernameOfferSchema,\n ProfileSchema,\n UpdateProfileInputSchema,\n UsernameHistoryEntrySchema,\n type AccountIdentity,\n type GeneratedUsernameOffer,\n type Profile,\n type UsernameHistoryEntry,\n} from \"./profile.schemas.js\";\nimport type { BaseSubscribeInput } from \"../../../shared/types.js\";\nimport type { PolyesterRealtime } from \"../../../realtime/index.js\";\n\ninterface SubscribeIdentityInput extends BaseSubscribeInput<AccountIdentity> {}\n\n/**\n * Manages the authenticated account's public profile and realtime identity updates.\n */\nexport class ProfileService {\n #client: Client<typeof Proto.ProfileService>;\n #realtime: PolyesterRealtime;\n\n constructor(transports: AuthApiTransports, realtime: PolyesterRealtime) {\n this.#client = createClient(Proto.ProfileService, transports.authApi);\n this.#realtime = realtime;\n }\n\n /**\n * Fetches the caller's public profile, including username eligibility/cooldown, verified social handles, avatar, VIP tier, and account creation timestamp.\n */\n async get(options?: PolyesterRequestOptions): Promise<Profile> {\n const res = await this.#client.getProfile({}, toConnectCallOptions(options));\n if (!res) throw new Error(\"Profile not found\");\n return parse(ProfileSchema, res);\n }\n\n /**\n * Updates only the provided mutable profile fields; omitted fields are unchanged, while present empty strings clear optional text fields such as bio, website, Twitter, and avatar URL.\n */\n async update(\n input: v.InferInput<typeof UpdateProfileInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Profile> {\n const validatedInput = parse(UpdateProfileInputSchema, input);\n const res = await this.#client.updateProfile(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n return parse(ProfileSchema, res);\n }\n\n /**\n * Returns the caller's recent username changes, newest first, capped at 20 entries.\n */\n async getUsernameHistory(options?: PolyesterRequestOptions): Promise<UsernameHistoryEntry[]> {\n const res = await this.#client.getUsernameHistory({}, toConnectCallOptions(options));\n return parse(v.array(UsernameHistoryEntrySchema), res.history);\n }\n\n /**\n * Returns five generated username options and the short-lived offer token required to claim one of them.\n */\n async generateUsernameOptions(\n options?: PolyesterRequestOptions,\n ): Promise<GeneratedUsernameOffer> {\n const res = await this.#client.generateUsernameOptions({}, toConnectCallOptions(options));\n return parse(GeneratedUsernameOfferSchema, res);\n }\n\n /**\n * Claims one username from a generated offer by its zero-based option index.\n */\n async claimGeneratedUsername(\n input: v.InferInput<typeof ClaimGeneratedUsernameInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Profile> {\n const validatedInput = parse(ClaimGeneratedUsernameInputSchema, input);\n const res = await this.#client.claimGeneratedUsername(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(ProfileSchema, res);\n }\n\n /**\n * Subscribes to public identity updates and emits normalized account identity records with base58 account IDs, username, avatar URL, and root smart-account address.\n */\n subscribeIdentity(input: SubscribeIdentityInput): () => void {\n const channel = \"public:identity:updates:proto\";\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.AccountIdentitySchema,\n onPublication: (data) => {\n const identity = parse(AccountIdentitySchema, data);\n input.onEvent(identity);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AA+BA,IAAa,iBAAb,MAA4B;CACxB;CACA;CAEA,YAAY,YAA+B,UAA6B;EACpE,KAAKA,UAAU,aAAaC,kBAAsB,WAAW,OAAO;EACpE,KAAKC,YAAY;CACrB;;;;CAKA,MAAM,IAAI,SAAqD;EAC3D,MAAM,MAAM,MAAM,KAAKF,QAAQ,WAAW,CAAC,GAAG,qBAAqB,OAAO,CAAC;EAC3E,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,mBAAmB;EAC7C,OAAO,MAAM,eAAe,GAAG;CACnC;;;;CAKA,MAAM,OACF,OACA,SACgB;EAChB,MAAM,iBAAiB,MAAM,0BAA0B,KAAK;EAC5D,MAAM,MAAM,MAAM,KAAKA,QAAQ,cAC3B,gBAAgB,cAAc,GAC9B,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,eAAe,GAAG;CACnC;;;;CAKA,MAAM,mBAAmB,SAAoE;EACzF,MAAM,MAAM,MAAM,KAAKA,QAAQ,mBAAmB,CAAC,GAAG,qBAAqB,OAAO,CAAC;EACnF,OAAO,MAAM,EAAE,MAAM,0BAA0B,GAAG,IAAI,OAAO;CACjE;;;;CAKA,MAAM,wBACF,SAC+B;EAC/B,MAAM,MAAM,MAAM,KAAKA,QAAQ,wBAAwB,CAAC,GAAG,qBAAqB,OAAO,CAAC;EACxF,OAAO,MAAM,8BAA8B,GAAG;CAClD;;;;CAKA,MAAM,uBACF,OACA,SACgB;EAChB,MAAM,iBAAiB,MAAM,mCAAmC,KAAK;EACrE,MAAM,MAAM,MAAM,KAAKA,QAAQ,uBAC3B,gBACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,eAAe,GAAG;CACnC;;;;CAKA,kBAAkB,OAA2C;EAEzD,OAAO,KAAKE,UAAU,oBAAoB;GACtC,SAAA;GACA,QAAQC;GACR,gBAAgB,SAAS;IACrB,MAAM,WAAW,MAAMC,yBAAuB,IAAI;IAClD,MAAM,QAAQ,QAAQ;GAC1B;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
1
+ {"version":3,"file":"profile.js","names":["#client","Proto.ProfileService","#realtime","Proto.AccountIdentitySchema","AccountIdentitySchema"],"sources":["../../../../src/services/auth/profile/profile.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../../gen/auth/v1/profile_pb.js\";\nimport type { AuthApiTransports } from \"../../../shared/transports.js\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../../shared/validation.js\";\nimport { removeUndefined } from \"../../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../../shared/request-options.js\";\nimport {\n AccountIdentitySchema,\n ClaimGeneratedUsernameInputSchema,\n GeneratedUsernameOfferSchema,\n ProfileSchema,\n UpdateProfileInputSchema,\n UsernameHistoryEntrySchema,\n type AccountIdentity,\n type GeneratedUsernameOffer,\n type Profile,\n type UsernameHistoryEntry,\n} from \"./profile.schemas.js\";\nimport type { BaseSubscribeInput } from \"../../../shared/types.js\";\nimport type { PolyesterRealtime } from \"../../../realtime/index.js\";\n\ninterface SubscribeIdentityInput extends BaseSubscribeInput<AccountIdentity> {}\n\n/**\n * Manages the authenticated account's public profile and realtime identity updates.\n */\nexport class ProfileService {\n #client: Client<typeof Proto.ProfileService>;\n #realtime: PolyesterRealtime;\n\n constructor(transports: AuthApiTransports, realtime: PolyesterRealtime) {\n this.#client = createClient(Proto.ProfileService, transports.authApi);\n this.#realtime = realtime;\n }\n\n /**\n * Fetches the caller's public profile, including username eligibility/cooldown, verified social handles, avatar, VIP tier, and account creation timestamp. API keys need `read-profile` and must be scoped to the main account.\n */\n async get(options?: PolyesterRequestOptions): Promise<Profile> {\n const res = await this.#client.getProfile({}, toConnectCallOptions(options));\n if (!res) throw new Error(\"Profile not found\");\n return parse(ProfileSchema, res);\n }\n\n /**\n * Updates only the provided mutable profile fields; omitted fields are unchanged, while present empty strings clear optional text fields such as bio, website, Twitter, and avatar URL.\n */\n async update(\n input: v.InferInput<typeof UpdateProfileInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Profile> {\n const validatedInput = parse(UpdateProfileInputSchema, input);\n const res = await this.#client.updateProfile(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n return parse(ProfileSchema, res);\n }\n\n /**\n * Returns the caller's recent username changes, newest first, capped at 20 entries. API keys need `read-profile` and must be scoped to the main account.\n */\n async getUsernameHistory(options?: PolyesterRequestOptions): Promise<UsernameHistoryEntry[]> {\n const res = await this.#client.getUsernameHistory({}, toConnectCallOptions(options));\n return parse(v.array(UsernameHistoryEntrySchema), res.history);\n }\n\n /**\n * Returns five generated username options and the short-lived offer token required to claim one of them.\n */\n async generateUsernameOptions(\n options?: PolyesterRequestOptions,\n ): Promise<GeneratedUsernameOffer> {\n const res = await this.#client.generateUsernameOptions({}, toConnectCallOptions(options));\n return parse(GeneratedUsernameOfferSchema, res);\n }\n\n /**\n * Claims one username from a generated offer by its zero-based option index.\n */\n async claimGeneratedUsername(\n input: v.InferInput<typeof ClaimGeneratedUsernameInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Profile> {\n const validatedInput = parse(ClaimGeneratedUsernameInputSchema, input);\n const res = await this.#client.claimGeneratedUsername(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(ProfileSchema, res);\n }\n\n /**\n * Subscribes to public identity updates and emits normalized account identity records with base58 account IDs, username, avatar URL, and root smart-account address.\n */\n subscribeIdentity(input: SubscribeIdentityInput): () => void {\n const channel = \"public:identity:updates:proto\";\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.AccountIdentitySchema,\n onPublication: (data) => {\n const identity = parse(AccountIdentitySchema, data);\n input.onEvent(identity);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AA+BA,IAAa,iBAAb,MAA4B;CACxB;CACA;CAEA,YAAY,YAA+B,UAA6B;EACpE,KAAKA,UAAU,aAAaC,kBAAsB,WAAW,OAAO;EACpE,KAAKC,YAAY;CACrB;;;;CAKA,MAAM,IAAI,SAAqD;EAC3D,MAAM,MAAM,MAAM,KAAKF,QAAQ,WAAW,CAAC,GAAG,qBAAqB,OAAO,CAAC;EAC3E,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,mBAAmB;EAC7C,OAAO,MAAM,eAAe,GAAG;CACnC;;;;CAKA,MAAM,OACF,OACA,SACgB;EAChB,MAAM,iBAAiB,MAAM,0BAA0B,KAAK;EAC5D,MAAM,MAAM,MAAM,KAAKA,QAAQ,cAC3B,gBAAgB,cAAc,GAC9B,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,eAAe,GAAG;CACnC;;;;CAKA,MAAM,mBAAmB,SAAoE;EACzF,MAAM,MAAM,MAAM,KAAKA,QAAQ,mBAAmB,CAAC,GAAG,qBAAqB,OAAO,CAAC;EACnF,OAAO,MAAM,EAAE,MAAM,0BAA0B,GAAG,IAAI,OAAO;CACjE;;;;CAKA,MAAM,wBACF,SAC+B;EAC/B,MAAM,MAAM,MAAM,KAAKA,QAAQ,wBAAwB,CAAC,GAAG,qBAAqB,OAAO,CAAC;EACxF,OAAO,MAAM,8BAA8B,GAAG;CAClD;;;;CAKA,MAAM,uBACF,OACA,SACgB;EAChB,MAAM,iBAAiB,MAAM,mCAAmC,KAAK;EACrE,MAAM,MAAM,MAAM,KAAKA,QAAQ,uBAC3B,gBACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,eAAe,GAAG;CACnC;;;;CAKA,kBAAkB,OAA2C;EAEzD,OAAO,KAAKE,UAAU,oBAAoB;GACtC,SAAA;GACA,QAAQC;GACR,gBAAgB,SAAS;IACrB,MAAM,WAAW,MAAMC,yBAAuB,IAAI;IAClD,MAAM,QAAQ,QAAQ;GAC1B;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
@@ -500,7 +500,7 @@ declare const AutoWithdrawStepSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
500
500
  readonly hi: v.BigintSchema<undefined>;
501
501
  readonly lo: v.BigintSchema<undefined>;
502
502
  }, undefined>, undefined>;
503
- readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "completed" | "skipped" | "pending" | "submitting" | "submitted">]>;
503
+ readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "completed" | "failed" | "skipped" | "pending" | "submitting" | "submitted">]>;
504
504
  readonly reason: v.SchemaWithPipe<readonly [v.OptionalSchema<v.StringSchema<undefined>, "">, v.TransformAction<string, AutoWithdrawStepReason | null>]>;
505
505
  readonly intentId: v.OptionalSchema<v.StringSchema<undefined>, "">;
506
506
  readonly txHash: v.OptionalSchema<v.StringSchema<undefined>, "">;
@@ -524,7 +524,7 @@ declare const AutoWithdrawStepSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
524
524
  hi: bigint;
525
525
  lo: bigint;
526
526
  } | undefined;
527
- state: "unspecified" | "failed" | "completed" | "skipped" | "pending" | "submitting" | "submitted";
527
+ state: "unspecified" | "completed" | "failed" | "skipped" | "pending" | "submitting" | "submitted";
528
528
  reason: AutoWithdrawStepReason | null;
529
529
  intentId: string;
530
530
  txHash: string;
@@ -538,7 +538,7 @@ declare const AutoWithdrawStepSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
538
538
  txHash: string | null;
539
539
  assetId: number;
540
540
  destinationAddress: string;
541
- state: "unspecified" | "failed" | "completed" | "skipped" | "pending" | "submitting" | "submitted";
541
+ state: "unspecified" | "completed" | "failed" | "skipped" | "pending" | "submitting" | "submitted";
542
542
  reason: AutoWithdrawStepReason | null;
543
543
  }>]>;
544
544
  /**
@@ -559,7 +559,7 @@ declare const AutoWithdrawRunSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
559
559
  seconds: bigint;
560
560
  nanos: number;
561
561
  }, number>]>;
562
- readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "planned" | "paying" | "completed" | "partially_failed" | "skipped">]>;
562
+ readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "planned" | "paying" | "completed" | "partially_failed" | "failed" | "skipped">]>;
563
563
  readonly reason: v.SchemaWithPipe<readonly [v.OptionalSchema<v.StringSchema<undefined>, "">, v.TransformAction<string, AutoWithdrawRunReason | null>]>;
564
564
  readonly steps: v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
565
565
  readonly assetId: v.NumberSchema<undefined>;
@@ -581,7 +581,7 @@ declare const AutoWithdrawRunSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
581
581
  readonly hi: v.BigintSchema<undefined>;
582
582
  readonly lo: v.BigintSchema<undefined>;
583
583
  }, undefined>, undefined>;
584
- readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "completed" | "skipped" | "pending" | "submitting" | "submitted">]>;
584
+ readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "completed" | "failed" | "skipped" | "pending" | "submitting" | "submitted">]>;
585
585
  readonly reason: v.SchemaWithPipe<readonly [v.OptionalSchema<v.StringSchema<undefined>, "">, v.TransformAction<string, AutoWithdrawStepReason | null>]>;
586
586
  readonly intentId: v.OptionalSchema<v.StringSchema<undefined>, "">;
587
587
  readonly txHash: v.OptionalSchema<v.StringSchema<undefined>, "">;
@@ -605,7 +605,7 @@ declare const AutoWithdrawRunSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
605
605
  hi: bigint;
606
606
  lo: bigint;
607
607
  } | undefined;
608
- state: "unspecified" | "failed" | "completed" | "skipped" | "pending" | "submitting" | "submitted";
608
+ state: "unspecified" | "completed" | "failed" | "skipped" | "pending" | "submitting" | "submitted";
609
609
  reason: AutoWithdrawStepReason | null;
610
610
  intentId: string;
611
611
  txHash: string;
@@ -619,7 +619,7 @@ declare const AutoWithdrawRunSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
619
619
  txHash: string | null;
620
620
  assetId: number;
621
621
  destinationAddress: string;
622
- state: "unspecified" | "failed" | "completed" | "skipped" | "pending" | "submitting" | "submitted";
622
+ state: "unspecified" | "completed" | "failed" | "skipped" | "pending" | "submitting" | "submitted";
623
623
  reason: AutoWithdrawStepReason | null;
624
624
  }>]>, undefined>;
625
625
  readonly createdAt: v.SchemaWithPipe<readonly [v.ObjectSchema<{
@@ -640,7 +640,7 @@ declare const AutoWithdrawRunSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
640
640
  runSeq: string;
641
641
  ruleVersion: number;
642
642
  scheduledFor: number;
643
- state: "unspecified" | "failed" | "planned" | "paying" | "completed" | "partially_failed" | "skipped";
643
+ state: "unspecified" | "planned" | "paying" | "completed" | "partially_failed" | "failed" | "skipped";
644
644
  reason: AutoWithdrawRunReason | null;
645
645
  steps: {
646
646
  destinationChainId: number;
@@ -652,7 +652,7 @@ declare const AutoWithdrawRunSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
652
652
  txHash: string | null;
653
653
  assetId: number;
654
654
  destinationAddress: string;
655
- state: "unspecified" | "failed" | "completed" | "skipped" | "pending" | "submitting" | "submitted";
655
+ state: "unspecified" | "completed" | "failed" | "skipped" | "pending" | "submitting" | "submitted";
656
656
  reason: AutoWithdrawStepReason | null;
657
657
  }[];
658
658
  createdAt: number;
@@ -662,7 +662,7 @@ declare const AutoWithdrawRunSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
662
662
  runSeq: string;
663
663
  ruleVersion: number;
664
664
  scheduledFor: number;
665
- state: "unspecified" | "failed" | "planned" | "paying" | "completed" | "partially_failed" | "skipped";
665
+ state: "unspecified" | "planned" | "paying" | "completed" | "partially_failed" | "failed" | "skipped";
666
666
  reason: AutoWithdrawRunReason | null;
667
667
  steps: {
668
668
  destinationChainId: number;
@@ -674,7 +674,7 @@ declare const AutoWithdrawRunSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
674
674
  txHash: string | null;
675
675
  assetId: number;
676
676
  destinationAddress: string;
677
- state: "unspecified" | "failed" | "completed" | "skipped" | "pending" | "submitting" | "submitted";
677
+ state: "unspecified" | "completed" | "failed" | "skipped" | "pending" | "submitting" | "submitted";
678
678
  reason: AutoWithdrawStepReason | null;
679
679
  }[];
680
680
  createdAt: number;
@@ -692,7 +692,7 @@ declare const ListAutoWithdrawRunsResultSchema: v.ObjectSchema<{
692
692
  seconds: bigint;
693
693
  nanos: number;
694
694
  }, number>]>;
695
- readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "planned" | "paying" | "completed" | "partially_failed" | "skipped">]>;
695
+ readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "planned" | "paying" | "completed" | "partially_failed" | "failed" | "skipped">]>;
696
696
  readonly reason: v.SchemaWithPipe<readonly [v.OptionalSchema<v.StringSchema<undefined>, "">, v.TransformAction<string, AutoWithdrawRunReason | null>]>;
697
697
  readonly steps: v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
698
698
  readonly assetId: v.NumberSchema<undefined>;
@@ -714,7 +714,7 @@ declare const ListAutoWithdrawRunsResultSchema: v.ObjectSchema<{
714
714
  readonly hi: v.BigintSchema<undefined>;
715
715
  readonly lo: v.BigintSchema<undefined>;
716
716
  }, undefined>, undefined>;
717
- readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "completed" | "skipped" | "pending" | "submitting" | "submitted">]>;
717
+ readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "completed" | "failed" | "skipped" | "pending" | "submitting" | "submitted">]>;
718
718
  readonly reason: v.SchemaWithPipe<readonly [v.OptionalSchema<v.StringSchema<undefined>, "">, v.TransformAction<string, AutoWithdrawStepReason | null>]>;
719
719
  readonly intentId: v.OptionalSchema<v.StringSchema<undefined>, "">;
720
720
  readonly txHash: v.OptionalSchema<v.StringSchema<undefined>, "">;
@@ -738,7 +738,7 @@ declare const ListAutoWithdrawRunsResultSchema: v.ObjectSchema<{
738
738
  hi: bigint;
739
739
  lo: bigint;
740
740
  } | undefined;
741
- state: "unspecified" | "failed" | "completed" | "skipped" | "pending" | "submitting" | "submitted";
741
+ state: "unspecified" | "completed" | "failed" | "skipped" | "pending" | "submitting" | "submitted";
742
742
  reason: AutoWithdrawStepReason | null;
743
743
  intentId: string;
744
744
  txHash: string;
@@ -752,7 +752,7 @@ declare const ListAutoWithdrawRunsResultSchema: v.ObjectSchema<{
752
752
  txHash: string | null;
753
753
  assetId: number;
754
754
  destinationAddress: string;
755
- state: "unspecified" | "failed" | "completed" | "skipped" | "pending" | "submitting" | "submitted";
755
+ state: "unspecified" | "completed" | "failed" | "skipped" | "pending" | "submitting" | "submitted";
756
756
  reason: AutoWithdrawStepReason | null;
757
757
  }>]>, undefined>;
758
758
  readonly createdAt: v.SchemaWithPipe<readonly [v.ObjectSchema<{
@@ -773,7 +773,7 @@ declare const ListAutoWithdrawRunsResultSchema: v.ObjectSchema<{
773
773
  runSeq: string;
774
774
  ruleVersion: number;
775
775
  scheduledFor: number;
776
- state: "unspecified" | "failed" | "planned" | "paying" | "completed" | "partially_failed" | "skipped";
776
+ state: "unspecified" | "planned" | "paying" | "completed" | "partially_failed" | "failed" | "skipped";
777
777
  reason: AutoWithdrawRunReason | null;
778
778
  steps: {
779
779
  destinationChainId: number;
@@ -785,7 +785,7 @@ declare const ListAutoWithdrawRunsResultSchema: v.ObjectSchema<{
785
785
  txHash: string | null;
786
786
  assetId: number;
787
787
  destinationAddress: string;
788
- state: "unspecified" | "failed" | "completed" | "skipped" | "pending" | "submitting" | "submitted";
788
+ state: "unspecified" | "completed" | "failed" | "skipped" | "pending" | "submitting" | "submitted";
789
789
  reason: AutoWithdrawStepReason | null;
790
790
  }[];
791
791
  createdAt: number;
@@ -795,7 +795,7 @@ declare const ListAutoWithdrawRunsResultSchema: v.ObjectSchema<{
795
795
  runSeq: string;
796
796
  ruleVersion: number;
797
797
  scheduledFor: number;
798
- state: "unspecified" | "failed" | "planned" | "paying" | "completed" | "partially_failed" | "skipped";
798
+ state: "unspecified" | "planned" | "paying" | "completed" | "partially_failed" | "failed" | "skipped";
799
799
  reason: AutoWithdrawRunReason | null;
800
800
  steps: {
801
801
  destinationChainId: number;
@@ -807,7 +807,7 @@ declare const ListAutoWithdrawRunsResultSchema: v.ObjectSchema<{
807
807
  txHash: string | null;
808
808
  assetId: number;
809
809
  destinationAddress: string;
810
- state: "unspecified" | "failed" | "completed" | "skipped" | "pending" | "submitting" | "submitted";
810
+ state: "unspecified" | "completed" | "failed" | "skipped" | "pending" | "submitting" | "submitted";
811
811
  reason: AutoWithdrawStepReason | null;
812
812
  }[];
813
813
  createdAt: number;
@@ -5,8 +5,8 @@ import { enumLabel, enumLabelSchema } from "../../shared/proto-enum-codec.js";
5
5
  import { decimalInputToScaled, scaledToDecimalOutput } from "../../shared/decimal-surface.js";
6
6
  import { PositiveUint32InputSchema } from "../shared.js";
7
7
  import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
8
- import "../../gen/chain/withdraw/v1/auto_withdraw_pb.js";
9
8
  import { fromU128, toU128 } from "../../utils/u128.js";
9
+ import "../../gen/chain/withdraw/v1/auto_withdraw_pb.js";
10
10
  import { AUTO_WITHDRAW_WEEKDAY_VALUES, AutoWithdrawCadenceCodec, AutoWithdrawPreviewStatusCodec, AutoWithdrawRunStateCodec, AutoWithdrawStepStateCodec, AutoWithdrawWeekdayCodec } from "./auto-withdraw.codecs.js";
11
11
  import * as v from "valibot";
12
12
  //#region src/services/auto-withdraw/auto-withdraw.schemas.ts
@@ -3,8 +3,8 @@ import { toConnectCallOptions } from "../../shared/request-options.js";
3
3
  import { AssetBalanceSchema, LedgerReadService } from "../../gen/ledger/read/v1/ledger_read_pb.js";
4
4
  import { resolveAccountScopedInput } from "../subaccount-resolver.js";
5
5
  import { accountScopeToSubaccountId } from "../../shared/account-scope.js";
6
- import { connectReadyGatedProtoChannel } from "../../realtime/ready-gated-subscription.js";
7
6
  import { BalanceHistoryInputSchema, BalancesListInputSchema, EquityHistoryInputSchema, PortfolioEquityHistoryInputSchema, createBalanceHistoryResponseSchema, createEquityHistoryResponseSchema, createPortfolioEquityHistoryResponseSchema, createPortfolioEquitySnapshotResponseSchema, formatLedgerBalance } from "./balances.schemas.js";
7
+ import { connectReadyGatedProtoChannel } from "../../realtime/ready-gated-subscription.js";
8
8
  import { createClient } from "@connectrpc/connect";
9
9
  //#region src/services/balances/balances.ts
10
10
  /**
@@ -1,10 +1,10 @@
1
1
  import { parse } from "../../shared/validation.js";
2
2
  import { toConnectCallOptions } from "../../shared/request-options.js";
3
3
  import { SymbolIdInputSchema } from "../shared.js";
4
- import { connectReadyGatedProtoChannel } from "../../realtime/ready-gated-subscription.js";
5
4
  import { CandlePointSchema, MarketDataService } from "../../gen/marketdata/v1/marketdata_pb.js";
6
5
  import { TimeframeCodec } from "./candles.codecs.js";
7
6
  import { ListCandlesInputSchema, TimeframeSchema, createCandleColumnarIntSchema, createCandleColumnarSchema, formatCandleRow } from "./candles.schemas.js";
7
+ import { connectReadyGatedProtoChannel } from "../../realtime/ready-gated-subscription.js";
8
8
  import { createClient } from "@connectrpc/connect";
9
9
  import * as v from "valibot";
10
10
  //#region src/services/candles/candles.ts
@@ -18,7 +18,7 @@ function timestampFromTsSec(tsSec) {
18
18
  nanos: 0
19
19
  };
20
20
  }
21
- v.object({
21
+ const CandleRowRawSchema = v.object({
22
22
  symbolId: v.number(),
23
23
  timeframe: v.pipe(v.number(), v.transform((v) => timeframeFromProto(v))),
24
24
  tsSec: v.bigint(),
@@ -45,6 +45,9 @@ function toCandleRow(scales, data) {
45
45
  isClosed: data.isClosed
46
46
  };
47
47
  }
48
+ function createCandleRowSchema(scales) {
49
+ return v.pipe(CandleRowRawSchema, v.transform((data) => toCandleRow(scales, data)));
50
+ }
48
51
  /**
49
52
  * Formats a protobuf-decoded candle point like {@link createCandleRowSchema} without
50
53
  * re-validating it. `timeframe` is the proto enum value of the series.
@@ -171,6 +174,6 @@ const ListCandlesInputSchema = v.pipe(v.object({
171
174
  pageToken: d.pageToken
172
175
  })));
173
176
  //#endregion
174
- export { ListCandlesInputSchema, TimeframeSchema, createCandleColumnarIntSchema, createCandleColumnarSchema, formatCandleRow };
177
+ export { ListCandlesInputSchema, TimeframeSchema, createCandleColumnarIntSchema, createCandleColumnarSchema, createCandleRowSchema, formatCandleRow };
175
178
 
176
179
  //# sourceMappingURL=candles.schemas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"candles.schemas.js","names":[],"sources":["../../../src/services/candles/candles.schemas.ts"],"sourcesContent":["import { SymbolIdInputSchema } from \"../shared.js\";\nimport * as v from \"valibot\";\nimport type * as ProtoMarketData from \"../../gen/marketdata/v1/marketdata_pb.js\";\nimport type { DecodedEnum } from \"../../utils/types.js\";\nimport { OptionalTimestampSecondsInputSchema } from \"../../shared/schemas.js\";\nimport { enumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { TIMEFRAMES, TimeframeCodec } from \"./candles.codecs.js\";\n\nexport const TimeframeSchema = v.picklist(TIMEFRAMES);\n\nexport type Timeframe = v.InferOutput<typeof TimeframeSchema>;\n\nfunction timeframeFromProto(value: number): DecodedEnum<Timeframe> {\n return enumLabel(TimeframeCodec.protoToOutput, value);\n}\n\nconst TimeframeInputSchema = v.pipe(\n TimeframeSchema,\n v.transform((value) => TimeframeCodec.inputToProto[value]),\n);\n\nconst OptionalPositiveNumberSchema = v.optional(\n v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(10_000)),\n);\n\nconst OptionalBooleanSchema = v.optional(v.boolean(), false);\n\ntype TimestampInit = { seconds: bigint; nanos: number };\n\nfunction timestampFromTsSec(tsSec: bigint): TimestampInit {\n return { seconds: tsSec, nanos: 0 };\n}\n\nconst CandleRowRawSchema = v.object({\n symbolId: v.number(),\n timeframe: v.pipe(\n v.number(),\n v.transform((v) => timeframeFromProto(v)),\n ),\n tsSec: v.bigint(),\n open: v.bigint(),\n high: v.bigint(),\n low: v.bigint(),\n close: v.bigint(),\n volume: v.bigint(),\n quoteVolume: v.string(),\n isClosed: v.optional(v.boolean(), false),\n});\n\nfunction toCandleRow(scales: SdkScales, data: v.InferOutput<typeof CandleRowRawSchema>) {\n const priceScale = scales.price();\n return {\n symbolId: data.symbolId,\n timeframe: data.timeframe,\n time: Number(data.tsSec),\n open: scaledToDecimalOutput(data.open, priceScale),\n high: scaledToDecimalOutput(data.high, priceScale),\n low: scaledToDecimalOutput(data.low, priceScale),\n close: scaledToDecimalOutput(data.close, priceScale),\n volume: scaledToDecimalOutput(data.volume, scales.marketDataVolume(data.symbolId)),\n quoteVolume: data.quoteVolume,\n isClosed: data.isClosed,\n };\n}\n\nexport function createCandleRowSchema(scales: SdkScales) {\n return v.pipe(\n CandleRowRawSchema,\n v.transform((data) => toCandleRow(scales, data)),\n );\n}\n\n/**\n * Formats a protobuf-decoded candle point like {@link createCandleRowSchema} without\n * re-validating it. `timeframe` is the proto enum value of the series.\n */\nexport function formatCandleRow(\n scales: SdkScales,\n point: ProtoMarketData.CandlePoint,\n symbolId: number,\n timeframe: number,\n): Candle {\n return toCandleRow(scales, {\n symbolId,\n timeframe: timeframeFromProto(timeframe),\n tsSec: point.tsSec,\n open: point.open,\n high: point.high,\n low: point.low,\n close: point.close,\n volume: point.volume,\n quoteVolume: point.quoteVolume,\n isClosed: point.isClosed ?? false,\n });\n}\n\nexport const createCandleRowIntSchema = createCandleRowSchema;\n\nexport const CandlePointSchema = v.object({\n tsSec: v.bigint(),\n open: v.bigint(),\n high: v.bigint(),\n low: v.bigint(),\n close: v.bigint(),\n volume: v.bigint(),\n quoteVolume: v.string(),\n isClosed: v.optional(v.boolean(), false),\n});\n\nconst CandleColumnarRawSchema = v.object({\n symbolId: v.number(),\n timeframe: v.pipe(\n v.number(),\n v.transform((v) => timeframeFromProto(v)),\n ),\n tsSec: v.array(v.bigint()),\n open: v.array(v.bigint()),\n high: v.array(v.bigint()),\n low: v.array(v.bigint()),\n close: v.array(v.bigint()),\n volume: v.array(v.bigint()),\n quoteVolume: v.array(v.string()),\n referenceTsSec: v.optional(v.array(v.bigint()), []),\n referenceOpen: v.optional(v.array(v.bigint()), []),\n referenceHigh: v.optional(v.array(v.bigint()), []),\n referenceLow: v.optional(v.array(v.bigint()), []),\n referenceClose: v.optional(v.array(v.bigint()), []),\n referenceVolume: v.optional(v.array(v.bigint()), []),\n nextPageToken: v.optional(v.string(), \"\"),\n});\n\nfunction scaledArrayToDecimal(values: bigint[], scale: number): string[] {\n return values.map((value) => scaledToDecimalOutput(value, scale));\n}\n\nexport function createCandleColumnarSchema(scales: SdkScales) {\n return v.pipe(\n CandleColumnarRawSchema,\n v.transform((d) => {\n const priceScale = scales.price();\n const referencePriceScale = scales.referencePrice(d.symbolId);\n const volumeScale = scales.marketDataVolume(d.symbolId);\n const referenceTsSec = d.referenceTsSec ?? [];\n const hasReference = referenceTsSec.length > 0;\n return {\n symbolId: d.symbolId,\n timeframe: d.timeframe,\n time: d.tsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(d.open, priceScale),\n high: scaledArrayToDecimal(d.high, priceScale),\n low: scaledArrayToDecimal(d.low, priceScale),\n close: scaledArrayToDecimal(d.close, priceScale),\n volume: scaledArrayToDecimal(d.volume, volumeScale),\n quoteVolume: d.quoteVolume,\n nextPageToken: d.nextPageToken,\n reference: hasReference\n ? {\n time: referenceTsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(d.referenceOpen ?? [], referencePriceScale),\n high: scaledArrayToDecimal(d.referenceHigh ?? [], referencePriceScale),\n low: scaledArrayToDecimal(d.referenceLow ?? [], referencePriceScale),\n close: scaledArrayToDecimal(d.referenceClose ?? [], referencePriceScale),\n volume: scaledArrayToDecimal(d.referenceVolume ?? [], volumeScale),\n }\n : null,\n };\n }),\n );\n}\n\nexport function createCandleColumnarIntSchema(scales: SdkScales) {\n return v.pipe(\n CandleColumnarRawSchema,\n v.transform((d) => {\n const priceScale = scales.price();\n const referencePriceScale = scales.referencePrice(d.symbolId);\n const volumeScale = scales.marketDataVolume(d.symbolId);\n const referenceTsSec = d.referenceTsSec ?? [];\n return {\n symbolId: d.symbolId,\n timeframe: d.timeframe,\n tsSec: d.tsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(d.open, priceScale),\n high: scaledArrayToDecimal(d.high, priceScale),\n low: scaledArrayToDecimal(d.low, priceScale),\n close: scaledArrayToDecimal(d.close, priceScale),\n volume: scaledArrayToDecimal(d.volume, volumeScale),\n quoteVolume: d.quoteVolume,\n nextPageToken: d.nextPageToken,\n reference:\n referenceTsSec.length > 0\n ? {\n tsSec: referenceTsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(\n d.referenceOpen ?? [],\n referencePriceScale,\n ),\n high: scaledArrayToDecimal(\n d.referenceHigh ?? [],\n referencePriceScale,\n ),\n low: scaledArrayToDecimal(d.referenceLow ?? [], referencePriceScale),\n close: scaledArrayToDecimal(\n d.referenceClose ?? [],\n referencePriceScale,\n ),\n volume: scaledArrayToDecimal(d.referenceVolume ?? [], volumeScale),\n }\n : null,\n };\n }),\n );\n}\n\nexport type Candle = v.InferOutput<ReturnType<typeof createCandleRowSchema>>;\nexport type CandleInput = v.InferInput<ReturnType<typeof createCandleRowSchema>>;\nexport type CandleIntInput = v.InferInput<ReturnType<typeof createCandleRowIntSchema>>;\nexport type CandleInt = v.InferOutput<ReturnType<typeof createCandleRowIntSchema>>;\nexport type CandleColumnar = v.InferOutput<ReturnType<typeof createCandleColumnarSchema>>;\nexport type CandleColumnarInput = v.InferInput<ReturnType<typeof createCandleColumnarSchema>>;\nexport type CandleColumnarIntInput = v.InferInput<ReturnType<typeof createCandleColumnarIntSchema>>;\nexport type CandleColumnarInt = v.InferOutput<ReturnType<typeof createCandleColumnarIntSchema>>;\n\nexport const ListCandlesInputSchema = v.pipe(\n v.object({\n symbolId: SymbolIdInputSchema,\n timeframe: TimeframeInputSchema,\n limit: OptionalPositiveNumberSchema,\n includeIncomplete: v.optional(v.boolean(), false),\n includeReference: OptionalBooleanSchema,\n startTsSec: OptionalTimestampSecondsInputSchema,\n endTsSec: OptionalTimestampSecondsInputSchema,\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform((d) => ({\n symbolId: d.symbolId,\n timeframe: d.timeframe,\n limit: d.limit,\n includeIncomplete: d.includeIncomplete,\n includeReference: d.includeReference,\n startTime: d.startTsSec != null ? timestampFromTsSec(d.startTsSec) : undefined,\n endTime: d.endTsSec != null ? timestampFromTsSec(d.endTsSec) : undefined,\n pageToken: d.pageToken,\n })),\n);\n\nexport function createListCandlesInputSchema() {\n return ListCandlesInputSchema;\n}\n\nexport type GetCandlesInput = v.InferInput<ReturnType<typeof createListCandlesInputSchema>>;\nexport const createGetCandlesColumnsInputSchema = createListCandlesInputSchema;\nexport type GetCandlesColumnsInput = v.InferInput<ReturnType<typeof createListCandlesInputSchema>>;\n"],"mappings":";;;;;;;AASA,MAAa,kBAAkB,EAAE,SAAS,UAAU;AAIpD,SAAS,mBAAmB,OAAuC;CAC/D,OAAO,UAAU,eAAe,eAAe,KAAK;AACxD;AAEA,MAAM,uBAAuB,EAAE,KAC3B,iBACA,EAAE,WAAW,UAAU,eAAe,aAAa,MAAM,CAC7D;AAEA,MAAM,+BAA+B,EAAE,SACnC,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAM,CAAC,CACpE;AAEA,MAAM,wBAAwB,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;AAI3D,SAAS,mBAAmB,OAA8B;CACtD,OAAO;EAAE,SAAS;EAAO,OAAO;CAAE;AACtC;AAE2B,EAAE,OAAO;CAChC,UAAU,EAAE,OAAO;CACnB,WAAW,EAAE,KACT,EAAE,OAAO,GACT,EAAE,WAAW,MAAM,mBAAmB,CAAC,CAAC,CAC5C;CACA,OAAO,EAAE,OAAO;CAChB,MAAM,EAAE,OAAO;CACf,MAAM,EAAE,OAAO;CACf,KAAK,EAAE,OAAO;CACd,OAAO,EAAE,OAAO;CAChB,QAAQ,EAAE,OAAO;CACjB,aAAa,EAAE,OAAO;CACtB,UAAU,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;AAC3C,CAAC;AAED,SAAS,YAAY,QAAmB,MAAgD;CACpF,MAAM,aAAa,OAAO,MAAM;CAChC,OAAO;EACH,UAAU,KAAK;EACf,WAAW,KAAK;EAChB,MAAM,OAAO,KAAK,KAAK;EACvB,MAAM,sBAAsB,KAAK,MAAM,UAAU;EACjD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AAC,CACL;AACJ;AAWA,MAAa,yBAAyB,EAAE,KACpC,EAAE,OAAO;CACL,UAAU;CACV,WAAW;CACX,OAAO;CACP,mBAAmB,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;CAChD,kBAAkB;CAClB,YAAY;CACZ,UAAU;CACV,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;AAC1D,CAAC,GACD,EAAE,WAAW,OAAO;CAChB,UAAU,EAAE;CACZ,WAAW,EAAE;CACb,OAAO,EAAE;CACT,mBAAmB,EAAE;CACrB,kBAAkB,EAAE;CACpB,WAAW,EAAE,cAAc,OAAO,mBAAmB,EAAE,UAAU,IAAI,KAAA;CACrE,SAAS,EAAE,YAAY,OAAO,mBAAmB,EAAE,QAAQ,IAAI,KAAA;CAC/D,WAAW,EAAE;AACjB,EAAE,CACN"}
1
+ {"version":3,"file":"candles.schemas.js","names":[],"sources":["../../../src/services/candles/candles.schemas.ts"],"sourcesContent":["import { SymbolIdInputSchema } from \"../shared.js\";\nimport * as v from \"valibot\";\nimport type * as ProtoMarketData from \"../../gen/marketdata/v1/marketdata_pb.js\";\nimport type { DecodedEnum } from \"../../utils/types.js\";\nimport { OptionalTimestampSecondsInputSchema } from \"../../shared/schemas.js\";\nimport { enumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { TIMEFRAMES, TimeframeCodec } from \"./candles.codecs.js\";\n\nexport const TimeframeSchema = v.picklist(TIMEFRAMES);\n\nexport type Timeframe = v.InferOutput<typeof TimeframeSchema>;\n\nfunction timeframeFromProto(value: number): DecodedEnum<Timeframe> {\n return enumLabel(TimeframeCodec.protoToOutput, value);\n}\n\nconst TimeframeInputSchema = v.pipe(\n TimeframeSchema,\n v.transform((value) => TimeframeCodec.inputToProto[value]),\n);\n\nconst OptionalPositiveNumberSchema = v.optional(\n v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(10_000)),\n);\n\nconst OptionalBooleanSchema = v.optional(v.boolean(), false);\n\ntype TimestampInit = { seconds: bigint; nanos: number };\n\nfunction timestampFromTsSec(tsSec: bigint): TimestampInit {\n return { seconds: tsSec, nanos: 0 };\n}\n\nconst CandleRowRawSchema = v.object({\n symbolId: v.number(),\n timeframe: v.pipe(\n v.number(),\n v.transform((v) => timeframeFromProto(v)),\n ),\n tsSec: v.bigint(),\n open: v.bigint(),\n high: v.bigint(),\n low: v.bigint(),\n close: v.bigint(),\n volume: v.bigint(),\n quoteVolume: v.string(),\n isClosed: v.optional(v.boolean(), false),\n});\n\nfunction toCandleRow(scales: SdkScales, data: v.InferOutput<typeof CandleRowRawSchema>) {\n const priceScale = scales.price();\n return {\n symbolId: data.symbolId,\n timeframe: data.timeframe,\n time: Number(data.tsSec),\n open: scaledToDecimalOutput(data.open, priceScale),\n high: scaledToDecimalOutput(data.high, priceScale),\n low: scaledToDecimalOutput(data.low, priceScale),\n close: scaledToDecimalOutput(data.close, priceScale),\n volume: scaledToDecimalOutput(data.volume, scales.marketDataVolume(data.symbolId)),\n quoteVolume: data.quoteVolume,\n isClosed: data.isClosed,\n };\n}\n\nexport function createCandleRowSchema(scales: SdkScales) {\n return v.pipe(\n CandleRowRawSchema,\n v.transform((data) => toCandleRow(scales, data)),\n );\n}\n\n/**\n * Formats a protobuf-decoded candle point like {@link createCandleRowSchema} without\n * re-validating it. `timeframe` is the proto enum value of the series.\n */\nexport function formatCandleRow(\n scales: SdkScales,\n point: ProtoMarketData.CandlePoint,\n symbolId: number,\n timeframe: number,\n): Candle {\n return toCandleRow(scales, {\n symbolId,\n timeframe: timeframeFromProto(timeframe),\n tsSec: point.tsSec,\n open: point.open,\n high: point.high,\n low: point.low,\n close: point.close,\n volume: point.volume,\n quoteVolume: point.quoteVolume,\n isClosed: point.isClosed ?? false,\n });\n}\n\nexport const createCandleRowIntSchema = createCandleRowSchema;\n\nexport const CandlePointSchema = v.object({\n tsSec: v.bigint(),\n open: v.bigint(),\n high: v.bigint(),\n low: v.bigint(),\n close: v.bigint(),\n volume: v.bigint(),\n quoteVolume: v.string(),\n isClosed: v.optional(v.boolean(), false),\n});\n\nconst CandleColumnarRawSchema = v.object({\n symbolId: v.number(),\n timeframe: v.pipe(\n v.number(),\n v.transform((v) => timeframeFromProto(v)),\n ),\n tsSec: v.array(v.bigint()),\n open: v.array(v.bigint()),\n high: v.array(v.bigint()),\n low: v.array(v.bigint()),\n close: v.array(v.bigint()),\n volume: v.array(v.bigint()),\n quoteVolume: v.array(v.string()),\n referenceTsSec: v.optional(v.array(v.bigint()), []),\n referenceOpen: v.optional(v.array(v.bigint()), []),\n referenceHigh: v.optional(v.array(v.bigint()), []),\n referenceLow: v.optional(v.array(v.bigint()), []),\n referenceClose: v.optional(v.array(v.bigint()), []),\n referenceVolume: v.optional(v.array(v.bigint()), []),\n nextPageToken: v.optional(v.string(), \"\"),\n});\n\nfunction scaledArrayToDecimal(values: bigint[], scale: number): string[] {\n return values.map((value) => scaledToDecimalOutput(value, scale));\n}\n\nexport function createCandleColumnarSchema(scales: SdkScales) {\n return v.pipe(\n CandleColumnarRawSchema,\n v.transform((d) => {\n const priceScale = scales.price();\n const referencePriceScale = scales.referencePrice(d.symbolId);\n const volumeScale = scales.marketDataVolume(d.symbolId);\n const referenceTsSec = d.referenceTsSec ?? [];\n const hasReference = referenceTsSec.length > 0;\n return {\n symbolId: d.symbolId,\n timeframe: d.timeframe,\n time: d.tsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(d.open, priceScale),\n high: scaledArrayToDecimal(d.high, priceScale),\n low: scaledArrayToDecimal(d.low, priceScale),\n close: scaledArrayToDecimal(d.close, priceScale),\n volume: scaledArrayToDecimal(d.volume, volumeScale),\n quoteVolume: d.quoteVolume,\n nextPageToken: d.nextPageToken,\n reference: hasReference\n ? {\n time: referenceTsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(d.referenceOpen ?? [], referencePriceScale),\n high: scaledArrayToDecimal(d.referenceHigh ?? [], referencePriceScale),\n low: scaledArrayToDecimal(d.referenceLow ?? [], referencePriceScale),\n close: scaledArrayToDecimal(d.referenceClose ?? [], referencePriceScale),\n volume: scaledArrayToDecimal(d.referenceVolume ?? [], volumeScale),\n }\n : null,\n };\n }),\n );\n}\n\nexport function createCandleColumnarIntSchema(scales: SdkScales) {\n return v.pipe(\n CandleColumnarRawSchema,\n v.transform((d) => {\n const priceScale = scales.price();\n const referencePriceScale = scales.referencePrice(d.symbolId);\n const volumeScale = scales.marketDataVolume(d.symbolId);\n const referenceTsSec = d.referenceTsSec ?? [];\n return {\n symbolId: d.symbolId,\n timeframe: d.timeframe,\n tsSec: d.tsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(d.open, priceScale),\n high: scaledArrayToDecimal(d.high, priceScale),\n low: scaledArrayToDecimal(d.low, priceScale),\n close: scaledArrayToDecimal(d.close, priceScale),\n volume: scaledArrayToDecimal(d.volume, volumeScale),\n quoteVolume: d.quoteVolume,\n nextPageToken: d.nextPageToken,\n reference:\n referenceTsSec.length > 0\n ? {\n tsSec: referenceTsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(\n d.referenceOpen ?? [],\n referencePriceScale,\n ),\n high: scaledArrayToDecimal(\n d.referenceHigh ?? [],\n referencePriceScale,\n ),\n low: scaledArrayToDecimal(d.referenceLow ?? [], referencePriceScale),\n close: scaledArrayToDecimal(\n d.referenceClose ?? [],\n referencePriceScale,\n ),\n volume: scaledArrayToDecimal(d.referenceVolume ?? [], volumeScale),\n }\n : null,\n };\n }),\n );\n}\n\nexport type Candle = v.InferOutput<ReturnType<typeof createCandleRowSchema>>;\nexport type CandleInput = v.InferInput<ReturnType<typeof createCandleRowSchema>>;\nexport type CandleIntInput = v.InferInput<ReturnType<typeof createCandleRowIntSchema>>;\nexport type CandleInt = v.InferOutput<ReturnType<typeof createCandleRowIntSchema>>;\nexport type CandleColumnar = v.InferOutput<ReturnType<typeof createCandleColumnarSchema>>;\nexport type CandleColumnarInput = v.InferInput<ReturnType<typeof createCandleColumnarSchema>>;\nexport type CandleColumnarIntInput = v.InferInput<ReturnType<typeof createCandleColumnarIntSchema>>;\nexport type CandleColumnarInt = v.InferOutput<ReturnType<typeof createCandleColumnarIntSchema>>;\n\nexport const ListCandlesInputSchema = v.pipe(\n v.object({\n symbolId: SymbolIdInputSchema,\n timeframe: TimeframeInputSchema,\n limit: OptionalPositiveNumberSchema,\n includeIncomplete: v.optional(v.boolean(), false),\n includeReference: OptionalBooleanSchema,\n startTsSec: OptionalTimestampSecondsInputSchema,\n endTsSec: OptionalTimestampSecondsInputSchema,\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform((d) => ({\n symbolId: d.symbolId,\n timeframe: d.timeframe,\n limit: d.limit,\n includeIncomplete: d.includeIncomplete,\n includeReference: d.includeReference,\n startTime: d.startTsSec != null ? timestampFromTsSec(d.startTsSec) : undefined,\n endTime: d.endTsSec != null ? timestampFromTsSec(d.endTsSec) : undefined,\n pageToken: d.pageToken,\n })),\n);\n\nexport function createListCandlesInputSchema() {\n return ListCandlesInputSchema;\n}\n\nexport type GetCandlesInput = v.InferInput<ReturnType<typeof createListCandlesInputSchema>>;\nexport const createGetCandlesColumnsInputSchema = createListCandlesInputSchema;\nexport type GetCandlesColumnsInput = v.InferInput<ReturnType<typeof createListCandlesInputSchema>>;\n"],"mappings":";;;;;;;AASA,MAAa,kBAAkB,EAAE,SAAS,UAAU;AAIpD,SAAS,mBAAmB,OAAuC;CAC/D,OAAO,UAAU,eAAe,eAAe,KAAK;AACxD;AAEA,MAAM,uBAAuB,EAAE,KAC3B,iBACA,EAAE,WAAW,UAAU,eAAe,aAAa,MAAM,CAC7D;AAEA,MAAM,+BAA+B,EAAE,SACnC,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAM,CAAC,CACpE;AAEA,MAAM,wBAAwB,EAA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