better-supabase 0.2.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.
Files changed (139) hide show
  1. package/README.md +34 -31
  2. package/dist/base64-CQeB1eSf.js +42 -0
  3. package/dist/client/index.d.ts +1 -1
  4. package/dist/client/index.js +4 -14
  5. package/dist/{compiler-CZ9nIuqy.d.ts → compiler-2zqGzxVZ.d.ts} +2 -2
  6. package/dist/config/index.d.ts +4 -3
  7. package/dist/config/index.js +5 -3
  8. package/dist/config-Be4GwsqI.js +129 -0
  9. package/dist/{index-DOsjFvMf.d.ts → config-C1CYcm6o.d.ts} +49 -49
  10. package/dist/{config-ClDXmVtY.js → config-DOsGYSiT.js} +14 -137
  11. package/dist/{define-BXMYD9AY.js → define-DF341GDj.js} +71 -51
  12. package/dist/{define-e3zI4_4g.d.ts → define-DUbydmJa.d.ts} +10 -9
  13. package/dist/edge/index.d.ts +4 -4
  14. package/dist/edge/index.js +4 -4
  15. package/dist/{entitlements-Dng-ctuT.d.ts → entitlements-DvJXoI02.d.ts} +1 -1
  16. package/dist/env/index.js +203 -1
  17. package/dist/events/index.d.ts +1 -1
  18. package/dist/events/index.js +139 -1
  19. package/dist/{events-DOt3nSO-.d.ts → events-Do8jXh4D.d.ts} +3 -3
  20. package/dist/{executor-BYXQ9AGn.d.ts → executor-B26lgbHD.d.ts} +2 -2
  21. package/dist/{executor-DeppvirK.js → executor-C57jx2pn.js} +7 -2
  22. package/dist/{executor-CGdNQ27g.d.ts → executor-DynmIWhq.d.ts} +2 -2
  23. package/dist/hono/index.d.ts +5 -5
  24. package/dist/hono/index.js +4 -4
  25. package/dist/{index-CBDufH1M.d.ts → index-BNsABq7P.d.ts} +8 -8
  26. package/dist/{index-Bw1bwtC0.d.ts → index-CADlNHK-.d.ts} +27 -14
  27. package/dist/{index-DuP14VHo.d.ts → index-CTTMS6_1.d.ts} +19 -8
  28. package/dist/index-Cf-D2jk1.d.ts +50 -0
  29. package/dist/{index-K-3WM2Hp.d.ts → index-CriFFJ_p.d.ts} +4 -4
  30. package/dist/{index-Ciu5Xlml.d.ts → index-GV77NpRP.d.ts} +5 -4
  31. package/dist/{index-D4v7sncu.d.ts → index-UJ-LUxtI.d.ts} +3 -3
  32. package/dist/{index-CG69s15v.d.ts → index-kpgopLNv.d.ts} +4 -3
  33. package/dist/{index-DbxFr7XG.d.ts → index-qriRM9cZ.d.ts} +7 -2
  34. package/dist/index.d.ts +12 -12
  35. package/dist/index.js +16 -7
  36. package/dist/jobs/index.d.ts +25 -24
  37. package/dist/jobs/index.js +16 -10
  38. package/dist/{json-schema-BpYqkCKf.js → json-schema--aOXAGfU.js} +7 -2
  39. package/dist/lint/index.js +1 -1
  40. package/dist/list/index.d.ts +2 -2
  41. package/dist/list/index.js +128 -93
  42. package/dist/{live-DJyZMD6w.d.ts → live-QE3UPbGm.d.ts} +16 -6
  43. package/dist/mcp/index.d.ts +24 -17
  44. package/dist/mcp/index.js +41 -12
  45. package/dist/{mfa-CpLfJSde.js → mfa-BxoR1RkN.js} +74 -19
  46. package/dist/{mfa-TVia554c.d.ts → mfa-x3V3vGh-.d.ts} +1 -1
  47. package/dist/next/index.d.ts +39 -26
  48. package/dist/next/index.js +28 -23
  49. package/dist/openapi/index.d.ts +1 -1
  50. package/dist/openapi/index.js +57 -34
  51. package/dist/orpc/index.d.ts +6 -6
  52. package/dist/orpc/index.js +3 -3
  53. package/dist/otel/index.d.ts +2 -2
  54. package/dist/otel/index.js +4 -2
  55. package/dist/{permdock-sql-CghlHPuH.js → permdock-sql-Bta_G0v-.js} +11 -6
  56. package/dist/permdock-sql-DImJULY-.d.ts +17 -0
  57. package/dist/{plugin-C4TR9J0Z.d.ts → plugin-DVRB8qNE.d.ts} +5 -4
  58. package/dist/plugins/actor/index.d.ts +1 -1
  59. package/dist/plugins/rules/index.d.ts +2 -2
  60. package/dist/plugins/rules/index.js +4 -4
  61. package/dist/plugins/soft-delete/index.d.ts +3 -3
  62. package/dist/plugins/soft-delete/index.js +2 -2
  63. package/dist/plugins/tenant/index.d.ts +2 -2
  64. package/dist/plugins/timestamps/index.d.ts +1 -1
  65. package/dist/plugins/timestamps/index.js +1 -1
  66. package/dist/plugins/validation/index.d.ts +2 -2
  67. package/dist/pool-B9qsLyFR.d.ts +71 -0
  68. package/dist/postgres/index.d.ts +10 -5
  69. package/dist/postgres/index.js +36 -16
  70. package/dist/{postgrest-cAEQ_IQN.d.ts → postgrest-DmBlevh-.d.ts} +1 -1
  71. package/dist/{problem-BTkTtRV9.js → problem-CGt1ADix.js} +10 -4
  72. package/dist/{problem-DlgB0lYl.d.ts → problem-Z2RTQjZD.d.ts} +6 -4
  73. package/dist/query/index.d.ts +2 -2
  74. package/dist/query/index.js +1 -1
  75. package/dist/{query-ChvDbsDE.js → query-BdKLTPlj.js} +2 -2
  76. package/dist/react/index.d.ts +7 -7
  77. package/dist/react/index.js +2 -2
  78. package/dist/react/server.d.ts +3 -3
  79. package/dist/react/server.js +1 -1
  80. package/dist/react/session.d.ts +21 -2
  81. package/dist/react/session.js +19 -1
  82. package/dist/{react-C83BdBGt.js → react-DNBYNazu.js} +20 -16
  83. package/dist/{read-set-4lI3W_gZ.js → read-set-D0qBcboM.js} +3 -3
  84. package/dist/realtime/index.d.ts +4 -3
  85. package/dist/realtime/index.js +7 -6
  86. package/dist/{resolve-CjHILk2w.d.ts → resolve-BRciX2jK.d.ts} +6 -5
  87. package/dist/{resource-CgZa3YG_.d.ts → resource-CwVgiI5q.d.ts} +16 -7
  88. package/dist/{resource-BHEWmQJK.js → resource-D30rp0GN.js} +38 -16
  89. package/dist/{respond-DMcbQwfN.js → respond-C44EZAJo.js} +35 -19
  90. package/dist/{respond-Dne1ARSa.d.ts → respond-DAkPIdTH.d.ts} +15 -9
  91. package/dist/{result-CTkCZ6JA.d.ts → result-c2OYgCV2.d.ts} +13 -8
  92. package/dist/server/index.d.ts +35 -10
  93. package/dist/server/index.js +38 -9
  94. package/dist/{simplify-bwJpLnaS.js → simplify-LakqK1vH.js} +10 -16
  95. package/dist/sql/index.d.ts +139 -0
  96. package/dist/sql/index.js +1983 -0
  97. package/dist/{sql-DTjA1LPj.js → sql-BIgk12ew.js} +72 -16
  98. package/dist/ssr/index.d.ts +4 -4
  99. package/dist/ssr/index.js +2 -2
  100. package/dist/{standard-CyhRzctb.d.ts → standard-eudBiRk1.d.ts} +1 -1
  101. package/dist/{stats-C5W-rBfR.js → stats-D78UQ8Yu.js} +8 -7
  102. package/dist/storage/index.d.ts +4 -3
  103. package/dist/storage/index.js +530 -1
  104. package/dist/{tables-rZxRxNPW.js → tables-Dhha3BXM.js} +5 -5
  105. package/dist/temporal-BwshQk0W.js +27 -0
  106. package/dist/temporal-required-CMxeSVPo.js +19 -0
  107. package/dist/testing/index.d.ts +13 -11
  108. package/dist/testing/index.js +128 -29
  109. package/dist/{types-C83v5SQz.d.ts → types-DONv9SHN.d.ts} +14 -11
  110. package/dist/{version-Cqq1m3UY.js → version-BfpG2gks.js} +1 -1
  111. package/dist/{view-D1s0wa0T.d.ts → view-3Po_PVlr.d.ts} +34 -4
  112. package/dist/{view-aOYizTeE.js → view-wZ-9qIUz.js} +11 -2
  113. package/dist/webhooks/index.d.ts +18 -16
  114. package/dist/webhooks/index.js +1 -1
  115. package/dist/{webhooks-DMipjhSP.js → webhooks-CAIFQSTM.js} +11 -9
  116. package/package.json +24 -28
  117. package/schemas/config-v1.json +31 -1
  118. package/schemas/doctor-report-v1.json +17 -1
  119. package/schemas/snapshot-v2.json +35 -0
  120. package/skills/better-supabase/SKILL.md +23 -11
  121. package/skills/better-supabase/references/plugins.md +21 -18
  122. package/skills/better-supabase/references/troubleshooting.md +15 -15
  123. package/skills/better-supabase-api/SKILL.md +7 -7
  124. package/skills/better-supabase-api/references/adapters.md +30 -25
  125. package/skills/better-supabase-testing/SKILL.md +11 -8
  126. package/bin/better-supabase.js +0 -4
  127. package/dist/casing-da0uRTqt.js +0 -14
  128. package/dist/cli/bin.d.ts +0 -1
  129. package/dist/cli/bin.js +0 -15
  130. package/dist/cli/index.d.ts +0 -226
  131. package/dist/cli/index.js +0 -3
  132. package/dist/cli-DrSgDOQC.js +0 -6646
  133. package/dist/env-BEToab0I.js +0 -204
  134. package/dist/events-BuzTgn2D.js +0 -135
  135. package/dist/pool-R2m_DkXi.d.ts +0 -37
  136. package/dist/seed-CzecODcJ.js +0 -101
  137. package/dist/session-C3LxnQ0e.d.ts +0 -22
  138. package/dist/session-CqEwzVup.js +0 -20
  139. package/dist/storage-DuGn38fr.js +0 -527
