@polyester/sdk 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/gen/auth/v1/auth_pb.d.ts +5 -3
- package/dist/gen/auth/v1/auth_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/auth_pb.js +1 -1
- package/dist/gen/auth/v1/auth_pb.js.map +1 -1
- package/dist/gen/auth/v1/profile_pb.d.ts +90 -2
- package/dist/gen/auth/v1/profile_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/profile_pb.js +20 -2
- package/dist/gen/auth/v1/profile_pb.js.map +1 -1
- package/dist/gen/auth/v1/resolve_pb.d.ts +35 -6
- package/dist/gen/auth/v1/resolve_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/resolve_pb.js +34 -2
- package/dist/gen/auth/v1/resolve_pb.js.map +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.d.ts +72 -16
- package/dist/gen/auth/v1/subaccounts_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.js +73 -9
- package/dist/gen/auth/v1/subaccounts_pb.js.map +1 -1
- package/dist/gen/orders/v1/orders_pb.d.ts +139 -15
- package/dist/gen/orders/v1/orders_pb.d.ts.map +1 -1
- package/dist/gen/orders/v1/orders_pb.js +139 -3
- package/dist/gen/orders/v1/orders_pb.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/services/accounts/accounts.codecs.js +6 -1
- package/dist/services/accounts/accounts.codecs.js.map +1 -1
- package/dist/services/accounts/accounts.schemas.d.ts +2 -2
- package/dist/services/accounts/accounts.schemas.d.ts.map +1 -1
- package/dist/services/accounts/accounts.schemas.js +4 -3
- package/dist/services/accounts/accounts.schemas.js.map +1 -1
- package/dist/services/auth/auth.d.ts +1 -1
- package/dist/services/auth/auth.d.ts.map +1 -1
- package/dist/services/auth/auth.js +2 -2
- package/dist/services/auth/auth.js.map +1 -1
- package/dist/services/auth/profile/profile.d.ts +9 -1
- package/dist/services/auth/profile/profile.d.ts.map +1 -1
- package/dist/services/auth/profile/profile.js +16 -1
- package/dist/services/auth/profile/profile.js.map +1 -1
- package/dist/services/auth/profile/profile.schemas.d.ts +18 -1
- package/dist/services/auth/profile/profile.schemas.d.ts.map +1 -1
- package/dist/services/auth/profile/profile.schemas.js +12 -2
- package/dist/services/auth/profile/profile.schemas.js.map +1 -1
- package/dist/services/auth/profile/profile.types.d.ts +2 -2
- package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +42 -42
- package/dist/services/orderbook/orderbook.schemas.d.ts +1 -1
- package/dist/services/orders/orders-batch.schemas.d.ts +9 -9
- package/dist/services/orders/orders-batch.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-batch.schemas.js +4 -4
- package/dist/services/orders/orders-batch.schemas.js.map +1 -1
- package/dist/services/orders/orders-input.schemas.d.ts +8 -8
- package/dist/services/orders/orders-input.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-input.schemas.js +5 -4
- package/dist/services/orders/orders-input.schemas.js.map +1 -1
- package/dist/services/orders/orders-output.schemas.d.ts +6 -6
- package/dist/services/orders/orders.codecs.js +20 -1
- package/dist/services/orders/orders.codecs.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.codecs.js +16 -9
- package/dist/services/subaccounts/subaccounts.codecs.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.js +1 -1
- package/dist/services/subaccounts/subaccounts.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +12 -12
- package/dist/services/subaccounts/subaccounts.schemas.d.ts.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.js +4 -8
- package/dist/services/subaccounts/subaccounts.schemas.js.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
- package/dist/services/triggers/triggers-output.schemas.d.ts +18 -18
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccounts.codecs.js","names":[],"sources":["../../../src/services/subaccounts/subaccounts.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport type { InputToProto, ProtoToOutput } from \"../../utils/types.js\";\n\nexport const SUBACCOUNT_ROLE_VALUES = [\n \"owner\",\n \"admin\",\n \"treasury\",\n \"leveraged_trader\",\n \"trader\",\n \"viewer\",\n] as const;\nexport type SubaccountRoleValue = (typeof SUBACCOUNT_ROLE_VALUES)[number];\n\nexport const SUBACCOUNT_PERMISSION_VALUES = [\n \"read_subaccount\",\n \"update_subaccount\",\n \"read_balances\",\n \"read_spot\",\n \"trade_spot\",\n \"read_internal_transfers\",\n \"internal_transfer\",\n \"external_withdraw\",\n \"read_address_book\",\n \"manage_address_book\",\n \"read_members\",\n \"manage_members\",\n \"read_invites\",\n \"manage_invites\",\n \"read_api_keys\",\n \"manage_api_keys\",\n \"read_subaccount_policy\",\n \"manage_subaccount_policy\",\n \"read_activity\",\n \"read_activity_security_details\",\n \"manage_member_mfa_requirement\",\n \"create_deposit_address\",\n \"read_deposit_addresses\",\n \"read_guard_signer_status\",\n \"manage_guard_signer\",\n] as const;\nexport type SubaccountPermissionValue = (typeof SUBACCOUNT_PERMISSION_VALUES)[number];\n\nexport const SUBACCOUNT_INVITE_ACTION_VALUES = [\"accept\", \"decline\", \"cancel\"] as const;\nexport type SubaccountInviteActionValue = (typeof SUBACCOUNT_INVITE_ACTION_VALUES)[number];\n\nexport const SUBACCOUNT_INVITE_STATUS_VALUES = [\n \"pending\",\n \"accepted\",\n \"declined\",\n \"cancelled\",\n] as const;\nexport type SubaccountInviteStatusValue = (typeof SUBACCOUNT_INVITE_STATUS_VALUES)[number];\n\nexport const SUBACCOUNT_STATUS_VALUES = [\"active\", \"disabled\"] as const;\nexport type SubaccountStatusValue = (typeof SUBACCOUNT_STATUS_VALUES)[number];\n\nexport const ACTIVITY_ENTITY_KIND_VALUES = [\n \"account\",\n \"session\",\n \"api_key\",\n \"subaccount\",\n \"member\",\n \"policy\",\n \"invite\",\n \"security\",\n \"destination\",\n] as const;\nexport type ActivityEntityKindValue = (typeof ACTIVITY_ENTITY_KIND_VALUES)[number];\n\nexport const ACTIVITY_EVENT_ACTION_VALUES = [\n \"created\",\n \"updated\",\n \"deleted\",\n \"enabled\",\n \"disabled\",\n \"removed\",\n \"role_set\",\n \"received\",\n \"replied\",\n \"failed\",\n \"revoked\",\n \"blocked\",\n \"hold_placed\",\n \"hold_released\",\n] as const;\nexport type ActivityEventActionValue = (typeof ACTIVITY_EVENT_ACTION_VALUES)[number];\n\nexport const ACTIVITY_EVENT_SOURCE_VALUES = [\"web\", \"mobile\", \"api\"] as const;\nexport type ActivityEventSourceValue = (typeof ACTIVITY_EVENT_SOURCE_VALUES)[number];\ntype SubaccountStatusProto = Proto.SubaccountUpdateSpec[\"status\"] & Proto.Subaccount[\"status\"];\n\nconst SubaccountStatusProto = {\n ACTIVE: \"active\",\n DISABLED: \"disabled\",\n} as const satisfies Record<string, SubaccountStatusProto>;\n\nexport const SubaccountRoleCodec = {\n inputToProto: {\n owner: Proto.SubaccountRole.OWNER,\n admin: Proto.SubaccountRole.ADMIN,\n treasury: Proto.SubaccountRole.TREASURY,\n leveraged_trader: Proto.SubaccountRole.LEVERAGED_TRADER,\n trader: Proto.SubaccountRole.TRADER,\n viewer: Proto.SubaccountRole.VIEWER,\n } satisfies InputToProto<SubaccountRoleValue, Proto.SubaccountRole>,\n protoToOutput: {\n [Proto.SubaccountRole.SUBACCOUNT_ROLE_UNSPECIFIED]: \"unspecified\",\n [Proto.SubaccountRole.OWNER]: \"owner\",\n [Proto.SubaccountRole.ADMIN]: \"admin\",\n [Proto.SubaccountRole.TREASURY]: \"treasury\",\n [Proto.SubaccountRole.LEVERAGED_TRADER]: \"leveraged_trader\",\n [Proto.SubaccountRole.TRADER]: \"trader\",\n [Proto.SubaccountRole.VIEWER]: \"viewer\",\n } satisfies ProtoToOutput<Proto.SubaccountRole, SubaccountRoleValue>,\n} as const;\n\nexport const SubaccountPermissionCodec = {\n protoToOutput: {\n [Proto.SubaccountPermission.UNSPECIFIED]: \"unspecified\",\n [Proto.SubaccountPermission.READ_SUBACCOUNT]: \"read_subaccount\",\n [Proto.SubaccountPermission.UPDATE_SUBACCOUNT]: \"update_subaccount\",\n [Proto.SubaccountPermission.READ_BALANCES]: \"read_balances\",\n [Proto.SubaccountPermission.READ_SPOT]: \"read_spot\",\n [Proto.SubaccountPermission.TRADE_SPOT]: \"trade_spot\",\n [Proto.SubaccountPermission.READ_INTERNAL_TRANSFERS]: \"read_internal_transfers\",\n [Proto.SubaccountPermission.INTERNAL_TRANSFER]: \"internal_transfer\",\n [Proto.SubaccountPermission.EXTERNAL_WITHDRAW]: \"external_withdraw\",\n [Proto.SubaccountPermission.READ_ADDRESS_BOOK]: \"read_address_book\",\n [Proto.SubaccountPermission.MANAGE_ADDRESS_BOOK]: \"manage_address_book\",\n [Proto.SubaccountPermission.READ_MEMBERS]: \"read_members\",\n [Proto.SubaccountPermission.MANAGE_MEMBERS]: \"manage_members\",\n [Proto.SubaccountPermission.READ_INVITES]: \"read_invites\",\n [Proto.SubaccountPermission.MANAGE_INVITES]: \"manage_invites\",\n [Proto.SubaccountPermission.READ_API_KEYS]: \"read_api_keys\",\n [Proto.SubaccountPermission.MANAGE_API_KEYS]: \"manage_api_keys\",\n [Proto.SubaccountPermission.READ_SUBACCOUNT_POLICY]: \"read_subaccount_policy\",\n [Proto.SubaccountPermission.MANAGE_SUBACCOUNT_POLICY]: \"manage_subaccount_policy\",\n [Proto.SubaccountPermission.READ_ACTIVITY]: \"read_activity\",\n [Proto.SubaccountPermission.READ_ACTIVITY_SECURITY_DETAILS]:\n \"read_activity_security_details\",\n [Proto.SubaccountPermission.MANAGE_MEMBER_MFA_REQUIREMENT]: \"manage_member_mfa_requirement\",\n [Proto.SubaccountPermission.CREATE_DEPOSIT_ADDRESS]: \"create_deposit_address\",\n [Proto.SubaccountPermission.READ_DEPOSIT_ADDRESSES]: \"read_deposit_addresses\",\n [Proto.SubaccountPermission.READ_GUARD_SIGNER_STATUS]: \"read_guard_signer_status\",\n [Proto.SubaccountPermission.MANAGE_GUARD_SIGNER]: \"manage_guard_signer\",\n } satisfies ProtoToOutput<Proto.SubaccountPermission, SubaccountPermissionValue>,\n} as const;\n\nexport const InviteActionCodec = {\n inputToProto: {\n accept: Proto.SubaccountInviteAction.ACCEPT,\n decline: Proto.SubaccountInviteAction.DECLINE,\n cancel: Proto.SubaccountInviteAction.CANCEL,\n } satisfies InputToProto<SubaccountInviteActionValue, Proto.SubaccountInviteAction>,\n} as const;\n\nexport const InviteStatusCodec = {\n protoToOutput: {\n [Proto.SubaccountInviteStatus.UNSPECIFIED]: \"unspecified\",\n [Proto.SubaccountInviteStatus.PENDING]: \"pending\",\n [Proto.SubaccountInviteStatus.ACCEPTED]: \"accepted\",\n [Proto.SubaccountInviteStatus.DECLINED]: \"declined\",\n [Proto.SubaccountInviteStatus.CANCELLED]: \"cancelled\",\n } satisfies ProtoToOutput<Proto.SubaccountInviteStatus, SubaccountInviteStatusValue>,\n} as const;\n\nexport const SubaccountStatusCodec = {\n inputToProto: {\n active: SubaccountStatusProto.ACTIVE,\n disabled: SubaccountStatusProto.DISABLED,\n } satisfies Record<SubaccountStatusValue, SubaccountStatusProto>,\n protoToOutput: {\n [SubaccountStatusProto.ACTIVE]: \"active\",\n [SubaccountStatusProto.DISABLED]: \"disabled\",\n } satisfies Record<SubaccountStatusProto, SubaccountStatusValue>,\n} as const;\n\nexport const ActivityEntityKindCodec = {\n protoToOutput: {\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_UNSPECIFIED]: \"unspecified\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_ACCOUNT]: \"account\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_SESSION]: \"session\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_API_KEY]: \"api_key\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_SUBACCOUNT]: \"subaccount\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_MEMBER]: \"member\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_POLICY]: \"policy\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_INVITE]: \"invite\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_SECURITY]: \"security\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_DESTINATION]: \"destination\",\n } satisfies ProtoToOutput<Proto.ActivityEntityKind, ActivityEntityKindValue>,\n} as const;\n\nexport const ActivityEventActionCodec = {\n protoToOutput: {\n [Proto.ActivityEventAction.ACTIVITY_ACTION_UNSPECIFIED]: \"unspecified\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_CREATED]: \"created\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_UPDATED]: \"updated\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_DELETED]: \"deleted\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_ENABLED]: \"enabled\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_DISABLED]: \"disabled\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_REMOVED]: \"removed\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_ROLE_SET]: \"role_set\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_RECEIVED]: \"received\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_REPLIED]: \"replied\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_FAILED]: \"failed\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_REVOKED]: \"revoked\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_BLOCKED]: \"blocked\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_HOLD_PLACED]: \"hold_placed\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_HOLD_RELEASED]: \"hold_released\",\n } satisfies ProtoToOutput<Proto.ActivityEventAction, ActivityEventActionValue>,\n} as const;\n\nexport const ActivityEventSourceCodec = {\n protoToOutput: {\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_UNSPECIFIED]: \"unspecified\",\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_WEB]: \"web\",\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_MOBILE]: \"mobile\",\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_API]: \"api\",\n } satisfies ProtoToOutput<Proto.ActivityEventSource, ActivityEventSourceValue>,\n} as const;\n"],"mappings":";;AAqDA,MAAa,2BAA2B,CAAC,UAAU,UAAU;AAsC7D,MAAM,wBAAwB;CAC1B,QAAQ;CACR,UAAU;AACd;AAEA,MAAa,sBAAsB;CAC/B,cAAc;EACV,OAAA;EACA,OAAA;EACA,UAAA;EACA,kBAAA;EACA,QAAA;EACA,QAAA;CACJ;CACA,eAAe;GACyC,IAAA;GACtB,IAAA;GACA,IAAA;GACG,IAAA;GACQ,IAAA;GACV,IAAA;GACA,IAAA;CACnC;AACJ;AAEA,MAAa,4BAA4B,EACrC,eAAe;EAC+B,IAAA;EACI,IAAA;EACE,IAAA;EACJ,IAAA;EACJ,IAAA;EACC,IAAA;EACa,IAAA;EACN,IAAA;EACA,IAAA;EACA,IAAA;EACE,KAAA;EACP,KAAA;EACE,KAAA;EACF,KAAA;EACE,KAAA;EACD,KAAA;EACE,KAAA;EACO,KAAA;EACE,KAAA;EACX,KAAA;EAExC,KAAA;EACwD,KAAA;EACP,KAAA;EACA,KAAA;EACE,KAAA;EACL,KAAA;AACtD,EACJ;AAEA,MAAa,oBAAoB,EAC7B,cAAc;CACV,QAAA;CACA,SAAA;CACA,QAAA;AACJ,EACJ;AAEA,MAAa,oBAAoB,EAC7B,eAAe;EACiC,IAAA;EACJ,IAAA;EACC,IAAA;EACA,IAAA;EACC,IAAA;AAC9C,EACJ;AAEA,MAAa,wBAAwB;CACjC,cAAc;EACV,QAAQ,sBAAsB;EAC9B,UAAU,sBAAsB;CACpC;CACA,eAAe;GACV,sBAAsB,SAAS;GAC/B,sBAAsB,WAAW;CACtC;AACJ;AAEA,MAAa,0BAA0B,EACnC,eAAe;EAC6C,IAAA;EACJ,IAAA;EACA,IAAA;EACA,IAAA;EACG,IAAA;EACJ,IAAA;EACA,IAAA;EACA,IAAA;EACE,IAAA;EACG,IAAA;AAC5D,EACJ;AAEA,MAAa,2BAA2B,EACpC,eAAe;EAC8C,IAAA;EACJ,IAAA;EACA,IAAA;EACA,IAAA;EACA,IAAA;EACC,IAAA;EACD,IAAA;EACC,IAAA;EACA,IAAA;EACD,IAAA;EACD,KAAA;EACC,KAAA;EACA,KAAA;EACI,KAAA;EACE,KAAA;AAC/D,EACJ;AAEA,MAAa,2BAA2B,EACpC,eAAe;EAC8C,IAAA;EACR,IAAA;EACG,IAAA;EACH,IAAA;AACrD,EACJ"}
|
|
1
|
+
{"version":3,"file":"subaccounts.codecs.js","names":[],"sources":["../../../src/services/subaccounts/subaccounts.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport type { InputToProto, ProtoToOutput } from \"../../utils/types.js\";\n\nexport const SUBACCOUNT_ROLE_VALUES = [\n \"owner\",\n \"admin\",\n \"treasury\",\n \"leveraged_trader\",\n \"trader\",\n \"viewer\",\n] as const;\nexport type SubaccountRoleValue = (typeof SUBACCOUNT_ROLE_VALUES)[number];\n\nexport const SUBACCOUNT_PERMISSION_VALUES = [\n \"read_subaccount\",\n \"update_subaccount\",\n \"read_balances\",\n \"read_spot\",\n \"trade_spot\",\n \"read_internal_transfers\",\n \"internal_transfer\",\n \"external_withdraw\",\n \"read_address_book\",\n \"manage_address_book\",\n \"read_members\",\n \"manage_members\",\n \"read_invites\",\n \"manage_invites\",\n \"read_api_keys\",\n \"manage_api_keys\",\n \"read_subaccount_policy\",\n \"manage_subaccount_policy\",\n \"read_activity\",\n \"read_activity_security_details\",\n \"manage_member_mfa_requirement\",\n \"create_deposit_address\",\n \"read_deposit_addresses\",\n \"read_guard_signer_status\",\n \"manage_guard_signer\",\n] as const;\nexport type SubaccountPermissionValue = (typeof SUBACCOUNT_PERMISSION_VALUES)[number];\n\nexport const SUBACCOUNT_INVITE_ACTION_VALUES = [\"accept\", \"decline\", \"cancel\"] as const;\nexport type SubaccountInviteActionValue = (typeof SUBACCOUNT_INVITE_ACTION_VALUES)[number];\n\nexport const SUBACCOUNT_INVITE_STATUS_VALUES = [\n \"pending\",\n \"accepted\",\n \"declined\",\n \"cancelled\",\n] as const;\nexport type SubaccountInviteStatusValue = (typeof SUBACCOUNT_INVITE_STATUS_VALUES)[number];\n\nexport const SUBACCOUNT_INVITE_DIRECTION_VALUES = [\"\", \"incoming\", \"outgoing\"] as const;\nexport type SubaccountInviteDirectionValue = (typeof SUBACCOUNT_INVITE_DIRECTION_VALUES)[number];\n\nexport const SUBACCOUNT_STATUS_VALUES = [\"active\", \"disabled\"] as const;\nexport type SubaccountStatusValue = (typeof SUBACCOUNT_STATUS_VALUES)[number];\n\nexport const ACTIVITY_ENTITY_KIND_VALUES = [\n \"account\",\n \"session\",\n \"api_key\",\n \"subaccount\",\n \"member\",\n \"policy\",\n \"invite\",\n \"security\",\n \"destination\",\n] as const;\nexport type ActivityEntityKindValue = (typeof ACTIVITY_ENTITY_KIND_VALUES)[number];\n\nexport const ACTIVITY_EVENT_ACTION_VALUES = [\n \"created\",\n \"updated\",\n \"deleted\",\n \"enabled\",\n \"disabled\",\n \"removed\",\n \"role_set\",\n \"received\",\n \"replied\",\n \"failed\",\n \"revoked\",\n \"blocked\",\n \"hold_placed\",\n \"hold_released\",\n] as const;\nexport type ActivityEventActionValue = (typeof ACTIVITY_EVENT_ACTION_VALUES)[number];\n\nexport const ACTIVITY_EVENT_SOURCE_VALUES = [\"web\", \"mobile\", \"api\"] as const;\nexport type ActivityEventSourceValue = (typeof ACTIVITY_EVENT_SOURCE_VALUES)[number];\n\nexport const SubaccountRoleCodec = {\n inputToProto: {\n owner: Proto.SubaccountRole.OWNER,\n admin: Proto.SubaccountRole.ADMIN,\n treasury: Proto.SubaccountRole.TREASURY,\n leveraged_trader: Proto.SubaccountRole.LEVERAGED_TRADER,\n trader: Proto.SubaccountRole.TRADER,\n viewer: Proto.SubaccountRole.VIEWER,\n } satisfies InputToProto<SubaccountRoleValue, Proto.SubaccountRole>,\n protoToOutput: {\n [Proto.SubaccountRole.SUBACCOUNT_ROLE_UNSPECIFIED]: \"unspecified\",\n [Proto.SubaccountRole.OWNER]: \"owner\",\n [Proto.SubaccountRole.ADMIN]: \"admin\",\n [Proto.SubaccountRole.TREASURY]: \"treasury\",\n [Proto.SubaccountRole.LEVERAGED_TRADER]: \"leveraged_trader\",\n [Proto.SubaccountRole.TRADER]: \"trader\",\n [Proto.SubaccountRole.VIEWER]: \"viewer\",\n } satisfies ProtoToOutput<Proto.SubaccountRole, SubaccountRoleValue>,\n} as const;\n\nexport const SubaccountPermissionCodec = {\n protoToOutput: {\n [Proto.SubaccountPermission.UNSPECIFIED]: \"unspecified\",\n [Proto.SubaccountPermission.READ_SUBACCOUNT]: \"read_subaccount\",\n [Proto.SubaccountPermission.UPDATE_SUBACCOUNT]: \"update_subaccount\",\n [Proto.SubaccountPermission.READ_BALANCES]: \"read_balances\",\n [Proto.SubaccountPermission.READ_SPOT]: \"read_spot\",\n [Proto.SubaccountPermission.TRADE_SPOT]: \"trade_spot\",\n [Proto.SubaccountPermission.READ_INTERNAL_TRANSFERS]: \"read_internal_transfers\",\n [Proto.SubaccountPermission.INTERNAL_TRANSFER]: \"internal_transfer\",\n [Proto.SubaccountPermission.EXTERNAL_WITHDRAW]: \"external_withdraw\",\n [Proto.SubaccountPermission.READ_ADDRESS_BOOK]: \"read_address_book\",\n [Proto.SubaccountPermission.MANAGE_ADDRESS_BOOK]: \"manage_address_book\",\n [Proto.SubaccountPermission.READ_MEMBERS]: \"read_members\",\n [Proto.SubaccountPermission.MANAGE_MEMBERS]: \"manage_members\",\n [Proto.SubaccountPermission.READ_INVITES]: \"read_invites\",\n [Proto.SubaccountPermission.MANAGE_INVITES]: \"manage_invites\",\n [Proto.SubaccountPermission.READ_API_KEYS]: \"read_api_keys\",\n [Proto.SubaccountPermission.MANAGE_API_KEYS]: \"manage_api_keys\",\n [Proto.SubaccountPermission.READ_SUBACCOUNT_POLICY]: \"read_subaccount_policy\",\n [Proto.SubaccountPermission.MANAGE_SUBACCOUNT_POLICY]: \"manage_subaccount_policy\",\n [Proto.SubaccountPermission.READ_ACTIVITY]: \"read_activity\",\n [Proto.SubaccountPermission.READ_ACTIVITY_SECURITY_DETAILS]:\n \"read_activity_security_details\",\n [Proto.SubaccountPermission.MANAGE_MEMBER_MFA_REQUIREMENT]: \"manage_member_mfa_requirement\",\n [Proto.SubaccountPermission.CREATE_DEPOSIT_ADDRESS]: \"create_deposit_address\",\n [Proto.SubaccountPermission.READ_DEPOSIT_ADDRESSES]: \"read_deposit_addresses\",\n [Proto.SubaccountPermission.READ_GUARD_SIGNER_STATUS]: \"read_guard_signer_status\",\n [Proto.SubaccountPermission.MANAGE_GUARD_SIGNER]: \"manage_guard_signer\",\n } satisfies ProtoToOutput<Proto.SubaccountPermission, SubaccountPermissionValue>,\n} as const;\n\nexport const InviteActionCodec = {\n inputToProto: {\n accept: Proto.SubaccountInviteAction.ACCEPT,\n decline: Proto.SubaccountInviteAction.DECLINE,\n cancel: Proto.SubaccountInviteAction.CANCEL,\n } satisfies InputToProto<SubaccountInviteActionValue, Proto.SubaccountInviteAction>,\n} as const;\n\nexport const InviteStatusCodec = {\n protoToOutput: {\n [Proto.SubaccountInviteStatus.UNSPECIFIED]: \"unspecified\",\n [Proto.SubaccountInviteStatus.PENDING]: \"pending\",\n [Proto.SubaccountInviteStatus.ACCEPTED]: \"accepted\",\n [Proto.SubaccountInviteStatus.DECLINED]: \"declined\",\n [Proto.SubaccountInviteStatus.CANCELLED]: \"cancelled\",\n } satisfies ProtoToOutput<Proto.SubaccountInviteStatus, SubaccountInviteStatusValue>,\n} as const;\n\nexport const SubaccountInviteDirectionCodec = {\n inputToProto: {\n \"\": Proto.SubaccountInviteDirection.DIRECTION_UNSPECIFIED,\n incoming: Proto.SubaccountInviteDirection.INCOMING,\n outgoing: Proto.SubaccountInviteDirection.OUTGOING,\n } satisfies InputToProto<SubaccountInviteDirectionValue, Proto.SubaccountInviteDirection>,\n} as const;\n\nexport const SubaccountStatusCodec = {\n inputToProto: {\n active: Proto.SubaccountStatus.ACTIVE,\n disabled: Proto.SubaccountStatus.DISABLED,\n } satisfies InputToProto<SubaccountStatusValue, Proto.SubaccountStatus>,\n protoToOutput: {\n [Proto.SubaccountStatus.UNSPECIFIED]: \"unspecified\",\n [Proto.SubaccountStatus.ACTIVE]: \"active\",\n [Proto.SubaccountStatus.DISABLED]: \"disabled\",\n } satisfies ProtoToOutput<Proto.SubaccountStatus, SubaccountStatusValue>,\n} as const;\n\nexport const ActivityEntityKindCodec = {\n protoToOutput: {\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_UNSPECIFIED]: \"unspecified\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_ACCOUNT]: \"account\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_SESSION]: \"session\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_API_KEY]: \"api_key\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_SUBACCOUNT]: \"subaccount\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_MEMBER]: \"member\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_POLICY]: \"policy\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_INVITE]: \"invite\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_SECURITY]: \"security\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_DESTINATION]: \"destination\",\n } satisfies ProtoToOutput<Proto.ActivityEntityKind, ActivityEntityKindValue>,\n} as const;\n\nexport const ActivityEventActionCodec = {\n protoToOutput: {\n [Proto.ActivityEventAction.ACTIVITY_ACTION_UNSPECIFIED]: \"unspecified\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_CREATED]: \"created\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_UPDATED]: \"updated\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_DELETED]: \"deleted\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_ENABLED]: \"enabled\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_DISABLED]: \"disabled\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_REMOVED]: \"removed\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_ROLE_SET]: \"role_set\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_RECEIVED]: \"received\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_REPLIED]: \"replied\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_FAILED]: \"failed\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_REVOKED]: \"revoked\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_BLOCKED]: \"blocked\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_HOLD_PLACED]: \"hold_placed\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_HOLD_RELEASED]: \"hold_released\",\n } satisfies ProtoToOutput<Proto.ActivityEventAction, ActivityEventActionValue>,\n} as const;\n\nexport const ActivityEventSourceCodec = {\n protoToOutput: {\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_UNSPECIFIED]: \"unspecified\",\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_WEB]: \"web\",\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_MOBILE]: \"mobile\",\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_API]: \"api\",\n } satisfies ProtoToOutput<Proto.ActivityEventSource, ActivityEventSourceValue>,\n} as const;\n"],"mappings":";;AAqDA,MAAa,qCAAqC;CAAC;CAAI;CAAY;AAAU;AAG7E,MAAa,2BAA2B,CAAC,UAAU,UAAU;AAqC7D,MAAa,sBAAsB;CAC/B,cAAc;EACV,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KAAA;AAC/D,EACJ;AAEA,MAAa,2BAA2B,EACpC,eAAe;EAC8C,IAAA;EACR,IAAA;EACG,IAAA;EACH,IAAA;AACrD,EACJ"}
|
|
@@ -51,7 +51,7 @@ var SubaccountsService = class {
|
|
|
51
51
|
includeMembers: true,
|
|
52
52
|
includeInvites: true,
|
|
53
53
|
includePolicy: true,
|
|
54
|
-
invitesDirection:
|
|
54
|
+
invitesDirection: 2
|
|
55
55
|
}, toConnectCallOptions(options));
|
|
56
56
|
if (!res.subaccount) throw new Error(`Subaccount not found: ${subaccountId}`);
|
|
57
57
|
return {
|
|
@@ -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 type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport type { SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSubaccountInputSchema,\n CreateSubaccountResultSchema,\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 SubaccountMutationResultSchema,\n SubaccountRoleCatalogSchema,\n EffectiveSubaccountPermissionsSchema,\n type CreateSubaccountResult,\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 count metadata useful for deriving future smart-account salts.\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, balances, members, and outgoing invites; throws if the subaccount is missing.\n */\n async get(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<\n Subaccount & {\n apiKeys: ApiKey[];\n policy: SubaccountPolicy;\n members: SubaccountMember[];\n invites: SubaccountInvite[];\n }\n > {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const subaccountId = formatId(validatedInput.subaccountId);\n const res = await this.#viewClient.getSubaccount(\n {\n subaccountId: validatedInput.subaccountId,\n includeApiKeys: true,\n includeBalances: true,\n includeMembers: true,\n includeInvites: true,\n includePolicy: true,\n invitesDirection: \"outgoing\",\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 };\n }\n\n /**\n * Creates a new subaccount under the caller's root account using a smart-account address, nonce, and signature proof.\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 incoming, outgoing, or all subaccount invitations for the caller, newest first.\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":";;;;;;;;;;;;;;;AA8DA,IAA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,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 type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport type { SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSubaccountInputSchema,\n CreateSubaccountResultSchema,\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 SubaccountMutationResultSchema,\n SubaccountRoleCatalogSchema,\n EffectiveSubaccountPermissionsSchema,\n type CreateSubaccountResult,\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 count metadata useful for deriving future smart-account salts.\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, balances, members, and outgoing invites; throws if the subaccount is missing.\n */\n async get(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<\n Subaccount & {\n apiKeys: ApiKey[];\n policy: SubaccountPolicy;\n members: SubaccountMember[];\n invites: SubaccountInvite[];\n }\n > {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const subaccountId = formatId(validatedInput.subaccountId);\n const res = await this.#viewClient.getSubaccount(\n {\n subaccountId: validatedInput.subaccountId,\n includeApiKeys: true,\n includeBalances: true,\n includeMembers: true,\n includeInvites: true,\n includePolicy: true,\n invitesDirection: Proto.SubaccountInviteDirection.OUTGOING,\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 };\n }\n\n /**\n * Creates a new subaccount under the caller's root account using a smart-account address, nonce, and signature proof.\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 incoming, outgoing, or all subaccount invitations for the caller, newest first.\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":";;;;;;;;;;;;;;;AA8DA,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;;;;CAKA,MAAM,IACF,OACA,SAQF;EACE,MAAM,iBAAiB,MAAM,yBAAyB,KAAK;EAC3D,MAAM,eAAe,SAAS,eAAe,YAAY;EACzD,MAAM,MAAM,MAAM,KAAKN,YAAY,cAC/B;GACI,cAAc,eAAe;GAC7B,gBAAgB;GAChB,iBAAiB;GACjB,gBAAgB;GAChB,gBAAgB;GAChB,eAAe;GACf,kBAAA;EACJ,GACA,qBAAqB,OAAO,CAChC;EACA,IAAI,CAAC,IAAI,YAAY,MAAM,IAAI,MAAM,yBAAyB,cAAc;EAE5E,OAAO;GACH,GAAG,MAAMM,oBAAkB,IAAI,UAAU;GACzC,QAAQ,IAAI,SACN,MAAM,wBAA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;;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,5 +1,5 @@
|
|
|
1
1
|
import { PolicyAction } from "../../gen/auth/v1/policies_pb.js";
|
|
2
|
-
import { ActivityEntityKind, ActivityEventAction, ActivityEventSource, SubaccountInviteAction, SubaccountInviteStatus as SubaccountInviteStatus$1, SubaccountPermission as SubaccountPermission$1, SubaccountRole as SubaccountRole$1 } from "../../gen/auth/v1/subaccounts_pb.js";
|
|
2
|
+
import { ActivityEntityKind, ActivityEventAction, ActivityEventSource, SubaccountInviteAction, SubaccountInviteDirection, SubaccountInviteStatus as SubaccountInviteStatus$1, SubaccountPermission as SubaccountPermission$1, SubaccountRole as SubaccountRole$1, SubaccountStatus as SubaccountStatus$1 } from "../../gen/auth/v1/subaccounts_pb.js";
|
|
3
3
|
import * as v from "valibot";
|
|
4
4
|
//#region src/services/subaccounts/subaccounts.schemas.d.ts
|
|
5
5
|
declare const SubaccountRoleSchema: v.PicklistSchema<readonly ["owner", "admin", "treasury", "leveraged_trader", "trader", "viewer"], undefined>;
|
|
@@ -97,7 +97,7 @@ declare const UpdateSubaccountInputSchema: v.SchemaWithPipe<readonly [v.StrictOb
|
|
|
97
97
|
} & {
|
|
98
98
|
color: string;
|
|
99
99
|
} & {
|
|
100
|
-
status:
|
|
100
|
+
status: SubaccountStatus$1.ACTIVE | SubaccountStatus$1.DISABLED;
|
|
101
101
|
}>;
|
|
102
102
|
updateMask: {
|
|
103
103
|
paths: string[];
|
|
@@ -128,7 +128,7 @@ declare const SetSubaccountMemberMfaRequirementInputSchema: v.StrictObjectSchema
|
|
|
128
128
|
}, undefined>;
|
|
129
129
|
type SetSubaccountMemberMfaRequirementInput = v.InferInput<typeof SetSubaccountMemberMfaRequirementInputSchema>;
|
|
130
130
|
declare const ListSubaccountInvitesInputSchema: v.StrictObjectSchema<{
|
|
131
|
-
readonly direction: v.OptionalSchema<v.PicklistSchema<["
|
|
131
|
+
readonly direction: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["", "incoming", "outgoing"], undefined>, "">, v.TransformAction<"" | "incoming" | "outgoing", SubaccountInviteDirection>]>;
|
|
132
132
|
}, undefined>;
|
|
133
133
|
type ListSubaccountInvitesInput = v.InferInput<typeof ListSubaccountInvitesInputSchema>;
|
|
134
134
|
declare const InviteStatusSchema: v.PicklistSchema<["pending", "accepted", "declined", "cancelled"], undefined>;
|
|
@@ -138,7 +138,7 @@ declare const RespondSubaccountInviteInputSchema: v.StrictObjectSchema<{
|
|
|
138
138
|
readonly action: v.SchemaWithPipe<readonly [v.PicklistSchema<["accept", "decline", "cancel"], undefined>, v.TransformAction<"accept" | "decline" | "cancel", SubaccountInviteAction.ACCEPT | SubaccountInviteAction.DECLINE | SubaccountInviteAction.CANCEL>]>;
|
|
139
139
|
}, undefined>;
|
|
140
140
|
type RespondSubaccountInviteInput = v.InferInput<typeof RespondSubaccountInviteInputSchema>;
|
|
141
|
-
declare const ProtoSubaccountStatusSchema: v.SchemaWithPipe<readonly [v.
|
|
141
|
+
declare const ProtoSubaccountStatusSchema: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountStatus$1, undefined>, v.TransformAction<SubaccountStatus$1, "unspecified" | "disabled" | "active">]>;
|
|
142
142
|
type SubaccountStatus = v.InferOutput<typeof ProtoSubaccountStatusSchema>;
|
|
143
143
|
declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
144
144
|
readonly id: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
@@ -146,7 +146,7 @@ declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
146
146
|
readonly label: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
147
147
|
readonly icon: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
148
148
|
readonly color: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
149
|
-
readonly status: v.SchemaWithPipe<readonly [v.
|
|
149
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountStatus$1, undefined>, v.TransformAction<SubaccountStatus$1, "unspecified" | "disabled" | "active">]>;
|
|
150
150
|
readonly smartAccountAddress: v.StringSchema<undefined>;
|
|
151
151
|
readonly smartAccountSaltNonce: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
152
152
|
readonly ownerUsername: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
@@ -165,7 +165,7 @@ declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
165
165
|
label: string;
|
|
166
166
|
icon: string;
|
|
167
167
|
color: string;
|
|
168
|
-
status: "disabled" | "active";
|
|
168
|
+
status: "unspecified" | "disabled" | "active";
|
|
169
169
|
smartAccountAddress: string;
|
|
170
170
|
smartAccountSaltNonce?: number | undefined;
|
|
171
171
|
ownerUsername: string;
|
|
@@ -186,7 +186,7 @@ declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
186
186
|
label: string;
|
|
187
187
|
icon: string;
|
|
188
188
|
color: string;
|
|
189
|
-
status: "disabled" | "active";
|
|
189
|
+
status: "unspecified" | "disabled" | "active";
|
|
190
190
|
smartAccountAddress: string;
|
|
191
191
|
smartAccountSaltNonce?: number | undefined;
|
|
192
192
|
ownerUsername: string;
|
|
@@ -212,7 +212,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
212
212
|
readonly granteeAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
213
213
|
readonly inviterAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
214
214
|
readonly role: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountRole$1, undefined>, v.TransformAction<SubaccountRole$1, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
215
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountInviteStatus$1, undefined>, v.TransformAction<SubaccountInviteStatus$1, "unspecified" | "pending" | "
|
|
215
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountInviteStatus$1, undefined>, v.TransformAction<SubaccountInviteStatus$1, "unspecified" | "pending" | "accepted" | "declined" | "cancelled">]>;
|
|
216
216
|
readonly createdAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
217
217
|
readonly seconds: v.BigintSchema<undefined>;
|
|
218
218
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -239,7 +239,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
239
239
|
granteeAccountId: string;
|
|
240
240
|
inviterAccountId: string;
|
|
241
241
|
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
242
|
-
status: "unspecified" | "pending" | "
|
|
242
|
+
status: "unspecified" | "pending" | "accepted" | "declined" | "cancelled";
|
|
243
243
|
createdAt?: number | undefined;
|
|
244
244
|
respondedAt?: number | undefined;
|
|
245
245
|
granteeUsername: string;
|
|
@@ -257,7 +257,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
257
257
|
granteeAccountId: string;
|
|
258
258
|
inviterAccountId: string;
|
|
259
259
|
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
260
|
-
status: "unspecified" | "pending" | "
|
|
260
|
+
status: "unspecified" | "pending" | "accepted" | "declined" | "cancelled";
|
|
261
261
|
createdAt?: number | undefined;
|
|
262
262
|
respondedAt?: number | undefined;
|
|
263
263
|
granteeUsername: string;
|
|
@@ -279,8 +279,8 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
|
|
|
279
279
|
seconds: bigint;
|
|
280
280
|
nanos: number;
|
|
281
281
|
} | undefined, number | undefined>]>;
|
|
282
|
-
readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "
|
|
283
|
-
readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "
|
|
282
|
+
readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "member" | "policy" | "invite" | "security">]>;
|
|
283
|
+
readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "created" | "updated" | "deleted" | "removed" | "role_set" | "received" | "replied" | "failed" | "revoked" | "blocked" | "hold_placed" | "hold_released">]>;
|
|
284
284
|
readonly source: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventSource, undefined>, v.TransformAction<ActivityEventSource, "unspecified" | "web" | "mobile" | "api">]>;
|
|
285
285
|
readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
286
286
|
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":";;;;
|
|
1
|
+
{"version":3,"file":"subaccounts.schemas.d.ts","names":[],"sources":["../../../src/services/subaccounts/subaccounts.schemas.ts"],"mappings":";;;;cAsCa,sBAAoB,EAAA;KAErB,iBAAiB,EAAE,mBAAmB;cAS5C,iCAA+B,EAAA,yBAAA,EAAA,kBAAA,oCAAA,EAAA,gBAAA;KAYzB,uBAAuB,EAAE,mBAAmB;cAE3C,sCAAoC,EAAA;;;;;;KAiBrC,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,6BAA2B,EAAA;;;;;;;;;;KAW5B,wBAAwB,EAAE,kBAAkB;cAE3C,yBAAuB,EAAA;;;KAIxB,oBAAoB,EAAE,kBAAkB;cAEvC,8BAA4B,EAAA;;;;;;KAO7B,yBAA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
|
5
5
|
import { PolicyActionCodec } from "../policies/shared.codecs.js";
|
|
6
6
|
import { buildProtoPatch, defineProtoPatchFields } from "../../utils/proto-patch.js";
|
|
7
|
-
import { ActivityEntityKind, ActivityEventAction, ActivityEventSource, SubaccountInviteStatus, SubaccountPermission, SubaccountRole } from "../../gen/auth/v1/subaccounts_pb.js";
|
|
8
|
-
import { ActivityEntityKindCodec, ActivityEventActionCodec, ActivityEventSourceCodec, InviteActionCodec, InviteStatusCodec, SUBACCOUNT_STATUS_VALUES, SubaccountPermissionCodec, SubaccountRoleCodec, SubaccountStatusCodec } from "./subaccounts.codecs.js";
|
|
7
|
+
import { ActivityEntityKind, ActivityEventAction, ActivityEventSource, SubaccountInviteStatus, SubaccountPermission, SubaccountRole, SubaccountStatus } from "../../gen/auth/v1/subaccounts_pb.js";
|
|
8
|
+
import { ActivityEntityKindCodec, ActivityEventActionCodec, ActivityEventSourceCodec, InviteActionCodec, InviteStatusCodec, SUBACCOUNT_INVITE_DIRECTION_VALUES, SUBACCOUNT_STATUS_VALUES, SubaccountInviteDirectionCodec, SubaccountPermissionCodec, SubaccountRoleCodec, SubaccountStatusCodec } from "./subaccounts.codecs.js";
|
|
9
9
|
import * as v from "valibot";
|
|
10
10
|
const SubaccountRoleSchema = v.picklist([
|
|
11
11
|
"owner",
|
|
@@ -105,11 +105,7 @@ const SetSubaccountMemberMfaRequirementInputSchema = v.strictObject({
|
|
|
105
105
|
subaccountId: idInputSchema("subaccountId"),
|
|
106
106
|
requireMemberMfa: v.boolean()
|
|
107
107
|
});
|
|
108
|
-
const ListSubaccountInvitesInputSchema = v.strictObject({ direction: v.optional(v.picklist([
|
|
109
|
-
"incoming",
|
|
110
|
-
"outgoing",
|
|
111
|
-
""
|
|
112
|
-
]), "") });
|
|
108
|
+
const ListSubaccountInvitesInputSchema = v.strictObject({ direction: v.pipe(v.optional(v.picklist(SUBACCOUNT_INVITE_DIRECTION_VALUES), ""), v.transform((direction) => SubaccountInviteDirectionCodec.inputToProto[direction])) });
|
|
113
109
|
const InviteActionSchema = v.picklist([
|
|
114
110
|
"accept",
|
|
115
111
|
"decline",
|
|
@@ -126,7 +122,7 @@ const RespondSubaccountInviteInputSchema = v.strictObject({
|
|
|
126
122
|
inviteId: idInputSchema("inviteId"),
|
|
127
123
|
action: v.pipe(InviteActionSchema, v.transform((v) => InviteActionCodec.inputToProto[v]))
|
|
128
124
|
});
|
|
129
|
-
const ProtoSubaccountStatusSchema = v.pipe(v.
|
|
125
|
+
const ProtoSubaccountStatusSchema = v.pipe(v.enum(SubaccountStatus), v.transform((status) => requiredEnumLabel(SubaccountStatusCodec.protoToOutput, status, "SubaccountSchema", "status")));
|
|
130
126
|
const SubaccountSchema = v.pipe(v.object({
|
|
131
127
|
id: PublicIdSchema,
|
|
132
128
|
role: ProtoSubaccountRoleSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccounts.schemas.js","names":["Proto.SubaccountRole","Proto.SubaccountPermission","ProtoPolicies.PolicyAction","Proto.SubaccountInviteStatus","Proto.ActivityEntityKind","Proto.ActivityEventAction","Proto.ActivityEventSource"],"sources":["../../../src/services/subaccounts/subaccounts.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport * as ProtoPolicies from \"../../gen/auth/v1/policies_pb.js\";\nimport * as v from \"valibot\";\nimport {\n BigIntStringSchema,\n OptionalTimestampMsSchema,\n PublicIdSchema,\n TimestampSchema,\n idInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../utils/time.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport {\n SubaccountRoleCodec,\n SubaccountPermissionCodec,\n InviteActionCodec,\n InviteStatusCodec,\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 = v.pipe(\n v.enum(Proto.SubaccountRole),\n v.transform((role) =>\n requiredEnumLabel(SubaccountRoleCodec.protoToOutput, role, \"SubaccountRoleSchema\", \"role\"),\n ),\n);\n\nconst ProtoSubaccountPermissionSchema = v.pipe(\n v.enum(Proto.SubaccountPermission),\n v.transform((permission) =>\n requiredEnumLabel(\n SubaccountPermissionCodec.protoToOutput,\n permission,\n \"SubaccountPermissionSchema\",\n \"permission\",\n ),\n ),\n);\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: v.pipe(\n v.enum(ProtoPolicies.PolicyAction),\n v.transform((action) =>\n requiredEnumLabel(\n PolicyActionCodec.protoToOutput,\n action,\n \"SubaccountPermissionDefinitionSchema\",\n \"policy action\",\n ),\n ),\n ),\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: PublicIdSchema,\n});\n\nexport type EffectiveSubaccountPermissions = v.InferOutput<\n typeof EffectiveSubaccountPermissionsSchema\n>;\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: v.string(),\n nonce: v.string(),\n signature: v.string(),\n primaryWalletAddress: v.optional(v.string(), \"\"),\n walletProvider: v.optional(v.string(), \"\"),\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 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.optional(v.picklist([\"incoming\", \"outgoing\", \"\"]), \"\"),\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\", \"cancelled\"]);\n\nexport type SubaccountInviteStatus = v.InferOutput<typeof InviteStatusSchema>;\n\nconst ProtoInviteStatusSchema = v.enum(Proto.SubaccountInviteStatus);\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 = v.pipe(\n v.picklist(SUBACCOUNT_STATUS_VALUES),\n v.transform((status) => SubaccountStatusCodec.protoToOutput[status]),\n);\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: PublicIdSchema,\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) =>\n requiredEnumLabel(\n InviteStatusCodec.protoToOutput,\n v,\n \"SubaccountInviteSchema\",\n \"status\",\n ),\n ),\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: v.pipe(\n v.enum(Proto.ActivityEntityKind),\n v.transform((value) =>\n requiredEnumLabel(\n ActivityEntityKindCodec.protoToOutput,\n value,\n \"SubaccountActivityEventSchema\",\n \"entity kind\",\n ),\n ),\n ),\n eventAction: v.pipe(\n v.enum(Proto.ActivityEventAction),\n v.transform((value) =>\n requiredEnumLabel(\n ActivityEventActionCodec.protoToOutput,\n value,\n \"SubaccountActivityEventSchema\",\n \"event action\",\n ),\n ),\n ),\n source: v.pipe(\n v.enum(Proto.ActivityEventSource),\n v.transform((value) =>\n requiredEnumLabel(\n ActivityEventSourceCodec.protoToOutput,\n value,\n \"SubaccountActivityEventSchema\",\n \"source\",\n ),\n ),\n ),\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":";;;;;;;;;AAoCA,MAAa,uBAAuB,EAAE,SAAS;CAR3C;CACA;CACA;CACA;CACA;CACA;AAG2C,CAAsB;AAIrE,MAAM,4BAA4B,EAAE,KAChC,EAAE,KAAKA,cAAoB,GAC3B,EAAE,WAAW,SACT,kBAAkB,oBAAoB,eAAe,MAAM,wBAAwB,MAAM,CAC7F,CACJ;AAEA,MAAM,kCAAkC,EAAE,KACtC,EAAE,KAAKC,oBAA0B,GACjC,EAAE,WAAW,eACT,kBACI,0BAA0B,eAC1B,YACA,8BACA,YACJ,CACJ,CACJ;AAIA,MAAa,uCAAuC,EAAE,OAAO;CACzD,YAAY;CACZ,aAAa,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACtC,aAAa,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;C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;CAClD,WAAW;CACX,YAAY,EAAE,KACV,EAAE,KAAKC,kBAAwB,GAC/B,EAAE,WAAW,UACT,kBACI,wBAAwB,eACxB,OACA,iCACA,aACJ,CACJ,CACJ;CACA,aAAa,EAAE,KACX,EAAE,KAAKC,mBAAyB,GAChC,EAAE,WAAW,UACT,kBACI,yBAAyB,eACzB,OACA,iCACA,cACJ,CACJ,CACJ;CACA,QAAQ,EAAE,KACN,EAAE,KAAKC,mBAAyB,GAChC,EAAE,WAAW,UACT,kBACI,yBAAyB,eACzB,OACA,iCACA,QACJ,CACJ,CACJ;CACA,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":["Proto.SubaccountRole","Proto.SubaccountPermission","ProtoPolicies.PolicyAction","Proto.SubaccountInviteStatus","Proto.SubaccountStatus","Proto.ActivityEntityKind","Proto.ActivityEventAction","Proto.ActivityEventSource"],"sources":["../../../src/services/subaccounts/subaccounts.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport * as ProtoPolicies from \"../../gen/auth/v1/policies_pb.js\";\nimport * as v from \"valibot\";\nimport {\n BigIntStringSchema,\n OptionalTimestampMsSchema,\n PublicIdSchema,\n TimestampSchema,\n idInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../utils/time.js\";\nimport { requiredEnumLabel } 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 = v.pipe(\n v.enum(Proto.SubaccountRole),\n v.transform((role) =>\n requiredEnumLabel(SubaccountRoleCodec.protoToOutput, role, \"SubaccountRoleSchema\", \"role\"),\n ),\n);\n\nconst ProtoSubaccountPermissionSchema = v.pipe(\n v.enum(Proto.SubaccountPermission),\n v.transform((permission) =>\n requiredEnumLabel(\n SubaccountPermissionCodec.protoToOutput,\n permission,\n \"SubaccountPermissionSchema\",\n \"permission\",\n ),\n ),\n);\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: v.pipe(\n v.enum(ProtoPolicies.PolicyAction),\n v.transform((action) =>\n requiredEnumLabel(\n PolicyActionCodec.protoToOutput,\n action,\n \"SubaccountPermissionDefinitionSchema\",\n \"policy action\",\n ),\n ),\n ),\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: PublicIdSchema,\n});\n\nexport type EffectiveSubaccountPermissions = v.InferOutput<\n typeof EffectiveSubaccountPermissionsSchema\n>;\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: v.string(),\n nonce: v.string(),\n signature: v.string(),\n primaryWalletAddress: v.optional(v.string(), \"\"),\n walletProvider: v.optional(v.string(), \"\"),\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 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\", \"cancelled\"]);\n\nexport type SubaccountInviteStatus = v.InferOutput<typeof InviteStatusSchema>;\n\nconst ProtoInviteStatusSchema = v.enum(Proto.SubaccountInviteStatus);\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 = v.pipe(\n v.enum(Proto.SubaccountStatus),\n v.transform((status) =>\n requiredEnumLabel(\n SubaccountStatusCodec.protoToOutput,\n status,\n \"SubaccountSchema\",\n \"status\",\n ),\n ),\n);\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: PublicIdSchema,\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) =>\n requiredEnumLabel(\n InviteStatusCodec.protoToOutput,\n v,\n \"SubaccountInviteSchema\",\n \"status\",\n ),\n ),\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: v.pipe(\n v.enum(Proto.ActivityEntityKind),\n v.transform((value) =>\n requiredEnumLabel(\n ActivityEntityKindCodec.protoToOutput,\n value,\n \"SubaccountActivityEventSchema\",\n \"entity kind\",\n ),\n ),\n ),\n eventAction: v.pipe(\n v.enum(Proto.ActivityEventAction),\n v.transform((value) =>\n requiredEnumLabel(\n ActivityEventActionCodec.protoToOutput,\n value,\n \"SubaccountActivityEventSchema\",\n \"event action\",\n ),\n ),\n ),\n source: v.pipe(\n v.enum(Proto.ActivityEventSource),\n v.transform((value) =>\n requiredEnumLabel(\n ActivityEventSourceCodec.protoToOutput,\n value,\n \"SubaccountActivityEventSchema\",\n \"source\",\n ),\n ),\n ),\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":";;;;;;;;;AAsCA,MAAa,uBAAuB,EAAE,SAAS;CAR3C;CACA;CACA;CACA;CACA;CACA;AAG2C,CAAsB;AAIrE,MAAM,4BAA4B,EAAE,KAChC,EAAE,KAAKA,cAAoB,GAC3B,EAAE,WAAW,SACT,kBAAkB,oBAAoB,eAAe,MAAM,wBAAwB,MAAM,CAC7F,CACJ;AAEA,MAAM,kCAAkC,EAAE,KACtC,EAAE,KAAKC,oBAA0B,GACjC,E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AAc,cAAc;CAC1C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,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,EAAE,KACV,EAAE,KAAKC,kBAAwB,GAC/B,EAAE,WAAW,UACT,kBACI,wBAAwB,eACxB,OACA,iCACA,aACJ,CACJ,CACJ;CACA,aAAa,EAAE,KACX,EAAE,KAAKC,mBAAyB,GAChC,EAAE,WAAW,UACT,kBACI,yBAAyB,eACzB,OACA,iCACA,cACJ,CACJ,CACJ;CACA,QAAQ,EAAE,KACN,EAAE,KAAKC,mBAAyB,GAChC,EAAE,WAAW,UACT,kBACI,yBAAyB,eACzB,OACA,iCACA,QACJ,CACJ,CACJ;CACA,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"}
|
|
@@ -809,7 +809,7 @@ type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInpu
|
|
|
809
809
|
declare const ListTriggersInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
810
810
|
readonly parentOrderId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
|
|
811
811
|
readonly symbolId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>;
|
|
812
|
-
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("
|
|
812
|
+
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
|
|
813
813
|
readonly triggerType: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["stop_loss", "take_profit", "trailing_stop", "twap", "ladder"], undefined>, undefined>, v.TransformAction<"twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop" | undefined, TriggerType>]>;
|
|
814
814
|
readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 1000, undefined>]>, 50>;
|
|
815
815
|
readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
|
|
@@ -1030,7 +1030,7 @@ declare const ListTriggerEventsInputSchema: v.SchemaWithPipe<readonly [v.StrictO
|
|
|
1030
1030
|
readonly triggerId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
|
|
1031
1031
|
}, undefined>, v.TransformAction<{
|
|
1032
1032
|
limit?: number | undefined;
|
|
1033
|
-
eventType?: "
|
|
1033
|
+
eventType?: "updated" | "failed" | "fired" | "canceled" | undefined;
|
|
1034
1034
|
pageToken: string;
|
|
1035
1035
|
account?: "active" | "main" | {
|
|
1036
1036
|
subaccountId: string;
|
|
@@ -31,62 +31,62 @@ declare const CreateTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSche
|
|
|
31
31
|
type CreateTriggerResult = v.InferOutput<typeof CreateTriggerResultSchema>;
|
|
32
32
|
declare const CancelTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
33
33
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
34
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "
|
|
34
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused">]>;
|
|
35
35
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
36
36
|
}, undefined>, v.TransformAction<{
|
|
37
37
|
triggerId: string;
|
|
38
|
-
status: "unspecified" | "
|
|
38
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
39
39
|
tsNs: bigint;
|
|
40
40
|
}, {
|
|
41
41
|
ts: number;
|
|
42
42
|
tsNs: string;
|
|
43
43
|
triggerId: string;
|
|
44
|
-
status: "unspecified" | "
|
|
44
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
45
45
|
}>]>;
|
|
46
46
|
type CancelTriggerResult = v.InferOutput<typeof CancelTriggerResultSchema>;
|
|
47
47
|
declare const ModifyTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
48
48
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
49
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "
|
|
49
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused">]>;
|
|
50
50
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
51
51
|
}, undefined>, v.TransformAction<{
|
|
52
52
|
triggerId: string;
|
|
53
|
-
status: "unspecified" | "
|
|
53
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
54
54
|
tsNs: bigint;
|
|
55
55
|
}, {
|
|
56
56
|
ts: number;
|
|
57
57
|
tsNs: string;
|
|
58
58
|
triggerId: string;
|
|
59
|
-
status: "unspecified" | "
|
|
59
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
60
60
|
}>]>;
|
|
61
61
|
type ModifyTriggerResult = v.InferOutput<typeof ModifyTriggerResultSchema>;
|
|
62
62
|
declare const PauseTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
63
63
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
64
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "
|
|
64
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused">]>;
|
|
65
65
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
66
66
|
}, undefined>, v.TransformAction<{
|
|
67
67
|
triggerId: string;
|
|
68
|
-
status: "unspecified" | "
|
|
68
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
69
69
|
tsNs: bigint;
|
|
70
70
|
}, {
|
|
71
71
|
ts: number;
|
|
72
72
|
tsNs: string;
|
|
73
73
|
triggerId: string;
|
|
74
|
-
status: "unspecified" | "
|
|
74
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
75
75
|
}>]>;
|
|
76
76
|
type PauseTriggerResult = v.InferOutput<typeof PauseTriggerResultSchema>;
|
|
77
77
|
declare const ResumeTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
78
78
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
79
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "
|
|
79
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused">]>;
|
|
80
80
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
81
81
|
}, undefined>, v.TransformAction<{
|
|
82
82
|
triggerId: string;
|
|
83
|
-
status: "unspecified" | "
|
|
83
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
84
84
|
tsNs: bigint;
|
|
85
85
|
}, {
|
|
86
86
|
ts: number;
|
|
87
87
|
tsNs: string;
|
|
88
88
|
triggerId: string;
|
|
89
|
-
status: "unspecified" | "
|
|
89
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
90
90
|
}>]>;
|
|
91
91
|
type ResumeTriggerResult = v.InferOutput<typeof ResumeTriggerResultSchema>;
|
|
92
92
|
type StopDetailsOutput = {
|
|
@@ -528,7 +528,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
528
528
|
triggerId: string;
|
|
529
529
|
subaccountId: string;
|
|
530
530
|
symbolId: number;
|
|
531
|
-
status: "unspecified" | "
|
|
531
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
532
532
|
parentOrderId: string | undefined;
|
|
533
533
|
qty: string;
|
|
534
534
|
feeAsset: "unspecified" | "quote" | "base";
|
|
@@ -669,7 +669,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
669
669
|
triggerId: string;
|
|
670
670
|
subaccountId: string;
|
|
671
671
|
symbolId: number;
|
|
672
|
-
status: "unspecified" | "
|
|
672
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
673
673
|
parentOrderId: string | undefined;
|
|
674
674
|
qty: string;
|
|
675
675
|
feeAsset: "unspecified" | "quote" | "base";
|
|
@@ -810,7 +810,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
810
810
|
triggerId: string;
|
|
811
811
|
subaccountId: string;
|
|
812
812
|
symbolId: number;
|
|
813
|
-
status: "unspecified" | "
|
|
813
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
814
814
|
parentOrderId: string | undefined;
|
|
815
815
|
qty: string;
|
|
816
816
|
feeAsset: "unspecified" | "quote" | "base";
|
|
@@ -994,7 +994,7 @@ declare function createTriggerEventSchema(scales: SdkScales): v.SchemaWithPipe<r
|
|
|
994
994
|
subaccountId: string;
|
|
995
995
|
symbolId: number;
|
|
996
996
|
triggerType: "unspecified" | "twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop";
|
|
997
|
-
eventType: "unspecified" | "
|
|
997
|
+
eventType: "unspecified" | "updated" | "failed" | "fired" | "canceled";
|
|
998
998
|
ts: number;
|
|
999
999
|
childSeq: number;
|
|
1000
1000
|
childOrderId: string | undefined;
|
|
@@ -1006,7 +1006,7 @@ declare function createTriggerEventSchema(scales: SdkScales): v.SchemaWithPipe<r
|
|
|
1006
1006
|
subaccountId: string;
|
|
1007
1007
|
symbolId: number;
|
|
1008
1008
|
triggerType: "unspecified" | "twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop";
|
|
1009
|
-
eventType: "unspecified" | "
|
|
1009
|
+
eventType: "unspecified" | "updated" | "failed" | "fired" | "canceled";
|
|
1010
1010
|
ts: number;
|
|
1011
1011
|
childSeq: number;
|
|
1012
1012
|
childOrderId: string | undefined;
|
|
@@ -1018,7 +1018,7 @@ declare function createTriggerEventSchema(scales: SdkScales): v.SchemaWithPipe<r
|
|
|
1018
1018
|
subaccountId: string;
|
|
1019
1019
|
symbolId: number;
|
|
1020
1020
|
triggerType: "unspecified" | "twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop";
|
|
1021
|
-
eventType: "unspecified" | "
|
|
1021
|
+
eventType: "unspecified" | "updated" | "failed" | "fired" | "canceled";
|
|
1022
1022
|
ts: number;
|
|
1023
1023
|
childSeq: number;
|
|
1024
1024
|
childOrderId: string | undefined;
|
package/package.json
CHANGED