@supacloud/js 0.34.1 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMPATIBILITY.md +84 -0
- package/LICENSE +202 -661
- package/NOTICE +8 -13
- package/REACTIVE.md +93 -0
- package/README.md +6 -0
- package/dist/api-error.d.mts +6 -0
- package/dist/{artifact-fetch.d.ts → artifact-fetch.d.cts} +1 -1
- package/dist/artifact-fetch.d.mts +6 -0
- package/dist/{artifact-link.d.ts → artifact-link.d.cts} +2 -2
- package/dist/artifact-link.d.mts +8 -0
- package/dist/{artifact-read.d.ts → artifact-read.d.cts} +2 -2
- package/dist/artifact-read.d.mts +13 -0
- package/dist/{artifact-register.d.ts → artifact-register.d.cts} +2 -2
- package/dist/artifact-register.d.mts +14 -0
- package/dist/{artifact-rpc.d.ts → artifact-rpc.d.cts} +1 -1
- package/dist/artifact-rpc.d.mts +2 -0
- package/dist/{artifacts.d.ts → artifacts.d.cts} +4 -4
- package/dist/artifacts.d.mts +53 -0
- package/dist/auth-fetch.d.mts +27 -0
- package/dist/bounded-rpc-fetch.d.mts +2 -0
- package/dist/{command-fetch.d.ts → command-fetch.d.cts} +1 -1
- package/dist/command-fetch.d.mts +6 -0
- package/dist/{commands.d.ts → commands.d.cts} +1 -1
- package/dist/commands.d.mts +44 -0
- package/dist/contracts.cjs +48 -0
- package/dist/contracts.d.mts +1 -0
- package/dist/index.cjs +3732 -0
- package/dist/{index.d.ts → index.d.cts} +20 -20
- package/dist/index.d.mts +360 -0
- package/dist/{oauth-clients.d.ts → oauth-clients.d.cts} +1 -1
- package/dist/oauth-clients.d.mts +95 -0
- package/dist/{oauth-server.d.ts → oauth-server.d.cts} +1 -1
- package/dist/oauth-server.d.mts +104 -0
- package/dist/{queue-rpc.d.ts → queue-rpc.d.cts} +1 -1
- package/dist/queue-rpc.d.mts +54 -0
- package/dist/reactive.cjs +119 -0
- package/dist/reactive.d.cts +26 -0
- package/dist/reactive.d.mts +26 -0
- package/dist/reactive.mjs +79 -0
- package/dist/{service-role-rpc.d.ts → service-role-rpc.d.cts} +1 -1
- package/dist/service-role-rpc.d.mts +2 -0
- package/dist/supabase-types.d.cts +9 -0
- package/dist/supabase-types.d.mts +9 -0
- package/dist/task-events.cjs +352 -0
- package/dist/task-events.d.mts +66 -0
- package/dist/{workflow-advance.d.ts → workflow-advance.d.cts} +2 -2
- package/dist/workflow-advance.d.mts +8 -0
- package/dist/{workflow-attempt.d.ts → workflow-attempt.d.cts} +1 -1
- package/dist/workflow-attempt.d.mts +4 -0
- package/dist/{workflow-cancel.d.ts → workflow-cancel.d.cts} +2 -2
- package/dist/workflow-cancel.d.mts +14 -0
- package/dist/{workflow-claim.d.ts → workflow-claim.d.cts} +2 -2
- package/dist/workflow-claim.d.mts +12 -0
- package/dist/{workflow-complete.d.ts → workflow-complete.d.cts} +2 -2
- package/dist/workflow-complete.d.mts +8 -0
- package/dist/{workflow-events.d.ts → workflow-events.d.cts} +2 -2
- package/dist/workflow-events.d.mts +14 -0
- package/dist/{workflow-fail.d.ts → workflow-fail.d.cts} +2 -2
- package/dist/workflow-fail.d.mts +8 -0
- package/dist/{workflow-fetch.d.ts → workflow-fetch.d.cts} +1 -1
- package/dist/workflow-fetch.d.mts +9 -0
- package/dist/workflow-json.d.mts +2 -0
- package/dist/{workflow-retry.d.ts → workflow-retry.d.cts} +2 -2
- package/dist/workflow-retry.d.mts +8 -0
- package/dist/{workflow-rpc.d.ts → workflow-rpc.d.cts} +1 -1
- package/dist/workflow-rpc.d.mts +6 -0
- package/dist/{workflow-run.d.ts → workflow-run.d.cts} +2 -2
- package/dist/workflow-run.d.mts +8 -0
- package/dist/{workflow-start.d.ts → workflow-start.d.cts} +2 -2
- package/dist/workflow-start.d.mts +8 -0
- package/dist/workflow-timestamp.d.mts +1 -0
- package/dist/{workflows.d.ts → workflows.d.cts} +10 -10
- package/dist/workflows.d.mts +141 -0
- package/package.json +54 -20
- /package/dist/{api-error.d.ts → api-error.d.cts} +0 -0
- /package/dist/{auth-fetch.d.ts → auth-fetch.d.cts} +0 -0
- /package/dist/{bounded-rpc-fetch.d.ts → bounded-rpc-fetch.d.cts} +0 -0
- /package/dist/{contracts.d.ts → contracts.d.cts} +0 -0
- /package/dist/{contracts.js → contracts.mjs} +0 -0
- /package/dist/{index.js → index.mjs} +0 -0
- /package/dist/{task-events.d.ts → task-events.d.cts} +0 -0
- /package/dist/{task-events.js → task-events.mjs} +0 -0
- /package/dist/{workflow-json.d.ts → workflow-json.d.cts} +0 -0
- /package/dist/{workflow-timestamp.d.ts → workflow-timestamp.d.cts} +0 -0
package/NOTICE
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
SupaCloud
|
|
2
2
|
Copyright 2025 SupaCloud Contributors
|
|
3
3
|
|
|
4
|
-
SupaCloud project-owned code in this revision is licensed under the
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
SupaCloud project-owned code in this revision is licensed under the Apache
|
|
5
|
+
License, Version 2.0 (Apache-2.0). The complete license is provided in
|
|
6
|
+
LICENSE.
|
|
7
7
|
|
|
8
8
|
This program is distributed without any warranty; without even the implied
|
|
9
9
|
warranty of merchantability or fitness for a particular purpose.
|
|
10
10
|
|
|
11
11
|
Third-party components, incorporated upstream code, and their copyright,
|
|
12
|
-
license and attribution notices retain their original terms. This notice
|
|
13
|
-
|
|
12
|
+
license and attribution notices retain their original terms. This notice does
|
|
13
|
+
not replace those terms or claim ownership of third-party work.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
in LICENSE-APACHE-2.0.txt. Retain any applicable upstream MIT notices as well.
|
|
19
|
-
|
|
20
|
-
Before publishing this licensing change, maintainers must confirm authority
|
|
21
|
-
to license the affected contributions and compatibility of incorporated
|
|
22
|
-
third-party code. This notice is not evidence of contributor consent.
|
|
15
|
+
Previously released SupaCloud versions retain the permissions granted with
|
|
16
|
+
those versions. See the historical license files and release notices where
|
|
17
|
+
applicable.
|
package/REACTIVE.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# SupaCloud JS reactive calls
|
|
2
|
+
|
|
3
|
+
RxJS is installed as a direct SDK dependency. Import the official adapters from
|
|
4
|
+
`@supacloud/js/reactive`; ordinary SDK and `/contracts` imports do not import RxJS.
|
|
5
|
+
There is no replacement client, proxy or new authentication path.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { createClient } from "@supabase/supabase-js";
|
|
9
|
+
import { createSupaCloudClient } from "@supacloud/js";
|
|
10
|
+
import { observeQuery, observeTask } from "@supacloud/js/reactive";
|
|
11
|
+
|
|
12
|
+
const supabase = createClient(projectUrl, publicKey);
|
|
13
|
+
const client = createSupaCloudClient({
|
|
14
|
+
supabase, projectRef, managementApiUrl,
|
|
15
|
+
// Supply getAccessToken only when using the existing configured identity flow.
|
|
16
|
+
});
|
|
17
|
+
const owner = new AbortController();
|
|
18
|
+
|
|
19
|
+
// Native data calls stay under client.supabase; generic row types and count survive.
|
|
20
|
+
const rows = observeQuery(signal => client.supabase
|
|
21
|
+
.from("widgets").select("id", { count: "exact" }).abortSignal(signal),
|
|
22
|
+
{ signal: owner.signal });
|
|
23
|
+
const rowsSubscription = rows.subscribe({
|
|
24
|
+
next: response => renderRows(response.data, response.count),
|
|
25
|
+
error: error => showQueryError(error),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// A write is submitted once, not every time the UI subscribes.
|
|
29
|
+
const receipt = await client.functions.invokeBackground("render", { body: input });
|
|
30
|
+
const progressSubscription = observeTask(receipt, { signal: owner.signal }).subscribe({
|
|
31
|
+
next: snapshot => renderProgress(snapshot),
|
|
32
|
+
error: error => showObservationError(error),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Component/connection shutdown stops observation, not the server-side task.
|
|
36
|
+
owner.abort();
|
|
37
|
+
rowsSubscription.unsubscribe();
|
|
38
|
+
progressSubscription.unsubscribe();
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The sample assumes application-provided URLs, public key, input and UI handlers;
|
|
42
|
+
never put a service-role key or management administrator credential in a browser.
|
|
43
|
+
Database/Auth/Storage calls remain on the original `client.supabase` instance.
|
|
44
|
+
Commands, workflow calls, task cancellation/retry and submission remain the
|
|
45
|
+
existing awaited SDK APIs. No methods or return types on that client are changed.
|
|
46
|
+
|
|
47
|
+
## Query contract
|
|
48
|
+
|
|
49
|
+
`observeQuery` takes a **factory**, not an already-started Promise. It accepts
|
|
50
|
+
Supabase's PromiseLike query builders and creates one read per subscriber. It
|
|
51
|
+
emits the original successful envelope, retaining `data`, `count`, `status` and
|
|
52
|
+
other fields; a non-null `error` is forwarded unchanged to RxJS `error()`.
|
|
53
|
+
Synchronous exceptions and rejected promises are also forwarded unchanged.
|
|
54
|
+
There is no retry, global cache or implicit sharing. Keep writes on native awaited
|
|
55
|
+
APIs, since subscribing twice to a write factory could execute the write twice.
|
|
56
|
+
|
|
57
|
+
Pass the supplied signal to `.abortSignal(signal)` or supported SDK options.
|
|
58
|
+
Unsubscribe aborts cooperative pending I/O and ignores late results. Owner-signal
|
|
59
|
+
abort completes observation. It cannot stop an operation that ignores that signal
|
|
60
|
+
or undo a committed write. Completed requests are not spuriously aborted.
|
|
61
|
+
|
|
62
|
+
## Task contract
|
|
63
|
+
|
|
64
|
+
Pass the receipt returned by `tasks.submit` / `submitTyped` or
|
|
65
|
+
`functions.invokeBackground`. The decoder and project binding remain on the
|
|
66
|
+
receipt. For an already-known task ID, adapt the existing subscriber without
|
|
67
|
+
creating a second client:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
const progress = observeTask({
|
|
71
|
+
subscribe: options => client.tasks.subscribe(taskId, options),
|
|
72
|
+
}, { signal: owner.signal });
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Each observer owns one existing SDK subscription. `stopOnTerminal` and optional
|
|
76
|
+
Realtime configuration are forwarded. Terminal statuses (including failed and
|
|
77
|
+
cancelled) are values, not transport errors; SDK close completes the stream.
|
|
78
|
+
Read/validation errors terminate observation without implicit resubmission.
|
|
79
|
+
Realtime connection failure can still fall back to SDK polling. No `public.tasks`
|
|
80
|
+
table is invented. Unsubscribe starts SDK cleanup and aborts its pending reads;
|
|
81
|
+
it does not synchronously await the SDK's asynchronous channel-removal operation.
|
|
82
|
+
|
|
83
|
+
## Durable output is intentionally different
|
|
84
|
+
|
|
85
|
+
Keep `@supacloud/js/task-events` and `for await ... of client.watch(...)` for
|
|
86
|
+
acknowledged output processing. Its `onCursor` advances only after the consumer
|
|
87
|
+
resumes the generator. RxJS `next()` and `subscribe(async ...)` do not await the
|
|
88
|
+
handler, so blindly applying `from(watch(...))` would acknowledge too early.
|
|
89
|
+
Do not use the progress snapshot adapter as an event journal or audit sink.
|
|
90
|
+
|
|
91
|
+
Use a release containing `/reactive`, or packed candidate packages during
|
|
92
|
+
repository acceptance. Existing deployed SDK versions do not gain this API
|
|
93
|
+
until upgraded.
|
package/README.md
CHANGED
|
@@ -694,3 +694,9 @@ files in the SDK checkout are neither read nor overwritten.
|
|
|
694
694
|
Dependency declaration failures remain failures. This check does not replace
|
|
695
695
|
Supabase declarations with stubs, patch ambient browser types or certify live
|
|
696
696
|
authentication behavior.
|
|
697
|
+
|
|
698
|
+
## Default reactive support
|
|
699
|
+
|
|
700
|
+
RxJS is provided by default. See [Reactive development](REACTIVE.md) for the
|
|
701
|
+
`/reactive` entry, SDK compatibility, cancellation and durable-output boundaries.
|
|
702
|
+
Ordinary Promise APIs and non-reactive entrypoints are unchanged.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type FetchTransport } from "./bounded-rpc-fetch.mjs";
|
|
2
|
+
export interface SupaCloudArtifactFetchOptions {
|
|
3
|
+
fetch?: FetchTransport;
|
|
4
|
+
}
|
|
5
|
+
/** Bound artifact RPC receipts without imposing limits on Storage file transfers. */
|
|
6
|
+
export declare function createSupaCloudArtifactFetch(options?: SupaCloudArtifactFetchOptions): FetchTransport;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SupaCloudApiError } from "./api-error.
|
|
2
|
-
import type { SupaCloudArtifact, SupaCloudArtifactLinkRequest } from "./artifacts.
|
|
1
|
+
import { SupaCloudApiError } from "./api-error.cjs";
|
|
2
|
+
import type { SupaCloudArtifact, SupaCloudArtifactLinkRequest } from "./artifacts.cjs";
|
|
3
3
|
export declare class SupaCloudArtifactLinkError extends SupaCloudApiError {
|
|
4
4
|
readonly mutationMayHaveApplied: boolean;
|
|
5
5
|
constructor(mutationMayHaveApplied?: boolean);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SupaCloudApiError } from "./api-error.mjs";
|
|
2
|
+
import type { SupaCloudArtifact, SupaCloudArtifactLinkRequest } from "./artifacts.mjs";
|
|
3
|
+
export declare class SupaCloudArtifactLinkError extends SupaCloudApiError {
|
|
4
|
+
readonly mutationMayHaveApplied: boolean;
|
|
5
|
+
constructor(mutationMayHaveApplied?: boolean);
|
|
6
|
+
}
|
|
7
|
+
export declare function captureArtifactLink(value: unknown): Required<SupaCloudArtifactLinkRequest>;
|
|
8
|
+
export declare function decodeArtifactLink(value: unknown, request: Required<SupaCloudArtifactLinkRequest>): SupaCloudArtifact;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SupaCloudApiError } from "./api-error.
|
|
2
|
-
import type { SupaCloudArtifact } from "./artifacts.
|
|
1
|
+
import { SupaCloudApiError } from "./api-error.cjs";
|
|
2
|
+
import type { SupaCloudArtifact } from "./artifacts.cjs";
|
|
3
3
|
export declare class SupaCloudArtifactReadError extends SupaCloudApiError {
|
|
4
4
|
readonly mutationMayHaveApplied = false;
|
|
5
5
|
constructor(input?: boolean);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SupaCloudApiError } from "./api-error.mjs";
|
|
2
|
+
import type { SupaCloudArtifact } from "./artifacts.mjs";
|
|
3
|
+
export declare class SupaCloudArtifactReadError extends SupaCloudApiError {
|
|
4
|
+
readonly mutationMayHaveApplied = false;
|
|
5
|
+
constructor(input?: boolean);
|
|
6
|
+
}
|
|
7
|
+
export declare function captureArtifactId(value: unknown): string;
|
|
8
|
+
export declare function artifactText(value: unknown, min?: number, max?: number): string;
|
|
9
|
+
export declare function artifactKey(value: unknown): string;
|
|
10
|
+
export declare function artifactTimestampMicros(value: string): bigint;
|
|
11
|
+
export declare function artifactSize(value: unknown): string;
|
|
12
|
+
export declare function artifactPath(value: unknown): string;
|
|
13
|
+
export declare function decodeArtifactRead(value: unknown, artifactId: string, allowIdempotent?: boolean): SupaCloudArtifact | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SupaCloudApiError } from "./api-error.
|
|
2
|
-
import type { SupaCloudArtifact, SupaCloudArtifactRegisterRequest } from "./artifacts.
|
|
1
|
+
import { SupaCloudApiError } from "./api-error.cjs";
|
|
2
|
+
import type { SupaCloudArtifact, SupaCloudArtifactRegisterRequest } from "./artifacts.cjs";
|
|
3
3
|
export declare class SupaCloudArtifactRegisterError extends SupaCloudApiError {
|
|
4
4
|
readonly mutationMayHaveApplied: boolean;
|
|
5
5
|
constructor(mutationMayHaveApplied?: boolean);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SupaCloudApiError } from "./api-error.mjs";
|
|
2
|
+
import type { SupaCloudArtifact, SupaCloudArtifactRegisterRequest } from "./artifacts.mjs";
|
|
3
|
+
export declare class SupaCloudArtifactRegisterError extends SupaCloudApiError {
|
|
4
|
+
readonly mutationMayHaveApplied: boolean;
|
|
5
|
+
constructor(mutationMayHaveApplied?: boolean);
|
|
6
|
+
}
|
|
7
|
+
type CapturedRegister = Omit<Required<SupaCloudArtifactRegisterRequest>, "sizeBytes" | "retentionUntil" | "createdBy"> & {
|
|
8
|
+
sizeBytes: string;
|
|
9
|
+
retentionUntil: string | null;
|
|
10
|
+
createdBy: string | null;
|
|
11
|
+
};
|
|
12
|
+
export declare function captureArtifactRegister(value: unknown): CapturedRegister;
|
|
13
|
+
export declare function decodeArtifactRegister(value: unknown, request: CapturedRegister): SupaCloudArtifact;
|
|
14
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SupabaseClient } from "
|
|
1
|
+
import type { SupabaseClient } from "./supabase-types.cjs";
|
|
2
2
|
export declare function invokeArtifactRpc(supabase: SupabaseClient, name: "supacloud_artifact_get" | "supacloud_artifact_register" | "supacloud_artifact_link", request: object, failure: () => Error): Promise<unknown>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { SupabaseClient } from "./supabase-types.mjs";
|
|
2
|
+
export declare function invokeArtifactRpc(supabase: SupabaseClient, name: "supacloud_artifact_get" | "supacloud_artifact_register" | "supacloud_artifact_link", request: object, failure: () => Error): Promise<unknown>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { SupabaseClient } from "
|
|
2
|
-
export { SupaCloudArtifactReadError } from "./artifact-read.
|
|
3
|
-
export { SupaCloudArtifactRegisterError } from "./artifact-register.
|
|
4
|
-
export { SupaCloudArtifactLinkError } from "./artifact-link.
|
|
1
|
+
import type { SupabaseClient } from "./supabase-types.cjs";
|
|
2
|
+
export { SupaCloudArtifactReadError } from "./artifact-read.cjs";
|
|
3
|
+
export { SupaCloudArtifactRegisterError } from "./artifact-register.cjs";
|
|
4
|
+
export { SupaCloudArtifactLinkError } from "./artifact-link.cjs";
|
|
5
5
|
export type SupaCloudArtifactJson = Record<string, unknown>;
|
|
6
6
|
export interface SupaCloudArtifactParent {
|
|
7
7
|
artifactId: string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { SupabaseClient } from "./supabase-types.mjs";
|
|
2
|
+
export { SupaCloudArtifactReadError } from "./artifact-read.mjs";
|
|
3
|
+
export { SupaCloudArtifactRegisterError } from "./artifact-register.mjs";
|
|
4
|
+
export { SupaCloudArtifactLinkError } from "./artifact-link.mjs";
|
|
5
|
+
export type SupaCloudArtifactJson = Record<string, unknown>;
|
|
6
|
+
export interface SupaCloudArtifactParent {
|
|
7
|
+
artifactId: string;
|
|
8
|
+
relationType: string;
|
|
9
|
+
metadata: SupaCloudArtifactJson;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
}
|
|
12
|
+
export interface SupaCloudArtifact {
|
|
13
|
+
artifactId: string;
|
|
14
|
+
bucketId: string;
|
|
15
|
+
objectPath: string;
|
|
16
|
+
objectVersion: string;
|
|
17
|
+
artifactType: string;
|
|
18
|
+
sha256: string;
|
|
19
|
+
sizeBytes: string;
|
|
20
|
+
mimeType: string;
|
|
21
|
+
metadata: SupaCloudArtifactJson;
|
|
22
|
+
retentionUntil: string | null;
|
|
23
|
+
createdBy: string | null;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
idempotent: boolean;
|
|
26
|
+
parents: SupaCloudArtifactParent[];
|
|
27
|
+
}
|
|
28
|
+
export interface SupaCloudArtifactRegisterRequest {
|
|
29
|
+
artifactId: string;
|
|
30
|
+
bucketId: string;
|
|
31
|
+
objectPath: string;
|
|
32
|
+
artifactType: string;
|
|
33
|
+
sha256: string;
|
|
34
|
+
sizeBytes: string | number;
|
|
35
|
+
mimeType: string;
|
|
36
|
+
metadata?: SupaCloudArtifactJson;
|
|
37
|
+
retentionUntil?: string;
|
|
38
|
+
createdBy?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface SupaCloudArtifactLinkRequest {
|
|
41
|
+
parentArtifactId: string;
|
|
42
|
+
childArtifactId: string;
|
|
43
|
+
relationType: string;
|
|
44
|
+
metadata?: SupaCloudArtifactJson;
|
|
45
|
+
}
|
|
46
|
+
/** Service-role-only immutable Storage artifact registry client. */
|
|
47
|
+
export declare class SupaCloudArtifactsClient<TClient extends SupabaseClient = SupabaseClient> {
|
|
48
|
+
private readonly supabase;
|
|
49
|
+
constructor(supabase: TClient);
|
|
50
|
+
register(request: SupaCloudArtifactRegisterRequest): Promise<SupaCloudArtifact>;
|
|
51
|
+
get(artifactId: string): Promise<SupaCloudArtifact | null>;
|
|
52
|
+
link(request: SupaCloudArtifactLinkRequest): Promise<SupaCloudArtifact>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type FetchTransport = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
2
|
+
export type SupaCloudOAuthFetchOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Public OAuth client identifier registered with SupAuth. Leave empty for a
|
|
5
|
+
* standard single-project Supabase deployment; the transport then becomes a
|
|
6
|
+
* transparent pass-through.
|
|
7
|
+
*/
|
|
8
|
+
clientId?: string | null;
|
|
9
|
+
/**
|
|
10
|
+
* OAuth token endpoint. When omitted, `/auth/v1/oauth/token` is derived from
|
|
11
|
+
* the Supabase Auth refresh URL origin.
|
|
12
|
+
*/
|
|
13
|
+
tokenEndpoint?: string;
|
|
14
|
+
/** Injectable transport for tests or runtimes with a custom fetch. */
|
|
15
|
+
fetch?: FetchTransport;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Adapts Supabase Auth's built-in refresh request to SupAuth's OAuth token
|
|
19
|
+
* contract while leaving every other supabase-js request untouched.
|
|
20
|
+
*
|
|
21
|
+
* Usage:
|
|
22
|
+
* createClient(authUrl, anonKey, {
|
|
23
|
+
* global: { fetch: createSupaCloudOAuthFetch({ clientId }) },
|
|
24
|
+
* });
|
|
25
|
+
*/
|
|
26
|
+
export declare function createSupaCloudOAuthFetch(options?: SupaCloudOAuthFetchOptions): FetchTransport;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type FetchTransport } from "./bounded-rpc-fetch.mjs";
|
|
2
|
+
export interface SupaCloudCommandFetchOptions {
|
|
3
|
+
fetch?: FetchTransport;
|
|
4
|
+
}
|
|
5
|
+
/** Install in Supabase's global.fetch to bound command responses before JSON parsing. */
|
|
6
|
+
export declare function createSupaCloudCommandFetch(options?: SupaCloudCommandFetchOptions): FetchTransport;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CommandLookup, type CommandStatus } from "@supacloud/contracts";
|
|
2
|
-
import { SupaCloudApiError } from "./api-error.
|
|
2
|
+
import { SupaCloudApiError } from "./api-error.cjs";
|
|
3
3
|
export declare class SupaCloudCommandReadError extends SupaCloudApiError {
|
|
4
4
|
readonly mutationMayHaveApplied = false;
|
|
5
5
|
constructor();
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type CommandLookup, type CommandStatus } from "@supacloud/contracts";
|
|
2
|
+
import { SupaCloudApiError } from "./api-error.mjs";
|
|
3
|
+
export declare class SupaCloudCommandReadError extends SupaCloudApiError {
|
|
4
|
+
readonly mutationMayHaveApplied = false;
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
export declare class SupaCloudCommandSubmitError extends SupaCloudApiError {
|
|
8
|
+
readonly mutationMayHaveApplied: boolean;
|
|
9
|
+
constructor(mutationMayHaveApplied?: boolean);
|
|
10
|
+
}
|
|
11
|
+
/** Narrow, validated boundary compatible with the Supabase RPC client. */
|
|
12
|
+
export interface CommandRpcClient {
|
|
13
|
+
rpc(functionName: string, args: {
|
|
14
|
+
request: object;
|
|
15
|
+
}): PromiseLike<{
|
|
16
|
+
data: unknown;
|
|
17
|
+
error: unknown;
|
|
18
|
+
status?: number;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
export interface SupaCloudCommandSubmitRequest {
|
|
22
|
+
commandId: string;
|
|
23
|
+
commandType: string;
|
|
24
|
+
targetType: string;
|
|
25
|
+
targetId: string;
|
|
26
|
+
actorId?: string;
|
|
27
|
+
/** Required, together with actorId, when binding a submission to a durable executor. */
|
|
28
|
+
tenantId?: string;
|
|
29
|
+
payload?: Record<string, unknown>;
|
|
30
|
+
maxAttempts?: number;
|
|
31
|
+
}
|
|
32
|
+
export type SupaCloudCommandReceipt = CommandStatus;
|
|
33
|
+
/**
|
|
34
|
+
* Service-role-only transactional command receipt client. Application-owned
|
|
35
|
+
* database RPCs can call `supacloud_commands.submit` directly inside a larger
|
|
36
|
+
* transaction when the domain write and durable enqueue must commit together.
|
|
37
|
+
*/
|
|
38
|
+
export declare class SupaCloudCommandsClient<TClient extends CommandRpcClient = CommandRpcClient> {
|
|
39
|
+
private readonly supabase;
|
|
40
|
+
constructor(supabase: TClient);
|
|
41
|
+
submit(request: SupaCloudCommandSubmitRequest): Promise<SupaCloudCommandReceipt>;
|
|
42
|
+
get(lookup: string | CommandLookup): Promise<SupaCloudCommandReceipt | null>;
|
|
43
|
+
private request;
|
|
44
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
8
|
+
var __toCommonJS = (from) => {
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
|
+
if (entry)
|
|
11
|
+
return entry;
|
|
12
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
__moduleCache.set(from, entry);
|
|
22
|
+
return entry;
|
|
23
|
+
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, {
|
|
32
|
+
get: all[name],
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/contracts.ts
|
|
40
|
+
var exports_contracts = {};
|
|
41
|
+
__export(exports_contracts, {
|
|
42
|
+
CommandAuthenticationError: () => import_client.CommandAuthenticationError,
|
|
43
|
+
createAuthenticatedFetch: () => import_client.createAuthenticatedFetch,
|
|
44
|
+
createAuthoritativeCommandClient: () => import_client.createAuthoritativeCommandClient,
|
|
45
|
+
createCommandScope: () => import_client.createCommandScope
|
|
46
|
+
});
|
|
47
|
+
module.exports = __toCommonJS(exports_contracts);
|
|
48
|
+
var import_client = require("@supacloud/contracts/client");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createAuthoritativeCommandClient, createAuthenticatedFetch, createCommandScope, CommandAuthenticationError, type AuthoritativeCommandContract, type AuthoritativeCommandOutcome, type AuthoritativeCommandTransport, type CommandAcknowledgement, type CommandDiagnostic, type CommandAttempt, type CommandScope, type SingleAttemptFetch, } from "@supacloud/contracts/client";
|