@polyester/sdk 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/gen/auth/v1/address_book_pb.d.ts +8 -0
  3. package/dist/gen/auth/v1/address_book_pb.d.ts.map +1 -1
  4. package/dist/gen/auth/v1/address_book_pb.js +1 -1
  5. package/dist/gen/auth/v1/address_book_pb.js.map +1 -1
  6. package/dist/gen/auth/v1/api_keys_pb.d.ts +1 -1
  7. package/dist/gen/auth/v1/api_keys_pb.js.map +1 -1
  8. package/dist/gen/auth/v1/auth_pb.d.ts +7 -1
  9. package/dist/gen/auth/v1/auth_pb.d.ts.map +1 -1
  10. package/dist/gen/auth/v1/auth_pb.js +7 -1
  11. package/dist/gen/auth/v1/auth_pb.js.map +1 -1
  12. package/dist/gen/auth/v1/policies_pb.d.ts +47 -337
  13. package/dist/gen/auth/v1/policies_pb.d.ts.map +1 -1
  14. package/dist/gen/auth/v1/policies_pb.js +49 -73
  15. package/dist/gen/auth/v1/policies_pb.js.map +1 -1
  16. package/dist/gen/orders/v1/orders_pb.d.ts +32 -1
  17. package/dist/gen/orders/v1/orders_pb.d.ts.map +1 -1
  18. package/dist/gen/orders/v1/orders_pb.js +25 -1
  19. package/dist/gen/orders/v1/orders_pb.js.map +1 -1
  20. package/dist/gen/triggers/v1/triggers_pb.d.ts +22 -2
  21. package/dist/gen/triggers/v1/triggers_pb.d.ts.map +1 -1
  22. package/dist/gen/triggers/v1/triggers_pb.js +7 -1
  23. package/dist/gen/triggers/v1/triggers_pb.js.map +1 -1
  24. package/dist/index.d.ts +3 -3
  25. package/dist/services/address-book/address-book.d.ts +1 -1
  26. package/dist/services/address-book/address-book.js +1 -1
  27. package/dist/services/address-book/address-book.js.map +1 -1
  28. package/dist/services/address-book/address-book.schemas.d.ts +27 -4
  29. package/dist/services/address-book/address-book.schemas.d.ts.map +1 -1
  30. package/dist/services/address-book/address-book.schemas.js +11 -5
  31. package/dist/services/address-book/address-book.schemas.js.map +1 -1
  32. package/dist/services/lifecycle/lifecycle.schemas.d.ts +42 -42
  33. package/dist/services/orders/order-errors.schemas.d.ts +1 -1
  34. package/dist/services/orders/orders-batch.schemas.d.ts +20 -20
  35. package/dist/services/orders/orders-input.schemas.d.ts +4 -4
  36. package/dist/services/orders/orders-modify.schemas.d.ts +3 -2
  37. package/dist/services/orders/orders-modify.schemas.d.ts.map +1 -1
  38. package/dist/services/orders/orders-modify.schemas.js +5 -3
  39. package/dist/services/orders/orders-modify.schemas.js.map +1 -1
  40. package/dist/services/orders/orders-output.schemas.d.ts +6 -6
  41. package/dist/services/orders/orders.d.ts +1 -1
  42. package/dist/services/orders/orders.js +1 -1
  43. package/dist/services/orders/orders.js.map +1 -1
  44. package/dist/services/policies/api-key-policies/api-key-policies.d.ts +2 -2
  45. package/dist/services/policies/api-key-policies/api-key-policies.js +2 -2
  46. package/dist/services/policies/api-key-policies/api-key-policies.js.map +1 -1
  47. package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts +15 -140
  48. package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts.map +1 -1
  49. package/dist/services/policies/api-key-policies/api-key-policies.schemas.js +5 -53
  50. package/dist/services/policies/api-key-policies/api-key-policies.schemas.js.map +1 -1
  51. package/dist/services/policies/shared.codecs.js +4 -12
  52. package/dist/services/policies/shared.codecs.js.map +1 -1
  53. package/dist/services/policies/shared.d.ts +1 -1
  54. package/dist/services/policies/shared.d.ts.map +1 -1
  55. package/dist/services/policies/shared.js +3 -11
  56. package/dist/services/policies/shared.js.map +1 -1
  57. package/dist/services/policies/subaccount-policies/subaccount-policies.d.ts +1 -1
  58. package/dist/services/policies/subaccount-policies/subaccount-policies.js +1 -1
  59. package/dist/services/policies/subaccount-policies/subaccount-policies.js.map +1 -1
  60. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +10 -206
  61. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts.map +1 -1
  62. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +9 -115
  63. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
  64. package/dist/services/social-verification/social-verification.schemas.d.ts +10 -2
  65. package/dist/services/social-verification/social-verification.schemas.d.ts.map +1 -1
  66. package/dist/services/social-verification/social-verification.schemas.js +4 -2
  67. package/dist/services/social-verification/social-verification.schemas.js.map +1 -1
  68. package/dist/services/subaccounts/subaccounts.schemas.d.ts +5 -5
  69. package/dist/services/triggers/trigger-input.schemas.d.ts +14 -7
  70. package/dist/services/triggers/trigger-input.schemas.d.ts.map +1 -1
  71. package/dist/services/triggers/trigger-input.schemas.js +13 -3
  72. package/dist/services/triggers/trigger-input.schemas.js.map +1 -1
  73. package/dist/services/triggers/triggers-output.schemas.d.ts +15 -15
  74. package/dist/services/triggers/triggers.codecs.js +6 -3
  75. package/dist/services/triggers/triggers.codecs.js.map +1 -1
  76. package/dist/services/triggers/triggers.d.ts +2 -2
  77. package/dist/services/triggers/triggers.js +2 -2
  78. package/dist/services/triggers/triggers.js.map +1 -1
  79. package/dist/services/triggers/triggers.types.d.ts +3 -3
  80. package/dist/shared/connect-error-mapping.d.ts.map +1 -1
  81. package/dist/shared/connect-error-mapping.js +1 -0
  82. package/dist/shared/connect-error-mapping.js.map +1 -1
  83. package/dist/shared/schemas.js +2 -2
  84. package/dist/shared/schemas.js.map +1 -1
  85. package/dist/shared/transports.js +6 -1
  86. package/dist/shared/transports.js.map +1 -1
  87. package/dist/shared/wire-bounds.js +3 -1
  88. package/dist/shared/wire-bounds.js.map +1 -1
  89. package/dist/utils/numbers.js +1 -10
  90. package/dist/utils/numbers.js.map +1 -1
  91. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"subaccount-policies.schemas.js","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n PerpMarketRuleSchema,\n PolicyActionEnumSchema,\n PolicyMarketScopeEnumSchema,\n ProtoPolicyActionEnumSchema,\n ProtoPolicyMarketScopeEnumSchema,\n SpotMarketRuleSchema,\n} from \"../shared.js\";\nimport {\n PolicyMarketScopeCodec,\n PolicyActionCodec,\n policyMarketScopeLabelFor,\n policyActionLabelFor,\n} from \"../shared.codecs.js\";\nimport { bpsToPct } from \"../../../utils/numbers.js\";\nimport { idToBigInt } from \"../../../utils/base58-id.js\";\nimport {\n OptionalNumberToBigIntOrZeroSchema,\n OptionalNumberToBpsOrZeroSchema,\n OptionalNumberToIntOrZeroSchema,\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n BigIntStringSchema,\n PublicIdSchema,\n TimestampSchema,\n TimestampMsSchema,\n idInputSchema,\n optionalSubaccountIdInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../../utils/time.js\";\nimport { toTimestamp } from \"../../../utils/timestamp.js\";\nimport { toBigIntOrZero, toBpsOrZero, toIntOrZero } from \"../../../utils/numbers.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../../shared/account-scope.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../../utils/proto-patch.js\";\n\nexport const ListSubaccountPoliciesInputSchema = v.pipe(\n v.strictObject(AccountScopeInputEntries),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ListSubaccountPoliciesInput = v.InferInput<typeof ListSubaccountPoliciesInputSchema>;\n\nexport const GetSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n policyId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n ...AccountScopeInputEntries,\n }),\n v.transform(({ policyId, account }) => ({\n policyId: idToBigInt(policyId, \"policyId\"),\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GetSubaccountPolicyInput = v.InferInput<typeof GetSubaccountPolicyInputSchema>;\n\n/**\n * From the backend format to a usable frontend/UI format, so big ints to numbers, etc.\n */\nexport const SubaccountPolicySchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n name: v.string(),\n description: v.string(),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n ProtoPolicyMarketScopeEnumSchema,\n v.transform((v) => policyMarketScopeLabelFor(v)),\n ),\n perpMarketScope: v.pipe(\n ProtoPolicyMarketScopeEnumSchema,\n v.transform((v) => policyMarketScopeLabelFor(v)),\n ),\n perpMarkets: v.optional(v.array(PerpMarketRuleSchema), []),\n actions: v.pipe(\n v.optional(v.array(ProtoPolicyActionEnumSchema), []),\n v.transform((v) => v.map((action) => policyActionLabelFor(action))),\n ),\n isTemplate: v.optional(v.boolean(), false),\n sourceTemplateId: OptionalPublicIdSchema,\n globalNotionalCap: v.pipe(\n v.bigint(),\n v.transform((v) => Number(v)),\n ),\n maxOrderNotional: v.pipe(\n v.bigint(),\n v.transform((v) => Number(v)),\n ),\n maxOpenOrders: v.number(),\n maxOpenPositions: v.number(),\n globalPerpLeverageX: v.number(),\n dailyInternalTransferOutLimit: v.pipe(\n v.bigint(),\n v.transform((v) => Number(v)),\n ),\n dailyWithdrawLimit: v.pipe(\n v.bigint(),\n v.transform((v) => Number(v)),\n ),\n internalTransfersOwnOnly: v.boolean(),\n enforceWithdrawWhitelist: v.boolean(),\n tradingHalted: v.boolean(),\n liquidationOnly: v.boolean(),\n dailyLossLimit: v.pipe(\n v.bigint(),\n v.transform((v) => Number(v)),\n ),\n intradayDrawdownLimitBps: v.pipe(\n v.number(),\n v.transform((v) => bpsToPct(v)),\n ),\n locked: v.boolean(),\n reviewAt: OptionalTimestampMsSchema,\n expiresAt: OptionalTimestampMsSchema,\n createdAt: TimestampMsSchema,\n updatedAt: TimestampSchema,\n revision: BigIntStringSchema,\n }),\n v.transform(\n ({\n maxOrderNotional,\n globalNotionalCap,\n intradayDrawdownLimitBps,\n updatedAt,\n ...rest\n }) => ({\n maxOrderSize: maxOrderNotional,\n globalExposureCap: globalNotionalCap,\n intradayDrawdownLimitPct: intradayDrawdownLimitBps,\n ...rest,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n }),\n ),\n);\n\nexport type SubaccountPolicy = v.InferOutput<typeof SubaccountPolicySchema>;\n\nconst SubaccountPolicyInputBaseSchema = v.strictObject({\n name: v.string(),\n description: v.optional(v.string(), \"\"),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n perpMarkets: v.optional(v.array(PerpMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n PolicyMarketScopeEnumSchema,\n v.transform((v) => PolicyMarketScopeCodec.inputToProto[v]),\n ),\n perpMarketScope: v.pipe(\n PolicyMarketScopeEnumSchema,\n v.transform((v) => PolicyMarketScopeCodec.inputToProto[v]),\n ),\n actions: v.pipe(\n v.optional(v.array(PolicyActionEnumSchema), [\"read-balances\", \"read-spot\"]),\n v.transform((v) => (v ?? []).map((action) => PolicyActionCodec.inputToProto[action])),\n ),\n globalLeverageCap: OptionalNumberToIntOrZeroSchema,\n globalExposureCap: OptionalNumberToBigIntOrZeroSchema,\n maxOrderSize: OptionalNumberToBigIntOrZeroSchema,\n maxOpenOrders: OptionalNumberToIntOrZeroSchema,\n maxOpenPositions: OptionalNumberToIntOrZeroSchema,\n dailyInternalTransferLimit: OptionalNumberToBigIntOrZeroSchema,\n dailyWithdrawLimit: OptionalNumberToBigIntOrZeroSchema,\n dailyLossLimit: OptionalNumberToBigIntOrZeroSchema,\n intradayDrawdownLimitPct: OptionalNumberToBpsOrZeroSchema,\n tradingHalted: v.optional(v.boolean(), false),\n liquidationOnly: v.optional(v.boolean(), false),\n policyLocked: v.optional(v.boolean(), false),\n internalTransfersOwnOnly: v.optional(v.boolean(), true),\n enforceWithdrawWhitelist: v.optional(v.boolean(), false),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n subaccountId: optionalSubaccountIdInputSchema(),\n});\n\nfunction timestampFromMs(value: number | null | undefined) {\n if (value == null) return undefined;\n return toTimestamp({\n seconds: BigInt(Math.floor(value / 1000)),\n nanos: (value % 1000) * 1_000_000,\n });\n}\n\nfunction createSubaccountPolicyBaseTransform(\n input: v.InferOutput<typeof SubaccountPolicyInputBaseSchema>,\n) {\n const {\n subaccountId: _subaccountId,\n reviewAt,\n expiresAt,\n globalExposureCap,\n maxOrderSize,\n globalLeverageCap,\n dailyInternalTransferLimit,\n intradayDrawdownLimitPct,\n policyLocked,\n ...rest\n } = input;\n return {\n ...rest,\n globalNotionalCap: globalExposureCap,\n maxOrderNotional: maxOrderSize,\n globalPerpLeverageX: globalLeverageCap,\n dailyInternalTransferOutLimit: dailyInternalTransferLimit,\n intradayDrawdownLimitBps: intradayDrawdownLimitPct,\n locked: policyLocked,\n reviewAt: timestampFromMs(reviewAt),\n expiresAt: timestampFromMs(expiresAt),\n };\n}\n\nexport const CreateSubaccountPolicyInputSchema = v.pipe(\n SubaccountPolicyInputBaseSchema,\n v.check(\n ({ actions }) =>\n actions.includes(PolicyActionCodec.inputToProto[\"read-balances\"]) &&\n actions.includes(PolicyActionCodec.inputToProto[\"read-spot\"]),\n \"Subaccount policy actions must include read-balances and read-spot\",\n ),\n v.transform((input) => ({\n policy: createSubaccountPolicyBaseTransform(input),\n subaccountId: input.subaccountId,\n })),\n);\nexport type SubaccountPolicyCreateInput = v.InferInput<typeof CreateSubaccountPolicyInputSchema>;\n\nconst SubaccountPolicyPatchSchema = v.strictObject({\n name: v.optional(v.string()),\n description: v.optional(v.string()),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema)),\n perpMarkets: v.optional(v.array(PerpMarketRuleSchema)),\n spotMarketScope: v.optional(PolicyMarketScopeEnumSchema),\n perpMarketScope: v.optional(PolicyMarketScopeEnumSchema),\n actions: v.optional(v.array(PolicyActionEnumSchema)),\n globalLeverageCap: v.optional(v.nullable(v.number())),\n globalExposureCap: v.optional(v.nullable(v.number())),\n maxOrderSize: v.optional(v.nullable(v.number())),\n maxOpenOrders: v.optional(v.nullable(v.number())),\n maxOpenPositions: v.optional(v.nullable(v.number())),\n dailyInternalTransferLimit: v.optional(v.nullable(v.number())),\n dailyWithdrawLimit: v.optional(v.nullable(v.number())),\n dailyLossLimit: v.optional(v.nullable(v.number())),\n intradayDrawdownLimitPct: v.optional(v.nullable(v.number())),\n tradingHalted: v.optional(v.boolean()),\n liquidationOnly: v.optional(v.boolean()),\n policyLocked: v.optional(v.boolean()),\n internalTransfersOwnOnly: v.optional(v.boolean()),\n enforceWithdrawWhitelist: v.optional(v.boolean()),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n});\n\ntype SubaccountPolicyPatch = v.InferOutput<typeof SubaccountPolicyPatchSchema>;\n\nconst SUBACCOUNT_POLICY_PATCH_FIELDS = defineProtoPatchFields<SubaccountPolicyPatch>()({\n name: { path: \"name\", encode: (name) => ({ name }) },\n description: { path: \"description\", encode: (description) => ({ description }) },\n spotMarkets: { path: \"spot_markets\", encode: (spotMarkets) => ({ spotMarkets }) },\n perpMarkets: { path: \"perp_markets\", encode: (perpMarkets) => ({ perpMarkets }) },\n spotMarketScope: {\n path: \"spot_market_scope\",\n encode: (scope) => ({ spotMarketScope: PolicyMarketScopeCodec.inputToProto[scope] }),\n },\n perpMarketScope: {\n path: \"perp_market_scope\",\n encode: (scope) => ({ perpMarketScope: PolicyMarketScopeCodec.inputToProto[scope] }),\n },\n actions: {\n path: \"actions\",\n encode: (actions) => ({\n actions: actions.map((action) => PolicyActionCodec.inputToProto[action]),\n }),\n },\n globalExposureCap: {\n path: \"global_notional_cap\",\n encode: (value) => ({ globalNotionalCap: toBigIntOrZero(value) }),\n },\n maxOrderSize: {\n path: \"max_order_notional\",\n encode: (value) => ({ maxOrderNotional: toBigIntOrZero(value) }),\n },\n maxOpenOrders: {\n path: \"max_open_orders\",\n encode: (value) => ({ maxOpenOrders: toIntOrZero(value) }),\n },\n maxOpenPositions: {\n path: \"max_open_positions\",\n encode: (value) => ({ maxOpenPositions: toIntOrZero(value) }),\n },\n globalLeverageCap: {\n path: \"global_perp_leverage_x\",\n encode: (value) => ({ globalPerpLeverageX: toIntOrZero(value) }),\n },\n dailyInternalTransferLimit: {\n path: \"daily_internal_transfer_out_limit\",\n encode: (value) => ({ dailyInternalTransferOutLimit: toBigIntOrZero(value) }),\n },\n dailyWithdrawLimit: {\n path: \"daily_withdraw_limit\",\n encode: (value) => ({ dailyWithdrawLimit: toBigIntOrZero(value) }),\n },\n internalTransfersOwnOnly: {\n path: \"internal_transfers_own_only\",\n encode: (internalTransfersOwnOnly) => ({ internalTransfersOwnOnly }),\n },\n enforceWithdrawWhitelist: {\n path: \"enforce_withdraw_whitelist\",\n encode: (enforceWithdrawWhitelist) => ({ enforceWithdrawWhitelist }),\n },\n tradingHalted: {\n path: \"trading_halted\",\n encode: (tradingHalted) => ({ tradingHalted }),\n },\n liquidationOnly: {\n path: \"liquidation_only\",\n encode: (liquidationOnly) => ({ liquidationOnly }),\n },\n dailyLossLimit: {\n path: \"daily_loss_limit\",\n encode: (value) => ({ dailyLossLimit: toBigIntOrZero(value) }),\n },\n intradayDrawdownLimitPct: {\n path: \"intraday_drawdown_limit_bps\",\n encode: (value) => ({ intradayDrawdownLimitBps: toBpsOrZero(value) }),\n },\n policyLocked: { path: \"locked\", encode: (locked) => ({ locked }) },\n reviewAt: {\n path: \"review_at\",\n encode: (reviewAt) => {\n const timestamp = timestampFromMs(reviewAt);\n return timestamp === undefined ? {} : { reviewAt: timestamp };\n },\n },\n expiresAt: {\n path: \"expires_at\",\n encode: (expiresAt) => {\n const timestamp = timestampFromMs(expiresAt);\n return timestamp === undefined ? {} : { expiresAt: timestamp };\n },\n },\n});\n\nfunction hasMandatorySubaccountActions(actions: readonly string[] | undefined): boolean {\n return (\n actions === undefined ||\n (actions.includes(\"read-balances\") && actions.includes(\"read-spot\"))\n );\n}\n\nexport const UpdateSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n ...SubaccountPolicyPatchSchema.entries,\n policyId: v.pipe(\n v.string(),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n ),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n }),\n v.check(\n ({ actions }) => hasMandatorySubaccountActions(actions),\n \"Subaccount policy actions must include read-balances and read-spot\",\n ),\n v.check(\n ({ policyId: _policyId, expectedRevision: _expectedRevision, ...patch }) =>\n Object.values(patch).some((value) => value !== undefined),\n \"At least one subaccount policy field must be provided\",\n ),\n v.transform(({ policyId, expectedRevision, ...patch }) => {\n const { patch: policy, updateMask } = buildProtoPatch(\n patch,\n SUBACCOUNT_POLICY_PATCH_FIELDS,\n );\n return {\n policyId,\n policy,\n updateMask,\n expectedRevision,\n };\n }),\n);\nexport type SubaccountPolicyUpdateInput = v.InferInput<typeof UpdateSubaccountPolicyInputSchema>;\n\nexport const PolicyIdSchema = v.pipe(\n v.string(),\n v.trim(),\n v.minLength(1),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n);\n\nexport const ApplySubaccountPolicyInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n policyId: v.pipe(\n v.nullable(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"policyId\") : undefined)),\n ),\n});\n\nexport type SubaccountPolicyApplyInput = v.InferInput<typeof ApplySubaccountPolicyInputSchema>;\n\nconst DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT = Date.now();\n\nexport const DEFAULT_SUBACCOUNT_POLICY: SubaccountPolicy = {\n id: \"\",\n name: \"Subaccount Policy\",\n description: \"Subaccount Policy description\",\n spotMarkets: [],\n perpMarkets: [],\n spotMarketScope: \"all\",\n perpMarketScope: \"all\",\n actions: [\n \"read-balances\",\n \"read-external-withdrawals\",\n \"read-internal-transfers\",\n \"read-perp\",\n \"read-spot\",\n ],\n globalExposureCap: 0,\n maxOrderSize: 0,\n maxOpenOrders: 0,\n maxOpenPositions: 0,\n globalPerpLeverageX: 0,\n dailyInternalTransferOutLimit: 0,\n dailyWithdrawLimit: 0,\n internalTransfersOwnOnly: true,\n enforceWithdrawWhitelist: false,\n tradingHalted: false,\n liquidationOnly: false,\n dailyLossLimit: 0,\n createdAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAtNs: (BigInt(DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT) * 1_000_000n).toString(),\n isTemplate: false,\n sourceTemplateId: undefined,\n locked: false,\n reviewAt: undefined,\n expiresAt: undefined,\n intradayDrawdownLimitPct: 0,\n revision: \"0\",\n};\n"],"mappings":";;;;;;;;;;;AAwCA,MAAa,oCAAoC,EAAE,KAC/C,EAAE,aAAa,wBAAwB,GACvC,EAAE,WAAW,EAAE,eAAe,EAC1B,cAAc,2BAA2B,OAAO,EACpD,EAAE,CACN;AAIA,MAAa,iCAAiC,EAAE,KAC5C,EAAE,aAAa;CACX,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;CACrD,GAAG;AACP,CAAC,GACD,EAAE,WAAW,EAAE,UAAU,eAAe;CACpC,UAAU,WAAW,UAAU,UAAU;CACzC,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;;;;AAOA,MAAa,yBAAyB,EAAE,KACpC,EAAE,OAAO;CACL,IAAI;CACJ,MAAM,EAAE,OAAO;CACf,aAAa,EAAE,OAAO;CACtB,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,GAAG,CAAC,CAAC;CACzD,iBAAiB,EAAE,KACf,kCACA,EAAE,WAAW,MAAM,0BAA0B,CAAC,CAAC,CACnD;CACA,iBAAiB,EAAE,KACf,kCACA,EAAE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CAAC,GACvC,EAAE,WAAW,UAAW,QAAQ,WAAW,OAAO,UAAU,IAAI,KAAA,CAAU,CAC9E;AACJ,CAAC;AAID,MAAM,uCAAuC,KAAK,IAAI;AAEtD,MAAa,4BAA8C;CACvD,IAAI;CACJ,MAAM;CACN,aAAa;CACb,aAAa,CAAC;CACd,aAAa,CAAC;CACd,iBAAiB;CACjB,iBAAiB;CACjB,SAAS;EACL;EACA;EACA;EACA;EACA;CACJ;CACA,mBAAmB;CACnB,cAAc;CACd,eAAe;CACf,kBAAkB;CAClB,qBAAqB;CACrB,+BAA+B;CAC/B,oBAAoB;CACpB,0BAA0B;CAC1B,0BAA0B;CAC1B,eAAe;CACf,iBAAiB;CACjB,gBAAgB;CAChB,WAAW;CACX,WAAW;CACX,cAAc,OAAO,oCAAoC,IAAI,SAAA,CAAY,SAAS;CAClF,YAAY;CACZ,kBAAkB,KAAA;CAClB,QAAQ;CACR,UAAU,KAAA;CACV,WAAW,KAAA;CACX,0BAA0B;CAC1B,UAAU;AACd"}
