@supacloud/js 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,95 @@
1
+ import { SupaCloudApiError } from "./api-error.js";
2
+ export type SupaCloudOAuthClientType = "public" | "confidential";
3
+ export type SupaCloudOAuthClientAuthMethod = "none" | "client_secret_basic" | "client_secret_post";
4
+ type SecretMethod = Exclude<SupaCloudOAuthClientAuthMethod, "none">;
5
+ type Grant = "authorization_code" | "refresh_token";
6
+ interface ClientMetadata {
7
+ client_id: string;
8
+ client_name?: string;
9
+ redirect_uris?: string[];
10
+ grant_types?: Grant[];
11
+ response_types?: "code"[];
12
+ client_uri?: string;
13
+ logo_uri?: string;
14
+ registration_type?: "manual" | "dynamic";
15
+ created_at?: string;
16
+ updated_at?: string;
17
+ }
18
+ export type SupaCloudOAuthClient = ClientMetadata & ({
19
+ client_type: "public";
20
+ token_endpoint_auth_method?: "none";
21
+ client_secret?: never;
22
+ } | {
23
+ client_type: "confidential";
24
+ token_endpoint_auth_method?: SecretMethod;
25
+ client_secret?: string;
26
+ });
27
+ export type SupaCloudOAuthClientList = {
28
+ clients: SupaCloudOAuthClient[];
29
+ };
30
+ export type SupaCloudOAuthCreatedClient = SupaCloudOAuthClient & ({
31
+ client_type: "public";
32
+ } | {
33
+ client_type: "confidential";
34
+ client_secret: string;
35
+ });
36
+ export type SupaCloudOAuthSecretClient = SupaCloudOAuthClient & {
37
+ client_type: "confidential";
38
+ client_secret: string;
39
+ };
40
+ export interface SupaCloudOAuthClientUpdate {
41
+ redirect_uris?: string[];
42
+ token_endpoint_auth_method?: SupaCloudOAuthClientAuthMethod;
43
+ grant_types?: Grant[];
44
+ client_name?: string;
45
+ client_uri?: string;
46
+ logo_uri?: string;
47
+ }
48
+ export type SupaCloudOAuthClientCreate = Omit<SupaCloudOAuthClientUpdate, "token_endpoint_auth_method"> & {
49
+ redirect_uris: string[];
50
+ } & ({
51
+ client_type: "public";
52
+ token_endpoint_auth_method?: "none";
53
+ } | {
54
+ client_type: "confidential";
55
+ token_endpoint_auth_method?: SecretMethod;
56
+ } | {
57
+ client_type?: never;
58
+ token_endpoint_auth_method?: SupaCloudOAuthClientAuthMethod;
59
+ });
60
+ export type SupaCloudOAuthRequest = (url: string, options: RequestInit) => Promise<Response>;
61
+ export type SupaCloudOAuthClientsOptions = {
62
+ managementApiUrl: string;
63
+ projectRef: string;
64
+ } & ({
65
+ getAccessToken: () => Promise<string | null> | string | null;
66
+ request?: SupaCloudOAuthRequest;
67
+ sessionRequest?: never;
68
+ } | {
69
+ sessionRequest: SupaCloudOAuthRequest;
70
+ getAccessToken?: never;
71
+ request?: never;
72
+ });
73
+ export interface SupaCloudOAuthRequestOptions {
74
+ signal?: AbortSignal;
75
+ timeoutMs?: number;
76
+ }
77
+ export declare class SupaCloudOAuthClientError extends SupaCloudApiError {
78
+ readonly mutationMayHaveApplied: boolean;
79
+ constructor(code: string, status?: number, mutationMayHaveApplied?: boolean);
80
+ }
81
+ /** Uses Management API credentials or an explicit same-origin session transport. */
82
+ export declare class SupaCloudOAuthClientsClient {
83
+ private readonly base;
84
+ private readonly send;
85
+ private readonly token;
86
+ constructor(options: SupaCloudOAuthClientsOptions);
87
+ private request;
88
+ list(options?: SupaCloudOAuthRequestOptions): Promise<SupaCloudOAuthClientList>;
89
+ get(clientId: string, options?: SupaCloudOAuthRequestOptions): Promise<SupaCloudOAuthClient>;
90
+ create(input: SupaCloudOAuthClientCreate, options?: SupaCloudOAuthRequestOptions): Promise<SupaCloudOAuthCreatedClient>;
91
+ update(clientId: string, input: SupaCloudOAuthClientUpdate, options?: SupaCloudOAuthRequestOptions): Promise<SupaCloudOAuthClient>;
92
+ delete(clientId: string, options?: SupaCloudOAuthRequestOptions): Promise<void>;
93
+ regenerateSecret(clientId: string, options?: SupaCloudOAuthRequestOptions): Promise<SupaCloudOAuthSecretClient>;
94
+ }
95
+ export {};
@@ -0,0 +1,104 @@
1
+ import { SupaCloudApiError } from "./api-error.js";
2
+ export type SupaCloudOAuthServerStatus = {
3
+ project_ref: string;
4
+ organization_id: string | null;
5
+ account_isolated: true;
6
+ state_source: "configuration";
7
+ runtime_verified: false;
8
+ enabled: boolean;
9
+ allow_dynamic_registration: boolean;
10
+ issuer: string;
11
+ authorization_path: string;
12
+ discovery_url: string;
13
+ oauth_authorization_server_metadata_url: string;
14
+ jwks_url: string;
15
+ authorization_endpoint: string;
16
+ token_endpoint: string;
17
+ userinfo_endpoint: string;
18
+ registration_endpoint: string;
19
+ warnings: string[];
20
+ } & ({
21
+ signing_alg: "ES256";
22
+ key_id: string;
23
+ oidc_id_token_ready: true;
24
+ migration_status: "oidc_es256_migrated";
25
+ } | {
26
+ signing_alg: "RS256";
27
+ key_id: string;
28
+ oidc_id_token_ready: true;
29
+ migration_status: "oidc_rs256_migrated";
30
+ } | {
31
+ signing_alg: "not_migrated";
32
+ key_id?: never;
33
+ oidc_id_token_ready: false;
34
+ migration_status: "not_migrated";
35
+ });
36
+ export type SupaCloudAuthorizeUrlOptions = {
37
+ clientId: string;
38
+ redirectUri: string;
39
+ scope?: string | string[];
40
+ state?: string;
41
+ codeChallenge?: string;
42
+ codeChallengeMethod?: "S256" | "plain";
43
+ nonce?: string;
44
+ responseType?: "code";
45
+ resource?: string;
46
+ };
47
+ export type SupaCloudOidcDiscovery = {
48
+ issuer: string;
49
+ authorization_endpoint: string;
50
+ token_endpoint: string;
51
+ jwks_uri: string;
52
+ response_types_supported: string[];
53
+ subject_types_supported: string[];
54
+ id_token_signing_alg_values_supported: string[];
55
+ userinfo_endpoint?: string;
56
+ registration_endpoint?: string;
57
+ };
58
+ export type SupaCloudPublicJwk = {
59
+ kty: "EC";
60
+ crv: "P-256";
61
+ x: string;
62
+ y: string;
63
+ alg: "ES256";
64
+ kid: string;
65
+ use: "sig";
66
+ } | {
67
+ kty: "RSA";
68
+ n: string;
69
+ e: string;
70
+ alg: "RS256";
71
+ kid: string;
72
+ use: "sig";
73
+ };
74
+ export type SupaCloudJwks = {
75
+ keys: SupaCloudPublicJwk[];
76
+ };
77
+ type Options = {
78
+ managementApiUrl: string;
79
+ projectRef: string;
80
+ getAccessToken: () => Promise<string | null> | string | null;
81
+ };
82
+ type MigrationOptions = {
83
+ allowDynamicRegistration?: boolean;
84
+ authorizationPath?: string;
85
+ };
86
+ export declare class SupaCloudOAuthServerError extends SupaCloudApiError {
87
+ readonly code: string;
88
+ readonly mutationMayHaveApplied: boolean;
89
+ constructor(message: string, code: string, mutationMayHaveApplied?: boolean, status?: number);
90
+ }
91
+ export declare class SupaCloudOAuthServerClient {
92
+ private readonly base;
93
+ private readonly projectRef;
94
+ private readonly getAccessToken;
95
+ constructor(options: Options);
96
+ private status;
97
+ getStatus(): Promise<SupaCloudOAuthServerStatus>;
98
+ migrateToOidc(options?: MigrationOptions): Promise<SupaCloudOAuthServerStatus>;
99
+ private publicDocument;
100
+ getDiscovery(): Promise<SupaCloudOidcDiscovery>;
101
+ getJwks(): Promise<SupaCloudJwks>;
102
+ buildAuthorizeUrl(options: SupaCloudAuthorizeUrlOptions): Promise<string>;
103
+ }
104
+ export {};
@@ -0,0 +1,54 @@
1
+ import { SupaCloudApiError } from "./api-error.js";
2
+ export type SupaCloudQueueJson = null | boolean | number | string | SupaCloudQueueJson[] | {
3
+ [key: string]: SupaCloudQueueJson;
4
+ };
5
+ export type SupaCloudQueueMessage = {
6
+ id: string;
7
+ msg_id: string;
8
+ read_ct?: number;
9
+ enqueued_at?: string | null;
10
+ vt?: string | null;
11
+ message: SupaCloudQueueJson;
12
+ payload: SupaCloudQueueJson;
13
+ status?: string;
14
+ queue_name?: string;
15
+ task_type?: string;
16
+ };
17
+ export type SupaCloudQueueSendResult = {
18
+ id: string;
19
+ msg_id: string;
20
+ queue_name: string;
21
+ status: "pending";
22
+ payload: SupaCloudQueueJson;
23
+ };
24
+ export type SupaCloudQueueMutationResult = {
25
+ id: string;
26
+ msg_id: string;
27
+ queue_name: string;
28
+ status: "archived" | "deleted" | "released";
29
+ success: boolean;
30
+ };
31
+ export declare class SupaCloudQueueError extends SupaCloudApiError {
32
+ readonly mutationMayHaveApplied: boolean;
33
+ constructor(mutationMayHaveApplied?: boolean, code?: string);
34
+ }
35
+ export declare function queueMessageId(value: unknown): string;
36
+ export declare function queueInteger(value: unknown, min: number, max?: number): number;
37
+ export declare function queueSeconds(options: {
38
+ sleepSeconds?: number;
39
+ sleep_seconds?: number;
40
+ delayMs?: number;
41
+ visibilityTimeoutSec?: number;
42
+ }): number;
43
+ export declare function queueReadCount(options: unknown, single?: boolean): number;
44
+ export declare function queueJsonSnapshot(value: unknown): SupaCloudQueueJson;
45
+ export declare function queueRpcIds(value: unknown, expected: number): string[];
46
+ export declare function queueRpcId(value: unknown): string;
47
+ export declare function queueRpcBoolean(value: unknown): boolean;
48
+ export declare function queueMessage(value: unknown, expected?: {
49
+ queueName?: string;
50
+ messageId?: string;
51
+ status?: string;
52
+ rpc?: boolean;
53
+ }): SupaCloudQueueMessage;
54
+ export declare function queueRpcMessages(queueName: string, value: unknown, max: number, status: string): SupaCloudQueueMessage[];
@@ -0,0 +1,8 @@
1
+ import { SupaCloudApiError } from "./api-error.js";
2
+ import type { SupaCloudWorkflowAdvanceRequest, SupaCloudWorkflowRun } from "./workflows.js";
3
+ export declare class SupaCloudWorkflowAdvanceError extends SupaCloudApiError {
4
+ readonly mutationMayHaveApplied: boolean;
5
+ constructor(mutationMayHaveApplied?: boolean);
6
+ }
7
+ export declare function captureWorkflowAdvance(value: unknown): Required<SupaCloudWorkflowAdvanceRequest>;
8
+ export declare function decodeWorkflowAdvance(value: unknown, request: Required<SupaCloudWorkflowAdvanceRequest>): SupaCloudWorkflowRun;
@@ -0,0 +1,4 @@
1
+ import type { SupaCloudWorkflowAttemptRequest } from "./workflows.js";
2
+ export declare function workflowRequestFields(value: unknown, names: readonly string[]): Record<string, unknown>;
3
+ export declare function captureWorkflowAttempt(fields: Record<string, unknown>): SupaCloudWorkflowAttemptRequest;
4
+ export declare function captureWorkflowErrorMessage(value: unknown): string;
@@ -0,0 +1,14 @@
1
+ import { SupaCloudApiError } from "./api-error.js";
2
+ import type { SupaCloudWorkflowRun } from "./workflows.js";
3
+ export declare class SupaCloudWorkflowCancelError extends SupaCloudApiError {
4
+ readonly mutationMayHaveApplied: boolean;
5
+ constructor(mutationMayHaveApplied?: boolean);
6
+ }
7
+ export declare function captureWorkflowCancel(runId: unknown, reason: unknown): {
8
+ runId: string;
9
+ reason: string;
10
+ };
11
+ export declare function decodeWorkflowCancel(value: unknown, request: {
12
+ runId: string;
13
+ reason: string;
14
+ }): SupaCloudWorkflowRun;
@@ -0,0 +1,12 @@
1
+ import { SupaCloudApiError } from "./api-error.js";
2
+ import type { SupaCloudWorkflowClaimRequest, SupaCloudWorkflowClaimResult } from "./workflows.js";
3
+ export declare class SupaCloudWorkflowClaimInputError extends SupaCloudApiError {
4
+ readonly mutationMayHaveApplied = false;
5
+ constructor();
6
+ }
7
+ export declare function captureWorkflowClaimRequest(value: unknown): Required<SupaCloudWorkflowClaimRequest>;
8
+ export declare class SupaCloudWorkflowClaimError extends SupaCloudApiError {
9
+ readonly mutationMayHaveApplied = true;
10
+ constructor();
11
+ }
12
+ export declare function decodeWorkflowClaim(value: unknown, expectedWorkerId: string): SupaCloudWorkflowClaimResult;
@@ -0,0 +1,8 @@
1
+ import { SupaCloudApiError } from "./api-error.js";
2
+ import type { SupaCloudWorkflowCompleteRequest, SupaCloudWorkflowRun } from "./workflows.js";
3
+ export declare class SupaCloudWorkflowCompleteError extends SupaCloudApiError {
4
+ readonly mutationMayHaveApplied: boolean;
5
+ constructor(mutationMayHaveApplied?: boolean);
6
+ }
7
+ export declare function captureWorkflowComplete(value: unknown): Required<SupaCloudWorkflowCompleteRequest>;
8
+ export declare function decodeWorkflowComplete(value: unknown, request: Required<SupaCloudWorkflowCompleteRequest>): SupaCloudWorkflowRun;
@@ -0,0 +1,14 @@
1
+ import { SupaCloudApiError } from "./api-error.js";
2
+ import type { SupaCloudWorkflowEvent } from "./workflows.js";
3
+ export declare class SupaCloudWorkflowEventsError extends SupaCloudApiError {
4
+ readonly mutationMayHaveApplied = false;
5
+ constructor(input?: boolean);
6
+ }
7
+ type EventRequest = {
8
+ runId: string;
9
+ afterEventId: string;
10
+ limit: number;
11
+ };
12
+ export declare function captureWorkflowEvents(runId: unknown, options: unknown): EventRequest;
13
+ export declare function decodeWorkflowEvents(value: unknown, request: EventRequest): SupaCloudWorkflowEvent[];
14
+ export {};
@@ -0,0 +1,8 @@
1
+ import { SupaCloudApiError } from "./api-error.js";
2
+ import type { SupaCloudWorkflowFailRequest, SupaCloudWorkflowRun } from "./workflows.js";
3
+ export declare class SupaCloudWorkflowFailError extends SupaCloudApiError {
4
+ readonly mutationMayHaveApplied: boolean;
5
+ constructor(mutationMayHaveApplied?: boolean);
6
+ }
7
+ export declare function captureWorkflowFail(value: unknown): SupaCloudWorkflowFailRequest;
8
+ export declare function decodeWorkflowFail(value: unknown, request: SupaCloudWorkflowFailRequest): SupaCloudWorkflowRun;
@@ -0,0 +1,9 @@
1
+ import { type FetchTransport } from "./bounded-rpc-fetch.js";
2
+ export interface SupaCloudWorkflowFetchOptions {
3
+ fetch?: FetchTransport;
4
+ }
5
+ /**
6
+ * Install in createClient's global.fetch before constructing the Supabase client.
7
+ * Only workflow RPCs are bounded; other Supabase requests pass through unchanged.
8
+ */
9
+ export declare function createSupaCloudWorkflowFetch(options?: SupaCloudWorkflowFetchOptions): FetchTransport;
@@ -0,0 +1,2 @@
1
+ export declare function workflowJsonObject(value: unknown): Record<string, unknown>;
2
+ export declare function workflowJsonEqual(left: unknown, right: unknown): boolean;
@@ -0,0 +1,8 @@
1
+ import { SupaCloudApiError } from "./api-error.js";
2
+ import type { SupaCloudWorkflowRetryRequest, SupaCloudWorkflowRun } from "./workflows.js";
3
+ export declare class SupaCloudWorkflowRetryError extends SupaCloudApiError {
4
+ readonly mutationMayHaveApplied: boolean;
5
+ constructor(mutationMayHaveApplied?: boolean);
6
+ }
7
+ export declare function captureWorkflowRetry(value: unknown): Required<SupaCloudWorkflowRetryRequest>;
8
+ export declare function decodeWorkflowRetry(value: unknown, request: Required<SupaCloudWorkflowRetryRequest>): SupaCloudWorkflowRun;
@@ -0,0 +1,6 @@
1
+ import type { SupabaseClient } from "@supabase/supabase-js";
2
+ type WorkflowMutationName = "supacloud_workflow_start" | "supacloud_workflow_claim" | "supacloud_workflow_cancel" | "supacloud_workflow_complete" | "supacloud_workflow_fail" | "supacloud_workflow_advance" | "supacloud_workflow_retry";
3
+ type WorkflowReadName = "supacloud_workflow_get" | "supacloud_workflow_events";
4
+ export declare function invokeWorkflowMutation(supabase: SupabaseClient, functionName: WorkflowMutationName, request: object, unconfirmed: () => Error): Promise<unknown>;
5
+ export declare function invokeWorkflowRead(supabase: SupabaseClient, functionName: WorkflowReadName, request: object, invalid: () => Error): Promise<unknown>;
6
+ export {};
@@ -0,0 +1,8 @@
1
+ import { SupaCloudApiError } from "./api-error.js";
2
+ import type { SupaCloudWorkflowRun } from "./workflows.js";
3
+ export declare class SupaCloudWorkflowReadError extends SupaCloudApiError {
4
+ readonly mutationMayHaveApplied = false;
5
+ constructor(code?: string);
6
+ }
7
+ export declare function captureWorkflowRunId(value: unknown): string;
8
+ export declare function decodeWorkflowRun(value: unknown, expectedRunId: string, allowIdempotent?: boolean): SupaCloudWorkflowRun | null;
@@ -0,0 +1,8 @@
1
+ import { SupaCloudApiError } from "./api-error.js";
2
+ import type { SupaCloudWorkflowRun, SupaCloudWorkflowStartRequest } from "./workflows.js";
3
+ export declare class SupaCloudWorkflowStartError extends SupaCloudApiError {
4
+ readonly mutationMayHaveApplied: boolean;
5
+ constructor(mutationMayHaveApplied?: boolean);
6
+ }
7
+ export declare function captureWorkflowStart(value: unknown): Required<SupaCloudWorkflowStartRequest>;
8
+ export declare function decodeWorkflowStart(value: unknown, request: Required<SupaCloudWorkflowStartRequest>): SupaCloudWorkflowRun;
@@ -0,0 +1 @@
1
+ export declare function isWorkflowTimestamp(value: unknown): value is string;
@@ -1,4 +1,13 @@
1
1
  import type { SupabaseClient } from "@supabase/supabase-js";
