@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,130 @@
1
+ import { PROTOBUF_UINT64_MAX } from "../../shared/wire-bounds.js";
2
+ import { BigIntStringSchema, OptionalTimestampMsSchema, PublicIdSchema, idInputSchema, positiveBigintStringInputSchema } from "../../shared/schemas.js";
3
+ import { enumLabelSchema } from "../../shared/proto-enum-codec.js";
4
+ import { positiveDecimalInputToScaled, scaledToDecimalOutput } from "../../shared/decimal-surface.js";
5
+ import { SymbolIdInputSchema } from "../shared.js";
6
+ import { buildProtoPatch, defineProtoPatchFields } from "../../utils/proto-patch.js";
7
+ import { PRICE_ALERT_CHANNEL_VALUES, PRICE_ALERT_DIRECTION_VALUES, PRICE_ALERT_PRICE_SOURCE_VALUES, PRICE_ALERT_STATUS_VALUES, PriceAlertChannelCodec, PriceAlertDirectionCodec, PriceAlertPriceSourceCodec, PriceAlertStatusCodec, PriceAlertUpdateOutcomeCodec } from "./price-alerts.codecs.js";
8
+ import * as v from "valibot";
9
+ //#region src/services/price-alerts/price-alerts.schemas.ts
10
+ const AlertIdInputSchema = idInputSchema("alertId");
11
+ /** Decimal alert price; sent as int64 ticks at the protocol price scale (1e9). */
12
+ function priceInputSchema(field) {
13
+ return v.pipe(v.string(), v.transform((price) => positiveDecimalInputToScaled(field, price, 9)));
14
+ }
15
+ /** One to two distinct delivery channels, sent in ascending enum order. */
16
+ const ChannelsInputSchema = v.pipe(v.array(v.picklist(PRICE_ALERT_CHANNEL_VALUES)), v.minLength(1, "At least one channel is required."), v.maxLength(2, "At most two channels are allowed."), v.check((channels) => new Set(channels).size === channels.length, "Channels must be distinct."), v.transform((channels) => channels.map((channel) => PriceAlertChannelCodec.inputToProto[channel]).sort()));
17
+ const IdempotencyKeySchema = v.optional(v.pipe(v.string(), v.trim(), v.minLength(1)));
18
+ const CreatePriceAlertInputSchema = v.pipe(v.strictObject({
19
+ symbolId: SymbolIdInputSchema,
20
+ direction: v.picklist(PRICE_ALERT_DIRECTION_VALUES),
21
+ /** Omit to watch the index price on markets that have one, else the last price. */
22
+ priceSource: v.optional(v.picklist(PRICE_ALERT_PRICE_SOURCE_VALUES)),
23
+ /** Alert price as a decimal string, e.g. `"90000"`. */
24
+ price: priceInputSchema("price"),
25
+ channels: ChannelsInputSchema,
26
+ /** Reusing a key with the same request returns the alert it created. */
27
+ idempotencyKey: IdempotencyKeySchema
28
+ }), v.transform(({ direction, priceSource, price, ...input }) => ({
29
+ ...input,
30
+ direction: PriceAlertDirectionCodec.inputToProto[direction],
31
+ priceSource: priceSource && PriceAlertPriceSourceCodec.inputToProto[priceSource],
32
+ priceTicks: price
33
+ })));
34
+ const ListPriceAlertsInputSchema = v.pipe(v.strictObject({
35
+ /** Only alerts in these states; omit or empty for every state. */
36
+ statuses: v.optional(v.array(v.picklist(PRICE_ALERT_STATUS_VALUES))),
37
+ /** Only alerts on this market. */
38
+ symbolId: v.optional(SymbolIdInputSchema),
39
+ /** Page size: default 50, at most 200. */
40
+ limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(200))),
41
+ /** Previous `nextPageToken`; reuse only with the same filters. */
42
+ pageToken: v.optional(v.pipe(v.string(), v.trim()))
43
+ }), v.transform(({ statuses, ...input }) => ({
44
+ ...input,
45
+ statuses: statuses?.map((status) => PriceAlertStatusCodec.inputToProto[status])
46
+ })));
47
+ const PRICE_ALERT_PATCH_FIELDS = defineProtoPatchFields()({
48
+ direction: {
49
+ path: "direction",
50
+ encode: (direction) => ({ direction: PriceAlertDirectionCodec.inputToProto[direction] })
51
+ },
52
+ price: {
53
+ path: "price_ticks",
54
+ encode: (priceTicks) => ({ priceTicks })
55
+ },
56
+ channels: {
57
+ path: "channels",
58
+ encode: (channels) => ({ channels })
59
+ }
60
+ });
61
+ const UpdatePriceAlertInputSchema = v.pipe(v.strictObject({
62
+ alertId: AlertIdInputSchema,
63
+ /** The alert's `revision` from the last read. */
64
+ expectedRevision: v.pipe(positiveBigintStringInputSchema("expectedRevision"), v.maxValue(PROTOBUF_UINT64_MAX, "expectedRevision exceeds the uint64 range")),
65
+ direction: v.optional(v.picklist(PRICE_ALERT_DIRECTION_VALUES)),
66
+ price: v.optional(priceInputSchema("price")),
67
+ channels: v.optional(ChannelsInputSchema),
68
+ idempotencyKey: IdempotencyKeySchema
69
+ }), v.transform(({ alertId, expectedRevision, idempotencyKey, ...fields }) => {
70
+ const { patch: update, updateMask } = buildProtoPatch(fields, PRICE_ALERT_PATCH_FIELDS);
71
+ return {
72
+ alertId,
73
+ expectedRevision,
74
+ idempotencyKey,
75
+ update,
76
+ updateMask
77
+ };
78
+ }));
79
+ const CancelPriceAlertInputSchema = v.strictObject({ alertId: AlertIdInputSchema });
80
+ const PriceSchema = v.pipe(v.bigint(), v.transform((ticks) => scaledToDecimalOutput(ticks, 9)));
81
+ /** A price alert of the caller's root account. Prices are decimal strings. */
82
+ const PriceAlertSchema = v.pipe(v.object({
83
+ alertId: PublicIdSchema,
84
+ symbolId: v.number(),
85
+ direction: enumLabelSchema(PriceAlertDirectionCodec.protoToOutput),
86
+ priceSource: enumLabelSchema(PriceAlertPriceSourceCodec.protoToOutput),
87
+ priceTicks: PriceSchema,
88
+ referencePriceTicks: PriceSchema,
89
+ armed: v.boolean(),
90
+ status: enumLabelSchema(PriceAlertStatusCodec.protoToOutput),
91
+ channels: v.array(enumLabelSchema(PriceAlertChannelCodec.protoToOutput)),
92
+ revision: BigIntStringSchema,
93
+ createdAt: OptionalTimestampMsSchema,
94
+ updatedAt: OptionalTimestampMsSchema,
95
+ triggeredAt: OptionalTimestampMsSchema,
96
+ triggeredPriceTicks: v.bigint()
97
+ }), v.transform((alert) => ({
98
+ alertId: alert.alertId,
99
+ symbolId: alert.symbolId,
100
+ direction: alert.direction,
101
+ priceSource: alert.priceSource,
102
+ /** Alert price. */
103
+ price: alert.priceTicks,
104
+ /** Price when the alert was created or last set again; it fires on a crossing from here. */
105
+ referencePrice: alert.referencePriceTicks,
106
+ /** False while an alert created past its price waits for the price to move back first. */
107
+ armed: alert.armed,
108
+ status: alert.status,
109
+ channels: alert.channels,
110
+ /** Pass as `expectedRevision` to `update`. */
111
+ revision: alert.revision,
112
+ createdAt: alert.createdAt ?? null,
113
+ updatedAt: alert.updatedAt ?? null,
114
+ /** Set only once the alert fired. */
115
+ triggeredAt: alert.triggeredAt ?? null,
116
+ /** Price that fired the alert; null unless it fired. */
117
+ triggeredPrice: alert.status === "triggered" ? scaledToDecimalOutput(alert.triggeredPriceTicks, 9) : null
118
+ })));
119
+ const ListPriceAlertsResultSchema = v.object({
120
+ alerts: v.array(PriceAlertSchema),
121
+ nextPageToken: v.optional(v.string(), "")
122
+ });
123
+ const UpdatePriceAlertResultSchema = v.object({
124
+ alert: PriceAlertSchema,
125
+ outcome: enumLabelSchema(PriceAlertUpdateOutcomeCodec.protoToOutput)
126
+ });
127
+ //#endregion
128
+ export { CancelPriceAlertInputSchema, CreatePriceAlertInputSchema, ListPriceAlertsInputSchema, ListPriceAlertsResultSchema, PriceAlertSchema, UpdatePriceAlertInputSchema, UpdatePriceAlertResultSchema };
129
+
130
+ //# sourceMappingURL=price-alerts.schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price-alerts.schemas.js","names":[],"sources":["../../../src/services/price-alerts/price-alerts.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { PRICE_SCALE } from \"../../catalogs/readers.js\";\nimport {\n positiveDecimalInputToScaled,\n scaledToDecimalOutput,\n} from \"../../shared/decimal-surface.js\";\nimport { enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport {\n BigIntStringSchema,\n OptionalTimestampMsSchema,\n PublicIdSchema,\n idInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../shared/schemas.js\";\nimport { PROTOBUF_UINT64_MAX } from \"../../shared/wire-bounds.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../utils/proto-patch.js\";\nimport { SymbolIdInputSchema } from \"../shared.js\";\nimport {\n PRICE_ALERT_CHANNEL_VALUES,\n PRICE_ALERT_DIRECTION_VALUES,\n PRICE_ALERT_PRICE_SOURCE_VALUES,\n PRICE_ALERT_STATUS_VALUES,\n PriceAlertChannelCodec,\n PriceAlertDirectionCodec,\n PriceAlertPriceSourceCodec,\n PriceAlertStatusCodec,\n PriceAlertUpdateOutcomeCodec,\n type PriceAlertDirection,\n} from \"./price-alerts.codecs.js\";\n\nconst AlertIdInputSchema = idInputSchema(\"alertId\");\n\n/** Decimal alert price; sent as int64 ticks at the protocol price scale (1e9). */\nfunction priceInputSchema(field: string) {\n return v.pipe(\n v.string(),\n v.transform((price) => positiveDecimalInputToScaled(field, price, PRICE_SCALE)),\n );\n}\n\n/** One to two distinct delivery channels, sent in ascending enum order. */\nconst ChannelsInputSchema = v.pipe(\n v.array(v.picklist(PRICE_ALERT_CHANNEL_VALUES)),\n v.minLength(1, \"At least one channel is required.\"),\n v.maxLength(2, \"At most two channels are allowed.\"),\n v.check((channels) => new Set(channels).size === channels.length, \"Channels must be distinct.\"),\n v.transform((channels) =>\n channels.map((channel) => PriceAlertChannelCodec.inputToProto[channel]).sort(),\n ),\n);\n\nconst IdempotencyKeySchema = v.optional(v.pipe(v.string(), v.trim(), v.minLength(1)));\n\nexport const CreatePriceAlertInputSchema = v.pipe(\n v.strictObject({\n symbolId: SymbolIdInputSchema,\n direction: v.picklist(PRICE_ALERT_DIRECTION_VALUES),\n /** Omit to watch the index price on markets that have one, else the last price. */\n priceSource: v.optional(v.picklist(PRICE_ALERT_PRICE_SOURCE_VALUES)),\n /** Alert price as a decimal string, e.g. `\"90000\"`. */\n price: priceInputSchema(\"price\"),\n channels: ChannelsInputSchema,\n /** Reusing a key with the same request returns the alert it created. */\n idempotencyKey: IdempotencyKeySchema,\n }),\n v.transform(({ direction, priceSource, price, ...input }) => ({\n ...input,\n direction: PriceAlertDirectionCodec.inputToProto[direction],\n priceSource: priceSource && PriceAlertPriceSourceCodec.inputToProto[priceSource],\n priceTicks: price,\n })),\n);\n\nexport type CreatePriceAlertInput = v.InferInput<typeof CreatePriceAlertInputSchema>;\n\nexport const ListPriceAlertsInputSchema = v.pipe(\n v.strictObject({\n /** Only alerts in these states; omit or empty for every state. */\n statuses: v.optional(v.array(v.picklist(PRICE_ALERT_STATUS_VALUES))),\n /** Only alerts on this market. */\n symbolId: v.optional(SymbolIdInputSchema),\n /** Page size: default 50, at most 200. */\n limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(200))),\n /** Previous `nextPageToken`; reuse only with the same filters. */\n pageToken: v.optional(v.pipe(v.string(), v.trim())),\n }),\n v.transform(({ statuses, ...input }) => ({\n ...input,\n statuses: statuses?.map((status) => PriceAlertStatusCodec.inputToProto[status]),\n })),\n);\n\nexport type ListPriceAlertsInput = v.InferInput<typeof ListPriceAlertsInputSchema>;\n\ntype PriceAlertPatch = {\n direction?: PriceAlertDirection;\n price?: bigint;\n channels?: number[];\n};\n\nconst PRICE_ALERT_PATCH_FIELDS = defineProtoPatchFields<PriceAlertPatch>()({\n direction: {\n path: \"direction\",\n encode: (direction) => ({ direction: PriceAlertDirectionCodec.inputToProto[direction] }),\n },\n price: { path: \"price_ticks\", encode: (priceTicks) => ({ priceTicks }) },\n channels: { path: \"channels\", encode: (channels) => ({ channels }) },\n});\n\nexport const UpdatePriceAlertInputSchema = v.pipe(\n v.strictObject({\n alertId: AlertIdInputSchema,\n /** The alert's `revision` from the last read. */\n expectedRevision: v.pipe(\n positiveBigintStringInputSchema(\"expectedRevision\"),\n v.maxValue(PROTOBUF_UINT64_MAX, \"expectedRevision exceeds the uint64 range\"),\n ),\n direction: v.optional(v.picklist(PRICE_ALERT_DIRECTION_VALUES)),\n price: v.optional(priceInputSchema(\"price\")),\n channels: v.optional(ChannelsInputSchema),\n idempotencyKey: IdempotencyKeySchema,\n }),\n v.transform(({ alertId, expectedRevision, idempotencyKey, ...fields }) => {\n const { patch: update, updateMask } = buildProtoPatch(fields, PRICE_ALERT_PATCH_FIELDS);\n return { alertId, expectedRevision, idempotencyKey, update, updateMask };\n }),\n);\n\nexport type UpdatePriceAlertInput = v.InferInput<typeof UpdatePriceAlertInputSchema>;\n\nexport const CancelPriceAlertInputSchema = v.strictObject({ alertId: AlertIdInputSchema });\n\nexport type CancelPriceAlertInput = v.InferInput<typeof CancelPriceAlertInputSchema>;\n\nconst PriceSchema = v.pipe(\n v.bigint(),\n v.transform((ticks) => scaledToDecimalOutput(ticks, PRICE_SCALE)),\n);\n\n/** A price alert of the caller's root account. Prices are decimal strings. */\nexport const PriceAlertSchema = v.pipe(\n v.object({\n alertId: PublicIdSchema,\n symbolId: v.number(),\n direction: enumLabelSchema(PriceAlertDirectionCodec.protoToOutput),\n priceSource: enumLabelSchema(PriceAlertPriceSourceCodec.protoToOutput),\n priceTicks: PriceSchema,\n referencePriceTicks: PriceSchema,\n armed: v.boolean(),\n status: enumLabelSchema(PriceAlertStatusCodec.protoToOutput),\n channels: v.array(enumLabelSchema(PriceAlertChannelCodec.protoToOutput)),\n revision: BigIntStringSchema,\n createdAt: OptionalTimestampMsSchema,\n updatedAt: OptionalTimestampMsSchema,\n triggeredAt: OptionalTimestampMsSchema,\n triggeredPriceTicks: v.bigint(),\n }),\n v.transform((alert) => ({\n alertId: alert.alertId,\n symbolId: alert.symbolId,\n direction: alert.direction,\n priceSource: alert.priceSource,\n /** Alert price. */\n price: alert.priceTicks,\n /** Price when the alert was created or last set again; it fires on a crossing from here. */\n referencePrice: alert.referencePriceTicks,\n /** False while an alert created past its price waits for the price to move back first. */\n armed: alert.armed,\n status: alert.status,\n channels: alert.channels,\n /** Pass as `expectedRevision` to `update`. */\n revision: alert.revision,\n createdAt: alert.createdAt ?? null,\n updatedAt: alert.updatedAt ?? null,\n /** Set only once the alert fired. */\n triggeredAt: alert.triggeredAt ?? null,\n /** Price that fired the alert; null unless it fired. */\n triggeredPrice:\n alert.status === \"triggered\"\n ? scaledToDecimalOutput(alert.triggeredPriceTicks, PRICE_SCALE)\n : null,\n })),\n);\n\nexport type PriceAlert = v.InferOutput<typeof PriceAlertSchema>;\n\nexport const ListPriceAlertsResultSchema = v.object({\n alerts: v.array(PriceAlertSchema),\n nextPageToken: v.optional(v.string(), \"\"),\n});\n\n/** One page of alerts, newest first; an empty `nextPageToken` means no more. */\nexport type ListPriceAlertsResult = v.InferOutput<typeof ListPriceAlertsResultSchema>;\n\nexport const UpdatePriceAlertResultSchema = v.object({\n alert: PriceAlertSchema,\n outcome: enumLabelSchema(PriceAlertUpdateOutcomeCodec.protoToOutput),\n});\n\nexport type UpdatePriceAlertResult = v.InferOutput<typeof UpdatePriceAlertResultSchema>;\n"],"mappings":";;;;;;;;;AA8BA,MAAM,qBAAqB,cAAc,SAAS;;AAGlD,SAAS,iBAAiB,OAAe;CACrC,OAAO,EAAE,KACL,EAAE,OAAO,GACT,EAAE,WAAW,UAAU,6BAA6B,OAAO,OAAA,CAAkB,CAAC,CAClF;AACJ;;AAGA,MAAM,sBAAsB,EAAE,KAC1B,EAAE,MAAM,EAAE,SAAS,0BAA0B,CAAC,GAC9C,EAAE,UAAU,GAAG,mCAAmC,GAClD,EAAE,UA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AAM;CACf,UAAU,MAAM;CAChB,WAAW,MAAM;CACjB,aAAa,MAAM;;CAEnB,OAAO,MAAM;;CAEb,gBAAgB,MAAM;;CAEtB,OAAO,MAAM;CACb,QAAQ,MAAM;CACd,UAAU,MAAM;;CAEhB,UAAU,MAAM;CAChB,WAAW,MAAM,aAAa;CAC9B,WAAW,MAAM,aAAa;;CAE9B,aAAa,MAAM,eAAe;;CAElC,gBACI,MAAM,WAAW,cACX,sBAAsB,MAAM,qBAAA,CAAgC,IAC5D;AACd,EAAE,CACN;AAIA,MAAa,8BAA8B,EAAE,OAAO;CAChD,QAAQ,EAAE,MAAM,gBAAgB;CAChC,eAAe,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;AAC5C,CAAC;AAKD,MAAa,+BAA+B,EAAE,OAAO;CACjD,OAAO;CACP,SAAS,gBAAgB,6BAA6B,aAAa;AACvE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { CancelPriceAlertInput, CreatePriceAlertInput, ListPriceAlertsInput, ListPriceAlertsResult, PriceAlert, UpdatePriceAlertInput, UpdatePriceAlertResult } from "./price-alerts.schemas.js";
2
+ import { PriceAlertChannel, PriceAlertDirection, PriceAlertPriceSource, PriceAlertStatus, PriceAlertUpdateOutcome } from "./price-alerts.codecs.js";
3
+ export type { CancelPriceAlertInput, CreatePriceAlertInput, ListPriceAlertsInput, ListPriceAlertsResult, PriceAlert, PriceAlertChannel, PriceAlertDirection, PriceAlertPriceSource, PriceAlertStatus, PriceAlertUpdateOutcome, UpdatePriceAlertInput, UpdatePriceAlertResult };
@@ -0,0 +1,8 @@
1
+ import { PriceAlertsService } from "./price-alerts.js";
2
+ import { PolyesterCore } from "../../core-client.js";
3
+ //#region src/services/price-alerts/service.d.ts
4
+ /** Returns the client's PriceAlertsService, creating it on first use. */
5
+ declare const priceAlertsService: (client: PolyesterCore) => PriceAlertsService;
6
+ //#endregion
7
+ export { priceAlertsService };
8
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","names":[],"sources":["../../../src/services/price-alerts/service.ts"],"mappings":";;;;cAIa,qBAAkB,QAAlB,kBAAkB"}
@@ -0,0 +1,9 @@
1
+ import { defineService } from "../../core-client.js";
2
+ import { PriceAlertsService } from "./price-alerts.js";
3
+ //#region src/services/price-alerts/service.ts
4
+ /** Returns the client's PriceAlertsService, creating it on first use. */
5
+ const priceAlertsService = defineService((context) => new PriceAlertsService(context.transports));
6
+ //#endregion
7
+ export { priceAlertsService };
8
+
9
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","names":[],"sources":["../../../src/services/price-alerts/service.ts"],"sourcesContent":["import { defineService } from \"../../core-client.js\";\nimport { PriceAlertsService } from \"./price-alerts.js\";\n\n/** Returns the client's PriceAlertsService, creating it on first use. */\nexport const priceAlertsService = defineService(\n (context) => new PriceAlertsService(context.transports),\n);\n"],"mappings":";;;;AAIA,MAAa,qBAAqB,eAC7B,YAAY,IAAI,mBAAmB,QAAQ,UAAU,CAC1D"}
@@ -29,7 +29,7 @@ declare const RewardAwardSchema: v.ObjectSchema<{
29
29
  readonly assetId: v.NumberSchema<undefined>;
30
30
  readonly amountBaseUnits: v.StringSchema<undefined>;
31
31
  readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
32
- readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
32
+ readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "canceled" | "awaiting_destination" | "ready_for_payout" | "paid">]>;
33
33
  readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