1
+ {"version":3,"file":"subaccount-policies.schemas.js","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n PolicyActionEnumSchema,\n PolicyMarketScopeEnumSchema,\n ProtoPolicyActionEnumSchema,\n ProtoPolicyMarketScopeEnumSchema,\n SpotMarketRuleSchema,\n} from \"../shared.js\";\nimport {\n PolicyMarketScopeCodec,\n PolicyActionCodec,\n policyMarketScopeLabelFor,\n policyActionLabelFor,\n} from \"../shared.codecs.js\";\nimport { idToBigInt } from \"../../../utils/base58-id.js\";\nimport {\n OptionalNumberToBigIntOrZeroSchema,\n OptionalNumberToIntOrZeroSchema,\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n BigIntStringSchema,\n PublicIdSchema,\n TimestampSchema,\n TimestampMsSchema,\n idInputSchema,\n optionalSubaccountIdInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../../utils/time.js\";\nimport { toTimestamp } from \"../../../utils/timestamp.js\";\nimport { toBigIntOrZero, toIntOrZero } from \"../../../utils/numbers.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../../shared/account-scope.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../../utils/proto-patch.js\";\n\nexport const ListSubaccountPoliciesInputSchema = v.pipe(\n v.strictObject(AccountScopeInputEntries),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ListSubaccountPoliciesInput = v.InferInput<typeof ListSubaccountPoliciesInputSchema>;\n\nexport const GetSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n policyId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n ...AccountScopeInputEntries,\n }),\n v.transform(({ policyId, account }) => ({\n policyId: idToBigInt(policyId, \"policyId\"),\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GetSubaccountPolicyInput = v.InferInput<typeof GetSubaccountPolicyInputSchema>;\n\n/**\n * From the backend format to a usable frontend/UI format, so big ints to numbers, etc.\n */\nexport const SubaccountPolicySchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n name: v.string(),\n description: v.string(),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n ProtoPolicyMarketScopeEnumSchema,\n v.transform((v) => policyMarketScopeLabelFor(v)),\n ),\n actions: v.pipe(\n v.optional(v.array(ProtoPolicyActionEnumSchema), []),\n v.transform((v) => v.map((action) => policyActionLabelFor(action))),\n ),\n isTemplate: v.optional(v.boolean(), false),\n sourceTemplateId: OptionalPublicIdSchema,\n maxOrderNotional: v.pipe(\n v.bigint(),\n v.transform((v) => Number(v)),\n ),\n maxOpenOrders: v.number(),\n tradingHalted: v.boolean(),\n locked: v.boolean(),\n reviewAt: OptionalTimestampMsSchema,\n expiresAt: OptionalTimestampMsSchema,\n createdAt: TimestampMsSchema,\n updatedAt: TimestampSchema,\n revision: BigIntStringSchema,\n }),\n v.transform(({ maxOrderNotional, updatedAt, ...rest }) => ({\n maxOrderSize: maxOrderNotional,\n ...rest,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n })),\n);\n\nexport type SubaccountPolicy = v.InferOutput<typeof SubaccountPolicySchema>;\n\nconst SubaccountPolicyInputBaseSchema = v.strictObject({\n name: v.string(),\n description: v.optional(v.string(), \"\"),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n PolicyMarketScopeEnumSchema,\n v.transform((v) => PolicyMarketScopeCodec.inputToProto[v]),\n ),\n actions: v.pipe(\n v.optional(v.array(PolicyActionEnumSchema), []),\n v.transform((v) => (v ?? []).map((action) => PolicyActionCodec.inputToProto[action])),\n ),\n maxOrderSize: OptionalNumberToBigIntOrZeroSchema,\n maxOpenOrders: OptionalNumberToIntOrZeroSchema,\n tradingHalted: v.optional(v.boolean(), false),\n policyLocked: v.optional(v.boolean(), false),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n subaccountId: optionalSubaccountIdInputSchema(),\n});\n\nfunction timestampFromMs(value: number | null | undefined) {\n if (value == null) return undefined;\n return toTimestamp({\n seconds: BigInt(Math.floor(value / 1000)),\n nanos: (value % 1000) * 1_000_000,\n });\n}\n\nfunction createSubaccountPolicyBaseTransform(\n input: v.InferOutput<typeof SubaccountPolicyInputBaseSchema>,\n) {\n const {\n subaccountId: _subaccountId,\n reviewAt,\n expiresAt,\n maxOrderSize,\n policyLocked,\n ...rest\n } = input;\n return {\n ...rest,\n maxOrderNotional: maxOrderSize,\n locked: policyLocked,\n reviewAt: timestampFromMs(reviewAt),\n expiresAt: timestampFromMs(expiresAt),\n };\n}\n\nexport const CreateSubaccountPolicyInputSchema = v.pipe(\n SubaccountPolicyInputBaseSchema,\n v.transform((input) => ({\n policy: createSubaccountPolicyBaseTransform(input),\n subaccountId: input.subaccountId,\n })),\n);\nexport type SubaccountPolicyCreateInput = v.InferInput<typeof CreateSubaccountPolicyInputSchema>;\n\nconst SubaccountPolicyPatchSchema = v.strictObject({\n name: v.optional(v.string()),\n description: v.optional(v.string()),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema)),\n spotMarketScope: v.optional(PolicyMarketScopeEnumSchema),\n actions: v.optional(v.array(PolicyActionEnumSchema)),\n maxOrderSize: v.optional(v.nullable(v.number())),\n maxOpenOrders: v.optional(v.nullable(v.number())),\n tradingHalted: v.optional(v.boolean()),\n policyLocked: v.optional(v.boolean()),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n});\n\ntype SubaccountPolicyPatch = v.InferOutput<typeof SubaccountPolicyPatchSchema>;\n\nconst SUBACCOUNT_POLICY_PATCH_FIELDS = defineProtoPatchFields<SubaccountPolicyPatch>()({\n name: { path: \"name\", encode: (name) => ({ name }) },\n description: { path: \"description\", encode: (description) => ({ description }) },\n spotMarkets: { path: \"spot_markets\", encode: (spotMarkets) => ({ spotMarkets }) },\n spotMarketScope: {\n path: \"spot_market_scope\",\n encode: (scope) => ({ spotMarketScope: PolicyMarketScopeCodec.inputToProto[scope] }),\n },\n actions: {\n path: \"actions\",\n encode: (actions) => ({\n actions: actions.map((action) => PolicyActionCodec.inputToProto[action]),\n }),\n },\n maxOrderSize: {\n path: \"max_order_notional\",\n encode: (value) => ({ maxOrderNotional: toBigIntOrZero(value) }),\n },\n maxOpenOrders: {\n path: \"max_open_orders\",\n encode: (value) => ({ maxOpenOrders: toIntOrZero(value) }),\n },\n tradingHalted: {\n path: \"trading_halted\",\n encode: (tradingHalted) => ({ tradingHalted }),\n },\n policyLocked: { path: \"locked\", encode: (locked) => ({ locked }) },\n reviewAt: {\n path: \"review_at\",\n encode: (reviewAt) => {\n const timestamp = timestampFromMs(reviewAt);\n return timestamp === undefined ? {} : { reviewAt: timestamp };\n },\n },\n expiresAt: {\n path: \"expires_at\",\n encode: (expiresAt) => {\n const timestamp = timestampFromMs(expiresAt);\n return timestamp === undefined ? {} : { expiresAt: timestamp };\n },\n },\n});\n\nexport const UpdateSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n ...SubaccountPolicyPatchSchema.entries,\n policyId: v.pipe(\n v.string(),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n ),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n }),\n v.check(\n ({ policyId: _policyId, expectedRevision: _expectedRevision, ...patch }) =>\n Object.values(patch).some((value) => value !== undefined),\n \"At least one subaccount policy field must be provided\",\n ),\n v.transform(({ policyId, expectedRevision, ...patch }) => {\n const { patch: policy, updateMask } = buildProtoPatch(\n patch,\n SUBACCOUNT_POLICY_PATCH_FIELDS,\n );\n return {\n policyId,\n policy,\n updateMask,\n expectedRevision,\n };\n }),\n);\nexport type SubaccountPolicyUpdateInput = v.InferInput<typeof UpdateSubaccountPolicyInputSchema>;\n\nexport const PolicyIdSchema = v.pipe(\n v.string(),\n v.trim(),\n v.minLength(1),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n);\n\nexport const ApplySubaccountPolicyInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n policyId: v.pipe(\n v.nullable(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"policyId\") : undefined)),\n ),\n});\n\nexport type SubaccountPolicyApplyInput = v.InferInput<typeof ApplySubaccountPolicyInputSchema>;\n\nconst DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT = Date.now();\n\nexport const DEFAULT_SUBACCOUNT_POLICY: SubaccountPolicy = {\n id: \"\",\n name: \"Subaccount Policy\",\n description: \"Subaccount Policy description\",\n spotMarkets: [],\n spotMarketScope: \"all\",\n actions: [\"read-balances\", \"read-internal-transfers\", \"read-address-book\", \"read-spot\"],\n maxOrderSize: 0,\n maxOpenOrders: 0,\n tradingHalted: false,\n createdAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAtNs: (BigInt(DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT) * 1_000_000n).toString(),\n isTemplate: false,\n sourceTemplateId: undefined,\n locked: false,\n reviewAt: undefined,\n expiresAt: undefined,\n revision: \"0\",\n};\n"],"mappings":";;;;;;;;;;;AAqCA,MAAa,oCAAoC,EAAE,KAC/C,EAAE,aAAa,wBAAwB,GACvC,EAAE,WAAW,EAAE,eAAe,EAC1B,cAAc,2BAA2B,OAAO,EACpD,EAAE,CACN;AAIA,MAAa,iCAAiC,EAAE,KAC5C,EAAE,aAAa;CACX,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;CACrD,GAAG;AACP,CAAC,GACD,EAAE,WAAW,EAAE,UAAU,eAAe;CACpC,UAAU,WAAW,UAAU,UAAU;CACzC,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;;;;AAOA,MAAa,yBAAyB,EAAE,KACpC,EAAE,OAAO;CACL,IAAI;CACJ,MAAM,EAAE,OAAO;CACf,aAAa,EAAE,OAAO;CACtB,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,GAAG,CAAC,CAAC;CACzD,iBAAiB,EAAE,KACf,kCACA,EAAE,WAAW,MAAM,0BAA0B,CAAC,CAAC,CACnD;CACA,SAAS,EAAE,KACP,EAAE,SAAS,EAAE,MAAM,2BAA2B,GAAG,CAAC,CAAC,GACnD,EAAE,WAAW,MAAM,EAAE,KAAK,WAAW,qBAAqB,MAAM,CAAC,CAAC,CACtE;CACA,YAAY,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;CACzC,kBAAkB;CAClB,kBAAkB,EAAE,KAChB,E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AAE,UAAU,kBAAkB,GAAG,YAAY;CACtD,MAAM,EAAE,OAAO,QAAQ,eAAe,gBAClC,OACA,8BACJ;CACA,OAAO;EACH;EACA;EACA;EACA;CACJ;AACJ,CAAC,CACL;AAGA,MAAa,iBAAiB,EAAE,KAC5B,EAAE,OAAO,GACT,EAAE,KAAK,GACP,EAAE,UAAU,CAAC,GACb,EAAE,WAAW,MAAM,WAAW,GAAG,UAAU,CAAC,CAChD;AAEA,MAAa,mCAAmC,EAAE,aAAa;CAC3D,cAAc,cAAc,cAAc;CAC1C,UAAU,EAAE,KACR,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,CAAC,GACvC,EAAE,WAAW,UAAW,QAAQ,WAAW,OAAO,UAAU,IAAI,KAAA,CAAU,CAC9E;AACJ,CAAC;AAID,MAAM,uCAAuC,KAAK,IAAI;AAEtD,MAAa,4BAA8C;CACvD,IAAI;CACJ,MAAM;CACN,aAAa;CACb,aAAa,CAAC;CACd,iBAAiB;CACjB,SAAS;EAAC;EAAiB;EAA2B;EAAqB;CAAW;CACtF,cAAc;CACd,eAAe;CACf,eAAe;CACf,WAAW;CACX,WAAW;CACX,cAAc,OAAO,oCAAoC,IAAI,SAAA,CAAY,SAAS;CAClF,YAAY;CACZ,kBAAkB,KAAA;CAClB,QAAQ;CACR,UAAU,KAAA;CACV,WAAW,KAAA;CACX,UAAU;AACd"}
@@ -42,11 +42,19 @@ type SocialVerification = Omit<SocialVerificationBase, "provider" | "method" | "
42
42
  method: DecodedEnum<SocialVerificationMethod>;
