@polyester/sdk 0.26.1 → 0.27.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 +16 -0
- package/dist/gen/auth/v1/auth_pb.d.ts +30 -21
- package/dist/gen/auth/v1/auth_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/auth_pb.js +25 -8
- package/dist/gen/auth/v1/auth_pb.js.map +1 -1
- package/dist/gen/auth/v1/mfa_pb.js +1 -1
- package/dist/gen/auth/v1/mfa_pb.js.map +1 -1
- package/dist/gen/auth/v1/profile_pb.d.ts +2 -2
- package/dist/gen/auth/v1/profile_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/profile_pb.js +2 -1
- package/dist/gen/auth/v1/profile_pb.js.map +1 -1
- package/dist/gen/auth/v1/resolve_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/resolve_pb.js +2 -1
- package/dist/gen/auth/v1/resolve_pb.js.map +1 -1
- package/dist/gen/auth/v1/social_verification_pb.d.ts +3 -0
- package/dist/gen/auth/v1/social_verification_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/social_verification_pb.js +2 -1
- package/dist/gen/auth/v1/social_verification_pb.js.map +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.d.ts +90 -10
- package/dist/gen/auth/v1/subaccounts_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.js +40 -28
- package/dist/gen/auth/v1/subaccounts_pb.js.map +1 -1
- package/dist/gen/claims/v1/claims_pb.d.ts +108 -2
- package/dist/gen/claims/v1/claims_pb.d.ts.map +1 -1
- package/dist/gen/claims/v1/claims_pb.js +109 -11
- package/dist/gen/claims/v1/claims_pb.js.map +1 -1
- package/dist/gen/index.d.ts +1 -1
- package/dist/gen/index.js +1 -1
- package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts.map +1 -1
- package/dist/gen/ledger/read/v1/ledger_read_pb.js +6 -1
- package/dist/gen/ledger/read/v1/ledger_read_pb.js.map +1 -1
- package/dist/gen/orderbook/v1/orderbook_pb.d.ts +1 -1
- package/dist/gen/orderbook/v1/orderbook_pb.js.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.d.ts +10 -0
- package/dist/gen/orders/v1/orders_read_pb.d.ts.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.js +1 -1
- package/dist/gen/orders/v1/orders_read_pb.js.map +1 -1
- package/dist/gen/polyester/api/options_pb.d.ts +39 -2
- package/dist/gen/polyester/api/options_pb.d.ts.map +1 -1
- package/dist/gen/polyester/api/options_pb.js +43 -2
- package/dist/gen/polyester/api/options_pb.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/services/auth/account-signer-auth.d.ts +10 -3
- package/dist/services/auth/account-signer-auth.d.ts.map +1 -1
- package/dist/services/auth/account-signer-auth.js +14 -12
- package/dist/services/auth/account-signer-auth.js.map +1 -1
- package/dist/services/auth/auth.d.ts +3 -4
- package/dist/services/auth/auth.d.ts.map +1 -1
- package/dist/services/auth/auth.js +4 -6
- package/dist/services/auth/auth.js.map +1 -1
- package/dist/services/auth/auth.types.d.ts +2 -2
- package/dist/services/candles/candles.schemas.d.ts +10 -10
- package/dist/services/claims/claims.js +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts +9 -9
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +42 -42
- package/dist/services/market-overview/market-overview.schemas.d.ts +3 -3
- package/dist/services/orders/orders-output.schemas.d.ts +12 -6
- package/dist/services/orders/orders-output.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-output.schemas.js +2 -0
- package/dist/services/orders/orders-output.schemas.js.map +1 -1
- package/dist/services/subaccounts/index.d.ts +2 -2
- package/dist/services/subaccounts/subaccounts.d.ts +9 -3
- package/dist/services/subaccounts/subaccounts.d.ts.map +1 -1
- package/dist/services/subaccounts/subaccounts.js +13 -3
- package/dist/services/subaccounts/subaccounts.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +25 -6
- package/dist/services/subaccounts/subaccounts.schemas.d.ts.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.js +13 -2
- package/dist/services/subaccounts/subaccounts.schemas.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.types.d.ts +2 -2
- package/dist/services/triggers/trigger-input.schemas.d.ts +1 -1
- package/dist/services/triggers/triggers-output.schemas.d.ts +15 -15
- package/dist/shared/connect-error-mapping.d.ts.map +1 -1
- package/dist/shared/connect-error-mapping.js +6 -4
- package/dist/shared/connect-error-mapping.js.map +1 -1
- package/dist/shared/error-detail.d.ts +12 -8
- package/dist/shared/error-detail.d.ts.map +1 -1
- package/dist/shared/error-detail.js +30 -19
- package/dist/shared/error-detail.js.map +1 -1
- package/dist/shared/errors.d.ts +10 -1
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/errors.js +12 -1
- package/dist/shared/errors.js.map +1 -1
- package/dist/wired-services.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orders-output.schemas.js","names":[],"sources":["../../../src/services/orders/orders-output.schemas.ts"],"sourcesContent":["import { OrderLineageSchema } from \"./order-lineage.schemas.js\";\nimport * as v from \"valibot\";\nimport { tsNsToMs } from \"../../utils/time.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport { OptionalPublicIdSchema, OptionalTimestampMsSchema } from \"../../shared/schemas.js\";\nimport { enumLabel, enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport { E18_SCALE, scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { createUserTradeSchema } from \"../trades/trades.schemas.js\";\nimport { fromU128 } from \"../../utils/u128.js\";\nimport { AccountCodeCodec, TransferCodeCodec } from \"../../shared/ledger-codes.js\";\nimport {\n FeeAssetCodec,\n OrderOriginScopeCodec,\n OrderSideCodec,\n OrderStatusCodec,\n OrderTriggerTypeCodec,\n OrderTypeCodec,\n SelfTradePreventionModeCodec,\n TimeInForceCodec,\n} from \"./orders.codecs.js\";\nimport {\n ReadAttachedRiskSchema,\n formatAttachedRisk,\n formatMarketMaxSlippage,\n} from \"./orders-risk.schemas.js\";\n\nconst OrderStatusOutputSchema = enumLabelSchema(OrderStatusCodec.protoToOutput);\n\nconst ReadOrderOriginSchema = v.object({\n scope: enumLabelSchema(OrderOriginScopeCodec.protoToOutput),\n triggerType: enumLabelSchema(OrderTriggerTypeCodec.protoToOutput),\n triggerId: OptionalPublicIdSchema,\n parentOrderId: OptionalPublicIdSchema,\n childSeq: v.number(),\n});\n\nexport function createOrderSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n orderId: v.bigint(),\n lineage: v.optional(OrderLineageSchema),\n symbolId: v.number(),\n clientOrderId: v.string(),\n side: v.number(),\n status: OrderStatusOutputSchema,\n orderType: v.number(),\n timeInForce: v.number(),\n selfTradePreventionMode: v.number(),\n feeAsset: v.number(),\n postOnly: v.boolean(),\n origQtyScaled: v.bigint(),\n cumQtyScaled: v.bigint(),\n leavesQtyScaled: v.bigint(),\n avgPriceTicks: v.bigint(),\n priceTicks: v.bigint(),\n createdTsNs: v.bigint(),\n terminalTsNs: v.bigint(),\n terminalReason: v.optional(v.string(), \"\"),\n terminalReasonCode: v.number(),\n attachedRisk: v.optional(ReadAttachedRiskSchema),\n origin: v.optional(ReadOrderOriginSchema),\n marketClientRefPriceTicks: v.bigint(),\n marketMaxSlippageTicks: v.number(),\n marketMaxSlippageBps: v.number(),\n version: v.pipe(v.number(), v.integer(), v.minValue(0)),\n batchRequestId: v.bigint(),\n submittedMaxQuoteDebitScaled: v.optional(v.bigint()),\n expireAt: OptionalTimestampMsSchema,\n }),\n v.transform((o) => {\n const isPartial = o.status === \"working\" && o.cumQtyScaled > 0n;\n const baseQtyScale = scales.baseQty(o.symbolId);\n const marketClientRefPrice =\n o.marketClientRefPriceTicks > 0n\n ? scaledToDecimalOutput(o.marketClientRefPriceTicks, scales.price())\n : undefined;\n const marketMaxSlippage = formatMarketMaxSlippage(\n scales,\n o.marketMaxSlippageTicks,\n o.marketMaxSlippageBps,\n );\n return {\n orderId: formatId(o.orderId),\n ...(o.lineage === undefined ? {} : { lineage: o.lineage }),\n symbolId: o.symbolId,\n clientOrderId: o.clientOrderId,\n status: isPartial ? (\"partial\" as const) : o.status,\n side: enumLabel(OrderSideCodec.protoToOutput, o.side),\n orderType: enumLabel(OrderTypeCodec.protoToOutput, o.orderType),\n timeInForce: enumLabel(TimeInForceCodec.protoToOutput, o.timeInForce),\n selfTradePreventionMode: enumLabel(\n SelfTradePreventionModeCodec.protoToOutput,\n o.selfTradePreventionMode,\n ),\n feeAsset: enumLabel(FeeAssetCodec.protoToOutput, o.feeAsset),\n postOnly: o.postOnly,\n totalQty: scaledToDecimalOutput(o.origQtyScaled, baseQtyScale),\n cumQty: scaledToDecimalOutput(o.cumQtyScaled, baseQtyScale),\n leavesQty: scaledToDecimalOutput(o.leavesQtyScaled, baseQtyScale),\n avgPx: scaledToDecimalOutput(o.avgPriceTicks, scales.price()),\n price: scaledToDecimalOutput(o.priceTicks, scales.price()),\n createdTs: tsNsToMs(o.createdTsNs),\n terminalTs: tsNsToMs(o.terminalTsNs),\n terminalReason: humanizeTerminalReason(o.terminalReason),\n terminalReasonCode: o.terminalReasonCode,\n attachedRisk: formatAttachedRisk(scales, o.attachedRisk),\n ...(o.origin ? { origin: o.origin } : {}),\n ...(marketClientRefPrice ? { marketClientRefPrice } : {}),\n ...(marketMaxSlippage ? { marketMaxSlippage } : {}),\n ...(o.batchRequestId > 0n ? { batchRequestId: formatId(o.batchRequestId) } : {}),\n ...(o.submittedMaxQuoteDebitScaled === undefined\n ? {}\n : {\n submittedMaxQuoteDebit: scaledToDecimalOutput(\n o.submittedMaxQuoteDebitScaled,\n scales.quoteAmount(o.symbolId),\n ),\n }),\n ...(o.expireAt === undefined ? {} : { expireAt: o.expireAt }),\n version: o.version,\n };\n }),\n );\n}\n\nfunction humanizeTerminalReason(raw: string | null | undefined): string {\n const key = (raw ?? \"\").trim();\n if (!key) return \"\";\n const uppercaseAcronyms = [\"GTC\", \"IOC\", \"FOK\", \"DAY\", \"GTD\", \"STP\"];\n return key\n .split(\"_\")\n .filter(Boolean)\n .map((part) => {\n const upper = part.toUpperCase();\n if (uppercaseAcronyms.includes(upper)) return upper;\n return upper[0] ? upper[0] + upper.slice(1).toLowerCase() : \"\";\n })\n .filter(Boolean)\n .join(\" \");\n}\n\nexport type Order = v.InferOutput<ReturnType<typeof createOrderSchema>>;\n\nexport function createOrderTransferSchema() {\n return v.pipe(\n v.object({\n txId: v.string(),\n matchId: v.pipe(\n v.bigint(),\n v.transform((value) => value.toString()),\n ),\n symbolId: v.number(),\n assetId: v.number(),\n amountE18: v.optional(\n v.object({\n hi: v.bigint(),\n lo: v.bigint(),\n }),\n ),\n isDebit: v.boolean(),\n transferCode: v.number(),\n accountCode: v.number(),\n tsNs: v.bigint(),\n }),\n v.transform((tr) => ({\n txId: tr.txId,\n matchId: tr.matchId,\n symbolId: tr.symbolId,\n assetId: tr.assetId,\n isDebit: tr.isDebit,\n timestamp: tsNsToMs(tr.tsNs),\n amount: scaledToDecimalOutput(fromU128(tr.amountE18), E18_SCALE),\n type: enumLabel(TransferCodeCodec.protoToOutput, tr.transferCode),\n accountCode: enumLabel(AccountCodeCodec.protoToOutput, tr.accountCode),\n })),\n );\n}\n\nexport type OrderTransfer = v.InferOutput<ReturnType<typeof createOrderTransferSchema>>;\n\nexport function createOrderDetailsSchema(scales: SdkScales) {\n return v.object({\n nextPageToken: v.optional(v.string(), \"\"),\n order: createOrderSchema(scales),\n trades: v.optional(v.array(createUserTradeSchema(scales)), []),\n transfers: v.optional(v.array(createOrderTransferSchema()), []),\n });\n}\n\nexport type OrderDetails = v.InferOutput<ReturnType<typeof createOrderDetailsSchema>>;\n"],"mappings":";;;;;;;;;;;;;;AA0BA,MAAM,0BAA0B,gBAAgB,iBAAiB,aAAa;AAE9E,MAAM,wBAAwB,EAAE,OAAO;CACnC,OAA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AAiB,eAAe,GAAG,WAAW;CACzE,EAAE,CACN;AACJ;AAIA,SAAgB,yBAAyB,QAAmB;CACxD,OAAO,EAAE,OAAO;EACZ,eAAe,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;EACxC,OAAO,kBAAkB,MAAM;EAC/B,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,MAAM,CAAC,GAAG,CAAC,CAAC;EAC7D,WAAW,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC,GAAG,CAAC,CAAC;CAClE,CAAC;AACL"}
|
|
1
|
+
{"version":3,"file":"orders-output.schemas.js","names":[],"sources":["../../../src/services/orders/orders-output.schemas.ts"],"sourcesContent":["import { OrderLineageSchema } from \"./order-lineage.schemas.js\";\nimport * as v from \"valibot\";\nimport { tsNsToMs } from \"../../utils/time.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport { OptionalPublicIdSchema, OptionalTimestampMsSchema } from \"../../shared/schemas.js\";\nimport { enumLabel, enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport { E18_SCALE, scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { createUserTradeSchema } from \"../trades/trades.schemas.js\";\nimport { fromU128 } from \"../../utils/u128.js\";\nimport { AccountCodeCodec, TransferCodeCodec } from \"../../shared/ledger-codes.js\";\nimport {\n FeeAssetCodec,\n OrderOriginScopeCodec,\n OrderSideCodec,\n OrderStatusCodec,\n OrderTriggerTypeCodec,\n OrderTypeCodec,\n SelfTradePreventionModeCodec,\n TimeInForceCodec,\n} from \"./orders.codecs.js\";\nimport {\n ReadAttachedRiskSchema,\n formatAttachedRisk,\n formatMarketMaxSlippage,\n} from \"./orders-risk.schemas.js\";\n\nconst OrderStatusOutputSchema = enumLabelSchema(OrderStatusCodec.protoToOutput);\n\nconst ReadOrderOriginSchema = v.object({\n scope: enumLabelSchema(OrderOriginScopeCodec.protoToOutput),\n triggerType: enumLabelSchema(OrderTriggerTypeCodec.protoToOutput),\n triggerId: OptionalPublicIdSchema,\n parentOrderId: OptionalPublicIdSchema,\n childSeq: v.number(),\n});\n\nexport function createOrderSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n orderId: v.bigint(),\n lineage: v.optional(OrderLineageSchema),\n symbolId: v.number(),\n clientOrderId: v.string(),\n side: v.number(),\n status: OrderStatusOutputSchema,\n orderType: v.number(),\n timeInForce: v.number(),\n selfTradePreventionMode: v.number(),\n feeAsset: v.number(),\n postOnly: v.boolean(),\n origQtyScaled: v.bigint(),\n cumQtyScaled: v.bigint(),\n inheritedCumQtyScaled: v.optional(v.bigint(), 0n),\n leavesQtyScaled: v.bigint(),\n avgPriceTicks: v.bigint(),\n priceTicks: v.bigint(),\n createdTsNs: v.bigint(),\n terminalTsNs: v.bigint(),\n terminalReason: v.optional(v.string(), \"\"),\n terminalReasonCode: v.number(),\n attachedRisk: v.optional(ReadAttachedRiskSchema),\n origin: v.optional(ReadOrderOriginSchema),\n marketClientRefPriceTicks: v.bigint(),\n marketMaxSlippageTicks: v.number(),\n marketMaxSlippageBps: v.number(),\n version: v.pipe(v.number(), v.integer(), v.minValue(0)),\n batchRequestId: v.bigint(),\n submittedMaxQuoteDebitScaled: v.optional(v.bigint()),\n expireAt: OptionalTimestampMsSchema,\n }),\n v.transform((o) => {\n const isPartial = o.status === \"working\" && o.cumQtyScaled > 0n;\n const baseQtyScale = scales.baseQty(o.symbolId);\n const marketClientRefPrice =\n o.marketClientRefPriceTicks > 0n\n ? scaledToDecimalOutput(o.marketClientRefPriceTicks, scales.price())\n : undefined;\n const marketMaxSlippage = formatMarketMaxSlippage(\n scales,\n o.marketMaxSlippageTicks,\n o.marketMaxSlippageBps,\n );\n return {\n orderId: formatId(o.orderId),\n ...(o.lineage === undefined ? {} : { lineage: o.lineage }),\n symbolId: o.symbolId,\n clientOrderId: o.clientOrderId,\n status: isPartial ? (\"partial\" as const) : o.status,\n side: enumLabel(OrderSideCodec.protoToOutput, o.side),\n orderType: enumLabel(OrderTypeCodec.protoToOutput, o.orderType),\n timeInForce: enumLabel(TimeInForceCodec.protoToOutput, o.timeInForce),\n selfTradePreventionMode: enumLabel(\n SelfTradePreventionModeCodec.protoToOutput,\n o.selfTradePreventionMode,\n ),\n feeAsset: enumLabel(FeeAssetCodec.protoToOutput, o.feeAsset),\n postOnly: o.postOnly,\n totalQty: scaledToDecimalOutput(o.origQtyScaled, baseQtyScale),\n cumQty: scaledToDecimalOutput(o.cumQtyScaled, baseQtyScale),\n inheritedCumQty: scaledToDecimalOutput(o.inheritedCumQtyScaled, baseQtyScale),\n leavesQty: scaledToDecimalOutput(o.leavesQtyScaled, baseQtyScale),\n avgPx: scaledToDecimalOutput(o.avgPriceTicks, scales.price()),\n price: scaledToDecimalOutput(o.priceTicks, scales.price()),\n createdTs: tsNsToMs(o.createdTsNs),\n terminalTs: tsNsToMs(o.terminalTsNs),\n terminalReason: humanizeTerminalReason(o.terminalReason),\n terminalReasonCode: o.terminalReasonCode,\n attachedRisk: formatAttachedRisk(scales, o.attachedRisk),\n ...(o.origin ? { origin: o.origin } : {}),\n ...(marketClientRefPrice ? { marketClientRefPrice } : {}),\n ...(marketMaxSlippage ? { marketMaxSlippage } : {}),\n ...(o.batchRequestId > 0n ? { batchRequestId: formatId(o.batchRequestId) } : {}),\n ...(o.submittedMaxQuoteDebitScaled === undefined\n ? {}\n : {\n submittedMaxQuoteDebit: scaledToDecimalOutput(\n o.submittedMaxQuoteDebitScaled,\n scales.quoteAmount(o.symbolId),\n ),\n }),\n ...(o.expireAt === undefined ? {} : { expireAt: o.expireAt }),\n version: o.version,\n };\n }),\n );\n}\n\nfunction humanizeTerminalReason(raw: string | null | undefined): string {\n const key = (raw ?? \"\").trim();\n if (!key) return \"\";\n const uppercaseAcronyms = [\"GTC\", \"IOC\", \"FOK\", \"DAY\", \"GTD\", \"STP\"];\n return key\n .split(\"_\")\n .filter(Boolean)\n .map((part) => {\n const upper = part.toUpperCase();\n if (uppercaseAcronyms.includes(upper)) return upper;\n return upper[0] ? upper[0] + upper.slice(1).toLowerCase() : \"\";\n })\n .filter(Boolean)\n .join(\" \");\n}\n\nexport type Order = v.InferOutput<ReturnType<typeof createOrderSchema>>;\n\nexport function createOrderTransferSchema() {\n return v.pipe(\n v.object({\n txId: v.string(),\n matchId: v.pipe(\n v.bigint(),\n v.transform((value) => value.toString()),\n ),\n symbolId: v.number(),\n assetId: v.number(),\n amountE18: v.optional(\n v.object({\n hi: v.bigint(),\n lo: v.bigint(),\n }),\n ),\n isDebit: v.boolean(),\n transferCode: v.number(),\n accountCode: v.number(),\n tsNs: v.bigint(),\n }),\n v.transform((tr) => ({\n txId: tr.txId,\n matchId: tr.matchId,\n symbolId: tr.symbolId,\n assetId: tr.assetId,\n isDebit: tr.isDebit,\n timestamp: tsNsToMs(tr.tsNs),\n amount: scaledToDecimalOutput(fromU128(tr.amountE18), E18_SCALE),\n type: enumLabel(TransferCodeCodec.protoToOutput, tr.transferCode),\n accountCode: enumLabel(AccountCodeCodec.protoToOutput, tr.accountCode),\n })),\n );\n}\n\nexport type OrderTransfer = v.InferOutput<ReturnType<typeof createOrderTransferSchema>>;\n\nexport function createOrderDetailsSchema(scales: SdkScales) {\n return v.object({\n nextPageToken: v.optional(v.string(), \"\"),\n order: createOrderSchema(scales),\n trades: v.optional(v.array(createUserTradeSchema(scales)), []),\n transfers: v.optional(v.array(createOrderTransferSchema()), []),\n });\n}\n\nexport type OrderDetails = v.InferOutput<ReturnType<typeof createOrderDetailsSchema>>;\n"],"mappings":";;;;;;;;;;;;;;AA0BA,MAAM,0BAA0B,gBAAgB,iBAAiB,aAAa;AAE9E,MAAM,wBAAwB,EAAE,OAAO;CACnC,OAAO,gBAAgB,sBAAsB,aAAa;CAC1D,aAAa,gBAAgB,sBAAsB,aAAa;CAChE,WAAW;CACX,eAAe;CACf,UAAU,EAAE,OAAO;AACvB,CAAC;AAED,SAAgB,kBAAkB,QAAmB;CACjD,OAAO,EAAE,KACL,EAAE,OAAO;EACL,SAAS,EAAE,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,eAAe,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;EACxC,OAAO,kBAAkB,MAAM;EAC/B,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,MAAM,CAAC,GAAG,CAAC,CAAC;EAC7D,WAAW,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC,GAAG,CAAC,CAAC;CAClE,CAAC;AACL"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { CreateSubaccountInput, CreateSubaccountInputSchema, CreateSubaccountResult, CreateSubaccountResultSchema, EffectiveSubaccountPermissions, EffectiveSubaccountPermissionsSchema, InviteSubaccountMemberInput, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInput, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInput, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInput, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInput, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityEventSchema, SubaccountActivityInput, SubaccountActivityInputSchema, SubaccountEvent, SubaccountIdInput, SubaccountIdInputSchema, SubaccountInvite, SubaccountInviteSchema, SubaccountInviteStatus, SubaccountMember, SubaccountMemberSchema, SubaccountMutationResult, SubaccountMutationResultSchema, SubaccountPermission, SubaccountPermissionDefinition, SubaccountPermissionDefinitionSchema, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleCatalogSchema, SubaccountRoleDefinition, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInput, UpdateSubaccountMemberRoleInputSchema } from "./subaccounts.schemas.js";
|
|
1
|
+
import { CreateSubaccountChallengeInput, CreateSubaccountChallengeInputSchema, CreateSubaccountInput, CreateSubaccountInputSchema, CreateSubaccountResult, CreateSubaccountResultSchema, EffectiveSubaccountPermissions, EffectiveSubaccountPermissionsSchema, InviteSubaccountMemberInput, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInput, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInput, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInput, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInput, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityEventSchema, SubaccountActivityInput, SubaccountActivityInputSchema, SubaccountChallenge, SubaccountChallengeSchema, SubaccountEvent, SubaccountIdInput, SubaccountIdInputSchema, SubaccountInvite, SubaccountInviteSchema, SubaccountInviteStatus, SubaccountMember, SubaccountMemberSchema, SubaccountMutationResult, SubaccountMutationResultSchema, SubaccountPermission, SubaccountPermissionDefinition, SubaccountPermissionDefinitionSchema, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleCatalogSchema, SubaccountRoleDefinition, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInput, UpdateSubaccountMemberRoleInputSchema } from "./subaccounts.schemas.js";
|
|
2
2
|
import { SubaccountsService } from "./subaccounts.js";
|
|
3
|
-
export { CreateSubaccountInput, CreateSubaccountInputSchema, CreateSubaccountResult, CreateSubaccountResultSchema, EffectiveSubaccountPermissions, EffectiveSubaccountPermissionsSchema, InviteSubaccountMemberInput, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInput, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInput, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInput, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInput, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityEventSchema, SubaccountActivityInput, SubaccountActivityInputSchema, SubaccountEvent, SubaccountIdInput, SubaccountIdInputSchema, SubaccountInvite, SubaccountInviteSchema, SubaccountInviteStatus, SubaccountMember, SubaccountMemberSchema, SubaccountMutationResult, SubaccountMutationResultSchema, SubaccountPermission, SubaccountPermissionDefinition, SubaccountPermissionDefinitionSchema, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleCatalogSchema, SubaccountRoleDefinition, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, SubaccountStatus, SubaccountsService, UpdateSubaccountInput, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInput, UpdateSubaccountMemberRoleInputSchema };
|
|
3
|
+
export { CreateSubaccountChallengeInput, CreateSubaccountChallengeInputSchema, CreateSubaccountInput, CreateSubaccountInputSchema, CreateSubaccountResult, CreateSubaccountResultSchema, EffectiveSubaccountPermissions, EffectiveSubaccountPermissionsSchema, InviteSubaccountMemberInput, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInput, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInput, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInput, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInput, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityEventSchema, SubaccountActivityInput, SubaccountActivityInputSchema, SubaccountChallenge, SubaccountChallengeSchema, SubaccountEvent, SubaccountIdInput, SubaccountIdInputSchema, SubaccountInvite, SubaccountInviteSchema, SubaccountInviteStatus, SubaccountMember, SubaccountMemberSchema, SubaccountMutationResult, SubaccountMutationResultSchema, SubaccountPermission, SubaccountPermissionDefinition, SubaccountPermissionDefinitionSchema, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleCatalogSchema, SubaccountRoleDefinition, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, SubaccountStatus, SubaccountsService, UpdateSubaccountInput, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInput, UpdateSubaccountMemberRoleInputSchema };
|
|
@@ -9,7 +9,7 @@ import "../api-keys/index.js";
|
|
|
9
9
|
import { SubaccountPolicy } from "../policies/subaccount-policies/subaccount-policies.schemas.js";
|
|
10
10
|
import { SubaccountPoliciesService } from "../policies/subaccount-policies/subaccount-policies.js";
|
|
11
11
|
import "../policies/subaccount-policies/index.js";
|
|
12
|
-
import { CreateSubaccountInputSchema, CreateSubaccountResult, EffectiveSubaccountPermissions, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityInputSchema, SubaccountEvent, SubaccountIdInputSchema, SubaccountInvite, SubaccountMember, SubaccountMutationResult, SubaccountRoleCatalog, SubaccountSchema, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInputSchema } from "./subaccounts.schemas.js";
|
|
12
|
+
import { CreateSubaccountChallengeInputSchema, CreateSubaccountInputSchema, CreateSubaccountResult, EffectiveSubaccountPermissions, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityInputSchema, SubaccountChallenge, SubaccountEvent, SubaccountIdInputSchema, SubaccountInvite, SubaccountMember, SubaccountMutationResult, SubaccountRoleCatalog, SubaccountSchema, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInputSchema } from "./subaccounts.schemas.js";
|
|
13
13
|
import * as v from "valibot";
|
|
14
14
|
//#region src/services/subaccounts/subaccounts.d.ts
|
|
15
15
|
interface SubscribeSubaccountsInput extends BaseSubscribeInput<Subaccount> {
|
|
@@ -26,7 +26,7 @@ declare class SubaccountsService {
|
|
|
26
26
|
readonly policies: SubaccountPoliciesService;
|
|
27
27
|
constructor(transports: AuthAndPublicApiTransports, realtime: PolyesterRealtime, resolver?: SubaccountResolver);
|
|
28
28
|
/**
|
|
29
|
-
* Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted
|
|
29
|
+
* Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted ones. Use `createChallenge` for the canonical next smart-account address and salt.
|
|
30
30
|
*/
|
|
31
31
|
list(options?: PolyesterRequestOptions): Promise<{
|
|
32
32
|
totalCreated: number;
|
|
@@ -42,7 +42,13 @@ declare class SubaccountsService {
|
|
|
42
42
|
invites: SubaccountInvite[];
|
|
43
43
|
}>;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Requests the canonical next smart account and a short-lived EIP-191 authorization message
|
|
46
|
+
* bound to the authenticated root and the selected owner EOA. Sign the exact message through
|
|
47
|
+
* the returned smart account, then pass it to `create`. A new challenge replaces the previous one.
|
|
48
|
+
*/
|
|
49
|
+
createChallenge(input: v.InferInput<typeof CreateSubaccountChallengeInputSchema>, options?: PolyesterRequestOptions): Promise<SubaccountChallenge>;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new subaccount under the caller's root account using the smart-account address, message, and smart-account signature from `createChallenge`.
|
|
46
52
|
*/
|
|
47
53
|
create(input: v.InferInput<typeof CreateSubaccountInputSchema>, options?: PolyesterMutationOptions): Promise<CreateSubaccountResult>;
|
|
48
54
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccounts.d.ts","names":[],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"subaccounts.d.ts","names":[],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"mappings":";;;;;;;;;;;;;;UAsDU,kCAAkC,mBAAmB;EAC3D;;UAGM,8BAA8B,mBAAmB;EACvD;;;;;cAMS;;WACA,UAAU;EASf,YAAA,YAAY,4BACZ,UAAU,mBACV,WAAW;;;;EAaT,KAAK,UAAU,0BAA0B;IAC3C;IACA,aAAa,EAAE,mBAAmB;;;;;EAYhC,IACF,OAAO,EAAE,kBAAkB,0BAC3B,UAAU,0BACX,QACC;IACI,SAAS;IACT,QAAQ;IACR,SAAS;IACT,SAAS;;;;;;;EAqCX,gBACF,OAAO,EAAE,kBAAkB,uCAC3B,UAAU,0BACX,QAAQ;;;;EAYL,OACF,OAAO,EAAE,kBAAkB,8BAC3B,UAAU,2BACX,QAAQ;;;;EAYL,OACF,OAAO,EAAE,kBAAkB,8BAC3B,UAAU,2BACX,QAAQ;;;;EAaL,aACF,OAAO,EAAE,kBAAkB,oCAC3B,UAAU,2BACX,QAAQ;;;;EAYL,aACF,OAAO,EAAE,kBAAkB,oCAC3B,UAAU,2BACX,QAAQ;;;;EAYL,iBACF,OAAO,EAAE,kBAAkB,wCAC3B,UAAU,2BACX,QAAQ;;;;EAYL,wBACF,OAAO,EAAE,kBAAkB,+CAC3B,UAAU,2BACX,QAAQ;;;;EAYL,YACF,OAAO,EAAE,kBAAkB,mCAC3B,UAAU,0BACX,QAAQ;;;;EAYL,UAAU,UAAU,0BAA0B,QAAQ;;;;EAWtD,wBACF,OAAO,EAAE,kBAAkB,0BAC3B,UAAU,0BACX,QAAQ;;;;EAYL,YACF,OAAO,EAAE,kBAAkB,0BAC3B,UAAU,0BACX,QAAQ;;;;EAYL,cACF,OAAO,EAAE,kBAAkB,qCAC3B,UAAU,2BACX,QAAQ;;;;EAYL,WACF,OAAO,EAAE,kBAAkB,gCAC3B,UAAU,0BACX;IAAU,QAAQ;IAAmB;;;;;EAexC,UAAU,OAAO;;;;EAmBjB,iBAAiB,OAAO"}
|
|
@@ -6,7 +6,7 @@ import { ApiKeySchema as ApiKeySchema$1 } from "../api-keys/api-keys.schemas.js"
|
|
|
6
6
|
import { SubaccountRoleService, SubaccountSchema, SubaccountService, SubaccountViewService } from "../../gen/auth/v1/subaccounts_pb.js";
|
|
7
7
|
import { DEFAULT_SUBACCOUNT_POLICY, SubaccountPolicySchema } from "../policies/subaccount-policies/subaccount-policies.schemas.js";
|
|
8
8
|
import { SubaccountPoliciesService } from "../policies/subaccount-policies/subaccount-policies.js";
|
|
9
|
-
import { CreateSubaccountInputSchema, CreateSubaccountResultSchema, EffectiveSubaccountPermissionsSchema, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInputSchema, SubaccountActivityEventSchema, SubaccountActivityInputSchema, SubaccountIdInputSchema, SubaccountInviteSchema, SubaccountMemberSchema, SubaccountMutationResultSchema, SubaccountRoleCatalogSchema, SubaccountSchema as SubaccountSchema$1, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInputSchema } from "./subaccounts.schemas.js";
|
|
9
|
+
import { CreateSubaccountChallengeInputSchema, CreateSubaccountInputSchema, CreateSubaccountResultSchema, EffectiveSubaccountPermissionsSchema, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInputSchema, SubaccountActivityEventSchema, SubaccountActivityInputSchema, SubaccountChallengeSchema, SubaccountIdInputSchema, SubaccountInviteSchema, SubaccountMemberSchema, SubaccountMutationResultSchema, SubaccountRoleCatalogSchema, SubaccountSchema as SubaccountSchema$1, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInputSchema } from "./subaccounts.schemas.js";
|
|
10
10
|
import { createClient } from "@connectrpc/connect";
|
|
11
11
|
import * as v from "valibot";
|
|
12
12
|
//#region src/services/subaccounts/subaccounts.ts
|
|
@@ -29,7 +29,7 @@ var SubaccountsService = class {
|
|
|
29
29
|
this.#realtime = realtime;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted
|
|
32
|
+
* Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted ones. Use `createChallenge` for the canonical next smart-account address and salt.
|
|
33
33
|
*/
|
|
34
34
|
async list(options) {
|
|
35
35
|
const res = await this.#client.listSubaccounts({}, toConnectCallOptions(options));
|
|
@@ -63,7 +63,17 @@ var SubaccountsService = class {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* Requests the canonical next smart account and a short-lived EIP-191 authorization message
|
|
67
|
+
* bound to the authenticated root and the selected owner EOA. Sign the exact message through
|
|
68
|
+
* the returned smart account, then pass it to `create`. A new challenge replaces the previous one.
|
|
69
|
+
*/
|
|
70
|
+
async createChallenge(input, options) {
|
|
71
|
+
const validatedInput = parse(CreateSubaccountChallengeInputSchema, input);
|
|
72
|
+
const res = await this.#client.createSubaccountChallenge(validatedInput, toConnectCallOptions(options));
|
|
73
|
+
return parse(SubaccountChallengeSchema, res);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Creates a new subaccount under the caller's root account using the smart-account address, message, and smart-account signature from `createChallenge`.
|
|
67
77
|
*/
|
|
68
78
|
async create(input, options) {
|
|
69
79
|
const validatedInput = parse(CreateSubaccountInputSchema, input);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccounts.js","names":["#client","Proto.SubaccountService","#viewClient","Proto.SubaccountViewService","#publicRoleClient","Proto.SubaccountRoleService","#authRoleClient","#realtime","SubaccountSchema","ApiKeySchema","Proto.SubaccountSchema","ProtoApiKeys.ApiKeySchema"],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport * as ProtoApiKeys from \"../../gen/auth/v1/api_keys_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type ApiKey, ApiKeySchema } from \"../api-keys/index.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport {\n DEFAULT_SUBACCOUNT_POLICY,\n SubaccountPoliciesService,\n type SubaccountPolicy,\n SubaccountPolicySchema,\n} from \"../policies/subaccount-policies/index.js\";\nimport 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, server-issued SIWE message, 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: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MAAM,6BAA6B,GAAG,CAAC,CAAC,GAAG,IAAI,MAAM;GAChF,eAAe,IAAI;EACvB;CACJ;;;;CAKA,UAAU,OAAkC;EACxC,MAAM,UAAU,4BAA4B,MAAM,UAAU;EAE5D,OAAO,KAAKK,UAAU,oBAAoB;GACtC;GACA,QAAQG;GACR,gBAAgB,SAAS;IACrB,MAAM,aAAa,MAAMF,oBAAkB,IAAI;IAC/C,MAAM,QAAQ,UAAU;GAC5B;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;;;;CAKA,iBAAiB,OAA8B;EAC3C,MAAM,UAAU,yBAAyB,MAAM,UAAU;EAEzD,OAAO,KAAKD,UAAU,oBAAoB;GACtC;GACA,QAAQI;GACR,gBAAgB,SAAS;IACrB,MAAM,SAAS,MAAMF,gBAAc,IAAI;IACvC,MAAM,QAAQ,MAAM;GACxB;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
|
|
1
|
+
{"version":3,"file":"subaccounts.js","names":["#client","Proto.SubaccountService","#viewClient","Proto.SubaccountViewService","#publicRoleClient","Proto.SubaccountRoleService","#authRoleClient","#realtime","SubaccountSchema","ApiKeySchema","Proto.SubaccountSchema","ProtoApiKeys.ApiKeySchema"],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport * as ProtoApiKeys from \"../../gen/auth/v1/api_keys_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type ApiKey, ApiKeySchema } from \"../api-keys/index.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport {\n DEFAULT_SUBACCOUNT_POLICY,\n SubaccountPoliciesService,\n type SubaccountPolicy,\n SubaccountPolicySchema,\n} from \"../policies/subaccount-policies/index.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport type { SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSubaccountChallengeInputSchema,\n CreateSubaccountInputSchema,\n CreateSubaccountResultSchema,\n SubaccountChallengeSchema,\n UpdateSubaccountInputSchema,\n InviteSubaccountMemberInputSchema,\n RemoveSubaccountMemberInputSchema,\n UpdateSubaccountMemberRoleInputSchema,\n ListSubaccountInvitesInputSchema,\n RespondSubaccountInviteInputSchema,\n SubaccountActivityInputSchema,\n SubaccountSchema,\n SubaccountMemberSchema,\n SubaccountInviteSchema,\n SubaccountActivityEventSchema,\n SetSubaccountMemberMfaRequirementInputSchema,\n SubaccountIdInputSchema,\n SubaccountMutationResultSchema,\n SubaccountRoleCatalogSchema,\n EffectiveSubaccountPermissionsSchema,\n type CreateSubaccountResult,\n type SubaccountChallenge,\n type Subaccount,\n type SubaccountMember,\n type SubaccountInvite,\n type SubaccountEvent,\n type SubaccountMutationResult,\n type SubaccountRoleCatalog,\n type EffectiveSubaccountPermissions,\n} from \"./subaccounts.schemas.js\";\n\ninterface SubscribeSubaccountsInput extends BaseSubscribeInput<Subaccount> {\n accountId: string;\n}\n\ninterface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {\n accountId: string;\n}\n\n/**\n * Reads the public role catalog and creates, manages, shares, audits, and subscribes to subaccounts visible to the authenticated caller.\n */\nexport class SubaccountsService {\n readonly policies: SubaccountPoliciesService;\n\n #client: Client<typeof Proto.SubaccountService>;\n #viewClient: Client<typeof Proto.SubaccountViewService>;\n #publicRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #authRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #realtime: PolyesterRealtime;\n\n constructor(\n transports: AuthAndPublicApiTransports,\n realtime: PolyesterRealtime,\n resolver?: SubaccountResolver,\n ) {\n this.policies = new SubaccountPoliciesService(transports, realtime, resolver);\n this.#client = createClient(Proto.SubaccountService, transports.authApi);\n this.#viewClient = createClient(Proto.SubaccountViewService, transports.authApi);\n this.#publicRoleClient = createClient(Proto.SubaccountRoleService, transports.publicApi);\n this.#authRoleClient = createClient(Proto.SubaccountRoleService, transports.authApi);\n this.#realtime = realtime;\n }\n\n /**\n * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted ones. Use `createChallenge` for the canonical next smart-account address and salt.\n */\n async list(options?: PolyesterRequestOptions): Promise<{\n totalCreated: number;\n subaccounts: v.InferOutput<typeof SubaccountSchema>[];\n }> {\n const res = await this.#client.listSubaccounts({}, toConnectCallOptions(options));\n return {\n totalCreated: res.totalCreated,\n subaccounts: parse(v.array(SubaccountSchema), res.subaccounts),\n };\n }\n\n /**\n * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, 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 * Requests the canonical next smart account and a short-lived EIP-191 authorization message\n * bound to the authenticated root and the selected owner EOA. Sign the exact message through\n * the returned smart account, then pass it to `create`. A new challenge replaces the previous one.\n */\n async createChallenge(\n input: v.InferInput<typeof CreateSubaccountChallengeInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountChallenge> {\n const validatedInput = parse(CreateSubaccountChallengeInputSchema, input);\n const res = await this.#client.createSubaccountChallenge(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountChallengeSchema, res);\n }\n\n /**\n * Creates a new subaccount under the caller's root account using the smart-account address, message, and smart-account signature from `createChallenge`.\n */\n async create(\n input: v.InferInput<typeof CreateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CreateSubaccountResult> {\n const validatedInput = parse(CreateSubaccountInputSchema, input);\n const res = await this.#client.createSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(CreateSubaccountResultSchema, res);\n }\n\n /**\n * Updates mutable subaccount display/status fields such as label and active/disabled status.\n */\n async update(\n input: v.InferInput<typeof UpdateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Subaccount> {\n const validatedInput = parse(UpdateSubaccountInputSchema, input);\n const res = await this.#client.updateSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(\"Failed to update subaccount\");\n return parse(SubaccountSchema, res.subaccount);\n }\n\n /**\n * Creates or refreshes a pending invitation granting a role on a subaccount to another root account.\n */\n async inviteMember(\n input: v.InferInput<typeof InviteSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(InviteSubaccountMemberInputSchema, input);\n const res = await this.#client.inviteSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Removes delegated access for a subaccount member by grantee account ID.\n */\n async removeMember(\n input: v.InferInput<typeof RemoveSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(RemoveSubaccountMemberInputSchema, input);\n const res = await this.#client.removeSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Changes an existing delegated member's role without sending a new invitation.\n */\n async updateMemberRole(\n input: v.InferInput<typeof UpdateSubaccountMemberRoleInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(UpdateSubaccountMemberRoleInputSchema, input);\n const res = await this.#client.updateSubaccountMemberRole(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Enables or disables the owner-controlled MFA requirement for delegated interactive member actions on a subaccount.\n */\n async setMemberMfaRequirement(\n input: v.InferInput<typeof SetSubaccountMemberMfaRequirementInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(SetSubaccountMemberMfaRequirementInputSchema, input);\n const res = await this.#client.setSubaccountMemberMFARequirement(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Returns 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":";;;;;;;;;;;;;;;AAiEA,IAAa,qBAAb,MAAgC;CAC5B;CAEA;CACA;CACA;CACA;CACA;CAEA,YACI,YACA,UACA,UACF;EACE,KAAK,WAAW,IAAI,0BAA0B,YAAY,UAAU,QAAQ;EAC5E,KAAKA,UAAU,aAAaC,mBAAyB,WAAW,OAAO;EACvE,KAAKC,cAAc,aAAaC,uBAA6B,WAAW,OAAO;EAC/E,KAAKC,oBAAoB,aAAaC,uBAA6B,WAAW,SAAS;EACvF,KAAKC,kBAAkB,aAAaD,uBAA6B,WAAW,OAAO;EACnF,KAAKE,YAAY;CACrB;;;;CAKA,MAAM,KAAK,SAGR;EACC,MAAM,MAAM,MAAM,KAAKP,QAAQ,gBAAgB,CAAC,GAAG,qBAAqB,OAAO,CAAC;EAChF,OAAO;GACH,cAAc,IAAI;GAClB,aAAa,MAAM,EAAE,MAAMQ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;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"}
|
|
@@ -42,6 +42,25 @@ declare const EffectiveSubaccountPermissionsSchema: v.ObjectSchema<{
|
|
|
42
42
|
readonly subaccountPolicyId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
43
43
|
}, undefined>;
|
|
44
44
|
type EffectiveSubaccountPermissions = v.InferOutput<typeof EffectiveSubaccountPermissionsSchema>;
|
|
45
|
+
declare const CreateSubaccountChallengeInputSchema: v.StrictObjectSchema<{
|
|
46
|
+
readonly ownerAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid wallet address.">]>;
|
|
47
|
+
readonly uri: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 2048, undefined>, v.CheckAction<string, "Wallet challenge URI must be an HTTP(S) origin without a path, query, fragment, or user information.">]>;
|
|
48
|
+
}, undefined>;
|
|
49
|
+
type CreateSubaccountChallengeInput = v.InferInput<typeof CreateSubaccountChallengeInputSchema>;
|
|
50
|
+
declare const SubaccountChallengeSchema: v.ObjectSchema<{
|
|
51
|
+
readonly message: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.CheckAction<string, "Wallet challenge message exceeds 4096 UTF-8 bytes.">]>;
|
|
52
|
+
readonly smartAccountAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid wallet address.">]>;
|
|
53
|
+
readonly smartAccountSaltNonce: v.NumberSchema<undefined>;
|
|
54
|
+
readonly expiresAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
55
|
+
readonly seconds: v.BigintSchema<undefined>;
|
|
56
|
+
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
57
|
+
}, undefined>, undefined>, v.TransformAction<{
|
|
58
|
+
seconds: bigint;
|
|
59
|
+
nanos: number;
|
|
60
|
+
} | undefined, number | undefined>]>;
|
|
61
|
+
readonly polyesterChainId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<any, number>]>;
|
|
62
|
+
}, undefined>;
|
|
63
|
+
type SubaccountChallenge = v.InferOutput<typeof SubaccountChallengeSchema>;
|
|
45
64
|
declare const CreateSubaccountInputSchema: v.StrictObjectSchema<{
|
|
46
65
|
readonly label: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
47
66
|
readonly icon: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
@@ -209,7 +228,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
209
228
|
readonly granteeAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
210
229
|
readonly inviterAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
211
230
|
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
212
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "pending" | "
|
|
231
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "pending" | "accepted" | "declined" | "cancelled">]>;
|
|
213
232
|
readonly createdAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
214
233
|
readonly seconds: v.BigintSchema<undefined>;
|
|
215
234
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -236,7 +255,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
236
255
|
granteeAccountId: string;
|
|
237
256
|
inviterAccountId: string;
|
|
238
257
|
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
239
|
-
status: "unspecified" | "pending" | "
|
|
258
|
+
status: "unspecified" | "pending" | "accepted" | "declined" | "cancelled";
|
|
240
259
|
createdAt?: number | undefined;
|
|
241
260
|
respondedAt?: number | undefined;
|
|
242
261
|
granteeUsername: string;
|
|
@@ -254,7 +273,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
254
273
|
granteeAccountId: string;
|
|
255
274
|
inviterAccountId: string;
|
|
256
275
|
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
257
|
-
status: "unspecified" | "pending" | "
|
|
276
|
+
status: "unspecified" | "pending" | "accepted" | "declined" | "cancelled";
|
|
258
277
|
createdAt?: number | undefined;
|
|
259
278
|
respondedAt?: number | undefined;
|
|
260
279
|
granteeUsername: string;
|
|
@@ -276,8 +295,8 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
|
|
|
276
295
|
seconds: bigint;
|
|
277
296
|
nanos: number;
|
|
278
297
|
} | undefined, number | undefined>]>;
|
|
279
|
-
readonly entityKind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "
|
|
280
|
-
readonly eventAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "enabled" | "disabled" | "
|
|
298
|
+
readonly entityKind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "member" | "policy" | "invite" | "security">]>;
|
|
299
|
+
readonly eventAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "enabled" | "disabled" | "failed" | "created" | "updated" | "deleted" | "removed" | "role_set" | "received" | "replied" | "revoked" | "blocked" | "hold_placed" | "hold_released">]>;
|
|
281
300
|
readonly source: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "web" | "mobile" | "api">]>;
|
|
282
301
|
readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
283
302
|
readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -286,5 +305,5 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
|
|
|
286
305
|
}, undefined>;
|
|
287
306
|
type SubaccountEvent = v.InferOutput<typeof SubaccountActivityEventSchema>;
|
|
288
307
|
//#endregion
|
|
289
|
-
export { CreateSubaccountInput, CreateSubaccountInputSchema, CreateSubaccountResult, CreateSubaccountResultSchema, EffectiveSubaccountPermissions, EffectiveSubaccountPermissionsSchema, InviteSubaccountMemberInput, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInput, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInput, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInput, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInput, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityEventSchema, SubaccountActivityInput, SubaccountActivityInputSchema, SubaccountEvent, SubaccountIdInput, SubaccountIdInputSchema, SubaccountInvite, SubaccountInviteSchema, SubaccountInviteStatus, SubaccountMember, SubaccountMemberSchema, SubaccountMutationResult, SubaccountMutationResultSchema, SubaccountPermission, SubaccountPermissionDefinition, SubaccountPermissionDefinitionSchema, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleCatalogSchema, SubaccountRoleDefinition, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInput, UpdateSubaccountMemberRoleInputSchema };
|
|
308
|
+
export { CreateSubaccountChallengeInput, CreateSubaccountChallengeInputSchema, CreateSubaccountInput, CreateSubaccountInputSchema, CreateSubaccountResult, CreateSubaccountResultSchema, EffectiveSubaccountPermissions, EffectiveSubaccountPermissionsSchema, InviteSubaccountMemberInput, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInput, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInput, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInput, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInput, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityEventSchema, SubaccountActivityInput, SubaccountActivityInputSchema, SubaccountChallenge, SubaccountChallengeSchema, SubaccountEvent, SubaccountIdInput, SubaccountIdInputSchema, SubaccountInvite, SubaccountInviteSchema, SubaccountInviteStatus, SubaccountMember, SubaccountMemberSchema, SubaccountMutationResult, SubaccountMutationResultSchema, SubaccountPermission, SubaccountPermissionDefinition, SubaccountPermissionDefinitionSchema, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleCatalogSchema, SubaccountRoleDefinition, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInput, UpdateSubaccountMemberRoleInputSchema };
|
|
290
309
|
//# sourceMappingURL=subaccounts.schemas.d.ts.map
|
|
@@ -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":";;;cA0Ca,sBAAoB,EAAA;KAErB,iBAAiB,EAAE,mBAAmB;cAI5C,iCAA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EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyBjB,aAAa,EAAE,mBAAmB;cAEjC,wBAAsB,EAAA;;;;;;;;KASvB,mBAAmB,EAAE,mBAAmB;cAEvC,wBAAsB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqCvB,mBAAmB,EAAE,mBAAmB;cAEvC,+BAA6B,EAAA;;;;;KAM9B,0BAA0B,EAAE,kBAAkB;cAE7C,+BAA6B,EAAA;;;;;;;;;;;;;;;;KAc9B,kBAAkB,EAAE,mBAAmB"}
|
|
@@ -3,7 +3,7 @@ import { tsObjToMs, tsObjToNsString } from "../../utils/time.js";
|
|
|
3
3
|
import { BigIntStringSchema, OptionalTimestampMsSchema, PublicIdSchema, TimestampSchema, idInputSchema, positiveBigintStringInputSchema } from "../../shared/schemas.js";
|
|
4
4
|
import { PolicyActionCodec } from "../policies/shared.codecs.js";
|
|
5
5
|
import { buildProtoPatch, defineProtoPatchFields } from "../../utils/proto-patch.js";
|
|
6
|
-
import { WalletAddressSchema, WalletChallengeMessageSchema, WalletSignatureSchema } from "../auth/wallet-challenge.schemas.js";
|
|
6
|
+
import { WalletAddressSchema, WalletChallengeMessageSchema, WalletChallengeUriSchema, WalletSignatureSchema } from "../auth/wallet-challenge.schemas.js";
|
|
7
7
|
import { ActivityEntityKindCodec, ActivityEventActionCodec, ActivityEventSourceCodec, InviteActionCodec, InviteStatusCodec, SUBACCOUNT_INVITE_DIRECTION_VALUES, SUBACCOUNT_STATUS_VALUES, SubaccountInviteDirectionCodec, SubaccountPermissionCodec, SubaccountRoleCodec, SubaccountStatusCodec } from "./subaccounts.codecs.js";
|
|
8
8
|
import * as v from "valibot";
|
|
9
9
|
const SubaccountRoleSchema = v.picklist([
|
|
@@ -38,6 +38,17 @@ const EffectiveSubaccountPermissionsSchema = v.object({
|
|
|
38
38
|
permissions: v.optional(v.array(ProtoSubaccountPermissionSchema), []),
|
|
39
39
|
subaccountPolicyId: PublicIdSchema
|
|
40
40
|
});
|
|
41
|
+
const CreateSubaccountChallengeInputSchema = v.strictObject({
|
|
42
|
+
ownerAddress: WalletAddressSchema,
|
|
43
|
+
uri: WalletChallengeUriSchema
|
|
44
|
+
});
|
|
45
|
+
const SubaccountChallengeSchema = v.object({
|
|
46
|
+
message: WalletChallengeMessageSchema,
|
|
47
|
+
smartAccountAddress: WalletAddressSchema,
|
|
48
|
+
smartAccountSaltNonce: v.number(),
|
|
49
|
+
expiresAt: OptionalTimestampMsSchema,
|
|
50
|
+
polyesterChainId: v.pipe(v.bigint(), v.transform(Number))
|
|
51
|
+
});
|
|
41
52
|
const CreateSubaccountInputSchema = v.strictObject({
|
|
42
53
|
label: v.optional(v.string(), ""),
|
|
43
54
|
icon: v.optional(v.string(), ""),
|
|
@@ -187,6 +198,6 @@ const SubaccountActivityEventSchema = v.object({
|
|
|
187
198
|
payloadJson: v.pipe(v.string(), v.transform((v) => JSON.parse(v)))
|
|
188
199
|
});
|
|
189
200
|
//#endregion
|
|
190
|
-
export { CreateSubaccountInputSchema, CreateSubaccountResultSchema, EffectiveSubaccountPermissionsSchema, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInputSchema, SubaccountActivityEventSchema, SubaccountActivityInputSchema, SubaccountIdInputSchema, SubaccountInviteSchema, SubaccountMemberSchema, SubaccountMutationResultSchema, SubaccountPermissionDefinitionSchema, SubaccountRoleCatalogSchema, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInputSchema };
|
|
201
|
+
export { CreateSubaccountChallengeInputSchema, CreateSubaccountInputSchema, CreateSubaccountResultSchema, EffectiveSubaccountPermissionsSchema, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInputSchema, SubaccountActivityEventSchema, SubaccountActivityInputSchema, SubaccountChallengeSchema, SubaccountIdInputSchema, SubaccountInviteSchema, SubaccountMemberSchema, SubaccountMutationResultSchema, SubaccountPermissionDefinitionSchema, SubaccountRoleCatalogSchema, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInputSchema };
|
|
191
202
|
|
|
192
203
|
//# sourceMappingURL=subaccounts.schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccounts.schemas.js","names":[],"sources":["../../../src/services/subaccounts/subaccounts.schemas.ts"],"sourcesContent":["import {\n WalletAddressSchema,\n WalletChallengeMessageSchema,\n WalletSignatureSchema,\n} from \"../auth/wallet-challenge.schemas.js\";\nimport * as v from \"valibot\";\nimport {\n BigIntStringSchema,\n OptionalTimestampMsSchema,\n PublicIdSchema,\n TimestampSchema,\n idInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../utils/time.js\";\nimport { enumLabel, enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport {\n SubaccountRoleCodec,\n SubaccountPermissionCodec,\n InviteActionCodec,\n InviteStatusCodec,\n SubaccountInviteDirectionCodec,\n SUBACCOUNT_INVITE_DIRECTION_VALUES,\n SubaccountStatusCodec,\n SUBACCOUNT_STATUS_VALUES,\n ActivityEntityKindCodec,\n ActivityEventActionCodec,\n ActivityEventSourceCodec,\n} from \"./subaccounts.codecs.js\";\nimport { PolicyActionCodec } from \"../policies/shared.codecs.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../utils/proto-patch.js\";\n\nconst SUBACCOUNT_ROLE_VALUES = [\n \"owner\",\n \"admin\",\n \"treasury\",\n \"leveraged_trader\",\n \"trader\",\n \"viewer\",\n] as const;\n\nexport const SubaccountRoleSchema = v.picklist(SUBACCOUNT_ROLE_VALUES);\n\nexport type SubaccountRole = v.InferOutput<typeof SubaccountRoleSchema>;\n\nconst ProtoSubaccountRoleSchema = enumLabelSchema(SubaccountRoleCodec.protoToOutput);\n\nconst ProtoSubaccountPermissionSchema = enumLabelSchema(SubaccountPermissionCodec.protoToOutput);\n\nexport type SubaccountPermission = v.InferOutput<typeof ProtoSubaccountPermissionSchema>;\n\nexport const SubaccountPermissionDefinitionSchema = v.object({\n permission: ProtoSubaccountPermissionSchema,\n displayName: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n policyAction: enumLabelSchema(PolicyActionCodec.protoToOutput),\n});\n\nexport type SubaccountPermissionDefinition = v.InferOutput<\n typeof SubaccountPermissionDefinitionSchema\n>;\n\nexport const SubaccountRoleDefinitionSchema = v.object({\n role: ProtoSubaccountRoleSchema,\n displayName: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n assignable: v.optional(v.boolean(), false),\n permissions: v.optional(v.array(ProtoSubaccountPermissionSchema), []),\n});\n\nexport type SubaccountRoleDefinition = v.InferOutput<typeof SubaccountRoleDefinitionSchema>;\n\nexport const SubaccountRoleCatalogSchema = v.object({\n permissions: v.optional(v.array(SubaccountPermissionDefinitionSchema), []),\n roles: v.optional(v.array(SubaccountRoleDefinitionSchema), []),\n});\n\nexport type SubaccountRoleCatalog = v.InferOutput<typeof SubaccountRoleCatalogSchema>;\n\nexport const EffectiveSubaccountPermissionsSchema = v.object({\n role: ProtoSubaccountRoleSchema,\n permissions: v.optional(v.array(ProtoSubaccountPermissionSchema), []),\n subaccountPolicyId: PublicIdSchema,\n});\n\nexport type EffectiveSubaccountPermissions = v.InferOutput<\n typeof EffectiveSubaccountPermissionsSchema\n>;\n\nexport const CreateSubaccountInputSchema = v.strictObject({\n label: v.optional(v.string(), \"\"),\n icon: v.optional(v.string(), \"\"),\n color: v.optional(v.string(), \"\"),\n smartAccountAddress: WalletAddressSchema,\n message: WalletChallengeMessageSchema,\n signature: WalletSignatureSchema,\n});\n\nexport type CreateSubaccountInput = v.InferInput<typeof CreateSubaccountInputSchema>;\n\nexport const SubaccountIdInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n});\n\nexport type SubaccountIdInput = v.InferInput<typeof SubaccountIdInputSchema>;\n\nexport const CreateSubaccountResultSchema = v.object({\n subaccountId: PublicIdSchema,\n totalCreated: v.number(),\n smartAccountSaltNonce: v.number(),\n revision: BigIntStringSchema,\n});\n\nexport type CreateSubaccountResult = v.InferOutput<typeof CreateSubaccountResultSchema>;\n\nexport const SubaccountMutationResultSchema = v.object({});\n\nexport type SubaccountMutationResult = v.InferOutput<typeof SubaccountMutationResultSchema>;\n\ntype SubaccountPatch = {\n label?: string;\n icon?: string;\n color?: string;\n status?: (typeof SUBACCOUNT_STATUS_VALUES)[number];\n};\n\nconst SUBACCOUNT_PATCH_FIELDS = defineProtoPatchFields<SubaccountPatch>()({\n label: { path: \"label\", encode: (label) => ({ label }) },\n icon: { path: \"icon\", encode: (icon) => ({ icon }) },\n color: { path: \"color\", encode: (color) => ({ color }) },\n status: {\n path: \"status\",\n encode: (status) => ({ status: SubaccountStatusCodec.inputToProto[status] }),\n },\n});\n\nexport const UpdateSubaccountInputSchema = v.pipe(\n v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n label: v.optional(v.string()),\n icon: v.optional(v.string()),\n color: v.optional(v.string()),\n status: v.optional(v.picklist(SUBACCOUNT_STATUS_VALUES)),\n }),\n v.check(\n ({ label, icon, color, status }) =>\n label !== undefined ||\n icon !== undefined ||\n color !== undefined ||\n status !== undefined,\n \"At least one subaccount field must be provided\",\n ),\n v.transform(({ subaccountId, expectedRevision, ...input }) => {\n const { patch: subaccount, updateMask } = buildProtoPatch(input, SUBACCOUNT_PATCH_FIELDS);\n return {\n subaccountId,\n subaccount,\n updateMask,\n expectedRevision,\n };\n }),\n);\n\nexport type UpdateSubaccountInput = v.InferInput<typeof UpdateSubaccountInputSchema>;\n\nexport const InviteSubaccountMemberInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n granteeAccountId: idInputSchema(\"granteeAccountId\"),\n role: v.pipe(\n SubaccountRoleSchema,\n v.transform((role) => SubaccountRoleCodec.inputToProto[role]),\n ),\n});\n\nexport type InviteSubaccountMemberInput = v.InferInput<typeof InviteSubaccountMemberInputSchema>;\n\nexport const RemoveSubaccountMemberInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n granteeAccountId: idInputSchema(\"granteeAccountId\"),\n});\n\nexport type RemoveSubaccountMemberInput = v.InferInput<typeof RemoveSubaccountMemberInputSchema>;\n\nexport const UpdateSubaccountMemberRoleInputSchema = InviteSubaccountMemberInputSchema;\n\nexport type UpdateSubaccountMemberRoleInput = v.InferInput<\n typeof UpdateSubaccountMemberRoleInputSchema\n>;\n\nexport const SetSubaccountMemberMfaRequirementInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n requireMemberMfa: v.boolean(),\n});\n\nexport type SetSubaccountMemberMfaRequirementInput = v.InferInput<\n typeof SetSubaccountMemberMfaRequirementInputSchema\n>;\n\nexport const ListSubaccountInvitesInputSchema = v.strictObject({\n direction: v.pipe(\n v.optional(v.picklist(SUBACCOUNT_INVITE_DIRECTION_VALUES), \"\"),\n v.transform((direction) => SubaccountInviteDirectionCodec.inputToProto[direction]),\n ),\n});\n\nexport type ListSubaccountInvitesInput = v.InferInput<typeof ListSubaccountInvitesInputSchema>;\n\nconst InviteActionSchema = v.picklist([\"accept\", \"decline\", \"cancel\"]);\n\nconst InviteStatusSchema = v.picklist([\"pending\", \"accepted\", \"declined\", \"cancelled\"]);\n\nexport type SubaccountInviteStatus = v.InferOutput<typeof InviteStatusSchema>;\n\nconst ProtoInviteStatusSchema = v.number();\n\nexport const RespondSubaccountInviteInputSchema = v.strictObject({\n inviteId: idInputSchema(\"inviteId\"),\n action: v.pipe(\n InviteActionSchema,\n v.transform((v) => InviteActionCodec.inputToProto[v]),\n ),\n});\n\nexport type RespondSubaccountInviteInput = v.InferInput<typeof RespondSubaccountInviteInputSchema>;\n\nconst ProtoSubaccountStatusSchema = enumLabelSchema(SubaccountStatusCodec.protoToOutput);\n\nexport type SubaccountStatus = v.InferOutput<typeof ProtoSubaccountStatusSchema>;\n\nexport const SubaccountSchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n label: v.optional(v.string(), \"\"),\n icon: v.optional(v.string(), \"\"),\n color: v.optional(v.string(), \"\"),\n status: ProtoSubaccountStatusSchema,\n smartAccountAddress: v.string(),\n smartAccountSaltNonce: v.optional(v.number()),\n ownerUsername: v.optional(v.string(), \"\"),\n ownerAvatarUrl: v.optional(v.string(), \"\"),\n ownerRootSmartAccountAddress: v.string(),\n subaccountPolicyId: PublicIdSchema,\n requireMemberMfa: v.optional(v.boolean(), false),\n updatedAt: v.optional(TimestampSchema),\n revision: BigIntStringSchema,\n }),\n v.transform(({ updatedAt, ...subaccount }) => ({\n ...subaccount,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n })),\n);\n\nexport type Subaccount = v.InferOutput<typeof SubaccountSchema>;\n\nexport const SubaccountMemberSchema = v.object({\n accountId: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n username: v.optional(v.string(), \"\"),\n smartAccountAddress: v.string(),\n avatarUrl: v.optional(v.string(), \"\"),\n mfaEnrolled: v.optional(v.boolean(), false),\n});\n\nexport type SubaccountMember = v.InferOutput<typeof SubaccountMemberSchema>;\n\nexport const SubaccountInviteSchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n subaccountId: PublicIdSchema,\n granteeAccountId: PublicIdSchema,\n inviterAccountId: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n status: v.pipe(\n ProtoInviteStatusSchema,\n v.transform((v) => enumLabel(InviteStatusCodec.protoToOutput, v)),\n ),\n createdAt: OptionalTimestampMsSchema,\n respondedAt: OptionalTimestampMsSchema,\n granteeUsername: v.optional(v.string(), \"\"),\n inviterUsername: v.optional(v.string(), \"\"),\n subaccountLabel: v.optional(v.string(), \"\"),\n inviterRootSmartAccountAddress: v.string(),\n granteeRootSmartAccountAddress: v.string(),\n requireMemberMfa: v.boolean(),\n }),\n v.transform(\n ({\n subaccountLabel,\n subaccountId,\n inviterRootSmartAccountAddress,\n granteeRootSmartAccountAddress,\n ...rest\n }) => ({\n ...rest,\n subaccountId,\n subaccountLabel,\n inviterSmartAccountAddress: inviterRootSmartAccountAddress,\n granteeSmartAccountAddress: granteeRootSmartAccountAddress,\n }),\n ),\n);\n\nexport type SubaccountInvite = v.InferOutput<typeof SubaccountInviteSchema>;\n\nexport const SubaccountActivityInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(200)), 50),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n});\n\nexport type SubaccountActivityInput = v.InferInput<typeof SubaccountActivityInputSchema>;\n\nexport const SubaccountActivityEventSchema = v.object({\n createdAt: OptionalTimestampMsSchema,\n entityKind: enumLabelSchema(ActivityEntityKindCodec.protoToOutput),\n eventAction: enumLabelSchema(ActivityEventActionCodec.protoToOutput),\n source: enumLabelSchema(ActivityEventSourceCodec.protoToOutput),\n ip: v.optional(v.string()),\n userAgent: v.optional(v.string()),\n actorAccountId: PublicIdSchema,\n payloadJson: v.pipe(\n v.string(),\n v.transform((v) => JSON.parse(v)),\n ),\n});\n\nexport type SubaccountEvent = v.InferOutput<typeof SubaccountActivityEventSchema>;\n"],"mappings":";;;;;;;;AAyCA,MAAa,uBAAuB,EAAE,SAAS;CAR3C;CACA;CACA;CACA;CACA;CACA;AAG2C,CAAsB;AAIrE,MAAM,4BAA4B,gBAAgB,oBAAoB,aAAa;AAEnF,MAAM,kCAAkC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gBAAgB,yBAAyB,aAAa;CAC9D,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC;CACzB,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC;CAChC,gBAAgB;CAChB,aAAa,EAAE,KACX,EAAE,OAAO,GACT,EAAE,WAAW,MAAM,KAAK,MAAM,CAAC,CAAC,CACpC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"subaccounts.schemas.js","names":[],"sources":["../../../src/services/subaccounts/subaccounts.schemas.ts"],"sourcesContent":["import {\n WalletAddressSchema,\n WalletChallengeMessageSchema,\n WalletChallengeUriSchema,\n WalletSignatureSchema,\n} from \"../auth/wallet-challenge.schemas.js\";\nimport * as v from \"valibot\";\nimport {\n BigIntStringSchema,\n OptionalTimestampMsSchema,\n PublicIdSchema,\n TimestampSchema,\n idInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../utils/time.js\";\nimport { enumLabel, enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport {\n SubaccountRoleCodec,\n SubaccountPermissionCodec,\n InviteActionCodec,\n InviteStatusCodec,\n SubaccountInviteDirectionCodec,\n SUBACCOUNT_INVITE_DIRECTION_VALUES,\n SubaccountStatusCodec,\n SUBACCOUNT_STATUS_VALUES,\n ActivityEntityKindCodec,\n ActivityEventActionCodec,\n ActivityEventSourceCodec,\n} from \"./subaccounts.codecs.js\";\nimport { PolicyActionCodec } from \"../policies/shared.codecs.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../utils/proto-patch.js\";\n\nconst SUBACCOUNT_ROLE_VALUES = [\n \"owner\",\n \"admin\",\n \"treasury\",\n \"leveraged_trader\",\n \"trader\",\n \"viewer\",\n] as const;\n\nexport const SubaccountRoleSchema = v.picklist(SUBACCOUNT_ROLE_VALUES);\n\nexport type SubaccountRole = v.InferOutput<typeof SubaccountRoleSchema>;\n\nconst ProtoSubaccountRoleSchema = enumLabelSchema(SubaccountRoleCodec.protoToOutput);\n\nconst ProtoSubaccountPermissionSchema = enumLabelSchema(SubaccountPermissionCodec.protoToOutput);\n\nexport type SubaccountPermission = v.InferOutput<typeof ProtoSubaccountPermissionSchema>;\n\nexport const SubaccountPermissionDefinitionSchema = v.object({\n permission: ProtoSubaccountPermissionSchema,\n displayName: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n policyAction: enumLabelSchema(PolicyActionCodec.protoToOutput),\n});\n\nexport type SubaccountPermissionDefinition = v.InferOutput<\n typeof SubaccountPermissionDefinitionSchema\n>;\n\nexport const SubaccountRoleDefinitionSchema = v.object({\n role: ProtoSubaccountRoleSchema,\n displayName: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n assignable: v.optional(v.boolean(), false),\n permissions: v.optional(v.array(ProtoSubaccountPermissionSchema), []),\n});\n\nexport type SubaccountRoleDefinition = v.InferOutput<typeof SubaccountRoleDefinitionSchema>;\n\nexport const SubaccountRoleCatalogSchema = v.object({\n permissions: v.optional(v.array(SubaccountPermissionDefinitionSchema), []),\n roles: v.optional(v.array(SubaccountRoleDefinitionSchema), []),\n});\n\nexport type SubaccountRoleCatalog = v.InferOutput<typeof SubaccountRoleCatalogSchema>;\n\nexport const EffectiveSubaccountPermissionsSchema = v.object({\n role: ProtoSubaccountRoleSchema,\n permissions: v.optional(v.array(ProtoSubaccountPermissionSchema), []),\n subaccountPolicyId: PublicIdSchema,\n});\n\nexport type EffectiveSubaccountPermissions = v.InferOutput<\n typeof EffectiveSubaccountPermissionsSchema\n>;\n\nexport const CreateSubaccountChallengeInputSchema = v.strictObject({\n ownerAddress: WalletAddressSchema,\n uri: WalletChallengeUriSchema,\n});\n\nexport type CreateSubaccountChallengeInput = v.InferInput<\n typeof CreateSubaccountChallengeInputSchema\n>;\n\nexport const SubaccountChallengeSchema = v.object({\n message: WalletChallengeMessageSchema,\n smartAccountAddress: WalletAddressSchema,\n smartAccountSaltNonce: v.number(),\n expiresAt: OptionalTimestampMsSchema,\n polyesterChainId: v.pipe(v.bigint(), v.transform(Number)),\n});\n\nexport type SubaccountChallenge = v.InferOutput<typeof SubaccountChallengeSchema>;\n\nexport const CreateSubaccountInputSchema = v.strictObject({\n label: v.optional(v.string(), \"\"),\n icon: v.optional(v.string(), \"\"),\n color: v.optional(v.string(), \"\"),\n smartAccountAddress: WalletAddressSchema,\n message: WalletChallengeMessageSchema,\n signature: WalletSignatureSchema,\n});\n\nexport type CreateSubaccountInput = v.InferInput<typeof CreateSubaccountInputSchema>;\n\nexport const SubaccountIdInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n});\n\nexport type SubaccountIdInput = v.InferInput<typeof SubaccountIdInputSchema>;\n\nexport const CreateSubaccountResultSchema = v.object({\n subaccountId: PublicIdSchema,\n totalCreated: v.number(),\n smartAccountSaltNonce: v.number(),\n revision: BigIntStringSchema,\n});\n\nexport type CreateSubaccountResult = v.InferOutput<typeof CreateSubaccountResultSchema>;\n\nexport const SubaccountMutationResultSchema = v.object({});\n\nexport type SubaccountMutationResult = v.InferOutput<typeof SubaccountMutationResultSchema>;\n\ntype SubaccountPatch = {\n label?: string;\n icon?: string;\n color?: string;\n status?: (typeof SUBACCOUNT_STATUS_VALUES)[number];\n};\n\nconst SUBACCOUNT_PATCH_FIELDS = defineProtoPatchFields<SubaccountPatch>()({\n label: { path: \"label\", encode: (label) => ({ label }) },\n icon: { path: \"icon\", encode: (icon) => ({ icon }) },\n color: { path: \"color\", encode: (color) => ({ color }) },\n status: {\n path: \"status\",\n encode: (status) => ({ status: SubaccountStatusCodec.inputToProto[status] }),\n },\n});\n\nexport const UpdateSubaccountInputSchema = v.pipe(\n v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n label: v.optional(v.string()),\n icon: v.optional(v.string()),\n color: v.optional(v.string()),\n status: v.optional(v.picklist(SUBACCOUNT_STATUS_VALUES)),\n }),\n v.check(\n ({ label, icon, color, status }) =>\n label !== undefined ||\n icon !== undefined ||\n color !== undefined ||\n status !== undefined,\n \"At least one subaccount field must be provided\",\n ),\n v.transform(({ subaccountId, expectedRevision, ...input }) => {\n const { patch: subaccount, updateMask } = buildProtoPatch(input, SUBACCOUNT_PATCH_FIELDS);\n return {\n subaccountId,\n subaccount,\n updateMask,\n expectedRevision,\n };\n }),\n);\n\nexport type UpdateSubaccountInput = v.InferInput<typeof UpdateSubaccountInputSchema>;\n\nexport const InviteSubaccountMemberInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n granteeAccountId: idInputSchema(\"granteeAccountId\"),\n role: v.pipe(\n SubaccountRoleSchema,\n v.transform((role) => SubaccountRoleCodec.inputToProto[role]),\n ),\n});\n\nexport type InviteSubaccountMemberInput = v.InferInput<typeof InviteSubaccountMemberInputSchema>;\n\nexport const RemoveSubaccountMemberInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n granteeAccountId: idInputSchema(\"granteeAccountId\"),\n});\n\nexport type RemoveSubaccountMemberInput = v.InferInput<typeof RemoveSubaccountMemberInputSchema>;\n\nexport const UpdateSubaccountMemberRoleInputSchema = InviteSubaccountMemberInputSchema;\n\nexport type UpdateSubaccountMemberRoleInput = v.InferInput<\n typeof UpdateSubaccountMemberRoleInputSchema\n>;\n\nexport const SetSubaccountMemberMfaRequirementInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n requireMemberMfa: v.boolean(),\n});\n\nexport type SetSubaccountMemberMfaRequirementInput = v.InferInput<\n typeof SetSubaccountMemberMfaRequirementInputSchema\n>;\n\nexport const ListSubaccountInvitesInputSchema = v.strictObject({\n direction: v.pipe(\n v.optional(v.picklist(SUBACCOUNT_INVITE_DIRECTION_VALUES), \"\"),\n v.transform((direction) => SubaccountInviteDirectionCodec.inputToProto[direction]),\n ),\n});\n\nexport type ListSubaccountInvitesInput = v.InferInput<typeof ListSubaccountInvitesInputSchema>;\n\nconst InviteActionSchema = v.picklist([\"accept\", \"decline\", \"cancel\"]);\n\nconst InviteStatusSchema = v.picklist([\"pending\", \"accepted\", \"declined\", \"cancelled\"]);\n\nexport type SubaccountInviteStatus = v.InferOutput<typeof InviteStatusSchema>;\n\nconst ProtoInviteStatusSchema = v.number();\n\nexport const RespondSubaccountInviteInputSchema = v.strictObject({\n inviteId: idInputSchema(\"inviteId\"),\n action: v.pipe(\n InviteActionSchema,\n v.transform((v) => InviteActionCodec.inputToProto[v]),\n ),\n});\n\nexport type RespondSubaccountInviteInput = v.InferInput<typeof RespondSubaccountInviteInputSchema>;\n\nconst ProtoSubaccountStatusSchema = enumLabelSchema(SubaccountStatusCodec.protoToOutput);\n\nexport type SubaccountStatus = v.InferOutput<typeof ProtoSubaccountStatusSchema>;\n\nexport const SubaccountSchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n label: v.optional(v.string(), \"\"),\n icon: v.optional(v.string(), \"\"),\n color: v.optional(v.string(), \"\"),\n status: ProtoSubaccountStatusSchema,\n smartAccountAddress: v.string(),\n smartAccountSaltNonce: v.optional(v.number()),\n ownerUsername: v.optional(v.string(), \"\"),\n ownerAvatarUrl: v.optional(v.string(), \"\"),\n ownerRootSmartAccountAddress: v.string(),\n subaccountPolicyId: PublicIdSchema,\n requireMemberMfa: v.optional(v.boolean(), false),\n updatedAt: v.optional(TimestampSchema),\n revision: BigIntStringSchema,\n }),\n v.transform(({ updatedAt, ...subaccount }) => ({\n ...subaccount,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n })),\n);\n\nexport type Subaccount = v.InferOutput<typeof SubaccountSchema>;\n\nexport const SubaccountMemberSchema = v.object({\n accountId: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n username: v.optional(v.string(), \"\"),\n smartAccountAddress: v.string(),\n avatarUrl: v.optional(v.string(), \"\"),\n mfaEnrolled: v.optional(v.boolean(), false),\n});\n\nexport type SubaccountMember = v.InferOutput<typeof SubaccountMemberSchema>;\n\nexport const SubaccountInviteSchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n subaccountId: PublicIdSchema,\n granteeAccountId: PublicIdSchema,\n inviterAccountId: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n status: v.pipe(\n ProtoInviteStatusSchema,\n v.transform((v) => enumLabel(InviteStatusCodec.protoToOutput, v)),\n ),\n createdAt: OptionalTimestampMsSchema,\n respondedAt: OptionalTimestampMsSchema,\n granteeUsername: v.optional(v.string(), \"\"),\n inviterUsername: v.optional(v.string(), \"\"),\n subaccountLabel: v.optional(v.string(), \"\"),\n inviterRootSmartAccountAddress: v.string(),\n granteeRootSmartAccountAddress: v.string(),\n requireMemberMfa: v.boolean(),\n }),\n v.transform(\n ({\n subaccountLabel,\n subaccountId,\n inviterRootSmartAccountAddress,\n granteeRootSmartAccountAddress,\n ...rest\n }) => ({\n ...rest,\n subaccountId,\n subaccountLabel,\n inviterSmartAccountAddress: inviterRootSmartAccountAddress,\n granteeSmartAccountAddress: granteeRootSmartAccountAddress,\n }),\n ),\n);\n\nexport type SubaccountInvite = v.InferOutput<typeof SubaccountInviteSchema>;\n\nexport const SubaccountActivityInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(200)), 50),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n});\n\nexport type SubaccountActivityInput = v.InferInput<typeof SubaccountActivityInputSchema>;\n\nexport const SubaccountActivityEventSchema = v.object({\n createdAt: OptionalTimestampMsSchema,\n entityKind: enumLabelSchema(ActivityEntityKindCodec.protoToOutput),\n eventAction: enumLabelSchema(ActivityEventActionCodec.protoToOutput),\n source: enumLabelSchema(ActivityEventSourceCodec.protoToOutput),\n ip: v.optional(v.string()),\n userAgent: v.optional(v.string()),\n actorAccountId: PublicIdSchema,\n payloadJson: v.pipe(\n v.string(),\n v.transform((v) => JSON.parse(v)),\n ),\n});\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A,4BAA4B;CAC5B,4BAA4B;AAChC,EACJ,CACJ;AAIA,MAAa,gCAAgC,EAAE,aAAa;CACxD,cAAc,cAAc,cAAc;CAC1C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,CAAC,GAAG,EAAE;CACrF,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;AAC1D,CAAC;AAID,MAAa,gCAAgC,EAAE,OAAO;CAClD,WAAW;CACX,YAAY,gBAAgB,wBAAwB,aAAa;CACjE,aAAa,gBAAgB,yBAAyB,aAAa;CACnE,QAAQ,gBAAgB,yBAAyB,aAAa;CAC9D,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC;CACzB,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC;CAChC,gBAAgB;CAChB,aAAa,EAAE,KACX,EAAE,OAAO,GACT,EAAE,WAAW,MAAM,KAAK,MAAM,CAAC,CAAC,CACpC;AACJ,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CreateSubaccountInput, CreateSubaccountResult, EffectiveSubaccountPermissions, InviteSubaccountMemberInput, ListSubaccountInvitesInput, RemoveSubaccountMemberInput, RespondSubaccountInviteInput, SetSubaccountMemberMfaRequirementInput, Subaccount, SubaccountActivityInput, SubaccountEvent, SubaccountIdInput, SubaccountInvite, SubaccountInviteStatus, SubaccountMember, SubaccountPermission, SubaccountPermissionDefinition, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleDefinition, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountMemberRoleInput } from "./subaccounts.schemas.js";
|
|
2
|
-
export type { CreateSubaccountInput, CreateSubaccountResult, CreateSubaccountResult as CreateSubaccountServiceResult, EffectiveSubaccountPermissions, InviteSubaccountMemberInput, ListSubaccountInvitesInput, RemoveSubaccountMemberInput, RespondSubaccountInviteInput, SetSubaccountMemberMfaRequirementInput, Subaccount, SubaccountActivityInput, SubaccountEvent, SubaccountIdInput, SubaccountInvite, SubaccountInviteStatus, SubaccountMember, SubaccountPermission, SubaccountPermissionDefinition, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleDefinition, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountMemberRoleInput };
|
|
1
|
+
import { CreateSubaccountChallengeInput, CreateSubaccountInput, CreateSubaccountResult, EffectiveSubaccountPermissions, InviteSubaccountMemberInput, ListSubaccountInvitesInput, RemoveSubaccountMemberInput, RespondSubaccountInviteInput, SetSubaccountMemberMfaRequirementInput, Subaccount, SubaccountActivityInput, SubaccountChallenge, SubaccountEvent, SubaccountIdInput, SubaccountInvite, SubaccountInviteStatus, SubaccountMember, SubaccountPermission, SubaccountPermissionDefinition, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleDefinition, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountMemberRoleInput } from "./subaccounts.schemas.js";
|
|
2
|
+
export type { CreateSubaccountChallengeInput, CreateSubaccountInput, CreateSubaccountResult, CreateSubaccountResult as CreateSubaccountServiceResult, EffectiveSubaccountPermissions, InviteSubaccountMemberInput, ListSubaccountInvitesInput, RemoveSubaccountMemberInput, RespondSubaccountInviteInput, SetSubaccountMemberMfaRequirementInput, Subaccount, SubaccountActivityInput, SubaccountChallenge, SubaccountEvent, SubaccountIdInput, SubaccountInvite, SubaccountInviteStatus, SubaccountMember, SubaccountPermission, SubaccountPermissionDefinition, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleDefinition, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountMemberRoleInput };
|
|
@@ -845,7 +845,7 @@ type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInpu
|
|
|
845
845
|
declare const ListTriggersInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
846
846
|
readonly parentOrderId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
|
|
847
847
|
readonly symbolId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>;
|
|
848
|
-
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("
|
|
848
|
+
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
|
|
849
849
|
readonly triggerType: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["stop_loss", "take_profit", "trailing_stop", "twap", "ladder"], undefined>, undefined>, v.TransformAction<"stop_loss" | "take_profit" | "trailing_stop" | "twap" | "ladder" | undefined, TriggerType>]>;
|
|
850
850
|
readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 1000, undefined>]>, 50>;
|
|
851
851
|
readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
|