@polyester/sdk 0.34.1-devnet-20261106025831 → 0.35.0-devnet-20261107174905

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 (52) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/README.md +12 -0
  3. package/dist/index.d.ts +2 -2
  4. package/dist/realtime/client.d.ts.map +1 -1
  5. package/dist/realtime/client.js +178 -29
  6. package/dist/realtime/client.js.map +1 -1
  7. package/dist/realtime/index.d.ts +2 -2
  8. package/dist/realtime/types.d.ts +21 -2
  9. package/dist/realtime/types.d.ts.map +1 -1
  10. package/dist/services/candles/candles.schemas.d.ts +10 -10
  11. package/dist/services/checkpoints/checkpoints.schemas.d.ts +8 -2
  12. package/dist/services/checkpoints/checkpoints.schemas.d.ts.map +1 -1
  13. package/dist/services/checkpoints/checkpoints.schemas.js +6 -0
  14. package/dist/services/checkpoints/checkpoints.schemas.js.map +1 -1
  15. package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
  16. package/dist/services/lifecycle/lifecycle.schemas.d.ts +79 -79
  17. package/dist/services/orderbook/orderbook.d.ts +1 -1
  18. package/dist/services/orderbook/orderbook.js +1 -1
  19. package/dist/services/orderbook/orderbook.js.map +1 -1
  20. package/dist/services/orderbook/orderbook.schemas.d.ts +1 -1
  21. package/dist/services/orders/orders-batch.schemas.d.ts +7 -7
  22. package/dist/services/orders/orders-output.schemas.d.ts +3 -3
  23. package/dist/services/orders/orders.d.ts +1 -1
  24. package/dist/services/orders/orders.js +1 -1
  25. package/dist/services/orders/orders.js.map +1 -1
  26. package/dist/services/rewards/rewards.d.ts +1 -1
  27. package/dist/services/rewards/rewards.js +1 -1
  28. package/dist/services/rewards/rewards.js.map +1 -1
  29. package/dist/services/rewards/rewards.schemas.d.ts +7 -0
  30. package/dist/services/rewards/rewards.schemas.d.ts.map +1 -1
  31. package/dist/services/rewards/rewards.schemas.js +8 -1
  32. package/dist/services/rewards/rewards.schemas.js.map +1 -1
  33. package/dist/services/subaccounts/subaccounts.d.ts +1 -1
  34. package/dist/services/subaccounts/subaccounts.js +1 -1
  35. package/dist/services/subaccounts/subaccounts.js.map +1 -1
  36. package/dist/services/subaccounts/subaccounts.schemas.d.ts +10 -1
  37. package/dist/services/subaccounts/subaccounts.schemas.d.ts.map +1 -1
  38. package/dist/services/subaccounts/subaccounts.schemas.js +8 -1
  39. package/dist/services/subaccounts/subaccounts.schemas.js.map +1 -1
  40. package/dist/services/trades/trades.schemas.d.ts +2 -2
  41. package/dist/services/triggers/triggers-output.schemas.d.ts +19 -19
  42. package/dist/shared/connect-error-mapping.d.ts.map +1 -1
  43. package/dist/shared/connect-error-mapping.js +5 -2
  44. package/dist/shared/connect-error-mapping.js.map +1 -1
  45. package/dist/shared/errors.d.ts +1 -1
  46. package/dist/shared/errors.d.ts.map +1 -1
  47. package/dist/shared/errors.js.map +1 -1
  48. package/dist/shared/subscription-errors.d.ts +2 -0
  49. package/dist/shared/subscription-errors.d.ts.map +1 -1
  50. package/dist/shared/subscription-errors.js.map +1 -1
  51. package/dist/shared/transports.js.map +1 -1
  52. package/package.json +1 -1
@@ -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.\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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BACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,wBAAwB,IAAI,MAAM;CACnD;;;;CAKA,MAAM,WACF,OACA,SAC6D;EAC7D,MAAM,iBAAiB,MAAM,+BAA+B,KAAK;EACjE,MAAM,MAAM,MAAM,KAAKE,YAAY,uBAC/B,gBACA,qBAAqB,OAAO,CAChC;EACA,OAAO;GACH,QAAQ,MAAM,EAAE,SAAS,EAAE,MAAM,6BAA6B,GAAG,CAAC,CAAC,GAAG,IAAI,MAAM;GAChF,eAAe,IAAI;EACvB;CACJ;;;;CAKA,UAAU,OAAkC;EACxC,MAAM,UAAU,4BAA4B,MAAM,UAAU;EAE5D,OAAO,KAAKK,UAAU,oBAAoB;GACtC;GACA,QAAQG;GACR,gBAAgB,SAAS;IACrB,MAAM,aAAa,MAAMF,oBAAkB,IAAI;IAC/C,MAAM,QAAQ,UAAU;GAC5B;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;;;;CAKA,iBAAiB,OAA8B;EAC3C,MAAM,UAAU,yBAAyB,MAAM,UAAU;EAEzD,OAAO,KAAKD,UAAU,oBAAoB;GACtC;GACA,QAAQI;GACR,gBAAgB,SAAS;IACrB,MAAM,SAAS,MAAMF,gBAAc,IAAI;IACvC,MAAM,QAAQ,MAAM;GACxB;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
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,MAAM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,6 +180,13 @@ declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
180
180
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
181
181
  }, undefined>, undefined>;
182
182
  readonly revision: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
183
+ /**
184
+ * Only realtime updates set this: the caller lost access, so drop the subaccount from
185
+ * local state. `role` is `"unspecified"` when it is true. Access and role changes leave
186
+ * `revision` and `updatedAt` unchanged, so apply them in arrival order rather than
187
+ * gating them on those fields.
188
+ */
189
+ readonly removed: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
183
190
  }, undefined>, v.TransformAction<{
184
191
  id: string;
185
192
  role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
@@ -199,6 +206,7 @@ declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
199
206
  nanos: number;
200
207
  } | undefined;
201
208
  revision: string;
209
+ removed: boolean;
202
210
  }, {
203
211
  updatedAt: number | undefined;
204
212
  updatedAtNs: string | undefined;
@@ -216,6 +224,7 @@ declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
216
224
  subaccountPolicyId: string;
217
225
  requireMemberMfa: boolean;
218
226
  revision: string;
227
+ removed: boolean;
219
228
  }>]>;
220
229
  type Subaccount = v.InferOutput<typeof SubaccountSchema>;
221
230
  declare const SubaccountMemberSchema: v.ObjectSchema<{
@@ -301,7 +310,7 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
301
310
  nanos: number;
302
311
  } | undefined, number | undefined>]>;
303
312
  readonly entityKind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "subaccount" | "api_key" | "account" | "destination" | "session" | "policy" | "member" | "invite" | "security">]>;
304
- readonly eventAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "disabled" | "revoked" | "removed" | "failed" | "enabled" | "created" | "updated" | "deleted" | "role_set" | "received" | "replied" | "blocked" | "hold_placed" | "hold_released">]>;
313
+ readonly eventAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "disabled" | "removed" | "revoked" | "failed" | "enabled" | "created" | "updated" | "deleted" | "role_set" | "received" | "replied" | "blocked" | "hold_placed" | "hold_released">]>;
305
314
  readonly source: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "api" | "web" | "mobile">]>;
306
315
  readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
307
316
  readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"subaccounts.schemas.d.ts","names":[],"sources":["../../../src/services/subaccounts/subaccounts.schemas.ts"],"mappings":";;;cA2Ca,sBAAoB,EAAA;KAErB,iBAAiB,EAAE,mBAAmB;cAI5C,iCAA+B,EAAA,yBAAA,EAAA,yBAAA,EAAA;KAEzB,uBAAuB,EAAE,mBAAmB;cAE3C,sCAAoC,EAAA;;;;;;KAOrC,iCAAiC,EAAE,mBACpC;cAGE,gCAA8B,EAAA;;;;;;;KAQ/B,2BAA2B,EAAE,mBAAmB;cAE/C,6BAA2B,EAAA;;;;;;;;;;;;;;;KAK5B,wBAAwB,EAAE,mBAAmB;cAE5C,sCAAoC,EAAA;;;;;KAMrC,iCAAiC,EAAE,mBACpC;cAGE,sCAAoC,EAAA;;;;KAKrC,iCAAiC,EAAE,kBACpC;cAGE,2BAAyB,EAAA;;;;;;;;;;;;;KAQ1B,sBAAsB,EAAE,mBAAmB;cAE1C,6BAA2B,EAAA;;;;;;;;KAS5B,wBAAwB,EAAE,kBAAkB;cAE3C,yBAAuB,EAAA;;;KAIxB,oBAAoB,EAAE,kBAAkB;cAEvC,0BAAwB,EAAA;;;;KAKzB,qBAAqB,EAAE,kBAAkB;cAExC,8BAA4B,EAAA;;;;;;KAO7B,yBAAy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AAA,yBAAA,EAAA;KAErB,mBAAmB,EAAE,mBAAmB;cAEvC,kBAAgB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgCjB,aAAa,EAAE,mBAAmB;cAEjC,wBAAsB,EAAA;;;;;;;;KASvB,mBAAmB,EAAE,mBAAmB;cAEvC,wBAAsB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqCvB,mBAAmB,EAAE,mBAAmB;cAEvC,+BAA6B,EAAA;;;;;KAM9B,0BAA0B,EAAE,kBAAkB;cAE7C,+BAA6B,EAAA;;;;;;;;;;;;;;;;KAc9B,kBAAkB,EAAE,mBAAmB"}