43
43
  status: DecodedEnum<SocialVerificationStatus>;
44
44
  };
45
- declare const StartVerificationInputSchema: v.StrictObjectSchema<{
45
+ declare const StartVerificationInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
46
46
  readonly provider: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["twitter", "discord"], undefined>, v.TransformAction<"twitter" | "discord", SocialProvider$1.TWITTER | SocialProvider$1.DISCORD>]>;
47
47
  readonly handle: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 64, undefined>]>;
48
48
  readonly method: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["profile", "channel", "dm"], undefined>, "profile">, v.TransformAction<"profile" | "channel" | "dm", SocialVerificationMethod$1.METHOD_PROFILE | SocialVerificationMethod$1.METHOD_CHANNEL | SocialVerificationMethod$1.METHOD_DM>]>;
49
- }, undefined>;
49
+ }, undefined>, v.CheckAction<{
50
+ provider: SocialProvider$1.TWITTER | SocialProvider$1.DISCORD;
51
+ handle: string;
52
+ method: SocialVerificationMethod$1.METHOD_PROFILE | SocialVerificationMethod$1.METHOD_CHANNEL | SocialVerificationMethod$1.METHOD_DM;
53
+ }, "Handle must not contain '<' or '>'">, v.CheckAction<{
54
+ provider: SocialProvider$1.TWITTER | SocialProvider$1.DISCORD;
55
+ handle: string;
56
+ method: SocialVerificationMethod$1.METHOD_PROFILE | SocialVerificationMethod$1.METHOD_CHANNEL | SocialVerificationMethod$1.METHOD_DM;
57
+ }, "Twitter handle must be 1-15 letters, digits, or underscores">]>;
50
58
  type StartVerificationInput = v.InferInput<typeof StartVerificationInputSchema>;