@@ -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 { C as PrimaryKeyValue, L as UniqueWhere, N as TableKey, R as Update, _ as Insert, n as AnyModels, t as AnyFunctions } from "./types-C83v5SQz.js";
2
- import { _ as DbException } from "./result-CTkCZ6JA.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-e3zI4_4g.js";
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/index.d.ts
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
- import { A as SchemaMeta } from "./types-C83v5SQz.js";
2
- import { a as EventHub, s as MutationNotice } from "./events-DOt3nSO-.js";
3
- import { l as MutationKind } from "./plugin-C4TR9J0Z.js";
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?: () => Date;
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-C83v5SQz.js";
2
- import { t as BetterSupabase, y as Db } from "./define-e3zI4_4g.js";
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-K-3WM2Hp.js";
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 {
@@ -1,6 +1,6 @@
1
- import { m as StoredSession } from "./resolve-CjHILk2w.js";
2
- import "./view-D1s0wa0T.js";
3
- import "./entitlements-Dng-ctuT.js";
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 { A as SchemaMeta } from "./types-C83v5SQz.js";
2
- import { f as OpenApiParameter } from "./index-Bw1bwtC0.js";
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,14 +1,14 @@
1
- import { A as SchemaMeta, C as PrimaryKeyValue, D as Relations, E as RelationShape, 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 Insert, a as Casing, b as PermdockBucketPolicy, c as Codec, d as Flags, f as FlagsShape, g as FunctionsOf, h as FunctionShape, i as BucketPolicyName, j as Simplify, k as Schema, l as ColumnMeta, m as FunctionMeta, n as AnyModels, o as CheckConstraint, p as ForeignKeyConstraint, r as BucketMeta, s as ClaimsMeta, t as AnyFunctions, u as DatabaseOf, v as ModelShape, w as RealtimeTableMeta, x as PermdockTopicPolicy, y as ModelsOf } from "./types-C83v5SQz.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-CGdNQ27g.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 BetterResultShape, t as AsyncResult, u as ok, v as ErrorMapper, w as isDbError, x as dbError, y as RawDbError } from "./result-CTkCZ6JA.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-DOt3nSO-.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-e3zI4_4g.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-C4TR9J0Z.js";
7
- import { n as validate, t as StandardSchemaV1 } from "./standard-CyhRzctb.js";
8
- import { a as compilePostgrest, i as PostgrestPlan, n as PlanLimit, r as PlanOrder, t as PlanFilter } from "./postgrest-cAEQ_IQN.js";
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-CZ9nIuqy.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-DlgB0lYl.js";
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
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. */
@@ -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: `Date` to ISO text, `bigint` to decimal text. */
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 BetterResultShape, 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 FlagsShape, type ForeignKeyConstraint, type FunctionMeta, type FunctionShape, type FunctionSource, 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 ModelShape, 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 RelationShape, 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 };
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,18 +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-bwJpLnaS.js";
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 rowKey, i as encodeCursor, l as rpcCacheTargets, n as defineSupabase, o as cacheTargetOf, r as decodeCursor, s as memoryCache, t as BetterSupabase } from "./define-BXMYD9AY.js";
6
- import { n as touchedTables, t as invalidationTargets } from "./tables-rZxRxNPW.js";
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
7
  import { n as silentLogger, t as consoleLogger } from "./logger-glM28NVN.js";
