better-supabase 0.4.0 → 0.5.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/README.md +2 -0
- package/dist/channel-FQW-CnGR.d.ts +70 -0
- package/dist/cli/bin.js +1 -1
- package/dist/cli/codemod-DqV7612m.js +388 -0
- package/dist/cli/{config-D9R0o1LH.js → config-CPVpXP5I.js} +78 -8
- package/dist/cli/{config-SSKSTUl2.js → config-dtoekM0v.js} +1 -1
- package/dist/cli/{read-sets-CMa29t9a.js → diff-SjkO5rNr.js} +1 -220
- package/dist/cli/{dist-CFgGknmZ.js → dist-DBPdlPYK.js} +4 -4
- package/dist/cli/{dist-B1MvLv-M.js → dist-DreZ24Sz.js} +1 -1
- package/dist/cli/{dist-Du7VnEUG.js → dist-xn4wlboc.js} +112 -1
- package/dist/cli/{doctor-BOym3mbL.js → doctor-L7Z8mYTx.js} +531 -50
- package/dist/cli/{env-BZ0uy8XK.js → env-DmKv_G4A.js} +1 -1
- package/dist/cli/gen-BJc9vdyu.js +2 -0
- package/dist/cli/{gen-Ccn_p90L.js → gen-C2osRcr5.js} +283 -87
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +4 -4
- package/dist/cli/{init-ClnxRYBF.js → init-Saf5-R9T.js} +2 -2
- package/dist/cli/{introspect-DxqfkVIv.js → introspect--H7oGmcd.js} +2 -2
- package/dist/cli/{openapi-8WHjxiTJ.js → openapi-Cp5Fyta-.js} +1 -1
- package/dist/cli/read-sets-BfMQcKy8.js +289 -0
- package/dist/cli/{run-CP20LKk_.js → run-BKR2W_79.js} +16 -12
- package/dist/cli/{seed-5J6eu_Xg.js → seed-CUlqWh-8.js} +1 -1
- package/dist/cli/sql-DzPbfngx.js +348 -0
- package/dist/cli/{version-5mW_8sY1.js → version-BDJuO0UR.js} +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +3 -10
- package/dist/clone-BfgmLU90.js +21 -0
- package/dist/{compiler-DB3aSFOA.d.ts → compiler-BXH_aZ7N.d.ts} +2 -2
- package/dist/config/index.d.ts +4 -4
- package/dist/config/index.js +4 -4
- package/dist/{config-CbvFmGD8.js → config-DreERlKo.js} +1 -1
- package/dist/{config-C1CYcm6o.d.ts → config-T_ejwyd3.d.ts} +176 -11
- package/dist/{define-CRS2MRV3.d.ts → define-Bp_BZa5h.d.ts} +11 -7
- package/dist/{define-Bh0AqTik.js → define-cNKzqwL_.js} +202 -16
- package/dist/edge/index.d.ts +16 -5
- package/dist/edge/index.js +10 -7
- package/dist/{entitlements-Dm-FHpNH.d.ts → entitlements-DUxU4oHe.d.ts} +1 -1
- package/dist/env/index.d.ts +2 -2
- package/dist/env/index.js +34 -1
- package/dist/{errors-L0xK41y_.js → errors-DtwXa6b8.js} +1 -0
- package/dist/events/index.d.ts +3 -2
- package/dist/events/index.js +65 -12
- package/dist/events-aIO7vsIk.d.ts +230 -0
- package/dist/{result-CqEsbgYs.d.ts → executor-BunPOO-k.d.ts} +200 -1
- package/dist/{executor-CZ7ImRiD.d.ts → executor-Cghdstwu.d.ts} +1 -2
- package/dist/{executor-CVt6dD0B.js → executor-XycESQPH.js} +3 -3
- package/dist/hono/index.d.ts +17 -6
- package/dist/hono/index.js +40 -5
- package/dist/impersonation-VfaGc4Q_.js +41 -0
- package/dist/{index-BBdvo-5d.d.ts → index-BGdgBPdf.d.ts} +49 -6
- package/dist/{index-BhHEC04r.d.ts → index-C7f8cOBM.d.ts} +2 -2
- package/dist/{index-Dy6kuF0P.d.ts → index-CLg87OBW.d.ts} +6 -1
- package/dist/{index-D5IfUIDh.d.ts → index-DOESKG27.d.ts} +33 -8
- package/dist/{index-DFmOpBGC.d.ts → index-DgILJRXj.d.ts} +35 -9
- package/dist/{index-RlLXd8dL.d.ts → index-DmXSxbLi.d.ts} +4 -4
- package/dist/{index-Cf-D2jk1.d.ts → index-Dxn2a5cw.d.ts} +2 -2
- package/dist/{index-528Ugmyp.d.ts → index-SaTsEfGP.d.ts} +76 -8
- package/dist/{index-BAy4tsAP.d.ts → index-fag8VJZ2.d.ts} +3 -4
- package/dist/index.d.ts +30 -13
- package/dist/index.js +10 -9
- package/dist/jobs/index.d.ts +147 -101
- package/dist/jobs/index.js +744 -237
- package/dist/{json-schema-DP6V7cbr.js → json-schema-m1fiwKgN.js} +22 -1
- package/dist/kit-events-CTFDfSwb.js +60 -0
- package/dist/kit-transport-B82k1djG.d.ts +33 -0
- package/dist/kit-transport-DJlHQUBU.js +55 -0
- package/dist/{config-BpxDfnbg.js → kits-CGLLrNPd.js} +37 -9
- package/dist/list/index.d.ts +1 -1
- package/dist/{live-BHakSWWo.d.ts → live-D9W2M5aO.d.ts} +6 -5
- package/dist/mcp/index.d.ts +25 -8
- package/dist/mcp/index.js +23 -14
- package/dist/{mfa-C7MNQ1Ob.d.ts → mfa-CusDgPaD.d.ts} +5 -1
- package/dist/next/index.d.ts +31 -10
- package/dist/next/index.js +136 -27
- package/dist/notifications/index.d.ts +162 -0
- package/dist/notifications/index.js +264 -0
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +2 -2
- package/dist/orgs/index.d.ts +132 -0
- package/dist/orgs/index.js +245 -0
- package/dist/orpc/index.d.ts +28 -8
- package/dist/orpc/index.js +16 -3
- package/dist/otel/index.d.ts +21 -2
- package/dist/otel/index.js +50 -9
- package/dist/permdock-sql-C2Inc6Xc.d.ts +29 -0
- package/dist/permdock-sql-DgOfeixi.js +51 -0
- package/dist/plugin-DwARMuQp.js +59 -0
- package/dist/{plugin-bNhvJwRh.d.ts → plugin-o144f322.d.ts} +17 -5
- package/dist/plugins/actor/index.d.ts +5 -2
- package/dist/plugins/actor/index.js +22 -8
- package/dist/plugins/rules/index.d.ts +2 -2
- package/dist/plugins/rules/index.js +15 -10
- package/dist/plugins/soft-delete/index.d.ts +3 -3
- package/dist/plugins/soft-delete/index.js +14 -5
- package/dist/plugins/tenant/index.d.ts +2 -2
- package/dist/plugins/tenant/index.js +38 -20
- package/dist/plugins/timestamps/index.d.ts +1 -1
- package/dist/plugins/timestamps/index.js +4 -3
- package/dist/plugins/validation/index.d.ts +2 -2
- package/dist/plugins/validation/index.js +26 -6
- package/dist/{pool-DFwEQwmN.d.ts → pool-C9voM4Kw.d.ts} +17 -6
- package/dist/postgres/index.d.ts +5 -5
- package/dist/postgres/index.js +20 -11
- package/dist/{postgrest-Bc-0Xw62.d.ts → postgrest-CruYKAvV.d.ts} +1 -1
- package/dist/{problem-BihjPR0t.js → problem-BW1KhzSG.js} +2 -1
- package/dist/{problem-U8UEKccv.d.ts → problem-Blxe8S31.d.ts} +1 -1
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +3 -3
- package/dist/{query-BMMSWbI7.js → query-CCbo44lG.js} +2 -2
- package/dist/queue-BYUCjr59.d.ts +252 -0
- package/dist/react/index.d.ts +8 -7
- package/dist/react/index.js +4 -3
- package/dist/react/server.d.ts +14 -3
- package/dist/react/server.js +10 -2
- package/dist/react/session.d.ts +7 -1
- package/dist/react/session.js +9 -1
- package/dist/{react-CQHMaESR.js → react-C_s7kiNz.js} +103 -11
- package/dist/{read-set-FWK8qQ58.js → read-set-DQFt1N_Y.js} +22 -1
- package/dist/realtime/index.d.ts +3 -3
- package/dist/realtime/index.js +5 -4
- package/dist/{refresh-BwYkyNOQ.d.ts → refresh-BTrQ_ZTp.d.ts} +1 -1
- package/dist/{resolve-BAqQcwMW.d.ts → resolve-C15TJq77.d.ts} +11 -5
- package/dist/{resource-My_y-Syh.js → resource-CRxxwkQq.js} +22 -7
- package/dist/{resource-BJcaIfxi.d.ts → resource-D8iqWMr-.d.ts} +5 -5
- package/dist/respond-D2OQl62-.d.ts +371 -0
- package/dist/{result-Bj6yt33D.js → result-BKiliPY7.js} +1 -1
- package/dist/server/index.d.ts +14 -12
- package/dist/server/index.js +11 -17
- package/dist/{server-BA75B0mT.js → server-Csx2sRjg.js} +251 -34
- package/dist/{shared-DnoCdMDr.js → shared-D1dRUrAg.js} +16 -2
- package/dist/signers-Cc6r98SW.d.ts +162 -0
- package/dist/{simplify-Cqvfr9dj.js → simplify-_0oUKqCd.js} +4 -115
- package/dist/sql/index.d.ts +247 -10
- package/dist/sql/index.js +8590 -779
- package/dist/{sql-B34HU2DI.js → sql-Coh6n4cC.js} +9 -2
- package/dist/ssr/index.d.ts +4 -4
- package/dist/ssr/index.js +1 -2
- package/dist/{standard-BRyBGTtp.js → standard-D7r6dMUu.js} +6 -3
- package/dist/{standard-BsaCYQJc.d.ts → standard-J4YgMOLm.d.ts} +1 -1
- package/dist/{stats-C_YxA2r1.js → stats-Bqob3WqT.js} +4 -4
- package/dist/storage/index.d.ts +4 -4
- package/dist/storage/index.js +155 -26
- package/dist/support-DT-OhSxD.d.ts +88 -0
- package/dist/support-Dk6vdmEw.js +291 -0
- package/dist/support-view-Da5peKFg.d.ts +17 -0
- package/dist/support-view-g4YLBeqX.js +18 -0
- package/dist/{permdock-sql-C4KFzLc9.js → template-TxrGI5jR.js} +2 -31
- package/dist/{temporal-BwshQk0W.js → temporal-CVlIV2DZ.js} +17 -4
- package/dist/{temporal-required-CBNHT6ni.js → temporal-required-CAt4Dc9Z.js} +2 -2
- package/dist/testing/index.d.ts +100 -10
- package/dist/testing/index.js +336 -8
- package/dist/{types-DONv9SHN.d.ts → types-Dnf_wRDz.d.ts} +26 -3
- package/dist/user-change-CHFEUro1.js +49 -0
- package/dist/{webhooks-Bh_Jf_-l.js → verify-Ce49ETPz.js} +5 -5
- package/dist/{version-Bmf7_FzM.js → version-DM_Roffb.js} +1 -1
- package/dist/{view-B64o81wp.d.ts → view-BEf0diC5.d.ts} +8 -3
- package/dist/{mfa-byfjruR9.js → view-Bq64ki8-.js} +95 -38
- package/dist/webhooks/index.d.ts +135 -4
- package/dist/webhooks/index.js +588 -2
- package/dist/wire-D2dT86vi.js +35 -0
- package/package.json +16 -8
- package/schemas/config-v1.json +131 -1
- package/schemas/doctor-report-v1.json +10 -0
- package/skills/better-supabase/SKILL.md +9 -6
- package/skills/better-supabase/references/plugins.md +6 -3
- package/skills/better-supabase/references/troubleshooting.md +1 -0
- package/skills/better-supabase-api/SKILL.md +9 -2
- package/skills/better-supabase-api/references/adapters.md +11 -8
- package/skills/better-supabase-auth/SKILL.md +3 -0
- package/skills/better-supabase-auth/references/permdock.md +56 -11
- package/dist/cli/gen-D5cLCULx.js +0 -2
- package/dist/cli/sql-D4VbqmXi.js +0 -199
- package/dist/events-B21UOhvP.d.ts +0 -84
- package/dist/executor-B5IoUxLE.d.ts +0 -195
- package/dist/invalidate-CgxmRamI.js +0 -24
- package/dist/permdock-sql-DImJULY-.d.ts +0 -17
- package/dist/plugin-BqR6wKMB.js +0 -23
- package/dist/respond-DgIbdrt8.d.ts +0 -194
- package/dist/view-BrJI2LKp.js +0 -45
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { d as Generator } from "./config-
|
|
1
|
+
import { c as ClaimsMeta, j as SchemaMeta } from "./types-Dnf_wRDz.js";
|
|
2
|
+
import { d as Generator } from "./config-T_ejwyd3.js";
|
|
3
3
|
//#region src/core/claims.d.ts
|
|
4
4
|
declare const DEFAULT_CLAIMS: ClaimsMeta;
|
|
5
5
|
/** Where the active tenant is read from: the top-level claim, then `app_metadata`. */
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { a as BucketPolicyName, t as AccessBucketPolicy, x as PermdockBucketPolicy } from "./types-Dnf_wRDz.js";
|
|
3
|
+
import { _ as DbError, a as AsyncResult, u as Result } from "./executor-BunPOO-k.js";
|
|
4
|
+
import { g as RequestContext } from "./plugin-o144f322.js";
|
|
5
|
+
import { n as PermdockCatalog } from "./permdock-sql-C2Inc6Xc.js";
|
|
4
6
|
import { n as StoragePath, t as PathIn } from "./path-Cv__-OTj.js";
|
|
5
|
-
import { t as PermdockCatalog } from "./permdock-sql-DImJULY-.js";
|
|
6
7
|
import { n as TemplateValues, t as TemplateParams } from "./template-mbvlysOo.js";
|
|
7
8
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
8
9
|
//#region src/storage/bucket.d.ts
|
|
9
|
-
type BucketPolicy = BucketPolicyName | PermdockBucketPolicy;
|
|
10
|
+
type BucketPolicy = BucketPolicyName | PermdockBucketPolicy | AccessBucketPolicy;
|
|
10
11
|
interface BucketConfig<P extends string = string, Id extends string = string> {
|
|
11
12
|
/** Bucket id, e.g. `customer-logos`. */
|
|
12
13
|
readonly id: Id;
|
|
@@ -15,8 +16,11 @@ interface BucketConfig<P extends string = string, Id extends string = string> {
|
|
|
15
16
|
readonly public?: boolean;
|
|
16
17
|
/**
|
|
17
18
|
* Generated `storage.objects` policies. `tenant` and `owner` match a path
|
|
18
|
-
* segment against the JWT; `public` allows reads
|
|
19
|
-
* the
|
|
19
|
+
* segment against the JWT; `public` allows reads (on a `public: true`
|
|
20
|
+
* bucket the public URLs need no policy, so none is written and nobody can
|
|
21
|
+
* list the objects); `none` leaves access to
|
|
22
|
+
* the secret key; `{ permdock, scope }` calls PermDock's SQL helpers;
|
|
23
|
+
* `{ access }` calls the SQL kit's access contract (`tenant_ids_with`).
|
|
20
24
|
* Defaults to `none`.
|
|
21
25
|
*
|
|
22
26
|
* The helpers check role and scope only. Use `permdock` just for
|
|
@@ -29,13 +33,19 @@ interface BucketConfig<P extends string = string, Id extends string = string> {
|
|
|
29
33
|
readonly policy?: BucketPolicy;
|
|
30
34
|
/**
|
|
31
35
|
* PermDock's `permissions.catalog.json`. With it, a `permdock` policy
|
|
32
|
-
* naming a permission
|
|
36
|
+
* naming a permission without `rowConditions: false` (including one the
|
|
37
|
+
* catalog doesn't list) throws.
|
|
33
38
|
*/
|
|
34
39
|
readonly catalog?: PermdockCatalog;
|
|
35
40
|
/** `'5MiB'`, `'500KB'` or bytes. */
|
|
36
41
|
readonly fileSizeLimit?: string | number;
|
|
37
42
|
/** `['image/png', 'image/*']`. */
|
|
38
43
|
readonly allowedMimeTypes?: readonly string[];
|
|
44
|
+
/**
|
|
45
|
+
* The tenant segment. Set it and connected clients only touch paths whose
|
|
46
|
+
* `param` holds the caller's tenant: pass `{ context }` or `{ tenant }` to
|
|
47
|
+
* `connect()`, or `{ allTenants: true }` for cross-tenant admin work.
|
|
48
|
+
*/
|
|
39
49
|
readonly tenant?: {
|
|
40
50
|
/** Placeholder holding the tenant id. Defaults to `orgId`. */
|
|
41
51
|
readonly param?: string;
|
|
@@ -145,6 +155,8 @@ interface ActualBucket {
|
|
|
145
155
|
type StorageClient = Pick<SupabaseClient, "storage">;
|
|
146
156
|
interface BucketClient<P extends string, Id extends string = string> {
|
|
147
157
|
readonly bucket: Bucket<P, Id>;
|
|
158
|
+
/** The object path, checked against the template and, with `tenant`, the caller's tenant. */
|
|
159
|
+
path(target: ObjectTarget<P, Id>): Result<StoragePath<Id>>;
|
|
148
160
|
upload(target: ObjectTarget<P, Id>, body: UploadBody, options?: UploadOptions): AsyncResult<{
|
|
149
161
|
path: StoragePath<Id>;
|
|
150
162
|
}>;
|
|
@@ -186,6 +198,8 @@ interface Bucket<P extends string, Id extends string = string> {
|
|
|
186
198
|
* removes the objects it fills.
|
|
187
199
|
*/
|
|
188
200
|
readonly owner: string | undefined;
|
|
201
|
+
/** Placeholder connected clients check against the caller's tenant; set by `tenant`. */
|
|
202
|
+
readonly tenant: string | undefined;
|
|
189
203
|
readonly fileSizeLimit: number | undefined;
|
|
190
204
|
readonly allowedMimeTypes: readonly string[] | undefined;
|
|
191
205
|
path(values: TemplateValues<P>): StoragePath<Id>;
|
|
@@ -212,6 +226,17 @@ interface BucketConnectOptions {
|
|
|
212
226
|
* never cross users.
|
|
213
227
|
*/
|
|
214
228
|
readonly cacheSignedUrls?: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* The request context (`db.$context`, or what an adapter passes to
|
|
231
|
+
* `connect`). For a bucket with `tenant`, its tenant (`context.tenant`, the
|
|
232
|
+
* one `tenant()` resolved, or the `tenant.claim` claims) must fill the
|
|
233
|
+
* tenant segment of every path.
|
|
234
|
+
*/
|
|
235
|
+
readonly context?: RequestContext;
|
|
236
|
+
/** The tenant every path must hold, instead of reading it from `context`. */
|
|
237
|
+
readonly tenant?: string;
|
|
238
|
+
/** Skip the tenant check, for admin jobs that work across tenants. */
|
|
239
|
+
readonly allTenants?: boolean;
|
|
215
240
|
}
|
|
216
241
|
declare function parseSize(value: string | number): number;
|
|
217
242
|
/** Maps a Storage error (`StorageApiError`, fetch failures) to a `DbError`. */
|
|
@@ -233,4 +258,47 @@ declare function fromStorageError(raw: unknown, table?: string): DbError;
|
|
|
233
258
|
*/
|
|
234
259
|
declare function defineBucket<const P extends string, const Id extends string = string>(config: BucketConfig<P, Id>): Bucket<P, Id>;
|
|
235
260
|
//#endregion
|
|
236
|
-
|
|
261
|
+
//#region src/storage/presets.d.ts
|
|
262
|
+
/** The image types browsers display everywhere. */
|
|
263
|
+
declare const IMAGE_TYPES: readonly string[];
|
|
264
|
+
interface ImageBucketOptions<P extends string, Id extends string> {
|
|
265
|
+
readonly id?: Id;
|
|
266
|
+
/** The path template; keep the preset's placeholders the policy relies on. */
|
|
267
|
+
readonly path?: P;
|
|
268
|
+
/** Defaults to `true`: images load from their public URL without signing. */
|
|
269
|
+
readonly public?: boolean;
|
|
270
|
+
readonly fileSizeLimit?: string | number;
|
|
271
|
+
readonly allowedMimeTypes?: readonly string[];
|
|
272
|
+
/** Replaces the preset's policy. */
|
|
273
|
+
readonly policy?: BucketPolicy;
|
|
274
|
+
}
|
|
275
|
+
type AvatarBucketOptions<P extends string, Id extends string> = ImageBucketOptions<P, Id>;
|
|
276
|
+
interface OrgLogoBucketOptions<P extends string, Id extends string> extends ImageBucketOptions<P, Id> {
|
|
277
|
+
/**
|
|
278
|
+
* The permission that may upload, replace and delete a logo, checked
|
|
279
|
+
* through the access contract. Defaults to `organization.update`, the
|
|
280
|
+
* `organizations` module's update permission.
|
|
281
|
+
*/
|
|
282
|
+
readonly permission?: string;
|
|
283
|
+
/**
|
|
284
|
+
* The tenant segment connected clients are held to. `false` lets one
|
|
285
|
+
* client upload for any organization the policy allows. Defaults to
|
|
286
|
+
* `{ param: 'orgId' }`.
|
|
287
|
+
*/
|
|
288
|
+
readonly tenant?: BucketConfig["tenant"] | false;
|
|
289
|
+
}
|
|
290
|
+
declare const AVATAR_PATH = "{userId}/avatar-{version}.{ext}";
|
|
291
|
+
declare const LOGO_PATH = "{orgId}/logo-{version}.{ext}";
|
|
292
|
+
/**
|
|
293
|
+
* A bucket for profile pictures: `{userId}/avatar-{version}.{ext}`, public,
|
|
294
|
+
* 2 MiB of images, written only by their owner (the `owner` policy).
|
|
295
|
+
*/
|
|
296
|
+
declare function avatarBucket<const P extends string = typeof AVATAR_PATH, const Id extends string = "avatars">(options?: AvatarBucketOptions<P, Id>): Bucket<P, Id>;
|
|
297
|
+
/**
|
|
298
|
+
* A bucket for organization logos: `{orgId}/logo-{version}.{ext}`, public,
|
|
299
|
+
* 2 MiB of images, written by members with the update permission through
|
|
300
|
+
* the access contract (`tenant_ids_with`), so it follows the app's roles.
|
|
301
|
+
*/
|
|
302
|
+
declare function orgLogoBucket<const P extends string = typeof LOGO_PATH, const Id extends string = "organization-logos">(options?: OrgLogoBucketOptions<P, Id>): Bucket<P, Id>;
|
|
303
|
+
//#endregion
|
|
304
|
+
export { parseSize as A, TransformOptions as C, UrlOptions as D, UploadOptions as E, defineBucket as O, TTL as S, UploadBody as T, Reservation as _, avatarBucket as a, SweepOptions as b, Bucket as c, BucketConnectOptions as d, BucketDrift as f, ReplaceResult as g, ReplaceOptions as h, OrgLogoBucketOptions as i, fromStorageError as k, BucketClient as l, ObjectTarget as m, IMAGE_TYPES as n, orgLogoBucket as o, BucketPolicy as p, ImageBucketOptions as r, ActualBucket as s, AvatarBucketOptions as t, BucketConfig as u, StorageClient as v, TtlPreset as w, SweepResult as x, StoredObject as y };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { C as FindExt, Ct as WhereInput, O as RepositoryOf, T as OffsetPageArgs, _ as CursorPage, dt as IncludeArg, gt as OrderByArg, t as BetterSupabase, v as CursorPageArgs, vt as Payload, w as OffsetPage, xt as SelectArg } from "./define-CRS2MRV3.js";
|
|
1
|
+
import { P as TableKey, k as Row, n as AnyFunctions, r as AnyModels } from "./types-Dnf_wRDz.js";
|
|
2
|
+
import { I as CountMode, a as AsyncResult, w as ValidationIssue } from "./executor-BunPOO-k.js";
|
|
3
|
+
import { C as FindExt, Ct as WhereInput, O as RepositoryOf, T as OffsetPageArgs, _ as CursorPage, dt as IncludeArg, gt as OrderByArg, t as BetterSupabase, v as CursorPageArgs, vt as Payload, w as OffsetPage, xt as SelectArg } from "./define-Bp_BZa5h.js";
|
|
5
4
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
5
|
//#region src/list/list-query.d.ts
|
|
7
6
|
/** Facet value meaning "not set": filters with `is null`. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { C as
|
|
3
|
-
import {
|
|
4
|
-
import { a as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { n as
|
|
8
|
-
import { a as compilePostgrest, i as PostgrestPlan, n as PlanLimit, r as PlanOrder, t as PlanFilter } from "./postgrest-Bc-0Xw62.js";
|
|
1
|
+
import { A as Schema, C as PrimaryKeyColumn, D as RelationTypes, E as RelationMeta, F as TableMeta, I as UniqueConstraint, L as UniqueKeyName, M as Simplify, N as TableFlags, O as Relations, P as TableKey, R as UniqueWhere, S as PermdockTopicPolicy, T as RealtimeTableMeta, _ as Insert, a as BucketPolicyName, b as ModelsOf, c as ClaimsMeta, d as DatabaseOf, f as Flags, g as FunctionsOf, h as FunctionTypes, i as BucketMeta, j as SchemaMeta, k as Row, l as Codec, m as FunctionMeta, n as AnyFunctions, o as Casing, p as ForeignKeyConstraint, r as AnyModels, s as CheckConstraint, t as AccessBucketPolicy, u as ColumnMeta, v as ModelFlags, w as PrimaryKeyValue, x as PermdockBucketPolicy, y as ModelTypes, z as Update } from "./types-Dnf_wRDz.js";
|
|
2
|
+
import { $ as or, A as mapDbError, B as InsertOp, C as RawDbError, D as isConflict, E as isCheck, F as Condition, G as Quantifier, H as MutationOp, I as CountMode, J as Selection, K as SelectColumn, L as DeleteOp, M as AggregateFn, N as Aggregation, O as isDbError, P as ColumnOp, Q as not, R as FunctionSource, S as ErrorMapper, T as dbError, U as Operation, V as Measure, W as OrderTerm, X as and, Y as UpdateOp, Z as column, _ as DbError, a as AsyncResult, b as DbErrorOf, c as Err, f as err, g as toDbError, h as toBetterResult, i as RpcContext, j as statusOf, k as isForeignKey, l as Ok, m as ok, n as ExecuteResult, o as BetterResultApi, p as fromBetterResult, q as SelectOp, r as Executor, s as BetterResultValue, t as ExecuteContext, u as Result, v as DbErrorKind, w as ValidationIssue, x as DbException, y as DbErrorKinds, z as Include } from "./executor-BunPOO-k.js";
|
|
3
|
+
import { D as consoleLogger, E as Logger, O as silentLogger, T as LogFields, _ as KitEventType, a as EventHub, c as QueryEvent, i as EventHandler, l as RefreshEvent, m as KitEventMap, n as BetterSupabaseEvents, o as EventName, p as KitEvent, r as ErrorEvent, s as MutationNotice, t as AuthEvent, u as RpcNotice } from "./events-aIO7vsIk.js";
|
|
4
|
+
import { $ as Specs, A as RpcOptions, B as ReadSet, C as FindExt, Ct as WhereInput, D as Repository, E as PageOf, F as EMPTY_STATS, G as ReadSetParams, H as ReadSetParamType, I as StatsRecorder, J as isReadSet, K as ReadSetResult, L as recordStats, M as UpsertArgs, N as WriteArgs, O as RepositoryOf, P as DbStats, Q as ReadMethod, R as SearchArgs, S as DeleteExt, St as SortDirection, T as OffsetPageArgs, U as ReadSetParamTypes, V as ReadSetOptions, W as ReadSetParamValue, X as InferResult, Y as readSetTables, Z as QuerySpec, _ as CursorPage, _t as OrderByInput, a as defineSupabase, at as AggregateRow, b as DbHelpers, bt as RelationMeasureArg, c as postgrestExecutor, ct as FieldFilter, d as MemoryCache, dt as IncludeArg, et as TableSpecs, f as cacheTargetOf, ft as IncludeArgs, g as ConflictTarget, gt as OrderByArg, h as rpcCacheTargets, ht as NumericMeasureArg, i as SupabaseOptions, it as AggregateResult, j as UpdateArgs, k as Returned, l as CacheAdapter, lt as FindFirstArgs, m as rowKey, mt as MeasureKey, n as ConnectOptions, nt as specTables, o as PostgrestClientLike, ot as CountArg, p as memoryCache, pt as MeasureArg, q as defineReadSet, r as RpcDefinition, rt as AggregateArgs, s as explainPostgrest, st as CountArgs, t as BetterSupabase, tt as isQuerySpec, u as CacheTarget, ut as FindManyArgs, v as CursorPageArgs, vt as Payload, w as OffsetPage, x as DeleteArgs, xt as SelectArg, y as Db, yt as ReadArgs, z as InferReadSetParams } from "./define-Bp_BZa5h.js";
|
|
5
|
+
import { _ as WithExtension, a as ExtensionOf, c as MutationEvent, d as NoExtension, f as PLUGIN_API_VERSION, g as RequestContext, h as RepositoryExtension, i as CallOptions, l as MutationIntent, m as RepositoryApi, n as AnyPlugin, o as HasFlag, p as Plugin, r as ApplyExtension, s as HookArgs, t as Actor, u as MutationKind, v as definePlugin } from "./plugin-o144f322.js";
|
|
6
|
+
import { n as validate, t as StandardSchemaV1 } from "./standard-J4YgMOLm.js";
|
|
7
|
+
import { a as compilePostgrest, i as PostgrestPlan, n as PlanLimit, r as PlanOrder, t as PlanFilter } from "./postgrest-CruYKAvV.js";
|
|
9
8
|
import { n as StoragePath } from "./path-Cv__-OTj.js";
|
|
10
|
-
import { n as postgrestCompiler, t as Compiler } from "./compiler-
|
|
11
|
-
import { a as ProblemResponseOptions, c as problemResponse, i as ProblemOptions, l as toProblem, n as PROBLEM_TYPE_BASE, o as fromProblem, r as ProblemDetails, s as isProblem, t as PROBLEM_CONTENT_TYPE } from "./problem-
|
|
9
|
+
import { n as postgrestCompiler, t as Compiler } from "./compiler-BXH_aZ7N.js";
|
|
10
|
+
import { a as ProblemResponseOptions, c as problemResponse, i as ProblemOptions, l as toProblem, n as PROBLEM_TYPE_BASE, o as fromProblem, r as ProblemDetails, s as isProblem, t as PROBLEM_CONTENT_TYPE } from "./problem-Blxe8S31.js";
|
|
12
11
|
import { t as SPEC_PINS } from "./spec-pins-CqorWDnO.js";
|
|
13
12
|
//#region src/core/define-repository.d.ts
|
|
14
13
|
/** Adds `Methods` to the repository of `Table` only. */
|
|
@@ -43,6 +42,22 @@ export declare function touchedTables(op: Operation): string[];
|
|
|
43
42
|
*/
|
|
44
43
|
export declare function invalidationTargets(meta: SchemaMeta, table: string): readonly string[];
|
|
45
44
|
//#endregion
|
|
45
|
+
//#region src/core/policy.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* A callback that decides something a kit would otherwise allow or refuse
|
|
48
|
+
* by default: `authorize`, `canInvite`, `shouldDeliver`, `allowUrl`. Only
|
|
49
|
+
* `true` allows; `false`, any other value, a throw or a rejection denies.
|
|
50
|
+
*/
|
|
51
|
+
type Policy<A extends readonly unknown[]> = (...args: A) => boolean | PromiseLike<boolean>;
|
|
52
|
+
type PolicyDecision = {
|
|
53
|
+
readonly allowed: true;
|
|
54
|
+
} | {
|
|
55
|
+
readonly allowed: false;
|
|
56
|
+
/** `denied`: the policy returned something other than `true`. `threw`: it threw or rejected. */
|
|
57
|
+
readonly reason: "denied" | "threw";
|
|
58
|
+
readonly cause?: unknown;
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
46
61
|
//#region src/core/cursor.d.ts
|
|
47
62
|
/** Opaque, URL-safe keyset cursor. */
|
|
48
63
|
export declare function encodeCursor(values: readonly unknown[]): string;
|
|
@@ -71,11 +86,13 @@ type EnrichDatabase<D, O> = { [S in keyof D]: S extends keyof O ? EnrichSchema<D
|
|
|
71
86
|
export declare function escapeLike(value: string): string;
|
|
72
87
|
//#endregion
|
|
73
88
|
//#region src/ir/codec.d.ts
|
|
74
|
-
/** Wire form of an app value: Temporal values to ISO text, `bigint` to decimal text. */
|
|
75
|
-
export declare function encodeValue(value: unknown): unknown;
|
|
76
89
|
/** Applies column codecs to returned rows, including embedded relations. */
|
|
77
90
|
export declare function decodeRows(selection: Selection | undefined, rows: readonly Record<string, unknown>[], checked?: boolean): Record<string, unknown>[];
|
|
78
91
|
//#endregion
|
|
92
|
+
//#region src/ir/wire.d.ts
|
|
93
|
+
/** Wire form of an app value: Temporal values to ISO text, `bigint` to decimal text. */
|
|
94
|
+
export declare function encodeValue(value: unknown): unknown;
|
|
95
|
+
//#endregion
|
|
79
96
|
//#region src/ir/scope.d.ts
|
|
80
97
|
/** Returns the filter that always applies to rows of `table`, if any. */
|
|
81
98
|
type ScopeFor = (table: TableMeta) => Condition | undefined;
|
|
@@ -107,4 +124,4 @@ export declare function toCamel(name: string): string;
|
|
|
107
124
|
/** `firstName` to `first_name`. */
|
|
108
125
|
export declare function toSnake(name: string): string;
|
|
109
126
|
//#endregion
|
|
110
|
-
export { type Actor, type AggregateArgs, type AggregateFn, type AggregateResult, type AggregateRow, type Aggregation, type AnyFunctions, type AnyModels, type AnyPlugin, type ApplyExtension, AsyncResult, type AuthEvent, type BetterResultApi, type BetterResultValue, BetterSupabase, type BetterSupabaseEvents, type BucketMeta, type BucketPolicyName, type CacheAdapter, type CacheTarget, type CallOptions, type Casing, type CheckConstraint, type ClaimsMeta, type Codec, type ColumnMeta, type ColumnOp, type Compiler, type Condition, type ConflictTarget, type ConnectOptions, type CountArg, type CountArgs, type CountMode, type CursorPage, type CursorPageArgs, type DatabaseOf, type Db, type DbError, type DbErrorKind, type DbErrorKinds, type DbErrorOf, DbException, type DbHelpers, type DbStats, type DeleteArgs, type DeleteExt, type DeleteOp, EMPTY_STATS, type EnrichDatabase, type Err, type ErrorEvent, type ErrorMapper, type EventHandler, EventHub, type EventName, type ExecuteContext, type ExecuteResult, type Executor, type ExtensionOf, type FieldFilter, type FindExt, type FindFirstArgs, type FindManyArgs, type Flags, type ForeignKeyConstraint, type FunctionMeta, type FunctionSource, type FunctionTypes, type FunctionsOf, type HasFlag, type HookArgs, type Include, type IncludeArg, type IncludeArgs, type InferReadSetParams, type InferResult, type Insert, type InsertOp, type LogFields, type Logger, type Measure, type MeasureArg, type MeasureKey, type MemoryCache, type ModelFlags, type ModelTypes, type ModelsOf, type MutationEvent, type MutationKind, type MutationNotice, type MutationOp, type NoExtension, type NumericMeasureArg, type OffsetPage, type OffsetPageArgs, type Ok, type Operation, type OrderByArg, type OrderByInput, type OrderTerm, PLUGIN_API_VERSION, PROBLEM_CONTENT_TYPE, PROBLEM_TYPE_BASE, type PageOf, type Payload, type PermdockBucketPolicy, type PermdockTopicPolicy, type PlanFilter, type PlanLimit, type PlanOrder, type Plugin, type PostgrestClientLike, type PostgrestPlan, type PrimaryKeyColumn, type PrimaryKeyValue, type ProblemDetails, type ProblemOptions, type ProblemResponseOptions, type Quantifier, type QueryEvent, type QuerySpec, type RawDbError, type ReadArgs, type ReadMethod, type ReadSet, type ReadSetOptions, type ReadSetParamType, type ReadSetParamTypes, type ReadSetParamValue, type ReadSetParams, type ReadSetResult, type RealtimeTableMeta, type RefreshEvent, type RelationMeasureArg, type RelationMeta, type RelationTypes, type Relations, type Repository, type RepositoryApi, type RepositoryExtension, type RepositoryOf, type RequestContext, type Result, type Returned, type Row, type RpcContext, type RpcDefinition, type RpcNotice, type RpcOptions, SPEC_PINS, type Schema, type SchemaMeta, type ScopeFor, type SearchArgs, type SelectArg, type SelectColumn, type SelectOp, type Selection, type Simplify, type SortDirection, type Specs, type StandardSchemaV1, StatsRecorder, type StoragePath, type SupabaseOptions, type TableFlags, type TableKey, type TableMeta, type TableRepositoryExtension, type TableSpecs, type UniqueConstraint, type UniqueKeyName, type UniqueWhere, type Update, type UpdateArgs, type UpdateOp, type UpsertArgs, type ValidationIssue, type WhereInput, type WithExtension, type WriteArgs, and, cacheTargetOf, column, compilePostgrest, consoleLogger, dbError, definePlugin, defineReadSet, defineSupabase, err, explainPostgrest, fromBetterResult, fromProblem, isCheck, isConflict, isDbError, isForeignKey, isProblem, isQuerySpec, isReadSet, mapDbError, memoryCache, not, ok, or, postgrestCompiler, postgrestExecutor, problemResponse, readSetTables, recordStats, rowKey, rpcCacheTargets, silentLogger, specTables, statusOf, toBetterResult, toDbError, toProblem, validate };
|
|
127
|
+
export { type AccessBucketPolicy, type Actor, type AggregateArgs, type AggregateFn, type AggregateResult, type AggregateRow, type Aggregation, type AnyFunctions, type AnyModels, type AnyPlugin, type ApplyExtension, AsyncResult, type AuthEvent, type BetterResultApi, type BetterResultValue, BetterSupabase, type BetterSupabaseEvents, type BucketMeta, type BucketPolicyName, type CacheAdapter, type CacheTarget, type CallOptions, type Casing, type CheckConstraint, type ClaimsMeta, type Codec, type ColumnMeta, type ColumnOp, type Compiler, type Condition, type ConflictTarget, type ConnectOptions, type CountArg, type CountArgs, type CountMode, type CursorPage, type CursorPageArgs, type DatabaseOf, type Db, type DbError, type DbErrorKind, type DbErrorKinds, type DbErrorOf, DbException, type DbHelpers, type DbStats, type DeleteArgs, type DeleteExt, type DeleteOp, EMPTY_STATS, type EnrichDatabase, type Err, type ErrorEvent, type ErrorMapper, type EventHandler, EventHub, type EventName, type ExecuteContext, type ExecuteResult, type Executor, type ExtensionOf, type FieldFilter, type FindExt, type FindFirstArgs, type FindManyArgs, type Flags, type ForeignKeyConstraint, type FunctionMeta, type FunctionSource, type FunctionTypes, type FunctionsOf, type HasFlag, type HookArgs, type Include, type IncludeArg, type IncludeArgs, type InferReadSetParams, type InferResult, type Insert, type InsertOp, type KitEvent, type KitEventMap, type KitEventType, type LogFields, type Logger, type Measure, type MeasureArg, type MeasureKey, type MemoryCache, type ModelFlags, type ModelTypes, type ModelsOf, type MutationEvent, type MutationIntent, type MutationKind, type MutationNotice, type MutationOp, type NoExtension, type NumericMeasureArg, type OffsetPage, type OffsetPageArgs, type Ok, type Operation, type OrderByArg, type OrderByInput, type OrderTerm, PLUGIN_API_VERSION, PROBLEM_CONTENT_TYPE, PROBLEM_TYPE_BASE, type PageOf, type Payload, type PermdockBucketPolicy, type PermdockTopicPolicy, type PlanFilter, type PlanLimit, type PlanOrder, type Plugin, type Policy, type PolicyDecision, type PostgrestClientLike, type PostgrestPlan, type PrimaryKeyColumn, type PrimaryKeyValue, type ProblemDetails, type ProblemOptions, type ProblemResponseOptions, type Quantifier, type QueryEvent, type QuerySpec, type RawDbError, type ReadArgs, type ReadMethod, type ReadSet, type ReadSetOptions, type ReadSetParamType, type ReadSetParamTypes, type ReadSetParamValue, type ReadSetParams, type ReadSetResult, type RealtimeTableMeta, type RefreshEvent, type RelationMeasureArg, type RelationMeta, type RelationTypes, type Relations, type Repository, type RepositoryApi, type RepositoryExtension, type RepositoryOf, type RequestContext, type Result, type Returned, type Row, type RpcContext, type RpcDefinition, type RpcNotice, type RpcOptions, SPEC_PINS, type Schema, type SchemaMeta, type ScopeFor, type SearchArgs, type SelectArg, type SelectColumn, type SelectOp, type Selection, type Simplify, type SortDirection, type Specs, type StandardSchemaV1, StatsRecorder, type StoragePath, type SupabaseOptions, type TableFlags, type TableKey, type TableMeta, type TableRepositoryExtension, type TableSpecs, type UniqueConstraint, type UniqueKeyName, type UniqueWhere, type Update, type UpdateArgs, type UpdateOp, type UpsertArgs, type ValidationIssue, type WhereInput, type WithExtension, type WriteArgs, and, cacheTargetOf, column, compilePostgrest, consoleLogger, dbError, definePlugin, defineReadSet, defineSupabase, err, explainPostgrest, fromBetterResult, fromProblem, isCheck, isConflict, isDbError, isForeignKey, isProblem, isQuerySpec, isReadSet, mapDbError, memoryCache, not, ok, or, postgrestCompiler, postgrestExecutor, problemResponse, readSetTables, recordStats, rowKey, rpcCacheTargets, silentLogger, specTables, statusOf, toBetterResult, toDbError, toProblem, validate };
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { a as isConflict, c as mapDbError, i as isCheck, l as statusOf, n as dbError, o as isDbError, s as isForeignKey, t as DbException } from "./errors-
|
|
2
|
-
import { i as escapeLike,
|
|
1
|
+
import { a as isConflict, c as mapDbError, i as isCheck, l as statusOf, n as dbError, o as isDbError, s as isForeignKey, t as DbException } from "./errors-DtwXa6b8.js";
|
|
2
|
+
import { i as escapeLike, o as defineSchema, s as tableMeta, t as simplify } from "./simplify-_0oUKqCd.js";
|
|
3
3
|
import { i as or, n as column, r as not, t as and } from "./types-6cYK9pbJ.js";
|
|
4
|
-
import {
|
|
5
|
-
import { a as
|
|
4
|
+
import { r as encodeValue } from "./wire-D2dT86vi.js";
|
|
5
|
+
import { a as toBetterResult, i as ok, n as err, o as toDbError, r as fromBetterResult, t as AsyncResult } from "./result-BKiliPY7.js";
|
|
6
|
+
import { a as decodeRows, c as memoryCache, i as encodeCursor, l as rowKey, n as defineSupabase, o as EventHub, r as decodeCursor, s as cacheTargetOf, t as BetterSupabase, u as rpcCacheTargets } from "./define-cNKzqwL_.js";
|
|
6
7
|
import { n as touchedTables, t as invalidationTargets } from "./tables-Cb-3_VWc.js";
|
|
7
8
|
import { n as silentLogger, t as consoleLogger } from "./logger-glM28NVN.js";
|
|
8
|
-
import {
|
|
9
|
-
import { a as postgrestExecutor, i as explainPostgrest, n as StatsRecorder, o as compilePostgrest, r as recordStats, t as EMPTY_STATS } from "./stats-
|
|
10
|
-
import { c as readSetTables, d as isQuerySpec, f as specTables, i as defineReadSet, o as isReadSet } from "./read-set-
|
|
11
|
-
import { t as validate } from "./standard-
|
|
12
|
-
import { a as problemResponse, i as isProblem, n as PROBLEM_TYPE_BASE, o as toProblem, r as fromProblem, t as PROBLEM_CONTENT_TYPE } from "./problem-
|
|
9
|
+
import { r as definePlugin, t as PLUGIN_API_VERSION } from "./plugin-DwARMuQp.js";
|
|
10
|
+
import { a as postgrestExecutor, i as explainPostgrest, n as StatsRecorder, o as compilePostgrest, r as recordStats, t as EMPTY_STATS } from "./stats-Bqob3WqT.js";
|
|
11
|
+
import { c as readSetTables, d as isQuerySpec, f as specTables, i as defineReadSet, o as isReadSet } from "./read-set-DQFt1N_Y.js";
|
|
12
|
+
import { t as validate } from "./standard-D7r6dMUu.js";
|
|
13
|
+
import { a as problemResponse, i as isProblem, n as PROBLEM_TYPE_BASE, o as toProblem, r as fromProblem, t as PROBLEM_CONTENT_TYPE } from "./problem-BW1KhzSG.js";
|
|
13
14
|
import { t as SPEC_PINS } from "./spec-pins-C3oc-Tdp.js";
|
|
14
15
|
import { n as scopeOperation, r as scopeSelection, t as scopeCondition } from "./scope-CDHcS7dE.js";
|
|
15
16
|
//#region src/core/define-repository.ts
|
package/dist/jobs/index.d.ts
CHANGED
|
@@ -1,108 +1,34 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import {
|
|
3
|
-
import { t as SqlClient } from "../executor-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
readonly payload: P;
|
|
14
|
-
/** 1 on the first run (pgmq's `read_ct`). */
|
|
15
|
-
readonly attempts: number;
|
|
16
|
-
readonly maxAttempts: number;
|
|
17
|
-
readonly enqueuedAt: Temporal.Instant;
|
|
18
|
-
/** End of the lease: the job becomes claimable again after this. */
|
|
19
|
-
readonly visibleUntil: Temporal.Instant;
|
|
20
|
-
readonly lastError: string | null;
|
|
21
|
-
}
|
|
22
|
-
interface EnqueueOptions {
|
|
23
|
-
/** Run no earlier than this. */
|
|
24
|
-
readonly runAt?: Temporal.Instant;
|
|
25
|
-
/** Seconds to wait before running. */
|
|
26
|
-
readonly delay?: number;
|
|
27
|
-
/** Defaults to 5. After this many failed attempts the job is archived as dead. */
|
|
28
|
-
readonly maxAttempts?: number;
|
|
29
|
-
/**
|
|
30
|
-
* While a job with this key is waiting or running, enqueueing again returns
|
|
31
|
-
* its id. SQL connections only.
|
|
32
|
-
*/
|
|
33
|
-
readonly dedupeKey?: string;
|
|
34
|
-
}
|
|
35
|
-
interface ClaimOptions {
|
|
36
|
-
/** Defaults to 1. */
|
|
37
|
-
readonly batch?: number;
|
|
38
|
-
/** Seconds a claimed job stays invisible to other workers. Defaults to 300. */
|
|
39
|
-
readonly lease?: number;
|
|
40
|
-
}
|
|
41
|
-
interface FailOptions {
|
|
42
|
-
/** Retry after this many seconds instead of the exponential backoff. SQL connections only. */
|
|
43
|
-
readonly retryIn?: number;
|
|
44
|
-
}
|
|
45
|
-
type JobHandler<P> = (payload: P, job: Job<P>, signal: AbortSignal) => unknown;
|
|
46
|
-
interface WorkOptions extends ClaimOptions {
|
|
47
|
-
/** Jobs handled at once. Defaults to 1. */
|
|
48
|
-
readonly concurrency?: number;
|
|
49
|
-
/**
|
|
50
|
-
* First wait between polls when the queue is empty, in ms. Defaults to
|
|
51
|
-
* 1000. Each empty poll doubles the wait up to `maxPollInterval`; a claimed
|
|
52
|
-
* job resets it.
|
|
53
|
-
*/
|
|
54
|
-
readonly pollInterval?: number;
|
|
55
|
-
/** Longest wait between empty polls, in ms. Defaults to 30000. */
|
|
56
|
-
readonly maxPollInterval?: number;
|
|
57
|
-
/** Stops the loop; running jobs finish first. */
|
|
58
|
-
readonly signal?: AbortSignal;
|
|
59
|
-
readonly onError?: (error: DbError, job: Job) => void;
|
|
60
|
-
}
|
|
61
|
-
interface DrainResult {
|
|
62
|
-
readonly succeeded: number;
|
|
63
|
-
readonly failed: number;
|
|
64
|
-
}
|
|
65
|
-
interface Jobs<Q extends QueueSchemas> {
|
|
66
|
-
/** Validates the payload with the queue's schema, then enqueues it. Returns the job id. */
|
|
67
|
-
enqueue<N extends Extract<keyof Q, string>>(queue: N, payload: PayloadIn<Q, N>, options?: EnqueueOptions): AsyncResult<number>;
|
|
68
|
-
claim<N extends Extract<keyof Q, string>>(queue: N, options?: ClaimOptions): AsyncResult<Job<PayloadOut<Q, N>>[]>;
|
|
69
|
-
/** Archives the job. `false` when the lease was lost (another worker claimed it since). */
|
|
70
|
-
complete(job: Job): AsyncResult<boolean>;
|
|
71
|
-
/** Returns the new state: `queued` (will retry), `dead` (archived), or `null` when the lease was lost. */
|
|
72
|
-
fail(job: Job, error: unknown, options?: FailOptions): AsyncResult<"queued" | "dead" | null>;
|
|
73
|
-
/** Pushes the lease out by `lease` seconds. `false` when it was lost or the transport can't. */
|
|
74
|
-
extend(job: Job, lease: number): AsyncResult<boolean>;
|
|
75
|
-
/**
|
|
76
|
-
* Enqueues `payload` on a cron schedule with pg_cron (`'0 3 * * *'`,
|
|
77
|
-
* `'30 seconds'`). Re-scheduling a name replaces it. SQL connections only.
|
|
78
|
-
*/
|
|
79
|
-
schedule<N extends Extract<keyof Q, string>>(name: string, cron: string, queue: N, payload: PayloadIn<Q, N>): AsyncResult<void>;
|
|
80
|
-
unschedule(name: string): AsyncResult<boolean>;
|
|
81
|
-
/** Processes ready jobs until the queue is empty. For cron and edge invocations. */
|
|
82
|
-
drain<N extends Extract<keyof Q, string>>(queue: N, handler: JobHandler<PayloadOut<Q, N>>, options?: Omit<WorkOptions, "pollInterval" | "maxPollInterval" | "signal">): Promise<DrainResult>;
|
|
83
|
-
/** Polls and processes jobs until `signal` aborts. */
|
|
84
|
-
work<N extends Extract<keyof Q, string>>(queue: N, handler: JobHandler<PayloadOut<Q, N>>, options?: WorkOptions): Promise<DrainResult>;
|
|
85
|
-
}
|
|
86
|
-
/** A Supabase client, or anything with `.schema(name).rpc(fn, args)`. */
|
|
87
|
-
interface QueueRpcClient {
|
|
88
|
-
schema(name: string): {
|
|
89
|
-
rpc(fn: string, args: Readonly<Record<string, unknown>>): PromiseLike<{
|
|
90
|
-
data: unknown;
|
|
91
|
-
error: unknown;
|
|
92
|
-
}>;
|
|
93
|
-
};
|
|
94
|
-
}
|
|
2
|
+
import { _ as DbError, a as AsyncResult, u as Result } from "../executor-BunPOO-k.js";
|
|
3
|
+
import { t as SqlClient } from "../executor-Cghdstwu.js";
|
|
4
|
+
import { r as EventSink, t as CloudEvent } from "../index-DOESKG27.js";
|
|
5
|
+
import { C as sqlQueueBackend, S as pgmqPublicBackend, _ as QueueSchemas, a as DrainRouteResult, b as WorkOptions, c as FailOptions, d as JobHandler, f as Jobs, g as QueueRpcClient, h as QueueMessageRow, i as DrainRouteOptions, l as Job, m as QueueMessageBody, n as DrainOptions, o as DueSchedule, p as QueueBackend, r as DrainResult, s as EnqueueOptions, t as ClaimOptions, u as JobContext, v as RunSchedulesOptions, x as createJobs, y as ScheduleOptions } from "../queue-BYUCjr59.js";
|
|
6
|
+
//#region src/jobs/cron.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Throws a `TypeError` unless `expression` is a schedule `nextCronRun`
|
|
9
|
+
* understands: five cron fields, a macro such as `@daily`, or an interval
|
|
10
|
+
* such as `30 seconds`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function assertCron(expression: string): void;
|
|
95
13
|
/**
|
|
96
|
-
*
|
|
14
|
+
* The first run of `expression` after `after`, in `timeZone`.
|
|
97
15
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
16
|
+
* Accepts five cron fields (lists, ranges and steps; a restricted day of
|
|
17
|
+
* month and day of week match either, as in cron), the macros `@hourly`,
|
|
18
|
+
* `@daily`, `@weekly`, `@monthly` and `@yearly`, and intervals such as
|
|
19
|
+
* `30 seconds`, `5 minutes` or `2 hours`, counted from `after`. A local time
|
|
20
|
+
* that a DST change skips runs at the same offset after the gap.
|
|
102
21
|
*/
|
|
103
|
-
export declare function
|
|
22
|
+
export declare function nextCronRun(expression: string, timeZone: string, after: Temporal.Instant): Temporal.Instant;
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/jobs/jobs.d.ts
|
|
104
25
|
interface IdempotencyOptions {
|
|
105
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Separates keys of different callers, endpoints or tenants. Defaults to a
|
|
28
|
+
* hash of the caller's credentials (the `Authorization` header or the
|
|
29
|
+
* Supabase auth cookies), so one caller never replays another's response.
|
|
30
|
+
* Pass the verified user id to keep keys across token refreshes.
|
|
31
|
+
*/
|
|
106
32
|
readonly scope?: string | ((request: Request) => string);
|
|
107
33
|
/** How long a completed response is replayed. Defaults to `24 hours`. */
|
|
108
34
|
readonly ttl?: number | string;
|
|
@@ -176,5 +102,125 @@ export declare const ENTITLEMENTS_UPDATED = "entitlements.active_entitlement_sum
|
|
|
176
102
|
* a job can invalidate their sessions. Empty for other payloads.
|
|
177
103
|
*/
|
|
178
104
|
export declare function entitlementMembers(sql: SqlClient, payload: unknown): AsyncResult<readonly string[]>;
|
|
105
|
+
interface PurgeAuditLogOptions {
|
|
106
|
+
/** How long entries are kept when `retention` has no answer. Defaults to `1 year`. */
|
|
107
|
+
readonly olderThan?: number | string;
|
|
108
|
+
/** The most entries deleted per tenant in one call. Defaults to 10000. */
|
|
109
|
+
readonly batch?: number;
|
|
110
|
+
/**
|
|
111
|
+
* Days a tenant keeps its entries (a plan's retention, say); `undefined`
|
|
112
|
+
* uses `olderThan`. Called with `null` for entries without a tenant.
|
|
113
|
+
* Retention shorter than a day is not supported.
|
|
114
|
+
*/
|
|
115
|
+
readonly retention?: (tenant: string | null) => number | undefined | Promise<number | undefined>;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Deletes audit entries past their retention and returns how many. Without
|
|
119
|
+
* `retention` it is one `purge_audit_log` call (which honours an
|
|
120
|
+
* `audit_retention` SQL hook); with it, each tenant is purged with its own
|
|
121
|
+
* interval. Run it from a schedule until it returns 0.
|
|
122
|
+
*/
|
|
123
|
+
export declare function purgeAuditLog(sql: SqlClient, options?: PurgeAuditLogOptions): AsyncResult<number>;
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/jobs/outbox.d.ts
|
|
126
|
+
/** One row of the outbox, as `outbox_claim` and `outbox_history` return it. */
|
|
127
|
+
interface OutboxEvent {
|
|
128
|
+
/** The cursor value: increases with every event. */
|
|
129
|
+
readonly position: number;
|
|
130
|
+
readonly id: string;
|
|
131
|
+
readonly type: string;
|
|
132
|
+
readonly payload: unknown;
|
|
133
|
+
/** The module or function that wrote it, e.g. `better-supabase/organizations`. */
|
|
134
|
+
readonly source: string | null;
|
|
135
|
+
readonly subject: string | null;
|
|
136
|
+
readonly tenant: string | null;
|
|
137
|
+
readonly key: string | null;
|
|
138
|
+
readonly actorId: string | null;
|
|
139
|
+
readonly createdAt: Temporal.Instant;
|
|
140
|
+
}
|
|
141
|
+
interface EmitOptions {
|
|
142
|
+
readonly subject?: string;
|
|
143
|
+
readonly tenant?: string;
|
|
144
|
+
/** With a key, emitting again (per tenant) returns the first event. */
|
|
145
|
+
readonly key?: string;
|
|
146
|
+
readonly source?: string;
|
|
147
|
+
}
|
|
148
|
+
interface OutboxOptions {
|
|
149
|
+
/** The schema of the `outbox` module. Defaults to `better_supabase`. */
|
|
150
|
+
readonly schema?: string;
|
|
151
|
+
/** CloudEvents `source` of the relayed events, e.g. `https://crm.example.com`. */
|
|
152
|
+
readonly source: string;
|
|
153
|
+
/** Prepended to each type with a dot when relaying, e.g. `com.example`. Defaults to `dev.better-supabase`. */
|
|
154
|
+
readonly typePrefix?: string;
|
|
155
|
+
}
|
|
156
|
+
interface RegisterOptions {
|
|
157
|
+
/** Type patterns such as `org.*` or `invoice.paid`. Defaults to every event. */
|
|
158
|
+
readonly types?: readonly string[];
|
|
159
|
+
/** Start at the first kept event instead of after the latest one. */
|
|
160
|
+
readonly fromStart?: boolean;
|
|
161
|
+
}
|
|
162
|
+
interface RelayOptions {
|
|
163
|
+
/** Events per claim and per `sink.send`. Defaults to 100. */
|
|
164
|
+
readonly batch?: number;
|
|
165
|
+
/** How long a claim holds the consumer. Defaults to `1 minute`. */
|
|
166
|
+
readonly lease?: string;
|
|
167
|
+
/** Stops claiming after this many milliseconds. */
|
|
168
|
+
readonly budgetMs?: number;
|
|
169
|
+
/** Identifies this worker in the lease. Defaults to a random id. */
|
|
170
|
+
readonly owner?: string;
|
|
171
|
+
}
|
|
172
|
+
interface RelayResult {
|
|
173
|
+
readonly delivered: number;
|
|
174
|
+
/** Set when the sink threw: the batch stays unacknowledged for the next run. */
|
|
175
|
+
readonly error?: DbError;
|
|
176
|
+
}
|
|
177
|
+
interface OutboxRouteOptions extends Omit<RelayOptions, "owner"> {
|
|
178
|
+
/** The bearer secret, such as `process.env.CRON_SECRET`. */
|
|
179
|
+
readonly secret: string | undefined;
|
|
180
|
+
/** Consumer name to the sink its events go to. */
|
|
181
|
+
readonly consumers: Readonly<Record<string, EventSink>>;
|
|
182
|
+
readonly onError?: (error: DbError, consumer: string) => void;
|
|
183
|
+
}
|
|
184
|
+
interface OutboxRouteResult {
|
|
185
|
+
readonly consumers: Readonly<Record<string, RelayResult>>;
|
|
186
|
+
readonly budgetExhausted: boolean;
|
|
187
|
+
}
|
|
188
|
+
interface HistoryFilter {
|
|
189
|
+
readonly subject?: string;
|
|
190
|
+
readonly type?: string;
|
|
191
|
+
/** Only events after this position. */
|
|
192
|
+
readonly after?: number;
|
|
193
|
+
readonly limit?: number;
|
|
194
|
+
}
|
|
195
|
+
interface Outbox {
|
|
196
|
+
/** Writes an event in the current transaction and returns its id. */
|
|
197
|
+
emit(type: string, payload?: unknown, options?: EmitOptions): AsyncResult<string>;
|
|
198
|
+
/** Creates the consumer, or changes its types. Returns its cursor position. */
|
|
199
|
+
register(consumer: string, options?: RegisterOptions): AsyncResult<number>;
|
|
200
|
+
/** Removes the consumer, so purges stop waiting for it. */
|
|
201
|
+
unregister(consumer: string): AsyncResult<boolean>;
|
|
202
|
+
/**
|
|
203
|
+
* Claims the consumer's next events, sends them to `sink` as CloudEvents and
|
|
204
|
+
* moves the cursor, until none are left or the budget runs out. A sink that
|
|
205
|
+
* throws leaves the batch for the next run, so delivery is at least once.
|
|
206
|
+
*/
|
|
207
|
+
relay(consumer: string, sink: EventSink, options?: RelayOptions): Promise<RelayResult>;
|
|
208
|
+
/** A `GET`/`POST` handler for a cron that relays every consumer in turn. */
|
|
209
|
+
relayRoute(options: OutboxRouteOptions): (request: Request) => Promise<Response>;
|
|
210
|
+
history(filter?: HistoryFilter): AsyncResult<readonly OutboxEvent[]>;
|
|
211
|
+
/**
|
|
212
|
+
* Deletes up to `batch` events (default 10,000) older than `olderThan` that
|
|
213
|
+
* every consumer has passed. Call it again while it returns `batch`.
|
|
214
|
+
*/
|
|
215
|
+
purge(olderThan?: string, batch?: number): AsyncResult<number>;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* The CloudEvent for an outbox row: the row id as `id` (stable, so receivers
|
|
219
|
+
* can deduplicate), the payload as `data`, the tenant as `partitionkey` and
|
|
220
|
+
* the writing module as `producer`. The actor stays out of the context
|
|
221
|
+
* attributes, which must not carry personal data.
|
|
222
|
+
*/
|
|
223
|
+
export declare function outboxCloudEvent(event: OutboxEvent, options: Pick<OutboxOptions, "source" | "typePrefix">): CloudEvent;
|
|
224
|
+
export declare function createOutbox(sql: SqlClient, options: OutboxOptions): Outbox;
|
|
179
225
|
//#endregion
|
|
180
|
-
export type
|
|
226
|
+
export { type ClaimOptions, type DrainOptions, type DrainResult, type DrainRouteOptions, type DrainRouteResult, type DueSchedule, type EmitOptions, type EnqueueOptions, type FailOptions, type HistoryFilter, type Idempotency, type IdempotencyOptions, type IdempotencyState, type Inbox, type InboxMessage, type InboxOptions, type Job, type JobContext, type JobHandler, type Jobs, type Outbox, type OutboxEvent, type OutboxOptions, type OutboxRouteOptions, type OutboxRouteResult, type PurgeAuditLogOptions, type QueueBackend, type QueueMessageBody, type QueueMessageRow, type QueueRpcClient, type QueueSchemas, type RegisterOptions, type RelayOptions, type RelayResult, type RunSchedulesOptions, type ScheduleOptions, type SqlClient, type WorkOptions, createJobs, pgmqPublicBackend, sqlQueueBackend };
|