@supacloud/js 0.22.1 → 0.23.1
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/README.md +7 -0
- package/dist/artifacts.d.ts +50 -0
- package/dist/commands.d.ts +33 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +69 -20
- package/dist/service-role-rpc.d.ts +2 -0
- package/dist/workflows.d.ts +0 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@ It does **not** replace [`@supabase/supabase-js`](https://www.npmjs.com/package/
|
|
|
10
10
|
- Realtime subscription with polling fallback
|
|
11
11
|
- Supabase Queues helpers backed by the official `pgmq_public` RPC API, plus SupaCloud management extensions for queue administration and diagnostics
|
|
12
12
|
- Service-role-only durable workflow helpers backed by PostgreSQL and PGMQ
|
|
13
|
+
- Service-role-only transactional command receipts backed by Durable Workflows
|
|
14
|
+
- Immutable Storage artifact registration and lineage helpers
|
|
13
15
|
- project OAuth/OIDC migration and OAuth client management
|
|
14
16
|
- SupAuth provisioning and runtime verification helpers
|
|
15
17
|
|
|
@@ -178,6 +180,11 @@ The current package focuses on:
|
|
|
178
180
|
- `supauth.rollback`
|
|
179
181
|
- `supauth.getClientConfig`
|
|
180
182
|
- `supauth.verify`
|
|
183
|
+
- `commands.submit`
|
|
184
|
+
- `commands.get`
|
|
185
|
+
- `artifacts.register`
|
|
186
|
+
- `artifacts.get`
|
|
187
|
+
- `artifacts.link`
|
|
181
188
|
|
|
182
189
|
## Status Subscription
|
|
183
190
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
export type SupaCloudArtifactJson = Record<string, unknown>;
|
|
3
|
+
export interface SupaCloudArtifactParent {
|
|
4
|
+
artifactId: string;
|
|
5
|
+
relationType: string;
|
|
6
|
+
metadata: SupaCloudArtifactJson;
|
|
7
|
+
createdAt: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SupaCloudArtifact {
|
|
10
|
+
artifactId: string;
|
|
11
|
+
bucketId: string;
|
|
12
|
+
objectPath: string;
|
|
13
|
+
objectVersion: string;
|
|
14
|
+
artifactType: string;
|
|
15
|
+
sha256: string;
|
|
16
|
+
sizeBytes: string;
|
|
17
|
+
mimeType: string;
|
|
18
|
+
metadata: SupaCloudArtifactJson;
|
|
19
|
+
retentionUntil: string | null;
|
|
20
|
+
createdBy: string | null;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
idempotent: boolean;
|
|
23
|
+
parents: SupaCloudArtifactParent[];
|
|
24
|
+
}
|
|
25
|
+
export interface SupaCloudArtifactRegisterRequest {
|
|
26
|
+
artifactId: string;
|
|
27
|
+
bucketId: string;
|
|
28
|
+
objectPath: string;
|
|
29
|
+
artifactType: string;
|
|
30
|
+
sha256: string;
|
|
31
|
+
sizeBytes: string | number;
|
|
32
|
+
mimeType: string;
|
|
33
|
+
metadata?: SupaCloudArtifactJson;
|
|
34
|
+
retentionUntil?: string;
|
|
35
|
+
createdBy?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface SupaCloudArtifactLinkRequest {
|
|
38
|
+
parentArtifactId: string;
|
|
39
|
+
childArtifactId: string;
|
|
40
|
+
relationType: string;
|
|
41
|
+
metadata?: SupaCloudArtifactJson;
|
|
42
|
+
}
|
|
43
|
+
/** Service-role-only immutable Storage artifact registry client. */
|
|
44
|
+
export declare class SupaCloudArtifactsClient<TClient extends SupabaseClient = SupabaseClient> {
|
|
45
|
+
private readonly supabase;
|
|
46
|
+
constructor(supabase: TClient);
|
|
47
|
+
register(request: SupaCloudArtifactRegisterRequest): Promise<SupaCloudArtifact>;
|
|
48
|
+
get(artifactId: string): Promise<SupaCloudArtifact | null>;
|
|
49
|
+
link(request: SupaCloudArtifactLinkRequest): Promise<SupaCloudArtifact>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
import type { SupaCloudWorkflowJson, SupaCloudWorkflowRun } from "./workflows.js";
|
|
3
|
+
export interface SupaCloudCommandSubmitRequest {
|
|
4
|
+
commandId: string;
|
|
5
|
+
commandType: string;
|
|
6
|
+
targetType: string;
|
|
7
|
+
targetId: string;
|
|
8
|
+
actorId?: string;
|
|
9
|
+
payload?: SupaCloudWorkflowJson;
|
|
10
|
+
maxAttempts?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface SupaCloudCommandReceipt {
|
|
13
|
+
commandId: string;
|
|
14
|
+
commandType: string;
|
|
15
|
+
targetType: string;
|
|
16
|
+
targetId: string;
|
|
17
|
+
actorId: string | null;
|
|
18
|
+
payloadFingerprint: string;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
idempotent: boolean;
|
|
21
|
+
workflow: SupaCloudWorkflowRun;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Service-role-only transactional command receipt client. Application-owned
|
|
25
|
+
* database RPCs can call `supacloud_commands.submit` directly inside a larger
|
|
26
|
+
* transaction when the domain write and durable enqueue must commit together.
|
|
27
|
+
*/
|
|
28
|
+
export declare class SupaCloudCommandsClient<TClient extends SupabaseClient = SupabaseClient> {
|
|
29
|
+
private readonly supabase;
|
|
30
|
+
constructor(supabase: TClient);
|
|
31
|
+
submit(request: SupaCloudCommandSubmitRequest): Promise<SupaCloudCommandReceipt>;
|
|
32
|
+
get(commandId: string): Promise<SupaCloudCommandReceipt | null>;
|
|
33
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
2
2
|
import { SupaCloudWorkflowsClient } from "./workflows.js";
|
|
3
|
+
import { SupaCloudCommandsClient } from "./commands.js";
|
|
4
|
+
import { SupaCloudArtifactsClient } from "./artifacts.js";
|
|
3
5
|
export { createSupaCloudOAuthFetch, type SupaCloudOAuthFetchOptions, } from "./auth-fetch.js";
|
|
4
6
|
export * from "./workflows.js";
|
|
7
|
+
export * from "./commands.js";
|
|
8
|
+
export * from "./artifacts.js";
|
|
5
9
|
export type SupaCloudTaskStatus = "pending" | "leased" | "running" | "retry_scheduled" | "succeeded" | "failed" | "dead_lettered" | "cancelled" | "queued" | "processing" | "completed";
|
|
6
10
|
export type SupaCloudTaskLogEntry = {
|
|
7
11
|
timestamp: string;
|
|
@@ -448,6 +452,8 @@ export declare function createSupaCloudClient<TClient extends SupabaseClient = S
|
|
|
448
452
|
};
|
|
449
453
|
tasks: SupaCloudTasksClient<TClient>;
|
|
450
454
|
workflows: SupaCloudWorkflowsClient<TClient>;
|
|
455
|
+
commands: SupaCloudCommandsClient<TClient>;
|
|
456
|
+
artifacts: SupaCloudArtifactsClient<TClient>;
|
|
451
457
|
supauth: SupaCloudSupAuthClient<TClient>;
|
|
452
458
|
queues: SupaCloudQueuesClient<TClient>;
|
|
453
459
|
queue: (name: string) => SupaCloudQueueClient<TClient>;
|
package/dist/index.js
CHANGED
|
@@ -1,42 +1,85 @@
|
|
|
1
|
+
// src/service-role-rpc.ts
|
|
2
|
+
async function invokeServiceRoleRpc(supabase, functionName, request) {
|
|
3
|
+
const rpcClient = supabase;
|
|
4
|
+
const { data: rpcResponse, error: rpcError } = await rpcClient.rpc(functionName, { request });
|
|
5
|
+
if (rpcError)
|
|
6
|
+
throw rpcError;
|
|
7
|
+
return rpcResponse;
|
|
8
|
+
}
|
|
9
|
+
|
|
1
10
|
// src/workflows.ts
|
|
2
11
|
class SupaCloudWorkflowsClient {
|
|
3
12
|
supabase;
|
|
4
13
|
constructor(supabase) {
|
|
5
14
|
this.supabase = supabase;
|
|
6
15
|
}
|
|
7
|
-
async invoke(functionName, request) {
|
|
8
|
-
const rpcClient = this.supabase;
|
|
9
|
-
const { data: rpcResponse, error: rpcError } = await rpcClient.rpc(functionName, { request });
|
|
10
|
-
if (rpcError)
|
|
11
|
-
throw rpcError;
|
|
12
|
-
return rpcResponse;
|
|
13
|
-
}
|
|
14
16
|
start(request) {
|
|
15
|
-
return this.
|
|
17
|
+
return invokeServiceRoleRpc(this.supabase, "supacloud_workflow_start", request);
|
|
16
18
|
}
|
|
17
19
|
claim(request) {
|
|
18
|
-
return this.
|
|
20
|
+
return invokeServiceRoleRpc(this.supabase, "supacloud_workflow_claim", request);
|
|
19
21
|
}
|
|
20
22
|
advance(request) {
|
|
21
|
-
return this.
|
|
23
|
+
return invokeServiceRoleRpc(this.supabase, "supacloud_workflow_advance", request);
|
|
22
24
|
}
|
|
23
25
|
complete(request) {
|
|
24
|
-
return this.
|
|
26
|
+
return invokeServiceRoleRpc(this.supabase, "supacloud_workflow_complete", request);
|
|
25
27
|
}
|
|
26
28
|
retry(request) {
|
|
27
|
-
return this.
|
|
29
|
+
return invokeServiceRoleRpc(this.supabase, "supacloud_workflow_retry", request);
|
|
28
30
|
}
|
|
29
31
|
fail(request) {
|
|
30
|
-
return this.
|
|
32
|
+
return invokeServiceRoleRpc(this.supabase, "supacloud_workflow_fail", request);
|
|
31
33
|
}
|
|
32
34
|
cancel(runId, reason) {
|
|
33
|
-
return this.
|
|
35
|
+
return invokeServiceRoleRpc(this.supabase, "supacloud_workflow_cancel", {
|
|
36
|
+
runId,
|
|
37
|
+
reason
|
|
38
|
+
});
|
|
34
39
|
}
|
|
35
40
|
get(runId) {
|
|
36
|
-
return this.
|
|
41
|
+
return invokeServiceRoleRpc(this.supabase, "supacloud_workflow_get", { runId });
|
|
37
42
|
}
|
|
38
43
|
events(runId, options = {}) {
|
|
39
|
-
return this.
|
|
44
|
+
return invokeServiceRoleRpc(this.supabase, "supacloud_workflow_events", {
|
|
45
|
+
runId,
|
|
46
|
+
...options
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/commands.ts
|
|
52
|
+
class SupaCloudCommandsClient {
|
|
53
|
+
supabase;
|
|
54
|
+
constructor(supabase) {
|
|
55
|
+
this.supabase = supabase;
|
|
56
|
+
}
|
|
57
|
+
submit(request) {
|
|
58
|
+
return invokeServiceRoleRpc(this.supabase, "supacloud_command_submit", request);
|
|
59
|
+
}
|
|
60
|
+
get(commandId) {
|
|
61
|
+
return invokeServiceRoleRpc(this.supabase, "supacloud_command_get", {
|
|
62
|
+
commandId
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/artifacts.ts
|
|
68
|
+
class SupaCloudArtifactsClient {
|
|
69
|
+
supabase;
|
|
70
|
+
constructor(supabase) {
|
|
71
|
+
this.supabase = supabase;
|
|
72
|
+
}
|
|
73
|
+
register(request) {
|
|
74
|
+
return invokeServiceRoleRpc(this.supabase, "supacloud_artifact_register", request);
|
|
75
|
+
}
|
|
76
|
+
get(artifactId) {
|
|
77
|
+
return invokeServiceRoleRpc(this.supabase, "supacloud_artifact_get", {
|
|
78
|
+
artifactId
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
link(request) {
|
|
82
|
+
return invokeServiceRoleRpc(this.supabase, "supacloud_artifact_link", request);
|
|
40
83
|
}
|
|
41
84
|
}
|
|
42
85
|
|
|
@@ -774,6 +817,8 @@ function createSupaCloudClient(options) {
|
|
|
774
817
|
const supauth = new SupaCloudSupAuthClient(normalized);
|
|
775
818
|
const queues = new SupaCloudQueuesClient(normalized);
|
|
776
819
|
const workflows2 = new SupaCloudWorkflowsClient(options.supabase);
|
|
820
|
+
const commands2 = new SupaCloudCommandsClient(options.supabase);
|
|
821
|
+
const artifacts2 = new SupaCloudArtifactsClient(options.supabase);
|
|
777
822
|
return {
|
|
778
823
|
supabase: options.supabase,
|
|
779
824
|
projectRef: normalized.projectRef,
|
|
@@ -784,6 +829,8 @@ function createSupaCloudClient(options) {
|
|
|
784
829
|
},
|
|
785
830
|
tasks,
|
|
786
831
|
workflows: workflows2,
|
|
832
|
+
commands: commands2,
|
|
833
|
+
artifacts: artifacts2,
|
|
787
834
|
supauth,
|
|
788
835
|
queues,
|
|
789
836
|
queue: (name) => new SupaCloudQueueClient(normalized, name),
|
|
@@ -793,9 +840,11 @@ function createSupaCloudClient(options) {
|
|
|
793
840
|
};
|
|
794
841
|
}
|
|
795
842
|
export {
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
843
|
+
SupaCloudApiError,
|
|
844
|
+
SupaCloudArtifactsClient,
|
|
845
|
+
SupaCloudCommandsClient,
|
|
799
846
|
SupaCloudTaskSubmitError,
|
|
800
|
-
|
|
847
|
+
SupaCloudWorkflowsClient,
|
|
848
|
+
createSupaCloudClient,
|
|
849
|
+
createSupaCloudOAuthFetch
|
|
801
850
|
};
|
package/dist/workflows.d.ts
CHANGED
|
@@ -117,7 +117,6 @@ export interface SupaCloudWorkflowEvent {
|
|
|
117
117
|
export declare class SupaCloudWorkflowsClient<TClient extends SupabaseClient = SupabaseClient> {
|
|
118
118
|
private readonly supabase;
|
|
119
119
|
constructor(supabase: TClient);
|
|
120
|
-
private invoke;
|
|
121
120
|
start(request: SupaCloudWorkflowStartRequest): Promise<SupaCloudWorkflowRun>;
|
|
122
121
|
claim(request: SupaCloudWorkflowClaimRequest): Promise<SupaCloudWorkflowClaimResult>;
|
|
123
122
|
advance(request: SupaCloudWorkflowAdvanceRequest): Promise<SupaCloudWorkflowRun>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supacloud/js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "Platform SDK for SupaCloud, built on top of supabase-js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@supabase/supabase-js": "^2.110.9"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@types/bun": "^1.
|
|
47
|
+
"@types/bun": "^1.4.0",
|
|
48
48
|
"@supabase/supabase-js": "^2.112.2",
|
|
49
49
|
"typescript": "^7.0.2"
|
|
50
50
|
}
|