8
8
  import { n as definePlugin, t as PLUGIN_API_VERSION } from "./plugin-BqR6wKMB.js";
9
- import { a as postgrestExecutor, i as explainPostgrest, n as StatsRecorder, o as compilePostgrest, r as recordStats, t as EMPTY_STATS } from "./stats-C5W-rBfR.js";
10
- import { c as readSetTables, d as isQuerySpec, f as specTables, i as defineReadSet, o as isReadSet } from "./read-set-4lI3W_gZ.js";
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";
11
11
  import { t as validate } from "./standard-FUi3Z3-7.js";
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-BTkTtRV9.js";
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
13
  import { t as SPEC_PINS } from "./spec-pins-C3oc-Tdp.js";
14
14
  import { n as scopeOperation, r as scopeSelection, t as scopeCondition } from "./scope-CDHcS7dE.js";
15
- import { n as toCamel, r as toSnake } from "./casing-da0uRTqt.js";
16
15
  //#region src/core/define-repository.ts
17
16
  /**
18
17
  * Domain methods for one table, installed with `use()`. `base` is the
@@ -40,4 +39,14 @@ const postgrestCompiler = {
40
39
  compile: compilePostgrest
41
40
  };
42
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
43
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 };
@@ -1,11 +1,12 @@
1
- import { o as Result, p as DbError, t as AsyncResult } from "../result-CTkCZ6JA.js";
2
- import { t as SqlClient } from "../executor-BYXQ9AGn.js";
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/index.d.ts
5
- export type QueueSchemas = Readonly<Record<string, StandardSchemaV1>>;
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
- export interface Job<P = unknown> {
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: Date;
17
+ readonly enqueuedAt: Temporal.Instant;
17
18
  /** End of the lease: the job becomes claimable again after this. */