34
34
  readonly seconds: v.BigintSchema<undefined>;
35
35
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -67,7 +67,7 @@ declare const ListRewardAwardsResultSchema: v.ObjectSchema<{
67
67
  readonly assetId: v.NumberSchema<undefined>;
68
68
  readonly amountBaseUnits: v.StringSchema<undefined>;
69
69
  readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
70
- readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
70
+ readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "canceled" | "awaiting_destination" | "ready_for_payout" | "paid">]>;
71
71
  readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
72
72
  readonly seconds: v.BigintSchema<undefined>;
73
73
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -114,7 +114,7 @@ declare const SetRewardDestinationResultSchema: v.ObjectSchema<{
114
114
  readonly assetId: v.NumberSchema<undefined>;
115
115
  readonly amountBaseUnits: v.StringSchema<undefined>;
116
116
  readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
117
- readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
117
+ readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "canceled" | "awaiting_destination" | "ready_for_payout" | "paid">]>;
118
118
  readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
119
119
  readonly seconds: v.BigintSchema<undefined>;
120
120
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -153,7 +153,7 @@ declare const AcknowledgeRewardAwardResultSchema: v.ObjectSchema<{
153
153
  readonly assetId: v.NumberSchema<undefined>;
154
154
  readonly amountBaseUnits: v.StringSchema<undefined>;
155
155
  readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
156
- readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
156
+ readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "canceled" | "awaiting_destination" | "ready_for_payout" | "paid">]>;
157
157
  readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