@@ -150,7 +150,14 @@ const SubaccountSchema = v.pipe(v.object({
150
150
  subaccountPolicyId: PublicIdOrEmptySchema,
151
151
  requireMemberMfa: v.optional(v.boolean(), false),
152
152
  updatedAt: v.optional(TimestampSchema),
153
- revision: BigIntStringSchema
153
+ revision: BigIntStringSchema,
154
+ /**
155
+ * Only realtime updates set this: the caller lost access, so drop the subaccount from
156
+ * local state. `role` is `"unspecified"` when it is true. Access and role changes leave
157
+ * `revision` and `updatedAt` unchanged, so apply them in arrival order rather than
158
+ * gating them on those fields.
159
+ */
160
+ removed: v.optional(v.boolean(), false)
154
161
  }), v.transform(({ updatedAt, ...subaccount }) => ({
155
162
  ...subaccount,
156
163
  updatedAt: tsObjToMs(updatedAt),
@@ -1 +1 @@
1
- {"version":3,"file":"subaccounts.schemas.js","names":[],"sources":["../../../src/services/subaccounts/subaccounts.schemas.ts"],"sourcesContent":["import {\n WalletAddressSchema,\n WalletChallengeMessageSchema,\n WalletChallengeUriSchema,\n WalletSignatureSchema,\n} from \"../auth/wallet-challenge.schemas.js\";\nimport * as v from \"valibot\";\nimport {\n BigIntStringSchema,\n OptionalTimestampMsSchema,\n PublicIdOrEmptySchema,\n PublicIdSchema,\n TimestampSchema,\n idInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../utils/time.js\";\nimport { enumLabel, enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport {\n SubaccountRoleCodec,\n SubaccountPermissionCodec,\n InviteActionCodec,\n InviteStatusCodec,\n SubaccountInviteDirectionCodec,\n SUBACCOUNT_INVITE_DIRECTION_VALUES,\n SubaccountStatusCodec,\n SUBACCOUNT_STATUS_VALUES,\n ActivityEntityKindCodec,\n ActivityEventActionCodec,\n ActivityEventSourceCodec,\n} from \"./subaccounts.codecs.js\";\nimport { PolicyActionCodec } from \"../policies/shared.codecs.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../utils/proto-patch.js\";\n\nconst SUBACCOUNT_ROLE_VALUES = [\n \"owner\",\n \"admin\",\n \"treasury\",\n \"leveraged_trader\",\n \"trader\",\n \"viewer\",\n] as const;\n\nexport const SubaccountRoleSchema = v.picklist(SUBACCOUNT_ROLE_VALUES);\n\nexport type SubaccountRole = v.InferOutput<typeof SubaccountRoleSchema>;\n\nconst ProtoSubaccountRoleSchema = enumLabelSchema(SubaccountRoleCodec.protoToOutput);\n\nconst ProtoSubaccountPermissionSchema = enumLabelSchema(SubaccountPermissionCodec.protoToOutput);\n\nexport type SubaccountPermission = v.InferOutput<typeof ProtoSubaccountPermissionSchema>;\n\nexport const SubaccountPermissionDefinitionSchema = v.object({\n permission: ProtoSubaccountPermissionSchema,\n displayName: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n policyAction: enumLabelSchema(PolicyActionCodec.protoToOutput),\n});\n\nexport type SubaccountPermissionDefinition = v.InferOutput<\n typeof SubaccountPermissionDefinitionSchema\n>;\n\nexport const SubaccountRoleDefinitionSchema = v.object({\n role: ProtoSubaccountRoleSchema,\n displayName: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n assignable: v.optional(v.boolean(), false),\n permissions: v.optional(v.array(ProtoSubaccountPermissionSchema), []),\n});\n\nexport type SubaccountRoleDefinition = v.InferOutput<typeof SubaccountRoleDefinitionSchema>;\n\nexport const SubaccountRoleCatalogSchema = v.object({\n permissions: v.optional(v.array(SubaccountPermissionDefinitionSchema), []),\n roles: v.optional(v.array(SubaccountRoleDefinitionSchema), []),\n});\n\nexport type SubaccountRoleCatalog = v.InferOutput<typeof SubaccountRoleCatalogSchema>;\n\nexport const EffectiveSubaccountPermissionsSchema = v.object({\n role: ProtoSubaccountRoleSchema,\n permissions: v.optional(v.array(ProtoSubaccountPermissionSchema), []),\n subaccountPolicyId: PublicIdOrEmptySchema,\n});\n\nexport type EffectiveSubaccountPermissions = v.InferOutput<\n typeof EffectiveSubaccountPermissionsSchema\n>;\n\nexport const CreateSubaccountChallengeInputSchema = v.strictObject({\n ownerAddress: WalletAddressSchema,\n uri: WalletChallengeUriSchema,\n});\n\nexport type CreateSubaccountChallengeInput = v.InferInput<\n typeof CreateSubaccountChallengeInputSchema\n>;\n\nexport const SubaccountChallengeSchema = v.object({\n message: WalletChallengeMessageSchema,\n smartAccountAddress: WalletAddressSchema,\n smartAccountSaltNonce: v.number(),\n expiresAt: OptionalTimestampMsSchema,\n polyesterChainId: v.pipe(v.bigint(), v.transform(Number)),\n});\n\nexport type SubaccountChallenge = v.InferOutput<typeof SubaccountChallengeSchema>;\n\nexport const CreateSubaccountInputSchema = v.strictObject({\n label: v.optional(v.string(), \"\"),\n icon: v.optional(v.string(), \"\"),\n color: v.optional(v.string(), \"\"),\n smartAccountAddress: WalletAddressSchema,\n message: WalletChallengeMessageSchema,\n signature: WalletSignatureSchema,\n});\n\nexport type CreateSubaccountInput = v.InferInput<typeof CreateSubaccountInputSchema>;\n\nexport const SubaccountIdInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n});\n\nexport type SubaccountIdInput = v.InferInput<typeof SubaccountIdInputSchema>;\n\nexport const GetSubaccountInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n includeBalances: v.optional(v.boolean()),\n});\n\nexport type GetSubaccountInput = v.InferInput<typeof GetSubaccountInputSchema>;\n\nexport const CreateSubaccountResultSchema = v.object({\n subaccountId: PublicIdSchema,\n totalCreated: v.number(),\n smartAccountSaltNonce: v.number(),\n revision: BigIntStringSchema,\n});\n\nexport type CreateSubaccountResult = v.InferOutput<typeof CreateSubaccountResultSchema>;\n\nexport const SubaccountMutationResultSchema = v.object({});\n\nexport type SubaccountMutationResult = v.InferOutput<typeof SubaccountMutationResultSchema>;\n\ntype SubaccountPatch = {\n label?: string;\n icon?: string;\n color?: string;\n status?: (typeof SUBACCOUNT_STATUS_VALUES)[number];\n};\n\nconst SUBACCOUNT_PATCH_FIELDS = defineProtoPatchFields<SubaccountPatch>()({\n label: { path: \"label\", encode: (label) => ({ label }) },\n icon: { path: \"icon\", encode: (icon) => ({ icon }) },\n color: { path: \"color\", encode: (color) => ({ color }) },\n status: {\n path: \"status\",\n encode: (status) => ({ status: SubaccountStatusCodec.inputToProto[status] }),\n },\n});\n\nexport const UpdateSubaccountInputSchema = v.pipe(\n v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n label: v.optional(v.string()),\n icon: v.optional(v.string()),\n color: v.optional(v.string()),\n status: v.optional(v.picklist(SUBACCOUNT_STATUS_VALUES)),\n }),\n v.check(\n ({ label, icon, color, status }) =>\n label !== undefined ||\n icon !== undefined ||\n color !== undefined ||\n status !== undefined,\n \"At least one subaccount field must be provided\",\n ),\n v.transform(({ subaccountId, expectedRevision, ...input }) => {\n const { patch: subaccount, updateMask } = buildProtoPatch(input, SUBACCOUNT_PATCH_FIELDS);\n return {\n subaccountId,\n subaccount,\n updateMask,\n expectedRevision,\n };\n }),\n);\n\nexport type UpdateSubaccountInput = v.InferInput<typeof UpdateSubaccountInputSchema>;\n\nexport const InviteSubaccountMemberInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n granteeAccountId: idInputSchema(\"granteeAccountId\"),\n role: v.pipe(\n SubaccountRoleSchema,\n v.transform((role) => SubaccountRoleCodec.inputToProto[role]),\n ),\n});\n\nexport type InviteSubaccountMemberInput = v.InferInput<typeof InviteSubaccountMemberInputSchema>;\n\nexport const RemoveSubaccountMemberInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n granteeAccountId: idInputSchema(\"granteeAccountId\"),\n});\n\nexport type RemoveSubaccountMemberInput = v.InferInput<typeof RemoveSubaccountMemberInputSchema>;\n\nexport const UpdateSubaccountMemberRoleInputSchema = InviteSubaccountMemberInputSchema;\n\nexport type UpdateSubaccountMemberRoleInput = v.InferInput<\n typeof UpdateSubaccountMemberRoleInputSchema\n>;\n\nexport const SetSubaccountMemberMfaRequirementInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n requireMemberMfa: v.boolean(),\n});\n\nexport type SetSubaccountMemberMfaRequirementInput = v.InferInput<\n typeof SetSubaccountMemberMfaRequirementInputSchema\n>;\n\nexport const ListSubaccountInvitesInputSchema = v.strictObject({\n direction: v.pipe(\n v.optional(v.picklist(SUBACCOUNT_INVITE_DIRECTION_VALUES), \"\"),\n v.transform((direction) => SubaccountInviteDirectionCodec.inputToProto[direction]),\n ),\n});\n\nexport type ListSubaccountInvitesInput = v.InferInput<typeof ListSubaccountInvitesInputSchema>;\n\nconst InviteActionSchema = v.picklist([\"accept\", \"decline\", \"cancel\"]);\n\nconst InviteStatusSchema = v.picklist([\"pending\", \"accepted\", \"declined\", \"canceled\"]);\n\nexport type SubaccountInviteStatus = v.InferOutput<typeof InviteStatusSchema>;\n\nconst ProtoInviteStatusSchema = v.number();\n\nexport const RespondSubaccountInviteInputSchema = v.strictObject({\n inviteId: idInputSchema(\"inviteId\"),\n action: v.pipe(\n InviteActionSchema,\n v.transform((v) => InviteActionCodec.inputToProto[v]),\n ),\n});\n\nexport type RespondSubaccountInviteInput = v.InferInput<typeof RespondSubaccountInviteInputSchema>;\n\nconst ProtoSubaccountStatusSchema = enumLabelSchema(SubaccountStatusCodec.protoToOutput);\n\nexport type SubaccountStatus = v.InferOutput<typeof ProtoSubaccountStatusSchema>;\n\nexport const SubaccountSchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n label: v.optional(v.string(), \"\"),\n icon: v.optional(v.string(), \"\"),\n color: v.optional(v.string(), \"\"),\n status: ProtoSubaccountStatusSchema,\n smartAccountAddress: v.string(),\n smartAccountSaltNonce: v.optional(v.number()),\n ownerUsername: v.optional(v.string(), \"\"),\n ownerAvatarUrl: v.optional(v.string(), \"\"),\n ownerRootSmartAccountAddress: v.string(),\n subaccountPolicyId: PublicIdOrEmptySchema,\n requireMemberMfa: v.optional(v.boolean(), false),\n updatedAt: v.optional(TimestampSchema),\n revision: BigIntStringSchema,\n }),\n v.transform(({ updatedAt, ...subaccount }) => ({\n ...subaccount,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n })),\n);\n\nexport type Subaccount = v.InferOutput<typeof SubaccountSchema>;\n\nexport const SubaccountMemberSchema = v.object({\n accountId: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n username: v.optional(v.string(), \"\"),\n smartAccountAddress: v.string(),\n avatarUrl: v.optional(v.string(), \"\"),\n mfaEnrolled: v.optional(v.boolean(), false),\n});\n\nexport type SubaccountMember = v.InferOutput<typeof SubaccountMemberSchema>;\n\nexport const SubaccountInviteSchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n subaccountId: PublicIdSchema,\n granteeAccountId: PublicIdSchema,\n inviterAccountId: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n status: v.pipe(\n ProtoInviteStatusSchema,\n v.transform((v) => enumLabel(InviteStatusCodec.protoToOutput, v)),\n ),\n createdAt: OptionalTimestampMsSchema,\n respondedAt: OptionalTimestampMsSchema,\n granteeUsername: v.optional(v.string(), \"\"),\n inviterUsername: v.optional(v.string(), \"\"),\n subaccountLabel: v.optional(v.string(), \"\"),\n inviterRootSmartAccountAddress: v.string(),\n granteeRootSmartAccountAddress: v.string(),\n requireMemberMfa: v.boolean(),\n }),\n v.transform(\n ({\n subaccountLabel,\n subaccountId,\n inviterRootSmartAccountAddress,\n granteeRootSmartAccountAddress,\n ...rest\n }) => ({\n ...rest,\n subaccountId,\n subaccountLabel,\n inviterSmartAccountAddress: inviterRootSmartAccountAddress,\n granteeSmartAccountAddress: granteeRootSmartAccountAddress,\n }),\n ),\n);\n\nexport type SubaccountInvite = v.InferOutput<typeof SubaccountInviteSchema>;\n\nexport const SubaccountActivityInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(200)), 50),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n});\n\nexport type SubaccountActivityInput = v.InferInput<typeof SubaccountActivityInputSchema>;\n\nexport const SubaccountActivityEventSchema = v.object({\n createdAt: OptionalTimestampMsSchema,\n entityKind: enumLabelSchema(ActivityEntityKindCodec.protoToOutput),\n eventAction: enumLabelSchema(ActivityEventActionCodec.protoToOutput),\n source: enumLabelSchema(ActivityEventSourceCodec.protoToOutput),\n ip: v.optional(v.string()),\n userAgent: v.optional(v.string()),\n actorAccountId: PublicIdSchema,\n payloadJson: v.pipe(\n v.string(),\n v.transform((v) => JSON.parse(v)),\n ),\n});\n\nexport type SubaccountEvent = v.InferOutput<typeof SubaccountActivityEventSchema>;\n"],"mappings":";;;;;;;;AA2CA,MAAa,uBAAuB,EAAE,SAAS;CAR3C;CACA;CACA;CACA;CACA;CACA;AAG2C,CAAsB;AAIrE,MAAM,4BAA4B,gBAAgB,oBAAoB,aAAa;AAEnF,MAAM,kCAAkC,gBAAgB,0BAA0B,aAAa;AAI/F,MAAa,uCAAuC,EAAE,OAAO;CACzD,YAAY;CACZ,aAAa,EAAE,SAAS,EAAE,OAAO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AE,SAAS,GAAG,CAAC,GAAG,EAAE;CACrF,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;AAC1D,CAAC;AAID,MAAa,gCAAgC,EAAE,OAAO;CAClD,WAAW;CACX,YAAY,gBAAgB,wBAAwB,aAAa;CACjE,aAAa,gBAAgB,yBAAyB,aAAa;CACnE,QAAQ,gBAAgB,yBAAyB,aAAa;CAC9D,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC;CACzB,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC;CAChC,gBAAgB;CAChB,aAAa,EAAE,KACX,EAAE,OAAO,GACT,EAAE,WAAW,MAAM,KAAK,MAAM,CAAC,CAAC,CACpC;AACJ,CAAC"}
1
+ {"version":3,"file":"subaccounts.schemas.js","names":[],"sources":["../../../src/services/subaccounts/subaccounts.schemas.ts"],"sourcesContent":["import {\n WalletAddressSchema,\n WalletChallengeMessageSchema,\n WalletChallengeUriSchema,\n WalletSignatureSchema,\n} from \"../auth/wallet-challenge.schemas.js\";\nimport * as v from \"valibot\";\nimport {\n BigIntStringSchema,\n OptionalTimestampMsSchema,\n PublicIdOrEmptySchema,\n PublicIdSchema,\n TimestampSchema,\n idInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../utils/time.js\";\nimport { enumLabel, enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport {\n SubaccountRoleCodec,\n SubaccountPermissionCodec,\n InviteActionCodec,\n InviteStatusCodec,\n SubaccountInviteDirectionCodec,\n SUBACCOUNT_INVITE_DIRECTION_VALUES,\n SubaccountStatusCodec,\n SUBACCOUNT_STATUS_VALUES,\n ActivityEntityKindCodec,\n ActivityEventActionCodec,\n ActivityEventSourceCodec,\n} from \"./subaccounts.codecs.js\";\nimport { PolicyActionCodec } from \"../policies/shared.codecs.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../utils/proto-patch.js\";\n\nconst SUBACCOUNT_ROLE_VALUES = [\n \"owner\",\n \"admin\",\n \"treasury\",\n \"leveraged_trader\",\n \"trader\",\n \"viewer\",\n] as const;\n\nexport const SubaccountRoleSchema = v.picklist(SUBACCOUNT_ROLE_VALUES);\n\nexport type SubaccountRole = v.InferOutput<typeof SubaccountRoleSchema>;\n\nconst ProtoSubaccountRoleSchema = enumLabelSchema(SubaccountRoleCodec.protoToOutput);\n\nconst ProtoSubaccountPermissionSchema = enumLabelSchema(SubaccountPermissionCodec.protoToOutput);\n\nexport type SubaccountPermission = v.InferOutput<typeof ProtoSubaccountPermissionSchema>;\n\nexport const SubaccountPermissionDefinitionSchema = v.object({\n permission: ProtoSubaccountPermissionSchema,\n displayName: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n policyAction: enumLabelSchema(PolicyActionCodec.protoToOutput),\n});\n\nexport type SubaccountPermissionDefinition = v.InferOutput<\n typeof SubaccountPermissionDefinitionSchema\n>;\n\nexport const SubaccountRoleDefinitionSchema = v.object({\n role: ProtoSubaccountRoleSchema,\n displayName: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n assignable: v.optional(v.boolean(), false),\n permissions: v.optional(v.array(ProtoSubaccountPermissionSchema), []),\n});\n\nexport type SubaccountRoleDefinition = v.InferOutput<typeof SubaccountRoleDefinitionSchema>;\n\nexport const SubaccountRoleCatalogSchema = v.object({\n permissions: v.optional(v.array(SubaccountPermissionDefinitionSchema), []),\n roles: v.optional(v.array(SubaccountRoleDefinitionSchema), []),\n});\n\nexport type SubaccountRoleCatalog = v.InferOutput<typeof SubaccountRoleCatalogSchema>;\n\nexport const EffectiveSubaccountPermissionsSchema = v.object({\n role: ProtoSubaccountRoleSchema,\n permissions: v.optional(v.array(ProtoSubaccountPermissionSchema), []),\n subaccountPolicyId: PublicIdOrEmptySchema,\n});\n\nexport type EffectiveSubaccountPermissions = v.InferOutput<\n typeof EffectiveSubaccountPermissionsSchema\n>;\n\nexport const CreateSubaccountChallengeInputSchema = v.strictObject({\n ownerAddress: WalletAddressSchema,\n uri: WalletChallengeUriSchema,\n});\n\nexport type CreateSubaccountChallengeInput = v.InferInput<\n typeof CreateSubaccountChallengeInputSchema\n>;\n\nexport const SubaccountChallengeSchema = v.object({\n message: WalletChallengeMessageSchema,\n smartAccountAddress: WalletAddressSchema,\n smartAccountSaltNonce: v.number(),\n expiresAt: OptionalTimestampMsSchema,\n polyesterChainId: v.pipe(v.bigint(), v.transform(Number)),\n});\n\nexport type SubaccountChallenge = v.InferOutput<typeof SubaccountChallengeSchema>;\n\nexport const CreateSubaccountInputSchema = v.strictObject({\n label: v.optional(v.string(), \"\"),\n icon: v.optional(v.string(), \"\"),\n color: v.optional(v.string(), \"\"),\n smartAccountAddress: WalletAddressSchema,\n message: WalletChallengeMessageSchema,\n signature: WalletSignatureSchema,\n});\n\nexport type CreateSubaccountInput = v.InferInput<typeof CreateSubaccountInputSchema>;\n\nexport const SubaccountIdInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n});\n\nexport type SubaccountIdInput = v.InferInput<typeof SubaccountIdInputSchema>;\n\nexport const GetSubaccountInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n includeBalances: v.optional(v.boolean()),\n});\n\nexport type GetSubaccountInput = v.InferInput<typeof GetSubaccountInputSchema>;\n\nexport const CreateSubaccountResultSchema = v.object({\n subaccountId: PublicIdSchema,\n totalCreated: v.number(),\n smartAccountSaltNonce: v.number(),\n revision: BigIntStringSchema,\n});\n\nexport type CreateSubaccountResult = v.InferOutput<typeof CreateSubaccountResultSchema>;\n\nexport const SubaccountMutationResultSchema = v.object({});\n\nexport type SubaccountMutationResult = v.InferOutput<typeof SubaccountMutationResultSchema>;\n\ntype SubaccountPatch = {\n label?: string;\n icon?: string;\n color?: string;\n status?: (typeof SUBACCOUNT_STATUS_VALUES)[number];\n};\n\nconst SUBACCOUNT_PATCH_FIELDS = defineProtoPatchFields<SubaccountPatch>()({\n label: { path: \"label\", encode: (label) => ({ label }) },\n icon: { path: \"icon\", encode: (icon) => ({ icon }) },\n color: { path: \"color\", encode: (color) => ({ color }) },\n status: {\n path: \"status\",\n encode: (status) => ({ status: SubaccountStatusCodec.inputToProto[status] }),\n },\n});\n\nexport const UpdateSubaccountInputSchema = v.pipe(\n v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n label: v.optional(v.string()),\n icon: v.optional(v.string()),\n color: v.optional(v.string()),\n status: v.optional(v.picklist(SUBACCOUNT_STATUS_VALUES)),\n }),\n v.check(\n ({ label, icon, color, status }) =>\n label !== undefined ||\n icon !== undefined ||\n color !== undefined ||\n status !== undefined,\n \"At least one subaccount field must be provided\",\n ),\n v.transform(({ subaccountId, expectedRevision, ...input }) => {\n const { patch: subaccount, updateMask } = buildProtoPatch(input, SUBACCOUNT_PATCH_FIELDS);\n return {\n subaccountId,\n subaccount,\n updateMask,\n expectedRevision,\n };\n }),\n);\n\nexport type UpdateSubaccountInput = v.InferInput<typeof UpdateSubaccountInputSchema>;\n\nexport const InviteSubaccountMemberInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n granteeAccountId: idInputSchema(\"granteeAccountId\"),\n role: v.pipe(\n SubaccountRoleSchema,\n v.transform((role) => SubaccountRoleCodec.inputToProto[role]),\n ),\n});\n\nexport type InviteSubaccountMemberInput = v.InferInput<typeof InviteSubaccountMemberInputSchema>;\n\nexport const RemoveSubaccountMemberInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n granteeAccountId: idInputSchema(\"granteeAccountId\"),\n});\n\nexport type RemoveSubaccountMemberInput = v.InferInput<typeof RemoveSubaccountMemberInputSchema>;\n\nexport const UpdateSubaccountMemberRoleInputSchema = InviteSubaccountMemberInputSchema;\n\nexport type UpdateSubaccountMemberRoleInput = v.InferInput<\n typeof UpdateSubaccountMemberRoleInputSchema\n>;\n\nexport const SetSubaccountMemberMfaRequirementInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n requireMemberMfa: v.boolean(),\n});\n\nexport type SetSubaccountMemberMfaRequirementInput = v.InferInput<\n typeof SetSubaccountMemberMfaRequirementInputSchema\n>;\n\nexport const ListSubaccountInvitesInputSchema = v.strictObject({\n direction: v.pipe(\n v.optional(v.picklist(SUBACCOUNT_INVITE_DIRECTION_VALUES), \"\"),\n v.transform((direction) => SubaccountInviteDirectionCodec.inputToProto[direction]),\n ),\n});\n\nexport type ListSubaccountInvitesInput = v.InferInput<typeof ListSubaccountInvitesInputSchema>;\n\nconst InviteActionSchema = v.picklist([\"accept\", \"decline\", \"cancel\"]);\n\nconst InviteStatusSchema = v.picklist([\"pending\", \"accepted\", \"declined\", \"canceled\"]);\n\nexport type SubaccountInviteStatus = v.InferOutput<typeof InviteStatusSchema>;\n\nconst ProtoInviteStatusSchema = v.number();\n\nexport const RespondSubaccountInviteInputSchema = v.strictObject({\n inviteId: idInputSchema(\"inviteId\"),\n action: v.pipe(\n InviteActionSchema,\n v.transform((v) => InviteActionCodec.inputToProto[v]),\n ),\n});\n\nexport type RespondSubaccountInviteInput = v.InferInput<typeof RespondSubaccountInviteInputSchema>;\n\nconst ProtoSubaccountStatusSchema = enumLabelSchema(SubaccountStatusCodec.protoToOutput);\n\nexport type SubaccountStatus = v.InferOutput<typeof ProtoSubaccountStatusSchema>;\n\nexport const SubaccountSchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n label: v.optional(v.string(), \"\"),\n icon: v.optional(v.string(), \"\"),\n color: v.optional(v.string(), \"\"),\n status: ProtoSubaccountStatusSchema,\n smartAccountAddress: v.string(),\n smartAccountSaltNonce: v.optional(v.number()),\n ownerUsername: v.optional(v.string(), \"\"),\n ownerAvatarUrl: v.optional(v.string(), \"\"),\n ownerRootSmartAccountAddress: v.string(),\n subaccountPolicyId: PublicIdOrEmptySchema,\n requireMemberMfa: v.optional(v.boolean(), false),\n updatedAt: v.optional(TimestampSchema),\n revision: BigIntStringSchema,\n /**\n * Only realtime updates set this: the caller lost access, so drop the subaccount from\n * local state. `role` is `\"unspecified\"` when it is true. Access and role changes leave\n * `revision` and `updatedAt` unchanged, so apply them in arrival order rather than\n * gating them on those fields.\n */\n removed: v.optional(v.boolean(), false),\n }),\n v.transform(({ updatedAt, ...subaccount }) => ({\n ...subaccount,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n })),\n);\n\nexport type Subaccount = v.InferOutput<typeof SubaccountSchema>;\n\nexport const SubaccountMemberSchema = v.object({\n accountId: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n username: v.optional(v.string(), \"\"),\n smartAccountAddress: v.string(),\n avatarUrl: v.optional(v.string(), \"\"),\n mfaEnrolled: v.optional(v.boolean(), false),\n});\n\nexport type SubaccountMember = v.InferOutput<typeof SubaccountMemberSchema>;\n\nexport const SubaccountInviteSchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n subaccountId: PublicIdSchema,\n granteeAccountId: PublicIdSchema,\n inviterAccountId: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n status: v.pipe(\n ProtoInviteStatusSchema,\n v.transform((v) => enumLabel(InviteStatusCodec.protoToOutput, v)),\n ),\n createdAt: OptionalTimestampMsSchema,\n respondedAt: OptionalTimestampMsSchema,\n granteeUsername: v.optional(v.string(), \"\"),\n inviterUsername: v.optional(v.string(), \"\"),\n subaccountLabel: v.optional(v.string(), \"\"),\n inviterRootSmartAccountAddress: v.string(),\n granteeRootSmartAccountAddress: v.string(),\n requireMemberMfa: v.boolean(),\n }),\n v.transform(\n ({\n subaccountLabel,\n subaccountId,\n inviterRootSmartAccountAddress,\n granteeRootSmartAccountAddress,\n ...rest\n }) => ({\n ...rest,\n subaccountId,\n subaccountLabel,\n inviterSmartAccountAddress: inviterRootSmartAccountAddress,\n granteeSmartAccountAddress: granteeRootSmartAccountAddress,\n }),\n ),\n);\n\nexport type SubaccountInvite = v.InferOutput<typeof SubaccountInviteSchema>;\n\nexport const SubaccountActivityInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(200)), 50),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n});\n\nexport type SubaccountActivityInput = v.InferInput<typeof SubaccountActivityInputSchema>;\n\nexport const SubaccountActivityEventSchema = v.object({\n createdAt: OptionalTimestampMsSchema,\n entityKind: enumLabelSchema(ActivityEntityKindCodec.protoToOutput),\n eventAction: enumLabelSchema(ActivityEventActionCodec.protoToOutput),\n source: enumLabelSchema(ActivityEventSourceCodec.protoToOutput),\n ip: v.optional(v.string()),\n userAgent: v.optional(v.string()),\n actorAccountId: PublicIdSchema,\n payloadJson: v.pipe(\n v.string(),\n v.transform((v) => JSON.parse(v)),\n ),\n});\n\nexport type SubaccountEvent = v.InferOutput<typeof SubaccountActivityEventSchema>;\n"],"mappings":";;;;;;;;AA2CA,MAAa,uBAAuB,EAAE,SAAS;CAR3C;CACA;CACA;CACA;CACA;CACA;AAG2C,CAAsB;AAIrE,MAAM,4BAA4B,gBAAgB,oBAAoB,aAAa;AAEnF,MAAM,kCAAkC,gBAAgB,0BAA0B,aAAa;AAI/F,MAAa,uCAAuC,EAAE,OAAO;CACzD,YAAY;CACZ,aAAa,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACtC,aAAa,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACtC,cAAc,gBAAgB,kBAAkB,aAAa;AACjE,CAAC;AAMD,MAAa,iCAAiC,EAAE,OAAO;CACnD,MAAM;CACN,aAAa,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACtC,aAAa,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACtC,YAAY,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;CACzC,aAAa,EAAE,SAAS,EAAE,MAAM,+BA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;CAC9D,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC;CACzB,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC;CAChC,gBAAgB;CAChB,aAAa,EAAE,KACX,EAAE,OAAO,GACT,EAAE,WAAW,MAAM,KAAK,MAAM,CAAC,CAAC,CACpC;AACJ,CAAC"}
@@ -63,7 +63,7 @@ declare function createUserTradeSchema(scales: SdkScales): v.SchemaWithPipe<read
63
63
  referralShare?: string | undefined;
64
64
  orderId: string;
65
65
  symbolId: number;
66
- sideLabel: "unspecified" | "buy" | "sell";
66
+ sideLabel: "buy" | "sell" | "unspecified";
67
67
  liquidityLabel: "maker" | "taker";
68
68
  feeAsset: "unspecified" | "quote" | "base";
69
69
  qty: string;
@@ -169,7 +169,7 @@ declare const GetUserTradesInputSchema: v.SchemaWithPipe<readonly [v.UnionSchema
169
169
  readonly orderId: v.OptionalSchema<v.NeverSchema<undefined>, undefined>;
170
170
  readonly lineageId: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>, v.CheckAction<bigint, `${string} must be greater than zero`>]>;
171
171
  readonly throughGeneration: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>;
172
- }, undefined>], undefined>], ({ input }: v.UnionIssue<v.StringIssue | v.NumberIssue | v.BooleanIssue | v.IntegerIssue<number> | v.MinValueIssue<number, 1> | v.MaxValueIssue<number, 4294967295> | v.StrictObjectIssue | v.PicklistIssue | v.MinLengthIssue<string, 1> | v.UnionIssue<v.StringIssue | v.StrictObjectIssue | v.PicklistIssue | v.MinLengthIssue<string, 1>> | v.GtValueIssue<number, 0> | v.CheckIssue<bigint> | v.NeverIssue | v.MaxValueIssue<number, 1000> | v.UnionIssue<v.StringIssue | v.NumberIssue | v.BooleanIssue | v.IntegerIssue<number> | v.MinValueIssue<number, 1> | v.MaxValueIssue<number, 4294967295> | v.StrictObjectIssue | v.PicklistIssue | v.MinLengthIssue<string, 1> | v.UnionIssue<v.StringIssue | v.StrictObjectIssue | v.PicklistIssue | v.MinLengthIssue<string, 1>> | v.GtValueIssue<number, 0> | v.CheckIssue<bigint> | v.NeverIssue | v.MaxValueIssue<number, 1000>>>) => "Provide at most one of orderId or lineageId" | "throughGeneration requires lineageId" | "symbolId is required when afterMatchId is set" | "Invalid trade filters">, v.TransformAction<{
172
+ }, undefined>], undefined>], ({ input }: v.UnionIssue<v.NumberIssue | v.BooleanIssue | v.IntegerIssue<number> | v.MinValueIssue<number, 1> | v.MaxValueIssue<number, 4294967295> | v.StringIssue | v.StrictObjectIssue | v.PicklistIssue | v.MinLengthIssue<string, 1> | v.UnionIssue<v.StringIssue | v.StrictObjectIssue | v.PicklistIssue | v.MinLengthIssue<string, 1>> | v.GtValueIssue<number, 0> | v.CheckIssue<bigint> | v.NeverIssue | v.MaxValueIssue<number, 1000> | v.UnionIssue<v.NumberIssue | v.BooleanIssue | v.IntegerIssue<number> | v.MinValueIssue<number, 1> | v.MaxValueIssue<number, 4294967295> | v.StringIssue | v.StrictObjectIssue | v.PicklistIssue | v.MinLengthIssue<string, 1> | v.UnionIssue<v.StringIssue | v.StrictObjectIssue | v.PicklistIssue | v.MinLengthIssue<string, 1>> | v.GtValueIssue<number, 0> | v.CheckIssue<bigint> | v.NeverIssue | v.MaxValueIssue<number, 1000>>>) => "Provide at most one of orderId or lineageId" | "throughGeneration requires lineageId" | "symbolId is required when afterMatchId is set" | "Invalid trade filters">, v.TransformAction<{
173
173
  symbolId?: number | undefined;
174
174
  afterMatchId?: undefined;
175
175
  side?: Side.BUY | Side.SELL | undefined;
@@ -608,7 +608,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
608
608
  }, {
609
609
  runtimeDetails: TriggerDetailsOutput;
610
610
  version: number;
611
- cancelReason: "unspecified" | "internal_error" | "oco" | "user_request" | "account_repair" | "market_halted" | "parent_canceled_no_fill" | "self_trade_prevention" | "pair_drain_trigger" | "pair_drain_twap" | "pair_drain_ladder" | "pair_drain_attached_leg" | "missing_reason_code";
611
+ cancelReason: "unspecified" | "oco" | "user_request" | "account_repair" | "market_halted" | "internal_error" | "parent_canceled_no_fill" | "self_trade_prevention" | "pair_drain_trigger" | "pair_drain_twap" | "pair_drain_ladder" | "pair_drain_attached_leg" | "missing_reason_code";
612
612
  failureReason: undefined;
613
613
  triggerId: string;
614
614
  subaccountId: string;
@@ -620,7 +620,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
620
620
  selfTradePreventionMode: "unspecified" | "expire_taker" | "expire_maker" | "expire_both";
621
621
  configuration: {
622
622
  type: "stop_loss" | "take_profit";
623
- side: "unspecified" | "buy" | "sell";
623
+ side: "buy" | "sell" | "unspecified";
624
624
  triggerPrice: string;
625
625
  execution: {
626
626
  readonly type: "market_ioc";
@@ -672,7 +672,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
672
672
  readonly postOnly?: undefined;
673
673
  } | {
674
674
  type: "trailing_stop";
675
- side: "unspecified" | "buy" | "sell";
675
+ side: "buy" | "sell" | "unspecified";
676
676
  trailingDistance: {
677
677
  kind: "distance";
678
678
  distance: string;
@@ -711,7 +711,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
711
711
  readonly postOnly?: undefined;
712
712
  } | {
713
713
  type: "twap";
714
- side: "unspecified" | "buy" | "sell";
714
+ side: "buy" | "sell" | "unspecified";
715
715
  durationMs: number;
716
716
  sliceIntervalMs: number;
717
717
  execution: {
@@ -750,7 +750,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
750
750
  readonly postOnly?: undefined;
751
751
  } | {
752
752
  type: "ladder";
753
- side: "unspecified" | "buy" | "sell";
753
+ side: "buy" | "sell" | "unspecified";
754
754
  priceMin: string;
755
755
  priceMax: string;
756
756
  levels: number;
@@ -788,7 +788,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
788
788
  runtimeDetails: TriggerDetailsOutput;
789
789
  version: number;
790
790
  cancelReason: undefined;
791
- failureReason: "unspecified" | "internal_error" | "market_halted" | "missing_reason_code" | "unknown_symbol" | "pair_disabled" | "min_notional" | "tick_size" | "insufficient_funds" | "risk_limit" | "duplicate_client_id" | "engine_busy" | "account_unknown" | "order_unknown" | "post_only_cross" | "reduce_only_blocked" | "price_band_violation" | "market_cap_violation" | "empty_book" | "fok_insufficient_liquidity" | "fee_asset_not_allowed" | "market_price_unavailable" | "stale_quote" | "min_quantity" | "step_size" | "invalid_sizing" | "max_quote_debit_too_small" | "fee_ceiling_exceeded" | "trigger_price_invalid" | "trigger_price_source_unsupported" | "trailing_distance_invalid" | "modification_requires_replace" | "order_already_terminal" | "conflict_idempotency_key_reuse" | "rate_limited" | "policy_spot_trade_deny" | "policy_market_deny" | "policy_max_notional" | "policy_max_open_orders" | "policy_trading_halted" | "max_slippage_invalid" | "invalid_time_in_force" | "duplicate_order_id" | "max_quantity" | "max_notional" | "pair_post_only" | "max_open_orders_total" | "stp_mode_not_allowed" | "pair_backlogged" | "mode_not_supported" | "market_quote_stale" | "market_quote_unhealthy" | "qty_invalid" | "limit_price_invalid" | "twap_interval_invalid" | "ladder_range_too_narrow" | "ladder_levels_invalid" | "attached_legs_exceeded" | "price_levels_exhausted" | "settlement_backlogged" | "client_order_ids_exhausted" | "invalid_order_id" | "order_id_conflict" | "invalid_side" | "invalid_order_type" | "invalid_stp_mode" | "invalid_order_flags" | "price_level_quantity_limit" | "child_qty_raise_not_allowed" | "triggers_exhausted" | "order_sequence_exhausted" | "fee_schedule_unavailable" | "policy_unavailable" | "account_routing_invalid" | "client_trigger_id_invalid" | "trigger_direction_invalid" | "fee_asset_invalid" | "fee_ceiling_invalid" | "unsupported_field_set" | "trigger_fire_limit_reached" | "condition_flags_invalid" | "condition_parameter_set" | "slippage_ticks_invalid" | "slippage_bps_invalid" | "slippage_bounds_conflict" | "limit_child_slippage_set" | "new_account_capacity_reached" | "order_type_not_allowed_in_auction" | "post_only_not_allowed_in_auction" | "twap_capacity_reached" | "order_limits_unavailable" | "child_order_inconsistent" | "index_price_unavailable" | "trigger_would_trigger_immediately" | "max_open_orders_per_pair" | "account_repairing" | "self_trade_prevented";
791
+ failureReason: "unspecified" | "market_halted" | "internal_error" | "missing_reason_code" | "unknown_symbol" | "pair_disabled" | "min_notional" | "tick_size" | "insufficient_funds" | "risk_limit" | "duplicate_client_id" | "engine_busy" | "account_unknown" | "order_unknown" | "post_only_cross" | "reduce_only_blocked" | "price_band_violation" | "market_cap_violation" | "empty_book" | "fok_insufficient_liquidity" | "fee_asset_not_allowed" | "market_price_unavailable" | "stale_quote" | "min_quantity" | "step_size" | "invalid_sizing" | "max_quote_debit_too_small" | "fee_ceiling_exceeded" | "trigger_price_invalid" | "trigger_price_source_unsupported" | "trailing_distance_invalid" | "modification_requires_replace" | "order_already_terminal" | "conflict_idempotency_key_reuse" | "rate_limited" | "policy_spot_trade_deny" | "policy_market_deny" | "policy_max_notional" | "policy_max_open_orders" | "policy_trading_halted" | "max_slippage_invalid" | "invalid_time_in_force" | "duplicate_order_id" | "max_quantity" | "max_notional" | "pair_post_only" | "max_open_orders_total" | "stp_mode_not_allowed" | "pair_backlogged" | "mode_not_supported" | "market_quote_stale" | "market_quote_unhealthy" | "qty_invalid" | "limit_price_invalid" | "twap_interval_invalid" | "ladder_range_too_narrow" | "ladder_levels_invalid" | "attached_legs_exceeded" | "price_levels_exhausted" | "settlement_backlogged" | "client_order_ids_exhausted" | "invalid_order_id" | "order_id_conflict" | "invalid_side" | "invalid_order_type" | "invalid_stp_mode" | "invalid_order_flags" | "price_level_quantity_limit" | "child_qty_raise_not_allowed" | "triggers_exhausted" | "order_sequence_exhausted" | "fee_schedule_unavailable" | "policy_unavailable" | "account_routing_invalid" | "client_trigger_id_invalid" | "trigger_direction_invalid" | "fee_asset_invalid" | "fee_ceiling_invalid" | "unsupported_field_set" | "trigger_fire_limit_reached" | "condition_flags_invalid" | "condition_parameter_set" | "slippage_ticks_invalid" | "slippage_bps_invalid" | "slippage_bounds_conflict" | "limit_child_slippage_set" | "new_account_capacity_reached" | "order_type_not_allowed_in_auction" | "post_only_not_allowed_in_auction" | "twap_capacity_reached" | "order_limits_unavailable" | "child_order_inconsistent" | "index_price_unavailable" | "trigger_would_trigger_immediately" | "max_open_orders_per_pair" | "account_repairing" | "self_trade_prevented";
792
792
  triggerId: string;
793
793
  subaccountId: string;
794
794
  symbolId: number;
@@ -799,7 +799,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
799
799
  selfTradePreventionMode: "unspecified" | "expire_taker" | "expire_maker" | "expire_both";
800
800
  configuration: {
801
801
  type: "stop_loss" | "take_profit";
802
- side: "unspecified" | "buy" | "sell";
802
+ side: "buy" | "sell" | "unspecified";
803
803
  triggerPrice: string;
804
804
  execution: {
805
805
  readonly type: "market_ioc";
@@ -851,7 +851,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
851
851
  readonly postOnly?: undefined;
852
852
  } | {
853
853
  type: "trailing_stop";
854
- side: "unspecified" | "buy" | "sell";
854
+ side: "buy" | "sell" | "unspecified";
855
855
  trailingDistance: {
856
856
  kind: "distance";
857
857
  distance: string;
@@ -890,7 +890,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
890
890
  readonly postOnly?: undefined;
891
891
  } | {
892
892
  type: "twap";
893
- side: "unspecified" | "buy" | "sell";
893
+ side: "buy" | "sell" | "unspecified";
894
894
  durationMs: number;
895
895
  sliceIntervalMs: number;
896
896
  execution: {
@@ -929,7 +929,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
929
929
  readonly postOnly?: undefined;
930
930
  } | {
931
931
  type: "ladder";
932
- side: "unspecified" | "buy" | "sell";
932
+ side: "buy" | "sell" | "unspecified";
933
933
  priceMin: string;
934
934
  priceMax: string;
935
935
  levels: number;
@@ -978,7 +978,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
978
978
  selfTradePreventionMode: "unspecified" | "expire_taker" | "expire_maker" | "expire_both";
979
979
  configuration: {
980
980
  type: "stop_loss" | "take_profit";
981
- side: "unspecified" | "buy" | "sell";
981
+ side: "buy" | "sell" | "unspecified";
982
982
  triggerPrice: string;
983
983
  execution: {
984
984
  readonly type: "market_ioc";
@@ -1030,7 +1030,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
1030
1030
  readonly postOnly?: undefined;
1031
1031
  } | {
1032
1032
  type: "trailing_stop";
1033
- side: "unspecified" | "buy" | "sell";
1033
+ side: "buy" | "sell" | "unspecified";
1034
1034
  trailingDistance: {
1035
1035
  kind: "distance";
1036
1036
  distance: string;
@@ -1069,7 +1069,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
1069
1069
  readonly postOnly?: undefined;
1070
1070
  } | {
1071
1071
  type: "twap";
1072
- side: "unspecified" | "buy" | "sell";
1072
+ side: "buy" | "sell" | "unspecified";
1073
1073
  durationMs: number;
1074
1074
  sliceIntervalMs: number;
1075
1075
  execution: {
@@ -1108,7 +1108,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
1108
1108
  readonly postOnly?: undefined;
1109
1109
  } | {
1110
1110
  type: "ladder";
1111
- side: "unspecified" | "buy" | "sell";
1111
+ side: "buy" | "sell" | "unspecified";
1112
1112
  priceMin: string;
1113
1113
  priceMax: string;
1114
1114
  levels: number;
@@ -1189,8 +1189,8 @@ declare function createTriggerEventSchema(scales: SdkScales): v.SchemaWithPipe<r
1189
1189
  fireRefusalReason?: number | undefined;
1190
1190
  }, {
1191
1191
  /** Why a `fire_refused` attempt was refused; the trigger stayed live. */
1192
- fireRefusalReason: "unspecified" | "internal_error" | "market_halted" | "missing_reason_code" | "unknown_symbol" | "pair_disabled" | "min_notional" | "tick_size" | "insufficient_funds" | "risk_limit" | "duplicate_client_id" | "engine_busy" | "account_unknown" | "order_unknown" | "post_only_cross" | "reduce_only_blocked" | "price_band_violation" | "market_cap_violation" | "empty_book" | "fok_insufficient_liquidity" | "fee_asset_not_allowed" | "market_price_unavailable" | "stale_quote" | "min_quantity" | "step_size" | "invalid_sizing" | "max_quote_debit_too_small" | "fee_ceiling_exceeded" | "trigger_price_invalid" | "trigger_price_source_unsupported" | "trailing_distance_invalid" | "modification_requires_replace" | "order_already_terminal" | "conflict_idempotency_key_reuse" | "rate_limited" | "policy_spot_trade_deny" | "policy_market_deny" | "policy_max_notional" | "policy_max_open_orders" | "policy_trading_halted" | "max_slippage_invalid" | "invalid_time_in_force" | "duplicate_order_id" | "max_quantity" | "max_notional" | "pair_post_only" | "max_open_orders_total" | "stp_mode_not_allowed" | "pair_backlogged" | "mode_not_supported" | "market_quote_stale" | "market_quote_unhealthy" | "qty_invalid" | "limit_price_invalid" | "twap_interval_invalid" | "ladder_range_too_narrow" | "ladder_levels_invalid" | "attached_legs_exceeded" | "price_levels_exhausted" | "settlement_backlogged" | "client_order_ids_exhausted" | "invalid_order_id" | "order_id_conflict" | "invalid_side" | "invalid_order_type" | "invalid_stp_mode" | "invalid_order_flags" | "price_level_quantity_limit" | "child_qty_raise_not_allowed" | "triggers_exhausted" | "order_sequence_exhausted" | "fee_schedule_unavailable" | "policy_unavailable" | "account_routing_invalid" | "client_trigger_id_invalid" | "trigger_direction_invalid" | "fee_asset_invalid" | "fee_ceiling_invalid" | "unsupported_field_set" | "trigger_fire_limit_reached" | "condition_flags_invalid" | "condition_parameter_set" | "slippage_ticks_invalid" | "slippage_bps_invalid" | "slippage_bounds_conflict" | "limit_child_slippage_set" | "new_account_capacity_reached" | "order_type_not_allowed_in_auction" | "post_only_not_allowed_in_auction" | "twap_capacity_reached" | "order_limits_unavailable" | "child_order_inconsistent" | "index_price_unavailable" | "trigger_would_trigger_immediately" | "max_open_orders_per_pair" | "account_repairing" | "self_trade_prevented" | undefined;
1193
- cancelReason: "unspecified" | "internal_error" | "oco" | "user_request" | "account_repair" | "market_halted" | "parent_canceled_no_fill" | "self_trade_prevention" | "pair_drain_trigger" | "pair_drain_twap" | "pair_drain_ladder" | "pair_drain_attached_leg" | "missing_reason_code";
1192
+ fireRefusalReason: "unspecified" | "market_halted" | "internal_error" | "missing_reason_code" | "unknown_symbol" | "pair_disabled" | "min_notional" | "tick_size" | "insufficient_funds" | "risk_limit" | "duplicate_client_id" | "engine_busy" | "account_unknown" | "order_unknown" | "post_only_cross" | "reduce_only_blocked" | "price_band_violation" | "market_cap_violation" | "empty_book" | "fok_insufficient_liquidity" | "fee_asset_not_allowed" | "market_price_unavailable" | "stale_quote" | "min_quantity" | "step_size" | "invalid_sizing" | "max_quote_debit_too_small" | "fee_ceiling_exceeded" | "trigger_price_invalid" | "trigger_price_source_unsupported" | "trailing_distance_invalid" | "modification_requires_replace" | "order_already_terminal" | "conflict_idempotency_key_reuse" | "rate_limited" | "policy_spot_trade_deny" | "policy_market_deny" | "policy_max_notional" | "policy_max_open_orders" | "policy_trading_halted" | "max_slippage_invalid" | "invalid_time_in_force" | "duplicate_order_id" | "max_quantity" | "max_notional" | "pair_post_only" | "max_open_orders_total" | "stp_mode_not_allowed" | "pair_backlogged" | "mode_not_supported" | "market_quote_stale" | "market_quote_unhealthy" | "qty_invalid" | "limit_price_invalid" | "twap_interval_invalid" | "ladder_range_too_narrow" | "ladder_levels_invalid" | "attached_legs_exceeded" | "price_levels_exhausted" | "settlement_backlogged" | "client_order_ids_exhausted" | "invalid_order_id" | "order_id_conflict" | "invalid_side" | "invalid_order_type" | "invalid_stp_mode" | "invalid_order_flags" | "price_level_quantity_limit" | "child_qty_raise_not_allowed" | "triggers_exhausted" | "order_sequence_exhausted" | "fee_schedule_unavailable" | "policy_unavailable" | "account_routing_invalid" | "client_trigger_id_invalid" | "trigger_direction_invalid" | "fee_asset_invalid" | "fee_ceiling_invalid" | "unsupported_field_set" | "trigger_fire_limit_reached" | "condition_flags_invalid" | "condition_parameter_set" | "slippage_ticks_invalid" | "slippage_bps_invalid" | "slippage_bounds_conflict" | "limit_child_slippage_set" | "new_account_capacity_reached" | "order_type_not_allowed_in_auction" | "post_only_not_allowed_in_auction" | "twap_capacity_reached" | "order_limits_unavailable" | "child_order_inconsistent" | "index_price_unavailable" | "trigger_would_trigger_immediately" | "max_open_orders_per_pair" | "account_repairing" | "self_trade_prevented" | undefined;
1193
+ cancelReason: "unspecified" | "oco" | "user_request" | "account_repair" | "market_halted" | "internal_error" | "parent_canceled_no_fill" | "self_trade_prevention" | "pair_drain_trigger" | "pair_drain_twap" | "pair_drain_ladder" | "pair_drain_attached_leg" | "missing_reason_code";
1194
1194
  failureReason: undefined;
1195
1195
  triggerId: string;
1196
1196
  subaccountId: string;
@@ -1204,9 +1204,9 @@ declare function createTriggerEventSchema(scales: SdkScales): v.SchemaWithPipe<r
1204
1204
  firePrice: string | undefined;
1205
1205
  } | {
1206
1206
  /** Why a `fire_refused` attempt was refused; the trigger stayed live. */
1207
- fireRefusalReason: "unspecified" | "internal_error" | "market_halted" | "missing_reason_code" | "unknown_symbol" | "pair_disabled" | "min_notional" | "tick_size" | "insufficient_funds" | "risk_limit" | "duplicate_client_id" | "engine_busy" | "account_unknown" | "order_unknown" | "post_only_cross" | "reduce_only_blocked" | "price_band_violation" | "market_cap_violation" | "empty_book" | "fok_insufficient_liquidity" | "fee_asset_not_allowed" | "market_price_unavailable" | "stale_quote" | "min_quantity" | "step_size" | "invalid_sizing" | "max_quote_debit_too_small" | "fee_ceiling_exceeded" | "trigger_price_invalid" | "trigger_price_source_unsupported" | "trailing_distance_invalid" | "modification_requires_replace" | "order_already_terminal" | "conflict_idempotency_key_reuse" | "rate_limited" | "policy_spot_trade_deny" | "policy_market_deny" | "policy_max_notional" | "policy_max_open_orders" | "policy_trading_halted" | "max_slippage_invalid" | "invalid_time_in_force" | "duplicate_order_id" | "max_quantity" | "max_notional" | "pair_post_only" | "max_open_orders_total" | "stp_mode_not_allowed" | "pair_backlogged" | "mode_not_supported" | "market_quote_stale" | "market_quote_unhealthy" | "qty_invalid" | "limit_price_invalid" | "twap_interval_invalid" | "ladder_range_too_narrow" | "ladder_levels_invalid" | "attached_legs_exceeded" | "price_levels_exhausted" | "settlement_backlogged" | "client_order_ids_exhausted" | "invalid_order_id" | "order_id_conflict" | "invalid_side" | "invalid_order_type" | "invalid_stp_mode" | "invalid_order_flags" | "price_level_quantity_limit" | "child_qty_raise_not_allowed" | "triggers_exhausted" | "order_sequence_exhausted" | "fee_schedule_unavailable" | "policy_unavailable" | "account_routing_invalid" | "client_trigger_id_invalid" | "trigger_direction_invalid" | "fee_asset_invalid" | "fee_ceiling_invalid" | "unsupported_field_set" | "trigger_fire_limit_reached" | "condition_flags_invalid" | "condition_parameter_set" | "slippage_ticks_invalid" | "slippage_bps_invalid" | "slippage_bounds_conflict" | "limit_child_slippage_set" | "new_account_capacity_reached" | "order_type_not_allowed_in_auction" | "post_only_not_allowed_in_auction" | "twap_capacity_reached" | "order_limits_unavailable" | "child_order_inconsistent" | "index_price_unavailable" | "trigger_would_trigger_immediately" | "max_open_orders_per_pair" | "account_repairing" | "self_trade_prevented" | undefined;
1207
+ fireRefusalReason: "unspecified" | "market_halted" | "internal_error" | "missing_reason_code" | "unknown_symbol" | "pair_disabled" | "min_notional" | "tick_size" | "insufficient_funds" | "risk_limit" | "duplicate_client_id" | "engine_busy" | "account_unknown" | "order_unknown" | "post_only_cross" | "reduce_only_blocked" | "price_band_violation" | "market_cap_violation" | "empty_book" | "fok_insufficient_liquidity" | "fee_asset_not_allowed" | "market_price_unavailable" | "stale_quote" | "min_quantity" | "step_size" | "invalid_sizing" | "max_quote_debit_too_small" | "fee_ceiling_exceeded" | "trigger_price_invalid" | "trigger_price_source_unsupported" | "trailing_distance_invalid" | "modification_requires_replace" | "order_already_terminal" | "conflict_idempotency_key_reuse" | "rate_limited" | "policy_spot_trade_deny" | "policy_market_deny" | "policy_max_notional" | "policy_max_open_orders" | "policy_trading_halted" | "max_slippage_invalid" | "invalid_time_in_force" | "duplicate_order_id" | "max_quantity" | "max_notional" | "pair_post_only" | "max_open_orders_total" | "stp_mode_not_allowed" | "pair_backlogged" | "mode_not_supported" | "market_quote_stale" | "market_quote_unhealthy" | "qty_invalid" | "limit_price_invalid" | "twap_interval_invalid" | "ladder_range_too_narrow" | "ladder_levels_invalid" | "attached_legs_exceeded" | "price_levels_exhausted" | "settlement_backlogged" | "client_order_ids_exhausted" | "invalid_order_id" | "order_id_conflict" | "invalid_side" | "invalid_order_type" | "invalid_stp_mode" | "invalid_order_flags" | "price_level_quantity_limit" | "child_qty_raise_not_allowed" | "triggers_exhausted" | "order_sequence_exhausted" | "fee_schedule_unavailable" | "policy_unavailable" | "account_routing_invalid" | "client_trigger_id_invalid" | "trigger_direction_invalid" | "fee_asset_invalid" | "fee_ceiling_invalid" | "unsupported_field_set" | "trigger_fire_limit_reached" | "condition_flags_invalid" | "condition_parameter_set" | "slippage_ticks_invalid" | "slippage_bps_invalid" | "slippage_bounds_conflict" | "limit_child_slippage_set" | "new_account_capacity_reached" | "order_type_not_allowed_in_auction" | "post_only_not_allowed_in_auction" | "twap_capacity_reached" | "order_limits_unavailable" | "child_order_inconsistent" | "index_price_unavailable" | "trigger_would_trigger_immediately" | "max_open_orders_per_pair" | "account_repairing" | "self_trade_prevented" | undefined;
1208
1208
  cancelReason: undefined;
1209
- failureReason: "unspecified" | "internal_error" | "market_halted" | "missing_reason_code" | "unknown_symbol" | "pair_disabled" | "min_notional" | "tick_size" | "insufficient_funds" | "risk_limit" | "duplicate_client_id" | "engine_busy" | "account_unknown" | "order_unknown" | "post_only_cross" | "reduce_only_blocked" | "price_band_violation" | "market_cap_violation" | "empty_book" | "fok_insufficient_liquidity" | "fee_asset_not_allowed" | "market_price_unavailable" | "stale_quote" | "min_quantity" | "step_size" | "invalid_sizing" | "max_quote_debit_too_small" | "fee_ceiling_exceeded" | "trigger_price_invalid" | "trigger_price_source_unsupported" | "trailing_distance_invalid" | "modification_requires_replace" | "order_already_terminal" | "conflict_idempotency_key_reuse" | "rate_limited" | "policy_spot_trade_deny" | "policy_market_deny" | "policy_max_notional" | "policy_max_open_orders" | "policy_trading_halted" | "max_slippage_invalid" | "invalid_time_in_force" | "duplicate_order_id" | "max_quantity" | "max_notional" | "pair_post_only" | "max_open_orders_total" | "stp_mode_not_allowed" | "pair_backlogged" | "mode_not_supported" | "market_quote_stale" | "market_quote_unhealthy" | "qty_invalid" | "limit_price_invalid" | "twap_interval_invalid" | "ladder_range_too_narrow" | "ladder_levels_invalid" | "attached_legs_exceeded" | "price_levels_exhausted" | "settlement_backlogged" | "client_order_ids_exhausted" | "invalid_order_id" | "order_id_conflict" | "invalid_side" | "invalid_order_type" | "invalid_stp_mode" | "invalid_order_flags" | "price_level_quantity_limit" | "child_qty_raise_not_allowed" | "triggers_exhausted" | "order_sequence_exhausted" | "fee_schedule_unavailable" | "policy_unavailable" | "account_routing_invalid" | "client_trigger_id_invalid" | "trigger_direction_invalid" | "fee_asset_invalid" | "fee_ceiling_invalid" | "unsupported_field_set" | "trigger_fire_limit_reached" | "condition_flags_invalid" | "condition_parameter_set" | "slippage_ticks_invalid" | "slippage_bps_invalid" | "slippage_bounds_conflict" | "limit_child_slippage_set" | "new_account_capacity_reached" | "order_type_not_allowed_in_auction" | "post_only_not_allowed_in_auction" | "twap_capacity_reached" | "order_limits_unavailable" | "child_order_inconsistent" | "index_price_unavailable" | "trigger_would_trigger_immediately" | "max_open_orders_per_pair" | "account_repairing" | "self_trade_prevented";
1209
+ failureReason: "unspecified" | "market_halted" | "internal_error" | "missing_reason_code" | "unknown_symbol" | "pair_disabled" | "min_notional" | "tick_size" | "insufficient_funds" | "risk_limit" | "duplicate_client_id" | "engine_busy" | "account_unknown" | "order_unknown" | "post_only_cross" | "reduce_only_blocked" | "price_band_violation" | "market_cap_violation" | "empty_book" | "fok_insufficient_liquidity" | "fee_asset_not_allowed" | "market_price_unavailable" | "stale_quote" | "min_quantity" | "step_size" | "invalid_sizing" | "max_quote_debit_too_small" | "fee_ceiling_exceeded" | "trigger_price_invalid" | "trigger_price_source_unsupported" | "trailing_distance_invalid" | "modification_requires_replace" | "order_already_terminal" | "conflict_idempotency_key_reuse" | "rate_limited" | "policy_spot_trade_deny" | "policy_market_deny" | "policy_max_notional" | "policy_max_open_orders" | "policy_trading_halted" | "max_slippage_invalid" | "invalid_time_in_force" | "duplicate_order_id" | "max_quantity" | "max_notional" | "pair_post_only" | "max_open_orders_total" | "stp_mode_not_allowed" | "pair_backlogged" | "mode_not_supported" | "market_quote_stale" | "market_quote_unhealthy" | "qty_invalid" | "limit_price_invalid" | "twap_interval_invalid" | "ladder_range_too_narrow" | "ladder_levels_invalid" | "attached_legs_exceeded" | "price_levels_exhausted" | "settlement_backlogged" | "client_order_ids_exhausted" | "invalid_order_id" | "order_id_conflict" | "invalid_side" | "invalid_order_type" | "invalid_stp_mode" | "invalid_order_flags" | "price_level_quantity_limit" | "child_qty_raise_not_allowed" | "triggers_exhausted" | "order_sequence_exhausted" | "fee_schedule_unavailable" | "policy_unavailable" | "account_routing_invalid" | "client_trigger_id_invalid" | "trigger_direction_invalid" | "fee_asset_invalid" | "fee_ceiling_invalid" | "unsupported_field_set" | "trigger_fire_limit_reached" | "condition_flags_invalid" | "condition_parameter_set" | "slippage_ticks_invalid" | "slippage_bps_invalid" | "slippage_bounds_conflict" | "limit_child_slippage_set" | "new_account_capacity_reached" | "order_type_not_allowed_in_auction" | "post_only_not_allowed_in_auction" | "twap_capacity_reached" | "order_limits_unavailable" | "child_order_inconsistent" | "index_price_unavailable" | "trigger_would_trigger_immediately" | "max_open_orders_per_pair" | "account_repairing" | "self_trade_prevented";
1210
1210
  triggerId: string;
1211
1211
  subaccountId: string;
1212
1212
  symbolId: number;
@@ -1219,7 +1219,7 @@ declare function createTriggerEventSchema(scales: SdkScales): v.SchemaWithPipe<r
1219
1219
  firePrice: string | undefined;
1220
1220
  } | {
1221
1221
  /** Why a `fire_refused` attempt was refused; the trigger stayed live. */
1222
- fireRefusalReason: "unspecified" | "internal_error" | "market_halted" | "missing_reason_code" | "unknown_symbol" | "pair_disabled" | "min_notional" | "tick_size" | "insufficient_funds" | "risk_limit" | "duplicate_client_id" | "engine_busy" | "account_unknown" | "order_unknown" | "post_only_cross" | "reduce_only_blocked" | "price_band_violation" | "market_cap_violation" | "empty_book" | "fok_insufficient_liquidity" | "fee_asset_not_allowed" | "market_price_unavailable" | "stale_quote" | "min_quantity" | "step_size" | "invalid_sizing" | "max_quote_debit_too_small" | "fee_ceiling_exceeded" | "trigger_price_invalid" | "trigger_price_source_unsupported" | "trailing_distance_invalid" | "modification_requires_replace" | "order_already_terminal" | "conflict_idempotency_key_reuse" | "rate_limited" | "policy_spot_trade_deny" | "policy_market_deny" | "policy_max_notional" | "policy_max_open_orders" | "policy_trading_halted" | "max_slippage_invalid" | "invalid_time_in_force" | "duplicate_order_id" | "max_quantity" | "max_notional" | "pair_post_only" | "max_open_orders_total" | "stp_mode_not_allowed" | "pair_backlogged" | "mode_not_supported" | "market_quote_stale" | "market_quote_unhealthy" | "qty_invalid" | "limit_price_invalid" | "twap_interval_invalid" | "ladder_range_too_narrow" | "ladder_levels_invalid" | "attached_legs_exceeded" | "price_levels_exhausted" | "settlement_backlogged" | "client_order_ids_exhausted" | "invalid_order_id" | "order_id_conflict" | "invalid_side" | "invalid_order_type" | "invalid_stp_mode" | "invalid_order_flags" | "price_level_quantity_limit" | "child_qty_raise_not_allowed" | "triggers_exhausted" | "order_sequence_exhausted" | "fee_schedule_unavailable" | "policy_unavailable" | "account_routing_invalid" | "client_trigger_id_invalid" | "trigger_direction_invalid" | "fee_asset_invalid" | "fee_ceiling_invalid" | "unsupported_field_set" | "trigger_fire_limit_reached" | "condition_flags_invalid" | "condition_parameter_set" | "slippage_ticks_invalid" | "slippage_bps_invalid" | "slippage_bounds_conflict" | "limit_child_slippage_set" | "new_account_capacity_reached" | "order_type_not_allowed_in_auction" | "post_only_not_allowed_in_auction" | "twap_capacity_reached" | "order_limits_unavailable" | "child_order_inconsistent" | "index_price_unavailable" | "trigger_would_trigger_immediately" | "max_open_orders_per_pair" | "account_repairing" | "self_trade_prevented" | undefined;
1222
+ fireRefusalReason: "unspecified" | "market_halted" | "internal_error" | "missing_reason_code" | "unknown_symbol" | "pair_disabled" | "min_notional" | "tick_size" | "insufficient_funds" | "risk_limit" | "duplicate_client_id" | "engine_busy" | "account_unknown" | "order_unknown" | "post_only_cross" | "reduce_only_blocked" | "price_band_violation" | "market_cap_violation" | "empty_book" | "fok_insufficient_liquidity" | "fee_asset_not_allowed" | "market_price_unavailable" | "stale_quote" | "min_quantity" | "step_size" | "invalid_sizing" | "max_quote_debit_too_small" | "fee_ceiling_exceeded" | "trigger_price_invalid" | "trigger_price_source_unsupported" | "trailing_distance_invalid" | "modification_requires_replace" | "order_already_terminal" | "conflict_idempotency_key_reuse" | "rate_limited" | "policy_spot_trade_deny" | "policy_market_deny" | "policy_max_notional" | "policy_max_open_orders" | "policy_trading_halted" | "max_slippage_invalid" | "invalid_time_in_force" | "duplicate_order_id" | "max_quantity" | "max_notional" | "pair_post_only" | "max_open_orders_total" | "stp_mode_not_allowed" | "pair_backlogged" | "mode_not_supported" | "market_quote_stale" | "market_quote_unhealthy" | "qty_invalid" | "limit_price_invalid" | "twap_interval_invalid" | "ladder_range_too_narrow" | "ladder_levels_invalid" | "attached_legs_exceeded" | "price_levels_exhausted" | "settlement_backlogged" | "client_order_ids_exhausted" | "invalid_order_id" | "order_id_conflict" | "invalid_side" | "invalid_order_type" | "invalid_stp_mode" | "invalid_order_flags" | "price_level_quantity_limit" | "child_qty_raise_not_allowed" | "triggers_exhausted" | "order_sequence_exhausted" | "fee_schedule_unavailable" | "policy_unavailable" | "account_routing_invalid" | "client_trigger_id_invalid" | "trigger_direction_invalid" | "fee_asset_invalid" | "fee_ceiling_invalid" | "unsupported_field_set" | "trigger_fire_limit_reached" | "condition_flags_invalid" | "condition_parameter_set" | "slippage_ticks_invalid" | "slippage_bps_invalid" | "slippage_bounds_conflict" | "limit_child_slippage_set" | "new_account_capacity_reached" | "order_type_not_allowed_in_auction" | "post_only_not_allowed_in_auction" | "twap_capacity_reached" | "order_limits_unavailable" | "child_order_inconsistent" | "index_price_unavailable" | "trigger_would_trigger_immediately" | "max_open_orders_per_pair" | "account_repairing" | "self_trade_prevented" | undefined;
1223
1223
  cancelReason: undefined;
1224
1224
  failureReason: undefined;
1225
1225
  triggerId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"connect-error-mapping.d.ts","names":[],"sources":["../../src/shared/connect-error-mapping.ts"],"mappings":";;;;;;;iBA4LgB,6BAA6B,IAAI,eAAe;;;;;;;;;iBAiNhD,iBAAiB;;;;;;iBAyDjB,iCAAiC"}
1
+ {"version":3,"file":"connect-error-mapping.d.ts","names":[],"sources":["../../src/shared/connect-error-mapping.ts"],"mappings":";;;;;;;iBAgMgB,6BAA6B,IAAI,eAAe;;;;;;;;;iBAiNhD,iBAAiB;;;;;;iBAyDjB,iCAAiC"}
@@ -53,7 +53,10 @@ function mfaErrorKind(detail) {
53
53
  return null;
54
54
  }
55
55
  function parseRetryAfterMs(ce) {
56
- const value = ce.metadata.get("retry-after");
56
+ return parseRetryAfterHeader(ce.metadata.get("retry-after"));
57
+ }
58
+ /** Parses an HTTP `Retry-After` value (delay seconds or HTTP date) into milliseconds. */
59
+ function parseRetryAfterHeader(value) {
57
60
  if (!value) return void 0;
58
61
  if (/^\d+$/u.test(value)) {
59
62
  const seconds = BigInt(value);
@@ -262,6 +265,6 @@ function createErrorMappingTransport(transport) {
262
265
  };
263
266
  }
264
267
  //#endregion
265
- export { TIMESTAMP_SKEW_CODE, connectErrorToPolyesterError, createErrorMappingInterceptor, createErrorMappingTransport, getNormalizedConnectMessage, toPolyesterError };
268
+ export { TIMESTAMP_SKEW_CODE, connectErrorToPolyesterError, createErrorMappingInterceptor, createErrorMappingTransport, getNormalizedConnectMessage, parseRetryAfterHeader, toPolyesterError };
266
269
 
267
270
  //# sourceMappingURL=connect-error-mapping.js.map