51
59
  declare const SocialProviderInputSchema: v.StrictObjectSchema<{
52
60
  readonly provider: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["twitter", "discord"], undefined>, v.TransformAction<"twitter" | "discord", SocialProvider$1.TWITTER | SocialProvider$1.DISCORD>]>;
@@ -1 +1 @@
1
- {"version":3,"file":"social-verification.schemas.d.ts","names":[],"sources":["../../../src/services/social-verification/social-verification.schemas.ts"],"mappings":";;;;;cAoBa,sBAAoB,EAAA;KACrB,iBAAiB,EAAE,kBAAkB;cAEpC,gCAA8B,EAAA;KAC/B,2BAA2B,EAAE,kBAAkB;cAE9C,gCAA8B,EAAA;KAC/B,2BAA2B,EAAE,mBAAmB;cA6C/C,0BAAwB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgBhC,yBAAyB,EAAE,mBAAmB;KACvC,qBAAqB,KAAK;EAClC,UAAU,YAAY;EACtB,QAAQ,YAAY;EACpB,QAAQ,YAAY;;cAGX,8BAA4B,EAAA;;;;;KAY7B,yBAAyB,EAAE,kBAAkB;cAO5C,2BAAyB,EAAA;;;KAI1B,sBAAsB,EAAE,kBAAkB;cAEzC,iCAA+B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;KAahC,4BAA4B,EAAE,mBAAmB;cAEhD,iCAA+B,EAAA,yBAAA,EAAA;;;;;;;KAShC,4BAA4B,EAAE,mBAAmB;cAEhD,+BAA6B,EAAA,yBAAA,EAAA;;;;;;;KAS9B,0BAA0B,EAAE,mBAAmB"}
1
+ {"version":3,"file":"social-verification.schemas.d.ts","names":[],"sources":["../../../src/services/social-verification/social-verification.schemas.ts"],"mappings":";;;;;cAoBa,sBAAoB,EAAA;KACrB,iBAAiB,EAAE,kBAAkB;cAEpC,gCAA8B,EAAA;KAC/B,2BAA2B,EAAE,kBAAkB;cAE9C,gCAA8B,EAAA;KAC/B,2BAA2B,EAAE,mBAAmB;cA+C/C,0BAAwB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgBhC,yBAAyB,EAAE,mBAAmB;KACvC,qBAAqB,KAAK;EAClC,UAAU,YAAY;EACtB,QAAQ,YAAY;EACpB,QAAQ,YAAY;;cAGX,8BAA4B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;KAoB7B,yBAAyB,EAAE,kBAAkB;cAO5C,2BAAyB,EAAA;;;KAI1B,sBAAsB,EAAE,kBAAkB;cAEzC,iCAA+B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;KAahC,4BAA4B,EAAE,mBAAmB;cAEhD,iCAA+B,EAAA,yBAAA,EAAA;;;;;;;KAShC,4BAA4B,EAAE,mBAAmB;cAEhD,+BAA6B,EAAA,yBAAA,EAAA;;;;;;;KAS9B,0BAA0B,EAAE,mBAAmB"}
@@ -1,5 +1,6 @@
1
1
  import { requiredEnumLabel } from "../../shared/proto-enum-codec.js";
2
2
  import { TimestampSchema } from "../../shared/schemas.js";
3
+ import "../../gen/auth/v1/social_verification_pb.js";
3
4
  import { SOCIAL_PROVIDER_VALUES, SOCIAL_VERIFICATION_METHOD_VALUES, SOCIAL_VERIFICATION_STATUS_VALUES, SocialProviderCodec, SocialVerificationMethodCodec, SocialVerificationStatusCodec } from "./social-verification.codecs.js";
4
5
  import * as v from "valibot";
5
6
  //#region src/services/social-verification/social-verification.schemas.ts