2
+ export { SupaCloudWorkflowClaimError, SupaCloudWorkflowClaimInputError } from "./workflow-claim.js";
3
+ export { SupaCloudWorkflowReadError } from "./workflow-run.js";
4
+ export { SupaCloudWorkflowStartError } from "./workflow-start.js";
5
+ export { SupaCloudWorkflowCancelError } from "./workflow-cancel.js";
6
+ export { SupaCloudWorkflowCompleteError } from "./workflow-complete.js";
7
+ export { SupaCloudWorkflowFailError } from "./workflow-fail.js";
8
+ export { SupaCloudWorkflowAdvanceError } from "./workflow-advance.js";
9
+ export { SupaCloudWorkflowRetryError } from "./workflow-retry.js";
10
+ export { SupaCloudWorkflowEventsError } from "./workflow-events.js";
2
11
  export type SupaCloudWorkflowRunStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
3
12
  export type SupaCloudWorkflowStepStatus = "queued" | "running" | "completed" | "failed" | "dead_lettered" | "cancelled";
4
13
  export type SupaCloudWorkflowJson = Record<string, unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/js",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "Platform SDK for SupaCloud, built on top of supabase-js",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "scripts": {
21
21
  "test": "bun test",
22
22
  "build": "bun run clean && bun run build:js && bun run build:types",
23
- "build:js": "bun build src/index.ts --outdir dist --target node --external @supacloud/contracts",
23
+ "build:js": "bun build src/index.ts --outdir dist --target node --external @supabase/supabase-js --external @supacloud/contracts",
24
24
  "build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
25
25
  "clean": "rm -rf dist",
26
26
  "prepublishOnly": "bun run build",