158
158
  readonly seconds: v.BigintSchema<undefined>;
159
159
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -18,7 +18,7 @@ declare class SocialVerificationService {
18
18
  */
19
19
  markReady(input: v.InferInput<typeof SocialProviderInputSchema>, options?: PolyesterMutationOptions): Promise<VerificationReadyResponse>;
20
20
  /**
21
- * Returns the caller's current verification state for a provider, including status, challenge metadata, attempts, last error, and verified timestamp.
21
+ * Returns the caller's current verification state for a provider, including status, challenge metadata, attempts, last error, and verified timestamp. API keys need `read-social-verification` and must be scoped to the main account.
22
22
  */
23
23
  get(input: v.InferInput<typeof SocialProviderInputSchema>, options?: PolyesterRequestOptions): Promise<GetVerificationResponse>;
24
24
  /**
@@ -29,7 +29,7 @@ var SocialVerificationService = class {
29
29
  return parse(VerificationReadyResponseSchema, res);
30
30
  }
31
31
  /**
32
- * Returns the caller's current verification state for a provider, including status, challenge metadata, attempts, last error, and verified timestamp.
32
+ * Returns the caller's current verification state for a provider, including status, challenge metadata, attempts, last error, and verified timestamp. API keys need `read-social-verification` and must be scoped to the main account.
33
33
  */
34
34
  async get(input, options) {
35
35
  const validated = parse(SocialProviderInputSchema, input);
@@ -1 +1 @@
1
- {"version":3,"file":"social-verification.js","names":["#client","Proto.SocialVerificationService"],"sources":["../../../src/services/social-verification/social-verification.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/auth/v1/social_verification_pb.js\";\nimport type * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport {\n ConfirmVerificationInputSchema,\n UnlinkSocialAccountInputSchema,\n StartVerificationInputSchema,\n StartVerificationResponseSchema,\n VerificationReadyResponseSchema,\n GetVerificationResponseSchema,\n SocialProviderInputSchema,\n type ConfirmVerificationInput,\n type UnlinkSocialAccountInput,\n type StartVerificationInput,\n type StartVerificationResponse,\n type VerificationReadyResponse,\n type GetVerificationResponse,\n} from \"./social-verification.schemas.js\";\n\n/**\n * Verifies ownership of external social accounts for the authenticated caller.\n */\nexport class SocialVerificationService {\n #client: Client<typeof Proto.SocialVerificationService>;\n\n constructor(transports: AuthApiTransports) {\n this.#client = createClient(Proto.SocialVerificationService, transports.authApi);\n }\n\n /**\n * Starts or restarts provider verification. Twitter requires a handle and strips a leading @; Discord and Telegram get their identity from the provider bot. An omitted method uses the provider default (Twitter profile, Discord channel, Telegram dm). Discord and Telegram return an empty challengeCode when no new challenge is issued. For Telegram, open `actionUrl` to send the code to the Polyester bot, poll `get` until `awaiting_confirmation`, then `confirm`; while a Telegram account is linked, starting again throws until it is unlinked.\n */\n async start(\n input: StartVerificationInput,\n options?: PolyesterMutationOptions,\n ): Promise<StartVerificationResponse> {\n const validated = parse(StartVerificationInputSchema, input);\n const res = await this.#client.startSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(StartVerificationResponseSchema, res);\n }\n\n /**\n * Queues a provider check after the caller has placed the challenge code according to the selected verification method. Not used for Telegram, which links through `confirm`.\n */\n async markReady(\n input: v.InferInput<typeof SocialProviderInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<VerificationReadyResponse> {\n const validated = parse(SocialProviderInputSchema, input);\n const res = await this.#client.socialVerificationReady(\n validated,\n toConnectCallOptions(options),\n );\n return parse(VerificationReadyResponseSchema, res);\n }\n\n /**\n * Returns the caller's current verification state for a provider, including status, challenge metadata, attempts, last error, and verified timestamp.\n */\n async get(\n input: v.InferInput<typeof SocialProviderInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(SocialProviderInputSchema, input);\n const res = await this.#client.getSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n\n /**\n * Links the Telegram account that sent the challenge code. Pass the `providerUserId` shown\n * while the verification is `awaiting_confirmation`, so the user links exactly the account\n * they were shown. Requires enrolled MFA and a fresh `stepUpToken`; a retried confirmation of\n * an existing link needs no new token. A mismatched ID or no account awaiting confirmation\n * fails with `social_verification_invalid_state`; a Telegram account linked elsewhere fails\n * the verification with `social_account_already_linked`.\n */\n async confirm(\n input: ConfirmVerificationInput,\n options?: PolyesterMutationOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(ConfirmVerificationInputSchema, input);\n const res = await this.#client.confirmSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n\n /**\n * Unlinks the Telegram account, or cancels a link in progress, and returns the `canceled`\n * verification (absent if none was ever started). Repeating it changes nothing; start a new\n * verification to link again.\n */\n async unlink(\n input: UnlinkSocialAccountInput,\n options?: PolyesterMutationOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(UnlinkSocialAccountInputSchema, input);\n const res = await this.#client.unlinkSocialAccount(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n}\n"],"mappings":";;;;;;;;;AA6BA,IAAa,4BAAb,MAAuC;CACnC;CAEA,YAAY,YAA+B;EACvC,KAAKA,UAAU,aAAaC,6BAAiC,WAAW,OAAO;CACnF;;;;CAKA,MAAM,MACF,OACA,SACkC;EAClC,MAAM,YAAY,MAAM,8BAA8B,KAAK;EAC3D,MAAM,MAAM,MAAM,KAAKD,QAAQ,wBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,iCAAiC,GAAG;CACrD;;;;CAKA,MAAM,UACF,OACA,SACkC;EAClC,MAAM,YAAY,MAAM,2BAA2B,KAAK;EACxD,MAAM,MAAM,MAAM,KAAKA,QAAQ,wBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,iCAAiC,GAAG;CACrD;;;;CAKA,MAAM,IACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,2BAA2B,KAAK;EACxD,MAAM,MAAM,MAAM,KAAKA,QAAQ,sBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;;;;;;;;;CAUA,MAAM,QACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,gCAAgC,KAAK;EAC7D,MAAM,MAAM,MAAM,KAAKA,QAAQ,0BAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;;;;;;CAOA,MAAM,OACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,gCAAgC,KAAK;EAC7D,MAAM,MAAM,MAAM,KAAKA,QAAQ,oBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;AACJ"}
1
+ {"version":3,"file":"social-verification.js","names":["#client","Proto.SocialVerificationService"],"sources":["../../../src/services/social-verification/social-verification.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/auth/v1/social_verification_pb.js\";\nimport type * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport {\n ConfirmVerificationInputSchema,\n UnlinkSocialAccountInputSchema,\n StartVerificationInputSchema,\n StartVerificationResponseSchema,\n VerificationReadyResponseSchema,\n GetVerificationResponseSchema,\n SocialProviderInputSchema,\n type ConfirmVerificationInput,\n type UnlinkSocialAccountInput,\n type StartVerificationInput,\n type StartVerificationResponse,\n type VerificationReadyResponse,\n type GetVerificationResponse,\n} from \"./social-verification.schemas.js\";\n\n/**\n * Verifies ownership of external social accounts for the authenticated caller.\n */\nexport class SocialVerificationService {\n #client: Client<typeof Proto.SocialVerificationService>;\n\n constructor(transports: AuthApiTransports) {\n this.#client = createClient(Proto.SocialVerificationService, transports.authApi);\n }\n\n /**\n * Starts or restarts provider verification. Twitter requires a handle and strips a leading @; Discord and Telegram get their identity from the provider bot. An omitted method uses the provider default (Twitter profile, Discord channel, Telegram dm). Discord and Telegram return an empty challengeCode when no new challenge is issued. For Telegram, open `actionUrl` to send the code to the Polyester bot, poll `get` until `awaiting_confirmation`, then `confirm`; while a Telegram account is linked, starting again throws until it is unlinked.\n */\n async start(\n input: StartVerificationInput,\n options?: PolyesterMutationOptions,\n ): Promise<StartVerificationResponse> {\n const validated = parse(StartVerificationInputSchema, input);\n const res = await this.#client.startSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(StartVerificationResponseSchema, res);\n }\n\n /**\n * Queues a provider check after the caller has placed the challenge code according to the selected verification method. Not used for Telegram, which links through `confirm`.\n */\n async markReady(\n input: v.InferInput<typeof SocialProviderInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<VerificationReadyResponse> {\n const validated = parse(SocialProviderInputSchema, input);\n const res = await this.#client.socialVerificationReady(\n validated,\n toConnectCallOptions(options),\n );\n return parse(VerificationReadyResponseSchema, res);\n }\n\n /**\n * Returns the caller's current verification state for a provider, including status, challenge metadata, attempts, last error, and verified timestamp. API keys need `read-social-verification` and must be scoped to the main account.\n */\n async get(\n input: v.InferInput<typeof SocialProviderInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(SocialProviderInputSchema, input);\n const res = await this.#client.getSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n\n /**\n * Links the Telegram account that sent the challenge code. Pass the `providerUserId` shown\n * while the verification is `awaiting_confirmation`, so the user links exactly the account\n * they were shown. Requires enrolled MFA and a fresh `stepUpToken`; a retried confirmation of\n * an existing link needs no new token. A mismatched ID or no account awaiting confirmation\n * fails with `social_verification_invalid_state`; a Telegram account linked elsewhere fails\n * the verification with `social_account_already_linked`.\n */\n async confirm(\n input: ConfirmVerificationInput,\n options?: PolyesterMutationOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(ConfirmVerificationInputSchema, input);\n const res = await this.#client.confirmSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n\n /**\n * Unlinks the Telegram account, or cancels a link in progress, and returns the `canceled`\n * verification (absent if none was ever started). Repeating it changes nothing; start a new\n * verification to link again.\n */\n async unlink(\n input: UnlinkSocialAccountInput,\n options?: PolyesterMutationOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(UnlinkSocialAccountInputSchema, input);\n const res = await this.#client.unlinkSocialAccount(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n}\n"],"mappings":";;;;;;;;;AA6BA,IAAa,4BAAb,MAAuC;CACnC;CAEA,YAAY,YAA+B;EACvC,KAAKA,UAAU,aAAaC,6BAAiC,WAAW,OAAO;CACnF;;;;CAKA,MAAM,MACF,OACA,SACkC;EAClC,MAAM,YAAY,MAAM,8BAA8B,KAAK;EAC3D,MAAM,MAAM,MAAM,KAAKD,QAAQ,wBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,iCAAiC,GAAG;CACrD;;;;CAKA,MAAM,UACF,OACA,SACkC;EAClC,MAAM,YAAY,MAAM,2BAA2B,KAAK;EACxD,MAAM,MAAM,MAAM,KAAKA,QAAQ,wBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,iCAAiC,GAAG;CACrD;;;;CAKA,MAAM,IACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,2BAA2B,KAAK;EACxD,MAAM,MAAM,MAAM,KAAKA,QAAQ,sBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;;;;;;;;;CAUA,MAAM,QACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,gCAAgC,KAAK;EAC7D,MAAM,MAAM,MAAM,KAAKA,QAAQ,0BAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;;;;;;CAOA,MAAM,OACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,gCAAgC,KAAK;EAC7D,MAAM,MAAM,MAAM,KAAKA,QAAQ,oBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;AACJ"}
@@ -27,14 +27,14 @@ declare class SubaccountsService {
27
27
  readonly policies: SubaccountPoliciesService;
28
28
  constructor(transports: AuthAndPublicApiTransports, realtime: PolyesterRealtime, resolver?: SubaccountResolver);
29
29
  /**
30
- * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted ones. Use `createChallenge` for the canonical next smart-account address and salt.
30
+ * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted ones. Use `createChallenge` for the canonical next smart-account address and salt. API keys need `read-subaccounts` and see only the subaccounts within their scope.
31
31
  */
32
32
  list(options?: PolyesterRequestOptions): Promise<{
33
33
  totalCreated: number;
34
34
  subaccounts: v.InferOutput<typeof SubaccountSchema>[];
35
35
  }>;
36
36
  /**
37
- * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, members, and outgoing invites; throws if the subaccount is missing.
37
+ * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, members, and outgoing invites; throws if the subaccount is missing. API keys need `read-subaccounts`.
38
38
  *
39
39
  * `includeBalances: true` also returns the sub-account's current `balances`, in the shape of
40
40
  * `balances.list`. It needs the READ_BALANCES action on the sub-account (its role, any attached
@@ -81,7 +81,7 @@ declare class SubaccountsService {
81
81
  setMemberMfaRequirement(input: v.InferInput<typeof SetSubaccountMemberMfaRequirementInputSchema>, options?: PolyesterMutationOptions): Promise<SubaccountMutationResult>;
82
82
  /**
83
83
  * Returns the caller's subaccount invitations, newest first. Omit `direction` to include both
84
- * incoming and outgoing invitations, or pass `"incoming"` or `"outgoing"` to filter.
84
+ * incoming and outgoing invitations, or pass `"incoming"` or `"outgoing"` to filter. API keys need `read-subaccount-invites` and see only outgoing invitations.
85
85
  */
86
86
  listInvites(input: v.InferInput<typeof ListSubaccountInvitesInputSchema>, options?: PolyesterRequestOptions): Promise<SubaccountInvite[]>;
87
87
  /**
@@ -89,11 +89,11 @@ declare class SubaccountsService {
89
89
  */
90
90
  listRoles(options?: PolyesterRequestOptions): Promise<SubaccountRoleCatalog>;
91
91
  /**
92
- * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount.
92
+ * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount. API keys need `read-subaccount-permissions` and get what the key itself may do.
93
93
  */
94
94
  getEffectivePermissions(input: v.InferInput<typeof SubaccountIdInputSchema>, options?: PolyesterRequestOptions): Promise<EffectiveSubaccountPermissions>;
95
95
  /**
96
- * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status.
96
+ * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status. API keys need `read-subaccount-members`.
97
97
  */
98
98
  listMembers(input: v.InferInput<typeof SubaccountIdInputSchema>, options?: PolyesterRequestOptions): Promise<SubaccountMember[]>;
99
99
  /**
@@ -101,7 +101,7 @@ declare class SubaccountsService {
101
101
  */
102
102
  respondInvite(input: v.InferInput<typeof RespondSubaccountInviteInputSchema>, options?: PolyesterMutationOptions): Promise<SubaccountInvite>;
103
103
  /**
104
- * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination.
104
+ * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination. API keys need `read-subaccount-activity`.
105
105
  */
106
106
  listEvents(input: v.InferInput<typeof SubaccountActivityInputSchema>, options?: PolyesterRequestOptions): Promise<{
107
107
  events: SubaccountEvent[];
@@ -30,7 +30,7 @@ var SubaccountsService = class {
30
30
  this.#realtime = realtime;
31
31
  }
32
32
  /**
33
- * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted ones. Use `createChallenge` for the canonical next smart-account address and salt.
33
+ * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted ones. Use `createChallenge` for the canonical next smart-account address and salt. API keys need `read-subaccounts` and see only the subaccounts within their scope.
34
34
  */
35
35
  async list(options) {
36
36
  const res = await this.#client.listSubaccounts({}, toConnectCallOptions(options));
@@ -40,7 +40,7 @@ var SubaccountsService = class {
40
40
  };
41
41
  }
42
42
  /**
43
- * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, members, and outgoing invites; throws if the subaccount is missing.
43
+ * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, members, and outgoing invites; throws if the subaccount is missing. API keys need `read-subaccounts`.
44
44
  *
45
45
  * `includeBalances: true` also returns the sub-account's current `balances`, in the shape of
46
46
  * `balances.list`. It needs the READ_BALANCES action on the sub-account (its role, any attached
@@ -132,7 +132,7 @@ var SubaccountsService = class {
132
132
  }
133
133
  /**
134
134
  * Returns the caller's subaccount invitations, newest first. Omit `direction` to include both
135
- * incoming and outgoing invitations, or pass `"incoming"` or `"outgoing"` to filter.
135
+ * incoming and outgoing invitations, or pass `"incoming"` or `"outgoing"` to filter. API keys need `read-subaccount-invites` and see only outgoing invitations.
136
136
  */
137
137
  async listInvites(input, options) {
138
138
  const validatedInput = parse(ListSubaccountInvitesInputSchema, input);
@@ -147,7 +147,7 @@ var SubaccountsService = class {
147
147
  return parse(SubaccountRoleCatalogSchema, res);
148
148
  }
149
149
  /**
150
- * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount.
150
+ * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount. API keys need `read-subaccount-permissions` and get what the key itself may do.
151
151
  */
152
152
  async getEffectivePermissions(input, options) {
153
153
  const validatedInput = parse(SubaccountIdInputSchema, input);
@@ -155,7 +155,7 @@ var SubaccountsService = class {
155
155
  return parse(EffectiveSubaccountPermissionsSchema, res);
156
156
  }
157
157
  /**
158
- * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status.
158
+ * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status. API keys need `read-subaccount-members`.
159
159
  */
160
160
  async listMembers(input, options) {
161
161
  const validatedInput = parse(SubaccountIdInputSchema, input);
@@ -171,7 +171,7 @@ var SubaccountsService = class {
171
171
  return parse(SubaccountInviteSchema, res.invite);
172
172
  }
173
173
  /**
174
- * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination.
174
+ * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination. API keys need `read-subaccount-activity`.
175
175
  */
176
176
  async listEvents(input, options) {
177
177
  const validatedInput = parse(SubaccountActivityInputSchema, input);
@@ -1 +1 @@
1
- {"version":3,"file":"subaccounts.js","names":["#client","Proto.SubaccountService","#viewClient","Proto.SubaccountViewService","#publicRoleClient","Proto.SubaccountRoleService","#authRoleClient","#realtime","SubaccountSchema","ApiKeySchema","Proto.SubaccountSchema","ProtoApiKeys.ApiKeySchema"],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport * as ProtoApiKeys from \"../../gen/auth/v1/api_keys_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type ApiKey, ApiKeySchema } from \"../api-keys/index.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport {\n DEFAULT_SUBACCOUNT_POLICY,\n SubaccountPoliciesService,\n type SubaccountPolicy,\n SubaccountPolicySchema,\n} from \"../policies/subaccount-policies/index.js\";\nimport { createLedgerBalanceSchema, type LedgerBalance } from \"../balances/balances.schemas.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport type { SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSubaccountChallengeInputSchema,\n CreateSubaccountInputSchema,\n CreateSubaccountResultSchema,\n SubaccountChallengeSchema,\n UpdateSubaccountInputSchema,\n InviteSubaccountMemberInputSchema,\n RemoveSubaccountMemberInputSchema,\n UpdateSubaccountMemberRoleInputSchema,\n ListSubaccountInvitesInputSchema,\n RespondSubaccountInviteInputSchema,\n SubaccountActivityInputSchema,\n SubaccountSchema,\n SubaccountMemberSchema,\n SubaccountInviteSchema,\n SubaccountActivityEventSchema,\n SetSubaccountMemberMfaRequirementInputSchema,\n SubaccountIdInputSchema,\n GetSubaccountInputSchema,\n SubaccountMutationResultSchema,\n SubaccountRoleCatalogSchema,\n EffectiveSubaccountPermissionsSchema,\n type CreateSubaccountResult,\n type SubaccountChallenge,\n type Subaccount,\n type SubaccountMember,\n type SubaccountInvite,\n type SubaccountEvent,\n type SubaccountMutationResult,\n type SubaccountRoleCatalog,\n type EffectiveSubaccountPermissions,\n} from \"./subaccounts.schemas.js\";\n\ninterface SubscribeSubaccountsInput extends BaseSubscribeInput<Subaccount> {\n accountId: string;\n}\n\ninterface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {\n accountId: string;\n}\n\n/**\n * Reads the public role catalog and creates, manages, shares, audits, and subscribes to subaccounts visible to the authenticated caller.\n */\nexport class SubaccountsService {\n readonly policies: SubaccountPoliciesService;\n\n #client: Client<typeof Proto.SubaccountService>;\n #viewClient: Client<typeof Proto.SubaccountViewService>;\n #publicRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #authRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #realtime: PolyesterRealtime;\n\n constructor(\n transports: AuthAndPublicApiTransports,\n realtime: PolyesterRealtime,\n resolver?: SubaccountResolver,\n ) {\n this.policies = new SubaccountPoliciesService(transports, realtime, resolver);\n this.#client = createClient(Proto.SubaccountService, transports.authApi);\n this.#viewClient = createClient(Proto.SubaccountViewService, transports.authApi);\n this.#publicRoleClient = createClient(Proto.SubaccountRoleService, transports.publicApi);\n this.#authRoleClient = createClient(Proto.SubaccountRoleService, transports.authApi);\n this.#realtime = realtime;\n }\n\n /**\n * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted ones. Use `createChallenge` for the canonical next smart-account address and salt.\n */\n async list(options?: PolyesterRequestOptions): Promise<{\n totalCreated: number;\n subaccounts: v.InferOutput<typeof SubaccountSchema>[];\n }> {\n const res = await this.#client.listSubaccounts({}, toConnectCallOptions(options));\n return {\n totalCreated: res.totalCreated,\n subaccounts: parse(v.array(SubaccountSchema), res.subaccounts),\n };\n }\n\n /**\n * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, members, and outgoing invites; throws if the subaccount is missing.\n *\n * `includeBalances: true` also returns the sub-account's current `balances`, in the shape of\n * `balances.list`. It needs the READ_BALANCES action on the sub-account (its role, any attached\n * policy and, for an API key, the key's policy), or the call fails with PermissionDenied. When\n * balances cannot be read right now the call fails with the retryable\n * `AUTH_TEMPORARILY_UNAVAILABLE`; retry the same call.\n */\n async get(\n input: v.InferInput<typeof GetSubaccountInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<\n Subaccount & {\n apiKeys: ApiKey[];\n policy: SubaccountPolicy;\n members: SubaccountMember[];\n invites: SubaccountInvite[];\n balances?: LedgerBalance[];\n }\n > {\n const validatedInput = parse(GetSubaccountInputSchema, input);\n const subaccountId = formatId(validatedInput.subaccountId);\n const includeBalances = validatedInput.includeBalances === true;\n const res = await this.#viewClient.getSubaccount(\n {\n subaccountId: validatedInput.subaccountId,\n includeApiKeys: true,\n includeMembers: true,\n includeInvites: true,\n includePolicy: true,\n invitesDirection: Proto.SubaccountInviteDirection.OUTGOING,\n ...(includeBalances && { includeBalances }),\n },\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(`Subaccount not found: ${subaccountId}`);\n\n return {\n ...parse(SubaccountSchema, res.subaccount),\n policy: res.policy\n ? parse(SubaccountPolicySchema, res.policy)\n : DEFAULT_SUBACCOUNT_POLICY,\n apiKeys: parse(v.optional(v.array(ApiKeySchema), []), res.apiKeys),\n members: parse(v.optional(v.array(SubaccountMemberSchema), []), res.members),\n invites: v\n .parse(v.optional(v.array(SubaccountInviteSchema), []), res.invites)\n .filter((invite) => invite.subaccountId === subaccountId),\n ...(includeBalances && {\n balances: parse(v.array(createLedgerBalanceSchema()), res.balances?.balances ?? []),\n }),\n };\n }\n\n /**\n * Requests the canonical next smart account and a short-lived EIP-191 authorization message\n * bound to the authenticated root and the selected owner EOA. Sign the exact message through\n * the returned smart account, then pass it to `create`. A new challenge replaces the previous one.\n */\n async createChallenge(\n input: v.InferInput<typeof CreateSubaccountChallengeInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountChallenge> {\n const validatedInput = parse(CreateSubaccountChallengeInputSchema, input);\n const res = await this.#client.createSubaccountChallenge(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountChallengeSchema, res);\n }\n\n /**\n * Creates a new subaccount under the caller's root account using the smart-account address, message, and smart-account signature from `createChallenge`.\n */\n async create(\n input: v.InferInput<typeof CreateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CreateSubaccountResult> {\n const validatedInput = parse(CreateSubaccountInputSchema, input);\n const res = await this.#client.createSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(CreateSubaccountResultSchema, res);\n }\n\n /**\n * Updates mutable subaccount display/status fields such as label and active/disabled status.\n */\n async update(\n input: v.InferInput<typeof UpdateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Subaccount> {\n const validatedInput = parse(UpdateSubaccountInputSchema, input);\n const res = await this.#client.updateSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(\"Failed to update subaccount\");\n return parse(SubaccountSchema, res.subaccount);\n }\n\n /**\n * Creates or refreshes a pending invitation granting a role on a subaccount to another root account.\n */\n async inviteMember(\n input: v.InferInput<typeof InviteSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(InviteSubaccountMemberInputSchema, input);\n const res = await this.#client.inviteSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Removes delegated access for a subaccount member by grantee account ID.\n */\n async removeMember(\n input: v.InferInput<typeof RemoveSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(RemoveSubaccountMemberInputSchema, input);\n const res = await this.#client.removeSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Changes an existing delegated member's role without sending a new invitation.\n */\n async updateMemberRole(\n input: v.InferInput<typeof UpdateSubaccountMemberRoleInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(UpdateSubaccountMemberRoleInputSchema, input);\n const res = await this.#client.updateSubaccountMemberRole(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Enables or disables the owner-controlled MFA requirement for delegated interactive member actions on a subaccount.\n */\n async setMemberMfaRequirement(\n input: v.InferInput<typeof SetSubaccountMemberMfaRequirementInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(SetSubaccountMemberMfaRequirementInputSchema, input);\n const res = await this.#client.setSubaccountMemberMFARequirement(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Returns the caller's subaccount invitations, newest first. Omit `direction` to include both\n * incoming and outgoing invitations, or pass `\"incoming\"` or `\"outgoing\"` to filter.\n */\n async listInvites(\n input: v.InferInput<typeof ListSubaccountInvitesInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountInvite[]> {\n const validatedInput = parse(ListSubaccountInvitesInputSchema, input);\n const res = await this.#client.listSubaccountInvites(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountInviteSchema), res.invites);\n }\n\n /**\n * Returns the public built-in role and permission catalog with display metadata and per-role permission sets.\n */\n async listRoles(options?: PolyesterRequestOptions): Promise<SubaccountRoleCatalog> {\n const res = await this.#publicRoleClient.listSubaccountRoles(\n {},\n toConnectCallOptions(options),\n );\n return parse(SubaccountRoleCatalogSchema, res);\n }\n\n /**\n * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount.\n */\n async getEffectivePermissions(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<EffectiveSubaccountPermissions> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#authRoleClient.getEffectiveSubaccountPermissions(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(EffectiveSubaccountPermissionsSchema, res);\n }\n\n /**\n * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status.\n */\n async listMembers(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountMember[]> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#client.listSubaccountMembers(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountMemberSchema), res.members);\n }\n\n /**\n * Accepts or rejects an incoming invite, or cancels an outgoing invite, returning the updated invitation.\n */\n async respondInvite(\n input: v.InferInput<typeof RespondSubaccountInviteInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(RespondSubaccountInviteInputSchema, input);\n const res = await this.#client.respondSubaccountInvite(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination.\n */\n async listEvents(\n input: v.InferInput<typeof SubaccountActivityInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<{ events: SubaccountEvent[]; nextPageToken: string }> {\n const validatedInput = parse(SubaccountActivityInputSchema, input);\n const res = await this.#viewClient.listSubaccountActivity(\n validatedInput,\n toConnectCallOptions(options),\n );\n return {\n events: parse(v.optional(v.array(SubaccountActivityEventSchema), []), res.events),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Subscribes to private subaccount updates for an account and emits normalized subaccount records. A record with `removed: true` means the caller lost access to that subaccount; remove it locally. Losing access also ends the caller's subscriptions to that subaccount's channels.\n */\n subscribe(input: SubscribeSubaccountsInput) {\n const channel = `private:auth:subaccounts:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.SubaccountSchema,\n onPublication: (data) => {\n const subaccount = parse(SubaccountSchema, data);\n input.onEvent(subaccount);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n\n /**\n * Subscribes to private API key updates for an account through the subaccount realtime channel helper.\n */\n subscribeApiKeys(input: SubscribeApiKeysInput) {\n const channel = `private:auth:api-keys:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: ProtoApiKeys.ApiKeySchema,\n onPublication: (data) => {\n const apiKey = parse(ApiKeySchema, data);\n input.onEvent(apiKey);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmEA,IAAa,qBAAb,MAAgC;CAC5B;CAEA;CACA;CACA;CACA;CACA;CAEA,YACI,YACA,UACA,UACF;EACE,KAAK,WAAW,IAAI,0BAA0B,YAAY,UAAU,QAAQ;EAC5E,KAAKA,UAAU,aAAaC,mBAAyB,WAAW,OAAO;EACvE,KAAKC,cAAc,aAAaC,uBAA6B,WAAW,OAAO;EAC/E,KAAKC,oBAAoB,aAAaC,uBAA6B,WAAW,SAAS;EACvF,KAAKC,kBAAkB,aAAaD,uBAA6B,WAAW,OAAO;EACnF,KAAKE,YAAY;CACrB;;;;CAKA,MAAM,KAAK,SAGR;EACC,MAAM,MAAM,MAAM,KAAKP,QAAQ,gBAAgB,CAAC,GAAG,qBAAqB,OAAO,CAAC;EAChF,OAAO;GACH,cAAc,IAAI;GAClB,aAAa,MAAM,EAAE,MAAMQ,kBAAgB,GAAG,IAAI,WAAW;EACjE;CACJ;;;;;;;;;;CAWA,MAAM,IACF,OACA,SASF;EACE,MAAM,iBAAiB,MAAM,0BAA0B,KAAK;EAC5D,MAAM,eAAe,SAAS,eAAe,YAAY;EACzD,MAAM,kBAAkB,eAAe,oBAAoB;EAC3D,MAAM,MAAM,MAAM,KAAKN,YAAY,cAC/B;GACI,cAAc,eAAe;GAC7B,gBAAgB;GAChB,gBAAgB;GAChB,gBAAgB;GAChB,eAAe;GACf,kBAAA;GACA,GAAI,mBAAmB,EAAE,gBAAgB;EAC7C,GACA,qBAAqB,OAAO,CAChC;EACA,IAAI,CAAC,IAAI,YAAY,MAAM,IAAI,MAAM,yBAAyB,cAAc;EAE5E,OAAO;GACH,GAAG,MAAMM,oB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,"file":"subaccounts.js","names":["#client","Proto.SubaccountService","#viewClient","Proto.SubaccountViewService","#publicRoleClient","Proto.SubaccountRoleService","#authRoleClient","#realtime","SubaccountSchema","ApiKeySchema","Proto.SubaccountSchema","ProtoApiKeys.ApiKeySchema"],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport * as ProtoApiKeys from \"../../gen/auth/v1/api_keys_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type ApiKey, ApiKeySchema } from \"../api-keys/index.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport {\n DEFAULT_SUBACCOUNT_POLICY,\n SubaccountPoliciesService,\n type SubaccountPolicy,\n SubaccountPolicySchema,\n} from \"../policies/subaccount-policies/index.js\";\nimport { createLedgerBalanceSchema, type LedgerBalance } from \"../balances/balances.schemas.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport type { SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSubaccountChallengeInputSchema,\n CreateSubaccountInputSchema,\n CreateSubaccountResultSchema,\n SubaccountChallengeSchema,\n UpdateSubaccountInputSchema,\n InviteSubaccountMemberInputSchema,\n RemoveSubaccountMemberInputSchema,\n UpdateSubaccountMemberRoleInputSchema,\n ListSubaccountInvitesInputSchema,\n RespondSubaccountInviteInputSchema,\n SubaccountActivityInputSchema,\n SubaccountSchema,\n SubaccountMemberSchema,\n SubaccountInviteSchema,\n SubaccountActivityEventSchema,\n SetSubaccountMemberMfaRequirementInputSchema,\n SubaccountIdInputSchema,\n GetSubaccountInputSchema,\n SubaccountMutationResultSchema,\n SubaccountRoleCatalogSchema,\n EffectiveSubaccountPermissionsSchema,\n type CreateSubaccountResult,\n type SubaccountChallenge,\n type Subaccount,\n type SubaccountMember,\n type SubaccountInvite,\n type SubaccountEvent,\n type SubaccountMutationResult,\n type SubaccountRoleCatalog,\n type EffectiveSubaccountPermissions,\n} from \"./subaccounts.schemas.js\";\n\ninterface SubscribeSubaccountsInput extends BaseSubscribeInput<Subaccount> {\n accountId: string;\n}\n\ninterface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {\n accountId: string;\n}\n\n/**\n * Reads the public role catalog and creates, manages, shares, audits, and subscribes to subaccounts visible to the authenticated caller.\n */\nexport class SubaccountsService {\n readonly policies: SubaccountPoliciesService;\n\n #client: Client<typeof Proto.SubaccountService>;\n #viewClient: Client<typeof Proto.SubaccountViewService>;\n #publicRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #authRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #realtime: PolyesterRealtime;\n\n constructor(\n transports: AuthAndPublicApiTransports,\n realtime: PolyesterRealtime,\n resolver?: SubaccountResolver,\n ) {\n this.policies = new SubaccountPoliciesService(transports, realtime, resolver);\n this.#client = createClient(Proto.SubaccountService, transports.authApi);\n this.#viewClient = createClient(Proto.SubaccountViewService, transports.authApi);\n this.#publicRoleClient = createClient(Proto.SubaccountRoleService, transports.publicApi);\n this.#authRoleClient = createClient(Proto.SubaccountRoleService, transports.authApi);\n this.#realtime = realtime;\n }\n\n /**\n * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted ones. Use `createChallenge` for the canonical next smart-account address and salt. API keys need `read-subaccounts` and see only the subaccounts within their scope.\n */\n async list(options?: PolyesterRequestOptions): Promise<{\n totalCreated: number;\n subaccounts: v.InferOutput<typeof SubaccountSchema>[];\n }> {\n const res = await this.#client.listSubaccounts({}, toConnectCallOptions(options));\n return {\n totalCreated: res.totalCreated,\n subaccounts: parse(v.array(SubaccountSchema), res.subaccounts),\n };\n }\n\n /**\n * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, members, and outgoing invites; throws if the subaccount is missing. API keys need `read-subaccounts`.\n *\n * `includeBalances: true` also returns the sub-account's current `balances`, in the shape of\n * `balances.list`. It needs the READ_BALANCES action on the sub-account (its role, any attached\n * policy and, for an API key, the key's policy), or the call fails with PermissionDenied. When\n * balances cannot be read right now the call fails with the retryable\n * `AUTH_TEMPORARILY_UNAVAILABLE`; retry the same call.\n */\n async get(\n input: v.InferInput<typeof GetSubaccountInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<\n Subaccount & {\n apiKeys: ApiKey[];\n policy: SubaccountPolicy;\n members: SubaccountMember[];\n invites: SubaccountInvite[];\n balances?: LedgerBalance[];\n }\n > {\n const validatedInput = parse(GetSubaccountInputSchema, input);\n const subaccountId = formatId(validatedInput.subaccountId);\n const includeBalances = validatedInput.includeBalances === true;\n const res = await this.#viewClient.getSubaccount(\n {\n subaccountId: validatedInput.subaccountId,\n includeApiKeys: true,\n includeMembers: true,\n includeInvites: true,\n includePolicy: true,\n invitesDirection: Proto.SubaccountInviteDirection.OUTGOING,\n ...(includeBalances && { includeBalances }),\n },\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(`Subaccount not found: ${subaccountId}`);\n\n return {\n ...parse(SubaccountSchema, res.subaccount),\n policy: res.policy\n ? parse(SubaccountPolicySchema, res.policy)\n : DEFAULT_SUBACCOUNT_POLICY,\n apiKeys: parse(v.optional(v.array(ApiKeySchema), []), res.apiKeys),\n members: parse(v.optional(v.array(SubaccountMemberSchema), []), res.members),\n invites: v\n .parse(v.optional(v.array(SubaccountInviteSchema), []), res.invites)\n .filter((invite) => invite.subaccountId === subaccountId),\n ...(includeBalances && {\n balances: parse(v.array(createLedgerBalanceSchema()), res.balances?.balances ?? []),\n }),\n };\n }\n\n /**\n * Requests the canonical next smart account and a short-lived EIP-191 authorization message\n * bound to the authenticated root and the selected owner EOA. Sign the exact message through\n * the returned smart account, then pass it to `create`. A new challenge replaces the previous one.\n */\n async createChallenge(\n input: v.InferInput<typeof CreateSubaccountChallengeInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountChallenge> {\n const validatedInput = parse(CreateSubaccountChallengeInputSchema, input);\n const res = await this.#client.createSubaccountChallenge(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountChallengeSchema, res);\n }\n\n /**\n * Creates a new subaccount under the caller's root account using the smart-account address, message, and smart-account signature from `createChallenge`.\n */\n async create(\n input: v.InferInput<typeof CreateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CreateSubaccountResult> {\n const validatedInput = parse(CreateSubaccountInputSchema, input);\n const res = await this.#client.createSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(CreateSubaccountResultSchema, res);\n }\n\n /**\n * Updates mutable subaccount display/status fields such as label and active/disabled status.\n */\n async update(\n input: v.InferInput<typeof UpdateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Subaccount> {\n const validatedInput = parse(UpdateSubaccountInputSchema, input);\n const res = await this.#client.updateSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(\"Failed to update subaccount\");\n return parse(SubaccountSchema, res.subaccount);\n }\n\n /**\n * Creates or refreshes a pending invitation granting a role on a subaccount to another root account.\n */\n async inviteMember(\n input: v.InferInput<typeof InviteSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(InviteSubaccountMemberInputSchema, input);\n const res = await this.#client.inviteSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Removes delegated access for a subaccount member by grantee account ID.\n */\n async removeMember(\n input: v.InferInput<typeof RemoveSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(RemoveSubaccountMemberInputSchema, input);\n const res = await this.#client.removeSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Changes an existing delegated member's role without sending a new invitation.\n */\n async updateMemberRole(\n input: v.InferInput<typeof UpdateSubaccountMemberRoleInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(UpdateSubaccountMemberRoleInputSchema, input);\n const res = await this.#client.updateSubaccountMemberRole(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Enables or disables the owner-controlled MFA requirement for delegated interactive member actions on a subaccount.\n */\n async setMemberMfaRequirement(\n input: v.InferInput<typeof SetSubaccountMemberMfaRequirementInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(SetSubaccountMemberMfaRequirementInputSchema, input);\n const res = await this.#client.setSubaccountMemberMFARequirement(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Returns the caller's subaccount invitations, newest first. Omit `direction` to include both\n * incoming and outgoing invitations, or pass `\"incoming\"` or `\"outgoing\"` to filter. API keys need `read-subaccount-invites` and see only outgoing invitations.\n */\n async listInvites(\n input: v.InferInput<typeof ListSubaccountInvitesInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountInvite[]> {\n const validatedInput = parse(ListSubaccountInvitesInputSchema, input);\n const res = await this.#client.listSubaccountInvites(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountInviteSchema), res.invites);\n }\n\n /**\n * Returns the public built-in role and permission catalog with display metadata and per-role permission sets.\n */\n async listRoles(options?: PolyesterRequestOptions): Promise<SubaccountRoleCatalog> {\n const res = await this.#publicRoleClient.listSubaccountRoles(\n {},\n toConnectCallOptions(options),\n );\n return parse(SubaccountRoleCatalogSchema, res);\n }\n\n /**\n * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount. API keys need `read-subaccount-permissions` and get what the key itself may do.\n */\n async getEffectivePermissions(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<EffectiveSubaccountPermissions> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#authRoleClient.getEffectiveSubaccountPermissions(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(EffectiveSubaccountPermissionsSchema, res);\n }\n\n /**\n * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status. API keys need `read-subaccount-members`.\n */\n async listMembers(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountMember[]> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#client.listSubaccountMembers(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountMemberSchema), res.members);\n }\n\n /**\n * Accepts or rejects an incoming invite, or cancels an outgoing invite, returning the updated invitation.\n */\n async respondInvite(\n input: v.InferInput<typeof RespondSubaccountInviteInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(RespondSubaccountInviteInputSchema, input);\n const res = await this.#client.respondSubaccountInvite(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination. API keys need `read-subaccount-activity`.\n */\n async listEvents(\n input: v.InferInput<typeof SubaccountActivityInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<{ events: SubaccountEvent[]; nextPageToken: string }> {\n const validatedInput = parse(SubaccountActivityInputSchema, input);\n const res = await this.#viewClient.listSubaccountActivity(\n validatedInput,\n toConnectCallOptions(options),\n );\n return {\n events: parse(v.optional(v.array(SubaccountActivityEventSchema), []), res.events),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Subscribes to private subaccount updates for an account and emits normalized subaccount records. A record with `removed: true` means the caller lost access to that subaccount; remove it locally. Losing access also ends the caller's subscriptions to that subaccount's channels.\n */\n subscribe(input: SubscribeSubaccountsInput) {\n const channel = `private:auth:subaccounts:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.SubaccountSchema,\n onPublication: (data) => {\n const subaccount = parse(SubaccountSchema, data);\n input.onEvent(subaccount);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n\n /**\n * Subscribes to private API key updates for an account through the subaccount realtime channel helper.\n */\n subscribeApiKeys(input: SubscribeApiKeysInput) {\n const channel = `private:auth:api-keys:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: ProtoApiKeys.ApiKeySchema,\n onPublication: (data) => {\n const apiKey = parse(ApiKeySchema, data);\n input.onEvent(apiKey);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmEA,IAAa,qBAAb,MAAgC;CAC5B;CAEA;CACA;CACA;CACA;CACA;CAEA,YACI,YACA,UACA,UACF;EACE,KAAK,WAAW,IAAI,0BAA0B,YAAY,UAAU,QAAQ;EAC5E,KAAKA,UAAU,aAAaC,mBAAyB,WAAW,OAAO;EACvE,KAAKC,cAAc,aAAaC,uBAA6B,WAAW,OAAO;EAC/E,KAAKC,oBAAoB,aAAaC,uBAA6B,WAAW,SAAS;EACvF,KAAKC,kBAAkB,aAAaD,uBAA6B,WAAW,OAAO;EACnF,KAAKE,YAAY;CACrB;;;;CAKA,MAAM,KAAK,SAGR;EACC,MAAM,MAAM,MAAM,KAAKP,QAAQ,gBAAgB,CAAC,GAAG,qBAAqB,OAAO,CAAC;EAChF,OAAO;GACH,cAAc,IAAI;GAClB,aAAa,MAAM,EAAE,MAAMQ,kBAAgB,GAAG,IAAI,WAAW;EACjE;CACJ;;;;;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