@@ -9,6 +10,7 @@ const SocialVerificationStatusSchema = v.picklist(SOCIAL_VERIFICATION_STATUS_VAL
9
10
  function normalizeHandle(input) {
10
11
  return (input ?? "").trim().replace(/^@+/, "");
11
12
  }
13
+ const TWITTER_HANDLE_PATTERN = /^[A-Za-z0-9_]{1,15}$/;
12
14
  /**
13
15
  * Normalizes a social verification response into the SDK verification shape.
14
16
  */
@@ -45,11 +47,11 @@ v.object({
45
47
  lastError: v.string(),
46
48
  updatedAt: v.optional(TimestampSchema)
47
49
  });
48
- const StartVerificationInputSchema = v.strictObject({
50
+ const StartVerificationInputSchema = v.pipe(v.strictObject({
49
51
  provider: v.pipe(SocialProviderSchema, v.transform((v) => SocialProviderCodec.inputToProto[v])),
50
52
  handle: v.pipe(v.string(), v.transform(normalizeHandle), v.minLength(1), v.maxLength(64)),
51
53
  method: v.pipe(v.optional(SocialVerificationMethodSchema, "profile"), v.transform((v) => SocialVerificationMethodCodec.inputToProto[v ?? "profile"]))
52
- });
54
+ }), v.check(({ handle }) => !/[<>]/.test(handle), "Handle must not contain '<' or '>'"), v.check(({ provider, handle }) => provider !== 1 || TWITTER_HANDLE_PATTERN.test(handle), "Twitter handle must be 1-15 letters, digits, or underscores"));
53
55
  const ProviderInputSchema = v.pipe(SocialProviderSchema, v.transform((v) => SocialProviderCodec.inputToProto[v]));
54
56
  const SocialProviderInputSchema = v.strictObject({ provider: ProviderInputSchema });
55
57
  const StartVerificationResponseSchema = v.pipe(v.object({
@@ -1 +1 @@
1
- {"version":3,"file":"social-verification.schemas.js","names":[],"sources":["../../../src/services/social-verification/social-verification.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { TimestampSchema } from \"../../shared/schemas.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport type { DecodedEnum } from \"../../utils/types.js\";\nimport type * as Proto from \"../../gen/auth/v1/social_verification_pb.js\";\nimport {\n SOCIAL_PROVIDER_VALUES,\n SOCIAL_VERIFICATION_METHOD_VALUES,\n SOCIAL_VERIFICATION_STATUS_VALUES,\n SocialProviderCodec,\n SocialVerificationMethodCodec,\n SocialVerificationStatusCodec,\n} from \"./social-verification.codecs.js\";\n\nexport {\n SOCIAL_PROVIDER_VALUES,\n SOCIAL_VERIFICATION_METHOD_VALUES,\n SOCIAL_VERIFICATION_STATUS_VALUES,\n} from \"./social-verification.codecs.js\";\n\nexport const SocialProviderSchema = v.picklist(SOCIAL_PROVIDER_VALUES);\nexport type SocialProvider = v.InferInput<typeof SocialProviderSchema>;\n\nexport const SocialVerificationMethodSchema = v.picklist(SOCIAL_VERIFICATION_METHOD_VALUES);\nexport type SocialVerificationMethod = v.InferInput<typeof SocialVerificationMethodSchema>;\n\nexport const SocialVerificationStatusSchema = v.picklist(SOCIAL_VERIFICATION_STATUS_VALUES);\nexport type SocialVerificationStatus = v.InferOutput<typeof SocialVerificationStatusSchema>;\n\nfunction normalizeHandle(input: string): string {\n return (input ?? \"\").trim().replace(/^@+/, \"\");\n}\n\n/**\n * Normalizes a social verification response into the SDK verification shape.\n */\nexport function transformVerification(\n v: Proto.SocialVerification | undefined,\n): SocialVerification | undefined {\n if (!v) return undefined;\n return {\n id: v.id,\n provider: requiredEnumLabel(\n SocialProviderCodec.protoToOutput,\n v.provider,\n \"SocialVerificationSchema\",\n \"provider\",\n ),\n method: requiredEnumLabel(\n SocialVerificationMethodCodec.protoToOutput,\n v.method,\n \"SocialVerificationSchema\",\n \"method\",\n ),\n handle: v.handle,\n providerUserId: v.providerUserId,\n challengeCode: v.challengeCode,\n status: requiredEnumLabel(\n SocialVerificationStatusCodec.protoToOutput,\n v.status,\n \"SocialVerificationSchema\",\n \"status\",\n ),\n requestedAt: v.requestedAt,\n expiresAt: v.expiresAt,\n verifiedAt: v.verifiedAt,\n attempts: v.attempts,\n lastError: v.lastError,\n updatedAt: v.updatedAt,\n };\n}\n\nexport const SocialVerificationSchema = v.object({\n id: v.bigint(),\n provider: SocialProviderSchema,\n method: SocialVerificationMethodSchema,\n handle: v.string(),\n providerUserId: v.string(),\n challengeCode: v.string(),\n status: SocialVerificationStatusSchema,\n requestedAt: v.optional(TimestampSchema),\n expiresAt: v.optional(TimestampSchema),\n verifiedAt: v.optional(TimestampSchema),\n attempts: v.number(),\n lastError: v.string(),\n updatedAt: v.optional(TimestampSchema),\n});\n\ntype SocialVerificationBase = v.InferOutput<typeof SocialVerificationSchema>;\nexport type SocialVerification = Omit<SocialVerificationBase, \"provider\" | \"method\" | \"status\"> & {\n provider: DecodedEnum<SocialProvider>;\n method: DecodedEnum<SocialVerificationMethod>;\n status: DecodedEnum<SocialVerificationStatus>;\n};\n\nexport const StartVerificationInputSchema = v.strictObject({\n provider: v.pipe(\n SocialProviderSchema,\n v.transform((v) => SocialProviderCodec.inputToProto[v]),\n ),\n handle: v.pipe(v.string(), v.transform(normalizeHandle), v.minLength(1), v.maxLength(64)),\n method: v.pipe(\n v.optional(SocialVerificationMethodSchema, \"profile\"),\n v.transform((v) => SocialVerificationMethodCodec.inputToProto[v ?? \"profile\"]),\n ),\n});\n\nexport type StartVerificationInput = v.InferInput<typeof StartVerificationInputSchema>;\n\nexport const ProviderInputSchema = v.pipe(\n SocialProviderSchema,\n v.transform((v) => SocialProviderCodec.inputToProto[v]),\n);\n\nexport const SocialProviderInputSchema = v.strictObject({\n provider: ProviderInputSchema,\n});\n\nexport type SocialProviderInput = v.InferInput<typeof SocialProviderInputSchema>;\n\nexport const StartVerificationResponseSchema = v.pipe(\n v.object({\n challengeCode: v.string(),\n expiresAt: v.optional(TimestampSchema),\n verification: v.optional(v.custom<Proto.SocialVerification>(() => true)),\n }),\n v.transform((res) => ({\n challengeCode: res.challengeCode,\n expiresAt: res.expiresAt,\n verification: transformVerification(res.verification),\n })),\n);\n\nexport type StartVerificationResponse = v.InferOutput<typeof StartVerificationResponseSchema>;\n\nexport const VerificationReadyResponseSchema = v.pipe(\n v.object({\n verification: v.optional(v.custom<Proto.SocialVerification>(() => true)),\n }),\n v.transform((res) => ({\n verification: transformVerification(res.verification),\n })),\n);\n\nexport type VerificationReadyResponse = v.InferOutput<typeof VerificationReadyResponseSchema>;\n\nexport const GetVerificationResponseSchema = v.pipe(\n v.object({\n verification: v.optional(v.custom<Proto.SocialVerification>(() => true)),\n }),\n v.transform((res) => ({\n verification: transformVerification(res.verification),\n })),\n);\n\nexport type GetVerificationResponse = v.InferOutput<typeof GetVerificationResponseSchema>;\n"],"mappings":";;;;;AAoBA,MAAa,uBAAuB,EAAE,SAAS,sBAAsB;AAGrE,MAAa,iCAAiC,EAAE,SAAS,iCAAiC;AAG1F,MAAa,iCAAiC,EAAE,SAAS,iCAAiC;AAG1F,SAAS,gBAAgB,OAAuB;CAC5C,QAAQ,SAAS,GAAA,CAAI,KAAK,CAAC,CAAC,QAAQ,OAAO,EAAE;AACjD;;;;AAKA,SAAgB,sBACZ,GAC8B;CAC9B,IAAI,CAAC,GAAG,OAAO,KAAA;CACf,OAAO;EACH,IAAI,EAAE;EACN,UAAU,kBACN,oBAAoB,eACpB,EAAE,UACF,4BACA,UACJ;EACA,QAAQ,kBACJ,8BAA8B,eAC9B,EAAE,QACF,4BACA,QACJ;EACA,QAAQ,EAAE;EACV,gBAAgB,EAAE;EAClB,eAAe,EAAE;EACjB,QAAQ,kBACJ,8BAA8B,eAC9B,EAAE,QACF,4BACA,QACJ;EACA,aAAa,EAAE;EACf,WAAW,EAAE;EACb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aAAuC,IAAI,CAAC,EAC3E,CAAC,GACD,EAAE,WAAW,SAAS,EAClB,cAAc,sBAAsB,IAAI,YAAY,EACxD,EAAE,CACN;AAIA,MAAa,gCAAgC,EAAE,KAC3C,EAAE,OAAO,EACL,cAAc,EAAE,SAAS,EAAE,aAAuC,IAAI,CAAC,EAC3E,CAAC,GACD,EAAE,WAAW,SAAS,EAClB,cAAc,sBAAsB,IAAI,YAAY,EACxD,EAAE,CACN"}
1
+ {"version":3,"file":"social-verification.schemas.js","names":[],"sources":["../../../src/services/social-verification/social-verification.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { TimestampSchema } from \"../../shared/schemas.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport type { DecodedEnum } from \"../../utils/types.js\";\nimport * as Proto from \"../../gen/auth/v1/social_verification_pb.js\";\nimport {\n SOCIAL_PROVIDER_VALUES,\n SOCIAL_VERIFICATION_METHOD_VALUES,\n SOCIAL_VERIFICATION_STATUS_VALUES,\n SocialProviderCodec,\n SocialVerificationMethodCodec,\n SocialVerificationStatusCodec,\n} from \"./social-verification.codecs.js\";\n\nexport {\n SOCIAL_PROVIDER_VALUES,\n SOCIAL_VERIFICATION_METHOD_VALUES,\n SOCIAL_VERIFICATION_STATUS_VALUES,\n} from \"./social-verification.codecs.js\";\n\nexport const SocialProviderSchema = v.picklist(SOCIAL_PROVIDER_VALUES);\nexport type SocialProvider = v.InferInput<typeof SocialProviderSchema>;\n\nexport const SocialVerificationMethodSchema = v.picklist(SOCIAL_VERIFICATION_METHOD_VALUES);\nexport type SocialVerificationMethod = v.InferInput<typeof SocialVerificationMethodSchema>;\n\nexport const SocialVerificationStatusSchema = v.picklist(SOCIAL_VERIFICATION_STATUS_VALUES);\nexport type SocialVerificationStatus = v.InferOutput<typeof SocialVerificationStatusSchema>;\n\nfunction normalizeHandle(input: string): string {\n return (input ?? \"\").trim().replace(/^@+/, \"\");\n}\n\nconst TWITTER_HANDLE_PATTERN = /^[A-Za-z0-9_]{1,15}$/;\n\n/**\n * Normalizes a social verification response into the SDK verification shape.\n */\nexport function transformVerification(\n v: Proto.SocialVerification | undefined,\n): SocialVerification | undefined {\n if (!v) return undefined;\n return {\n id: v.id,\n provider: requiredEnumLabel(\n SocialProviderCodec.protoToOutput,\n v.provider,\n \"SocialVerificationSchema\",\n \"provider\",\n ),\n method: requiredEnumLabel(\n SocialVerificationMethodCodec.protoToOutput,\n v.method,\n \"SocialVerificationSchema\",\n \"method\",\n ),\n handle: v.handle,\n providerUserId: v.providerUserId,\n challengeCode: v.challengeCode,\n status: requiredEnumLabel(\n SocialVerificationStatusCodec.protoToOutput,\n v.status,\n \"SocialVerificationSchema\",\n \"status\",\n ),\n requestedAt: v.requestedAt,\n expiresAt: v.expiresAt,\n verifiedAt: v.verifiedAt,\n attempts: v.attempts,\n lastError: v.lastError,\n updatedAt: v.updatedAt,\n };\n}\n\nexport const SocialVerificationSchema = v.object({\n id: v.bigint(),\n provider: SocialProviderSchema,\n method: SocialVerificationMethodSchema,\n handle: v.string(),\n providerUserId: v.string(),\n challengeCode: v.string(),\n status: SocialVerificationStatusSchema,\n requestedAt: v.optional(TimestampSchema),\n expiresAt: v.optional(TimestampSchema),\n verifiedAt: v.optional(TimestampSchema),\n attempts: v.number(),\n lastError: v.string(),\n updatedAt: v.optional(TimestampSchema),\n});\n\ntype SocialVerificationBase = v.InferOutput<typeof SocialVerificationSchema>;\nexport type SocialVerification = Omit<SocialVerificationBase, \"provider\" | \"method\" | \"status\"> & {\n provider: DecodedEnum<SocialProvider>;\n method: DecodedEnum<SocialVerificationMethod>;\n status: DecodedEnum<SocialVerificationStatus>;\n};\n\nexport const StartVerificationInputSchema = v.pipe(\n v.strictObject({\n provider: v.pipe(\n SocialProviderSchema,\n v.transform((v) => SocialProviderCodec.inputToProto[v]),\n ),\n handle: v.pipe(v.string(), v.transform(normalizeHandle), v.minLength(1), v.maxLength(64)),\n method: v.pipe(\n v.optional(SocialVerificationMethodSchema, \"profile\"),\n v.transform((v) => SocialVerificationMethodCodec.inputToProto[v ?? \"profile\"]),\n ),\n }),\n v.check(({ handle }) => !/[<>]/.test(handle), \"Handle must not contain '<' or '>'\"),\n v.check(\n ({ provider, handle }) =>\n provider !== Proto.SocialProvider.TWITTER || TWITTER_HANDLE_PATTERN.test(handle),\n \"Twitter handle must be 1-15 letters, digits, or underscores\",\n ),\n);\n\nexport type StartVerificationInput = v.InferInput<typeof StartVerificationInputSchema>;\n\nexport const ProviderInputSchema = v.pipe(\n SocialProviderSchema,\n v.transform((v) => SocialProviderCodec.inputToProto[v]),\n);\n\nexport const SocialProviderInputSchema = v.strictObject({\n provider: ProviderInputSchema,\n});\n\nexport type SocialProviderInput = v.InferInput<typeof SocialProviderInputSchema>;\n\nexport const StartVerificationResponseSchema = v.pipe(\n v.object({\n challengeCode: v.string(),\n expiresAt: v.optional(TimestampSchema),\n verification: v.optional(v.custom<Proto.SocialVerification>(() => true)),\n }),\n v.transform((res) => ({\n challengeCode: res.challengeCode,\n expiresAt: res.expiresAt,\n verification: transformVerification(res.verification),\n })),\n);\n\nexport type StartVerificationResponse = v.InferOutput<typeof StartVerificationResponseSchema>;\n\nexport const VerificationReadyResponseSchema = v.pipe(\n v.object({\n verification: v.optional(v.custom<Proto.SocialVerification>(() => true)),\n }),\n v.transform((res) => ({\n verification: transformVerification(res.verification),\n })),\n);\n\nexport type VerificationReadyResponse = v.InferOutput<typeof VerificationReadyResponseSchema>;\n\nexport const GetVerificationResponseSchema = v.pipe(\n v.object({\n verification: v.optional(v.custom<Proto.SocialVerification>(() => true)),\n }),\n v.transform((res) => ({\n verification: transformVerification(res.verification),\n })),\n);\n\nexport type GetVerificationResponse = v.InferOutput<typeof GetVerificationResponseSchema>;\n"],"mappings":";;;;;;AAoBA,MAAa,uBAAuB,EAAE,SAAS,sBAAsB;AAGrE,MAAa,iCAAiC,EAAE,SAAS,iCAAiC;AAG1F,MAAa,iCAAiC,EAAE,SAAS,iCAAiC;AAG1F,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J,CAAC,GACD,EAAE,OAAO,EAAE,aAAa,CAAC,OAAO,KAAK,MAAM,GAAG,oCAAoC,GAClF,EAAE,OACG,EAAE,UAAU,aACT,aAAA,KAA6C,uBAAuB,KAAK,MAAM,GACnF,6DACJ,CACJ;AAIA,MAAa,sBAAsB,EAAE,KACjC,sBACA,EAAE,WAAW,MAAM,oBAAoB,aAAa,EAAE,CAC1D;AAEA,MAAa,4BAA4B,EAAE,aAAa,EACpD,UAAU,oBACd,CAAC;AAID,MAAa,kCAAkC,EAAE,KAC7C,EAAE,OAAO;CACL,eAAe,EAAE,OAAO;CACxB,WAAW,EAAE,SAAS,eAAe;CACrC,cAAc,EAAE,SAAS,EAAE,aAAuC,IAAI,CAAC;AAC3E,CAAC,GACD,EAAE,WAAW,SAAS;CAClB,eAAe,IAAI;CACnB,WAAW,IAAI;CACf,cAAc,sBAAsB,IAAI,YAAY;AACxD,EAAE,CACN;AAIA,MAAa,kCAAkC,EAAE,KAC7C,EAAE,OAAO,EACL,cAAc,EAAE,SAAS,EAAE,aAAuC,IAAI,CAAC,EAC3E,CAAC,GACD,EAAE,WAAW,SAAS,EAClB,cAAc,sBAAsB,IAAI,YAAY,EACxD,EAAE,CACN;AAIA,MAAa,gCAAgC,EAAE,KAC3C,EAAE,OAAO,EACL,cAAc,EAAE,SAAS,EAAE,aAAuC,IAAI,CAAC,EAC3E,CAAC,GACD,EAAE,WAAW,SAAS,EAClB,cAAc,sBAAsB,IAAI,YAAY,EACxD,EAAE,CACN"}
@@ -176,7 +176,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
176
176
  readonly granteeAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
177
177
  readonly inviterAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
178
178
  readonly role: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountRole$1, undefined>, v.TransformAction<SubaccountRole$1, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
179
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountInviteStatus$1, undefined>, v.TransformAction<SubaccountInviteStatus$1, "unspecified" | "pending" | "accepted" | "declined" | "cancelled">]>;
179
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountInviteStatus$1, undefined>, v.TransformAction<SubaccountInviteStatus$1, "unspecified" | "pending" | "cancelled" | "accepted" | "declined">]>;
180
180
  readonly createdAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
181
181
  readonly seconds: v.BigintSchema<undefined>;
182
182
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -203,7 +203,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
203
203
  granteeAccountId: string;
204
204
  inviterAccountId: string;
205
205
  role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
206
- status: "unspecified" | "pending" | "accepted" | "declined" | "cancelled";
206
+ status: "unspecified" | "pending" | "cancelled" | "accepted" | "declined";
207
207
  createdAt?: number | undefined;
208
208
  respondedAt?: number | undefined;
209
209
  granteeUsername: string;
@@ -221,7 +221,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
221
221
  granteeAccountId: string;
222
222
  inviterAccountId: string;
223
223
  role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
224
- status: "unspecified" | "pending" | "accepted" | "declined" | "cancelled";
224
+ status: "unspecified" | "pending" | "cancelled" | "accepted" | "declined";
225
225
  createdAt?: number | undefined;
226
226
  respondedAt?: number | undefined;
227
227
  granteeUsername: string;
@@ -243,8 +243,8 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
243
243
  seconds: bigint;
244
244
  nanos: number;
245
245
  } | undefined, number | undefined>]>;
246
- readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "member" | "policy" | "invite" | "security">]>;
247
- readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "deleted" | "created" | "updated" | "removed" | "role_set" | "received" | "replied" | "failed" | "revoked" | "blocked" | "hold_placed" | "hold_released">]>;
246
+ readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "policy" | "member" | "invite" | "security">]>;
247
+ readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "revoked" | "failed" | "deleted" | "created" | "updated" | "removed" | "role_set" | "received" | "replied" | "blocked" | "hold_placed" | "hold_released">]>;
248
248
  readonly source: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventSource, undefined>, v.TransformAction<ActivityEventSource, "unspecified" | "web" | "mobile" | "api">]>;
249
249
  readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
250
250
  readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -787,8 +787,8 @@ type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInpu
787
787
  declare const ListTriggersInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
788
788
  readonly parentOrderId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
789
789
  readonly symbol: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>;
790
- 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)[]>]>;
791
- 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>]>;
790
+ readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("completed" | "failed" | "cancelled" | "created" | "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)[]>]>;
791
+ readonly triggerType: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["stop_loss", "take_profit", "trailing_stop", "twap", "ladder"], undefined>, undefined>, v.TransformAction<"stop_loss" | "take_profit" | "trailing_stop" | "twap" | "ladder" | undefined, TriggerType>]>;
792
792
  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>;
793
793
  readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
794
794
  readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
@@ -860,21 +860,25 @@ declare const PauseTriggerInputSchema: v.SchemaWithPipe<readonly [v.StrictObject
860
860
  }>]>;
861
861
  type PauseTriggerInput = v.InferInput<typeof PauseTriggerInputSchema>;