18
- readonly visibleUntil: Date;
19
+ readonly visibleUntil: Temporal.Instant;
19
20
  readonly lastError: string | null;
20
21
  }
21
- export interface EnqueueOptions {
22
+ interface EnqueueOptions {
22
23
  /** Run no earlier than this. */
23
- readonly runAt?: Date;
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
- export interface ClaimOptions {
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
- export interface FailOptions {
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
- export type JobHandler<P> = (payload: P, job: Job<P>, signal: AbortSignal) => unknown;
45
- export interface WorkOptions extends ClaimOptions {
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
- export interface DrainResult {
55
+ interface DrainResult {
55
56
  readonly succeeded: number;
56
57
  readonly failed: number;
57
58
  }
58
- export interface Jobs<Q extends QueueSchemas> {
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
- export interface QueueRpcClient {
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
- export interface IdempotencyOptions {
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
- export type IdempotencyState = "started" | "replay" | "running" | "mismatch";
110
- export interface Idempotency {
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
- export interface InboxMessage<T = unknown> {
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: Date;
136
+ readonly receivedAt: Temporal.Instant;
136
137
  }
137
- export interface InboxOptions {
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
- export interface Inbox {
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 };
@@ -1,10 +1,12 @@
1
1
  import { c as mapDbError, n as dbError, t as DbException } from "../errors-Bl3rkOzo.js";
2
+ import { n as nowInstant } from "../temporal-BwshQk0W.js";
3
+ import { t as temporal } from "../temporal-required-CMxeSVPo.js";
2
4
  import { i as ok, n as err, o as toDbError, t as AsyncResult } from "../result-DWXatkd6.js";
3
5
  import { t as validate } from "../standard-FUi3Z3-7.js";
4
- import { a as problemResponse } from "../problem-BTkTtRV9.js";
5
- import { t as fromPgError } from "../executor-DeppvirK.js";
6
- import { c as verifyWebhook } from "../webhooks-DMipjhSP.js";
7
- //#region src/jobs/index.ts
6
+ import { a as problemResponse } from "../problem-CGt1ADix.js";
7
+ import { t as fromPgError } from "../executor-C57jx2pn.js";
8
+ import { c as verifyWebhook } from "../webhooks-CAIFQSTM.js";
9
+ //#region src/jobs/jobs.ts
8
10
  function run(fn) {
9
11
  return AsyncResult.from(async () => {
10
12
  try {
@@ -22,7 +24,10 @@ function workerId() {
22
24
  return `worker-${crypto.randomUUID().slice(0, 8)}`;
23
25
  }
24
26
  const sleep = (ms, signal) => new Promise((resolve) => {
25
- if (signal?.aborted) return resolve();
27
+ if (signal?.aborted) {
28
+ resolve();
29
+ return;
30
+ }
26
31
  const timer = setTimeout(done, ms);
27
32
  function done() {
28
33
  clearTimeout(timer);
@@ -149,7 +154,8 @@ function postgrestTransport(client) {
149
154
  unschedule: () => sqlOnly("unschedule")
150
155
  };
151
156
  }
152
- const toDate = (value) => value instanceof Date ? value : new Date(value);
157
+ /** pgmq and the inbox return `timestamptz` as text over RPC and as `Date` from `pg`. */
158
+ const toInstant = (value) => value instanceof Date ? temporal().Instant.fromEpochMilliseconds(value.getTime()) : temporal().Instant.from(value);
153
159
  function toJob(queue, row) {
154
160
  const message = row.message ?? {};
155
161
  return {
@@ -158,8 +164,8 @@ function toJob(queue, row) {
158
164
  payload: message.payload,
159
165
  attempts: row.attempts,
160
166
  maxAttempts: message.max_attempts ?? 5,
161
- enqueuedAt: toDate(row.enqueued_at),
162
- visibleUntil: toDate(row.visible_until),
167
+ enqueuedAt: toInstant(row.enqueued_at),
168
+ visibleUntil: toInstant(row.visible_until),
163
169
  lastError: message.last_error ?? null
164
170
  };
165
171
  }
@@ -254,7 +260,7 @@ function createJobs(source, queues) {
254
260
  return AsyncResult.from(async () => {
255
261
  const valid = await validate(schemaOf(queue), payload, "payload");
256
262
  if (!valid.ok) return valid;
257
- const delay = enqueueOptions.delay ?? (enqueueOptions.runAt ? Math.max(0, Math.ceil((enqueueOptions.runAt.getTime() - Date.now()) / 1e3)) : 0);
263
+ const delay = enqueueOptions.delay ?? (enqueueOptions.runAt ? Math.max(0, Math.ceil((enqueueOptions.runAt.epochMilliseconds - nowInstant().epochMilliseconds) / 1e3)) : 0);
258
264
  return run(() => transport.send(queue, valid.data, delay, enqueueOptions.maxAttempts ?? 5, enqueueOptions.dedupeKey));
259
265
  });
260
266
  },
@@ -435,7 +441,7 @@ function createInbox(sql, options) {
435
441
  payload: row.payload,
436
442
  headers: row.headers,
437
443
  attempts: row.attempts,
438
- receivedAt: toDate(row.received_at)
444
+ receivedAt: toInstant(row.received_at)
439
445
  };
440
446
  try {
441
447
  const outcome = await handler(message);
@@ -19,7 +19,8 @@ function scalarKind(column) {
19
19
  values: column.enum
20
20
  };
21
21
  if (column.json) return { kind: "json" };
22
- if (column.codec === "date") return { kind: "dateObject" };
22
+ if (column.codec === "instant") return { kind: "instant" };
23
+ if (column.codec === "plainDateTime") return { kind: "plainDateTime" };
23
24
  if (column.codec === "bigint") return { kind: "bigint" };
24
25
  if (column.codec === "string") return { kind: "string" };
25
26
  if (column.type === "uuid") return { kind: "uuid" };
@@ -107,10 +108,14 @@ function scalar(kind) {
107
108
  type: "string",
108
109
  format: "date"
109
110
  };
110
- case "dateObject": return {
111
+ case "instant": return {
111
112
  type: "string",
112
113
  format: "date-time"
113
114
  };
115
+ case "plainDateTime": return {
116
+ type: "string",
117
+ pattern: "^\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?$"
118
+ };
114
119
  case "bigint": return {
115
120
  type: "string",
116
121
  pattern: "^-?\\d+$"
@@ -16,7 +16,7 @@ function receiverName(node) {
16
16
  return receiver.property.name;
17
17
  }
18
18
  /** Matches `order_items`, `orderItems` and `public.order_items` alike. */
19
- const tableKey = (name) => (name.split(".").at(-1) ?? name).replace(/_/g, "").toLowerCase();
19
+ const tableKey = (name) => (name.split(".").at(-1) ?? name).replaceAll("_", "").toLowerCase();
20
20
  function keyName(property) {
21
21
  if (property.computed) return void 0;
22
22
  if (property.key.type === "Identifier") return property.key.name;
@@ -1,2 +1,2 @@
1
- import { a as ListPage, c as ListQuery, d as ListSearchParams, f as OpenApiParameter, h as defineListQuery, i as ListExtra, l as ListQueryConfig, m as UNSET, n as FacetInfo, o as ListParseResult, p as ParserSpec, r as ListDefinition, s as ListParsers, t as FacetCounts, u as ListQueryInput } from "../index-Bw1bwtC0.js";
2
- export { FacetCounts, FacetInfo, ListDefinition, ListExtra, ListPage, ListParseResult, ListParsers, ListQuery, ListQueryConfig, ListQueryInput, ListSearchParams, OpenApiParameter, ParserSpec, UNSET, defineListQuery };
1
+ import { a as ListPage, c as ListParsers, d as ListQueryInput, f as ListSearchParams, g as defineListQuery, h as UNSET, i as ListExtra, l as ListQuery, m as ParserSpec, n as FacetInfo, o as ListPagination, p as OpenApiParameter, r as ListDefinition, s as ListParseResult, t as FacetCounts, u as ListQueryConfig } from "../index-CADlNHK-.js";
2
+ export { type FacetCounts, type FacetInfo, type ListDefinition, type ListExtra, type ListPage, type ListPagination, type ListParseResult, type ListParsers, type ListQuery, type ListQueryConfig, type ListQueryInput, type ListSearchParams, type OpenApiParameter, type ParserSpec, UNSET, defineListQuery };