@polyester/sdk 0.19.2 → 0.19.3
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 +6 -0
- package/dist/realtime/client.d.ts.map +1 -1
- package/dist/realtime/client.js +11 -4
- package/dist/realtime/client.js.map +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +42 -42
- package/dist/services/orders/orders-input.schemas.d.ts +1 -1
- package/dist/services/orders/orders-output.schemas.d.ts +6 -6
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +5 -5
- package/dist/services/triggers/trigger-input.schemas.d.ts +1 -1
- package/dist/services/triggers/triggers-output.schemas.d.ts +15 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @polyester/sdk
|
|
2
2
|
|
|
3
|
+
## 0.19.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Stop automatic realtime connection and subscription token retries for non-retryable SDK errors while preserving the original errors in `onError`. Transient failures retain Centrifuge backoff, and explicit private subscriptions can restart after authentication or request inputs are corrected. ([#116](https://github.com/Fabric-Labs/polyester-sdk-typescript/pull/116))
|
|
8
|
+
|
|
3
9
|
## 0.19.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","names":[],"sources":["../../src/realtime/client.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":[],"sources":["../../src/realtime/client.ts"],"mappings":";;;;UA2EiB;EACb,cAAc;EACd;;UAGa;EACb;EACA;EACA;EACA,kBAAkB,SAAS,wBAAwB,QAAQ,eAAe;EAC1E"}
|
package/dist/realtime/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthenticationError, InternalServerError, errorFromHttpStatus } from "../shared/errors.js";
|
|
1
|
+
import { AuthenticationError, InternalServerError, PolyesterError, errorFromHttpStatus } from "../shared/errors.js";
|
|
2
2
|
import { makeFetch } from "../shared/transports.js";
|
|
3
3
|
import { createSdkSubscriptionErrorContext, fromCentrifugeSubscriptionError } from "../shared/subscription-errors.js";
|
|
4
4
|
import { decodeProtoFrame } from "../utils/streams.js";
|
|
@@ -52,7 +52,7 @@ var RealtimeClient = class {
|
|
|
52
52
|
#emitConnectionTokenError(error) {
|
|
53
53
|
for (const shared of this.#sharedSubs.values()) if (this.#channelKind(shared.channel) === "private") this.#emitSubscriptionError(shared, "connection_token", error);
|
|
54
54
|
}
|
|
55
|
-
#subscriptionOpts(shared, attachmentEpoch) {
|
|
55
|
+
#subscriptionOpts(Centrifuge, shared, attachmentEpoch) {
|
|
56
56
|
if (this.#channelKind(shared.channel) !== "private") return void 0;
|
|
57
57
|
return { getToken: async () => {
|
|
58
58
|
try {
|
|
@@ -69,6 +69,7 @@ var RealtimeClient = class {
|
|
|
69
69
|
return json.token;
|
|
70
70
|
} catch (error) {
|
|
71
71
|
if (shared.attachmentEpoch === attachmentEpoch) this.#emitSubscriptionError(shared, "subscription_token", error);
|
|
72
|
+
if (error instanceof PolyesterError && !error.retryable) throw new Centrifuge.UnauthorizedError(error.message);
|
|
72
73
|
throw error;
|
|
73
74
|
}
|
|
74
75
|
} };
|
|
@@ -108,6 +109,7 @@ var RealtimeClient = class {
|
|
|
108
109
|
return json.token;
|
|
109
110
|
} catch (error) {
|
|
110
111
|
if (this.#privateClient === client) this.#emitConnectionTokenError(error);
|
|
112
|
+
if (error instanceof PolyesterError && !error.retryable) throw new Centrifuge.UnauthorizedError(error.message);
|
|
111
113
|
throw error;
|
|
112
114
|
}
|
|
113
115
|
} });
|
|
@@ -170,7 +172,7 @@ var RealtimeClient = class {
|
|
|
170
172
|
}
|
|
171
173
|
#attachSubscriptionNow(Centrifuge, shared, attachmentEpoch) {
|
|
172
174
|
const client = this.#ensureClientForChannel(Centrifuge, shared.channel);
|
|
173
|
-
const sub = client.newSubscription(shared.channel, this.#subscriptionOpts(shared, attachmentEpoch));
|
|
175
|
+
const sub = client.newSubscription(shared.channel, this.#subscriptionOpts(Centrifuge, shared, attachmentEpoch));
|
|
174
176
|
shared.sub = sub;
|
|
175
177
|
shared.client = client;
|
|
176
178
|
sub.on("publication", (ctx) => {
|
|
@@ -303,7 +305,8 @@ var RealtimeClient = class {
|
|
|
303
305
|
/**
|
|
304
306
|
* Subscribes to a realtime channel and returns an unsubscribe function. Missing
|
|
305
307
|
* authentication is reported to `onError`, or thrown synchronously when no error
|
|
306
|
-
* observer is provided.
|
|
308
|
+
* observer is provided. Non-retryable token failures stop automatic retries;
|
|
309
|
+
* calling subscribe again after correcting the failure restarts private realtime.
|
|
307
310
|
*/
|
|
308
311
|
subscribe(channel, handlers) {
|
|
309
312
|
let shared;
|
|
@@ -336,6 +339,10 @@ var RealtimeClient = class {
|
|
|
336
339
|
if (onSubscribed) shared.subscribedHandlers.add(onSubscribed);
|
|
337
340
|
if (onUnsubscribed) shared.unsubscribedHandlers.add(onUnsubscribed);
|
|
338
341
|
if (onError) shared.errorHandlers.add(onError);
|
|
342
|
+
if (this.#channelKind(channel) === "private" && this.#hasAuth()) {
|
|
343
|
+
if (shared.client?.state === "disconnected") shared.client.connect();
|
|
344
|
+
if (shared.sub?.state === "unsubscribed") shared.sub.subscribe();
|
|
345
|
+
}
|
|
339
346
|
let closed = false;
|
|
340
347
|
if (onSubscribed && shared.sub?.state === "subscribed") {
|
|
341
348
|
const subscriptionEpoch = shared.subscriptionEpoch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["#config","#getAuthHeaders","#sharedSubs","#channelKind","#emitSubscriptionError","#publicClient","#connectionHandlers","#privateClient","#emitConnectionTokenError","#createPublicClient","#hasAuth","#createPrivateClient","#assertChannelAuth","#ensurePrivateClient","#ensurePublicClient","#attachSubscriptionNow","#attachSubscriptionWhenLoaded","#ensureClientForChannel","#subscriptionOpts","#pendingTeardowns","#attachSubscription","#callErrorHandler","#disconnectClientIfIdle","#hasChannelsForKind","#teardownSubscription","#getOrCreateSubscription","#callConsumerHandler","#disconnect","#disconnectPrivate"],"sources":["../../src/realtime/client.ts"],"sourcesContent":["import { fromBinary, type DescMessage, type MessageShape } from \"@bufbuild/protobuf\";\nimport type {\n Centrifuge,\n SubscriptionErrorContext,\n PublicationContext,\n Subscription,\n} from \"centrifuge/build/protobuf\";\nimport type * as CentrifugeModule from \"centrifuge/build/protobuf\";\nimport {\n createSdkSubscriptionErrorContext,\n fromCentrifugeSubscriptionError,\n type SdkSubscriptionErrorContext,\n} from \"../shared/subscription-errors.js\";\nimport { AuthenticationError, errorFromHttpStatus, InternalServerError } from \"../shared/errors.js\";\nimport { makeFetch } from \"../shared/transports.js\";\nimport { decodeProtoFrame } from \"../utils/streams.js\";\nimport type { ConnectChannelParams, PolyesterRealtime, SubscribeHandlers } from \"./types.js\";\n\nconst realtimeFetch = makeFetch();\n\ntype CentrifugeCtor = typeof CentrifugeModule.Centrifuge;\ntype CentrifugeModuleLoader = () => Promise<typeof CentrifugeModule>;\n\nconst defaultCentrifugeModuleLoader: CentrifugeModuleLoader = () =>\n import(\"centrifuge/build/protobuf\");\n\n// Centrifuge's protobuf build embeds the protobuf.js runtime (~300 KB minified).\n// Loading it lazily keeps it out of the eager module graph on both the server\n// (Cloudflare isolate cold start — SSR never opens a websocket) and the client\n// app shell; it is only fetched when the first subscription attaches.\nlet centrifugeCtorPromise: Promise<CentrifugeCtor> | null = null;\nlet loadedCentrifugeCtor: CentrifugeCtor | null = null;\nlet centrifugeModuleLoader = defaultCentrifugeModuleLoader;\nexport function __setRealtimeCentrifugeForTests(Centrifuge: CentrifugeCtor | null): void {\n loadedCentrifugeCtor = Centrifuge;\n centrifugeCtorPromise = Centrifuge ? Promise.resolve(Centrifuge) : null;\n}\n\n/** Replaces the lazy Centrifuge module loader for isolated transport-load tests. */\nexport function __setRealtimeCentrifugeLoaderForTests(loader: CentrifugeModuleLoader | null): void {\n centrifugeModuleLoader = loader ?? defaultCentrifugeModuleLoader;\n loadedCentrifugeCtor = null;\n centrifugeCtorPromise = null;\n}\n\nfunction loadCentrifuge(): Promise<CentrifugeCtor> {\n if (\n centrifugeModuleLoader === defaultCentrifugeModuleLoader &&\n (import.meta as { env?: { SSR?: boolean } }).env?.SSR\n ) {\n return Promise.reject(new Error(\"Realtime subscriptions are browser-only during SSR.\"));\n }\n\n if (!centrifugeCtorPromise) {\n const loadAttempt = Promise.resolve().then(centrifugeModuleLoader);\n const retryableLoad = loadAttempt.then(\n (mod) => {\n loadedCentrifugeCtor = mod.Centrifuge;\n return mod.Centrifuge;\n },\n (error) => {\n if (centrifugeCtorPromise === retryableLoad) centrifugeCtorPromise = null;\n throw error;\n },\n );\n centrifugeCtorPromise = retryableLoad;\n }\n return centrifugeCtorPromise;\n}\n\nexport interface RealtimeAuthRequest {\n url: string | URL;\n method: string;\n}\n\nexport interface RealtimeConfig {\n wsUrl: string;\n tokenEndpoint: string;\n subscribeEndpoint: string;\n getAuthHeaders?: (request: RealtimeAuthRequest) => Promise<HeadersInit> | HeadersInit;\n hasAuth?: () => boolean;\n}\n\ntype ResolvedRealtimeConfig = Pick<\n RealtimeConfig,\n \"wsUrl\" | \"tokenEndpoint\" | \"subscribeEndpoint\"\n> & {\n getAuthHeaders: (request: RealtimeAuthRequest) => Promise<HeadersInit> | HeadersInit;\n hasAuth: () => boolean;\n};\n\nexport type { ConnectChannelParams, PolyesterRealtime, SubscribeHandlers } from \"./types.js\";\n\ntype ConnectionHandler = { onConnected?: () => void; onDisconnected?: () => void };\ntype PublicationHandler<T = unknown> = (data: T) => void;\ntype ErrorHandler = (ctx: SdkSubscriptionErrorContext) => void;\ntype RealtimeClientKind = \"public\" | \"private\";\n\ninterface SharedSubscription {\n channel: string;\n sub: Subscription | null;\n client: Centrifuge | null;\n attachmentEpoch: number;\n consumers: number;\n subscriptionEpoch: number;\n publicationHandlers: Set<PublicationHandler>;\n subscribedHandlers: Set<(epoch: number) => void>;\n unsubscribedHandlers: Set<() => void>;\n errorHandlers: Set<ErrorHandler>;\n}\n\n/**\n * Shared Centrifuge realtime client that multiplexes public and private protobuf subscriptions across SDK services.\n */\nexport class RealtimeClient implements PolyesterRealtime {\n #publicClient: Centrifuge | null = null;\n #privateClient: Centrifuge | null = null;\n #connectionHandlers = new Set<ConnectionHandler>();\n #sharedSubs = new Map<string, SharedSubscription>();\n #pendingTeardowns = new Map<string, SharedSubscription>();\n readonly #config: ResolvedRealtimeConfig;\n\n constructor(config: RealtimeConfig) {\n this.#config = {\n wsUrl: config.wsUrl,\n tokenEndpoint: config.tokenEndpoint,\n subscribeEndpoint: config.subscribeEndpoint,\n getAuthHeaders: config.getAuthHeaders ?? (() => ({})),\n hasAuth: config.hasAuth ?? (() => false),\n };\n }\n\n async #getAuthHeaders(request: RealtimeAuthRequest): Promise<HeadersInit> {\n return this.#config.getAuthHeaders(request);\n }\n\n #emitSubscriptionError(shared: SharedSubscription, type: string, error: unknown): void {\n const ctx = createSdkSubscriptionErrorContext(shared.channel, type, error);\n for (const handler of shared.errorHandlers) {\n handler(ctx);\n }\n }\n\n #emitConnectionTokenError(error: unknown): void {\n for (const shared of this.#sharedSubs.values()) {\n if (this.#channelKind(shared.channel) === \"private\") {\n this.#emitSubscriptionError(shared, \"connection_token\", error);\n }\n }\n }\n\n #subscriptionOpts(shared: SharedSubscription, attachmentEpoch: number) {\n if (this.#channelKind(shared.channel) !== \"private\") return undefined;\n return {\n getToken: async () => {\n try {\n const url = new URL(this.#config.subscribeEndpoint);\n url.searchParams.set(\"channel\", shared.channel);\n const headers = await this.#getAuthHeaders({ url, method: \"GET\" });\n const res = await realtimeFetch(url, { headers });\n if (!res.ok) {\n throw errorFromHttpStatus(\n res.status,\n `Failed to fetch subscription token: ${res.status}`,\n );\n }\n const json = (await res.json()) as { token?: string };\n if (!json?.token) {\n throw new InternalServerError(\"Subscription token response had no token\");\n }\n return json.token;\n } catch (error) {\n if (shared.attachmentEpoch === attachmentEpoch) {\n this.#emitSubscriptionError(shared, \"subscription_token\", error);\n }\n throw error;\n }\n },\n };\n }\n\n #hasAuth(): boolean {\n return this.#config.hasAuth();\n }\n\n #channelKind(channel: string): RealtimeClientKind {\n return channel.startsWith(\"private:\") ? \"private\" : \"public\";\n }\n\n #createPublicClient(Centrifuge: CentrifugeCtor): Centrifuge {\n const client = new Centrifuge(this.#config.wsUrl);\n this.#publicClient = client;\n\n client.on(\"connected\", () => {\n if (this.#publicClient !== client) return;\n for (const h of this.#connectionHandlers) h.onConnected?.();\n });\n client.on(\"disconnected\", () => {\n if (this.#publicClient !== client) return;\n for (const h of this.#connectionHandlers) h.onDisconnected?.();\n });\n\n client.connect();\n return client;\n }\n\n #createPrivateClient(Centrifuge: CentrifugeCtor): Centrifuge {\n let client: Centrifuge;\n const opts = {\n getToken: async () => {\n try {\n const headers = await this.#getAuthHeaders({\n url: this.#config.tokenEndpoint,\n method: \"GET\",\n });\n const res = await realtimeFetch(this.#config.tokenEndpoint, {\n headers,\n });\n if (!res.ok) {\n throw errorFromHttpStatus(\n res.status,\n `Failed to fetch connection token: ${res.status}`,\n );\n }\n const json = (await res.json()) as { token?: string };\n if (!json?.token) {\n throw new InternalServerError(\"Connection token response had no token\");\n }\n return json.token;\n } catch (error) {\n if (this.#privateClient === client) {\n this.#emitConnectionTokenError(error);\n }\n throw error;\n }\n },\n };\n\n client = new Centrifuge(this.#config.wsUrl, opts);\n this.#privateClient = client;\n\n client.on(\"connected\", () => {\n if (this.#privateClient !== client) return;\n for (const h of this.#connectionHandlers) h.onConnected?.();\n });\n client.on(\"disconnected\", () => {\n if (this.#privateClient !== client) return;\n for (const h of this.#connectionHandlers) h.onDisconnected?.();\n });\n\n client.connect();\n return client;\n }\n\n #ensurePublicClient(Centrifuge: CentrifugeCtor): Centrifuge {\n return this.#publicClient ?? this.#createPublicClient(Centrifuge);\n }\n\n #ensurePrivateClient(Centrifuge: CentrifugeCtor): Centrifuge {\n if (!this.#hasAuth()) {\n throw new AuthenticationError(\n \"Cannot create authenticated realtime client without authentication\",\n );\n }\n return this.#privateClient ?? this.#createPrivateClient(Centrifuge);\n }\n\n #assertChannelAuth(channel: string): void {\n if (this.#channelKind(channel) === \"private\" && !this.#hasAuth()) {\n throw new AuthenticationError(\n `Cannot subscribe to private channel \"${channel}\" without authentication`,\n );\n }\n }\n\n #ensureClientForChannel(Centrifuge: CentrifugeCtor, channel: string): Centrifuge {\n this.#assertChannelAuth(channel);\n if (this.#channelKind(channel) === \"private\") {\n return this.#ensurePrivateClient(Centrifuge);\n }\n\n return this.#ensurePublicClient(Centrifuge);\n }\n\n #attachSubscription(shared: SharedSubscription): void {\n if (shared.sub) return;\n\n // Auth failures must surface synchronously to subscribe() callers, as\n // they did when centrifuge was imported statically.\n this.#assertChannelAuth(shared.channel);\n\n const attachmentEpoch = shared.attachmentEpoch + 1;\n shared.attachmentEpoch = attachmentEpoch;\n\n // Once the transport module is loaded, attachment stays fully\n // synchronous — only the very first attach pays the dynamic import.\n if (loadedCentrifugeCtor) {\n this.#attachSubscriptionNow(loadedCentrifugeCtor, shared, attachmentEpoch);\n return;\n }\n void this.#attachSubscriptionWhenLoaded(shared, attachmentEpoch);\n }\n\n async #attachSubscriptionWhenLoaded(\n shared: SharedSubscription,\n attachmentEpoch: number,\n ): Promise<void> {\n let Centrifuge: CentrifugeCtor;\n try {\n Centrifuge = await loadCentrifuge();\n } catch (error) {\n if (shared.attachmentEpoch !== attachmentEpoch) return;\n if (this.#sharedSubs.get(shared.channel) === shared) {\n this.#sharedSubs.delete(shared.channel);\n }\n this.#emitSubscriptionError(shared, \"transport_load\", error);\n return;\n }\n\n // The subscription may have been torn down or re-attached while the\n // transport module was loading.\n if (shared.attachmentEpoch !== attachmentEpoch || shared.sub) return;\n if (this.#sharedSubs.get(shared.channel) !== shared) return;\n\n try {\n this.#attachSubscriptionNow(Centrifuge, shared, attachmentEpoch);\n } catch (error) {\n this.#sharedSubs.delete(shared.channel);\n this.#emitSubscriptionError(shared, \"auth\", error);\n }\n }\n\n #attachSubscriptionNow(\n Centrifuge: CentrifugeCtor,\n shared: SharedSubscription,\n attachmentEpoch: number,\n ): void {\n const client = this.#ensureClientForChannel(Centrifuge, shared.channel);\n\n const sub = client.newSubscription(\n shared.channel,\n this.#subscriptionOpts(shared, attachmentEpoch),\n );\n shared.sub = sub;\n shared.client = client;\n\n sub.on(\"publication\", (ctx: PublicationContext) => {\n if (shared.sub !== sub || shared.attachmentEpoch !== attachmentEpoch) return;\n for (const handler of shared.publicationHandlers) handler(ctx.data);\n });\n sub.on(\"subscribed\", () => {\n if (shared.sub !== sub || shared.attachmentEpoch !== attachmentEpoch) return;\n const subscriptionEpoch = ++shared.subscriptionEpoch;\n for (const handler of shared.subscribedHandlers) handler(subscriptionEpoch);\n });\n sub.on(\"unsubscribed\", () => {\n if (shared.sub !== sub || shared.attachmentEpoch !== attachmentEpoch) return;\n for (const handler of shared.unsubscribedHandlers) handler();\n });\n sub.on(\"error\", (ctx: SubscriptionErrorContext) => {\n if (shared.sub !== sub || shared.attachmentEpoch !== attachmentEpoch) return;\n const sdkCtx = fromCentrifugeSubscriptionError(ctx);\n for (const handler of shared.errorHandlers) handler(sdkCtx);\n });\n\n sub.subscribe();\n }\n\n #getOrCreateSubscription(channel: string): SharedSubscription {\n const existing = this.#sharedSubs.get(channel);\n if (existing) return existing;\n\n const pending = this.#pendingTeardowns.get(channel);\n if (pending) {\n this.#pendingTeardowns.delete(channel);\n this.#sharedSubs.set(channel, pending);\n if (!pending.sub) {\n this.#attachSubscription(pending);\n } else if (pending.sub.state !== \"subscribed\") {\n pending.sub.subscribe();\n }\n return pending;\n }\n\n const shared: SharedSubscription = {\n channel,\n sub: null,\n client: null,\n attachmentEpoch: 0,\n consumers: 0,\n subscriptionEpoch: 0,\n publicationHandlers: new Set(),\n subscribedHandlers: new Set(),\n unsubscribedHandlers: new Set(),\n errorHandlers: new Set(),\n };\n\n this.#sharedSubs.set(channel, shared);\n try {\n this.#attachSubscription(shared);\n } catch (error) {\n this.#sharedSubs.delete(channel);\n throw error;\n }\n return shared;\n }\n\n #callErrorHandler(handler: ErrorHandler | undefined, ctx: SdkSubscriptionErrorContext): void {\n if (!handler) return;\n\n try {\n handler(ctx);\n } catch {\n // Keep error reporting isolated from other subscription consumers.\n }\n }\n\n #callConsumerHandler(\n channel: string,\n type: string,\n handler: () => void,\n onError?: ErrorHandler,\n ): void {\n try {\n handler();\n } catch (error) {\n this.#callErrorHandler(\n onError,\n createSdkSubscriptionErrorContext(channel, type, error),\n );\n }\n }\n\n #teardownSubscription(shared: SharedSubscription): void {\n const sub = shared.sub;\n const client = shared.client;\n const kind = this.#channelKind(shared.channel);\n shared.sub = null;\n shared.client = null;\n shared.attachmentEpoch++;\n if (!sub) return;\n\n try {\n if (sub.state !== \"unsubscribed\") {\n sub.unsubscribe();\n }\n } catch {\n // noop\n }\n try {\n client?.removeSubscription?.(sub);\n } catch {\n // noop\n }\n this.#disconnectClientIfIdle(kind);\n }\n\n #hasChannelsForKind(kind: RealtimeClientKind): boolean {\n for (const shared of this.#sharedSubs.values()) {\n if (this.#channelKind(shared.channel) === kind) return true;\n }\n for (const shared of this.#pendingTeardowns.values()) {\n if (this.#channelKind(shared.channel) === kind) return true;\n }\n return false;\n }\n\n #disconnectClientIfIdle(kind: RealtimeClientKind): void {\n if (this.#hasChannelsForKind(kind)) return;\n\n const client = kind === \"private\" ? this.#privateClient : this.#publicClient;\n if (kind === \"private\") {\n this.#privateClient = null;\n } else {\n this.#publicClient = null;\n }\n\n try {\n client?.disconnect();\n } catch {\n // noop\n }\n }\n\n #disconnect(): void {\n const publicClient = this.#publicClient;\n const privateClient = this.#privateClient;\n\n this.#pendingTeardowns.clear();\n this.#sharedSubs.clear();\n this.#publicClient = null;\n this.#privateClient = null;\n\n try {\n publicClient?.disconnect();\n } catch {\n // noop\n }\n try {\n privateClient?.disconnect();\n } catch {\n // noop\n }\n this.#connectionHandlers.clear();\n }\n\n #disconnectPrivate(): void {\n const privateClient = this.#privateClient;\n this.#privateClient = null;\n\n for (const [channel, shared] of this.#sharedSubs) {\n if (this.#channelKind(channel) !== \"private\") continue;\n this.#sharedSubs.delete(channel);\n this.#teardownSubscription(shared);\n }\n for (const [channel, shared] of this.#pendingTeardowns) {\n if (this.#channelKind(channel) !== \"private\") continue;\n this.#pendingTeardowns.delete(channel);\n this.#teardownSubscription(shared);\n }\n\n try {\n privateClient?.disconnect();\n } catch {\n // noop\n }\n }\n\n /**\n * Subscribes to a realtime channel and returns an unsubscribe function. Missing\n * authentication is reported to `onError`, or thrown synchronously when no error\n * observer is provided.\n */\n subscribe<T>(channel: string, handlers: SubscribeHandlers<T>): () => void {\n let shared: SharedSubscription;\n try {\n shared = this.#getOrCreateSubscription(channel);\n } catch (error) {\n if (!(error instanceof AuthenticationError)) throw error;\n if (!handlers.onError) throw error;\n\n const ctx = createSdkSubscriptionErrorContext(channel, \"auth\", error);\n queueMicrotask(() => this.#callErrorHandler(handlers.onError, ctx));\n return () => {};\n }\n shared.consumers++;\n\n const publicationHandler = handlers.onPublication;\n const errorHandler = handlers.onError;\n const subscribedHandler = handlers.onSubscribed;\n const unsubscribedHandler = handlers.onUnsubscribed;\n\n const onError: ErrorHandler | undefined = errorHandler\n ? (ctx) => this.#callErrorHandler(errorHandler, ctx)\n : undefined;\n const onPub: PublicationHandler = (data) => {\n this.#callConsumerHandler(\n channel,\n \"publication_handler\",\n () => publicationHandler(data as T),\n onError,\n );\n };\n let lastSubscribedEpoch = -1;\n const onSubscribed = subscribedHandler\n ? (subscriptionEpoch: number) => {\n if (subscriptionEpoch <= lastSubscribedEpoch) return;\n lastSubscribedEpoch = subscriptionEpoch;\n this.#callConsumerHandler(\n channel,\n \"subscribed_handler\",\n subscribedHandler,\n onError,\n );\n }\n : undefined;\n const onUnsubscribed = unsubscribedHandler\n ? () =>\n this.#callConsumerHandler(\n channel,\n \"unsubscribed_handler\",\n unsubscribedHandler,\n onError,\n )\n : undefined;\n\n shared.publicationHandlers.add(onPub);\n\n if (onSubscribed) shared.subscribedHandlers.add(onSubscribed);\n if (onUnsubscribed) shared.unsubscribedHandlers.add(onUnsubscribed);\n if (onError) shared.errorHandlers.add(onError);\n\n let closed = false;\n if (onSubscribed && shared.sub?.state === \"subscribed\") {\n const subscriptionEpoch = shared.subscriptionEpoch;\n queueMicrotask(() => {\n if (closed || shared.sub?.state !== \"subscribed\") return;\n onSubscribed(subscriptionEpoch);\n });\n }\n\n return () => {\n if (closed) return;\n closed = true;\n\n shared.publicationHandlers.delete(onPub);\n if (onSubscribed) shared.subscribedHandlers.delete(onSubscribed);\n if (onUnsubscribed) shared.unsubscribedHandlers.delete(onUnsubscribed);\n if (onError) shared.errorHandlers.delete(onError);\n\n shared.consumers--;\n if (shared.consumers <= 0) {\n const currentShared = this.#sharedSubs.get(channel);\n if (currentShared !== shared) return;\n\n this.#sharedSubs.delete(channel);\n this.#pendingTeardowns.set(channel, shared);\n\n queueMicrotask(() => {\n if (this.#pendingTeardowns.get(channel) !== shared) return;\n this.#pendingTeardowns.delete(channel);\n\n this.#teardownSubscription(shared);\n\n if (this.#sharedSubs.size === 0 && this.#pendingTeardowns.size === 0) {\n this.#disconnect();\n }\n });\n }\n };\n }\n\n /**\n * Connects to a realtime channel with a custom message decoder.\n */\n connectChannel<T extends DescMessage>(params: ConnectChannelParams<T>): () => void {\n return this.subscribe<Uint8Array>(params.channel, {\n onPublication: (data) => {\n let decoded: MessageShape<T>;\n try {\n decoded = fromBinary(params.schema, data);\n } catch (error) {\n this.#callErrorHandler(\n params.onError,\n createSdkSubscriptionErrorContext(params.channel, \"decode\", error),\n );\n return;\n }\n params.onPublication(decoded);\n },\n onSubscribed: params.onConnected,\n onUnsubscribed: params.onDisconnected,\n onError: params.onError,\n });\n }\n\n /**\n * Connects to a realtime channel that emits protobuf messages.\n */\n connectProtoChannel<T extends DescMessage>(params: ConnectChannelParams<T>): () => void {\n return this.subscribe<Uint8Array | MessageShape<T>>(params.channel, {\n onPublication: (data) => {\n let msg: MessageShape<T> | null;\n try {\n msg = decodeProtoFrame(params.schema, data);\n } catch (error) {\n this.#callErrorHandler(\n params.onError,\n createSdkSubscriptionErrorContext(params.channel, \"decode\", error),\n );\n return;\n }\n if (!msg) {\n this.#callErrorHandler(\n params.onError,\n createSdkSubscriptionErrorContext(\n params.channel,\n \"decode\",\n \"Unable to decode protobuf frame\",\n ),\n );\n return;\n }\n params.onPublication(msg);\n },\n onSubscribed: params.onConnected,\n onUnsubscribed: params.onDisconnected,\n onError: params.onError,\n });\n }\n\n /**\n * Disconnects the realtime client from all active channels.\n */\n disconnect(): void {\n this.#disconnect();\n }\n\n /**\n * Disconnects authenticated realtime state without touching public channels.\n */\n disconnectPrivate(): void {\n this.#disconnectPrivate();\n }\n\n get isConnected(): boolean {\n return this.#publicClient !== null || this.#privateClient !== null;\n }\n\n get activeChannels(): number {\n return this.#sharedSubs.size;\n }\n\n get totalConsumers(): number {\n let total = 0;\n for (const shared of this.#sharedSubs.values()) {\n total += shared.consumers;\n }\n return total;\n }\n}\n"],"mappings":";;;;;;AAkBA,MAAM,gBAAgB,UAAU;AAKhC,MAAM,sCACF,OAAO;AAMX,IAAI,wBAAwD;AAC5D,IAAI,uBAA8C;AAClD,IAAI,yBAAyB;AAa7B,SAAS,iBAA0C;CAC/C,IACI,2BAA2B,iCAC1B,YAA4C,KAAK,KAElD,OAAO,QAAQ,uBAAO,IAAI,MAAM,qDAAqD,CAAC;CAG1F,IAAI,CAAC,uBAAuB;EAExB,MAAM,gBADc,QAAQ,QAAQ,CAAC,CAAC,KAAK,sBACX,CAAC,CAAC,MAC7B,QAAQ;GACL,uBAAuB,IAAI;GAC3B,OAAO,IAAI;EACf,IACC,UAAU;GACP,IAAI,0BAA0B,eAAe,wBAAwB;GACrE,MAAM;EACV,CACJ;EACA,wBAAwB;CAC5B;CACA,OAAO;AACX;;;;AA8CA,IAAa,iBAAb,MAAyD;CACrD,gBAAmC;CACnC,iBAAoC;CACpC,sCAAsB,IAAI,IAAuB;CACjD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ACJ;KACA;IACJ;IACA,OAAO,cAAc,GAAG;GAC5B;GACA,cAAc,OAAO;GACrB,gBAAgB,OAAO;GACvB,SAAS,OAAO;EACpB,CAAC;CACL;;;;CAKA,aAAmB;EACf,KAAKM,YAAY;CACrB;;;;CAKA,oBAA0B;EACtB,KAAKC,mBAAmB;CAC5B;CAEA,IAAI,cAAuB;EACvB,OAAO,KAAKvB,kBAAkB,QAAQ,KAAKE,mBAAmB;CAClE;CAEA,IAAI,iBAAyB;EACzB,OAAO,KAAKL,YAAY;CAC5B;CAEA,IAAI,iBAAyB;EACzB,IAAI,QAAQ;EACZ,KAAK,MAAM,UAAU,KAAKA,YAAY,OAAO,GACzC,SAAS,OAAO;EAEpB,OAAO;CACX;AACJ"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["#config","#getAuthHeaders","#sharedSubs","#channelKind","#emitSubscriptionError","#publicClient","#connectionHandlers","#privateClient","#emitConnectionTokenError","#createPublicClient","#hasAuth","#createPrivateClient","#assertChannelAuth","#ensurePrivateClient","#ensurePublicClient","#attachSubscriptionNow","#attachSubscriptionWhenLoaded","#ensureClientForChannel","#subscriptionOpts","#pendingTeardowns","#attachSubscription","#callErrorHandler","#disconnectClientIfIdle","#hasChannelsForKind","#teardownSubscription","#getOrCreateSubscription","#callConsumerHandler","#disconnect","#disconnectPrivate"],"sources":["../../src/realtime/client.ts"],"sourcesContent":["import { fromBinary, type DescMessage, type MessageShape } from \"@bufbuild/protobuf\";\nimport type {\n Centrifuge,\n SubscriptionErrorContext,\n PublicationContext,\n Subscription,\n} from \"centrifuge/build/protobuf\";\nimport type * as CentrifugeModule from \"centrifuge/build/protobuf\";\nimport {\n createSdkSubscriptionErrorContext,\n fromCentrifugeSubscriptionError,\n type SdkSubscriptionErrorContext,\n} from \"../shared/subscription-errors.js\";\nimport {\n AuthenticationError,\n errorFromHttpStatus,\n InternalServerError,\n PolyesterError,\n} from \"../shared/errors.js\";\nimport { makeFetch } from \"../shared/transports.js\";\nimport { decodeProtoFrame } from \"../utils/streams.js\";\nimport type { ConnectChannelParams, PolyesterRealtime, SubscribeHandlers } from \"./types.js\";\n\nconst realtimeFetch = makeFetch();\n\ntype CentrifugeCtor = typeof CentrifugeModule.Centrifuge;\ntype CentrifugeModuleLoader = () => Promise<typeof CentrifugeModule>;\n\nconst defaultCentrifugeModuleLoader: CentrifugeModuleLoader = () =>\n import(\"centrifuge/build/protobuf\");\n\n// Centrifuge's protobuf build embeds the protobuf.js runtime (~300 KB minified).\n// Loading it lazily keeps it out of the eager module graph on both the server\n// (Cloudflare isolate cold start — SSR never opens a websocket) and the client\n// app shell; it is only fetched when the first subscription attaches.\nlet centrifugeCtorPromise: Promise<CentrifugeCtor> | null = null;\nlet loadedCentrifugeCtor: CentrifugeCtor | null = null;\nlet centrifugeModuleLoader = defaultCentrifugeModuleLoader;\nexport function __setRealtimeCentrifugeForTests(Centrifuge: CentrifugeCtor | null): void {\n loadedCentrifugeCtor = Centrifuge;\n centrifugeCtorPromise = Centrifuge ? Promise.resolve(Centrifuge) : null;\n}\n\n/** Replaces the lazy Centrifuge module loader for isolated transport-load tests. */\nexport function __setRealtimeCentrifugeLoaderForTests(loader: CentrifugeModuleLoader | null): void {\n centrifugeModuleLoader = loader ?? defaultCentrifugeModuleLoader;\n loadedCentrifugeCtor = null;\n centrifugeCtorPromise = null;\n}\n\nfunction loadCentrifuge(): Promise<CentrifugeCtor> {\n if (\n centrifugeModuleLoader === defaultCentrifugeModuleLoader &&\n (import.meta as { env?: { SSR?: boolean } }).env?.SSR\n ) {\n return Promise.reject(new Error(\"Realtime subscriptions are browser-only during SSR.\"));\n }\n\n if (!centrifugeCtorPromise) {\n const loadAttempt = Promise.resolve().then(centrifugeModuleLoader);\n const retryableLoad = loadAttempt.then(\n (mod) => {\n loadedCentrifugeCtor = mod.Centrifuge;\n return mod.Centrifuge;\n },\n (error) => {\n if (centrifugeCtorPromise === retryableLoad) centrifugeCtorPromise = null;\n throw error;\n },\n );\n centrifugeCtorPromise = retryableLoad;\n }\n return centrifugeCtorPromise;\n}\n\nexport interface RealtimeAuthRequest {\n url: string | URL;\n method: string;\n}\n\nexport interface RealtimeConfig {\n wsUrl: string;\n tokenEndpoint: string;\n subscribeEndpoint: string;\n getAuthHeaders?: (request: RealtimeAuthRequest) => Promise<HeadersInit> | HeadersInit;\n hasAuth?: () => boolean;\n}\n\ntype ResolvedRealtimeConfig = Pick<\n RealtimeConfig,\n \"wsUrl\" | \"tokenEndpoint\" | \"subscribeEndpoint\"\n> & {\n getAuthHeaders: (request: RealtimeAuthRequest) => Promise<HeadersInit> | HeadersInit;\n hasAuth: () => boolean;\n};\n\nexport type { ConnectChannelParams, PolyesterRealtime, SubscribeHandlers } from \"./types.js\";\n\ntype ConnectionHandler = { onConnected?: () => void; onDisconnected?: () => void };\ntype PublicationHandler<T = unknown> = (data: T) => void;\ntype ErrorHandler = (ctx: SdkSubscriptionErrorContext) => void;\ntype RealtimeClientKind = \"public\" | \"private\";\n\ninterface SharedSubscription {\n channel: string;\n sub: Subscription | null;\n client: Centrifuge | null;\n attachmentEpoch: number;\n consumers: number;\n subscriptionEpoch: number;\n publicationHandlers: Set<PublicationHandler>;\n subscribedHandlers: Set<(epoch: number) => void>;\n unsubscribedHandlers: Set<() => void>;\n errorHandlers: Set<ErrorHandler>;\n}\n\n/**\n * Shared Centrifuge realtime client that multiplexes public and private protobuf subscriptions across SDK services.\n */\nexport class RealtimeClient implements PolyesterRealtime {\n #publicClient: Centrifuge | null = null;\n #privateClient: Centrifuge | null = null;\n #connectionHandlers = new Set<ConnectionHandler>();\n #sharedSubs = new Map<string, SharedSubscription>();\n #pendingTeardowns = new Map<string, SharedSubscription>();\n readonly #config: ResolvedRealtimeConfig;\n\n constructor(config: RealtimeConfig) {\n this.#config = {\n wsUrl: config.wsUrl,\n tokenEndpoint: config.tokenEndpoint,\n subscribeEndpoint: config.subscribeEndpoint,\n getAuthHeaders: config.getAuthHeaders ?? (() => ({})),\n hasAuth: config.hasAuth ?? (() => false),\n };\n }\n\n async #getAuthHeaders(request: RealtimeAuthRequest): Promise<HeadersInit> {\n return this.#config.getAuthHeaders(request);\n }\n\n #emitSubscriptionError(shared: SharedSubscription, type: string, error: unknown): void {\n const ctx = createSdkSubscriptionErrorContext(shared.channel, type, error);\n for (const handler of shared.errorHandlers) {\n handler(ctx);\n }\n }\n\n #emitConnectionTokenError(error: unknown): void {\n for (const shared of this.#sharedSubs.values()) {\n if (this.#channelKind(shared.channel) === \"private\") {\n this.#emitSubscriptionError(shared, \"connection_token\", error);\n }\n }\n }\n\n #subscriptionOpts(\n Centrifuge: CentrifugeCtor,\n shared: SharedSubscription,\n attachmentEpoch: number,\n ) {\n if (this.#channelKind(shared.channel) !== \"private\") return undefined;\n return {\n getToken: async () => {\n try {\n const url = new URL(this.#config.subscribeEndpoint);\n url.searchParams.set(\"channel\", shared.channel);\n const headers = await this.#getAuthHeaders({ url, method: \"GET\" });\n const res = await realtimeFetch(url, { headers });\n if (!res.ok) {\n throw errorFromHttpStatus(\n res.status,\n `Failed to fetch subscription token: ${res.status}`,\n );\n }\n const json = (await res.json()) as { token?: string };\n if (!json?.token) {\n throw new InternalServerError(\"Subscription token response had no token\");\n }\n return json.token;\n } catch (error) {\n if (shared.attachmentEpoch === attachmentEpoch) {\n this.#emitSubscriptionError(shared, \"subscription_token\", error);\n }\n if (error instanceof PolyesterError && !error.retryable) {\n throw new Centrifuge.UnauthorizedError(error.message);\n }\n throw error;\n }\n },\n };\n }\n\n #hasAuth(): boolean {\n return this.#config.hasAuth();\n }\n\n #channelKind(channel: string): RealtimeClientKind {\n return channel.startsWith(\"private:\") ? \"private\" : \"public\";\n }\n\n #createPublicClient(Centrifuge: CentrifugeCtor): Centrifuge {\n const client = new Centrifuge(this.#config.wsUrl);\n this.#publicClient = client;\n\n client.on(\"connected\", () => {\n if (this.#publicClient !== client) return;\n for (const h of this.#connectionHandlers) h.onConnected?.();\n });\n client.on(\"disconnected\", () => {\n if (this.#publicClient !== client) return;\n for (const h of this.#connectionHandlers) h.onDisconnected?.();\n });\n\n client.connect();\n return client;\n }\n\n #createPrivateClient(Centrifuge: CentrifugeCtor): Centrifuge {\n let client: Centrifuge;\n const opts = {\n getToken: async () => {\n try {\n const headers = await this.#getAuthHeaders({\n url: this.#config.tokenEndpoint,\n method: \"GET\",\n });\n const res = await realtimeFetch(this.#config.tokenEndpoint, {\n headers,\n });\n if (!res.ok) {\n throw errorFromHttpStatus(\n res.status,\n `Failed to fetch connection token: ${res.status}`,\n );\n }\n const json = (await res.json()) as { token?: string };\n if (!json?.token) {\n throw new InternalServerError(\"Connection token response had no token\");\n }\n return json.token;\n } catch (error) {\n if (this.#privateClient === client) {\n this.#emitConnectionTokenError(error);\n }\n if (error instanceof PolyesterError && !error.retryable) {\n throw new Centrifuge.UnauthorizedError(error.message);\n }\n throw error;\n }\n },\n };\n\n client = new Centrifuge(this.#config.wsUrl, opts);\n this.#privateClient = client;\n\n client.on(\"connected\", () => {\n if (this.#privateClient !== client) return;\n for (const h of this.#connectionHandlers) h.onConnected?.();\n });\n client.on(\"disconnected\", () => {\n if (this.#privateClient !== client) return;\n for (const h of this.#connectionHandlers) h.onDisconnected?.();\n });\n\n client.connect();\n return client;\n }\n\n #ensurePublicClient(Centrifuge: CentrifugeCtor): Centrifuge {\n return this.#publicClient ?? this.#createPublicClient(Centrifuge);\n }\n\n #ensurePrivateClient(Centrifuge: CentrifugeCtor): Centrifuge {\n if (!this.#hasAuth()) {\n throw new AuthenticationError(\n \"Cannot create authenticated realtime client without authentication\",\n );\n }\n return this.#privateClient ?? this.#createPrivateClient(Centrifuge);\n }\n\n #assertChannelAuth(channel: string): void {\n if (this.#channelKind(channel) === \"private\" && !this.#hasAuth()) {\n throw new AuthenticationError(\n `Cannot subscribe to private channel \"${channel}\" without authentication`,\n );\n }\n }\n\n #ensureClientForChannel(Centrifuge: CentrifugeCtor, channel: string): Centrifuge {\n this.#assertChannelAuth(channel);\n if (this.#channelKind(channel) === \"private\") {\n return this.#ensurePrivateClient(Centrifuge);\n }\n\n return this.#ensurePublicClient(Centrifuge);\n }\n\n #attachSubscription(shared: SharedSubscription): void {\n if (shared.sub) return;\n\n // Auth failures must surface synchronously to subscribe() callers, as\n // they did when centrifuge was imported statically.\n this.#assertChannelAuth(shared.channel);\n\n const attachmentEpoch = shared.attachmentEpoch + 1;\n shared.attachmentEpoch = attachmentEpoch;\n\n // Once the transport module is loaded, attachment stays fully\n // synchronous — only the very first attach pays the dynamic import.\n if (loadedCentrifugeCtor) {\n this.#attachSubscriptionNow(loadedCentrifugeCtor, shared, attachmentEpoch);\n return;\n }\n void this.#attachSubscriptionWhenLoaded(shared, attachmentEpoch);\n }\n\n async #attachSubscriptionWhenLoaded(\n shared: SharedSubscription,\n attachmentEpoch: number,\n ): Promise<void> {\n let Centrifuge: CentrifugeCtor;\n try {\n Centrifuge = await loadCentrifuge();\n } catch (error) {\n if (shared.attachmentEpoch !== attachmentEpoch) return;\n if (this.#sharedSubs.get(shared.channel) === shared) {\n this.#sharedSubs.delete(shared.channel);\n }\n this.#emitSubscriptionError(shared, \"transport_load\", error);\n return;\n }\n\n // The subscription may have been torn down or re-attached while the\n // transport module was loading.\n if (shared.attachmentEpoch !== attachmentEpoch || shared.sub) return;\n if (this.#sharedSubs.get(shared.channel) !== shared) return;\n\n try {\n this.#attachSubscriptionNow(Centrifuge, shared, attachmentEpoch);\n } catch (error) {\n this.#sharedSubs.delete(shared.channel);\n this.#emitSubscriptionError(shared, \"auth\", error);\n }\n }\n\n #attachSubscriptionNow(\n Centrifuge: CentrifugeCtor,\n shared: SharedSubscription,\n attachmentEpoch: number,\n ): void {\n const client = this.#ensureClientForChannel(Centrifuge, shared.channel);\n\n const sub = client.newSubscription(\n shared.channel,\n this.#subscriptionOpts(Centrifuge, shared, attachmentEpoch),\n );\n shared.sub = sub;\n shared.client = client;\n\n sub.on(\"publication\", (ctx: PublicationContext) => {\n if (shared.sub !== sub || shared.attachmentEpoch !== attachmentEpoch) return;\n for (const handler of shared.publicationHandlers) handler(ctx.data);\n });\n sub.on(\"subscribed\", () => {\n if (shared.sub !== sub || shared.attachmentEpoch !== attachmentEpoch) return;\n const subscriptionEpoch = ++shared.subscriptionEpoch;\n for (const handler of shared.subscribedHandlers) handler(subscriptionEpoch);\n });\n sub.on(\"unsubscribed\", () => {\n if (shared.sub !== sub || shared.attachmentEpoch !== attachmentEpoch) return;\n for (const handler of shared.unsubscribedHandlers) handler();\n });\n sub.on(\"error\", (ctx: SubscriptionErrorContext) => {\n if (shared.sub !== sub || shared.attachmentEpoch !== attachmentEpoch) return;\n const sdkCtx = fromCentrifugeSubscriptionError(ctx);\n for (const handler of shared.errorHandlers) handler(sdkCtx);\n });\n\n sub.subscribe();\n }\n\n #getOrCreateSubscription(channel: string): SharedSubscription {\n const existing = this.#sharedSubs.get(channel);\n if (existing) return existing;\n\n const pending = this.#pendingTeardowns.get(channel);\n if (pending) {\n this.#pendingTeardowns.delete(channel);\n this.#sharedSubs.set(channel, pending);\n if (!pending.sub) {\n this.#attachSubscription(pending);\n } else if (pending.sub.state !== \"subscribed\") {\n pending.sub.subscribe();\n }\n return pending;\n }\n\n const shared: SharedSubscription = {\n channel,\n sub: null,\n client: null,\n attachmentEpoch: 0,\n consumers: 0,\n subscriptionEpoch: 0,\n publicationHandlers: new Set(),\n subscribedHandlers: new Set(),\n unsubscribedHandlers: new Set(),\n errorHandlers: new Set(),\n };\n\n this.#sharedSubs.set(channel, shared);\n try {\n this.#attachSubscription(shared);\n } catch (error) {\n this.#sharedSubs.delete(channel);\n throw error;\n }\n return shared;\n }\n\n #callErrorHandler(handler: ErrorHandler | undefined, ctx: SdkSubscriptionErrorContext): void {\n if (!handler) return;\n\n try {\n handler(ctx);\n } catch {\n // Keep error reporting isolated from other subscription consumers.\n }\n }\n\n #callConsumerHandler(\n channel: string,\n type: string,\n handler: () => void,\n onError?: ErrorHandler,\n ): void {\n try {\n handler();\n } catch (error) {\n this.#callErrorHandler(\n onError,\n createSdkSubscriptionErrorContext(channel, type, error),\n );\n }\n }\n\n #teardownSubscription(shared: SharedSubscription): void {\n const sub = shared.sub;\n const client = shared.client;\n const kind = this.#channelKind(shared.channel);\n shared.sub = null;\n shared.client = null;\n shared.attachmentEpoch++;\n if (!sub) return;\n\n try {\n if (sub.state !== \"unsubscribed\") {\n sub.unsubscribe();\n }\n } catch {\n // noop\n }\n try {\n client?.removeSubscription?.(sub);\n } catch {\n // noop\n }\n this.#disconnectClientIfIdle(kind);\n }\n\n #hasChannelsForKind(kind: RealtimeClientKind): boolean {\n for (const shared of this.#sharedSubs.values()) {\n if (this.#channelKind(shared.channel) === kind) return true;\n }\n for (const shared of this.#pendingTeardowns.values()) {\n if (this.#channelKind(shared.channel) === kind) return true;\n }\n return false;\n }\n\n #disconnectClientIfIdle(kind: RealtimeClientKind): void {\n if (this.#hasChannelsForKind(kind)) return;\n\n const client = kind === \"private\" ? this.#privateClient : this.#publicClient;\n if (kind === \"private\") {\n this.#privateClient = null;\n } else {\n this.#publicClient = null;\n }\n\n try {\n client?.disconnect();\n } catch {\n // noop\n }\n }\n\n #disconnect(): void {\n const publicClient = this.#publicClient;\n const privateClient = this.#privateClient;\n\n this.#pendingTeardowns.clear();\n this.#sharedSubs.clear();\n this.#publicClient = null;\n this.#privateClient = null;\n\n try {\n publicClient?.disconnect();\n } catch {\n // noop\n }\n try {\n privateClient?.disconnect();\n } catch {\n // noop\n }\n this.#connectionHandlers.clear();\n }\n\n #disconnectPrivate(): void {\n const privateClient = this.#privateClient;\n this.#privateClient = null;\n\n for (const [channel, shared] of this.#sharedSubs) {\n if (this.#channelKind(channel) !== \"private\") continue;\n this.#sharedSubs.delete(channel);\n this.#teardownSubscription(shared);\n }\n for (const [channel, shared] of this.#pendingTeardowns) {\n if (this.#channelKind(channel) !== \"private\") continue;\n this.#pendingTeardowns.delete(channel);\n this.#teardownSubscription(shared);\n }\n\n try {\n privateClient?.disconnect();\n } catch {\n // noop\n }\n }\n\n /**\n * Subscribes to a realtime channel and returns an unsubscribe function. Missing\n * authentication is reported to `onError`, or thrown synchronously when no error\n * observer is provided. Non-retryable token failures stop automatic retries;\n * calling subscribe again after correcting the failure restarts private realtime.\n */\n subscribe<T>(channel: string, handlers: SubscribeHandlers<T>): () => void {\n let shared: SharedSubscription;\n try {\n shared = this.#getOrCreateSubscription(channel);\n } catch (error) {\n if (!(error instanceof AuthenticationError)) throw error;\n if (!handlers.onError) throw error;\n\n const ctx = createSdkSubscriptionErrorContext(channel, \"auth\", error);\n queueMicrotask(() => this.#callErrorHandler(handlers.onError, ctx));\n return () => {};\n }\n shared.consumers++;\n\n const publicationHandler = handlers.onPublication;\n const errorHandler = handlers.onError;\n const subscribedHandler = handlers.onSubscribed;\n const unsubscribedHandler = handlers.onUnsubscribed;\n\n const onError: ErrorHandler | undefined = errorHandler\n ? (ctx) => this.#callErrorHandler(errorHandler, ctx)\n : undefined;\n const onPub: PublicationHandler = (data) => {\n this.#callConsumerHandler(\n channel,\n \"publication_handler\",\n () => publicationHandler(data as T),\n onError,\n );\n };\n let lastSubscribedEpoch = -1;\n const onSubscribed = subscribedHandler\n ? (subscriptionEpoch: number) => {\n if (subscriptionEpoch <= lastSubscribedEpoch) return;\n lastSubscribedEpoch = subscriptionEpoch;\n this.#callConsumerHandler(\n channel,\n \"subscribed_handler\",\n subscribedHandler,\n onError,\n );\n }\n : undefined;\n const onUnsubscribed = unsubscribedHandler\n ? () =>\n this.#callConsumerHandler(\n channel,\n \"unsubscribed_handler\",\n unsubscribedHandler,\n onError,\n )\n : undefined;\n\n shared.publicationHandlers.add(onPub);\n\n if (onSubscribed) shared.subscribedHandlers.add(onSubscribed);\n if (onUnsubscribed) shared.unsubscribedHandlers.add(onUnsubscribed);\n if (onError) shared.errorHandlers.add(onError);\n\n // Only an explicit subscribe restarts terminal private token failures.\n if (this.#channelKind(channel) === \"private\" && this.#hasAuth()) {\n if (shared.client?.state === \"disconnected\") shared.client.connect();\n if (shared.sub?.state === \"unsubscribed\") shared.sub.subscribe();\n }\n\n let closed = false;\n if (onSubscribed && shared.sub?.state === \"subscribed\") {\n const subscriptionEpoch = shared.subscriptionEpoch;\n queueMicrotask(() => {\n if (closed || shared.sub?.state !== \"subscribed\") return;\n onSubscribed(subscriptionEpoch);\n });\n }\n\n return () => {\n if (closed) return;\n closed = true;\n\n shared.publicationHandlers.delete(onPub);\n if (onSubscribed) shared.subscribedHandlers.delete(onSubscribed);\n if (onUnsubscribed) shared.unsubscribedHandlers.delete(onUnsubscribed);\n if (onError) shared.errorHandlers.delete(onError);\n\n shared.consumers--;\n if (shared.consumers <= 0) {\n const currentShared = this.#sharedSubs.get(channel);\n if (currentShared !== shared) return;\n\n this.#sharedSubs.delete(channel);\n this.#pendingTeardowns.set(channel, shared);\n\n queueMicrotask(() => {\n if (this.#pendingTeardowns.get(channel) !== shared) return;\n this.#pendingTeardowns.delete(channel);\n\n this.#teardownSubscription(shared);\n\n if (this.#sharedSubs.size === 0 && this.#pendingTeardowns.size === 0) {\n this.#disconnect();\n }\n });\n }\n };\n }\n\n /**\n * Connects to a realtime channel with a custom message decoder.\n */\n connectChannel<T extends DescMessage>(params: ConnectChannelParams<T>): () => void {\n return this.subscribe<Uint8Array>(params.channel, {\n onPublication: (data) => {\n let decoded: MessageShape<T>;\n try {\n decoded = fromBinary(params.schema, data);\n } catch (error) {\n this.#callErrorHandler(\n params.onError,\n createSdkSubscriptionErrorContext(params.channel, \"decode\", error),\n );\n return;\n }\n params.onPublication(decoded);\n },\n onSubscribed: params.onConnected,\n onUnsubscribed: params.onDisconnected,\n onError: params.onError,\n });\n }\n\n /**\n * Connects to a realtime channel that emits protobuf messages.\n */\n connectProtoChannel<T extends DescMessage>(params: ConnectChannelParams<T>): () => void {\n return this.subscribe<Uint8Array | MessageShape<T>>(params.channel, {\n onPublication: (data) => {\n let msg: MessageShape<T> | null;\n try {\n msg = decodeProtoFrame(params.schema, data);\n } catch (error) {\n this.#callErrorHandler(\n params.onError,\n createSdkSubscriptionErrorContext(params.channel, \"decode\", error),\n );\n return;\n }\n if (!msg) {\n this.#callErrorHandler(\n params.onError,\n createSdkSubscriptionErrorContext(\n params.channel,\n \"decode\",\n \"Unable to decode protobuf frame\",\n ),\n );\n return;\n }\n params.onPublication(msg);\n },\n onSubscribed: params.onConnected,\n onUnsubscribed: params.onDisconnected,\n onError: params.onError,\n });\n }\n\n /**\n * Disconnects the realtime client from all active channels.\n */\n disconnect(): void {\n this.#disconnect();\n }\n\n /**\n * Disconnects authenticated realtime state without touching public channels.\n */\n disconnectPrivate(): void {\n this.#disconnectPrivate();\n }\n\n get isConnected(): boolean {\n return this.#publicClient !== null || this.#privateClient !== null;\n }\n\n get activeChannels(): number {\n return this.#sharedSubs.size;\n }\n\n get totalConsumers(): number {\n let total = 0;\n for (const shared of this.#sharedSubs.values()) {\n total += shared.consumers;\n }\n return total;\n }\n}\n"],"mappings":";;;;;;AAuBA,MAAM,gBAAgB,UAAU;AAKhC,MAAM,sCACF,OAAO;AAMX,IAAI,wBAAwD;AAC5D,IAAI,uBAA8C;AAClD,IAAI,yBAAyB;AAa7B,SAAS,iBAA0C;CAC/C,IACI,2BAA2B,iCAC1B,YAA4C,KAAK,KAElD,OAAO,QAAQ,uBAAO,IAAI,MAAM,qDAAqD,CAAC;CAG1F,IAAI,CAAC,uBAAuB;EAExB,MAAM,gBADc,QAAQ,QAAQ,CAAC,CAAC,KAAK,sBACX,CAAC,CAAC,MAC7B,QAAQ;GACL,uBAAuB,IAAI;GAC3B,OAAO,IAAI;EACf,IACC,UAAU;GACP,IAAI,0BAA0B,eAAe,wBAAwB;GACrE,MAAM;EACV,CACJ;EACA,wBAAwB;CAC5B;CACA,OAAO;AACX;;;;AA8CA,IAAa,iBAAb,MAAyD;CACrD,gBAAmC;CACnC,iBAAoC;CACpC,sCAAsB,IAAI,IAAuB;CACjD,8BAAc,IAAI,IAAgC;CAClD,oCAAoB,IAAI,IAAgC;CACxD;CAEA,YAAY,QAAwB;EAChC,KAAKA,UAAU;GACX,OAAO,OAAO;GACd,e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AS;IACrB,IAAI;IACJ,IAAI;KACA,MAAM,iBAAiB,OAAO,QAAQ,IAAI;IAC9C,SAAS,OAAO;KACZ,KAAKA,kBACD,OAAO,SACP,kCAAkC,OAAO,SAAS,UAAU,KAAK,CACrE;KACA;IACJ;IACA,IAAI,CAAC,KAAK;KACN,KAAKA,kBACD,OAAO,SACP,kCACI,OAAO,SACP,UACA,iCACJ,CACJ;KACA;IACJ;IACA,OAAO,cAAc,GAAG;GAC5B;GACA,cAAc,OAAO;GACrB,gBAAgB,OAAO;GACvB,SAAS,OAAO;EACpB,CAAC;CACL;;;;CAKA,aAAmB;EACf,KAAKM,YAAY;CACrB;;;;CAKA,oBAA0B;EACtB,KAAKC,mBAAmB;CAC5B;CAEA,IAAI,cAAuB;EACvB,OAAO,KAAKvB,kBAAkB,QAAQ,KAAKE,mBAAmB;CAClE;CAEA,IAAI,iBAAyB;EACzB,OAAO,KAAKL,YAAY;CAC5B;CAEA,IAAI,iBAAyB;EACzB,IAAI,QAAQ;EACZ,KAAK,MAAM,UAAU,KAAKA,YAAY,OAAO,GACzC,SAAS,OAAO;EAEpB,OAAO;CACX;AACJ"}
|
|
@@ -7,7 +7,7 @@ declare const LifecycleAssetIdsSchema: v.ObjectSchema<{
|
|
|
7
7
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
8
8
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
9
9
|
}, undefined>;
|
|
10
|
-
declare const LifecycleFlowStateEnumSchema: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowState, undefined>, v.TransformAction<FlowState, "unspecified" | "
|
|
10
|
+
declare const LifecycleFlowStateEnumSchema: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowState, undefined>, v.TransformAction<FlowState, "unspecified" | "pending_source" | "pending_polyester_chain" | "pending_ledger" | "completed" | "failed" | "dropped" | "refunded">]>;
|
|
11
11
|
declare const LifecycleZipperReasonSchema: v.ObjectSchema<{
|
|
12
12
|
readonly code: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
13
13
|
readonly reasonId: v.StringSchema<undefined>;
|
|
@@ -17,7 +17,7 @@ declare const ListLifecycleFlowsInputSchema: v.SchemaWithPipe<readonly [v.Strict
|
|
|
17
17
|
readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 500, undefined>]>, 100>;
|
|
18
18
|
readonly sort: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["newest", "oldest"], undefined>, "newest">, v.TransformAction<"newest" | "oldest", Sort.NEWEST | Sort.OLDEST>]>;
|
|
19
19
|
readonly flowKind: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["deposit", "withdraw", "transfer"], undefined>, undefined>, v.TransformAction<"deposit" | "withdraw" | "transfer" | undefined, FlowKind>]>;
|
|
20
|
-
readonly flowState: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["pending_source", "pending_polyester_chain", "pending_ledger", "completed", "failed", "dropped", "refunded"], undefined>, undefined>, v.TransformAction<"
|
|
20
|
+
readonly flowState: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["pending_source", "pending_polyester_chain", "pending_ledger", "completed", "failed", "dropped", "refunded"], undefined>, undefined>, v.TransformAction<"pending_source" | "pending_polyester_chain" | "pending_ledger" | "completed" | "failed" | "dropped" | "refunded" | undefined, FlowState>]>;
|
|
21
21
|
readonly txRef: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, "txHash is required.">, v.CheckAction<string, "txHash must be a valid EVM hash or chain-native transaction id.">, v.TransformAction<string, string>]>, undefined>;
|
|
22
22
|
readonly scope: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["all", "open", "terminal"], undefined>, "all">, v.TransformAction<"open" | "all" | "terminal", ListScope.LIST_ALL | ListScope.LIST_OPEN_ONLY | ListScope.LIST_TERMINAL_ONLY>]>;
|
|
23
23
|
readonly accountSelector: v.OptionalSchema<v.SchemaWithPipe<readonly [v.VariantSchema<"kind", [v.StrictObjectSchema<{
|
|
@@ -209,7 +209,7 @@ declare const LifecycleFlowStepActivitySchema: v.SchemaWithPipe<readonly [v.Obje
|
|
|
209
209
|
}>]>;
|
|
210
210
|
declare const LifecycleFlowStepSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
211
211
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
212
|
-
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "
|
|
212
|
+
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
213
213
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
214
214
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
215
215
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -346,7 +346,7 @@ declare const LifecycleFlowStepSchema: v.SchemaWithPipe<readonly [v.ObjectSchema
|
|
|
346
346
|
}>]>, undefined>, readonly []>;
|
|
347
347
|
}, undefined>, v.TransformAction<{
|
|
348
348
|
sequence: number;
|
|
349
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
349
|
+
step: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
350
350
|
assetIds?: {
|
|
351
351
|
zippedAssetId: number;
|
|
352
352
|
unifiedAssetId: number;
|
|
@@ -407,7 +407,7 @@ declare const LifecycleFlowStepSchema: v.SchemaWithPipe<readonly [v.ObjectSchema
|
|
|
407
407
|
})[];
|
|
408
408
|
}, Omit<{
|
|
409
409
|
sequence: number;
|
|
410
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
410
|
+
step: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
411
411
|
assetIds?: {
|
|
412
412
|
zippedAssetId: number;
|
|
413
413
|
unifiedAssetId: number;
|
|
@@ -471,7 +471,7 @@ declare const LifecycleFlowStepSchema: v.SchemaWithPipe<readonly [v.ObjectSchema
|
|
|
471
471
|
}>]>;
|
|
472
472
|
declare const LifecycleFlowTimelineItemSchema: v.ObjectSchema<{
|
|
473
473
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
474
|
-
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "
|
|
474
|
+
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
475
475
|
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowTimelineStatus, undefined>, v.TransformAction<FlowTimelineStatus, "unspecified" | "completed" | "current" | "planned">]>;
|
|
476
476
|
readonly expectedDurationMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
477
477
|
}, undefined>;
|
|
@@ -491,7 +491,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
491
491
|
readonly smartAccountAddress: v.StringSchema<undefined>;
|
|
492
492
|
readonly flowId: v.StringSchema<undefined>;
|
|
493
493
|
readonly flowKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowKind, undefined>, v.TransformAction<FlowKind, "unspecified" | "deposit" | "withdraw" | "transfer">]>;
|
|
494
|
-
readonly currentStep: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "
|
|
494
|
+
readonly currentStep: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
495
495
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
496
496
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
497
497
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -571,7 +571,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
571
571
|
}, undefined>, undefined>;
|
|
572
572
|
readonly progressTimeline: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
573
573
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
574
|
-
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "
|
|
574
|
+
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
575
575
|
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowTimelineStatus, undefined>, v.TransformAction<FlowTimelineStatus, "unspecified" | "completed" | "current" | "planned">]>;
|
|
576
576
|
readonly expectedDurationMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
577
577
|
}, undefined>, undefined>, readonly []>;
|
|
@@ -581,7 +581,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
581
581
|
smartAccountAddress: string;
|
|
582
582
|
flowId: string;
|
|
583
583
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
584
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
584
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
585
585
|
assetIds?: {
|
|
586
586
|
zippedAssetId: number;
|
|
587
587
|
unifiedAssetId: number;
|
|
@@ -633,7 +633,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
633
633
|
} | undefined;
|
|
634
634
|
progressTimeline: {
|
|
635
635
|
sequence: number;
|
|
636
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
636
|
+
step: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
637
637
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
638
638
|
expectedDurationMs: number;
|
|
639
639
|
}[];
|
|
@@ -643,7 +643,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
643
643
|
smartAccountAddress: string;
|
|
644
644
|
flowId: string;
|
|
645
645
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
646
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
646
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
647
647
|
assetIds?: {
|
|
648
648
|
zippedAssetId: number;
|
|
649
649
|
unifiedAssetId: number;
|
|
@@ -695,7 +695,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
695
695
|
} | undefined;
|
|
696
696
|
progressTimeline: {
|
|
697
697
|
sequence: number;
|
|
698
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
698
|
+
step: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
699
699
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
700
700
|
expectedDurationMs: number;
|
|
701
701
|
}[];
|
|
@@ -709,7 +709,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
709
709
|
readonly smartAccountAddress: v.StringSchema<undefined>;
|
|
710
710
|
readonly flowId: v.StringSchema<undefined>;
|
|
711
711
|
readonly flowKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowKind, undefined>, v.TransformAction<FlowKind, "unspecified" | "deposit" | "withdraw" | "transfer">]>;
|
|
712
|
-
readonly currentStep: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "
|
|
712
|
+
readonly currentStep: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
713
713
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
714
714
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
715
715
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -789,7 +789,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
789
789
|
}, undefined>, undefined>;
|
|
790
790
|
readonly progressTimeline: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
791
791
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
792
|
-
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "
|
|
792
|
+
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
793
793
|
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowTimelineStatus, undefined>, v.TransformAction<FlowTimelineStatus, "unspecified" | "completed" | "current" | "planned">]>;
|
|
794
794
|
readonly expectedDurationMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
795
795
|
}, undefined>, undefined>, readonly []>;
|
|
@@ -799,7 +799,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
799
799
|
smartAccountAddress: string;
|
|
800
800
|
flowId: string;
|
|
801
801
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
802
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
802
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
803
803
|
assetIds?: {
|
|
804
804
|
zippedAssetId: number;
|
|
805
805
|
unifiedAssetId: number;
|
|
@@ -851,7 +851,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
851
851
|
} | undefined;
|
|
852
852
|
progressTimeline: {
|
|
853
853
|
sequence: number;
|
|
854
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
854
|
+
step: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
855
855
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
856
856
|
expectedDurationMs: number;
|
|
857
857
|
}[];
|
|
@@ -861,7 +861,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
861
861
|
smartAccountAddress: string;
|
|
862
862
|
flowId: string;
|
|
863
863
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
864
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
864
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
865
865
|
assetIds?: {
|
|
866
866
|
zippedAssetId: number;
|
|
867
867
|
unifiedAssetId: number;
|
|
@@ -913,7 +913,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
913
913
|
} | undefined;
|
|
914
914
|
progressTimeline: {
|
|
915
915
|
sequence: number;
|
|
916
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
916
|
+
step: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
917
917
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
918
918
|
expectedDurationMs: number;
|
|
919
919
|
}[];
|
|
@@ -923,7 +923,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
923
923
|
}>]>, undefined>;
|
|
924
924
|
readonly observedSteps: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
925
925
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
926
|
-
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "
|
|
926
|
+
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
927
927
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
928
928
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
929
929
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -1060,7 +1060,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
1060
1060
|
}>]>, undefined>, readonly []>;
|
|
1061
1061
|
}, undefined>, v.TransformAction<{
|
|
1062
1062
|
sequence: number;
|
|
1063
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1063
|
+
step: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1064
1064
|
assetIds?: {
|
|
1065
1065
|
zippedAssetId: number;
|
|
1066
1066
|
unifiedAssetId: number;
|
|
@@ -1121,7 +1121,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
1121
1121
|
})[];
|
|
1122
1122
|
}, Omit<{
|
|
1123
1123
|
sequence: number;
|
|
1124
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1124
|
+
step: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1125
1125
|
assetIds?: {
|
|
1126
1126
|
zippedAssetId: number;
|
|
1127
1127
|
unifiedAssetId: number;
|
|
@@ -1191,7 +1191,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
|
|
|
1191
1191
|
readonly smartAccountAddress: v.StringSchema<undefined>;
|
|
1192
1192
|
readonly flowId: v.StringSchema<undefined>;
|
|
1193
1193
|
readonly flowKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowKind, undefined>, v.TransformAction<FlowKind, "unspecified" | "deposit" | "withdraw" | "transfer">]>;
|
|
1194
|
-
readonly currentStep: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "
|
|
1194
|
+
readonly currentStep: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1195
1195
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
1196
1196
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
1197
1197
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -1271,7 +1271,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
|
|
|
1271
1271
|
}, undefined>, undefined>;
|
|
1272
1272
|
readonly progressTimeline: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
1273
1273
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
1274
|
-
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "
|
|
1274
|
+
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1275
1275
|
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowTimelineStatus, undefined>, v.TransformAction<FlowTimelineStatus, "unspecified" | "completed" | "current" | "planned">]>;
|
|
1276
1276
|
readonly expectedDurationMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
1277
1277
|
}, undefined>, undefined>, readonly []>;
|
|
@@ -1281,7 +1281,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
|
|
|
1281
1281
|
smartAccountAddress: string;
|
|
1282
1282
|
flowId: string;
|
|
1283
1283
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
1284
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
1284
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1285
1285
|
assetIds?: {
|
|
1286
1286
|
zippedAssetId: number;
|
|
1287
1287
|
unifiedAssetId: number;
|
|
@@ -1333,7 +1333,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
|
|
|
1333
1333
|
} | undefined;
|
|
1334
1334
|
progressTimeline: {
|
|
1335
1335
|
sequence: number;
|
|
1336
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1336
|
+
step: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1337
1337
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
1338
1338
|
expectedDurationMs: number;
|
|
1339
1339
|
}[];
|
|
@@ -1343,7 +1343,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
|
|
|
1343
1343
|
smartAccountAddress: string;
|
|
1344
1344
|
flowId: string;
|
|
1345
1345
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
1346
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
1346
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1347
1347
|
assetIds?: {
|
|
1348
1348
|
zippedAssetId: number;
|
|
1349
1349
|
unifiedAssetId: number;
|
|
@@ -1395,7 +1395,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
|
|
|
1395
1395
|
} | undefined;
|
|
1396
1396
|
progressTimeline: {
|
|
1397
1397
|
sequence: number;
|
|
1398
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1398
|
+
step: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1399
1399
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
1400
1400
|
expectedDurationMs: number;
|
|
1401
1401
|
}[];
|
|
@@ -1412,7 +1412,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1412
1412
|
readonly smartAccountAddress: v.StringSchema<undefined>;
|
|
1413
1413
|
readonly flowId: v.StringSchema<undefined>;
|
|
1414
1414
|
readonly flowKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowKind, undefined>, v.TransformAction<FlowKind, "unspecified" | "deposit" | "withdraw" | "transfer">]>;
|
|
1415
|
-
readonly currentStep: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "
|
|
1415
|
+
readonly currentStep: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1416
1416
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
1417
1417
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
1418
1418
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -1492,7 +1492,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1492
1492
|
}, undefined>, undefined>;
|
|
1493
1493
|
readonly progressTimeline: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
1494
1494
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
1495
|
-
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "
|
|
1495
|
+
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1496
1496
|
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowTimelineStatus, undefined>, v.TransformAction<FlowTimelineStatus, "unspecified" | "completed" | "current" | "planned">]>;
|
|
1497
1497
|
readonly expectedDurationMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
1498
1498
|
}, undefined>, undefined>, readonly []>;
|
|
@@ -1502,7 +1502,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1502
1502
|
smartAccountAddress: string;
|
|
1503
1503
|
flowId: string;
|
|
1504
1504
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
1505
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
1505
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1506
1506
|
assetIds?: {
|
|
1507
1507
|
zippedAssetId: number;
|
|
1508
1508
|
unifiedAssetId: number;
|
|
@@ -1554,7 +1554,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1554
1554
|
} | undefined;
|
|
1555
1555
|
progressTimeline: {
|
|
1556
1556
|
sequence: number;
|
|
1557
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1557
|
+
step: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1558
1558
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
1559
1559
|
expectedDurationMs: number;
|
|
1560
1560
|
}[];
|
|
@@ -1564,7 +1564,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1564
1564
|
smartAccountAddress: string;
|
|
1565
1565
|
flowId: string;
|
|
1566
1566
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
1567
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
1567
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1568
1568
|
assetIds?: {
|
|
1569
1569
|
zippedAssetId: number;
|
|
1570
1570
|
unifiedAssetId: number;
|
|
@@ -1616,7 +1616,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1616
1616
|
} | undefined;
|
|
1617
1617
|
progressTimeline: {
|
|
1618
1618
|
sequence: number;
|
|
1619
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1619
|
+
step: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1620
1620
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
1621
1621
|
expectedDurationMs: number;
|
|
1622
1622
|
}[];
|
|
@@ -1626,7 +1626,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1626
1626
|
}>]>, undefined>;
|
|
1627
1627
|
readonly observedSteps: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
1628
1628
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
1629
|
-
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "
|
|
1629
|
+
readonly step: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1630
1630
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
1631
1631
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
1632
1632
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -1763,7 +1763,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1763
1763
|
}>]>, undefined>, readonly []>;
|
|
1764
1764
|
}, undefined>, v.TransformAction<{
|
|
1765
1765
|
sequence: number;
|
|
1766
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1766
|
+
step: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1767
1767
|
assetIds?: {
|
|
1768
1768
|
zippedAssetId: number;
|
|
1769
1769
|
unifiedAssetId: number;
|
|
@@ -1824,7 +1824,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1824
1824
|
})[];
|
|
1825
1825
|
}, Omit<{
|
|
1826
1826
|
sequence: number;
|
|
1827
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1827
|
+
step: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1828
1828
|
assetIds?: {
|
|
1829
1829
|
zippedAssetId: number;
|
|
1830
1830
|
unifiedAssetId: number;
|
|
@@ -1899,7 +1899,7 @@ declare const LifecycleFlowTxMatchSchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
1899
1899
|
readonly txOccurrenceIndex: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BigintSchema<undefined>, undefined>, v.TransformAction<bigint | undefined, number>]>;
|
|
1900
1900
|
readonly sourceDomain: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowDomain, undefined>, v.TransformAction<FlowDomain, "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending">]>;
|
|
1901
1901
|
readonly destinationDomain: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowDomain, undefined>, v.TransformAction<FlowDomain, "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending">]>;
|
|
1902
|
-
readonly currentStep: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "
|
|
1902
|
+
readonly currentStep: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1903
1903
|
readonly isOpen: v.BooleanSchema<undefined>;
|
|
1904
1904
|
readonly isTerminal: v.BooleanSchema<undefined>;
|
|
1905
1905
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
@@ -1933,7 +1933,7 @@ declare const LifecycleFlowTxMatchSchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
1933
1933
|
txOccurrenceIndex?: number | undefined;
|
|
1934
1934
|
sourceDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
1935
1935
|
destinationDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
1936
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
1936
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1937
1937
|
isOpen: boolean;
|
|
1938
1938
|
isTerminal: boolean;
|
|
1939
1939
|
assetIds?: {
|
|
@@ -1961,7 +1961,7 @@ declare const LifecycleFlowTxMatchSchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
1961
1961
|
txOccurrenceIndex?: number | undefined;
|
|
1962
1962
|
sourceDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
1963
1963
|
destinationDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
1964
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
1964
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1965
1965
|
isOpen: boolean;
|
|
1966
1966
|
isTerminal: boolean;
|
|
1967
1967
|
assetIds?: {
|
|
@@ -1994,7 +1994,7 @@ declare const ListLifecycleFlowsByTxOutputSchema: v.ObjectSchema<{
|
|
|
1994
1994
|
readonly txOccurrenceIndex: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BigintSchema<undefined>, undefined>, v.TransformAction<bigint | undefined, number>]>;
|
|
1995
1995
|
readonly sourceDomain: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowDomain, undefined>, v.TransformAction<FlowDomain, "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending">]>;
|
|
1996
1996
|
readonly destinationDomain: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowDomain, undefined>, v.TransformAction<FlowDomain, "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending">]>;
|
|
1997
|
-
readonly currentStep: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "
|
|
1997
|
+
readonly currentStep: v.SchemaWithPipe<readonly [v.EnumSchema<typeof FlowStep, undefined>, v.TransformAction<FlowStep, "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1998
1998
|
readonly isOpen: v.BooleanSchema<undefined>;
|
|
1999
1999
|
readonly isTerminal: v.BooleanSchema<undefined>;
|
|
2000
2000
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
@@ -2028,7 +2028,7 @@ declare const ListLifecycleFlowsByTxOutputSchema: v.ObjectSchema<{
|
|
|
2028
2028
|
txOccurrenceIndex?: number | undefined;
|
|
2029
2029
|
sourceDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
2030
2030
|
destinationDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
2031
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
2031
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
2032
2032
|
isOpen: boolean;
|
|
2033
2033
|
isTerminal: boolean;
|
|
2034
2034
|
assetIds?: {
|
|
@@ -2056,7 +2056,7 @@ declare const ListLifecycleFlowsByTxOutputSchema: v.ObjectSchema<{
|
|
|
2056
2056
|
txOccurrenceIndex?: number | undefined;
|
|
2057
2057
|
sourceDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
2058
2058
|
destinationDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
2059
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
2059
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "transfer" | "failed" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
2060
2060
|
isOpen: boolean;
|
|
2061
2061
|
isTerminal: boolean;
|
|
2062
2062
|
assetIds?: {
|
|
@@ -40,7 +40,7 @@ type OpenOrdersInput = v.InferInput<typeof OpenOrdersInputSchema>;
|
|
|
40
40
|
declare const OrderHistoryInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
41
41
|
readonly includeAttachedRisk: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
|
|
42
42
|
readonly includeAttachedRiskState: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
43
|
-
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["FILLED", "CANCELED", "REJECTED"], undefined>, undefined>, v.TransformAction<"
|
|
43
|
+
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["FILLED", "CANCELED", "REJECTED"], undefined>, undefined>, v.TransformAction<"CANCELED" | "REJECTED" | "FILLED" | undefined, OrderStatus.FILLED | OrderStatus.CANCELED | OrderStatus.REJECTED | undefined>]>;
|
|
44
44
|
readonly startTsNs: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
|
|
45
45
|
readonly endTsNs: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
|
|
46
46
|
readonly symbolId: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>, undefined>;
|
|
@@ -243,7 +243,7 @@ declare function createOrderSchema(scales: SdkScales): v.SchemaWithPipe<readonly
|
|
|
243
243
|
attachedRisk: {
|
|
244
244
|
takeProfit: {
|
|
245
245
|
state: {
|
|
246
|
-
status: "unspecified" | "
|
|
246
|
+
status: "unspecified" | "completed" | "failed" | "created" | "armed" | "running" | "paused" | "canceled" | "not_configured";
|
|
247
247
|
armedTs: number | undefined;
|
|
248
248
|
armedTsNs: string | undefined;
|
|
249
249
|
terminalTs: number | undefined;
|
|
@@ -262,7 +262,7 @@ declare function createOrderSchema(scales: SdkScales): v.SchemaWithPipe<readonly
|
|
|
262
262
|
} | undefined;
|
|
263
263
|
stopLoss: {
|
|
264
264
|
state: {
|
|
265
|
-
status: "unspecified" | "
|
|
265
|
+
status: "unspecified" | "completed" | "failed" | "created" | "armed" | "running" | "paused" | "canceled" | "not_configured";
|
|
266
266
|
armedTs: number | undefined;
|
|
267
267
|
armedTsNs: string | undefined;
|
|
268
268
|
terminalTs: number | undefined;
|
|
@@ -281,7 +281,7 @@ declare function createOrderSchema(scales: SdkScales): v.SchemaWithPipe<readonly
|
|
|
281
281
|
} | undefined;
|
|
282
282
|
trailingStop: {
|
|
283
283
|
state: {
|
|
284
|
-
status: "unspecified" | "
|
|
284
|
+
status: "unspecified" | "completed" | "failed" | "created" | "armed" | "running" | "paused" | "canceled" | "not_configured";
|
|
285
285
|
armedTs: number | undefined;
|
|
286
286
|
armedTsNs: string | undefined;
|
|
287
287
|
terminalTs: number | undefined;
|
|
@@ -586,7 +586,7 @@ declare function createOrderDetailsSchema(scales: SdkScales): v.ObjectSchema<{
|
|
|
586
586
|
attachedRisk: {
|
|
587
587
|
takeProfit: {
|
|
588
588
|
state: {
|
|
589
|
-
status: "unspecified" | "
|
|
589
|
+
status: "unspecified" | "completed" | "failed" | "created" | "armed" | "running" | "paused" | "canceled" | "not_configured";
|
|
590
590
|
armedTs: number | undefined;
|
|
591
591
|
armedTsNs: string | undefined;
|
|
592
592
|
terminalTs: number | undefined;
|
|
@@ -605,7 +605,7 @@ declare function createOrderDetailsSchema(scales: SdkScales): v.ObjectSchema<{
|
|
|
605
605
|
} | undefined;
|
|
606
606
|
stopLoss: {
|
|
607
607
|
state: {
|
|
608
|
-
status: "unspecified" | "
|
|
608
|
+
status: "unspecified" | "completed" | "failed" | "created" | "armed" | "running" | "paused" | "canceled" | "not_configured";
|
|
609
609
|
armedTs: number | undefined;
|
|
610
610
|
armedTsNs: string | undefined;
|
|
611
611
|
terminalTs: number | undefined;
|
|
@@ -624,7 +624,7 @@ declare function createOrderDetailsSchema(scales: SdkScales): v.ObjectSchema<{
|
|
|
624
624
|
} | undefined;
|
|
625
625
|
trailingStop: {
|
|
626
626
|
state: {
|
|
627
|
-
status: "unspecified" | "
|
|
627
|
+
status: "unspecified" | "completed" | "failed" | "created" | "armed" | "running" | "paused" | "canceled" | "not_configured";
|
|
628
628
|
armedTs: number | undefined;
|
|
629
629
|
armedTsNs: string | undefined;
|
|
630
630
|
terminalTs: number | undefined;
|
|
@@ -212,7 +212,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
212
212
|
readonly granteeAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
213
213
|
readonly inviterAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
214
214
|
readonly role: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountRole$1, undefined>, v.TransformAction<SubaccountRole$1, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
215
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountInviteStatus$1, undefined>, v.TransformAction<SubaccountInviteStatus$1, "unspecified" | "pending" | "
|
|
215
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountInviteStatus$1, undefined>, v.TransformAction<SubaccountInviteStatus$1, "unspecified" | "pending" | "accepted" | "declined" | "cancelled">]>;
|
|
216
216
|
readonly createdAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
217
217
|
readonly seconds: v.BigintSchema<undefined>;
|
|
218
218
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -239,7 +239,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
239
239
|
granteeAccountId: string;
|
|
240
240
|
inviterAccountId: string;
|
|
241
241
|
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
242
|
-
status: "unspecified" | "pending" | "
|
|
242
|
+
status: "unspecified" | "pending" | "accepted" | "declined" | "cancelled";
|
|
243
243
|
createdAt?: number | undefined;
|
|
244
244
|
respondedAt?: number | undefined;
|
|
245
245
|
granteeUsername: string;
|
|
@@ -257,7 +257,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
257
257
|
granteeAccountId: string;
|
|
258
258
|
inviterAccountId: string;
|
|
259
259
|
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
260
|
-
status: "unspecified" | "pending" | "
|
|
260
|
+
status: "unspecified" | "pending" | "accepted" | "declined" | "cancelled";
|
|
261
261
|
createdAt?: number | undefined;
|
|
262
262
|
respondedAt?: number | undefined;
|
|
263
263
|
granteeUsername: string;
|
|
@@ -279,8 +279,8 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
|
|
|
279
279
|
seconds: bigint;
|
|
280
280
|
nanos: number;
|
|
281
281
|
} | undefined, number | undefined>]>;
|
|
282
|
-
readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "
|
|
283
|
-
readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "failed" | "created" | "updated" | "deleted" | "removed" | "role_set" | "received" | "replied" | "
|
|
282
|
+
readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "member" | "policy" | "invite" | "security">]>;
|
|
283
|
+
readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "revoked" | "failed" | "created" | "updated" | "deleted" | "removed" | "role_set" | "received" | "replied" | "blocked" | "hold_placed" | "hold_released">]>;
|
|
284
284
|
readonly source: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventSource, undefined>, v.TransformAction<ActivityEventSource, "unspecified" | "web" | "mobile" | "api">]>;
|
|
285
285
|
readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
286
286
|
readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -809,7 +809,7 @@ type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInpu
|
|
|
809
809
|
declare const ListTriggersInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
810
810
|
readonly parentOrderId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
|
|
811
811
|
readonly symbolId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>;
|
|
812
|
-
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("
|
|
812
|
+
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("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)[]>]>;
|
|
813
813
|
readonly triggerType: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["stop_loss", "take_profit", "trailing_stop", "twap", "ladder"], undefined>, undefined>, v.TransformAction<"twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop" | undefined, TriggerType>]>;
|
|
814
814
|
readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 1000, undefined>]>, 50>;
|
|
815
815
|
readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
|
|
@@ -31,62 +31,62 @@ declare const CreateTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSche
|
|
|
31
31
|
type CreateTriggerResult = v.InferOutput<typeof CreateTriggerResultSchema>;
|
|
32
32
|
declare const CancelTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
33
33
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
34
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "
|
|
34
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused">]>;
|
|
35
35
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
36
36
|
}, undefined>, v.TransformAction<{
|
|
37
37
|
triggerId: string;
|
|
38
|
-
status: "unspecified" | "
|
|
38
|
+
status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
|
|
39
39
|
tsNs: bigint;
|
|
40
40
|
}, {
|
|
41
41
|
ts: number;
|
|
42
42
|
tsNs: string;
|
|
43
43
|
triggerId: string;
|
|
44
|
-
status: "unspecified" | "
|
|
44
|
+
status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
|
|
45
45
|
}>]>;
|
|
46
46
|
type CancelTriggerResult = v.InferOutput<typeof CancelTriggerResultSchema>;
|
|
47
47
|
declare const ModifyTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
48
48
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
49
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "
|
|
49
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused">]>;
|
|
50
50
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
51
51
|
}, undefined>, v.TransformAction<{
|
|
52
52
|
triggerId: string;
|
|
53
|
-
status: "unspecified" | "
|
|
53
|
+
status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
|
|
54
54
|
tsNs: bigint;
|
|
55
55
|
}, {
|
|
56
56
|
ts: number;
|
|
57
57
|
tsNs: string;
|
|
58
58
|
triggerId: string;
|
|
59
|
-
status: "unspecified" | "
|
|
59
|
+
status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
|
|
60
60
|
}>]>;
|
|
61
61
|
type ModifyTriggerResult = v.InferOutput<typeof ModifyTriggerResultSchema>;
|
|
62
62
|
declare const PauseTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
63
63
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
64
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "
|
|
64
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused">]>;
|
|
65
65
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
66
66
|
}, undefined>, v.TransformAction<{
|
|
67
67
|
triggerId: string;
|
|
68
|
-
status: "unspecified" | "
|
|
68
|
+
status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
|
|
69
69
|
tsNs: bigint;
|
|
70
70
|
}, {
|
|
71
71
|
ts: number;
|
|
72
72
|
tsNs: string;
|
|
73
73
|
triggerId: string;
|
|
74
|
-
status: "unspecified" | "
|
|
74
|
+
status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
|
|
75
75
|
}>]>;
|
|
76
76
|
type PauseTriggerResult = v.InferOutput<typeof PauseTriggerResultSchema>;
|
|
77
77
|
declare const ResumeTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
78
78
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
79
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "
|
|
79
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused">]>;
|
|
80
80
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
81
81
|
}, undefined>, v.TransformAction<{
|
|
82
82
|
triggerId: string;
|
|
83
|
-
status: "unspecified" | "
|
|
83
|
+
status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
|
|
84
84
|
tsNs: bigint;
|
|
85
85
|
}, {
|
|
86
86
|
ts: number;
|
|
87
87
|
tsNs: string;
|
|
88
88
|
triggerId: string;
|
|
89
|
-
status: "unspecified" | "
|
|
89
|
+
status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
|
|
90
90
|
}>]>;
|
|
91
91
|
type ResumeTriggerResult = v.InferOutput<typeof ResumeTriggerResultSchema>;
|
|
92
92
|
type StopDetailsOutput = {
|
|
@@ -528,7 +528,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
528
528
|
triggerId: string;
|
|
529
529
|
subaccountId: string;
|
|
530
530
|
symbolId: number;
|
|
531
|
-
status: "unspecified" | "
|
|
531
|
+
status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
|
|
532
532
|
parentOrderId: string | undefined;
|
|
533
533
|
qty: string;
|
|
534
534
|
feeAsset: "unspecified" | "quote" | "base";
|
|
@@ -669,7 +669,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
669
669
|
triggerId: string;
|
|
670
670
|
subaccountId: string;
|
|
671
671
|
symbolId: number;
|
|
672
|
-
status: "unspecified" | "
|
|
672
|
+
status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
|
|
673
673
|
parentOrderId: string | undefined;
|
|
674
674
|
qty: string;
|
|
675
675
|
feeAsset: "unspecified" | "quote" | "base";
|
|
@@ -810,7 +810,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
810
810
|
triggerId: string;
|
|
811
811
|
subaccountId: string;
|
|
812
812
|
symbolId: number;
|
|
813
|
-
status: "unspecified" | "
|
|
813
|
+
status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
|
|
814
814
|
parentOrderId: string | undefined;
|
|
815
815
|
qty: string;
|
|
816
816
|
feeAsset: "unspecified" | "quote" | "base";
|
package/package.json
CHANGED