862
862
  declare const ResumeTriggerInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
863
- account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
863
+ readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
864
+ readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
864
865
  readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
865
866
  }, undefined>], undefined>, undefined>;
866
- triggerId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
867
+ readonly triggerId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
867
868
  }, undefined>, v.TransformAction<{
869
+ symbolId: number;
868
870
  account?: "active" | "main" | {
869
871
  subaccountId: string;
870
872
  } | undefined;
871
873
  triggerId: bigint;
872
874
  }, {
873
875
  subaccountId: bigint | undefined;
876
+ symbolId: number;
874
877
  triggerId: bigint;
875
878
  }>]>;
876
879
  type ResumeTriggerInput = v.InferInput<typeof ResumeTriggerInputSchema>;
877
880
  declare function createModifyTriggerInputSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
881
+ readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
878
882
  readonly triggerPrice: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>, undefined>;
879
883
  readonly limitPrice: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>, undefined>;
880
884
  readonly trailingDistance: v.OptionalSchema<v.UnionSchema<[v.StrictObjectSchema<{
@@ -899,6 +903,7 @@ declare function createModifyTriggerInputSchema(scales: SdkScales): v.SchemaWith
899
903
  }, undefined>], undefined>, undefined>;
900
904
  readonly triggerId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
901
905
  }, undefined>, v.CheckAction<{
906
+ symbolId: number;
902
907
  triggerPrice?: string | undefined;
903
908
  limitPrice?: string | undefined;
904
909
  trailingDistance?: {
@@ -923,6 +928,7 @@ declare function createModifyTriggerInputSchema(scales: SdkScales): v.SchemaWith
923
928
  } | undefined;
924
929
  triggerId: bigint;
925
930
  }, "At least one patch field is required">, v.TransformAction<{
931
+ symbolId: number;
926
932
  triggerPrice?: string | undefined;
927
933
  limitPrice?: string | undefined;
928
934
  trailingDistance?: {
@@ -949,6 +955,7 @@ declare function createModifyTriggerInputSchema(scales: SdkScales): v.SchemaWith
949
955
  }, {
950
956
  triggerId: bigint;
951
957
  subaccountId: bigint | undefined;
958
+ symbolId: number;
952
959
  triggerPriceTicks: bigint | undefined;
953
960
  limitPriceTicks: bigint | undefined;
954
961
  trailingDistance: {
@@ -982,7 +989,7 @@ declare function createModifyTriggerInputSchema(scales: SdkScales): v.SchemaWith
982
989
  type ModifyTriggerInput = v.InferInput<ReturnType<typeof createModifyTriggerInputSchema>>;
983
990
  declare const ListTriggerEventsInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
984
991
  readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 1000, undefined>]>, undefined>;
985
- readonly eventType: v.OptionalSchema<v.PicklistSchema<readonly ["fired", "canceled", "updated"], undefined>, undefined>;
992
+ readonly eventType: v.OptionalSchema<v.PicklistSchema<readonly ["fired", "canceled", "updated", "failed"], undefined>, undefined>;
986
993
  readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
987
994
  readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
988
995
  readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
@@ -990,7 +997,7 @@ declare const ListTriggerEventsInputSchema: v.SchemaWithPipe<readonly [v.StrictO
990
997
  readonly triggerId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
991
998
  }, undefined>, v.TransformAction<{
992
999
  limit?: number | undefined;
993
- eventType?: "updated" | "fired" | "canceled" | undefined;
1000
+ eventType?: "failed" | "updated" | "fired" | "canceled" | undefined;
994
1001
  pageToken: string;
995
1002
  account?: "active" | "main" | {
996
1003
  subaccountId: string;
@@ -998,7 +1005,7 @@ declare const ListTriggerEventsInputSchema: v.SchemaWithPipe<readonly [v.StrictO
998
1005
  triggerId: bigint;
999
1006
  }, {
1000
1007
  subaccountId: bigint | undefined;
1001
- eventType: TriggerEventType.EVENT_FIRED | TriggerEventType.EVENT_CANCELED | TriggerEventType.EVENT_UPDATED | undefined;
1008
+ eventType: TriggerEventType.EVENT_FIRED | TriggerEventType.EVENT_CANCELED | TriggerEventType.EVENT_UPDATED | TriggerEventType.EVENT_FAILED | undefined;
1002
1009
  limit?: number | undefined;
1003
1010
  pageToken: string;
1004
1011
  triggerId: bigint;
@@ -1 +1 @@
1
- {"version":3,"file":"trigger-input.schemas.d.ts","names":[],"sources":["../../../src/services/triggers/trigger-input.schemas.ts"],"mappings":";;;;;iBAyVgB,+BAA+B,QAAQ,YAAS,EAAA,aAAA,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAUpD,qBAAqB,EAAE,WAAW,kBAAkB;cAEnD,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kBAAkB;cAEnD,8BAA4B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;KAiB7B,yBAAyB,EAAE,kBAAkB"}
@@ -4,7 +4,7 @@ import { parseOptionalPositiveIntLike } from "../../utils/numbers.js";
4
4
  import { idInputSchema } from "../../shared/schemas.js";
5
5
  import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
6
6
  import { CatalogConversionError } from "../../catalogs/types.js";
7
- import "../../shared/wire-bounds.js";
7
+ import { PROTOBUF_UINT32_MAX } from "../../shared/wire-bounds.js";
8
8
  import { positiveDecimalInputToScaled } from "../../shared/decimal-surface.js";
9
9
  import { BpsStringOrNumberInputSchema, NoneInputSchema } from "../shared.js";
10
10
  import { OrderSideCodec } from "../orders/order-enums.codecs.js";
@@ -16,8 +16,10 @@ import * as v from "valibot";
16
16
  const TriggerTypeSchema = v.picklist(TRIGGER_TYPE_VALUES);
17
17
  const TriggerStatusFilterSchema = v.picklist(TRIGGER_STATUS_FILTER_VALUES);
18
18
  const TriggerEventTypeSchema = v.picklist(TRIGGER_EVENT_TYPE_VALUES);
19
+ const TriggerIdInputSchema = idInputSchema("triggerId");
20
+ const TriggerSymbolIdInputSchema = v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(PROTOBUF_UINT32_MAX));
19
21
  const TriggerScopedInputEntries = {
20
- triggerId: idInputSchema("triggerId"),
22
+ triggerId: TriggerIdInputSchema,
21
23
  ...AccountScopeInputEntries
22
24
  };
23
25
  const TriggerScopedInputSchema = v.pipe(v.strictObject(TriggerScopedInputEntries), v.transform(({ account, ...input }) => ({
@@ -229,10 +231,17 @@ const ListTriggersInputSchema = v.pipe(v.strictObject({
229
231
  const CancelTriggerInputSchema = TriggerScopedInputSchema;
230
232
  const GetTriggerInputSchema = CancelTriggerInputSchema;
231
233
  const PauseTriggerInputSchema = TriggerScopedInputSchema;
232
- const ResumeTriggerInputSchema = TriggerScopedInputSchema;
234
+ const ResumeTriggerInputSchema = v.pipe(v.strictObject({
235
+ ...TriggerScopedInputEntries,
236
+ symbolId: TriggerSymbolIdInputSchema
237
+ }), v.transform(({ account, ...input }) => ({
238
+ ...input,
239
+ subaccountId: accountScopeToSubaccountId(account)
240
+ })));
233
241
  function createModifyTriggerInputSchema(scales) {
234
242
  return v.pipe(v.strictObject({
235
243
  ...TriggerScopedInputEntries,
244
+ symbolId: TriggerSymbolIdInputSchema,
236
245
  triggerPrice: v.optional(DecimalInputStringSchema),
237
246
  limitPrice: v.optional(DecimalInputStringSchema),
238
247
  trailingDistance: v.optional(TrailingDistanceInputSchema),
@@ -241,6 +250,7 @@ function createModifyTriggerInputSchema(scales) {
241
250
  }), v.check((input) => input.triggerPrice !== void 0 || input.limitPrice !== void 0 || input.trailingDistance !== void 0 || input.activationPrice !== void 0 || input.maxSlippage !== void 0, "At least one patch field is required"), v.transform(({ account, ...input }) => ({
242
251
  triggerId: input.triggerId,
243
252
  subaccountId: accountScopeToSubaccountId(account),
253
+ symbolId: input.symbolId,
244
254
  triggerPriceTicks: input.triggerPrice === void 0 ? void 0 : positiveDecimalInputToScaled("triggerPrice", input.triggerPrice, scales.price()),
245
255
  limitPriceTicks: input.limitPrice === void 0 ? void 0 : positiveDecimalInputToScaled("limitPrice", input.limitPrice, scales.price()),
246
256
  trailingDistance: input.trailingDistance === void 0 ? {
@@ -1 +1 @@
1
- {"version":3,"file":"trigger-input.schemas.js","names":["TriggerSideCodec"],"sources":["../../../src/services/triggers/trigger-input.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/triggers/v1/triggers_pb.js\";\nimport * as ProtoOrders from \"../../gen/orders/v1/orders_pb.js\";\nimport * as v from \"valibot\";\nimport { idInputSchema } from \"../../shared/schemas.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { positiveDecimalInputToScaled, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { CatalogConversionError } from \"../../catalogs/types.js\";\nimport { PROTOBUF_INT32_MAX } from \"../../shared/wire-bounds.js\";\nimport { parseOptionalPositiveIntLike } from \"../../utils/numbers.js\";\nimport { idToBigInt } from \"../../utils/base58-id.js\";\nimport {\n TRIGGER_EVENT_TYPE_VALUES,\n TRIGGER_STATUS_FILTER_VALUES,\n TRIGGER_TYPE_VALUES,\n TriggerEventTypeCodec,\n TriggerSideCodec,\n TriggerTypeCodec,\n TriggerStatusCodec,\n} from \"./triggers.codecs.js\";\nimport { BpsStringOrNumberInputSchema, NoneInputSchema } from \"../shared.js\";\nimport {\n BaseTriggerFieldsSchema,\n ConditionalExecutionInputSchema,\n DecimalInputStringSchema,\n LimitConditionalExecutionInputSchema,\n TriggerSideInputSchema,\n TwapExecutionInputSchema,\n buildConditionalExecution,\n buildTriggerIntentBase,\n buildTwapExecution,\n type MaxSlippageOneof,\n type TrailingDistanceOneof,\n} from \"./trigger-child-order.schemas.js\";\n\nconst TriggerTypeSchema = v.picklist(TRIGGER_TYPE_VALUES);\nconst TriggerStatusFilterSchema = v.picklist(TRIGGER_STATUS_FILTER_VALUES);\nconst TriggerEventTypeSchema = v.picklist(TRIGGER_EVENT_TYPE_VALUES);\nconst TriggerIdInputSchema = idInputSchema(\"triggerId\");\n\nconst TriggerScopedInputEntries = {\n triggerId: TriggerIdInputSchema,\n ...AccountScopeInputEntries,\n};\n\nconst TriggerScopedInputSchema = v.pipe(\n v.strictObject(TriggerScopedInputEntries),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\n/** Absolute price distance, as a decimal price string (e.g. \"0.50\"). */\nconst PriceDistanceInputSchema = v.strictObject({\n kind: v.literal(\"distance\"),\n distance: DecimalInputStringSchema,\n});\n\n/** Absolute price slippage, as a decimal price string (e.g. \"0.25\"). */\nconst PriceSlippageInputSchema = v.strictObject({\n kind: v.literal(\"slippage\"),\n slippage: DecimalInputStringSchema,\n});\n\nconst TrailingDistanceInputSchema = v.union([\n PriceDistanceInputSchema,\n BpsStringOrNumberInputSchema,\n]);\n\nconst MaxSlippageInputSchema = v.union([\n PriceSlippageInputSchema,\n BpsStringOrNumberInputSchema,\n NoneInputSchema,\n]);\n\nfunction parseTrailingDistance(\n scales: SdkScales,\n distance: v.InferOutput<typeof TrailingDistanceInputSchema>,\n): TrailingDistanceOneof {\n if (distance.kind === \"distance\") {\n return {\n case: \"trailingDistanceTicks\",\n value: positiveDecimalInputToScaled(\n \"trailingDistance.distance\",\n distance.distance,\n scales.price(),\n ),\n };\n }\n const bps = parseOptionalPositiveIntLike(distance.bps);\n if (bps === undefined || bps <= 0) {\n throw new Error(\"trailingDistanceBps must be a positive integer\");\n }\n return { case: \"trailingDistanceBps\", value: bps };\n}\n\nfunction parseMaxSlippage(\n scales: SdkScales,\n slippage: v.InferOutput<typeof MaxSlippageInputSchema> | undefined,\n): MaxSlippageOneof {\n if (!slippage || slippage.kind === \"none\") {\n return { case: undefined, value: undefined };\n }\n if (slippage.kind === \"slippage\") {\n const ticks = positiveDecimalInputToScaled(\n \"maxSlippage.slippage\",\n slippage.slippage,\n scales.price(),\n );\n if (ticks > PROTOBUF_INT32_MAX) {\n throw new CatalogConversionError(\n \"maxSlippage.slippage\",\n `maxSlippage.slippage exceeds the maximum supported price distance: ${slippage.slippage}`,\n );\n }\n return { case: \"maxSlippageTicks\", value: Number(ticks) };\n }\n const bps = parseOptionalPositiveIntLike(slippage.bps);\n if (bps === undefined || bps <= 0) {\n throw new Error(\"maxSlippageBps must be a positive integer\");\n }\n return { case: \"maxSlippageBps\", value: bps };\n}\n\nfunction createConditionalTriggerInputSchema<const TriggerType extends \"stop_loss\" | \"take_profit\">(\n scales: SdkScales,\n triggerType: TriggerType,\n) {\n const sharedEntries = {\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(triggerType),\n triggerPrice: DecimalInputStringSchema,\n };\n\n const sellInputSchema = v.strictObject({\n ...sharedEntries,\n side: v.literal(\"sell\"),\n execution: ConditionalExecutionInputSchema,\n });\n const buyInputSchema = v.strictObject({\n ...sharedEntries,\n side: v.literal(\"buy\"),\n execution: LimitConditionalExecutionInputSchema,\n });\n\n function transformInput(\n input: v.InferOutput<typeof sellInputSchema> | v.InferOutput<typeof buyInputSchema>,\n ) {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n const strategy = {\n triggerPriceTicks: positiveDecimalInputToScaled(\n \"triggerPrice\",\n input.triggerPrice,\n scales.price(),\n ),\n side: TriggerSideCodec.inputToProto[input.side],\n child: buildConditionalExecution(input.execution, scales),\n };\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy:\n triggerType === \"stop_loss\"\n ? ({ case: \"stopLoss\", value: strategy } as const)\n : ({ case: \"takeProfit\", value: strategy } as const),\n },\n };\n }\n\n return [\n v.pipe(\n sellInputSchema,\n v.check(\n (input) => input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.transform((input: v.InferOutput<typeof sellInputSchema>) => transformInput(input)),\n ),\n v.pipe(\n buyInputSchema,\n v.transform((input: v.InferOutput<typeof buyInputSchema>) => transformInput(input)),\n ),\n ] as const;\n}\n\nfunction createTrailingStopTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"trailing_stop\"),\n trailingDistance: TrailingDistanceInputSchema,\n activationPrice: v.optional(DecimalInputStringSchema),\n maxSlippage: v.optional(MaxSlippageInputSchema),\n }),\n v.check(\n (input) => input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"Trailing-stop triggers must use the quote fee asset\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"trailingStop\",\n value: {\n trailingDistance: parseTrailingDistance(scales, input.trailingDistance),\n activationPriceTicks:\n input.activationPrice === undefined\n ? 0n\n : positiveDecimalInputToScaled(\n \"activationPrice\",\n input.activationPrice,\n scales.price(),\n ),\n maxSlippage: parseMaxSlippage(scales, input.maxSlippage),\n side: ProtoOrders.Side.SELL,\n },\n } as const,\n },\n };\n }),\n );\n}\n\nfunction createTwapTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"twap\"),\n side: TriggerSideInputSchema,\n durationMs: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.number()]),\n v.transform((value) => {\n const durationMs = parseOptionalPositiveIntLike(value);\n if (!durationMs || durationMs < 1000) {\n throw new Error(\"durationMs must be at least 1000ms\");\n }\n return BigInt(durationMs);\n }),\n ),\n sliceIntervalMs: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.number()]),\n v.transform((value) => {\n const sliceIntervalMs = parseOptionalPositiveIntLike(value);\n if (!sliceIntervalMs || sliceIntervalMs < 100) {\n throw new Error(\"sliceIntervalMs must be at least 100ms\");\n }\n return BigInt(sliceIntervalMs);\n }),\n ),\n execution: TwapExecutionInputSchema,\n }),\n v.check(\n (input) =>\n input.side !== ProtoOrders.Side.SELL ||\n input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.check(\n (input) => input.sliceIntervalMs <= input.durationMs,\n \"sliceIntervalMs cannot exceed durationMs\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"twap\",\n value: {\n side: input.side,\n durationMs: input.durationMs,\n sliceIntervalMs: input.sliceIntervalMs,\n execution: buildTwapExecution(input.execution, scales),\n },\n } as const,\n },\n };\n }),\n );\n}\n\nfunction createLadderTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"ladder\"),\n side: TriggerSideInputSchema,\n priceMin: DecimalInputStringSchema,\n priceMax: DecimalInputStringSchema,\n levels: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.pipe(v.number(), v.integer())]),\n v.transform((value) => {\n const levels = parseOptionalPositiveIntLike(value);\n if (!levels || levels < 2 || levels > 100) {\n throw new Error(\"levels must be between 2 and 100\");\n }\n return levels;\n }),\n ),\n postOnly: v.optional(v.boolean(), false),\n }),\n v.check(\n (input) =>\n input.side !== ProtoOrders.Side.SELL ||\n input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"ladder\",\n value: {\n side: input.side,\n priceMinTicks: positiveDecimalInputToScaled(\n \"priceMin\",\n input.priceMin,\n scales.price(),\n ),\n priceMaxTicks: positiveDecimalInputToScaled(\n \"priceMax\",\n input.priceMax,\n scales.price(),\n ),\n levels: input.levels,\n postOnly: input.postOnly,\n },\n } as const,\n },\n };\n }),\n );\n}\n\nexport function createCreateTriggerInputSchema(scales: SdkScales) {\n return v.union([\n ...createConditionalTriggerInputSchema(scales, \"stop_loss\"),\n ...createConditionalTriggerInputSchema(scales, \"take_profit\"),\n createTrailingStopTriggerInputSchema(scales),\n createTwapTriggerInputSchema(scales),\n createLadderTriggerInputSchema(scales),\n ]);\n}\n\nexport type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInputSchema>>;\n\nexport const ListTriggersInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n parentOrderId: v.pipe(\n v.optional(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"parentOrderId\") : undefined)),\n ),\n symbol: v.optional(v.pipe(v.string(), v.trim())),\n status: v.pipe(\n v.optional(v.array(TriggerStatusFilterSchema)),\n v.transform(\n (values) => values?.map((value) => TriggerStatusCodec.inputToProto[value]) ?? [],\n ),\n ),\n triggerType: v.pipe(\n v.optional(TriggerTypeSchema),\n v.transform((value) =>\n value\n ? TriggerTypeCodec.inputToProto[value]\n : Proto.TriggerType.TRIGGER_TYPE_UNSPECIFIED,\n ),\n ),\n limit: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(1000)), 50),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ListTriggersInput = v.InferInput<typeof ListTriggersInputSchema>;\n\nexport const CancelTriggerInputSchema = TriggerScopedInputSchema;\nexport type CancelTriggerInput = v.InferInput<typeof CancelTriggerInputSchema>;\n\nexport const GetTriggerInputSchema = CancelTriggerInputSchema;\nexport type GetTriggerInput = v.InferInput<typeof GetTriggerInputSchema>;\n\nexport const PauseTriggerInputSchema = TriggerScopedInputSchema;\nexport type PauseTriggerInput = v.InferInput<typeof PauseTriggerInputSchema>;\n\nexport const ResumeTriggerInputSchema = TriggerScopedInputSchema;\nexport type ResumeTriggerInput = v.InferInput<typeof ResumeTriggerInputSchema>;\n\nexport function createModifyTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n triggerPrice: v.optional(DecimalInputStringSchema),\n limitPrice: v.optional(DecimalInputStringSchema),\n trailingDistance: v.optional(TrailingDistanceInputSchema),\n activationPrice: v.optional(DecimalInputStringSchema),\n maxSlippage: v.optional(MaxSlippageInputSchema),\n }),\n v.check(\n (input) =>\n input.triggerPrice !== undefined ||\n input.limitPrice !== undefined ||\n input.trailingDistance !== undefined ||\n input.activationPrice !== undefined ||\n input.maxSlippage !== undefined,\n \"At least one patch field is required\",\n ),\n v.transform(({ account, ...input }) => ({\n triggerId: input.triggerId,\n subaccountId: accountScopeToSubaccountId(account),\n triggerPriceTicks:\n input.triggerPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\n \"triggerPrice\",\n input.triggerPrice,\n scales.price(),\n ),\n limitPriceTicks:\n input.limitPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\"limitPrice\", input.limitPrice, scales.price()),\n trailingDistance:\n input.trailingDistance === undefined\n ? ({ case: undefined, value: undefined } as const)\n : parseTrailingDistance(scales, input.trailingDistance),\n activationPriceTicks:\n input.activationPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\n \"activationPrice\",\n input.activationPrice,\n scales.price(),\n ),\n maxSlippage:\n input.maxSlippage === undefined\n ? ({ case: undefined, value: undefined } as const)\n : parseMaxSlippage(scales, input.maxSlippage),\n })),\n );\n}\n\nexport type ModifyTriggerInput = v.InferInput<ReturnType<typeof createModifyTriggerInputSchema>>;\n\nexport const ListTriggerEventsInputSchema = v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n limit: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(1000))),\n eventType: v.optional(TriggerEventTypeSchema),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n eventType:\n input.eventType === undefined\n ? undefined\n : TriggerEventTypeCodec.inputToProto[input.eventType],\n })),\n);\n\nexport type ListTriggerEventsInput = v.InferInput<typeof ListTriggerEventsInputSchema>;\n"],"mappings":";;;;;;;;;;;;;;;AAqCA,MAAM,oBAAoB,EAAE,SAAS,mBAAmB;AACxD,MAAM,4BAA4B,EAAE,SAAS,4BAA4B;AACzE,MAAM,yBAAyB,EAAE,SAAS,yBAAyB;AAGnE,MAAM,4BAA4B;CAC9B,WAHyB,cAAc,WAGT;CAC9B,GAAG;AACP;AAEA,MAAM,2BAA2B,EAAE,KAC/B,EAAE,aAAa,yBAAyB,GACxC,EAAE,WAAW,EAAE,SAAS,GAAG,aAAa;CACpC,GAAG;CACH,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;;AAGA,MAAM,2BAA2B,EAAE,aAAa;CAC5C,MAAM,EAAE,QAAQ,UAAU;CAC1B,UAAU;AACd,CAAC;;AA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E,SAAS,GAAG,aAAa;EACpC,WAAW,MAAM;EACjB,cAAc,2BAA2B,OAAO;EAChD,mBACI,MAAM,iBAAiB,KAAA,IACjB,KAAA,IACA,6BACI,gBACA,MAAM,cACN,OAAO,MAAM,CACjB;EACV,iBACI,MAAM,eAAe,KAAA,IACf,KAAA,IACA,6BAA6B,cAAc,MAAM,YAAY,OAAO,MAAM,CAAC;EACrF,kBACI,MAAM,qBAAqB,KAAA,IACpB;GAAE,MAAM,KAAA;GAAW,OAAO,KAAA;EAAU,IACrC,sBAAsB,QAAQ,MAAM,gBAAgB;EAC9D,sBACI,MAAM,oBAAoB,KAAA,IACpB,KAAA,IACA,6BACI,mBACA,MAAM,iBACN,OAAO,MAAM,CACjB;EACV,aACI,MAAM,gBAAgB,KAAA,IACf;GAAE,MAAM,KAAA;GAAW,OAAO,KAAA;EAAU,IACrC,iBAAiB,QAAQ,MAAM,WAAW;CACxD,EAAE,CACN;AACJ;AAIA,MAAa,+BAA+B,EAAE,KAC1C,EAAE,aAAa;CACX,GAAG;CACH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAI,CAAC,CAAC;CACjF,WAAW,EAAE,SAAS,sBAAsB;CAC5C,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;AAC1D,CAAC,GACD,EAAE,WAAW,EAAE,SAAS,GAAG,aAAa;CACpC,GAAG;CACH,cAAc,2BAA2B,OAAO;CAChD,WACI,MAAM,cAAc,KAAA,IACd,KAAA,IACA,sBAAsB,aAAa,MAAM;AACvD,EAAE,CACN"}
1
+ {"version":3,"file":"trigger-input.schemas.js","names":["TriggerSideCodec"],"sources":["../../../src/services/triggers/trigger-input.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/triggers/v1/triggers_pb.js\";\nimport * as ProtoOrders from \"../../gen/orders/v1/orders_pb.js\";\nimport * as v from \"valibot\";\nimport { idInputSchema } from \"../../shared/schemas.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { positiveDecimalInputToScaled, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { CatalogConversionError } from \"../../catalogs/types.js\";\nimport { PROTOBUF_INT32_MAX, PROTOBUF_UINT32_MAX } from \"../../shared/wire-bounds.js\";\nimport { parseOptionalPositiveIntLike } from \"../../utils/numbers.js\";\nimport { idToBigInt } from \"../../utils/base58-id.js\";\nimport {\n TRIGGER_EVENT_TYPE_VALUES,\n TRIGGER_STATUS_FILTER_VALUES,\n TRIGGER_TYPE_VALUES,\n TriggerEventTypeCodec,\n TriggerSideCodec,\n TriggerTypeCodec,\n TriggerStatusCodec,\n} from \"./triggers.codecs.js\";\nimport { BpsStringOrNumberInputSchema, NoneInputSchema } from \"../shared.js\";\nimport {\n BaseTriggerFieldsSchema,\n ConditionalExecutionInputSchema,\n DecimalInputStringSchema,\n LimitConditionalExecutionInputSchema,\n TriggerSideInputSchema,\n TwapExecutionInputSchema,\n buildConditionalExecution,\n buildTriggerIntentBase,\n buildTwapExecution,\n type MaxSlippageOneof,\n type TrailingDistanceOneof,\n} from \"./trigger-child-order.schemas.js\";\n\nconst TriggerTypeSchema = v.picklist(TRIGGER_TYPE_VALUES);\nconst TriggerStatusFilterSchema = v.picklist(TRIGGER_STATUS_FILTER_VALUES);\nconst TriggerEventTypeSchema = v.picklist(TRIGGER_EVENT_TYPE_VALUES);\nconst TriggerIdInputSchema = idInputSchema(\"triggerId\");\nconst TriggerSymbolIdInputSchema = v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(PROTOBUF_UINT32_MAX),\n);\n\nconst TriggerScopedInputEntries = {\n triggerId: TriggerIdInputSchema,\n ...AccountScopeInputEntries,\n};\n\nconst TriggerScopedInputSchema = v.pipe(\n v.strictObject(TriggerScopedInputEntries),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\n/** Absolute price distance, as a decimal price string (e.g. \"0.50\"). */\nconst PriceDistanceInputSchema = v.strictObject({\n kind: v.literal(\"distance\"),\n distance: DecimalInputStringSchema,\n});\n\n/** Absolute price slippage, as a decimal price string (e.g. \"0.25\"). */\nconst PriceSlippageInputSchema = v.strictObject({\n kind: v.literal(\"slippage\"),\n slippage: DecimalInputStringSchema,\n});\n\nconst TrailingDistanceInputSchema = v.union([\n PriceDistanceInputSchema,\n BpsStringOrNumberInputSchema,\n]);\n\nconst MaxSlippageInputSchema = v.union([\n PriceSlippageInputSchema,\n BpsStringOrNumberInputSchema,\n NoneInputSchema,\n]);\n\nfunction parseTrailingDistance(\n scales: SdkScales,\n distance: v.InferOutput<typeof TrailingDistanceInputSchema>,\n): TrailingDistanceOneof {\n if (distance.kind === \"distance\") {\n return {\n case: \"trailingDistanceTicks\",\n value: positiveDecimalInputToScaled(\n \"trailingDistance.distance\",\n distance.distance,\n scales.price(),\n ),\n };\n }\n const bps = parseOptionalPositiveIntLike(distance.bps);\n if (bps === undefined || bps <= 0) {\n throw new Error(\"trailingDistanceBps must be a positive integer\");\n }\n return { case: \"trailingDistanceBps\", value: bps };\n}\n\nfunction parseMaxSlippage(\n scales: SdkScales,\n slippage: v.InferOutput<typeof MaxSlippageInputSchema> | undefined,\n): MaxSlippageOneof {\n if (!slippage || slippage.kind === \"none\") {\n return { case: undefined, value: undefined };\n }\n if (slippage.kind === \"slippage\") {\n const ticks = positiveDecimalInputToScaled(\n \"maxSlippage.slippage\",\n slippage.slippage,\n scales.price(),\n );\n if (ticks > PROTOBUF_INT32_MAX) {\n throw new CatalogConversionError(\n \"maxSlippage.slippage\",\n `maxSlippage.slippage exceeds the maximum supported price distance: ${slippage.slippage}`,\n );\n }\n return { case: \"maxSlippageTicks\", value: Number(ticks) };\n }\n const bps = parseOptionalPositiveIntLike(slippage.bps);\n if (bps === undefined || bps <= 0) {\n throw new Error(\"maxSlippageBps must be a positive integer\");\n }\n return { case: \"maxSlippageBps\", value: bps };\n}\n\nfunction createConditionalTriggerInputSchema<const TriggerType extends \"stop_loss\" | \"take_profit\">(\n scales: SdkScales,\n triggerType: TriggerType,\n) {\n const sharedEntries = {\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(triggerType),\n triggerPrice: DecimalInputStringSchema,\n };\n\n const sellInputSchema = v.strictObject({\n ...sharedEntries,\n side: v.literal(\"sell\"),\n execution: ConditionalExecutionInputSchema,\n });\n const buyInputSchema = v.strictObject({\n ...sharedEntries,\n side: v.literal(\"buy\"),\n execution: LimitConditionalExecutionInputSchema,\n });\n\n function transformInput(\n input: v.InferOutput<typeof sellInputSchema> | v.InferOutput<typeof buyInputSchema>,\n ) {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n const strategy = {\n triggerPriceTicks: positiveDecimalInputToScaled(\n \"triggerPrice\",\n input.triggerPrice,\n scales.price(),\n ),\n side: TriggerSideCodec.inputToProto[input.side],\n child: buildConditionalExecution(input.execution, scales),\n };\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy:\n triggerType === \"stop_loss\"\n ? ({ case: \"stopLoss\", value: strategy } as const)\n : ({ case: \"takeProfit\", value: strategy } as const),\n },\n };\n }\n\n return [\n v.pipe(\n sellInputSchema,\n v.check(\n (input) => input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.transform((input: v.InferOutput<typeof sellInputSchema>) => transformInput(input)),\n ),\n v.pipe(\n buyInputSchema,\n v.transform((input: v.InferOutput<typeof buyInputSchema>) => transformInput(input)),\n ),\n ] as const;\n}\n\nfunction createTrailingStopTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"trailing_stop\"),\n trailingDistance: TrailingDistanceInputSchema,\n activationPrice: v.optional(DecimalInputStringSchema),\n maxSlippage: v.optional(MaxSlippageInputSchema),\n }),\n v.check(\n (input) => input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"Trailing-stop triggers must use the quote fee asset\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"trailingStop\",\n value: {\n trailingDistance: parseTrailingDistance(scales, input.trailingDistance),\n activationPriceTicks:\n input.activationPrice === undefined\n ? 0n\n : positiveDecimalInputToScaled(\n \"activationPrice\",\n input.activationPrice,\n scales.price(),\n ),\n maxSlippage: parseMaxSlippage(scales, input.maxSlippage),\n side: ProtoOrders.Side.SELL,\n },\n } as const,\n },\n };\n }),\n );\n}\n\nfunction createTwapTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"twap\"),\n side: TriggerSideInputSchema,\n durationMs: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.number()]),\n v.transform((value) => {\n const durationMs = parseOptionalPositiveIntLike(value);\n if (!durationMs || durationMs < 1000) {\n throw new Error(\"durationMs must be at least 1000ms\");\n }\n return BigInt(durationMs);\n }),\n ),\n sliceIntervalMs: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.number()]),\n v.transform((value) => {\n const sliceIntervalMs = parseOptionalPositiveIntLike(value);\n if (!sliceIntervalMs || sliceIntervalMs < 100) {\n throw new Error(\"sliceIntervalMs must be at least 100ms\");\n }\n return BigInt(sliceIntervalMs);\n }),\n ),\n execution: TwapExecutionInputSchema,\n }),\n v.check(\n (input) =>\n input.side !== ProtoOrders.Side.SELL ||\n input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.check(\n (input) => input.sliceIntervalMs <= input.durationMs,\n \"sliceIntervalMs cannot exceed durationMs\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"twap\",\n value: {\n side: input.side,\n durationMs: input.durationMs,\n sliceIntervalMs: input.sliceIntervalMs,\n execution: buildTwapExecution(input.execution, scales),\n },\n } as const,\n },\n };\n }),\n );\n}\n\nfunction createLadderTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"ladder\"),\n side: TriggerSideInputSchema,\n priceMin: DecimalInputStringSchema,\n priceMax: DecimalInputStringSchema,\n levels: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.pipe(v.number(), v.integer())]),\n v.transform((value) => {\n const levels = parseOptionalPositiveIntLike(value);\n if (!levels || levels < 2 || levels > 100) {\n throw new Error(\"levels must be between 2 and 100\");\n }\n return levels;\n }),\n ),\n postOnly: v.optional(v.boolean(), false),\n }),\n v.check(\n (input) =>\n input.side !== ProtoOrders.Side.SELL ||\n input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"ladder\",\n value: {\n side: input.side,\n priceMinTicks: positiveDecimalInputToScaled(\n \"priceMin\",\n input.priceMin,\n scales.price(),\n ),\n priceMaxTicks: positiveDecimalInputToScaled(\n \"priceMax\",\n input.priceMax,\n scales.price(),\n ),\n levels: input.levels,\n postOnly: input.postOnly,\n },\n } as const,\n },\n };\n }),\n );\n}\n\nexport function createCreateTriggerInputSchema(scales: SdkScales) {\n return v.union([\n ...createConditionalTriggerInputSchema(scales, \"stop_loss\"),\n ...createConditionalTriggerInputSchema(scales, \"take_profit\"),\n createTrailingStopTriggerInputSchema(scales),\n createTwapTriggerInputSchema(scales),\n createLadderTriggerInputSchema(scales),\n ]);\n}\n\nexport type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInputSchema>>;\n\nexport const ListTriggersInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n parentOrderId: v.pipe(\n v.optional(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"parentOrderId\") : undefined)),\n ),\n symbol: v.optional(v.pipe(v.string(), v.trim())),\n status: v.pipe(\n v.optional(v.array(TriggerStatusFilterSchema)),\n v.transform(\n (values) => values?.map((value) => TriggerStatusCodec.inputToProto[value]) ?? [],\n ),\n ),\n triggerType: v.pipe(\n v.optional(TriggerTypeSchema),\n v.transform((value) =>\n value\n ? TriggerTypeCodec.inputToProto[value]\n : Proto.TriggerType.TRIGGER_TYPE_UNSPECIFIED,\n ),\n ),\n limit: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(1000)), 50),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ListTriggersInput = v.InferInput<typeof ListTriggersInputSchema>;\n\nexport const CancelTriggerInputSchema = TriggerScopedInputSchema;\nexport type CancelTriggerInput = v.InferInput<typeof CancelTriggerInputSchema>;\n\nexport const GetTriggerInputSchema = CancelTriggerInputSchema;\nexport type GetTriggerInput = v.InferInput<typeof GetTriggerInputSchema>;\n\nexport const PauseTriggerInputSchema = TriggerScopedInputSchema;\nexport type PauseTriggerInput = v.InferInput<typeof PauseTriggerInputSchema>;\n\nexport const ResumeTriggerInputSchema = v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n symbolId: TriggerSymbolIdInputSchema,\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\nexport type ResumeTriggerInput = v.InferInput<typeof ResumeTriggerInputSchema>;\n\nexport function createModifyTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n symbolId: TriggerSymbolIdInputSchema,\n triggerPrice: v.optional(DecimalInputStringSchema),\n limitPrice: v.optional(DecimalInputStringSchema),\n trailingDistance: v.optional(TrailingDistanceInputSchema),\n activationPrice: v.optional(DecimalInputStringSchema),\n maxSlippage: v.optional(MaxSlippageInputSchema),\n }),\n v.check(\n (input) =>\n input.triggerPrice !== undefined ||\n input.limitPrice !== undefined ||\n input.trailingDistance !== undefined ||\n input.activationPrice !== undefined ||\n input.maxSlippage !== undefined,\n \"At least one patch field is required\",\n ),\n v.transform(({ account, ...input }) => ({\n triggerId: input.triggerId,\n subaccountId: accountScopeToSubaccountId(account),\n symbolId: input.symbolId,\n triggerPriceTicks:\n input.triggerPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\n \"triggerPrice\",\n input.triggerPrice,\n scales.price(),\n ),\n limitPriceTicks:\n input.limitPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\"limitPrice\", input.limitPrice, scales.price()),\n trailingDistance:\n input.trailingDistance === undefined\n ? ({ case: undefined, value: undefined } as const)\n : parseTrailingDistance(scales, input.trailingDistance),\n activationPriceTicks:\n input.activationPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\n \"activationPrice\",\n input.activationPrice,\n scales.price(),\n ),\n maxSlippage:\n input.maxSlippage === undefined\n ? ({ case: undefined, value: undefined } as const)\n : parseMaxSlippage(scales, input.maxSlippage),\n })),\n );\n}\n\nexport type ModifyTriggerInput = v.InferInput<ReturnType<typeof createModifyTriggerInputSchema>>;\n\nexport const ListTriggerEventsInputSchema = v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n limit: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(1000))),\n eventType: v.optional(TriggerEventTypeSchema),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n eventType:\n input.eventType === undefined\n ? undefined\n : TriggerEventTypeCodec.inputToProto[input.eventType],\n })),\n);\n\nexport type ListT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