better-supabase 0.1.0 → 0.3.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 +34 -31
- package/dist/base64-CQeB1eSf.js +42 -0
- package/dist/claims-CoTobNC-.js +25 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +4 -14
- package/dist/{compiler-DL18ukPe.d.ts → compiler-2zqGzxVZ.d.ts} +2 -2
- package/dist/config/index.d.ts +4 -3
- package/dist/config/index.js +5 -3
- package/dist/config-Be4GwsqI.js +129 -0
- package/dist/{index-BD6wKthp.d.ts → config-C1CYcm6o.d.ts} +75 -54
- package/dist/{config-D-aR2ZoN.js → config-DOsGYSiT.js} +14 -136
- package/dist/{define-QGkq04oe.js → define-DF341GDj.js} +133 -110
- package/dist/{define-CTfWw-SS.d.ts → define-DUbydmJa.d.ts} +32 -14
- package/dist/edge/index.d.ts +4 -4
- package/dist/edge/index.js +4 -4
- package/dist/entitlements-CTEBm7IB.js +20 -0
- package/dist/entitlements-DvJXoI02.d.ts +42 -0
- package/dist/env/index.js +203 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +139 -1
- package/dist/{events-2OJsVG_d.d.ts → events-Do8jXh4D.d.ts} +3 -3
- package/dist/{executor-Bje4suQF.d.ts → executor-B26lgbHD.d.ts} +2 -2
- package/dist/{executor-Ceq60hPM.js → executor-C57jx2pn.js} +7 -2
- package/dist/{executor-Bazhgsgq.d.ts → executor-DynmIWhq.d.ts} +2 -2
- package/dist/guards-BnzDvFrz.js +10 -0
- package/dist/hono/index.d.ts +5 -5
- package/dist/hono/index.js +4 -4
- package/dist/{index-Hf8PP9sP.d.ts → index-BNsABq7P.d.ts} +17 -13
- package/dist/{index-JXHBuS53.d.ts → index-CADlNHK-.d.ts} +27 -14
- package/dist/{index-Nxo3TJcm.d.ts → index-CTTMS6_1.d.ts} +27 -8
- package/dist/index-Cf-D2jk1.d.ts +50 -0
- package/dist/{index-Dup-nSe9.d.ts → index-CriFFJ_p.d.ts} +4 -4
- package/dist/{index-DQVvHzjW.d.ts → index-GV77NpRP.d.ts} +5 -4
- package/dist/{index-Sw43J8HG.d.ts → index-UJ-LUxtI.d.ts} +6 -6
- package/dist/{index-cEeweTeM.d.ts → index-kpgopLNv.d.ts} +4 -3
- package/dist/{index-DRid0qIv.d.ts → index-qriRM9cZ.d.ts} +7 -2
- package/dist/index.d.ts +13 -13
- package/dist/index.js +18 -8
- package/dist/jobs/index.d.ts +25 -24
- package/dist/jobs/index.js +19 -12
- package/dist/{json-schema-BbwO2mZg.js → json-schema--aOXAGfU.js} +9 -3
- package/dist/lint/index.js +1 -1
- package/dist/list/index.d.ts +2 -2
- package/dist/list/index.js +128 -93
- package/dist/{live-6b9i72Ux.d.ts → live-QE3UPbGm.d.ts} +27 -6
- package/dist/logger-glM28NVN.js +21 -0
- package/dist/mcp/index.d.ts +59 -15
- package/dist/mcp/index.js +229 -67
- package/dist/{mfa-CpogP66z.js → mfa-BxoR1RkN.js} +97 -22
- package/dist/{mfa-TVia554c.d.ts → mfa-x3V3vGh-.d.ts} +1 -1
- package/dist/next/index.d.ts +51 -38
- package/dist/next/index.js +31 -25
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +58 -35
- package/dist/orpc/index.d.ts +6 -6
- package/dist/orpc/index.js +3 -3
- package/dist/otel/index.d.ts +3 -3
- package/dist/otel/index.js +5 -3
- package/dist/{template-BeOGnynM.js → permdock-sql-Bta_G0v-.js} +32 -3
- package/dist/permdock-sql-DImJULY-.d.ts +17 -0
- package/dist/{plugin-HvGqCurB.d.ts → plugin-DVRB8qNE.d.ts} +5 -4
- package/dist/plugins/actor/index.d.ts +1 -1
- package/dist/plugins/rules/index.d.ts +4 -3
- package/dist/plugins/rules/index.js +8 -15
- package/dist/plugins/soft-delete/index.d.ts +3 -3
- package/dist/plugins/soft-delete/index.js +2 -2
- package/dist/plugins/tenant/index.d.ts +10 -4
- package/dist/plugins/tenant/index.js +15 -13
- package/dist/plugins/timestamps/index.d.ts +1 -1
- package/dist/plugins/timestamps/index.js +1 -1
- package/dist/plugins/validation/index.d.ts +2 -2
- package/dist/pool-B9qsLyFR.d.ts +71 -0
- package/dist/postgres/index.d.ts +10 -5
- package/dist/postgres/index.js +36 -16
- package/dist/{postgrest-Dm-vhY6R.d.ts → postgrest-DmBlevh-.d.ts} +1 -1
- package/dist/{problem-DPu6Fh-t.js → problem-CGt1ADix.js} +14 -8
- package/dist/{problem-DlgB0lYl.d.ts → problem-Z2RTQjZD.d.ts} +6 -4
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +1 -1
- package/dist/{query-ChvDbsDE.js → query-BdKLTPlj.js} +2 -2
- package/dist/react/index.d.ts +7 -7
- package/dist/react/index.js +3 -3
- package/dist/react/server.d.ts +5 -5
- package/dist/react/server.js +1 -1
- package/dist/react/session.d.ts +21 -2
- package/dist/react/session.js +19 -1
- package/dist/{react-CrOvrnIP.js → react-DNBYNazu.js} +28 -23
- package/dist/{read-set-DhX2d04c.js → read-set-D0qBcboM.js} +3 -3
- package/dist/realtime/index.d.ts +4 -2
- package/dist/realtime/index.js +30 -14
- package/dist/{resolve-DW8h9NPm.d.ts → resolve-BRciX2jK.d.ts} +25 -9
- package/dist/{resource-SkPTRJDD.d.ts → resource-CwVgiI5q.d.ts} +16 -7
- package/dist/{resource-CYiu6Ygi.js → resource-D30rp0GN.js} +38 -16
- package/dist/{respond-4-dhoV7x.js → respond-C44EZAJo.js} +38 -19
- package/dist/{respond-PoTpy5DT.d.ts → respond-DAkPIdTH.d.ts} +23 -17
- package/dist/{result-CTkCZ6JA.d.ts → result-c2OYgCV2.d.ts} +13 -8
- package/dist/server/index.d.ts +35 -10
- package/dist/server/index.js +38 -9
- package/dist/{simplify-oHiDKRVQ.js → simplify-LakqK1vH.js} +22 -28
- package/dist/{spec-pins-t6sPaHvl.js → spec-pins-C3oc-Tdp.js} +1 -1
- package/dist/{spec-pins-CJPVghHy.d.ts → spec-pins-CqorWDnO.d.ts} +1 -1
- package/dist/sql/index.d.ts +139 -0
- package/dist/sql/index.js +1983 -0
- package/dist/{sql-M8l3fnS0.js → sql-BIgk12ew.js} +72 -16
- package/dist/ssr/index.d.ts +5 -5
- package/dist/ssr/index.js +3 -3
- package/dist/{standard-CyhRzctb.d.ts → standard-eudBiRk1.d.ts} +1 -1
- package/dist/{stats-3iy8u3_P.js → stats-D78UQ8Yu.js} +8 -7
- package/dist/storage/index.d.ts +4 -2
- package/dist/storage/index.js +530 -1
- package/dist/{tables-rZxRxNPW.js → tables-Dhha3BXM.js} +5 -5
- package/dist/temporal-BwshQk0W.js +27 -0
- package/dist/temporal-required-CMxeSVPo.js +19 -0
- package/dist/testing/index.d.ts +49 -16
- package/dist/testing/index.js +233 -66
- package/dist/{types-C2fslP1z.d.ts → types-DONv9SHN.d.ts} +68 -12
- package/dist/{version-Cqq1m3UY.js → version-BfpG2gks.js} +1 -1
- package/dist/view-3Po_PVlr.d.ts +79 -0
- package/dist/{view-B6F9QbG-.js → view-wZ-9qIUz.js} +12 -2
- package/dist/webhooks/index.d.ts +19 -17
- package/dist/webhooks/index.js +1 -1
- package/dist/{webhooks-DbMTJJX2.js → webhooks-CAIFQSTM.js} +12 -10
- package/package.json +30 -30
- package/schemas/config-v1.json +80 -5
- package/schemas/doctor-report-v1.json +18 -1
- package/schemas/snapshot-v2.json +39 -0
- package/skills/better-supabase/SKILL.md +23 -11
- package/skills/better-supabase/references/plugins.md +28 -16
- package/skills/better-supabase/references/troubleshooting.md +15 -15
- package/skills/better-supabase-api/SKILL.md +9 -9
- package/skills/better-supabase-api/references/adapters.md +30 -25
- package/skills/better-supabase-testing/SKILL.md +15 -11
- package/bin/better-supabase.js +0 -3
- package/dist/casing-da0uRTqt.js +0 -14
- package/dist/cli/bin.d.ts +0 -1
- package/dist/cli/bin.js +0 -15
- package/dist/cli/index.d.ts +0 -226
- package/dist/cli/index.js +0 -3
- package/dist/cli-CoByWYja.js +0 -6472
- package/dist/entitlements-BBg61DQZ.d.ts +0 -20
- package/dist/entitlements-BC_khwRy.js +0 -17
- package/dist/env-BEToab0I.js +0 -204
- package/dist/events-BuzTgn2D.js +0 -135
- package/dist/pool-BFeqzwQS.d.ts +0 -37
- package/dist/seed-CzecODcJ.js +0 -101
- package/dist/session-C3osL21k.d.ts +0 -21
- package/dist/session-CD-3orO_.js +0 -19
- package/dist/storage-BWXVUXGk.js +0 -461
- package/dist/view-B0ltUmTi.d.ts +0 -43
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { l as CountMode } from "./executor-
|
|
3
|
-
import { b as ValidationIssue, t as AsyncResult } from "./result-
|
|
4
|
-
import { C as FindExt, Ct as WhereInput, O as RepositoryOf, T as OffsetPageArgs, dt as IncludeArg, gt as OrderByArg, t as BetterSupabase, vt as Payload, w as OffsetPage, xt as SelectArg } from "./define-
|
|
1
|
+
import { N as TableKey, O as Row, n as AnyModels, t as AnyFunctions } from "./types-DONv9SHN.js";
|
|
2
|
+
import { l as CountMode } from "./executor-DynmIWhq.js";
|
|
3
|
+
import { b as ValidationIssue, t as AsyncResult } from "./result-c2OYgCV2.js";
|
|
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-DUbydmJa.js";
|
|
5
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
|
-
//#region src/list/
|
|
6
|
+
//#region src/list/list-query.d.ts
|
|
7
7
|
/** Facet value meaning "not set": filters with `is null`. */
|
|
8
8
|
declare const UNSET = "__unset__";
|
|
9
9
|
type Column<M extends AnyModels, T extends keyof M> = Extract<keyof Row<M, T>, string>;
|
|
10
10
|
type TextColumn<M extends AnyModels, T extends keyof M> = { [K in Column<M, T>]: [NonNullable<Row<M, T>[K]>] extends [string] ? K : never; }[Column<M, T>];
|
|
11
|
-
|
|
11
|
+
/** `offset` pages by number; `cursor` continues after the last row (keyset). */
|
|
12
|
+
type ListPagination = "offset" | "cursor";
|
|
13
|
+
interface ListQueryConfig<M extends AnyModels, T extends keyof M, S extends string, F extends string, C extends boolean = boolean, P extends ListPagination = ListPagination> {
|
|
12
14
|
/**
|
|
13
15
|
* Also count rows per facet value, with one grouped aggregate that runs
|
|
14
16
|
* next to the page: 2 calls, 1 wave. Needs PostgREST aggregates.
|
|
@@ -26,6 +28,12 @@ interface ListQueryConfig<M extends AnyModels, T extends keyof M, S extends stri
|
|
|
26
28
|
/** Named orderings. Add a unique column last for stable pages. */
|
|
27
29
|
readonly sorts: { readonly [K in S]: OrderByArg<M, T>; };
|
|
28
30
|
readonly defaultSort: NoInfer<S>;
|
|
31
|
+
/**
|
|
32
|
+
* `cursor` takes an `after` cursor instead of `page` and returns
|
|
33
|
+
* `nextCursor`: the cost of a page stays the same however deep it is, and
|
|
34
|
+
* rows inserted meanwhile don't shift it. Defaults to `offset`.
|
|
35
|
+
*/
|
|
36
|
+
readonly pagination?: P;
|
|
29
37
|
/** Defaults to 50. */
|
|
30
38
|
readonly pageSize?: number;
|
|
31
39
|
/** Defaults to 200. */
|
|
@@ -36,8 +44,10 @@ interface ListQueryConfig<M extends AnyModels, T extends keyof M, S extends stri
|
|
|
36
44
|
interface ListQuery<S extends string, F extends string> {
|
|
37
45
|
readonly q?: string;
|
|
38
46
|
readonly sort: S;
|
|
39
|
-
/** 1-based. */
|
|
47
|
+
/** 1-based. Always 1 with cursor pagination. */
|
|
40
48
|
readonly page: number;
|
|
49
|
+
/** Cursor pagination: the `nextCursor` of the previous page. */
|
|
50
|
+
readonly after?: string;
|
|
41
51
|
readonly size: number;
|
|
42
52
|
readonly facets: { readonly [K in F]?: readonly string[]; };
|
|
43
53
|
}
|
|
@@ -46,6 +56,7 @@ interface ListQueryInput<S extends string, F extends string> {
|
|
|
46
56
|
readonly q?: string;
|
|
47
57
|
readonly sort?: S;
|
|
48
58
|
readonly page?: number;
|
|
59
|
+
readonly after?: string;
|
|
49
60
|
readonly size?: number;
|
|
50
61
|
readonly facets?: { readonly [K in F]?: readonly string[]; };
|
|
51
62
|
}
|
|
@@ -83,13 +94,14 @@ interface FacetInfo {
|
|
|
83
94
|
/** Rows per facet value, keyed by facet and then by value (`UNSET` for empty). */
|
|
84
95
|
type FacetCounts<F extends string> = { readonly [K in F]: Readonly<Record<string, number>>; };
|
|
85
96
|
/** A page of a list; with `facetCounts: true`, also the counts per facet value. */
|
|
86
|
-
type ListPage<R, F extends string, C extends boolean> = OffsetPage<R> & ([C] extends [true] ? {
|
|
97
|
+
type ListPage<R, F extends string, C extends boolean, P extends ListPagination = "offset"> = ([P] extends ["cursor"] ? CursorPage<R> : OffsetPage<R>) & ([C] extends [true] ? {
|
|
87
98
|
readonly facetCounts: FacetCounts<F>;
|
|
88
99
|
} : [C] extends [false] ? unknown : {
|
|
89
100
|
readonly facetCounts?: FacetCounts<F>;
|
|
90
101
|
});
|
|
91
|
-
interface ListDefinition<M extends AnyModels, T extends TableKey<M>, E, S extends string, F extends string, C extends boolean = false> {
|
|
102
|
+
interface ListDefinition<M extends AnyModels, T extends TableKey<M>, E, S extends string, F extends string, C extends boolean = false, P extends ListPagination = "offset"> {
|
|
92
103
|
readonly table: T;
|
|
104
|
+
readonly pagination: P;
|
|
93
105
|
readonly defaults: ListQuery<S, F>;
|
|
94
106
|
readonly facets: readonly FacetInfo[];
|
|
95
107
|
/** Validates typed input or URL params. Also a Standard Schema (`schema`). */
|
|
@@ -100,13 +112,13 @@ interface ListDefinition<M extends AnyModels, T extends TableKey<M>, E, S extend
|
|
|
100
112
|
/** `{ parse, serialize }` per URL key, for routers and nuqs (`list.nuqs(createParser)`). */
|
|
101
113
|
readonly parsers: ListParsers<S, F>;
|
|
102
114
|
nuqs<P>(createParser: (spec: ParserSpec<unknown>) => P): { readonly [K in keyof ListParsers<S, F>]: P; };
|
|
103
|
-
/** Repository arguments: `where`, `orderBy`, `
|
|
104
|
-
args(query: ListQuery<S, F>): OffsetPageArgs<M, T>;
|
|
115
|
+
/** Repository arguments: `where`, `orderBy`, `size`, and `page` and `count` or `after`. */
|
|
116
|
+
args(query: ListQuery<S, F>): [P] extends ["cursor"] ? CursorPageArgs<M, T> : OffsetPageArgs<M, T>;
|
|
105
117
|
/**
|
|
106
118
|
* Runs the list against a table, merging your `select`, `include`, `where`
|
|
107
119
|
* and `count`. One request, plus one for `facetCounts`, always one wave.
|
|
108
120
|
*/
|
|
109
|
-
run<const A extends ListExtra<M, T> & FindExt<E, M, T>>(db: { readonly [K in T]: RepositoryOf<M, K, E>; }, query: ListQuery<S, F>, extra?: A): AsyncResult<ListPage<Payload<M, T, A>, F, C>>;
|
|
121
|
+
run<const A extends ListExtra<M, T> & FindExt<E, M, T>>(db: { readonly [K in T]: RepositoryOf<M, K, E>; }, query: ListQuery<S, F>, extra?: A): AsyncResult<ListPage<Payload<M, T, A>, F, C, P>>;
|
|
110
122
|
/** OpenAPI 3.1 query parameters. */
|
|
111
123
|
readonly openapi: readonly OpenApiParameter[];
|
|
112
124
|
/** JSON Schema of the typed input, e.g. for MCP tool arguments. */
|
|
@@ -123,6 +135,7 @@ type ListParsers<S extends string, F extends string> = {
|
|
|
123
135
|
readonly q: ParserSpec<string>;
|
|
124
136
|
readonly sort: ParserSpec<S>;
|
|
125
137
|
readonly page: ParserSpec<number>;
|
|
138
|
+
readonly after: ParserSpec<string>;
|
|
126
139
|
readonly size: ParserSpec<number>;
|
|
127
140
|
} & { readonly [K in F]: ParserSpec<readonly string[]>; };
|
|
128
141
|
/**
|
|
@@ -139,6 +152,6 @@ type ListParsers<S extends string, F extends string> = {
|
|
|
139
152
|
* });
|
|
140
153
|
* ```
|
|
141
154
|
*/
|
|
142
|
-
declare function defineListQuery<M extends AnyModels, D, Fn extends AnyFunctions, E, T extends TableKey<M>, const S extends string, const F extends string = never, const C extends boolean = false>(sb: BetterSupabase<M, D, Fn, E>, table: T, config: ListQueryConfig<M, T, S, F, C>): ListDefinition<M, T, E, S, F, C>;
|
|
155
|
+
declare function defineListQuery<M extends AnyModels, D, Fn extends AnyFunctions, E, T extends TableKey<M>, const S extends string, const F extends string = never, const C extends boolean = false, const P extends ListPagination = "offset">(sb: BetterSupabase<M, D, Fn, E>, table: T, config: ListQueryConfig<M, T, S, F, C, P>): ListDefinition<M, T, E, S, F, C, P>;
|
|
143
156
|
//#endregion
|
|
144
|
-
export { ListPage as a,
|
|
157
|
+
export { ListPage as a, ListParsers as c, ListQueryInput as d, ListSearchParams as f, defineListQuery as g, UNSET as h, ListExtra as i, ListQuery as l, ParserSpec as m, FacetInfo as n, ListPagination as o, OpenApiParameter as p, ListDefinition as r, ListParseResult as s, FacetCounts as t, ListQueryConfig as u };
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference lib="esnext.temporal" />
|
|
2
|
+
import { b as PermdockBucketPolicy, i as BucketPolicyName } from "./types-DONv9SHN.js";
|
|
3
|
+
import { p as DbError, t as AsyncResult } from "./result-c2OYgCV2.js";
|
|
2
4
|
import { n as StoragePath, t as PathIn } from "./path-Cv__-OTj.js";
|
|
5
|
+
import { t as PermdockCatalog } from "./permdock-sql-DImJULY-.js";
|
|
3
6
|
import { n as TemplateValues, t as TemplateParams } from "./template-mbvlysOo.js";
|
|
4
7
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
5
|
-
//#region src/storage/
|
|
6
|
-
type BucketPolicy =
|
|
8
|
+
//#region src/storage/bucket.d.ts
|
|
9
|
+
type BucketPolicy = BucketPolicyName | PermdockBucketPolicy;
|
|
7
10
|
interface BucketConfig<P extends string = string, Id extends string = string> {
|
|
8
11
|
/** Bucket id, e.g. `customer-logos`. */
|
|
9
12
|
readonly id: Id;
|
|
@@ -13,9 +16,22 @@ interface BucketConfig<P extends string = string, Id extends string = string> {
|
|
|
13
16
|
/**
|
|
14
17
|
* Generated `storage.objects` policies. `tenant` and `owner` match a path
|
|
15
18
|
* segment against the JWT; `public` allows reads; `none` leaves access to
|
|
16
|
-
* the secret key
|
|
19
|
+
* the secret key; `{ permdock, scope }` calls PermDock's SQL helpers.
|
|
20
|
+
* Defaults to `none`.
|
|
21
|
+
*
|
|
22
|
+
* The helpers check role and scope only. Use `permdock` just for
|
|
23
|
+
* permissions whose grants have no row conditions beyond the scope: for a
|
|
24
|
+
* permission with row conditions (e.g. `ownerId = principal.id`) the bucket
|
|
25
|
+
* would grant every object in the scope. Pass `catalog` to refuse those
|
|
26
|
+
* keys here; `better-supabase doctor` (BS214) refuses them from the
|
|
27
|
+
* catalog file.
|
|
17
28
|
*/
|
|
18
29
|
readonly policy?: BucketPolicy;
|
|
30
|
+
/**
|
|
31
|
+
* PermDock's `permissions.catalog.json`. With it, a `permdock` policy
|
|
32
|
+
* naming a permission with `rowConditions: true` throws.
|
|
33
|
+
*/
|
|
34
|
+
readonly catalog?: PermdockCatalog;
|
|
19
35
|
/** `'5MiB'`, `'500KB'` or bytes. */
|
|
20
36
|
readonly fileSizeLimit?: string | number;
|
|
21
37
|
/** `['image/png', 'image/*']`. */
|
|
@@ -23,7 +39,7 @@ interface BucketConfig<P extends string = string, Id extends string = string> {
|
|
|
23
39
|
readonly tenant?: {
|
|
24
40
|
/** Placeholder holding the tenant id. Defaults to `orgId`. */
|
|
25
41
|
readonly param?: string;
|
|
26
|
-
/** JWT claim paths, first match wins. Defaults to `
|
|
42
|
+
/** JWT claim paths, first match wins. Defaults to `tenant_id`, then `app_metadata.tenant_id`. */
|
|
27
43
|
readonly claim?: string | readonly string[];
|
|
28
44
|
/** SQL expression for the tenant id, instead of `claim`. */
|
|
29
45
|
readonly sql?: string;
|
|
@@ -97,14 +113,17 @@ interface ReplaceResult<Id extends string = string> {
|
|
|
97
113
|
interface SweepOptions<P extends string> {
|
|
98
114
|
/** Only look under the path prefix these values fill. */
|
|
99
115
|
readonly within?: Partial<TemplateValues<P>>;
|
|
100
|
-
/**
|
|
101
|
-
|
|
116
|
+
/**
|
|
117
|
+
* A cutoff instant, or a minimum age. A duration counts a day as 24 hours
|
|
118
|
+
* and cannot use months or years.
|
|
119
|
+
*/
|
|
120
|
+
readonly olderThan: Temporal.Instant | Temporal.Duration;
|
|
102
121
|
/** Returns which of `paths` are still referenced. */
|
|
103
122
|
readonly referenced: (paths: readonly string[]) => PromiseLike<Iterable<string>> | Iterable<string>;
|
|
104
123
|
readonly dryRun?: boolean;
|
|
105
124
|
readonly batchSize?: number;
|
|
106
125
|
readonly signal?: AbortSignal;
|
|
107
|
-
readonly now?: () =>
|
|
126
|
+
readonly now?: () => Temporal.Instant;
|
|
108
127
|
}
|
|
109
128
|
interface SweepResult {
|
|
110
129
|
readonly scanned: number;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { A as SchemaMeta, s as ClaimsMeta } from "./types-DONv9SHN.js";
|
|
2
|
+
import { d as Generator } from "./config-C1CYcm6o.js";
|
|
3
|
+
//#region src/core/claims.d.ts
|
|
4
|
+
declare const DEFAULT_CLAIMS: ClaimsMeta;
|
|
5
|
+
/** Where the active tenant is read from: the top-level claim, then `app_metadata`. */
|
|
6
|
+
declare function tenantClaimPaths(tenant?: string): readonly [string, string];
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/generators/shared.d.ts
|
|
9
|
+
/** What field planning reads: the metadata and the typed-jsonb config. */
|
|
10
|
+
interface SchemaSource {
|
|
11
|
+
readonly meta: SchemaMeta;
|
|
12
|
+
readonly config: {
|
|
13
|
+
readonly json: Readonly<Record<string, unknown>>;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/generators/json-schema.d.ts
|
|
18
|
+
interface JsonSchemaGeneratorOptions {
|
|
19
|
+
/** Output path relative to the project root. Defaults to `<output>.schema.json`. */
|
|
20
|
+
readonly output?: string;
|
|
21
|
+
/** `$id` of the document. */
|
|
22
|
+
readonly id?: string;
|
|
23
|
+
}
|
|
24
|
+
type JsonSchema = Record<string, unknown>;
|
|
25
|
+
/** JSON Schema (2020-12) `$defs` for every table: `customersRow`, `customersInsert`, ... */
|
|
26
|
+
declare function buildJsonSchema(input: SchemaSource, id?: string): JsonSchema;
|
|
27
|
+
/** Writes the JSON Schema document; `createOpenApi` reuses the same `$defs`. */
|
|
28
|
+
declare function jsonSchema(options?: JsonSchemaGeneratorOptions): Generator;
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/generators/valibot.d.ts
|
|
31
|
+
interface ValibotGeneratorOptions {
|
|
32
|
+
/** Output path relative to the project root. Defaults to `<output>.valibot.ts`. */
|
|
33
|
+
readonly output?: string;
|
|
34
|
+
/** Schemas for typed jsonb columns: `{ 'customers.metadata': './schemas.ts#metadata' }`. */
|
|
35
|
+
readonly json?: Readonly<Record<string, string>>;
|
|
36
|
+
}
|
|
37
|
+
/** Valibot schemas for every table's Row, Insert and Update shape. */
|
|
38
|
+
declare function valibot(options?: ValibotGeneratorOptions): Generator;
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/generators/zod.d.ts
|
|
41
|
+
interface ZodGeneratorOptions {
|
|
42
|
+
/** Output path relative to the project root. Defaults to `<output>.zod.ts`. */
|
|
43
|
+
readonly output?: string;
|
|
44
|
+
/** Schemas for typed jsonb columns: `{ 'customers.metadata': './schemas.ts#metadata' }`. */
|
|
45
|
+
readonly json?: Readonly<Record<string, string>>;
|
|
46
|
+
}
|
|
47
|
+
/** Zod 4 schemas for every table's Row, Insert and Update shape. */
|
|
48
|
+
declare function zod(options?: ZodGeneratorOptions): Generator;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { JsonSchemaGeneratorOptions as a, DEFAULT_CLAIMS as c, valibot as i, tenantClaimPaths as l, zod as n, buildJsonSchema as o, ValibotGeneratorOptions as r, jsonSchema as s, ZodGeneratorOptions as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as DbException } from "./result-
|
|
3
|
-
import { C as FindExt, Ct as WhereInput, M as UpsertArgs, N as WriteArgs, S as DeleteExt, T as OffsetPageArgs, X as InferResult, Z as QuerySpec, _ as CursorPage, it as AggregateResult, j as UpdateArgs, k as Returned, l as CacheAdapter, lt as FindFirstArgs, rt as AggregateArgs, st as CountArgs, t as BetterSupabase, ut as FindManyArgs, v as CursorPageArgs, vt as Payload, w as OffsetPage, x as DeleteArgs, y as Db, yt as ReadArgs } from "./define-
|
|
1
|
+
import { C as PrimaryKeyValue, L as UniqueWhere, N as TableKey, R as Update, g as Insert, n as AnyModels, t as AnyFunctions } from "./types-DONv9SHN.js";
|
|
2
|
+
import { _ as DbException } from "./result-c2OYgCV2.js";
|
|
3
|
+
import { C as FindExt, Ct as WhereInput, M as UpsertArgs, N as WriteArgs, S as DeleteExt, T as OffsetPageArgs, X as InferResult, Z as QuerySpec, _ as CursorPage, it as AggregateResult, j as UpdateArgs, k as Returned, l as CacheAdapter, lt as FindFirstArgs, rt as AggregateArgs, st as CountArgs, t as BetterSupabase, ut as FindManyArgs, v as CursorPageArgs, vt as Payload, w as OffsetPage, x as DeleteArgs, y as Db, yt as ReadArgs } from "./define-DUbydmJa.js";
|
|
4
4
|
import { DataTag, InfiniteData, QueryClient, SkipToken } from "@tanstack/query-core";
|
|
5
5
|
//#region src/query/invalidate.d.ts
|
|
6
6
|
/** Carried by every better-supabase query: the tables whose changes make it stale. */
|
|
@@ -14,7 +14,7 @@ interface BetterQueryMeta {
|
|
|
14
14
|
*/
|
|
15
15
|
declare function invalidateTables(client: QueryClient, tables: readonly string[]): Promise<void>;
|
|
16
16
|
//#endregion
|
|
17
|
-
//#region src/query/
|
|
17
|
+
//#region src/query/queries.d.ts
|
|
18
18
|
type QueryKeyOf<T> = DataTag<readonly unknown[], T, DbException>;
|
|
19
19
|
type QueryFnOf<T> = ((context: {
|
|
20
20
|
readonly signal: AbortSignal;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
/// <reference lib="esnext.temporal" />
|
|
2
|
+
import { A as SchemaMeta } from "./types-DONv9SHN.js";
|
|
3
|
+
import { a as EventHub, s as MutationNotice } from "./events-Do8jXh4D.js";
|
|
4
|
+
import { l as MutationKind } from "./plugin-DVRB8qNE.js";
|
|
4
5
|
//#region src/events/index.d.ts
|
|
5
6
|
/** A CloudEvents 1.0 event. Extension attributes are lowercase alphanumerics. */
|
|
6
7
|
interface CloudEvent<T = unknown> {
|
|
@@ -26,7 +27,7 @@ interface CloudEventOptions {
|
|
|
26
27
|
/** Replaces the `dev.better-supabase` type prefix. */
|
|
27
28
|
readonly typePrefix?: string;
|
|
28
29
|
readonly id?: () => string;
|
|
29
|
-
readonly now?: () =>
|
|
30
|
+
readonly now?: () => Temporal.Instant;
|
|
30
31
|
}
|
|
31
32
|
/** Sends events somewhere: a queue, a bus, an outbox table, an HTTP endpoint. */
|
|
32
33
|
interface EventSink {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as AnyModels, t as AnyFunctions } from "./types-
|
|
2
|
-
import { t as BetterSupabase, y as Db } from "./define-
|
|
1
|
+
import { n as AnyModels, t as AnyFunctions } from "./types-DONv9SHN.js";
|
|
2
|
+
import { t as BetterSupabase, y as Db } from "./define-DUbydmJa.js";
|
|
3
3
|
import { c as PublicEnv } from "./index-Dy6kuF0P.js";
|
|
4
|
-
import { i as Queries } from "./index-
|
|
4
|
+
import { i as Queries } from "./index-CriFFJ_p.js";
|
|
5
5
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
6
6
|
//#region src/client/index.d.ts
|
|
7
7
|
interface BrowserOptions {
|
|
@@ -39,9 +39,9 @@ interface BrowserAuth {
|
|
|
39
39
|
/** `useSyncExternalStore`-compatible. */
|
|
40
40
|
readonly subscribe: (listener: () => void) => () => void;
|
|
41
41
|
}
|
|
42
|
-
interface BetterBrowser<M extends AnyModels, F extends AnyFunctions, E, C = unknown> {
|
|
42
|
+
interface BetterBrowser<M extends AnyModels, F extends AnyFunctions, E, C = unknown, P = unknown> {
|
|
43
43
|
/** The definition the browser was created from (schema metadata, specs, live queries). */
|
|
44
|
-
readonly sb: BetterSupabase<M, unknown, F, E, C>;
|
|
44
|
+
readonly sb: BetterSupabase<M, unknown, F, E, C, P>;
|
|
45
45
|
readonly supabase: SupabaseClient;
|
|
46
46
|
/** Repositories with the current session's actor and claims. */
|
|
47
47
|
readonly db: Db<M, F, E, SupabaseClient>;
|
|
@@ -57,6 +57,6 @@ interface BetterBrowser<M extends AnyModels, F extends AnyFunctions, E, C = unkn
|
|
|
57
57
|
* export const browser = createBrowser(sb, { env: { url, publishableKey } });
|
|
58
58
|
* ```
|
|
59
59
|
*/
|
|
60
|
-
declare function createBrowser<M extends AnyModels, D, F extends AnyFunctions, E, C = unknown>(sb: BetterSupabase<M, D, F, E, C>, options?: BrowserOptions): BetterBrowser<M, F, E, C>;
|
|
60
|
+
declare function createBrowser<M extends AnyModels, D, F extends AnyFunctions, E, C = unknown, P = unknown>(sb: BetterSupabase<M, D, F, E, C, P>, options?: BrowserOptions): BetterBrowser<M, F, E, C, P>;
|
|
61
61
|
//#endregion
|
|
62
62
|
export { BrowserOptions as a, BrowserAuth as i, AuthUser as n, createBrowser as o, BetterBrowser as r, AuthSnapshot as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { m as StoredSession } from "./resolve-
|
|
2
|
-
import "./view-
|
|
3
|
-
import "./entitlements-
|
|
1
|
+
import { m as StoredSession } from "./resolve-BRciX2jK.js";
|
|
2
|
+
import "./view-3Po_PVlr.js";
|
|
3
|
+
import "./entitlements-DvJXoI02.js";
|
|
4
4
|
//#region src/auth/refresh.d.ts
|
|
5
5
|
interface RefreshOptions {
|
|
6
6
|
readonly url: string;
|
|
@@ -14,6 +14,7 @@ interface RefreshOptions {
|
|
|
14
14
|
readonly secretKey: string;
|
|
15
15
|
};
|
|
16
16
|
readonly fetch?: typeof fetch;
|
|
17
|
+
/** Epoch milliseconds, the unit JWT `exp` and `iat` math needs. */
|
|
17
18
|
readonly now?: () => number;
|
|
18
19
|
}
|
|
19
20
|
type RefreshOutcome = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { A as SchemaMeta } from "./types-DONv9SHN.js";
|
|
2
|
+
import { p as OpenApiParameter } from "./index-CADlNHK-.js";
|
|
3
3
|
//#region src/openapi/index.d.ts
|
|
4
4
|
type Json = Record<string, unknown>;
|
|
5
5
|
type ResourceOperation = "list" | "get" | "create" | "update" | "delete";
|
|
@@ -9,7 +9,12 @@ interface ResourceOptions {
|
|
|
9
9
|
/** Parameters for `list`, from `defineListQuery`. */
|
|
10
10
|
readonly list?: {
|
|
11
11
|
readonly openapi: readonly OpenApiParameter[];
|
|
12
|
+
readonly pagination?: "offset" | "cursor";
|
|
12
13
|
};
|
|
14
|
+
/** Paging of the default list, as in `defineResource`. Defaults to `offset`. */
|
|
15
|
+
readonly pagination?: "offset" | "cursor";
|
|
16
|
+
/** Largest page of the default list. Defaults to 200. */
|
|
17
|
+
readonly maxPageSize?: number;
|
|
13
18
|
/** Path of the collection. Defaults to `/<table>`. */
|
|
14
19
|
readonly path?: string;
|
|
15
20
|
readonly tag?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { C as and, E as or, S as UpdateOp, T as not, _ as OrderTerm, a as AggregateFn, b as SelectOp, c as Condition, d as FunctionSource, f as Include, g as Operation, h as MutationOp, i as RpcContext, l as CountMode, m as Measure, n as ExecuteResult, o as Aggregation, p as InsertOp, r as Executor, s as ColumnOp, t as ExecuteContext, u as DeleteOp, v as Quantifier, w as column, x as Selection, y as SelectColumn } from "./executor-
|
|
3
|
-
import { C as isConflict, D as statusOf, E as mapDbError, S as isCheck, T as isForeignKey, _ as DbException, a as Ok, b as ValidationIssue, c as err, d as toBetterResult, f as toDbError, g as DbErrorOf, h as DbErrorKinds, i as Err, l as fromBetterResult, m as DbErrorKind, n as BetterResultApi, o as Result, p as DbError, r as
|
|
4
|
-
import { a as EventHub, c as QueryEvent, d as LogFields, f as Logger, i as EventHandler, l as RefreshEvent, m as silentLogger, n as BetterSupabaseEvents, o as EventName, p as consoleLogger, r as ErrorEvent, s as MutationNotice, t as AuthEvent, u as RpcNotice } from "./events-
|
|
5
|
-
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 RpcDefinition, 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 DefineSupabaseOptions, 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-
|
|
6
|
-
import { _ as definePlugin, a as ExtensionOf, c as MutationEvent, d as PLUGIN_API_VERSION, f as Plugin, g as WithExtension, h as RequestContext, i as CallOptions, l as MutationKind, m as RepositoryExtension, n as AnyPlugin, o as HasFlag, p as RepositoryApi, r as ApplyExtension, s as HookArgs, t as Actor, u as NoExtension } from "./plugin-
|
|
7
|
-
import { n as validate, t as StandardSchemaV1 } from "./standard-
|
|
8
|
-
import { a as compilePostgrest, i as PostgrestPlan, n as PlanLimit, r as PlanOrder, t as PlanFilter } from "./postgrest-
|
|
1
|
+
import { A as SchemaMeta, C as PrimaryKeyValue, D as Relations, E as RelationTypes, F as UniqueConstraint, I as UniqueKeyName, L as UniqueWhere, M as TableFlags, N as TableKey, O as Row, P as TableMeta, R as Update, S as PrimaryKeyColumn, T as RelationMeta, _ as ModelFlags, a as Casing, b as PermdockBucketPolicy, c as Codec, d as Flags, f as ForeignKeyConstraint, g as Insert, h as FunctionsOf, i as BucketPolicyName, j as Simplify, k as Schema, l as ColumnMeta, m as FunctionTypes, n as AnyModels, o as CheckConstraint, p as FunctionMeta, r as BucketMeta, s as ClaimsMeta, t as AnyFunctions, u as DatabaseOf, v as ModelTypes, w as RealtimeTableMeta, x as PermdockTopicPolicy, y as ModelsOf } from "./types-DONv9SHN.js";
|
|
2
|
+
import { C as and, E as or, S as UpdateOp, T as not, _ as OrderTerm, a as AggregateFn, b as SelectOp, c as Condition, d as FunctionSource, f as Include, g as Operation, h as MutationOp, i as RpcContext, l as CountMode, m as Measure, n as ExecuteResult, o as Aggregation, p as InsertOp, r as Executor, s as ColumnOp, t as ExecuteContext, u as DeleteOp, v as Quantifier, w as column, x as Selection, y as SelectColumn } from "./executor-DynmIWhq.js";
|
|
3
|
+
import { C as isConflict, D as statusOf, E as mapDbError, S as isCheck, T as isForeignKey, _ as DbException, a as Ok, b as ValidationIssue, c as err, d as toBetterResult, f as toDbError, g as DbErrorOf, h as DbErrorKinds, i as Err, l as fromBetterResult, m as DbErrorKind, n as BetterResultApi, o as Result, p as DbError, r as BetterResultValue, t as AsyncResult, u as ok, v as ErrorMapper, w as isDbError, x as dbError, y as RawDbError } from "./result-c2OYgCV2.js";
|
|
4
|
+
import { a as EventHub, c as QueryEvent, d as LogFields, f as Logger, i as EventHandler, l as RefreshEvent, m as silentLogger, n as BetterSupabaseEvents, o as EventName, p as consoleLogger, r as ErrorEvent, s as MutationNotice, t as AuthEvent, u as RpcNotice } from "./events-Do8jXh4D.js";
|
|
5
|
+
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 RpcDefinition, 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 DefineSupabaseOptions, 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-DUbydmJa.js";
|
|
6
|
+
import { _ as definePlugin, a as ExtensionOf, c as MutationEvent, d as PLUGIN_API_VERSION, f as Plugin, g as WithExtension, h as RequestContext, i as CallOptions, l as MutationKind, m as RepositoryExtension, n as AnyPlugin, o as HasFlag, p as RepositoryApi, r as ApplyExtension, s as HookArgs, t as Actor, u as NoExtension } from "./plugin-DVRB8qNE.js";
|
|
7
|
+
import { n as validate, t as StandardSchemaV1 } from "./standard-eudBiRk1.js";
|
|
8
|
+
import { a as compilePostgrest, i as PostgrestPlan, n as PlanLimit, r as PlanOrder, t as PlanFilter } from "./postgrest-DmBlevh-.js";
|
|
9
9
|
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-
|
|
12
|
-
import { t as SPEC_PINS } from "./spec-pins-
|
|
10
|
+
import { n as postgrestCompiler, t as Compiler } from "./compiler-2zqGzxVZ.js";
|
|
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-Z2RTQjZD.js";
|
|
12
|
+
import { t as SPEC_PINS } from "./spec-pins-CqorWDnO.js";
|
|
13
13
|
//#region src/core/define-repository.d.ts
|
|
14
14
|
/** Adds `Methods` to the repository of `Table` only. */
|
|
15
15
|
interface TableRepositoryExtension<Table extends string, Methods> extends RepositoryExtension {
|
|
@@ -71,7 +71,7 @@ type EnrichDatabase<D, O> = { [S in keyof D]: S extends keyof O ? EnrichSchema<D
|
|
|
71
71
|
export declare function escapeLike(value: string): string;
|
|
72
72
|
//#endregion
|
|
73
73
|
//#region src/ir/codec.d.ts
|
|
74
|
-
/** Wire form of an app value:
|
|
74
|
+
/** Wire form of an app value: Temporal values to ISO text, `bigint` to decimal text. */
|
|
75
75
|
export declare function encodeValue(value: unknown): unknown;
|
|
76
76
|
/** Applies column codecs to returned rows, including embedded relations. */
|
|
77
77
|
export declare function decodeRows(selection: Selection | undefined, rows: readonly Record<string, unknown>[]): Record<string, unknown>[];
|
|
@@ -107,4 +107,4 @@ export declare function toCamel(name: string): string;
|
|
|
107
107
|
/** `firstName` to `first_name`. */
|
|
108
108
|
export declare function toSnake(name: string): string;
|
|
109
109
|
//#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
|
|
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 DefineSupabaseOptions, 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 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,17 +1,17 @@
|
|
|
1
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-Bl3rkOzo.js";
|
|
2
|
-
import { i as escapeLike, l as defineSchema, o as decodeRows, s as encodeValue, t as simplify, u as tableMeta } from "./simplify-
|
|
2
|
+
import { i as escapeLike, l as defineSchema, o as decodeRows, s as encodeValue, t as simplify, u as tableMeta } from "./simplify-LakqK1vH.js";
|
|
3
3
|
import { i as or, n as column, r as not, t as and } from "./types-6cYK9pbJ.js";
|
|
4
4
|
import { a as toBetterResult, i as ok, n as err, o as toDbError, r as fromBetterResult, t as AsyncResult } from "./result-DWXatkd6.js";
|
|
5
|
-
import { a as EventHub, c as
|
|
6
|
-
import { n as touchedTables, t as invalidationTargets } from "./tables-
|
|
5
|
+
import { a as EventHub, c as rowKey, i as encodeCursor, l as rpcCacheTargets, n as defineSupabase, o as cacheTargetOf, r as decodeCursor, s as memoryCache, t as BetterSupabase } from "./define-DF341GDj.js";
|
|
6
|
+
import { n as touchedTables, t as invalidationTargets } from "./tables-Dhha3BXM.js";
|
|
7
|
+
import { n as silentLogger, t as consoleLogger } from "./logger-glM28NVN.js";
|
|
7
8
|
import { n as definePlugin, t as PLUGIN_API_VERSION } from "./plugin-BqR6wKMB.js";
|
|
8
|
-
import { a as postgrestExecutor, i as explainPostgrest, n as StatsRecorder, o as compilePostgrest, r as recordStats, t as EMPTY_STATS } from "./stats-
|
|
9
|
-
import { c as readSetTables, d as isQuerySpec, f as specTables, i as defineReadSet, o as isReadSet } from "./read-set-
|
|
9
|
+
import { a as postgrestExecutor, i as explainPostgrest, n as StatsRecorder, o as compilePostgrest, r as recordStats, t as EMPTY_STATS } from "./stats-D78UQ8Yu.js";
|
|
10
|
+
import { c as readSetTables, d as isQuerySpec, f as specTables, i as defineReadSet, o as isReadSet } from "./read-set-D0qBcboM.js";
|
|
10
11
|
import { t as validate } from "./standard-FUi3Z3-7.js";
|
|
11
|
-
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-
|
|
12
|
-
import { t as SPEC_PINS } from "./spec-pins-
|
|
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-CGt1ADix.js";
|
|
13
|
+
import { t as SPEC_PINS } from "./spec-pins-C3oc-Tdp.js";
|
|
13
14
|
import { n as scopeOperation, r as scopeSelection, t as scopeCondition } from "./scope-CDHcS7dE.js";
|
|
14
|
-
import { n as toCamel, r as toSnake } from "./casing-da0uRTqt.js";
|
|
15
15
|
//#region src/core/define-repository.ts
|
|
16
16
|
/**
|
|
17
17
|
* Domain methods for one table, installed with `use()`. `base` is the
|
|
@@ -39,4 +39,14 @@ const postgrestCompiler = {
|
|
|
39
39
|
compile: compilePostgrest
|
|
40
40
|
};
|
|
41
41
|
//#endregion
|
|
42
|
+
//#region src/casing/index.ts
|
|
43
|
+
/** `first_name` to `firstName`. Leaves already camel-cased names untouched. */
|
|
44
|
+
function toCamel(name) {
|
|
45
|
+
return name.replaceAll(/_+([a-z0-9])/g, (_, char) => char.toUpperCase());
|
|
46
|
+
}
|
|
47
|
+
/** `firstName` to `first_name`. */
|
|
48
|
+
function toSnake(name) {
|
|
49
|
+
return name.replaceAll(/([a-z0-9])([A-Z])/g, "$1_$2").replaceAll(/([A-Z])([A-Z][a-z])/g, "$1_$2").toLowerCase();
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
42
52
|
export { AsyncResult, BetterSupabase, DbException, EMPTY_STATS, EventHub, PLUGIN_API_VERSION, PROBLEM_CONTENT_TYPE, PROBLEM_TYPE_BASE, SPEC_PINS, StatsRecorder, and, cacheTargetOf, column, compilePostgrest, consoleLogger, dbError, decodeCursor, decodeRows, definePlugin, defineReadSet, defineRepository, defineSchema, defineSupabase, encodeCursor, encodeValue, err, escapeLike, explainPostgrest, fromBetterResult, fromProblem, invalidationTargets, isCheck, isConflict, isDbError, isForeignKey, isProblem, isQuerySpec, isReadSet, mapDbError, memoryCache, not, ok, or, postgrestCompiler, postgrestExecutor, problemResponse, readSetTables, recordStats, rowKey, rpcCacheTargets, scopeCondition, scopeOperation, scopeSelection, silentLogger, simplify, specTables, statusOf, tableMeta, toBetterResult, toCamel, toDbError, toProblem, toSnake, touchedTables, validate };
|
package/dist/jobs/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import { t as
|
|
1
|
+
/// <reference lib="esnext.temporal" />
|
|
2
|
+
import { o as Result, p as DbError, t as AsyncResult } from "../result-c2OYgCV2.js";
|
|
3
|
+
import { t as SqlClient } from "../executor-B26lgbHD.js";
|
|
3
4
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
|
-
//#region src/jobs/
|
|
5
|
-
|
|
5
|
+
//#region src/jobs/jobs.d.ts
|
|
6
|
+
type QueueSchemas = Readonly<Record<string, StandardSchemaV1>>;
|
|
6
7
|
type PayloadIn<Q extends QueueSchemas, N extends keyof Q> = StandardSchemaV1.InferInput<Q[N]>;
|
|
7
8
|
type PayloadOut<Q extends QueueSchemas, N extends keyof Q> = StandardSchemaV1.InferOutput<Q[N]>;
|
|
8
|
-
|
|
9
|
+
interface Job<P = unknown> {
|
|
9
10
|
/** The pgmq message id. */
|
|
10
11
|
readonly id: number;
|
|
11
12
|
readonly queue: string;
|
|
@@ -13,14 +14,14 @@ export interface Job<P = unknown> {
|
|
|
13
14
|
/** 1 on the first run (pgmq's `read_ct`). */
|
|
14
15
|
readonly attempts: number;
|
|
15
16
|
readonly maxAttempts: number;
|
|
16
|
-
readonly enqueuedAt:
|
|
17
|
+
readonly enqueuedAt: Temporal.Instant;
|
|
17
18
|
/** End of the lease: the job becomes claimable again after this. */
|
|
18
|
-
readonly visibleUntil:
|
|
19
|
+
readonly visibleUntil: Temporal.Instant;
|
|
19
20
|
readonly lastError: string | null;
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
+
interface EnqueueOptions {
|
|
22
23
|
/** Run no earlier than this. */
|
|
23
|
-
readonly runAt?:
|
|
24
|
+
readonly runAt?: Temporal.Instant;
|
|
24
25
|
/** Seconds to wait before running. */
|
|
25
26
|
readonly delay?: number;
|
|
26
27
|
/** Defaults to 5. After this many failed attempts the job is archived as dead. */
|
|
@@ -31,18 +32,18 @@ export interface EnqueueOptions {
|
|
|
31
32
|
*/
|
|
32
33
|
readonly dedupeKey?: string;
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
+
interface ClaimOptions {
|
|
35
36
|
/** Defaults to 1. */
|
|
36
37
|
readonly batch?: number;
|
|
37
38
|
/** Seconds a claimed job stays invisible to other workers. Defaults to 300. */
|
|
38
39
|
readonly lease?: number;
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
+
interface FailOptions {
|
|
41
42
|
/** Retry after this many seconds instead of the exponential backoff. SQL connections only. */
|
|
42
43
|
readonly retryIn?: number;
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
type JobHandler<P> = (payload: P, job: Job<P>, signal: AbortSignal) => unknown;
|
|
46
|
+
interface WorkOptions extends ClaimOptions {
|
|
46
47
|
/** Jobs handled at once. Defaults to 1. */
|
|
47
48
|
readonly concurrency?: number;
|
|
48
49
|
/** Wait between polls when the queue is empty, in ms. Defaults to 1000. */
|
|
@@ -51,11 +52,11 @@ export interface WorkOptions extends ClaimOptions {
|
|
|
51
52
|
readonly signal?: AbortSignal;
|
|
52
53
|
readonly onError?: (error: DbError, job: Job) => void;
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
+
interface DrainResult {
|
|
55
56
|
readonly succeeded: number;
|
|
56
57
|
readonly failed: number;
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
+
interface Jobs<Q extends QueueSchemas> {
|
|
59
60
|
/** Validates the payload with the queue's schema, then enqueues it. Returns the job id. */
|
|
60
61
|
enqueue<N extends Extract<keyof Q, string>>(queue: N, payload: PayloadIn<Q, N>, options?: EnqueueOptions): AsyncResult<number>;
|
|
61
62
|
claim<N extends Extract<keyof Q, string>>(queue: N, options?: ClaimOptions): AsyncResult<Job<PayloadOut<Q, N>>[]>;
|
|
@@ -77,7 +78,7 @@ export interface Jobs<Q extends QueueSchemas> {
|
|
|
77
78
|
work<N extends Extract<keyof Q, string>>(queue: N, handler: JobHandler<PayloadOut<Q, N>>, options?: WorkOptions): Promise<DrainResult>;
|
|
78
79
|
}
|
|
79
80
|
/** A Supabase client, or anything with `.schema(name).rpc(fn, args)`. */
|
|
80
|
-
|
|
81
|
+
interface QueueRpcClient {
|
|
81
82
|
schema(name: string): {
|
|
82
83
|
rpc(fn: string, args: Readonly<Record<string, unknown>>): PromiseLike<{
|
|
83
84
|
data: unknown;
|
|
@@ -94,7 +95,7 @@ export interface QueueRpcClient {
|
|
|
94
95
|
* Queue names are lowercase letters, digits and underscores.
|
|
95
96
|
*/
|
|
96
97
|
export declare function createJobs<const Q extends QueueSchemas>(source: SqlClient | QueueRpcClient, queues: Q): Jobs<Q>;
|
|
97
|
-
|
|
98
|
+
interface IdempotencyOptions {
|
|
98
99
|
/** Separates keys of different endpoints or tenants. Defaults to `''`. */
|
|
99
100
|
readonly scope?: string | ((request: Request) => string);
|
|
100
101
|
/** How long a completed response is replayed. Defaults to `24 hours`. */
|
|
@@ -106,8 +107,8 @@ export interface IdempotencyOptions {
|
|
|
106
107
|
/** Defaults to `Idempotency-Key`. */
|
|
107
108
|
readonly header?: string;
|
|
108
109
|
}
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
type IdempotencyState = "started" | "replay" | "running" | "mismatch";
|
|
111
|
+
interface Idempotency {
|
|
111
112
|
/**
|
|
112
113
|
* Runs `handler` at most once per key: retries with the same key and body
|
|
113
114
|
* get the stored response (with `Idempotency-Replayed: true`).
|
|
@@ -124,7 +125,7 @@ export interface Idempotency {
|
|
|
124
125
|
}
|
|
125
126
|
/** HTTP idempotency keys (IETF `Idempotency-Key` header) over the `idempotency` SQL kit module. */
|
|
126
127
|
export declare function createIdempotency(sql: SqlClient, options?: IdempotencyOptions): Idempotency;
|
|
127
|
-
|
|
128
|
+
interface InboxMessage<T = unknown> {
|
|
128
129
|
readonly id: number;
|
|
129
130
|
readonly source: string;
|
|
130
131
|
readonly messageId: string;
|
|
@@ -132,9 +133,9 @@ export interface InboxMessage<T = unknown> {
|
|
|
132
133
|
readonly payload: T;
|
|
133
134
|
readonly headers: Readonly<Record<string, string>>;
|
|
134
135
|
readonly attempts: number;
|
|
135
|
-
readonly receivedAt:
|
|
136
|
+
readonly receivedAt: Temporal.Instant;
|
|
136
137
|
}
|
|
137
|
-
|
|
138
|
+
interface InboxOptions {
|
|
138
139
|
/** Name of the sender, e.g. `stripe` or `supabase-auth`. */
|
|
139
140
|
readonly source: string;
|
|
140
141
|
/** Standard Webhooks secrets; the signature is verified before storing. */
|
|
@@ -150,7 +151,7 @@ export interface InboxOptions {
|
|
|
150
151
|
readonly keepHeaders?: readonly string[];
|
|
151
152
|
readonly worker?: string;
|
|
152
153
|
}
|
|
153
|
-
|
|
154
|
+
interface Inbox {
|
|
154
155
|
/** Verifies and stores a webhook; answers 202, or 200 for a duplicate delivery. */
|
|
155
156
|
receive(request: Request): Promise<Response>;
|
|
156
157
|
/** Processes stored messages until none are ready. */
|
|
@@ -170,4 +171,4 @@ export declare const ENTITLEMENTS_UPDATED = "entitlements.active_entitlement_sum
|
|
|
170
171
|
*/
|
|
171
172
|
export declare function entitlementMembers(sql: SqlClient, payload: unknown): AsyncResult<readonly string[]>;
|
|
172
173
|
//#endregion
|
|
173
|
-
export type { SqlClient };
|
|
174
|
+
export type { ClaimOptions, DrainResult, EnqueueOptions, FailOptions, Idempotency, IdempotencyOptions, IdempotencyState, Inbox, InboxMessage, InboxOptions, Job, JobHandler, Jobs, QueueRpcClient, QueueSchemas, SqlClient, WorkOptions };
|