@polyester/sdk 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/gen/auth/v1/resolve_pb.d.ts +35 -6
- package/dist/gen/auth/v1/resolve_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/resolve_pb.js +34 -2
- package/dist/gen/auth/v1/resolve_pb.js.map +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.d.ts +37 -10
- package/dist/gen/auth/v1/subaccounts_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.js +38 -6
- package/dist/gen/auth/v1/subaccounts_pb.js.map +1 -1
- package/dist/gen/orders/v1/orders_pb.d.ts +124 -14
- package/dist/gen/orders/v1/orders_pb.d.ts.map +1 -1
- package/dist/gen/orders/v1/orders_pb.js +124 -2
- package/dist/gen/orders/v1/orders_pb.js.map +1 -1
- package/dist/services/accounts/accounts.codecs.js +6 -1
- package/dist/services/accounts/accounts.codecs.js.map +1 -1
- package/dist/services/accounts/accounts.schemas.d.ts +2 -2
- package/dist/services/accounts/accounts.schemas.d.ts.map +1 -1
- package/dist/services/accounts/accounts.schemas.js +4 -3
- package/dist/services/accounts/accounts.schemas.js.map +1 -1
- package/dist/services/market-overview/market-overview.d.ts +1 -0
- package/dist/services/market-overview/market-overview.d.ts.map +1 -1
- package/dist/services/market-overview/market-overview.js +24 -6
- package/dist/services/market-overview/market-overview.js.map +1 -1
- package/dist/services/orders/orders-batch.schemas.d.ts +9 -9
- package/dist/services/orders/orders-batch.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-batch.schemas.js +4 -4
- package/dist/services/orders/orders-batch.schemas.js.map +1 -1
- package/dist/services/orders/orders-input.schemas.d.ts +8 -8
- package/dist/services/orders/orders-input.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-input.schemas.js +5 -4
- package/dist/services/orders/orders-input.schemas.js.map +1 -1
- package/dist/services/orders/orders-output.schemas.d.ts +6 -6
- package/dist/services/orders/orders.codecs.js +20 -1
- package/dist/services/orders/orders.codecs.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.codecs.js +11 -1
- package/dist/services/subaccounts/subaccounts.codecs.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.js +1 -1
- package/dist/services/subaccounts/subaccounts.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +4 -4
- package/dist/services/subaccounts/subaccounts.schemas.d.ts.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.js +2 -6
- package/dist/services/subaccounts/subaccounts.schemas.js.map +1 -1
- package/dist/services/trades/trades.d.ts +3 -4
- package/dist/services/trades/trades.d.ts.map +1 -1
- package/dist/services/trades/trades.js +1 -1
- package/dist/services/trades/trades.js.map +1 -1
- package/dist/services/trades/trades.schemas.d.ts +41 -7
- package/dist/services/trades/trades.schemas.d.ts.map +1 -1
- package/dist/services/trades/trades.schemas.js +20 -10
- package/dist/services/trades/trades.schemas.js.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts +1 -1
- package/dist/services/triggers/triggers-output.schemas.d.ts +15 -15
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orders-input.schemas.js","names":["ProtoWrite.MarketIocSchema","ProtoWrite.LimitGtcSchema","ProtoWrite.LimitIocSchema","ProtoWrite.LimitFokSchema"],"sources":["../../../src/services/orders/orders-input.schemas.ts"],"sourcesContent":["import * as ProtoWrite from \"../../gen/orders/v1/orders_pb.js\";\nimport { create } from \"@bufbuild/protobuf\";\nimport * as v from \"valibot\";\nimport { SideSchema, SymbolIdInputSchema } from \"../shared.js\";\nimport { tsNsToMs } from \"../../utils/time.js\";\nimport {\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n PublicIdSchema,\n TimestampMsSchema,\n optionalIdInputSchema,\n optionalUint64DecimalFilterSchema,\n} from \"../../shared/schemas.js\";\nimport {\n positiveDecimalInputToScaled,\n scaledToDecimalOutput,\n type SdkScales,\n} from \"../../shared/decimal-surface.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport {\n FEE_ASSET_VALUES,\n ORDER_STATUS_FILTER_VALUES,\n OrderSideCodec,\n OrderStatusFilterCodec,\n SELF_TRADE_PREVENTION_MODE_VALUES,\n FeeAssetCodec,\n SelfTradePreventionModeCodec,\n} from \"./orders.codecs.js\";\nimport {\n MarketMaxSlippageSchema,\n createRiskPolicyInputSchema,\n parseMarketMaxSlippage,\n} from \"./orders-risk.schemas.js\";\nimport {\n ClientOrderIdInputSchema,\n OptionalClientOrderIdInputSchema,\n OrderIdInputSchema,\n OrderRequestIdInputSchema,\n} from \"./orders-identifiers.schemas.js\";\nimport { OrderErrorDetailSchema } from \"./order-errors.schemas.js\";\n\nconst OrderStatusSchema = v.picklist(ORDER_STATUS_FILTER_VALUES);\nconst FeeAssetSchema = v.picklist(FEE_ASSET_VALUES);\nconst SelfTradePreventionModeSchema = v.picklist(SELF_TRADE_PREVENTION_MODE_VALUES);\n\nconst BaseOrdersFilterInputEntries = {\n ...AccountScopeInputEntries,\n symbolId: v.optional(v.array(SymbolIdInputSchema)),\n triggerId: optionalIdInputSchema(\"triggerId\"),\n side: v.pipe(\n v.optional(SideSchema),\n v.transform((v) => (v ? OrderSideCodec.inputToProto[v] : undefined)),\n ),\n limit: v.optional(v.number()),\n pageToken: v.optional(v.pipe(v.string(), v.trim())),\n};\n\nexport const BaseOrdersFilterInputSchema = v.pipe(\n v.strictObject(BaseOrdersFilterInputEntries),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport const OpenOrdersInputSchema = v.pipe(\n v.strictObject({\n ...BaseOrdersFilterInputEntries,\n\n includeAttachedRisk: v.optional(v.boolean(), true),\n includeAttachedRiskState: v.optional(v.boolean(), false),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type OpenOrdersInput = v.InferInput<typeof OpenOrdersInputSchema>;\n\nexport const OrderHistoryInputSchema = v.pipe(\n v.strictObject({\n ...BaseOrdersFilterInputEntries,\n includeAttachedRisk: v.optional(v.boolean(), true),\n includeAttachedRiskState: v.optional(v.boolean(), false),\n status: v.pipe(\n v.optional(OrderStatusSchema),\n v.transform((v) => (v ? OrderStatusFilterCodec.inputToProto[v] : undefined)),\n ),\n startTsNs: optionalUint64DecimalFilterSchema(\"startTsNs\"),\n endTsNs: optionalUint64DecimalFilterSchema(\"endTsNs\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type OrderHistoryInput = v.InferInput<typeof OrderHistoryInputSchema>;\n\nconst DecimalInputStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\n\nfunction createOrderIntentBaseEntries(scales: SdkScales) {\n return {\n symbolId: SymbolIdInputSchema,\n side: v.pipe(\n SideSchema,\n v.transform((v) => OrderSideCodec.inputToProto[v]),\n ),\n execution: createOrderExecutionInputSchema(scales),\n clientOrderId: OptionalClientOrderIdInputSchema,\n feeAsset: v.pipe(\n v.optional(FeeAssetSchema),\n v.transform((v) => (v ? FeeAssetCodec.inputToProto[v] : undefined)),\n ),\n selfTradePreventionMode: v.pipe(\n v.optional(SelfTradePreventionModeSchema),\n v.transform((v) => (v ? SelfTradePreventionModeCodec.inputToProto[v] : undefined)),\n ),\n risk: createRiskPolicyInputSchema(scales),\n };\n}\n\ntype ParsedOrderIntentInput = v.InferOutput<ReturnType<typeof createOrderIntentInputObjectSchema>>;\n\nfunction createOrderIntentInputObjectSchema(scales: SdkScales) {\n const baseEntries = createOrderIntentBaseEntries(scales);\n return v.pipe(\n v.union([\n v.strictObject({\n ...baseEntries,\n qty: DecimalInputStringSchema,\n maxQuoteDebit: v.optional(v.never()),\n }),\n v.strictObject({\n ...baseEntries,\n qty: v.optional(v.never()),\n maxQuoteDebit: DecimalInputStringSchema,\n }),\n ]),\n v.check(\n (input) =>\n input.maxQuoteDebit === undefined ||\n (input.side === ProtoWrite.Side.BUY &&\n (input.execution.case === \"marketIoc\" || input.execution.case === \"limitIoc\")),\n \"maxQuoteDebit is supported only for BUY market IOC and BUY limit IOC orders\",\n ),\n v.check(\n (input) =>\n input.side !== ProtoWrite.Side.SELL ||\n input.feeAsset === undefined ||\n input.feeAsset === ProtoWrite.FeeAsset.QUOTE,\n \"SELL orders must use the quote fee asset\",\n ),\n );\n}\n\nfunction createScopedOrderIntentInputObjectSchema(scales: SdkScales) {\n const baseEntries = {\n ...AccountScopeInputEntries,\n ...createOrderIntentBaseEntries(scales),\n };\n return v.pipe(\n v.union([\n v.strictObject({\n ...baseEntries,\n qty: DecimalInputStringSchema,\n maxQuoteDebit: v.optional(v.never()),\n }),\n v.strictObject({\n ...baseEntries,\n qty: v.optional(v.never()),\n maxQuoteDebit: DecimalInputStringSchema,\n }),\n ]),\n v.check(\n (input) =>\n input.maxQuoteDebit === undefined ||\n (input.side === ProtoWrite.Side.BUY &&\n (input.execution.case === \"marketIoc\" || input.execution.case === \"limitIoc\")),\n \"maxQuoteDebit is supported only for BUY market IOC and BUY limit IOC orders\",\n ),\n v.check(\n (input) =>\n input.side !== ProtoWrite.Side.SELL ||\n input.feeAsset === undefined ||\n input.feeAsset === ProtoWrite.FeeAsset.QUOTE,\n \"SELL orders must use the quote fee asset\",\n ),\n );\n}\n\nfunction toOrderIntent(input: ParsedOrderIntentInput, scales: SdkScales) {\n const { risk, qty, maxQuoteDebit, ...intent } = input;\n const sizing =\n qty !== undefined\n ? ({\n case: \"baseQtyScaled\",\n value: positiveDecimalInputToScaled(\"qty\", qty, scales.baseQty(intent.symbolId)),\n } as const)\n : ({\n case: \"maxQuoteDebitScaled\",\n value: positiveDecimalInputToScaled(\n \"maxQuoteDebit\",\n maxQuoteDebit,\n scales.quoteAmount(intent.symbolId),\n ),\n } as const);\n return {\n ...intent,\n sizing,\n feeAsset: intent.feeAsset ?? ProtoWrite.FeeAsset.QUOTE,\n attachedRisk: risk,\n };\n}\n\nexport function createOrderIntentInputSchema(scales: SdkScales) {\n return v.pipe(\n createOrderIntentInputObjectSchema(scales),\n v.transform((input) => toOrderIntent(input, scales)),\n );\n}\n\nexport type OrderIntentInput = v.InferInput<ReturnType<typeof createOrderIntentInputSchema>>;\n\nfunction createOrderExecutionInputSchema(scales: SdkScales) {\n const priceToTicks = (fieldName: string, price: string) =>\n positiveDecimalInputToScaled(fieldName, price, scales.price());\n\n return v.variant(\"type\", [\n v.pipe(\n v.strictObject({\n type: v.literal(\"market_ioc\"),\n maxSlippage: v.optional(MarketMaxSlippageSchema),\n clientRefPrice: v.optional(DecimalInputStringSchema),\n }),\n v.transform(({ maxSlippage, clientRefPrice }) => ({\n case: \"marketIoc\" as const,\n value: create(ProtoWrite.MarketIocSchema, {\n maxSlippage: parseMarketMaxSlippage(scales, maxSlippage),\n clientRefPriceTicks:\n clientRefPrice === undefined\n ? 0n\n : priceToTicks(\"execution.clientRefPrice\", clientRefPrice),\n }),\n })),\n ),\n v.pipe(\n v.strictObject({\n type: v.literal(\"limit_gtc\"),\n price: DecimalInputStringSchema,\n postOnly: v.optional(v.boolean(), false),\n }),\n v.transform(({ price, postOnly }) => ({\n case: \"limitGtc\" as const,\n value: create(ProtoWrite.LimitGtcSchema, {\n priceTicks: priceToTicks(\"execution.price\", price),\n postOnly,\n }),\n })),\n ),\n v.pipe(\n v.strictObject({\n type: v.literal(\"limit_ioc\"),\n price: DecimalInputStringSchema,\n }),\n v.transform(({ price }) => ({\n case: \"limitIoc\" as const,\n value: create(ProtoWrite.LimitIocSchema, {\n priceTicks: priceToTicks(\"execution.price\", price),\n }),\n })),\n ),\n v.pipe(\n v.strictObject({\n type: v.literal(\"limit_fok\"),\n price: DecimalInputStringSchema,\n }),\n v.transform(({ price }) => ({\n case: \"limitFok\" as const,\n value: create(ProtoWrite.LimitFokSchema, {\n priceTicks: priceToTicks(\"execution.price\", price),\n }),\n })),\n ),\n ]);\n}\n\nexport function createNewOrderInputSchema(scales: SdkScales) {\n return v.pipe(\n createScopedOrderIntentInputObjectSchema(scales),\n v.transform(({ account, ...input }) => {\n return {\n subaccountId: accountScopeToSubaccountId(account),\n order: toOrderIntent(input, scales),\n };\n }),\n );\n}\n\nexport type NewOrderInput = v.InferInput<ReturnType<typeof createNewOrderInputSchema>>;\n\nconst CancelOrderScopeInputEntries = {\n symbolId: v.optional(SymbolIdInputSchema),\n ...AccountScopeInputEntries,\n};\n\nexport const CancelOrderInputSchema = v.pipe(\n v.union([\n v.strictObject({\n ...CancelOrderScopeInputEntries,\n orderId: OrderIdInputSchema,\n clientOrderId: v.optional(v.never()),\n }),\n v.strictObject({\n ...CancelOrderScopeInputEntries,\n orderId: v.optional(v.never()),\n clientOrderId: ClientOrderIdInputSchema,\n }),\n ]),\n v.transform(({ orderId, clientOrderId, account, ...rest }) => {\n const key =\n orderId !== undefined\n ? ({ case: \"orderId\", value: orderId } as const)\n : ({ case: \"clientOrderId\", value: clientOrderId } as const);\n return {\n ...rest,\n subaccountId: accountScopeToSubaccountId(account),\n key,\n };\n }),\n);\n\nexport type CancelOrderInput = v.InferInput<typeof CancelOrderInputSchema>;\n\nexport const CancelOrderResultSchema = v.pipe(\n v.object({\n status: v.string(),\n orderId: PublicIdSchema,\n tsNs: v.bigint(),\n }),\n v.transform(({ tsNs, ...result }) => ({\n ...result,\n ts: tsNsToMs(tsNs),\n tsNs: tsNs.toString(),\n })),\n);\n\nexport type CancelOrderResult = v.InferOutput<typeof CancelOrderResultSchema>;\n\nexport const CancelAllOrdersInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n symbolId: v.optional(SymbolIdInputSchema),\n side: v.pipe(\n v.optional(SideSchema),\n v.transform((v) => (v ? OrderSideCodec.inputToProto[v] : undefined)),\n ),\n dryRun: v.optional(v.boolean(), false),\n requestId: v.optional(OrderRequestIdInputSchema),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type CancelAllOrdersInput = v.InferInput<typeof CancelAllOrdersInputSchema>;\n\nexport const CancelAllOrdersResponseSchema = v.pipe(\n v.object({\n status: v.string(),\n matchedOrders: v.number(),\n submittedCancels: v.number(),\n failedCancels: v.number(),\n tsNs: v.bigint(),\n }),\n v.transform((o) => ({\n status: o.status,\n matchedOrders: o.matchedOrders,\n submittedCancels: o.submittedCancels,\n failedCancels: o.failedCancels,\n ts: tsNsToMs(o.tsNs),\n })),\n);\n\nexport type CancelAllOrdersResponse = v.InferOutput<typeof CancelAllOrdersResponseSchema>;\n\nexport const GetOrderDetailsInputSchema = v.pipe(\n v.strictObject({\n orderId: v.optional(OrderIdInputSchema),\n clientOrderId: v.optional(ClientOrderIdInputSchema),\n ...AccountScopeInputEntries,\n includeAttachedRisk: v.optional(v.boolean(), true),\n includeAttachedRiskState: v.optional(v.boolean(), true),\n }),\n v.check((input) => {\n const hasOrderId = input.orderId !== undefined;\n const hasClientOrderId = input.clientOrderId !== undefined;\n return hasOrderId !== hasClientOrderId;\n }, \"Provide exactly one of orderId or clientOrderId\"),\n v.transform(({ account, orderId, clientOrderId, ...rest }) => {\n const key =\n orderId !== undefined\n ? ({ case: \"orderId\", value: orderId } as const)\n : ({ case: \"clientOrderId\", value: clientOrderId ?? \"\" } as const);\n return {\n ...rest,\n subaccountId: accountScopeToSubaccountId(account),\n key,\n };\n }),\n);\n\nexport type GetOrderDetailsInput = v.InferInput<typeof GetOrderDetailsInputSchema>;\n\nexport function createCreateOrderResultSchema(scales: SdkScales, symbolId: number) {\n return v.pipe(\n v.object({\n orderId: PublicIdSchema,\n clientOrderId: v.string(),\n acceptedAt: OptionalTimestampMsSchema,\n acceptedAtTsNs: v.bigint(),\n resolvedBaseQtyScaled: v.bigint(),\n submittedMaxQuoteDebitScaled: v.optional(v.bigint()),\n takeProfitTriggerId: OptionalPublicIdSchema,\n stopLossTriggerId: OptionalPublicIdSchema,\n trailingStopTriggerId: OptionalPublicIdSchema,\n }),\n v.transform(\n ({\n acceptedAt,\n acceptedAtTsNs,\n resolvedBaseQtyScaled,\n submittedMaxQuoteDebitScaled,\n ...result\n }) => ({\n ...result,\n acceptedAt: acceptedAt ?? tsNsToMs(acceptedAtTsNs),\n acceptedAtNs: acceptedAtTsNs.toString(),\n resolvedBaseQty: scaledToDecimalOutput(\n resolvedBaseQtyScaled,\n scales.baseQty(symbolId),\n ),\n ...(submittedMaxQuoteDebitScaled === undefined\n ? {}\n : {\n submittedMaxQuoteDebit: scaledToDecimalOutput(\n submittedMaxQuoteDebitScaled,\n scales.quoteAmount(symbolId),\n ),\n }),\n }),\n ),\n );\n}\n\nexport type CreateOrderResult = v.InferOutput<ReturnType<typeof createCreateOrderResultSchema>>;\n\nexport function createPreviewOrderResultSchema(scales: SdkScales, symbolId: number) {\n return v.pipe(\n v.object({\n admissible: v.optional(v.boolean()),\n rejection: v.optional(OrderErrorDetailSchema),\n resolvedBaseQtyScaled: v.optional(v.bigint()),\n protectedPriceBoundTicks: v.optional(v.bigint()),\n evaluatedAt: TimestampMsSchema,\n }),\n v.transform(({ resolvedBaseQtyScaled, protectedPriceBoundTicks, ...result }) => ({\n ...result,\n ...(resolvedBaseQtyScaled === undefined\n ? {}\n : {\n resolvedBaseQty: scaledToDecimalOutput(\n resolvedBaseQtyScaled,\n scales.baseQty(symbolId),\n ),\n }),\n ...(protectedPriceBoundTicks === undefined\n ? {}\n : {\n protectedPriceBound: scaledToDecimalOutput(\n protectedPriceBoundTicks,\n scales.price(),\n ),\n }),\n })),\n );\n}\n\nexport type PreviewOrderResult = v.InferOutput<ReturnType<typeof createPreviewOrderResultSchema>>;\n"],"mappings":";;;;;;;;;;;;;;AA4CA,MAAM,oBAAoB,EAAE,SAAS,0BAA0B;AAC/D,MAAM,iBAAiB,EAAE,SAAS,gBAAgB;AAClD,MAAM,gCAAgC,EAAE,SAAS,iCAAiC;AAElF,MAAM,+BAA+B;C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AE,OAAO,CAAC;EAC5C,0BAA0B,EAAE,SAAS,EAAE,OAAO,CAAC;EAC/C,aAAa;CACjB,CAAC,GACD,EAAE,WAAW,EAAE,uBAAuB,0BAA0B,GAAG,cAAc;EAC7E,GAAG;EACH,GAAI,0BAA0B,KAAA,IACxB,CAAC,IACD,EACI,iBAAiB,sBACb,uBACA,OAAO,QAAQ,QAAQ,CAC3B,EACJ;EACN,GAAI,6BAA6B,KAAA,IAC3B,CAAC,IACD,EACI,qBAAqB,sBACjB,0BACA,OAAO,MAAM,CACjB,EACJ;CACV,EAAE,CACN;AACJ"}
|
|
1
|
+
{"version":3,"file":"orders-input.schemas.js","names":["ProtoWrite.MarketIocSchema","ProtoWrite.LimitGtcSchema","ProtoWrite.LimitIocSchema","ProtoWrite.LimitFokSchema","ProtoWrite.CancelOrderResponse_Status","ProtoWrite.CancelAllOrdersResponse_Status"],"sources":["../../../src/services/orders/orders-input.schemas.ts"],"sourcesContent":["import * as ProtoWrite from \"../../gen/orders/v1/orders_pb.js\";\nimport { create } from \"@bufbuild/protobuf\";\nimport * as v from \"valibot\";\nimport { SideSchema, SymbolIdInputSchema } from \"../shared.js\";\nimport { tsNsToMs } from \"../../utils/time.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport {\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n PublicIdSchema,\n TimestampMsSchema,\n optionalIdInputSchema,\n optionalUint64DecimalFilterSchema,\n} from \"../../shared/schemas.js\";\nimport {\n positiveDecimalInputToScaled,\n scaledToDecimalOutput,\n type SdkScales,\n} from \"../../shared/decimal-surface.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport {\n FEE_ASSET_VALUES,\n ORDER_STATUS_FILTER_VALUES,\n OrderSideCodec,\n OrderStatusFilterCodec,\n SELF_TRADE_PREVENTION_MODE_VALUES,\n FeeAssetCodec,\n SelfTradePreventionModeCodec,\n CancelAllOrdersStatusCodec,\n CancelOrderStatusCodec,\n} from \"./orders.codecs.js\";\nimport {\n MarketMaxSlippageSchema,\n createRiskPolicyInputSchema,\n parseMarketMaxSlippage,\n} from \"./orders-risk.schemas.js\";\nimport {\n ClientOrderIdInputSchema,\n OptionalClientOrderIdInputSchema,\n OrderIdInputSchema,\n OrderRequestIdInputSchema,\n} from \"./orders-identifiers.schemas.js\";\nimport { OrderErrorDetailSchema } from \"./order-errors.schemas.js\";\n\nconst OrderStatusSchema = v.picklist(ORDER_STATUS_FILTER_VALUES);\nconst FeeAssetSchema = v.picklist(FEE_ASSET_VALUES);\nconst SelfTradePreventionModeSchema = v.picklist(SELF_TRADE_PREVENTION_MODE_VALUES);\n\nconst BaseOrdersFilterInputEntries = {\n ...AccountScopeInputEntries,\n symbolId: v.optional(v.array(SymbolIdInputSchema)),\n triggerId: optionalIdInputSchema(\"triggerId\"),\n side: v.pipe(\n v.optional(SideSchema),\n v.transform((v) => (v ? OrderSideCodec.inputToProto[v] : undefined)),\n ),\n limit: v.optional(v.number()),\n pageToken: v.optional(v.pipe(v.string(), v.trim())),\n};\n\nexport const BaseOrdersFilterInputSchema = v.pipe(\n v.strictObject(BaseOrdersFilterInputEntries),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport const OpenOrdersInputSchema = v.pipe(\n v.strictObject({\n ...BaseOrdersFilterInputEntries,\n\n includeAttachedRisk: v.optional(v.boolean(), true),\n includeAttachedRiskState: v.optional(v.boolean(), false),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type OpenOrdersInput = v.InferInput<typeof OpenOrdersInputSchema>;\n\nexport const OrderHistoryInputSchema = v.pipe(\n v.strictObject({\n ...BaseOrdersFilterInputEntries,\n includeAttachedRisk: v.optional(v.boolean(), true),\n includeAttachedRiskState: v.optional(v.boolean(), false),\n status: v.pipe(\n v.optional(OrderStatusSchema),\n v.transform((v) => (v ? OrderStatusFilterCodec.inputToProto[v] : undefined)),\n ),\n startTsNs: optionalUint64DecimalFilterSchema(\"startTsNs\"),\n endTsNs: optionalUint64DecimalFilterSchema(\"endTsNs\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type OrderHistoryInput = v.InferInput<typeof OrderHistoryInputSchema>;\n\nconst DecimalInputStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\n\nfunction createOrderIntentBaseEntries(scales: SdkScales) {\n return {\n symbolId: SymbolIdInputSchema,\n side: v.pipe(\n SideSchema,\n v.transform((v) => OrderSideCodec.inputToProto[v]),\n ),\n execution: createOrderExecutionInputSchema(scales),\n clientOrderId: OptionalClientOrderIdInputSchema,\n feeAsset: v.pipe(\n v.optional(FeeAssetSchema),\n v.transform((v) => (v ? FeeAssetCodec.inputToProto[v] : undefined)),\n ),\n selfTradePreventionMode: v.pipe(\n v.optional(SelfTradePreventionModeSchema),\n v.transform((v) => (v ? SelfTradePreventionModeCodec.inputToProto[v] : undefined)),\n ),\n risk: createRiskPolicyInputSchema(scales),\n };\n}\n\ntype ParsedOrderIntentInput = v.InferOutput<ReturnType<typeof createOrderIntentInputObjectSchema>>;\n\nfunction createOrderIntentInputObjectSchema(scales: SdkScales) {\n const baseEntries = createOrderIntentBaseEntries(scales);\n return v.pipe(\n v.union([\n v.strictObject({\n ...baseEntries,\n qty: DecimalInputStringSchema,\n maxQuoteDebit: v.optional(v.never()),\n }),\n v.strictObject({\n ...baseEntries,\n qty: v.optional(v.never()),\n maxQuoteDebit: DecimalInputStringSchema,\n }),\n ]),\n v.check(\n (input) =>\n input.maxQuoteDebit === undefined ||\n (input.side === ProtoWrite.Side.BUY &&\n (input.execution.case === \"marketIoc\" || input.execution.case === \"limitIoc\")),\n \"maxQuoteDebit is supported only for BUY market IOC and BUY limit IOC orders\",\n ),\n v.check(\n (input) =>\n input.side !== ProtoWrite.Side.SELL ||\n input.feeAsset === undefined ||\n input.feeAsset === ProtoWrite.FeeAsset.QUOTE,\n \"SELL orders must use the quote fee asset\",\n ),\n );\n}\n\nfunction createScopedOrderIntentInputObjectSchema(scales: SdkScales) {\n const baseEntries = {\n ...AccountScopeInputEntries,\n ...createOrderIntentBaseEntries(scales),\n };\n return v.pipe(\n v.union([\n v.strictObject({\n ...baseEntries,\n qty: DecimalInputStringSchema,\n maxQuoteDebit: v.optional(v.never()),\n }),\n v.strictObject({\n ...baseEntries,\n qty: v.optional(v.never()),\n maxQuoteDebit: DecimalInputStringSchema,\n }),\n ]),\n v.check(\n (input) =>\n input.maxQuoteDebit === undefined ||\n (input.side === ProtoWrite.Side.BUY &&\n (input.execution.case === \"marketIoc\" || input.execution.case === \"limitIoc\")),\n \"maxQuoteDebit is supported only for BUY market IOC and BUY limit IOC orders\",\n ),\n v.check(\n (input) =>\n input.side !== ProtoWrite.Side.SELL ||\n input.feeAsset === undefined ||\n input.feeAsset === ProtoWrite.FeeAsset.QUOTE,\n \"SELL orders must use the quote fee asset\",\n ),\n );\n}\n\nfunction toOrderIntent(input: ParsedOrderIntentInput, scales: SdkScales) {\n const { risk, qty, maxQuoteDebit, ...intent } = input;\n const sizing =\n qty !== undefined\n ? ({\n case: \"baseQtyScaled\",\n value: positiveDecimalInputToScaled(\"qty\", qty, scales.baseQty(intent.symbolId)),\n } as const)\n : ({\n case: \"maxQuoteDebitScaled\",\n value: positiveDecimalInputToScaled(\n \"maxQuoteDebit\",\n maxQuoteDebit,\n scales.quoteAmount(intent.symbolId),\n ),\n } as const);\n return {\n ...intent,\n sizing,\n feeAsset: intent.feeAsset ?? ProtoWrite.FeeAsset.QUOTE,\n attachedRisk: risk,\n };\n}\n\nexport function createOrderIntentInputSchema(scales: SdkScales) {\n return v.pipe(\n createOrderIntentInputObjectSchema(scales),\n v.transform((input) => toOrderIntent(input, scales)),\n );\n}\n\nexport type OrderIntentInput = v.InferInput<ReturnType<typeof createOrderIntentInputSchema>>;\n\nfunction createOrderExecutionInputSchema(scales: SdkScales) {\n const priceToTicks = (fieldName: string, price: string) =>\n positiveDecimalInputToScaled(fieldName, price, scales.price());\n\n return v.variant(\"type\", [\n v.pipe(\n v.strictObject({\n type: v.literal(\"market_ioc\"),\n maxSlippage: v.optional(MarketMaxSlippageSchema),\n clientRefPrice: v.optional(DecimalInputStringSchema),\n }),\n v.transform(({ maxSlippage, clientRefPrice }) => ({\n case: \"marketIoc\" as const,\n value: create(ProtoWrite.MarketIocSchema, {\n maxSlippage: parseMarketMaxSlippage(scales, maxSlippage),\n clientRefPriceTicks:\n clientRefPrice === undefined\n ? 0n\n : priceToTicks(\"execution.clientRefPrice\", clientRefPrice),\n }),\n })),\n ),\n v.pipe(\n v.strictObject({\n type: v.literal(\"limit_gtc\"),\n price: DecimalInputStringSchema,\n postOnly: v.optional(v.boolean(), false),\n }),\n v.transform(({ price, postOnly }) => ({\n case: \"limitGtc\" as const,\n value: create(ProtoWrite.LimitGtcSchema, {\n priceTicks: priceToTicks(\"execution.price\", price),\n postOnly,\n }),\n })),\n ),\n v.pipe(\n v.strictObject({\n type: v.literal(\"limit_ioc\"),\n price: DecimalInputStringSchema,\n }),\n v.transform(({ price }) => ({\n case: \"limitIoc\" as const,\n value: create(ProtoWrite.LimitIocSchema, {\n priceTicks: priceToTicks(\"execution.price\", price),\n }),\n })),\n ),\n v.pipe(\n v.strictObject({\n type: v.literal(\"limit_fok\"),\n price: DecimalInputStringSchema,\n }),\n v.transform(({ price }) => ({\n case: \"limitFok\" as const,\n value: create(ProtoWrite.LimitFokSchema, {\n priceTicks: priceToTicks(\"execution.price\", price),\n }),\n })),\n ),\n ]);\n}\n\nexport function createNewOrderInputSchema(scales: SdkScales) {\n return v.pipe(\n createScopedOrderIntentInputObjectSchema(scales),\n v.transform(({ account, ...input }) => {\n return {\n subaccountId: accountScopeToSubaccountId(account),\n order: toOrderIntent(input, scales),\n };\n }),\n );\n}\n\nexport type NewOrderInput = v.InferInput<ReturnType<typeof createNewOrderInputSchema>>;\n\nconst CancelOrderScopeInputEntries = {\n symbolId: v.optional(SymbolIdInputSchema),\n ...AccountScopeInputEntries,\n};\n\nexport const CancelOrderInputSchema = v.pipe(\n v.union([\n v.strictObject({\n ...CancelOrderScopeInputEntries,\n orderId: OrderIdInputSchema,\n clientOrderId: v.optional(v.never()),\n }),\n v.strictObject({\n ...CancelOrderScopeInputEntries,\n orderId: v.optional(v.never()),\n clientOrderId: ClientOrderIdInputSchema,\n }),\n ]),\n v.transform(({ orderId, clientOrderId, account, ...rest }) => {\n const key =\n orderId !== undefined\n ? ({ case: \"orderId\", value: orderId } as const)\n : ({ case: \"clientOrderId\", value: clientOrderId } as const);\n return {\n ...rest,\n subaccountId: accountScopeToSubaccountId(account),\n key,\n };\n }),\n);\n\nexport type CancelOrderInput = v.InferInput<typeof CancelOrderInputSchema>;\n\nexport const CancelOrderResultSchema = v.pipe(\n v.object({\n status: v.pipe(\n v.enum(ProtoWrite.CancelOrderResponse_Status),\n v.transform((status) =>\n requiredEnumLabel(\n CancelOrderStatusCodec.protoToOutput,\n status,\n \"CancelOrderResultSchema\",\n \"status\",\n ),\n ),\n ),\n orderId: PublicIdSchema,\n tsNs: v.bigint(),\n }),\n v.transform(({ tsNs, ...result }) => ({\n ...result,\n ts: tsNsToMs(tsNs),\n tsNs: tsNs.toString(),\n })),\n);\n\nexport type CancelOrderResult = v.InferOutput<typeof CancelOrderResultSchema>;\n\nexport const CancelAllOrdersInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n symbolId: v.optional(SymbolIdInputSchema),\n side: v.pipe(\n v.optional(SideSchema),\n v.transform((v) => (v ? OrderSideCodec.inputToProto[v] : undefined)),\n ),\n dryRun: v.optional(v.boolean(), false),\n requestId: v.optional(OrderRequestIdInputSchema),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type CancelAllOrdersInput = v.InferInput<typeof CancelAllOrdersInputSchema>;\n\nexport const CancelAllOrdersResponseSchema = v.pipe(\n v.object({\n status: v.pipe(\n v.enum(ProtoWrite.CancelAllOrdersResponse_Status),\n v.transform((status) =>\n requiredEnumLabel(\n CancelAllOrdersStatusCodec.protoToOutput,\n status,\n \"CancelAllOrdersResponseSchema\",\n \"status\",\n ),\n ),\n ),\n matchedOrders: v.number(),\n submittedCancels: v.number(),\n failedCancels: v.number(),\n tsNs: v.bigint(),\n }),\n v.transform((o) => ({\n status: o.status,\n matchedOrders: o.matchedOrders,\n submittedCancels: o.submittedCancels,\n failedCancels: o.failedCancels,\n ts: tsNsToMs(o.tsNs),\n })),\n);\n\nexport type CancelAllOrdersResponse = v.InferOutput<typeof CancelAllOrdersResponseSchema>;\n\nexport const GetOrderDetailsInputSchema = v.pipe(\n v.strictObject({\n orderId: v.optional(OrderIdInputSchema),\n clientOrderId: v.optional(ClientOrderIdInputSchema),\n ...AccountScopeInputEntries,\n includeAttachedRisk: v.optional(v.boolean(), true),\n includeAttachedRiskState: v.optional(v.boolean(), true),\n }),\n v.check((input) => {\n const hasOrderId = input.orderId !== undefined;\n const hasClientOrderId = input.clientOrderId !== undefined;\n return hasOrderId !== hasClientOrderId;\n }, \"Provide exactly one of orderId or clientOrderId\"),\n v.transform(({ account, orderId, clientOrderId, ...rest }) => {\n const key =\n orderId !== undefined\n ? ({ case: \"orderId\", value: orderId } as const)\n : ({ case: \"clientOrderId\", value: clientOrderId ?? \"\" } as const);\n return {\n ...rest,\n subaccountId: accountScopeToSubaccountId(account),\n key,\n };\n }),\n);\n\nexport type GetOrderDetailsInput = v.InferInput<typeof GetOrderDetailsInputSchema>;\n\nexport function createCreateOrderResultSchema(scales: SdkScales, symbolId: number) {\n return v.pipe(\n v.object({\n orderId: PublicIdSchema,\n clientOrderId: v.string(),\n acceptedAt: OptionalTimestampMsSchema,\n acceptedAtTsNs: v.bigint(),\n resolvedBaseQtyScaled: v.bigint(),\n submittedMaxQuoteDebitScaled: v.optional(v.bigint()),\n takeProfitTriggerId: OptionalPublicIdSchema,\n stopLossTriggerId: OptionalPublicIdSchema,\n trailingStopTriggerId: OptionalPublicIdSchema,\n }),\n v.transform(\n ({\n acceptedAt,\n acceptedAtTsNs,\n resolvedBaseQtyScaled,\n submittedMaxQuoteDebitScaled,\n ...result\n }) => ({\n ...result,\n acceptedAt: acceptedAt ?? tsNsToMs(acceptedAtTsNs),\n acceptedAtNs: acceptedAtTsNs.toString(),\n resolvedBaseQty: scaledToDecimalOutput(\n resolvedBaseQtyScaled,\n scales.baseQty(symbolId),\n ),\n ...(submittedMaxQuoteDebitScaled === undefined\n ? {}\n : {\n submittedMaxQuoteDebit: scaledToDecimalOutput(\n submittedMaxQuoteDebitScaled,\n scales.quoteAmount(symbolId),\n ),\n }),\n }),\n ),\n );\n}\n\nexport type CreateOrderResult = v.InferOutput<ReturnType<typeof createCreateOrderResultSchema>>;\n\nexport function createPreviewOrderResultSchema(scales: SdkScales, symbolId: number) {\n return v.pipe(\n v.object({\n admissible: v.optional(v.boolean()),\n rejection: v.optional(OrderErrorDetailSchema),\n resolvedBaseQtyScaled: v.optional(v.bigint()),\n protectedPriceBoundTicks: v.optional(v.bigint()),\n evaluatedAt: TimestampMsSchema,\n }),\n v.transform(({ resolvedBaseQtyScaled, protectedPriceBoundTicks, ...result }) => ({\n ...result,\n ...(resolvedBaseQtyScaled === undefined\n ? {}\n : {\n resolvedBaseQty: scaledToDecimalOutput(\n resolvedBaseQtyScaled,\n scales.baseQty(symbolId),\n ),\n }),\n ...(protectedPriceBoundTicks === undefined\n ? {}\n : {\n protectedPriceBound: scaledToDecimalOutput(\n protectedPriceBoundTicks,\n scales.price(),\n ),\n }),\n })),\n );\n}\n\nexport type PreviewOrderResult = v.InferOutput<ReturnType<typeof createPreviewOrderResultSchema>>;\n"],"mappings":";;;;;;;;;;;;;;;AA+CA,MAAM,oBAAoB,EAAE,SAAS,0BAA0B;AAC/D,MAAM,iBAAiB,EAAE,SAAS,gBAAgB;AAClD,MAAM,gCAAgC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AO,YAAY,QAAQ,CAC/B,EACJ;CACV,EACJ,CACJ;AACJ;AAIA,SAAgB,+BAA+B,QAAmB,UAAkB;CAChF,OAAO,EAAE,KACL,EAAE,OAAO;EACL,YAAY,EAAE,SAAS,EAAE,QAAQ,CAAC;EAClC,WAAW,EAAE,SAAS,sBAAsB;EAC5C,uBAAuB,EAAE,SAAS,EAAE,OAAO,CAAC;EAC5C,0BAA0B,EAAE,SAAS,EAAE,OAAO,CAAC;EAC/C,aAAa;CACjB,CAAC,GACD,EAAE,WAAW,EAAE,uBAAuB,0BAA0B,GAAG,cAAc;EAC7E,GAAG;EACH,GAAI,0BAA0B,KAAA,IACxB,CAAC,IACD,EACI,iBAAiB,sBACb,uBACA,OAAO,QAAQ,QAAQ,CAC3B,EACJ;EACN,GAAI,6BAA6B,KAAA,IAC3B,CAAC,IACD,EACI,qBAAqB,sBACjB,0BACA,OAAO,MAAM,CACjB,EACJ;CACV,EAAE,CACN;AACJ"}
|
|
@@ -243,7 +243,7 @@ declare function createOrderSchema(scales: SdkScales): v.SchemaWithPipe<readonly
|
|
|
243
243
|
attachedRisk: {
|
|
244
244
|
takeProfit: {
|
|
245
245
|
state: {
|
|
246
|
-
status: "unspecified" | "failed" | "
|
|
246
|
+
status: "unspecified" | "failed" | "created" | "completed" | "armed" | "running" | "paused" | "canceled" | "not_configured";
|
|
247
247
|
armedTs: number | undefined;
|
|
248
248
|
armedTsNs: string | undefined;
|
|
249
249
|
terminalTs: number | undefined;
|
|
@@ -262,7 +262,7 @@ declare function createOrderSchema(scales: SdkScales): v.SchemaWithPipe<readonly
|
|
|
262
262
|
} | undefined;
|
|
263
263
|
stopLoss: {
|
|
264
264
|
state: {
|
|
265
|
-
status: "unspecified" | "failed" | "
|
|
265
|
+
status: "unspecified" | "failed" | "created" | "completed" | "armed" | "running" | "paused" | "canceled" | "not_configured";
|
|
266
266
|
armedTs: number | undefined;
|
|
267
267
|
armedTsNs: string | undefined;
|
|
268
268
|
terminalTs: number | undefined;
|
|
@@ -281,7 +281,7 @@ declare function createOrderSchema(scales: SdkScales): v.SchemaWithPipe<readonly
|
|
|
281
281
|
} | undefined;
|
|
282
282
|
trailingStop: {
|
|
283
283
|
state: {
|
|
284
|
-
status: "unspecified" | "failed" | "
|
|
284
|
+
status: "unspecified" | "failed" | "created" | "completed" | "armed" | "running" | "paused" | "canceled" | "not_configured";
|
|
285
285
|
armedTs: number | undefined;
|
|
286
286
|
armedTsNs: string | undefined;
|
|
287
287
|
terminalTs: number | undefined;
|
|
@@ -586,7 +586,7 @@ declare function createOrderDetailsSchema(scales: SdkScales): v.ObjectSchema<{
|
|
|
586
586
|
attachedRisk: {
|
|
587
587
|
takeProfit: {
|
|
588
588
|
state: {
|
|
589
|
-
status: "unspecified" | "failed" | "
|
|
589
|
+
status: "unspecified" | "failed" | "created" | "completed" | "armed" | "running" | "paused" | "canceled" | "not_configured";
|
|
590
590
|
armedTs: number | undefined;
|
|
591
591
|
armedTsNs: string | undefined;
|
|
592
592
|
terminalTs: number | undefined;
|
|
@@ -605,7 +605,7 @@ declare function createOrderDetailsSchema(scales: SdkScales): v.ObjectSchema<{
|
|
|
605
605
|
} | undefined;
|
|
606
606
|
stopLoss: {
|
|
607
607
|
state: {
|
|
608
|
-
status: "unspecified" | "failed" | "
|
|
608
|
+
status: "unspecified" | "failed" | "created" | "completed" | "armed" | "running" | "paused" | "canceled" | "not_configured";
|
|
609
609
|
armedTs: number | undefined;
|
|
610
610
|
armedTsNs: string | undefined;
|
|
611
611
|
terminalTs: number | undefined;
|
|
@@ -624,7 +624,7 @@ declare function createOrderDetailsSchema(scales: SdkScales): v.ObjectSchema<{
|
|
|
624
624
|
} | undefined;
|
|
625
625
|
trailingStop: {
|
|
626
626
|
state: {
|
|
627
|
-
status: "unspecified" | "failed" | "
|
|
627
|
+
status: "unspecified" | "failed" | "created" | "completed" | "armed" | "running" | "paused" | "canceled" | "not_configured";
|
|
628
628
|
armedTs: number | undefined;
|
|
629
629
|
armedTsNs: string | undefined;
|
|
630
630
|
terminalTs: number | undefined;
|
|
@@ -12,6 +12,25 @@ const MODIFY_BEHAVIOR_VALUES = [
|
|
|
12
12
|
"AMEND_ONLY",
|
|
13
13
|
"REPLACE_ONLY"
|
|
14
14
|
];
|
|
15
|
+
const CancelOrderStatusCodec = { protoToOutput: {
|
|
16
|
+
[0]: "unspecified",
|
|
17
|
+
[1]: "accepted"
|
|
18
|
+
} };
|
|
19
|
+
const CancelAllOrdersStatusCodec = { protoToOutput: {
|
|
20
|
+
[0]: "unspecified",
|
|
21
|
+
[1]: "submitted",
|
|
22
|
+
[2]: "dry_run"
|
|
23
|
+
} };
|
|
24
|
+
const CancelAllAfterStatusCodec = { protoToOutput: {
|
|
25
|
+
[0]: "unspecified",
|
|
26
|
+
[1]: "armed",
|
|
27
|
+
[2]: "disabled"
|
|
28
|
+
} };
|
|
29
|
+
const BatchCancelOrderStatusCodec = { protoToOutput: {
|
|
30
|
+
[0]: "unspecified",
|
|
31
|
+
[1]: "accepted",
|
|
32
|
+
[2]: "rejected"
|
|
33
|
+
} };
|
|
15
34
|
const OrderStatusFilterCodec = { inputToProto: {
|
|
16
35
|
FILLED: 4,
|
|
17
36
|
CANCELED: 5,
|
|
@@ -81,6 +100,6 @@ const BatchReplacePhaseCodec = { protoToOutput: {
|
|
|
81
100
|
[4]: "terminal"
|
|
82
101
|
} };
|
|
83
102
|
//#endregion
|
|
84
|
-
export { AttachedRiskLegStatusCodec, BatchReplaceAdmissionStatusCodec, BatchReplaceItemAdmissionStatusCodec, BatchReplacePhaseCodec, FEE_ASSET_VALUES, FeeAssetCodec, MODIFY_BEHAVIOR_VALUES, ModifyActionCodec, ModifyBehaviorCodec, ORDER_STATUS_FILTER_VALUES, OrderOriginScopeCodec, OrderSideCodec, OrderStatusCodec, OrderStatusFilterCodec, OrderTriggerTypeCodec, OrderTypeCodec, SELF_TRADE_PREVENTION_MODE_VALUES, SelfTradePreventionModeCodec, TimeInForceCodec };
|
|
103
|
+
export { AttachedRiskLegStatusCodec, BatchCancelOrderStatusCodec, BatchReplaceAdmissionStatusCodec, BatchReplaceItemAdmissionStatusCodec, BatchReplacePhaseCodec, CancelAllAfterStatusCodec, CancelAllOrdersStatusCodec, CancelOrderStatusCodec, FEE_ASSET_VALUES, FeeAssetCodec, MODIFY_BEHAVIOR_VALUES, ModifyActionCodec, ModifyBehaviorCodec, ORDER_STATUS_FILTER_VALUES, OrderOriginScopeCodec, OrderSideCodec, OrderStatusCodec, OrderStatusFilterCodec, OrderTriggerTypeCodec, OrderTypeCodec, SELF_TRADE_PREVENTION_MODE_VALUES, SelfTradePreventionModeCodec, TimeInForceCodec };
|
|
85
104
|
|
|
86
105
|
//# sourceMappingURL=orders.codecs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orders.codecs.js","names":[],"sources":["../../../src/services/orders/orders.codecs.ts"],"sourcesContent":["import * as ProtoRead from \"../../gen/orders/v1/orders_read_pb.js\";\nimport * as ProtoWrite from \"../../gen/orders/v1/orders_pb.js\";\nimport type { InputToProto, ProtoToOutput } from \"../../utils/types.js\";\nexport {\n FEE_ASSET_VALUES,\n FeeAssetCodec,\n type FeeAssetValue,\n ORDER_SIDE_VALUES,\n ORDER_TYPE_VALUES,\n OrderSideCodec,\n type OrderSideValue,\n OrderTypeCodec,\n type OrderTypeValue,\n SELF_TRADE_PREVENTION_MODE_VALUES,\n SelfTradePreventionModeCodec,\n type SelfTradePreventionModeValue,\n TIME_IN_FORCE_OUTPUT_VALUES,\n TIME_IN_FORCE_VALUES,\n TimeInForceCodec,\n type TimeInForceOutputValue,\n type TimeInForceValue,\n TRIGGER_PRICE_SOURCE_VALUES,\n TriggerPriceSourceCodec,\n type TriggerPriceSourceValue,\n} from \"./order-enums.codecs.js\";\n\nexport const ORDER_STATUS_FILTER_VALUES = [\"FILLED\", \"CANCELED\", \"REJECTED\"] as const;\nexport type OrderStatusFilterValue = (typeof ORDER_STATUS_FILTER_VALUES)[number];\n\nexport const ORDER_STATUS_VALUES = [\n \"pending\",\n \"pending_cancel\",\n \"working\",\n \"filled\",\n \"canceled\",\n \"rejected\",\n] as const;\nexport type OrderStatusValue = (typeof ORDER_STATUS_VALUES)[number];\n\nexport const ORDER_ORIGIN_SCOPE_VALUES = [\n \"direct\",\n \"attached_risk\",\n \"standalone_trigger\",\n \"system\",\n] as const;\nexport type OrderOriginScope = (typeof ORDER_ORIGIN_SCOPE_VALUES)[number];\n\nexport const ORDER_TRIGGER_TYPE_VALUES = [\n \"unspecified\",\n \"stop_loss\",\n \"take_profit\",\n \"trailing_stop\",\n \"twap\",\n \"ladder\",\n] as const;\nexport type OrderTriggerType = (typeof ORDER_TRIGGER_TYPE_VALUES)[number];\n\nexport const ATTACHED_RISK_LEG_STATUS_VALUES = [\n \"not_configured\",\n \"created\",\n \"armed\",\n \"running\",\n \"completed\",\n \"canceled\",\n \"failed\",\n \"paused\",\n] as const;\nexport type AttachedRiskLegStatusValue = (typeof ATTACHED_RISK_LEG_STATUS_VALUES)[number];\n\nexport const MODIFY_BEHAVIOR_VALUES = [\"AMEND_OR_REPLACE\", \"AMEND_ONLY\", \"REPLACE_ONLY\"] as const;\nexport type ModifyBehaviorValue = (typeof MODIFY_BEHAVIOR_VALUES)[number];\n\nexport const MODIFY_ACTION_VALUES = [\"AMENDED\", \"REPLACED\"] as const;\nexport type ModifyActionValue = (typeof MODIFY_ACTION_VALUES)[number];\n\nexport const BATCH_REPLACE_ADMISSION_STATUS_VALUES = [\n \"admitted\",\n \"partially_admitted\",\n \"rejected\",\n] as const;\nexport type BatchReplaceAdmissionStatusValue =\n (typeof BATCH_REPLACE_ADMISSION_STATUS_VALUES)[number];\n\nexport const BATCH_REPLACE_ITEM_ADMISSION_STATUS_VALUES = [\"admitted\", \"rejected\"] as const;\nexport type BatchReplaceItemAdmissionStatusValue =\n (typeof BATCH_REPLACE_ITEM_ADMISSION_STATUS_VALUES)[number];\n\nexport const BATCH_REPLACE_PHASE_VALUES = [\"admitted\", \"working\", \"rejected\", \"terminal\"] as const;\nexport type BatchReplacePhaseValue = (typeof BATCH_REPLACE_PHASE_VALUES)[number];\n\nexport const OrderStatusFilterCodec = {\n inputToProto: {\n FILLED: ProtoRead.OrderStatus.FILLED,\n CANCELED: ProtoRead.OrderStatus.CANCELED,\n REJECTED: ProtoRead.OrderStatus.REJECTED,\n } satisfies InputToProto<OrderStatusFilterValue, ProtoRead.OrderStatus>,\n} as const;\n\nexport const OrderStatusCodec = {\n protoToOutput: {\n [ProtoRead.OrderStatus.ORDER_STATUS_UNSPECIFIED]: \"unspecified\",\n [ProtoRead.OrderStatus.PENDING]: \"pending\",\n [ProtoRead.OrderStatus.PENDING_CANCEL]: \"pending_cancel\",\n [ProtoRead.OrderStatus.WORKING]: \"working\",\n [ProtoRead.OrderStatus.FILLED]: \"filled\",\n [ProtoRead.OrderStatus.CANCELED]: \"canceled\",\n [ProtoRead.OrderStatus.REJECTED]: \"rejected\",\n } satisfies ProtoToOutput<ProtoRead.OrderStatus, OrderStatusValue>,\n} as const;\n\nexport const OrderOriginScopeCodec = {\n protoToOutput: {\n [ProtoRead.OrderOriginScope.ORDER_ORIGIN_SCOPE_UNSPECIFIED]: \"unspecified\",\n [ProtoRead.OrderOriginScope.DIRECT]: \"direct\",\n [ProtoRead.OrderOriginScope.ATTACHED_RISK]: \"attached_risk\",\n [ProtoRead.OrderOriginScope.STANDALONE_TRIGGER]: \"standalone_trigger\",\n [ProtoRead.OrderOriginScope.SYSTEM]: \"system\",\n } satisfies ProtoToOutput<ProtoRead.OrderOriginScope, OrderOriginScope>,\n} as const;\n\nexport const OrderTriggerTypeCodec = {\n protoToOutput: {\n [ProtoRead.OrderTriggerType.ORDER_TRIGGER_TYPE_UNSPECIFIED]: \"unspecified\",\n [ProtoRead.OrderTriggerType.STOP_LOSS]: \"stop_loss\",\n [ProtoRead.OrderTriggerType.TAKE_PROFIT]: \"take_profit\",\n [ProtoRead.OrderTriggerType.TRAILING_STOP]: \"trailing_stop\",\n [ProtoRead.OrderTriggerType.TWAP]: \"twap\",\n [ProtoRead.OrderTriggerType.LADDER]: \"ladder\",\n } satisfies Record<ProtoRead.OrderTriggerType, OrderTriggerType>,\n} as const;\n\nexport const AttachedRiskLegStatusCodec = {\n protoToOutput: {\n [ProtoRead.AttachedRiskLegState_Status.STATUS_UNSPECIFIED]: \"unspecified\",\n [ProtoRead.AttachedRiskLegState_Status.NOT_CONFIGURED]: \"not_configured\",\n [ProtoRead.AttachedRiskLegState_Status.CREATED]: \"created\",\n [ProtoRead.AttachedRiskLegState_Status.ARMED]: \"armed\",\n [ProtoRead.AttachedRiskLegState_Status.RUNNING]: \"running\",\n [ProtoRead.AttachedRiskLegState_Status.COMPLETED]: \"completed\",\n [ProtoRead.AttachedRiskLegState_Status.CANCELED]: \"canceled\",\n [ProtoRead.AttachedRiskLegState_Status.FAILED]: \"failed\",\n [ProtoRead.AttachedRiskLegState_Status.PAUSED]: \"paused\",\n } satisfies ProtoToOutput<ProtoRead.AttachedRiskLegState_Status, AttachedRiskLegStatusValue>,\n} as const;\n\nexport const ModifyBehaviorCodec = {\n inputToProto: {\n AMEND_OR_REPLACE: ProtoWrite.ModifyBehavior.AMEND_OR_REPLACE,\n AMEND_ONLY: ProtoWrite.ModifyBehavior.AMEND_ONLY,\n REPLACE_ONLY: ProtoWrite.ModifyBehavior.REPLACE_ONLY,\n } satisfies InputToProto<ModifyBehaviorValue, ProtoWrite.ModifyBehavior>,\n} as const;\n\nexport const ModifyActionCodec = {\n protoToOutput: {\n [ProtoWrite.ModifyActionTaken.MODIFY_ACTION_UNSPECIFIED]: \"unspecified\",\n [ProtoWrite.ModifyActionTaken.AMENDED]: \"AMENDED\",\n [ProtoWrite.ModifyActionTaken.REPLACED]: \"REPLACED\",\n } satisfies ProtoToOutput<ProtoWrite.ModifyActionTaken, ModifyActionValue>,\n} as const;\n\nexport const BatchReplaceAdmissionStatusCodec = {\n protoToOutput: {\n [ProtoWrite.BatchReplaceAdmissionStatus.UNSPECIFIED]: \"unspecified\",\n [ProtoWrite.BatchReplaceAdmissionStatus.ADMITTED]: \"admitted\",\n [ProtoWrite.BatchReplaceAdmissionStatus.PARTIALLY_ADMITTED]: \"partially_admitted\",\n [ProtoWrite.BatchReplaceAdmissionStatus.REJECTED]: \"rejected\",\n } satisfies ProtoToOutput<\n ProtoWrite.BatchReplaceAdmissionStatus,\n BatchReplaceAdmissionStatusValue\n >,\n} as const;\n\nexport const BatchReplaceItemAdmissionStatusCodec = {\n protoToOutput: {\n [ProtoWrite.BatchReplaceItemAdmissionStatus.UNSPECIFIED]: \"unspecified\",\n [ProtoWrite.BatchReplaceItemAdmissionStatus.ADMITTED]: \"admitted\",\n [ProtoWrite.BatchReplaceItemAdmissionStatus.REJECTED]: \"rejected\",\n } satisfies ProtoToOutput<\n ProtoWrite.BatchReplaceItemAdmissionStatus,\n BatchReplaceItemAdmissionStatusValue\n >,\n} as const;\n\nexport const BatchReplacePhaseCodec = {\n protoToOutput: {\n [ProtoRead.BatchReplacePhase.UNSPECIFIED]: \"unspecified\",\n [ProtoRead.BatchReplacePhase.ADMITTED]: \"admitted\",\n [ProtoRead.BatchReplacePhase.WORKING]: \"working\",\n [ProtoRead.BatchReplacePhase.REJECTED]: \"rejected\",\n [ProtoRead.BatchReplacePhase.TERMINAL]: \"terminal\",\n } satisfies ProtoToOutput<ProtoRead.BatchReplacePhase, BatchReplacePhaseValue>,\n} as const;\n"],"mappings":";;;;AA0BA,MAAa,6BAA6B;CAAC;CAAU;CAAY;AAAU;AA2C3E,MAAa,yBAAyB;CAAC;CAAoB;CAAc;AAAc;AAqBvF,MAAa,yBAAyB,EAClC,cAAc;CACV,QAAA;CACA,UAAA;CACA,UAAA;AACJ,EACJ;AAEA,MAAa,mBAAmB,EAC5B,eAAe;EACuC,IAAA;EACjB,IAAA;EACO,IAAA;EACP,IAAA;EACD,IAAA;EACE,IAAA;EACA,IAAA;AACtC,EACJ;AAEA,MAAa,wBAAwB,EACjC,eAAe;EACkD,IAAA;EACxB,IAAA;EACO,IAAA;EACK,IAAA;EACZ,IAAA;AACzC,EACJ;AAEA,MAAa,wBAAwB,EACjC,eAAe;EACkD,IAAA;EACrB,IAAA;EACE,IAAA;EACE,IAAA;EACT,IAAA;EACE,IAAA;AACzC,EACJ;AAEA,MAAa,6BAA6B,EACtC,eAAe;EACiD,IAAA;EACJ,IAAA;EACP,IAAA;EACF,IAAA;EACE,IAAA;EACE,IAAA;EACD,IAAA;EACF,IAAA;EACA,IAAA;AACpD,EACJ;AAEA,MAAa,sBAAsB,EAC/B,cAAc;CACV,kBAAA;CACA,YAAA;CACA,cAAA;AACJ,EACJ;AAEA,MAAa,oBAAoB,EAC7B,eAAe;EAC+C,IAAA;EAClB,IAAA;EACC,IAAA;AAC7C,EACJ;AAEA,MAAa,mCAAmC,EAC5C,eAAe;EAC2C,IAAA;EACH,IAAA;EACU,IAAA;EACV,IAAA;AACvD,EAIJ;AAEA,MAAa,uCAAuC,EAChD,eAAe;EAC+C,IAAA;EACH,IAAA;EACA,IAAA;AAC3D,EAIJ;AAEA,MAAa,yBAAyB,EAClC,eAAe;EACgC,IAAA;EACH,IAAA;EACD,IAAA;EACC,IAAA;EACA,IAAA;AAC5C,EACJ"}
|
|
1
|
+
{"version":3,"file":"orders.codecs.js","names":[],"sources":["../../../src/services/orders/orders.codecs.ts"],"sourcesContent":["import * as ProtoRead from \"../../gen/orders/v1/orders_read_pb.js\";\nimport * as ProtoWrite from \"../../gen/orders/v1/orders_pb.js\";\nimport type { InputToProto, ProtoToOutput } from \"../../utils/types.js\";\nexport {\n FEE_ASSET_VALUES,\n FeeAssetCodec,\n type FeeAssetValue,\n ORDER_SIDE_VALUES,\n ORDER_TYPE_VALUES,\n OrderSideCodec,\n type OrderSideValue,\n OrderTypeCodec,\n type OrderTypeValue,\n SELF_TRADE_PREVENTION_MODE_VALUES,\n SelfTradePreventionModeCodec,\n type SelfTradePreventionModeValue,\n TIME_IN_FORCE_OUTPUT_VALUES,\n TIME_IN_FORCE_VALUES,\n TimeInForceCodec,\n type TimeInForceOutputValue,\n type TimeInForceValue,\n TRIGGER_PRICE_SOURCE_VALUES,\n TriggerPriceSourceCodec,\n type TriggerPriceSourceValue,\n} from \"./order-enums.codecs.js\";\n\nexport const ORDER_STATUS_FILTER_VALUES = [\"FILLED\", \"CANCELED\", \"REJECTED\"] as const;\nexport type OrderStatusFilterValue = (typeof ORDER_STATUS_FILTER_VALUES)[number];\n\nexport const ORDER_STATUS_VALUES = [\n \"pending\",\n \"pending_cancel\",\n \"working\",\n \"filled\",\n \"canceled\",\n \"rejected\",\n] as const;\nexport type OrderStatusValue = (typeof ORDER_STATUS_VALUES)[number];\n\nexport const ORDER_ORIGIN_SCOPE_VALUES = [\n \"direct\",\n \"attached_risk\",\n \"standalone_trigger\",\n \"system\",\n] as const;\nexport type OrderOriginScope = (typeof ORDER_ORIGIN_SCOPE_VALUES)[number];\n\nexport const ORDER_TRIGGER_TYPE_VALUES = [\n \"unspecified\",\n \"stop_loss\",\n \"take_profit\",\n \"trailing_stop\",\n \"twap\",\n \"ladder\",\n] as const;\nexport type OrderTriggerType = (typeof ORDER_TRIGGER_TYPE_VALUES)[number];\n\nexport const ATTACHED_RISK_LEG_STATUS_VALUES = [\n \"not_configured\",\n \"created\",\n \"armed\",\n \"running\",\n \"completed\",\n \"canceled\",\n \"failed\",\n \"paused\",\n] as const;\nexport type AttachedRiskLegStatusValue = (typeof ATTACHED_RISK_LEG_STATUS_VALUES)[number];\n\nexport const MODIFY_BEHAVIOR_VALUES = [\"AMEND_OR_REPLACE\", \"AMEND_ONLY\", \"REPLACE_ONLY\"] as const;\nexport type ModifyBehaviorValue = (typeof MODIFY_BEHAVIOR_VALUES)[number];\n\nexport const MODIFY_ACTION_VALUES = [\"AMENDED\", \"REPLACED\"] as const;\nexport type ModifyActionValue = (typeof MODIFY_ACTION_VALUES)[number];\n\nexport const BATCH_REPLACE_ADMISSION_STATUS_VALUES = [\n \"admitted\",\n \"partially_admitted\",\n \"rejected\",\n] as const;\nexport type BatchReplaceAdmissionStatusValue =\n (typeof BATCH_REPLACE_ADMISSION_STATUS_VALUES)[number];\n\nexport const BATCH_REPLACE_ITEM_ADMISSION_STATUS_VALUES = [\"admitted\", \"rejected\"] as const;\nexport type BatchReplaceItemAdmissionStatusValue =\n (typeof BATCH_REPLACE_ITEM_ADMISSION_STATUS_VALUES)[number];\n\nexport const BATCH_REPLACE_PHASE_VALUES = [\"admitted\", \"working\", \"rejected\", \"terminal\"] as const;\nexport type BatchReplacePhaseValue = (typeof BATCH_REPLACE_PHASE_VALUES)[number];\n\nexport const CancelOrderStatusCodec = {\n protoToOutput: {\n [ProtoWrite.CancelOrderResponse_Status.STATUS_UNSPECIFIED]: \"unspecified\",\n [ProtoWrite.CancelOrderResponse_Status.ACCEPTED]: \"accepted\",\n } satisfies ProtoToOutput<ProtoWrite.CancelOrderResponse_Status, \"accepted\">,\n} as const;\n\nexport const CancelAllOrdersStatusCodec = {\n protoToOutput: {\n [ProtoWrite.CancelAllOrdersResponse_Status.STATUS_UNSPECIFIED]: \"unspecified\",\n [ProtoWrite.CancelAllOrdersResponse_Status.SUBMITTED]: \"submitted\",\n [ProtoWrite.CancelAllOrdersResponse_Status.DRY_RUN]: \"dry_run\",\n } satisfies ProtoToOutput<ProtoWrite.CancelAllOrdersResponse_Status, \"submitted\" | \"dry_run\">,\n} as const;\n\nexport const CancelAllAfterStatusCodec = {\n protoToOutput: {\n [ProtoWrite.CancelAllAfterResponse_Status.STATUS_UNSPECIFIED]: \"unspecified\",\n [ProtoWrite.CancelAllAfterResponse_Status.ARMED]: \"armed\",\n [ProtoWrite.CancelAllAfterResponse_Status.DISABLED]: \"disabled\",\n } satisfies ProtoToOutput<ProtoWrite.CancelAllAfterResponse_Status, \"armed\" | \"disabled\">,\n} as const;\n\nexport const BatchCancelOrderStatusCodec = {\n protoToOutput: {\n [ProtoWrite.BatchCancelResultItem_Status.STATUS_UNSPECIFIED]: \"unspecified\",\n [ProtoWrite.BatchCancelResultItem_Status.ACCEPTED]: \"accepted\",\n [ProtoWrite.BatchCancelResultItem_Status.REJECTED]: \"rejected\",\n } satisfies ProtoToOutput<ProtoWrite.BatchCancelResultItem_Status, \"accepted\" | \"rejected\">,\n} as const;\n\nexport const OrderStatusFilterCodec = {\n inputToProto: {\n FILLED: ProtoRead.OrderStatus.FILLED,\n CANCELED: ProtoRead.OrderStatus.CANCELED,\n REJECTED: ProtoRead.OrderStatus.REJECTED,\n } satisfies InputToProto<OrderStatusFilterValue, ProtoRead.OrderStatus>,\n} as const;\n\nexport const OrderStatusCodec = {\n protoToOutput: {\n [ProtoRead.OrderStatus.ORDER_STATUS_UNSPECIFIED]: \"unspecified\",\n [ProtoRead.OrderStatus.PENDING]: \"pending\",\n [ProtoRead.OrderStatus.PENDING_CANCEL]: \"pending_cancel\",\n [ProtoRead.OrderStatus.WORKING]: \"working\",\n [ProtoRead.OrderStatus.FILLED]: \"filled\",\n [ProtoRead.OrderStatus.CANCELED]: \"canceled\",\n [ProtoRead.OrderStatus.REJECTED]: \"rejected\",\n } satisfies ProtoToOutput<ProtoRead.OrderStatus, OrderStatusValue>,\n} as const;\n\nexport const OrderOriginScopeCodec = {\n protoToOutput: {\n [ProtoRead.OrderOriginScope.ORDER_ORIGIN_SCOPE_UNSPECIFIED]: \"unspecified\",\n [ProtoRead.OrderOriginScope.DIRECT]: \"direct\",\n [ProtoRead.OrderOriginScope.ATTACHED_RISK]: \"attached_risk\",\n [ProtoRead.OrderOriginScope.STANDALONE_TRIGGER]: \"standalone_trigger\",\n [ProtoRead.OrderOriginScope.SYSTEM]: \"system\",\n } satisfies ProtoToOutput<ProtoRead.OrderOriginScope, OrderOriginScope>,\n} as const;\n\nexport const OrderTriggerTypeCodec = {\n protoToOutput: {\n [ProtoRead.OrderTriggerType.ORDER_TRIGGER_TYPE_UNSPECIFIED]: \"unspecified\",\n [ProtoRead.OrderTriggerType.STOP_LOSS]: \"stop_loss\",\n [ProtoRead.OrderTriggerType.TAKE_PROFIT]: \"take_profit\",\n [ProtoRead.OrderTriggerType.TRAILING_STOP]: \"trailing_stop\",\n [ProtoRead.OrderTriggerType.TWAP]: \"twap\",\n [ProtoRead.OrderTriggerType.LADDER]: \"ladder\",\n } satisfies Record<ProtoRead.OrderTriggerType, OrderTriggerType>,\n} as const;\n\nexport const AttachedRiskLegStatusCodec = {\n protoToOutput: {\n [ProtoRead.AttachedRiskLegState_Status.STATUS_UNSPECIFIED]: \"unspecified\",\n [ProtoRead.AttachedRiskLegState_Status.NOT_CONFIGURED]: \"not_configured\",\n [ProtoRead.AttachedRiskLegState_Status.CREATED]: \"created\",\n [ProtoRead.AttachedRiskLegState_Status.ARMED]: \"armed\",\n [ProtoRead.AttachedRiskLegState_Status.RUNNING]: \"running\",\n [ProtoRead.AttachedRiskLegState_Status.COMPLETED]: \"completed\",\n [ProtoRead.AttachedRiskLegState_Status.CANCELED]: \"canceled\",\n [ProtoRead.AttachedRiskLegState_Status.FAILED]: \"failed\",\n [ProtoRead.AttachedRiskLegState_Status.PAUSED]: \"paused\",\n } satisfies ProtoToOutput<ProtoRead.AttachedRiskLegState_Status, AttachedRiskLegStatusValue>,\n} as const;\n\nexport const ModifyBehaviorCodec = {\n inputToProto: {\n AMEND_OR_REPLACE: ProtoWrite.ModifyBehavior.AMEND_OR_REPLACE,\n AMEND_ONLY: ProtoWrite.ModifyBehavior.AMEND_ONLY,\n REPLACE_ONLY: ProtoWrite.ModifyBehavior.REPLACE_ONLY,\n } satisfies InputToProto<ModifyBehaviorValue, ProtoWrite.ModifyBehavior>,\n} as const;\n\nexport const ModifyActionCodec = {\n protoToOutput: {\n [ProtoWrite.ModifyActionTaken.MODIFY_ACTION_UNSPECIFIED]: \"unspecified\",\n [ProtoWrite.ModifyActionTaken.AMENDED]: \"AMENDED\",\n [ProtoWrite.ModifyActionTaken.REPLACED]: \"REPLACED\",\n } satisfies ProtoToOutput<ProtoWrite.ModifyActionTaken, ModifyActionValue>,\n} as const;\n\nexport const BatchReplaceAdmissionStatusCodec = {\n protoToOutput: {\n [ProtoWrite.BatchReplaceAdmissionStatus.UNSPECIFIED]: \"unspecified\",\n [ProtoWrite.BatchReplaceAdmissionStatus.ADMITTED]: \"admitted\",\n [ProtoWrite.BatchReplaceAdmissionStatus.PARTIALLY_ADMITTED]: \"partially_admitted\",\n [ProtoWrite.BatchReplaceAdmissionStatus.REJECTED]: \"rejected\",\n } satisfies ProtoToOutput<\n ProtoWrite.BatchReplaceAdmissionStatus,\n BatchReplaceAdmissionStatusValue\n >,\n} as const;\n\nexport const BatchReplaceItemAdmissionStatusCodec = {\n protoToOutput: {\n [ProtoWrite.BatchReplaceItemAdmissionStatus.UNSPECIFIED]: \"unspecified\",\n [ProtoWrite.BatchReplaceItemAdmissionStatus.ADMITTED]: \"admitted\",\n [ProtoWrite.BatchReplaceItemAdmissionStatus.REJECTED]: \"rejected\",\n } satisfies ProtoToOutput<\n ProtoWrite.BatchReplaceItemAdmissionStatus,\n BatchReplaceItemAdmissionStatusValue\n >,\n} as const;\n\nexport const BatchReplacePhaseCodec = {\n protoToOutput: {\n [ProtoRead.BatchReplacePhase.UNSPECIFIED]: \"unspecified\",\n [ProtoRead.BatchReplacePhase.ADMITTED]: \"admitted\",\n [ProtoRead.BatchReplacePhase.WORKING]: \"working\",\n [ProtoRead.BatchReplacePhase.REJECTED]: \"rejected\",\n [ProtoRead.BatchReplacePhase.TERMINAL]: \"terminal\",\n } satisfies ProtoToOutput<ProtoRead.BatchReplacePhase, BatchReplacePhaseValue>,\n} as const;\n"],"mappings":";;;;AA0BA,MAAa,6BAA6B;CAAC;CAAU;CAAY;AAAU;AA2C3E,MAAa,yBAAyB;CAAC;CAAoB;CAAc;AAAc;AAqBvF,MAAa,yBAAyB,EAClC,eAAe;EACiD,IAAA;EACV,IAAA;AACtD,EACJ;AAEA,MAAa,6BAA6B,EACtC,eAAe;EACqD,IAAA;EACT,IAAA;EACF,IAAA;AACzD,EACJ;AAEA,MAAa,4BAA4B,EACrC,eAAe;EACoD,IAAA;EACb,IAAA;EACG,IAAA;AACzD,EACJ;AAEA,MAAa,8BAA8B,EACvC,eAAe;EACmD,IAAA;EACV,IAAA;EACA,IAAA;AACxD,EACJ;AAEA,MAAa,yBAAyB,EAClC,cAAc;CACV,QAAA;CACA,UAAA;CACA,UAAA;AACJ,EACJ;AAEA,MAAa,mBAAmB,EAC5B,eAAe;EACuC,IAAA;EACjB,IAAA;EACO,IAAA;EACP,IAAA;EACD,IAAA;EACE,IAAA;EACA,IAAA;AACtC,EACJ;AAEA,MAAa,wBAAwB,EACjC,eAAe;EACkD,IAAA;EACxB,IAAA;EACO,IAAA;EACK,IAAA;EACZ,IAAA;AACzC,EACJ;AAEA,MAAa,wBAAwB,EACjC,eAAe;EACkD,IAAA;EACrB,IAAA;EACE,IAAA;EACE,IAAA;EACT,IAAA;EACE,IAAA;AACzC,EACJ;AAEA,MAAa,6BAA6B,EACtC,eAAe;EACiD,IAAA;EACJ,IAAA;EACP,IAAA;EACF,IAAA;EACE,IAAA;EACE,IAAA;EACD,IAAA;EACF,IAAA;EACA,IAAA;AACpD,EACJ;AAEA,MAAa,sBAAsB,EAC/B,cAAc;CACV,kBAAA;CACA,YAAA;CACA,cAAA;AACJ,EACJ;AAEA,MAAa,oBAAoB,EAC7B,eAAe;EAC+C,IAAA;EAClB,IAAA;EACC,IAAA;AAC7C,EACJ;AAEA,MAAa,mCAAmC,EAC5C,eAAe;EAC2C,IAAA;EACH,IAAA;EACU,IAAA;EACV,IAAA;AACvD,EAIJ;AAEA,MAAa,uCAAuC,EAChD,eAAe;EAC+C,IAAA;EACH,IAAA;EACA,IAAA;AAC3D,EAIJ;AAEA,MAAa,yBAAyB,EAClC,eAAe;EACgC,IAAA;EACH,IAAA;EACD,IAAA;EACC,IAAA;EACA,IAAA;AAC5C,EACJ"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import "../../gen/auth/v1/subaccounts_pb.js";
|
|
2
2
|
//#region src/services/subaccounts/subaccounts.codecs.ts
|
|
3
|
+
const SUBACCOUNT_INVITE_DIRECTION_VALUES = [
|
|
4
|
+
"",
|
|
5
|
+
"incoming",
|
|
6
|
+
"outgoing"
|
|
7
|
+
];
|
|
3
8
|
const SUBACCOUNT_STATUS_VALUES = ["active", "disabled"];
|
|
4
9
|
const SubaccountRoleCodec = {
|
|
5
10
|
inputToProto: {
|
|
@@ -60,6 +65,11 @@ const InviteStatusCodec = { protoToOutput: {
|
|
|
60
65
|
[3]: "declined",
|
|
61
66
|
[4]: "cancelled"
|
|
62
67
|
} };
|
|
68
|
+
const SubaccountInviteDirectionCodec = { inputToProto: {
|
|
69
|
+
"": 0,
|
|
70
|
+
incoming: 1,
|
|
71
|
+
outgoing: 2
|
|
72
|
+
} };
|
|
63
73
|
const SubaccountStatusCodec = {
|
|
64
74
|
inputToProto: {
|
|
65
75
|
active: 1,
|
|
@@ -107,6 +117,6 @@ const ActivityEventSourceCodec = { protoToOutput: {
|
|
|
107
117
|
[3]: "api"
|
|
108
118
|
} };
|
|
109
119
|
//#endregion
|
|
110
|
-
export { ActivityEntityKindCodec, ActivityEventActionCodec, ActivityEventSourceCodec, InviteActionCodec, InviteStatusCodec, SUBACCOUNT_STATUS_VALUES, SubaccountPermissionCodec, SubaccountRoleCodec, SubaccountStatusCodec };
|
|
120
|
+
export { ActivityEntityKindCodec, ActivityEventActionCodec, ActivityEventSourceCodec, InviteActionCodec, InviteStatusCodec, SUBACCOUNT_INVITE_DIRECTION_VALUES, SUBACCOUNT_STATUS_VALUES, SubaccountInviteDirectionCodec, SubaccountPermissionCodec, SubaccountRoleCodec, SubaccountStatusCodec };
|
|
111
121
|
|
|
112
122
|
//# sourceMappingURL=subaccounts.codecs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccounts.codecs.js","names":[],"sources":["../../../src/services/subaccounts/subaccounts.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport type { InputToProto, ProtoToOutput } from \"../../utils/types.js\";\n\nexport const SUBACCOUNT_ROLE_VALUES = [\n \"owner\",\n \"admin\",\n \"treasury\",\n \"leveraged_trader\",\n \"trader\",\n \"viewer\",\n] as const;\nexport type SubaccountRoleValue = (typeof SUBACCOUNT_ROLE_VALUES)[number];\n\nexport const SUBACCOUNT_PERMISSION_VALUES = [\n \"read_subaccount\",\n \"update_subaccount\",\n \"read_balances\",\n \"read_spot\",\n \"trade_spot\",\n \"read_internal_transfers\",\n \"internal_transfer\",\n \"external_withdraw\",\n \"read_address_book\",\n \"manage_address_book\",\n \"read_members\",\n \"manage_members\",\n \"read_invites\",\n \"manage_invites\",\n \"read_api_keys\",\n \"manage_api_keys\",\n \"read_subaccount_policy\",\n \"manage_subaccount_policy\",\n \"read_activity\",\n \"read_activity_security_details\",\n \"manage_member_mfa_requirement\",\n \"create_deposit_address\",\n \"read_deposit_addresses\",\n \"read_guard_signer_status\",\n \"manage_guard_signer\",\n] as const;\nexport type SubaccountPermissionValue = (typeof SUBACCOUNT_PERMISSION_VALUES)[number];\n\nexport const SUBACCOUNT_INVITE_ACTION_VALUES = [\"accept\", \"decline\", \"cancel\"] as const;\nexport type SubaccountInviteActionValue = (typeof SUBACCOUNT_INVITE_ACTION_VALUES)[number];\n\nexport const SUBACCOUNT_INVITE_STATUS_VALUES = [\n \"pending\",\n \"accepted\",\n \"declined\",\n \"cancelled\",\n] as const;\nexport type SubaccountInviteStatusValue = (typeof SUBACCOUNT_INVITE_STATUS_VALUES)[number];\n\nexport const SUBACCOUNT_STATUS_VALUES = [\"active\", \"disabled\"] as const;\nexport type SubaccountStatusValue = (typeof SUBACCOUNT_STATUS_VALUES)[number];\n\nexport const ACTIVITY_ENTITY_KIND_VALUES = [\n \"account\",\n \"session\",\n \"api_key\",\n \"subaccount\",\n \"member\",\n \"policy\",\n \"invite\",\n \"security\",\n \"destination\",\n] as const;\nexport type ActivityEntityKindValue = (typeof ACTIVITY_ENTITY_KIND_VALUES)[number];\n\nexport const ACTIVITY_EVENT_ACTION_VALUES = [\n \"created\",\n \"updated\",\n \"deleted\",\n \"enabled\",\n \"disabled\",\n \"removed\",\n \"role_set\",\n \"received\",\n \"replied\",\n \"failed\",\n \"revoked\",\n \"blocked\",\n \"hold_placed\",\n \"hold_released\",\n] as const;\nexport type ActivityEventActionValue = (typeof ACTIVITY_EVENT_ACTION_VALUES)[number];\n\nexport const ACTIVITY_EVENT_SOURCE_VALUES = [\"web\", \"mobile\", \"api\"] as const;\nexport type ActivityEventSourceValue = (typeof ACTIVITY_EVENT_SOURCE_VALUES)[number];\n\nexport const SubaccountRoleCodec = {\n inputToProto: {\n owner: Proto.SubaccountRole.OWNER,\n admin: Proto.SubaccountRole.ADMIN,\n treasury: Proto.SubaccountRole.TREASURY,\n leveraged_trader: Proto.SubaccountRole.LEVERAGED_TRADER,\n trader: Proto.SubaccountRole.TRADER,\n viewer: Proto.SubaccountRole.VIEWER,\n } satisfies InputToProto<SubaccountRoleValue, Proto.SubaccountRole>,\n protoToOutput: {\n [Proto.SubaccountRole.SUBACCOUNT_ROLE_UNSPECIFIED]: \"unspecified\",\n [Proto.SubaccountRole.OWNER]: \"owner\",\n [Proto.SubaccountRole.ADMIN]: \"admin\",\n [Proto.SubaccountRole.TREASURY]: \"treasury\",\n [Proto.SubaccountRole.LEVERAGED_TRADER]: \"leveraged_trader\",\n [Proto.SubaccountRole.TRADER]: \"trader\",\n [Proto.SubaccountRole.VIEWER]: \"viewer\",\n } satisfies ProtoToOutput<Proto.SubaccountRole, SubaccountRoleValue>,\n} as const;\n\nexport const SubaccountPermissionCodec = {\n protoToOutput: {\n [Proto.SubaccountPermission.UNSPECIFIED]: \"unspecified\",\n [Proto.SubaccountPermission.READ_SUBACCOUNT]: \"read_subaccount\",\n [Proto.SubaccountPermission.UPDATE_SUBACCOUNT]: \"update_subaccount\",\n [Proto.SubaccountPermission.READ_BALANCES]: \"read_balances\",\n [Proto.SubaccountPermission.READ_SPOT]: \"read_spot\",\n [Proto.SubaccountPermission.TRADE_SPOT]: \"trade_spot\",\n [Proto.SubaccountPermission.READ_INTERNAL_TRANSFERS]: \"read_internal_transfers\",\n [Proto.SubaccountPermission.INTERNAL_TRANSFER]: \"internal_transfer\",\n [Proto.SubaccountPermission.EXTERNAL_WITHDRAW]: \"external_withdraw\",\n [Proto.SubaccountPermission.READ_ADDRESS_BOOK]: \"read_address_book\",\n [Proto.SubaccountPermission.MANAGE_ADDRESS_BOOK]: \"manage_address_book\",\n [Proto.SubaccountPermission.READ_MEMBERS]: \"read_members\",\n [Proto.SubaccountPermission.MANAGE_MEMBERS]: \"manage_members\",\n [Proto.SubaccountPermission.READ_INVITES]: \"read_invites\",\n [Proto.SubaccountPermission.MANAGE_INVITES]: \"manage_invites\",\n [Proto.SubaccountPermission.READ_API_KEYS]: \"read_api_keys\",\n [Proto.SubaccountPermission.MANAGE_API_KEYS]: \"manage_api_keys\",\n [Proto.SubaccountPermission.READ_SUBACCOUNT_POLICY]: \"read_subaccount_policy\",\n [Proto.SubaccountPermission.MANAGE_SUBACCOUNT_POLICY]: \"manage_subaccount_policy\",\n [Proto.SubaccountPermission.READ_ACTIVITY]: \"read_activity\",\n [Proto.SubaccountPermission.READ_ACTIVITY_SECURITY_DETAILS]:\n \"read_activity_security_details\",\n [Proto.SubaccountPermission.MANAGE_MEMBER_MFA_REQUIREMENT]: \"manage_member_mfa_requirement\",\n [Proto.SubaccountPermission.CREATE_DEPOSIT_ADDRESS]: \"create_deposit_address\",\n [Proto.SubaccountPermission.READ_DEPOSIT_ADDRESSES]: \"read_deposit_addresses\",\n [Proto.SubaccountPermission.READ_GUARD_SIGNER_STATUS]: \"read_guard_signer_status\",\n [Proto.SubaccountPermission.MANAGE_GUARD_SIGNER]: \"manage_guard_signer\",\n } satisfies ProtoToOutput<Proto.SubaccountPermission, SubaccountPermissionValue>,\n} as const;\n\nexport const InviteActionCodec = {\n inputToProto: {\n accept: Proto.SubaccountInviteAction.ACCEPT,\n decline: Proto.SubaccountInviteAction.DECLINE,\n cancel: Proto.SubaccountInviteAction.CANCEL,\n } satisfies InputToProto<SubaccountInviteActionValue, Proto.SubaccountInviteAction>,\n} as const;\n\nexport const InviteStatusCodec = {\n protoToOutput: {\n [Proto.SubaccountInviteStatus.UNSPECIFIED]: \"unspecified\",\n [Proto.SubaccountInviteStatus.PENDING]: \"pending\",\n [Proto.SubaccountInviteStatus.ACCEPTED]: \"accepted\",\n [Proto.SubaccountInviteStatus.DECLINED]: \"declined\",\n [Proto.SubaccountInviteStatus.CANCELLED]: \"cancelled\",\n } satisfies ProtoToOutput<Proto.SubaccountInviteStatus, SubaccountInviteStatusValue>,\n} as const;\n\nexport const SubaccountStatusCodec = {\n inputToProto: {\n active: Proto.SubaccountStatus.ACTIVE,\n disabled: Proto.SubaccountStatus.DISABLED,\n } satisfies InputToProto<SubaccountStatusValue, Proto.SubaccountStatus>,\n protoToOutput: {\n [Proto.SubaccountStatus.UNSPECIFIED]: \"unspecified\",\n [Proto.SubaccountStatus.ACTIVE]: \"active\",\n [Proto.SubaccountStatus.DISABLED]: \"disabled\",\n } satisfies ProtoToOutput<Proto.SubaccountStatus, SubaccountStatusValue>,\n} as const;\n\nexport const ActivityEntityKindCodec = {\n protoToOutput: {\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_UNSPECIFIED]: \"unspecified\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_ACCOUNT]: \"account\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_SESSION]: \"session\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_API_KEY]: \"api_key\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_SUBACCOUNT]: \"subaccount\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_MEMBER]: \"member\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_POLICY]: \"policy\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_INVITE]: \"invite\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_SECURITY]: \"security\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_DESTINATION]: \"destination\",\n } satisfies ProtoToOutput<Proto.ActivityEntityKind, ActivityEntityKindValue>,\n} as const;\n\nexport const ActivityEventActionCodec = {\n protoToOutput: {\n [Proto.ActivityEventAction.ACTIVITY_ACTION_UNSPECIFIED]: \"unspecified\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_CREATED]: \"created\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_UPDATED]: \"updated\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_DELETED]: \"deleted\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_ENABLED]: \"enabled\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_DISABLED]: \"disabled\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_REMOVED]: \"removed\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_ROLE_SET]: \"role_set\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_RECEIVED]: \"received\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_REPLIED]: \"replied\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_FAILED]: \"failed\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_REVOKED]: \"revoked\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_BLOCKED]: \"blocked\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_HOLD_PLACED]: \"hold_placed\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_HOLD_RELEASED]: \"hold_released\",\n } satisfies ProtoToOutput<Proto.ActivityEventAction, ActivityEventActionValue>,\n} as const;\n\nexport const ActivityEventSourceCodec = {\n protoToOutput: {\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_UNSPECIFIED]: \"unspecified\",\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_WEB]: \"web\",\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_MOBILE]: \"mobile\",\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_API]: \"api\",\n } satisfies ProtoToOutput<Proto.ActivityEventSource, ActivityEventSourceValue>,\n} as const;\n"],"mappings":";;AAqDA,MAAa,2BAA2B,CAAC,UAAU,UAAU;AAqC7D,MAAa,sBAAsB;CAC/B,cAAc;EACV,OAAA;EACA,OAAA;EACA,UAAA;EACA,kBAAA;EACA,QAAA;EACA,QAAA;CACJ;CACA,eAAe;GACyC,IAAA;GACtB,IAAA;GACA,IAAA;GACG,IAAA;GACQ,IAAA;GACV,IAAA;GACA,IAAA;CACnC;AACJ;AAEA,MAAa,4BAA4B,EACrC,eAAe;EAC+B,IAAA;EACI,IAAA;EACE,IAAA;EACJ,IAAA;EACJ,IAAA;EACC,IAAA;EACa,IAAA;EACN,IAAA;EACA,IAAA;EACA,IAAA;EACE,KAAA;EACP,KAAA;EACE,KAAA;EACF,KAAA;EACE,KAAA;EACD,KAAA;EACE,KAAA;EACO,KAAA;EACE,KAAA;EACX,KAAA;EAExC,KAAA;EACwD,KAAA;EACP,KAAA;EACA,KAAA;EACE,KAAA;EACL,KAAA;AACtD,EACJ;AAEA,MAAa,oBAAoB,EAC7B,cAAc;CACV,QAAA;CACA,SAAA;CACA,QAAA;AACJ,EACJ;AAEA,MAAa,oBAAoB,EAC7B,eAAe;EACiC,IAAA;EACJ,IAAA;EACC,IAAA;EACA,IAAA;EACC,IAAA;AAC9C,EACJ;AAEA,MAAa,wBAAwB;CACjC,cAAc;EACV,QAAA;EACA,UAAA;CACJ;CACA,eAAe;GAC2B,IAAA;GACL,IAAA;GACE,IAAA;CACvC;AACJ;AAEA,MAAa,0BAA0B,EACnC,eAAe;EAC6C,IAAA;EACJ,IAAA;EACA,IAAA;EACA,IAAA;EACG,IAAA;EACJ,IAAA;EACA,IAAA;EACA,IAAA;EACE,IAAA;EACG,IAAA;AAC5D,EACJ;AAEA,MAAa,2BAA2B,EACpC,eAAe;EAC8C,IAAA;EACJ,IAAA;EACA,IAAA;EACA,IAAA;EACA,IAAA;EACC,IAAA;EACD,IAAA;EACC,IAAA;EACA,IAAA;EACD,IAAA;EACD,KAAA;EACC,KAAA;EACA,KAAA;EACI,KAAA;EACE,KAAA;AAC/D,EACJ;AAEA,MAAa,2BAA2B,EACpC,eAAe;EAC8C,IAAA;EACR,IAAA;EACG,IAAA;EACH,IAAA;AACrD,EACJ"}
|
|
1
|
+
{"version":3,"file":"subaccounts.codecs.js","names":[],"sources":["../../../src/services/subaccounts/subaccounts.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport type { InputToProto, ProtoToOutput } from \"../../utils/types.js\";\n\nexport const SUBACCOUNT_ROLE_VALUES = [\n \"owner\",\n \"admin\",\n \"treasury\",\n \"leveraged_trader\",\n \"trader\",\n \"viewer\",\n] as const;\nexport type SubaccountRoleValue = (typeof SUBACCOUNT_ROLE_VALUES)[number];\n\nexport const SUBACCOUNT_PERMISSION_VALUES = [\n \"read_subaccount\",\n \"update_subaccount\",\n \"read_balances\",\n \"read_spot\",\n \"trade_spot\",\n \"read_internal_transfers\",\n \"internal_transfer\",\n \"external_withdraw\",\n \"read_address_book\",\n \"manage_address_book\",\n \"read_members\",\n \"manage_members\",\n \"read_invites\",\n \"manage_invites\",\n \"read_api_keys\",\n \"manage_api_keys\",\n \"read_subaccount_policy\",\n \"manage_subaccount_policy\",\n \"read_activity\",\n \"read_activity_security_details\",\n \"manage_member_mfa_requirement\",\n \"create_deposit_address\",\n \"read_deposit_addresses\",\n \"read_guard_signer_status\",\n \"manage_guard_signer\",\n] as const;\nexport type SubaccountPermissionValue = (typeof SUBACCOUNT_PERMISSION_VALUES)[number];\n\nexport const SUBACCOUNT_INVITE_ACTION_VALUES = [\"accept\", \"decline\", \"cancel\"] as const;\nexport type SubaccountInviteActionValue = (typeof SUBACCOUNT_INVITE_ACTION_VALUES)[number];\n\nexport const SUBACCOUNT_INVITE_STATUS_VALUES = [\n \"pending\",\n \"accepted\",\n \"declined\",\n \"cancelled\",\n] as const;\nexport type SubaccountInviteStatusValue = (typeof SUBACCOUNT_INVITE_STATUS_VALUES)[number];\n\nexport const SUBACCOUNT_INVITE_DIRECTION_VALUES = [\"\", \"incoming\", \"outgoing\"] as const;\nexport type SubaccountInviteDirectionValue = (typeof SUBACCOUNT_INVITE_DIRECTION_VALUES)[number];\n\nexport const SUBACCOUNT_STATUS_VALUES = [\"active\", \"disabled\"] as const;\nexport type SubaccountStatusValue = (typeof SUBACCOUNT_STATUS_VALUES)[number];\n\nexport const ACTIVITY_ENTITY_KIND_VALUES = [\n \"account\",\n \"session\",\n \"api_key\",\n \"subaccount\",\n \"member\",\n \"policy\",\n \"invite\",\n \"security\",\n \"destination\",\n] as const;\nexport type ActivityEntityKindValue = (typeof ACTIVITY_ENTITY_KIND_VALUES)[number];\n\nexport const ACTIVITY_EVENT_ACTION_VALUES = [\n \"created\",\n \"updated\",\n \"deleted\",\n \"enabled\",\n \"disabled\",\n \"removed\",\n \"role_set\",\n \"received\",\n \"replied\",\n \"failed\",\n \"revoked\",\n \"blocked\",\n \"hold_placed\",\n \"hold_released\",\n] as const;\nexport type ActivityEventActionValue = (typeof ACTIVITY_EVENT_ACTION_VALUES)[number];\n\nexport const ACTIVITY_EVENT_SOURCE_VALUES = [\"web\", \"mobile\", \"api\"] as const;\nexport type ActivityEventSourceValue = (typeof ACTIVITY_EVENT_SOURCE_VALUES)[number];\n\nexport const SubaccountRoleCodec = {\n inputToProto: {\n owner: Proto.SubaccountRole.OWNER,\n admin: Proto.SubaccountRole.ADMIN,\n treasury: Proto.SubaccountRole.TREASURY,\n leveraged_trader: Proto.SubaccountRole.LEVERAGED_TRADER,\n trader: Proto.SubaccountRole.TRADER,\n viewer: Proto.SubaccountRole.VIEWER,\n } satisfies InputToProto<SubaccountRoleValue, Proto.SubaccountRole>,\n protoToOutput: {\n [Proto.SubaccountRole.SUBACCOUNT_ROLE_UNSPECIFIED]: \"unspecified\",\n [Proto.SubaccountRole.OWNER]: \"owner\",\n [Proto.SubaccountRole.ADMIN]: \"admin\",\n [Proto.SubaccountRole.TREASURY]: \"treasury\",\n [Proto.SubaccountRole.LEVERAGED_TRADER]: \"leveraged_trader\",\n [Proto.SubaccountRole.TRADER]: \"trader\",\n [Proto.SubaccountRole.VIEWER]: \"viewer\",\n } satisfies ProtoToOutput<Proto.SubaccountRole, SubaccountRoleValue>,\n} as const;\n\nexport const SubaccountPermissionCodec = {\n protoToOutput: {\n [Proto.SubaccountPermission.UNSPECIFIED]: \"unspecified\",\n [Proto.SubaccountPermission.READ_SUBACCOUNT]: \"read_subaccount\",\n [Proto.SubaccountPermission.UPDATE_SUBACCOUNT]: \"update_subaccount\",\n [Proto.SubaccountPermission.READ_BALANCES]: \"read_balances\",\n [Proto.SubaccountPermission.READ_SPOT]: \"read_spot\",\n [Proto.SubaccountPermission.TRADE_SPOT]: \"trade_spot\",\n [Proto.SubaccountPermission.READ_INTERNAL_TRANSFERS]: \"read_internal_transfers\",\n [Proto.SubaccountPermission.INTERNAL_TRANSFER]: \"internal_transfer\",\n [Proto.SubaccountPermission.EXTERNAL_WITHDRAW]: \"external_withdraw\",\n [Proto.SubaccountPermission.READ_ADDRESS_BOOK]: \"read_address_book\",\n [Proto.SubaccountPermission.MANAGE_ADDRESS_BOOK]: \"manage_address_book\",\n [Proto.SubaccountPermission.READ_MEMBERS]: \"read_members\",\n [Proto.SubaccountPermission.MANAGE_MEMBERS]: \"manage_members\",\n [Proto.SubaccountPermission.READ_INVITES]: \"read_invites\",\n [Proto.SubaccountPermission.MANAGE_INVITES]: \"manage_invites\",\n [Proto.SubaccountPermission.READ_API_KEYS]: \"read_api_keys\",\n [Proto.SubaccountPermission.MANAGE_API_KEYS]: \"manage_api_keys\",\n [Proto.SubaccountPermission.READ_SUBACCOUNT_POLICY]: \"read_subaccount_policy\",\n [Proto.SubaccountPermission.MANAGE_SUBACCOUNT_POLICY]: \"manage_subaccount_policy\",\n [Proto.SubaccountPermission.READ_ACTIVITY]: \"read_activity\",\n [Proto.SubaccountPermission.READ_ACTIVITY_SECURITY_DETAILS]:\n \"read_activity_security_details\",\n [Proto.SubaccountPermission.MANAGE_MEMBER_MFA_REQUIREMENT]: \"manage_member_mfa_requirement\",\n [Proto.SubaccountPermission.CREATE_DEPOSIT_ADDRESS]: \"create_deposit_address\",\n [Proto.SubaccountPermission.READ_DEPOSIT_ADDRESSES]: \"read_deposit_addresses\",\n [Proto.SubaccountPermission.READ_GUARD_SIGNER_STATUS]: \"read_guard_signer_status\",\n [Proto.SubaccountPermission.MANAGE_GUARD_SIGNER]: \"manage_guard_signer\",\n } satisfies ProtoToOutput<Proto.SubaccountPermission, SubaccountPermissionValue>,\n} as const;\n\nexport const InviteActionCodec = {\n inputToProto: {\n accept: Proto.SubaccountInviteAction.ACCEPT,\n decline: Proto.SubaccountInviteAction.DECLINE,\n cancel: Proto.SubaccountInviteAction.CANCEL,\n } satisfies InputToProto<SubaccountInviteActionValue, Proto.SubaccountInviteAction>,\n} as const;\n\nexport const InviteStatusCodec = {\n protoToOutput: {\n [Proto.SubaccountInviteStatus.UNSPECIFIED]: \"unspecified\",\n [Proto.SubaccountInviteStatus.PENDING]: \"pending\",\n [Proto.SubaccountInviteStatus.ACCEPTED]: \"accepted\",\n [Proto.SubaccountInviteStatus.DECLINED]: \"declined\",\n [Proto.SubaccountInviteStatus.CANCELLED]: \"cancelled\",\n } satisfies ProtoToOutput<Proto.SubaccountInviteStatus, SubaccountInviteStatusValue>,\n} as const;\n\nexport const SubaccountInviteDirectionCodec = {\n inputToProto: {\n \"\": Proto.SubaccountInviteDirection.DIRECTION_UNSPECIFIED,\n incoming: Proto.SubaccountInviteDirection.INCOMING,\n outgoing: Proto.SubaccountInviteDirection.OUTGOING,\n } satisfies InputToProto<SubaccountInviteDirectionValue, Proto.SubaccountInviteDirection>,\n} as const;\n\nexport const SubaccountStatusCodec = {\n inputToProto: {\n active: Proto.SubaccountStatus.ACTIVE,\n disabled: Proto.SubaccountStatus.DISABLED,\n } satisfies InputToProto<SubaccountStatusValue, Proto.SubaccountStatus>,\n protoToOutput: {\n [Proto.SubaccountStatus.UNSPECIFIED]: \"unspecified\",\n [Proto.SubaccountStatus.ACTIVE]: \"active\",\n [Proto.SubaccountStatus.DISABLED]: \"disabled\",\n } satisfies ProtoToOutput<Proto.SubaccountStatus, SubaccountStatusValue>,\n} as const;\n\nexport const ActivityEntityKindCodec = {\n protoToOutput: {\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_UNSPECIFIED]: \"unspecified\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_ACCOUNT]: \"account\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_SESSION]: \"session\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_API_KEY]: \"api_key\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_SUBACCOUNT]: \"subaccount\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_MEMBER]: \"member\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_POLICY]: \"policy\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_INVITE]: \"invite\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_SECURITY]: \"security\",\n [Proto.ActivityEntityKind.ACTIVITY_ENTITY_DESTINATION]: \"destination\",\n } satisfies ProtoToOutput<Proto.ActivityEntityKind, ActivityEntityKindValue>,\n} as const;\n\nexport const ActivityEventActionCodec = {\n protoToOutput: {\n [Proto.ActivityEventAction.ACTIVITY_ACTION_UNSPECIFIED]: \"unspecified\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_CREATED]: \"created\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_UPDATED]: \"updated\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_DELETED]: \"deleted\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_ENABLED]: \"enabled\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_DISABLED]: \"disabled\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_REMOVED]: \"removed\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_ROLE_SET]: \"role_set\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_RECEIVED]: \"received\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_REPLIED]: \"replied\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_FAILED]: \"failed\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_REVOKED]: \"revoked\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_BLOCKED]: \"blocked\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_HOLD_PLACED]: \"hold_placed\",\n [Proto.ActivityEventAction.ACTIVITY_ACTION_HOLD_RELEASED]: \"hold_released\",\n } satisfies ProtoToOutput<Proto.ActivityEventAction, ActivityEventActionValue>,\n} as const;\n\nexport const ActivityEventSourceCodec = {\n protoToOutput: {\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_UNSPECIFIED]: \"unspecified\",\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_WEB]: \"web\",\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_MOBILE]: \"mobile\",\n [Proto.ActivityEventSource.ACTIVITY_SOURCE_API]: \"api\",\n } satisfies ProtoToOutput<Proto.ActivityEventSource, ActivityEventSourceValue>,\n} as const;\n"],"mappings":";;AAqDA,MAAa,qCAAqC;CAAC;CAAI;CAAY;AAAU;AAG7E,MAAa,2BAA2B,CAAC,UAAU,UAAU;AAqC7D,MAAa,sBAAsB;CAC/B,cAAc;EACV,OAAA;EACA,OAAA;EACA,UAAA;EACA,kBAAA;EACA,QAAA;EACA,QAAA;CACJ;CACA,eAAe;GACyC,IAAA;GACtB,IAAA;GACA,IAAA;GACG,IAAA;GACQ,IAAA;GACV,IAAA;GACA,IAAA;CACnC;AACJ;AAEA,MAAa,4BAA4B,EACrC,eAAe;EAC+B,IAAA;EACI,IAAA;EACE,IAAA;EACJ,IAAA;EACJ,IAAA;EACC,IAAA;EACa,IAAA;EACN,IAAA;EACA,IAAA;EACA,IAAA;EACE,KAAA;EACP,KAAA;EACE,KAAA;EACF,KAAA;EACE,KAAA;EACD,KAAA;EACE,KAAA;EACO,KAAA;EACE,KAAA;EACX,KAAA;EAExC,KAAA;EACwD,KAAA;EACP,KAAA;EACA,KAAA;EACE,KAAA;EACL,KAAA;AACtD,EACJ;AAEA,MAAa,oBAAoB,EAC7B,cAAc;CACV,QAAA;CACA,SAAA;CACA,QAAA;AACJ,EACJ;AAEA,MAAa,oBAAoB,EAC7B,eAAe;EACiC,IAAA;EACJ,IAAA;EACC,IAAA;EACA,IAAA;EACC,IAAA;AAC9C,EACJ;AAEA,MAAa,iCAAiC,EAC1C,cAAc;CACV,IAAA;CACA,UAAA;CACA,UAAA;AACJ,EACJ;AAEA,MAAa,wBAAwB;CACjC,cAAc;EACV,QAAA;EACA,UAAA;CACJ;CACA,eAAe;GAC2B,IAAA;GACL,IAAA;GACE,IAAA;CACvC;AACJ;AAEA,MAAa,0BAA0B,EACnC,eAAe;EAC6C,IAAA;EACJ,IAAA;EACA,IAAA;EACA,IAAA;EACG,IAAA;EACJ,IAAA;EACA,IAAA;EACA,IAAA;EACE,IAAA;EACG,IAAA;AAC5D,EACJ;AAEA,MAAa,2BAA2B,EACpC,eAAe;EAC8C,IAAA;EACJ,IAAA;EACA,IAAA;EACA,IAAA;EACA,IAAA;EACC,IAAA;EACD,IAAA;EACC,IAAA;EACA,IAAA;EACD,IAAA;EACD,KAAA;EACC,KAAA;EACA,KAAA;EACI,KAAA;EACE,KAAA;AAC/D,EACJ;AAEA,MAAa,2BAA2B,EACpC,eAAe;EAC8C,IAAA;EACR,IAAA;EACG,IAAA;EACH,IAAA;AACrD,EACJ"}
|
|
@@ -51,7 +51,7 @@ var SubaccountsService = class {
|
|
|
51
51
|
includeMembers: true,
|
|
52
52
|
includeInvites: true,
|
|
53
53
|
includePolicy: true,
|
|
54
|
-
invitesDirection:
|
|
54
|
+
invitesDirection: 2
|
|
55
55
|
}, toConnectCallOptions(options));
|
|
56
56
|
if (!res.subaccount) throw new Error(`Subaccount not found: ${subaccountId}`);
|
|
57
57
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccounts.js","names":["#client","Proto.SubaccountService","#viewClient","Proto.SubaccountViewService","#publicRoleClient","Proto.SubaccountRoleService","#authRoleClient","#realtime","SubaccountSchema","ApiKeySchema","Proto.SubaccountSchema","ProtoApiKeys.ApiKeySchema"],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport * as ProtoApiKeys from \"../../gen/auth/v1/api_keys_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type ApiKey, ApiKeySchema } from \"../api-keys/index.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport {\n DEFAULT_SUBACCOUNT_POLICY,\n SubaccountPoliciesService,\n type SubaccountPolicy,\n SubaccountPolicySchema,\n} from \"../policies/subaccount-policies/index.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport type { SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSubaccountInputSchema,\n CreateSubaccountResultSchema,\n UpdateSubaccountInputSchema,\n InviteSubaccountMemberInputSchema,\n RemoveSubaccountMemberInputSchema,\n UpdateSubaccountMemberRoleInputSchema,\n ListSubaccountInvitesInputSchema,\n RespondSubaccountInviteInputSchema,\n SubaccountActivityInputSchema,\n SubaccountSchema,\n SubaccountMemberSchema,\n SubaccountInviteSchema,\n SubaccountActivityEventSchema,\n SetSubaccountMemberMfaRequirementInputSchema,\n SubaccountIdInputSchema,\n SubaccountMutationResultSchema,\n SubaccountRoleCatalogSchema,\n EffectiveSubaccountPermissionsSchema,\n type CreateSubaccountResult,\n type Subaccount,\n type SubaccountMember,\n type SubaccountInvite,\n type SubaccountEvent,\n type SubaccountMutationResult,\n type SubaccountRoleCatalog,\n type EffectiveSubaccountPermissions,\n} from \"./subaccounts.schemas.js\";\n\ninterface SubscribeSubaccountsInput extends BaseSubscribeInput<Subaccount> {\n accountId: string;\n}\n\ninterface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {\n accountId: string;\n}\n\n/**\n * Reads the public role catalog and creates, manages, shares, audits, and subscribes to subaccounts visible to the authenticated caller.\n */\nexport class SubaccountsService {\n readonly policies: SubaccountPoliciesService;\n\n #client: Client<typeof Proto.SubaccountService>;\n #viewClient: Client<typeof Proto.SubaccountViewService>;\n #publicRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #authRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #realtime: PolyesterRealtime;\n\n constructor(\n transports: AuthAndPublicApiTransports,\n realtime: PolyesterRealtime,\n resolver?: SubaccountResolver,\n ) {\n this.policies = new SubaccountPoliciesService(transports, realtime, resolver);\n this.#client = createClient(Proto.SubaccountService, transports.authApi);\n this.#viewClient = createClient(Proto.SubaccountViewService, transports.authApi);\n this.#publicRoleClient = createClient(Proto.SubaccountRoleService, transports.publicApi);\n this.#authRoleClient = createClient(Proto.SubaccountRoleService, transports.authApi);\n this.#realtime = realtime;\n }\n\n /**\n * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted count metadata useful for deriving future smart-account salts.\n */\n async list(options?: PolyesterRequestOptions): Promise<{\n totalCreated: number;\n subaccounts: v.InferOutput<typeof SubaccountSchema>[];\n }> {\n const res = await this.#client.listSubaccounts({}, toConnectCallOptions(options));\n return {\n totalCreated: res.totalCreated,\n subaccounts: parse(v.array(SubaccountSchema), res.subaccounts),\n };\n }\n\n /**\n * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, balances, members, and outgoing invites; throws if the subaccount is missing.\n */\n async get(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<\n Subaccount & {\n apiKeys: ApiKey[];\n policy: SubaccountPolicy;\n members: SubaccountMember[];\n invites: SubaccountInvite[];\n }\n > {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const subaccountId = formatId(validatedInput.subaccountId);\n const res = await this.#viewClient.getSubaccount(\n {\n subaccountId: validatedInput.subaccountId,\n includeApiKeys: true,\n includeBalances: true,\n includeMembers: true,\n includeInvites: true,\n includePolicy: true,\n invitesDirection: \"outgoing\",\n },\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(`Subaccount not found: ${subaccountId}`);\n\n return {\n ...parse(SubaccountSchema, res.subaccount),\n policy: res.policy\n ? parse(SubaccountPolicySchema, res.policy)\n : DEFAULT_SUBACCOUNT_POLICY,\n apiKeys: parse(v.optional(v.array(ApiKeySchema), []), res.apiKeys),\n members: parse(v.optional(v.array(SubaccountMemberSchema), []), res.members),\n invites: v\n .parse(v.optional(v.array(SubaccountInviteSchema), []), res.invites)\n .filter((invite) => invite.subaccountId === subaccountId),\n };\n }\n\n /**\n * Creates a new subaccount under the caller's root account using a smart-account address, nonce, and signature proof.\n */\n async create(\n input: v.InferInput<typeof CreateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CreateSubaccountResult> {\n const validatedInput = parse(CreateSubaccountInputSchema, input);\n const res = await this.#client.createSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(CreateSubaccountResultSchema, res);\n }\n\n /**\n * Updates mutable subaccount display/status fields such as label and active/disabled status.\n */\n async update(\n input: v.InferInput<typeof UpdateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Subaccount> {\n const validatedInput = parse(UpdateSubaccountInputSchema, input);\n const res = await this.#client.updateSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(\"Failed to update subaccount\");\n return parse(SubaccountSchema, res.subaccount);\n }\n\n /**\n * Creates or refreshes a pending invitation granting a role on a subaccount to another root account.\n */\n async inviteMember(\n input: v.InferInput<typeof InviteSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(InviteSubaccountMemberInputSchema, input);\n const res = await this.#client.inviteSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Removes delegated access for a subaccount member by grantee account ID.\n */\n async removeMember(\n input: v.InferInput<typeof RemoveSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(RemoveSubaccountMemberInputSchema, input);\n const res = await this.#client.removeSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Changes an existing delegated member's role without sending a new invitation.\n */\n async updateMemberRole(\n input: v.InferInput<typeof UpdateSubaccountMemberRoleInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(UpdateSubaccountMemberRoleInputSchema, input);\n const res = await this.#client.updateSubaccountMemberRole(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Enables or disables the owner-controlled MFA requirement for delegated interactive member actions on a subaccount.\n */\n async setMemberMfaRequirement(\n input: v.InferInput<typeof SetSubaccountMemberMfaRequirementInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(SetSubaccountMemberMfaRequirementInputSchema, input);\n const res = await this.#client.setSubaccountMemberMFARequirement(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Returns incoming, outgoing, or all subaccount invitations for the caller, newest first.\n */\n async listInvites(\n input: v.InferInput<typeof ListSubaccountInvitesInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountInvite[]> {\n const validatedInput = parse(ListSubaccountInvitesInputSchema, input);\n const res = await this.#client.listSubaccountInvites(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountInviteSchema), res.invites);\n }\n\n /**\n * Returns the public built-in role and permission catalog with display metadata and per-role permission sets.\n */\n async listRoles(options?: PolyesterRequestOptions): Promise<SubaccountRoleCatalog> {\n const res = await this.#publicRoleClient.listSubaccountRoles(\n {},\n toConnectCallOptions(options),\n );\n return parse(SubaccountRoleCatalogSchema, res);\n }\n\n /**\n * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount.\n */\n async getEffectivePermissions(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<EffectiveSubaccountPermissions> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#authRoleClient.getEffectiveSubaccountPermissions(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(EffectiveSubaccountPermissionsSchema, res);\n }\n\n /**\n * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status.\n */\n async listMembers(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountMember[]> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#client.listSubaccountMembers(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountMemberSchema), res.members);\n }\n\n /**\n * Accepts or rejects an incoming invite, or cancels an outgoing invite, returning the updated invitation.\n */\n async respondInvite(\n input: v.InferInput<typeof RespondSubaccountInviteInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(RespondSubaccountInviteInputSchema, input);\n const res = await this.#client.respondSubaccountInvite(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination.\n */\n async listEvents(\n input: v.InferInput<typeof SubaccountActivityInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<{ events: SubaccountEvent[]; nextPageToken: string }> {\n const validatedInput = parse(SubaccountActivityInputSchema, input);\n const res = await this.#viewClient.listSubaccountActivity(\n validatedInput,\n toConnectCallOptions(options),\n );\n return {\n events: parse(v.optional(v.array(SubaccountActivityEventSchema), []), res.events),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Subscribes to private subaccount updates for an account and emits normalized subaccount records.\n */\n subscribe(input: SubscribeSubaccountsInput) {\n const channel = `private:auth:subaccounts:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.SubaccountSchema,\n onPublication: (data) => {\n const subaccount = parse(SubaccountSchema, data);\n input.onEvent(subaccount);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n\n /**\n * Subscribes to private API key updates for an account through the subaccount realtime channel helper.\n */\n subscribeApiKeys(input: SubscribeApiKeysInput) {\n const channel = `private:auth:api-keys:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: ProtoApiKeys.ApiKeySchema,\n onPublication: (data) => {\n const apiKey = parse(ApiKeySchema, data);\n input.onEvent(apiKey);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8DA,IAAa,qBAAb,MAAgC;CAC5B;CAEA;CACA;CACA;CACA;CACA;CAEA,YACI,YACA,UACA,UACF;EACE,KAAK,WAAW,IAAI,0BAA0B,YAAY,UAAU,QAAQ;EAC5E,KAAKA,UAAU,aAAaC,mBAAyB,WAAW,OAAO;EACvE,KAAKC,cAAc,aAAaC,uBAA6B,WAAW,OAAO;EAC/E,KAAKC,oBAAoB,aAAaC,uBAA6B,WAAW,SAAS;EACvF,KAAKC,kBAAkB,aAAaD,uBAA6B,WAAW,OAAO;EACnF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KA,iBAAiB,OAA8B;EAC3C,MAAM,UAAU,yBAAyB,MAAM,UAAU;EAEzD,OAAO,KAAKD,UAAU,oBAAoB;GACtC;GACA,QAAQI;GACR,gBAAgB,SAAS;IACrB,MAAM,SAAS,MAAMF,gBAAc,IAAI;IACvC,MAAM,QAAQ,MAAM;GACxB;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
|
|
1
|
+
{"version":3,"file":"subaccounts.js","names":["#client","Proto.SubaccountService","#viewClient","Proto.SubaccountViewService","#publicRoleClient","Proto.SubaccountRoleService","#authRoleClient","#realtime","SubaccountSchema","ApiKeySchema","Proto.SubaccountSchema","ProtoApiKeys.ApiKeySchema"],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport * as ProtoApiKeys from \"../../gen/auth/v1/api_keys_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type ApiKey, ApiKeySchema } from \"../api-keys/index.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport {\n DEFAULT_SUBACCOUNT_POLICY,\n SubaccountPoliciesService,\n type SubaccountPolicy,\n SubaccountPolicySchema,\n} from \"../policies/subaccount-policies/index.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport type { SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSubaccountInputSchema,\n CreateSubaccountResultSchema,\n UpdateSubaccountInputSchema,\n InviteSubaccountMemberInputSchema,\n RemoveSubaccountMemberInputSchema,\n UpdateSubaccountMemberRoleInputSchema,\n ListSubaccountInvitesInputSchema,\n RespondSubaccountInviteInputSchema,\n SubaccountActivityInputSchema,\n SubaccountSchema,\n SubaccountMemberSchema,\n SubaccountInviteSchema,\n SubaccountActivityEventSchema,\n SetSubaccountMemberMfaRequirementInputSchema,\n SubaccountIdInputSchema,\n SubaccountMutationResultSchema,\n SubaccountRoleCatalogSchema,\n EffectiveSubaccountPermissionsSchema,\n type CreateSubaccountResult,\n type Subaccount,\n type SubaccountMember,\n type SubaccountInvite,\n type SubaccountEvent,\n type SubaccountMutationResult,\n type SubaccountRoleCatalog,\n type EffectiveSubaccountPermissions,\n} from \"./subaccounts.schemas.js\";\n\ninterface SubscribeSubaccountsInput extends BaseSubscribeInput<Subaccount> {\n accountId: string;\n}\n\ninterface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {\n accountId: string;\n}\n\n/**\n * Reads the public role catalog and creates, manages, shares, audits, and subscribes to subaccounts visible to the authenticated caller.\n */\nexport class SubaccountsService {\n readonly policies: SubaccountPoliciesService;\n\n #client: Client<typeof Proto.SubaccountService>;\n #viewClient: Client<typeof Proto.SubaccountViewService>;\n #publicRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #authRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #realtime: PolyesterRealtime;\n\n constructor(\n transports: AuthAndPublicApiTransports,\n realtime: PolyesterRealtime,\n resolver?: SubaccountResolver,\n ) {\n this.policies = new SubaccountPoliciesService(transports, realtime, resolver);\n this.#client = createClient(Proto.SubaccountService, transports.authApi);\n this.#viewClient = createClient(Proto.SubaccountViewService, transports.authApi);\n this.#publicRoleClient = createClient(Proto.SubaccountRoleService, transports.publicApi);\n this.#authRoleClient = createClient(Proto.SubaccountRoleService, transports.authApi);\n this.#realtime = realtime;\n }\n\n /**\n * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted count metadata useful for deriving future smart-account salts.\n */\n async list(options?: PolyesterRequestOptions): Promise<{\n totalCreated: number;\n subaccounts: v.InferOutput<typeof SubaccountSchema>[];\n }> {\n const res = await this.#client.listSubaccounts({}, toConnectCallOptions(options));\n return {\n totalCreated: res.totalCreated,\n subaccounts: parse(v.array(SubaccountSchema), res.subaccounts),\n };\n }\n\n /**\n * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, balances, members, and outgoing invites; throws if the subaccount is missing.\n */\n async get(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<\n Subaccount & {\n apiKeys: ApiKey[];\n policy: SubaccountPolicy;\n members: SubaccountMember[];\n invites: SubaccountInvite[];\n }\n > {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const subaccountId = formatId(validatedInput.subaccountId);\n const res = await this.#viewClient.getSubaccount(\n {\n subaccountId: validatedInput.subaccountId,\n includeApiKeys: true,\n includeBalances: true,\n includeMembers: true,\n includeInvites: true,\n includePolicy: true,\n invitesDirection: Proto.SubaccountInviteDirection.OUTGOING,\n },\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(`Subaccount not found: ${subaccountId}`);\n\n return {\n ...parse(SubaccountSchema, res.subaccount),\n policy: res.policy\n ? parse(SubaccountPolicySchema, res.policy)\n : DEFAULT_SUBACCOUNT_POLICY,\n apiKeys: parse(v.optional(v.array(ApiKeySchema), []), res.apiKeys),\n members: parse(v.optional(v.array(SubaccountMemberSchema), []), res.members),\n invites: v\n .parse(v.optional(v.array(SubaccountInviteSchema), []), res.invites)\n .filter((invite) => invite.subaccountId === subaccountId),\n };\n }\n\n /**\n * Creates a new subaccount under the caller's root account using a smart-account address, nonce, and signature proof.\n */\n async create(\n input: v.InferInput<typeof CreateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CreateSubaccountResult> {\n const validatedInput = parse(CreateSubaccountInputSchema, input);\n const res = await this.#client.createSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(CreateSubaccountResultSchema, res);\n }\n\n /**\n * Updates mutable subaccount display/status fields such as label and active/disabled status.\n */\n async update(\n input: v.InferInput<typeof UpdateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Subaccount> {\n const validatedInput = parse(UpdateSubaccountInputSchema, input);\n const res = await this.#client.updateSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(\"Failed to update subaccount\");\n return parse(SubaccountSchema, res.subaccount);\n }\n\n /**\n * Creates or refreshes a pending invitation granting a role on a subaccount to another root account.\n */\n async inviteMember(\n input: v.InferInput<typeof InviteSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(InviteSubaccountMemberInputSchema, input);\n const res = await this.#client.inviteSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Removes delegated access for a subaccount member by grantee account ID.\n */\n async removeMember(\n input: v.InferInput<typeof RemoveSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(RemoveSubaccountMemberInputSchema, input);\n const res = await this.#client.removeSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Changes an existing delegated member's role without sending a new invitation.\n */\n async updateMemberRole(\n input: v.InferInput<typeof UpdateSubaccountMemberRoleInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(UpdateSubaccountMemberRoleInputSchema, input);\n const res = await this.#client.updateSubaccountMemberRole(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Enables or disables the owner-controlled MFA requirement for delegated interactive member actions on a subaccount.\n */\n async setMemberMfaRequirement(\n input: v.InferInput<typeof SetSubaccountMemberMfaRequirementInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(SetSubaccountMemberMfaRequirementInputSchema, input);\n const res = await this.#client.setSubaccountMemberMFARequirement(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Returns incoming, outgoing, or all subaccount invitations for the caller, newest first.\n */\n async listInvites(\n input: v.InferInput<typeof ListSubaccountInvitesInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountInvite[]> {\n const validatedInput = parse(ListSubaccountInvitesInputSchema, input);\n const res = await this.#client.listSubaccountInvites(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountInviteSchema), res.invites);\n }\n\n /**\n * Returns the public built-in role and permission catalog with display metadata and per-role permission sets.\n */\n async listRoles(options?: PolyesterRequestOptions): Promise<SubaccountRoleCatalog> {\n const res = await this.#publicRoleClient.listSubaccountRoles(\n {},\n toConnectCallOptions(options),\n );\n return parse(SubaccountRoleCatalogSchema, res);\n }\n\n /**\n * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount.\n */\n async getEffectivePermissions(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<EffectiveSubaccountPermissions> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#authRoleClient.getEffectiveSubaccountPermissions(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(EffectiveSubaccountPermissionsSchema, res);\n }\n\n /**\n * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status.\n */\n async listMembers(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountMember[]> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#client.listSubaccountMembers(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountMemberSchema), res.members);\n }\n\n /**\n * Accepts or rejects an incoming invite, or cancels an outgoing invite, returning the updated invitation.\n */\n async respondInvite(\n input: v.InferInput<typeof RespondSubaccountInviteInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(RespondSubaccountInviteInputSchema, input);\n const res = await this.#client.respondSubaccountInvite(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination.\n */\n async listEvents(\n input: v.InferInput<typeof SubaccountActivityInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<{ events: SubaccountEvent[]; nextPageToken: string }> {\n const validatedInput = parse(SubaccountActivityInputSchema, input);\n const res = await this.#viewClient.listSubaccountActivity(\n validatedInput,\n toConnectCallOptions(options),\n );\n return {\n events: parse(v.optional(v.array(SubaccountActivityEventSchema), []), res.events),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Subscribes to private subaccount updates for an account and emits normalized subaccount records.\n */\n subscribe(input: SubscribeSubaccountsInput) {\n const channel = `private:auth:subaccounts:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.SubaccountSchema,\n onPublication: (data) => {\n const subaccount = parse(SubaccountSchema, data);\n input.onEvent(subaccount);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n\n /**\n * Subscribes to private API key updates for an account through the subaccount realtime channel helper.\n */\n subscribeApiKeys(input: SubscribeApiKeysInput) {\n const channel = `private:auth:api-keys:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: ProtoApiKeys.ApiKeySchema,\n onPublication: (data) => {\n const apiKey = parse(ApiKeySchema, data);\n input.onEvent(apiKey);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8DA,IAAa,qBAAb,MAAgC;CAC5B;CAEA;CACA;CACA;CACA;CACA;CAEA,YACI,YACA,UACA,UACF;E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AM,UAAU;EAE5D,OAAO,KAAKK,UAAU,oBAAoB;GACtC;GACA,QAAQG;GACR,gBAAgB,SAAS;IACrB,MAAM,aAAa,MAAMF,oBAAkB,IAAI;IAC/C,MAAM,QAAQ,UAAU;GAC5B;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;;;;CAKA,iBAAiB,OAA8B;EAC3C,MAAM,UAAU,yBAAyB,MAAM,UAAU;EAEzD,OAAO,KAAKD,UAAU,oBAAoB;GACtC;GACA,QAAQI;GACR,gBAAgB,SAAS;IACrB,MAAM,SAAS,MAAMF,gBAAc,IAAI;IACvC,MAAM,QAAQ,MAAM;GACxB;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PolicyAction } from "../../gen/auth/v1/policies_pb.js";
|
|
2
|
-
import { ActivityEntityKind, ActivityEventAction, ActivityEventSource, SubaccountInviteAction, SubaccountInviteStatus as SubaccountInviteStatus$1, SubaccountPermission as SubaccountPermission$1, SubaccountRole as SubaccountRole$1, SubaccountStatus as SubaccountStatus$1 } from "../../gen/auth/v1/subaccounts_pb.js";
|
|
2
|
+
import { ActivityEntityKind, ActivityEventAction, ActivityEventSource, SubaccountInviteAction, SubaccountInviteDirection, SubaccountInviteStatus as SubaccountInviteStatus$1, SubaccountPermission as SubaccountPermission$1, SubaccountRole as SubaccountRole$1, SubaccountStatus as SubaccountStatus$1 } from "../../gen/auth/v1/subaccounts_pb.js";
|
|
3
3
|
import * as v from "valibot";
|
|
4
4
|
//#region src/services/subaccounts/subaccounts.schemas.d.ts
|
|
5
5
|
declare const SubaccountRoleSchema: v.PicklistSchema<readonly ["owner", "admin", "treasury", "leveraged_trader", "trader", "viewer"], undefined>;
|
|
@@ -128,7 +128,7 @@ declare const SetSubaccountMemberMfaRequirementInputSchema: v.StrictObjectSchema
|
|
|
128
128
|
}, undefined>;
|
|
129
129
|
type SetSubaccountMemberMfaRequirementInput = v.InferInput<typeof SetSubaccountMemberMfaRequirementInputSchema>;
|
|
130
130
|
declare const ListSubaccountInvitesInputSchema: v.StrictObjectSchema<{
|
|
131
|
-
readonly direction: v.OptionalSchema<v.PicklistSchema<["
|
|
131
|
+
readonly direction: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["", "incoming", "outgoing"], undefined>, "">, v.TransformAction<"" | "incoming" | "outgoing", SubaccountInviteDirection>]>;
|
|
132
132
|
}, undefined>;
|
|
133
133
|
type ListSubaccountInvitesInput = v.InferInput<typeof ListSubaccountInvitesInputSchema>;
|
|
134
134
|
declare const InviteStatusSchema: v.PicklistSchema<["pending", "accepted", "declined", "cancelled"], undefined>;
|
|
@@ -279,8 +279,8 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
|
|
|
279
279
|
seconds: bigint;
|
|
280
280
|
nanos: number;
|
|
281
281
|
} | undefined, number | undefined>]>;
|
|
282
|
-
readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "
|
|
283
|
-
readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "
|
|
282
|
+
readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "member" | "policy" | "invite" | "security">]>;
|
|
283
|
+
readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "failed" | "revoked" | "created" | "updated" | "deleted" | "removed" | "role_set" | "received" | "replied" | "blocked" | "hold_placed" | "hold_released">]>;
|
|
284
284
|
readonly source: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventSource, undefined>, v.TransformAction<ActivityEventSource, "unspecified" | "web" | "mobile" | "api">]>;
|
|
285
285
|
readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
286
286
|
readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccounts.schemas.d.ts","names":[],"sources":["../../../src/services/subaccounts/subaccounts.schemas.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"subaccounts.schemas.d.ts","names":[],"sources":["../../../src/services/subaccounts/subaccounts.schemas.ts"],"mappings":";;;;cAsCa,sBAAoB,EAAA;KAErB,iBAAiB,EAAE,mBAAmB;cAS5C,iCAA+B,EAAA,yBAAA,EAAA,kBAAA,oCAAA,EAAA,gBAAA;KAYzB,uBAAuB,EAAE,mBAAmB;cAE3C,sCAAoC,EAAA;;;;;;KAiBrC,iCAAiC,EAAE,mBACpC;cAGE,gCAA8B,EAAA;;;;;;;KAQ/B,2BAA2B,EAAE,mBAAmB;cAE/C,6BAA2B,EAAA;;;;;;;;;;;;;;;KAK5B,wBAAwB,EAAE,mBAAmB;cAE5C,sCAAoC,EAAA;;;;;KAMrC,iCAAiC,EAAE,mBACpC;cAGE,6BAA2B,EAAA;;;;;;;;;;KAW5B,wBAAwB,EAAE,kBAAkB;cAE3C,yBAAuB,EAAA;;;KAIxB,oBAAoB,EAAE,kBAAkB;cAEvC,8BAA4B,EAAA;;;;;;KAO7B,yBAAyB,EAAE,mBAAmB;cAE7C,gCAA8B,EAAA;KAE/B,2BAA2B,EAAE,mBAAmB;cAmB/C,6BAA2B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4B5B,wBAAwB,EAAE,kBAAkB;cAE3C,mCAAiC,EAAA;;;;;KASlC,8BAA8B,EAAE,kBAAkB;cAEjD,mCAAiC,EAAA;;;;KAKlC,8BAA8B,EAAE,kBAAkB;cAEjD,uCAAqC,EAAA;;;;;KAEtC,kCAAkC,EAAE,kBACrC;cAGE,8CAA4C,EAAA;;;;KAK7C,yCAAyC,EAAE,kBAC5C;cAGE,kCAAgC,EAAA;;;KAOjC,6BAA6B,EAAE,kBAAkB;cAIvD,oBAAkB,EAAA;KAEZ,yBAAyB,EAAE,mBAAmB;cAI7C,oCAAkC,EAAA;;;;KAQnC,+BAA+B,EAAE,kBAAkB;cAEzD,6BAA2B,EAAA,yBAAA,EAAA,kBAAA,gCAAA,EAAA,gBAAA;KAYrB,mBAAmB,EAAE,mBAAmB;cAEvC,kBAAgB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyBjB,aAAa,EAAE,mBAAmB;cAEjC,wBAAsB,EAAA;;;;;;;;KASvB,mBAAmB,EAAE,mBAAmB;cAEvC,wBAAsB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4CvB,mBAAmB,EAAE,mBAAmB;cAEvC,+BAA6B,EAAA;;;;;KAM9B,0BAA0B,EAAE,kBAAkB;cAE7C,+BAA6B,EAAA;;;;;;;;;;;;;;;;KA4C9B,kBAAkB,EAAE,mBAAmB"}
|
|
@@ -5,7 +5,7 @@ import { PolicyAction } from "../../gen/auth/v1/policies_pb.js";
|
|
|
5
5
|
import { PolicyActionCodec } from "../policies/shared.codecs.js";
|
|
6
6
|
import { buildProtoPatch, defineProtoPatchFields } from "../../utils/proto-patch.js";
|
|
7
7
|
import { ActivityEntityKind, ActivityEventAction, ActivityEventSource, SubaccountInviteStatus, SubaccountPermission, SubaccountRole, SubaccountStatus } from "../../gen/auth/v1/subaccounts_pb.js";
|
|
8
|
-
import { ActivityEntityKindCodec, ActivityEventActionCodec, ActivityEventSourceCodec, InviteActionCodec, InviteStatusCodec, SUBACCOUNT_STATUS_VALUES, SubaccountPermissionCodec, SubaccountRoleCodec, SubaccountStatusCodec } from "./subaccounts.codecs.js";
|
|
8
|
+
import { ActivityEntityKindCodec, ActivityEventActionCodec, ActivityEventSourceCodec, InviteActionCodec, InviteStatusCodec, SUBACCOUNT_INVITE_DIRECTION_VALUES, SUBACCOUNT_STATUS_VALUES, SubaccountInviteDirectionCodec, SubaccountPermissionCodec, SubaccountRoleCodec, SubaccountStatusCodec } from "./subaccounts.codecs.js";
|
|
9
9
|
import * as v from "valibot";
|
|
10
10
|
const SubaccountRoleSchema = v.picklist([
|
|
11
11
|
"owner",
|
|
@@ -105,11 +105,7 @@ const SetSubaccountMemberMfaRequirementInputSchema = v.strictObject({
|
|
|
105
105
|
subaccountId: idInputSchema("subaccountId"),
|
|
106
106
|
requireMemberMfa: v.boolean()
|
|
107
107
|
});
|
|
108
|
-
const ListSubaccountInvitesInputSchema = v.strictObject({ direction: v.optional(v.picklist([
|
|
109
|
-
"incoming",
|
|
110
|
-
"outgoing",
|
|
111
|
-
""
|
|
112
|
-
]), "") });
|
|
108
|
+
const ListSubaccountInvitesInputSchema = v.strictObject({ direction: v.pipe(v.optional(v.picklist(SUBACCOUNT_INVITE_DIRECTION_VALUES), ""), v.transform((direction) => SubaccountInviteDirectionCodec.inputToProto[direction])) });
|
|
113
109
|
const InviteActionSchema = v.picklist([
|
|
114
110
|
"accept",
|
|
115
111
|
"decline",
|