@palbase/backend 24.3.0 → 25.0.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/dist/bin/palbase-backend.cjs +101 -60
- package/dist/bin/palbase-backend.cjs.map +1 -1
- package/dist/bin/palbase-backend.js +17 -13
- package/dist/bin/palbase-backend.js.map +1 -1
- package/dist/{chunk-EIXCY4SS.js → chunk-43A3KGWL.js} +80 -49
- package/dist/chunk-43A3KGWL.js.map +1 -0
- package/dist/{chunk-ERDL5VAE.js → chunk-5CMLOAEF.js} +2 -2
- package/dist/chunk-OEQBHE2Z.js +825 -0
- package/dist/chunk-OEQBHE2Z.js.map +1 -0
- package/dist/{chunk-7Z6MGMXQ.js → chunk-XJ2RSHEU.js} +11 -5
- package/dist/chunk-XJ2RSHEU.js.map +1 -0
- package/dist/{chunk-UWSYTUGM.js → chunk-ZQRWW37O.js} +44 -1
- package/dist/chunk-ZQRWW37O.js.map +1 -0
- package/dist/db/env.cjs.map +1 -1
- package/dist/db/env.d.cts +29 -13
- package/dist/db/env.d.ts +29 -13
- package/dist/db/index.cjs +212 -111
- package/dist/db/index.cjs.map +1 -1
- package/dist/db/index.d.cts +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.js +11 -1
- package/dist/engine/index.cjs +87 -50
- package/dist/engine/index.cjs.map +1 -1
- package/dist/engine/index.d.cts +2 -2
- package/dist/engine/index.d.ts +2 -2
- package/dist/engine/index.js +3 -3
- package/dist/{index-DEneI8Mn.d.ts → index-BF1f0DfA.d.ts} +5 -2
- package/dist/{index-C-ALG22n.d.cts → index-CoaDN9dL.d.cts} +5 -2
- package/dist/{index-BTMYod_l.d.ts → index-Ct1iiB4N.d.ts} +203 -61
- package/dist/{index-BLAbr9ZH.d.cts → index-CwaWRhyc.d.cts} +203 -61
- package/dist/index.cjs +550 -297
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +122 -20
- package/dist/index.d.ts +122 -20
- package/dist/index.js +164 -217
- package/dist/index.js.map +1 -1
- package/dist/openapi/index.cjs +100 -36
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.js +59 -2
- package/dist/openapi/index.js.map +1 -1
- package/docs/README.md +64 -31
- package/docs/endpoints.md +25 -28
- package/docs/llms-full.txt +399 -153
- package/docs/schema.md +272 -91
- package/docs/services.md +39 -4
- package/package.json +1 -1
- package/template/AGENTS.md +119 -314
- package/template/CLAUDE.md +13 -0
- package/template/controllers/notes.controller.ts +6 -13
- package/template/db/public.ts +38 -0
- package/template/models/notes/create.ts +38 -0
- package/template/package.json +6 -3
- package/template/services/note.service.test.ts +45 -0
- package/template/services/note.service.ts +2 -2
- package/dist/chunk-7Z6MGMXQ.js.map +0 -1
- package/dist/chunk-D5CQES25.js +0 -556
- package/dist/chunk-D5CQES25.js.map +0 -1
- package/dist/chunk-EIXCY4SS.js.map +0 -1
- package/dist/chunk-UWSYTUGM.js.map +0 -1
- package/template/db/schema.ts +0 -35
- /package/dist/{chunk-ERDL5VAE.js.map → chunk-5CMLOAEF.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Tables, TableTypes } from './db/env.cjs';
|
|
1
|
+
import { Tables, TableTypes, Schemas } from './db/env.cjs';
|
|
2
2
|
import { D as DBClient, b8 as TxPlanHandle, bh as TxTable, M as Materialized } from './endpoint-BSGw1pTu.cjs';
|
|
3
3
|
|
|
4
4
|
/** On delete action for foreign key references. */
|
|
@@ -26,6 +26,19 @@ interface ColumnDef {
|
|
|
26
26
|
table: string;
|
|
27
27
|
column: string;
|
|
28
28
|
};
|
|
29
|
+
/** Pending FK target, resolved by `defineSchema` once every binding exists. */
|
|
30
|
+
referencesThunk?: () => ColumnBuilder;
|
|
31
|
+
/** FK onto THIS table — no thunk needed, the target is the declaring table. */
|
|
32
|
+
selfRefColumn?: string;
|
|
33
|
+
/** This column OWNS the row: erasure, RLS and the `owner` relation read it. */
|
|
34
|
+
owns?: true;
|
|
35
|
+
/** Explicit relation name, when the derived one would be ambiguous. */
|
|
36
|
+
refAs?: string;
|
|
37
|
+
/** The table this column belongs to; set by `defineTable`. */
|
|
38
|
+
ownerTable?: {
|
|
39
|
+
name: string;
|
|
40
|
+
columns: Record<string, ColumnBuilder>;
|
|
41
|
+
};
|
|
29
42
|
/**
|
|
30
43
|
* The name this column used to have. A diff cannot tell a rename from a drop and
|
|
31
44
|
* an add — both leave one name gone and another present — so the intent has to be
|
|
@@ -171,47 +184,37 @@ declare class ColumnBuilder<K extends ColumnType = ColumnType, N extends boolean
|
|
|
171
184
|
* safety gate in silence.
|
|
172
185
|
*/
|
|
173
186
|
ignored(): ColumnBuilder<K, N, D, E, P, T>;
|
|
174
|
-
references(table: string, column: string): ColumnBuilder<K, N, D, E, P, T>;
|
|
175
187
|
/**
|
|
176
|
-
*
|
|
177
|
-
* (`REFERENCES auth.users(id)`), so a column like `user_id` gets true
|
|
178
|
-
* database cascade/integrity instead of app-layer-only. Sugar for
|
|
179
|
-
* `.references("auth.users", "id")`.
|
|
188
|
+
* Foreign key onto another table's column.
|
|
180
189
|
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* the
|
|
190
|
+
* The target is a THUNK, not a direct reference. In a cycle (`x → y`, `y → x`)
|
|
191
|
+
* the second table does not exist yet when the first is built; a direct
|
|
192
|
+
* reference makes TypeScript chase its own tail (TS7022 — measured, and making
|
|
193
|
+
* the return type independent of the target does NOT help). The thunk is
|
|
194
|
+
* invoked in `defineSchema`, where every binding exists and every table
|
|
195
|
+
* already knows its name.
|
|
185
196
|
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* `text().notNull().referencesAuthUser("cascade")`, or
|
|
190
|
-
* `text().nullable().referencesAuthUser("set null")`. The server
|
|
191
|
-
* (validateAuthUserFK) enforces this — and the remaining rules the type can't
|
|
192
|
-
* express (referencing column is text, `set null` needs a nullable column) —
|
|
193
|
-
* as the real boundary; this signature is the compile-time DX mirror.
|
|
197
|
+
* In a cycle, ONE side needs an explicit return type:
|
|
198
|
+
* `references((): AnyColumn => y.id)`. One side is enough — measured.
|
|
199
|
+
* For a self-reference use `selfReferences(column)`: no thunk, no annotation.
|
|
194
200
|
*/
|
|
195
|
-
|
|
201
|
+
references(target: () => AnyColumn, opts?: {
|
|
202
|
+
as?: string;
|
|
203
|
+
onDelete?: OnDeleteAction;
|
|
204
|
+
}): ColumnBuilder<K, N, D, E, P, T>;
|
|
196
205
|
/**
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
* root (`ins_...`). Sugar for `.references("auth.installations", "id")`.
|
|
200
|
-
*
|
|
201
|
-
* An installation is an APP INSTALL, not a user: this FK is NOT user ownership.
|
|
202
|
-
* A user-owned row STILL needs its own `.referencesAuthUser(...)` FK so account
|
|
203
|
-
* erasure removes it — an installation reference alone does not tie a row to a
|
|
204
|
-
* user's deletion. Use this only for install-scoped state (device prefs, push
|
|
205
|
-
* routing, …), alongside a separate auth-user FK where the row is user-owned.
|
|
206
|
+
* Foreign key onto THIS table (`parent_id → id`) — category trees, comment
|
|
207
|
+
* replies, org charts.
|
|
206
208
|
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
* blocked by a lingering FK. The server (validateAuthAnchorFK) is the real
|
|
212
|
-
* boundary; this signature is the compile-time DX mirror.
|
|
209
|
+
* No thunk and no type annotation: the target table is the one being declared,
|
|
210
|
+
* so there is nothing to defer and nothing for TypeScript to chase in a circle.
|
|
211
|
+
* Drizzle forces an explicit `(): AnyPgColumn =>` here because its reference
|
|
212
|
+
* always goes through a callback; measured, we do not need one.
|
|
213
213
|
*/
|
|
214
|
-
|
|
214
|
+
selfReferences(column: string, opts?: {
|
|
215
|
+
as?: string;
|
|
216
|
+
onDelete?: OnDeleteAction;
|
|
217
|
+
}): ColumnBuilder<K, N, D, E, P, T>;
|
|
215
218
|
/** Set the ON DELETE action for a foreign key reference. */
|
|
216
219
|
onDelete(action: OnDeleteAction): ColumnBuilder<K, N, D, E, P, T>;
|
|
217
220
|
/** Add a single-column UNIQUE constraint. */
|
|
@@ -310,6 +313,54 @@ declare function enumType<const V extends readonly string[]>(name: string, value
|
|
|
310
313
|
* 2000 = pgvector'ün HNSW-indekslenebilir tavanı; auto-index bu beyanla bağlı
|
|
311
314
|
* (spec FR-001, D-3). */
|
|
312
315
|
declare function vector(dimensions: number): ColumnBuilder<'vector', false, false, unknown, number[]>;
|
|
316
|
+
/**
|
|
317
|
+
* Any column, whatever its type parameters.
|
|
318
|
+
*
|
|
319
|
+
* Exported so a cycle can be broken from ONE side:
|
|
320
|
+
* `references((): AnyColumn => y.id)`.
|
|
321
|
+
*/
|
|
322
|
+
type AnyColumn = ColumnBuilder;
|
|
323
|
+
/**
|
|
324
|
+
* The column that OWNS this row: a `text` FK onto `auth.users(id)`, NOT NULL,
|
|
325
|
+
* ON DELETE CASCADE.
|
|
326
|
+
*
|
|
327
|
+
* Ownership drives account erasure, so cascade is the only correct action and
|
|
328
|
+
* takes no argument. The referencing column must be `text` (palauth ids are
|
|
329
|
+
* `usr_<uuid>`) and NOT NULL — both are implied here rather than left to the
|
|
330
|
+
* caller, so three rules the type could not express before become UNWRITABLE.
|
|
331
|
+
*
|
|
332
|
+
* At most ONE per table. The old shape let several columns reference
|
|
333
|
+
* `auth.users` and picked the FIRST IN DECLARATION ORDER as the owner — moving a
|
|
334
|
+
* `created_by` above a `user_id` silently changed which rows an account deletion
|
|
335
|
+
* took with it. A second one is now rejected at push.
|
|
336
|
+
*
|
|
337
|
+
* For a column that merely POINTS at a user without owning the row
|
|
338
|
+
* (`created_by`, `edited_by`), use `userRef({ onDelete })`.
|
|
339
|
+
*/
|
|
340
|
+
declare function ownedByUser(): ColumnBuilder<'text', false, false, never>;
|
|
341
|
+
/**
|
|
342
|
+
* A plain FK onto `auth.users(id)` that does NOT own the row.
|
|
343
|
+
*
|
|
344
|
+
* `created_by` / `edited_by`: deleting that user must not delete the row. ON
|
|
345
|
+
* DELETE is required and limited to `cascade | set null` so an erasure request
|
|
346
|
+
* is never blocked by a lingering FK; `set null` needs a nullable column.
|
|
347
|
+
*/
|
|
348
|
+
declare function userRef(opts: {
|
|
349
|
+
onDelete: AuthUserOnDelete;
|
|
350
|
+
as?: string;
|
|
351
|
+
}): ColumnBuilder<'text', boolean, false, never>;
|
|
352
|
+
/**
|
|
353
|
+
* A plain FK onto `auth.installations(id)` — the app-scoped verified-device
|
|
354
|
+
* anchor.
|
|
355
|
+
*
|
|
356
|
+
* An installation is an APP INSTALL, not a user: this is NOT ownership. A
|
|
357
|
+
* user-owned row still needs its own `ownedByUser()` so account erasure removes
|
|
358
|
+
* it; an installation reference alone does not tie a row to a user's deletion.
|
|
359
|
+
*/
|
|
360
|
+
declare function installationRef(opts: {
|
|
361
|
+
onDelete: AuthUserOnDelete;
|
|
362
|
+
as?: string;
|
|
363
|
+
}): ColumnBuilder<'text', boolean, false, never>;
|
|
313
364
|
|
|
314
365
|
/**
|
|
315
366
|
* policy.ts — the RLS policy authoring DSL.
|
|
@@ -482,7 +533,7 @@ declare const openai: {
|
|
|
482
533
|
|
|
483
534
|
/**
|
|
484
535
|
* A map of column builders keyed by column name — the value you write under
|
|
485
|
-
* the `columns` key of `
|
|
536
|
+
* the `columns` key of `defineTable("<name>", { columns })`.
|
|
486
537
|
*
|
|
487
538
|
* The default `Record<string, ColumnBuilder>` keeps bare references compiling
|
|
488
539
|
* without a type argument.
|
|
@@ -655,6 +706,10 @@ interface TableDef<C extends ColumnMap = ColumnMap> {
|
|
|
655
706
|
* `TableDef<{ id: ColumnBuilder<'uuid', false, true, never>; ... }>`.
|
|
656
707
|
*/
|
|
657
708
|
interface SchemaDef<T extends Record<string, TableDef> = Record<string, TableDef>> {
|
|
709
|
+
/** The schema's own name — `public`, `billing`, … Declared, never derived. */
|
|
710
|
+
name: string;
|
|
711
|
+
/** Reachable over HTTP? False unless the author opts in. */
|
|
712
|
+
exposed: boolean;
|
|
658
713
|
tables: T;
|
|
659
714
|
/** Postgres extensions to install on deploy. Normalized to `[]` when absent. */
|
|
660
715
|
extensions: PalbaseExtension[];
|
|
@@ -675,35 +730,39 @@ interface SchemaInput<T extends Record<string, TableInput> = Record<string, Tabl
|
|
|
675
730
|
/** Map the author's `{ tables: { <name>: { columns } } }` input to the
|
|
676
731
|
* `{ tables: { <name>: TableDef<columns> } }` runtime/type shape, threading the
|
|
677
732
|
* per-table column map `T[K]["columns"]` so column-level inference survives. */
|
|
678
|
-
type
|
|
679
|
-
[K in
|
|
733
|
+
type TablesByName<T extends readonly TableHandle[]> = {
|
|
734
|
+
[K in T[number] as K[typeof TABLE_META]["name"]]: K[typeof TABLE_META];
|
|
680
735
|
};
|
|
681
736
|
/**
|
|
682
|
-
*
|
|
683
|
-
*
|
|
737
|
+
* How a schema file reads. One file per schema — `db/public.ts`, `db/billing.ts`
|
|
738
|
+
* — and the schema says its own name:
|
|
684
739
|
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
*
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
* owner: text().notNull(),
|
|
691
|
-
* title: text().notNull(),
|
|
692
|
-
* },
|
|
693
|
-
* rls: true,
|
|
694
|
-
* policies: [
|
|
695
|
-
* policy("owner_all").for("all").to("authenticated")
|
|
696
|
-
* .using("owner = (select auth.uid())")
|
|
697
|
-
* .withCheck("owner = (select auth.uid())"),
|
|
698
|
-
* ],
|
|
699
|
-
* },
|
|
740
|
+
* const todos = defineTable("todos", {
|
|
741
|
+
* columns: {
|
|
742
|
+
* id: uuid().primaryKey().defaultRandom(),
|
|
743
|
+
* owner: text().notNull(),
|
|
744
|
+
* title: text().notNull(),
|
|
700
745
|
* },
|
|
746
|
+
* rls: true,
|
|
747
|
+
* policies: [
|
|
748
|
+
* policy("owner_all").for("all").to("authenticated")
|
|
749
|
+
* .using("owner = (select auth.uid())")
|
|
750
|
+
* .withCheck("owner = (select auth.uid())"),
|
|
751
|
+
* ],
|
|
701
752
|
* });
|
|
702
753
|
*
|
|
703
|
-
*
|
|
704
|
-
*
|
|
705
|
-
*
|
|
706
|
-
*
|
|
754
|
+
* export default defineSchema("public", { tables: [todos] });
|
|
755
|
+
*
|
|
756
|
+
* The dictionary form `defineSchema({ tables: { todos: {…} } })` is RETIRED and
|
|
757
|
+
* refused by name: a table whose name comes from a key does not know what it is
|
|
758
|
+
* called while it is being built, so it cannot resolve `references(() =>
|
|
759
|
+
* other.id)`, and a schema that does not say its own name cannot tell one
|
|
760
|
+
* `invoices` from another schema's `invoices`.
|
|
761
|
+
*
|
|
762
|
+
* The returned value is `{ name, tables: { todos: { name, columns, rls,
|
|
763
|
+
* policies } }, extensions, exposed }` — the exact shape the runtime schema
|
|
764
|
+
* extractor parses. Per-column phantom types are preserved so
|
|
765
|
+
* `Database.tables.todos.insert({...})` stays typed.
|
|
707
766
|
*
|
|
708
767
|
* RLS normalization: `rls` defaults to **`true`**, `policies` to `[]`. A table
|
|
709
768
|
* that declares neither is therefore deny-all — nothing reads it until a policy
|
|
@@ -713,7 +772,46 @@ type TablesFromInput<T extends Record<string, TableInput>> = {
|
|
|
713
772
|
* `rls` is forced on (ENABLE + FORCE) regardless of the declared flag — a table
|
|
714
773
|
* with policies must have RLS enabled or the policies would be inert.
|
|
715
774
|
*/
|
|
716
|
-
|
|
775
|
+
/**
|
|
776
|
+
* Where a table's metadata lives.
|
|
777
|
+
*
|
|
778
|
+
* The table VALUE is its columns, so `lists.id` is the column — which means a
|
|
779
|
+
* column called `name` would overwrite the table's own name if metadata sat in
|
|
780
|
+
* a plain field. Measured, not imagined: the existing `users` / `rooms` tests
|
|
781
|
+
* (both declare a `name` column) produced an `[object Object]` table key.
|
|
782
|
+
* `columns`, `rls`, `search`, `memory`, `unique` and `indexes` are all plausible
|
|
783
|
+
* column names too. A column cannot collide with a symbol.
|
|
784
|
+
*/
|
|
785
|
+
declare const TABLE_META: unique symbol;
|
|
786
|
+
/** A value produced by `defineTable`: the columns, plus metadata behind the symbol. */
|
|
787
|
+
type TableHandle<C extends ColumnMap = ColumnMap, N extends string = string> = C & {
|
|
788
|
+
readonly [TABLE_META]: TableDef<C> & {
|
|
789
|
+
name: N;
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
/**
|
|
793
|
+
* Declare one table as a standalone value that KNOWS ITS OWN NAME.
|
|
794
|
+
*
|
|
795
|
+
* The name lives here, not in a dictionary key. A table whose name comes from a
|
|
796
|
+
* key cannot resolve `references(() => other.id)` when it is built — it does not
|
|
797
|
+
* know what to call itself — which forces a two-phase resolution with an
|
|
798
|
+
* empty-name intermediate state. One name source, no empty identity.
|
|
799
|
+
*
|
|
800
|
+
* The returned object spreads its own columns, so a sibling can point at it:
|
|
801
|
+
* `references(() => lists.id)`.
|
|
802
|
+
*/
|
|
803
|
+
declare function defineTable<const N extends string, C extends ColumnMap>(name: N, input: TableInput<C>): TableHandle<C, N>;
|
|
804
|
+
/**
|
|
805
|
+
* Collect declared tables into one schema.
|
|
806
|
+
*
|
|
807
|
+
* Takes an ARRAY, not a dictionary: the tables already carry their names, and a
|
|
808
|
+
* second name source is a second thing that can disagree.
|
|
809
|
+
*/
|
|
810
|
+
declare function defineSchema<const T extends readonly TableHandle[]>(name: string, input: {
|
|
811
|
+
tables: T;
|
|
812
|
+
exposed?: boolean;
|
|
813
|
+
extensions?: PalbaseExtension[];
|
|
814
|
+
}): SchemaDef<TablesByName<T>>;
|
|
717
815
|
|
|
718
816
|
/**
|
|
719
817
|
* typed-db.ts — Task 2: TypedDB schema-derived insert/row shapes.
|
|
@@ -978,6 +1076,26 @@ type EnvTypedTable<T extends TableTypes> = EnvTypedTableBase<T> & (T extends {
|
|
|
978
1076
|
type EnvTables = {
|
|
979
1077
|
[K in keyof Tables]: EnvTypedTable<Tables[K]>;
|
|
980
1078
|
};
|
|
1079
|
+
/**
|
|
1080
|
+
* The project's NON-public schemas, keyed by schema name, each exposing its own
|
|
1081
|
+
* `tables` map — the shape `Database.schema("billing")` returns.
|
|
1082
|
+
*
|
|
1083
|
+
* The intermediate `tables` is there for the reason {@link EnvTables} sits under
|
|
1084
|
+
* `.tables`: a schema's table names must not share a namespace with anything the
|
|
1085
|
+
* accessor itself might grow.
|
|
1086
|
+
*
|
|
1087
|
+
* Empty by default. The generated `palbase-env.d.ts` augments `Schemas` with one
|
|
1088
|
+
* member per declared schema other than `public`, so a project that declares
|
|
1089
|
+
* none has `keyof Schemas = never` and every `schema(...)` call is a compile
|
|
1090
|
+
* error rather than a runtime surprise.
|
|
1091
|
+
*/
|
|
1092
|
+
type EnvSchemas = {
|
|
1093
|
+
[S in keyof Schemas]: {
|
|
1094
|
+
tables: {
|
|
1095
|
+
[T in keyof Schemas[S]]: EnvTypedTable<Extract<Schemas[S][T], TableTypes>>;
|
|
1096
|
+
};
|
|
1097
|
+
};
|
|
1098
|
+
};
|
|
981
1099
|
/** The project's tables as PLAN operations, keyed by the env `Tables`
|
|
982
1100
|
* interface. The transaction twin of {@link EnvTables}. */
|
|
983
1101
|
type TxTables = {
|
|
@@ -999,6 +1117,10 @@ type TxPlan = TxPlanHandle<TxTables>;
|
|
|
999
1117
|
*/
|
|
1000
1118
|
interface EnvServiceDatabase extends Omit<DBClient, "txPlan" | "asService"> {
|
|
1001
1119
|
tables: EnvTables;
|
|
1120
|
+
/** See {@link EnvTypedDatabase.schema}. The bypass sibling reaches every
|
|
1121
|
+
* schema the default surface does — a `billing` table is no less reachable
|
|
1122
|
+
* because the caller asked to run as the service role. */
|
|
1123
|
+
schema<S extends keyof Schemas>(name: S): EnvSchemas[S];
|
|
1002
1124
|
transaction<T>(fn: (tx: TxPlan) => T extends Promise<unknown> ? never : T): Promise<Materialized<T>>;
|
|
1003
1125
|
}
|
|
1004
1126
|
/**
|
|
@@ -1013,6 +1135,26 @@ interface EnvServiceDatabase extends Omit<DBClient, "txPlan" | "asService"> {
|
|
|
1013
1135
|
*/
|
|
1014
1136
|
interface EnvTypedDatabase extends Omit<DBClient, "txPlan" | "asService"> {
|
|
1015
1137
|
tables: EnvTables;
|
|
1138
|
+
/**
|
|
1139
|
+
* The tables of a schema other than `public`.
|
|
1140
|
+
*
|
|
1141
|
+
* `Database.tables.*` is the PUBLIC schema and only the public schema. Two
|
|
1142
|
+
* schemas may declare the same table name — `public.invoices` and
|
|
1143
|
+
* `billing.invoices` are different tables — so one flat namespace would make
|
|
1144
|
+
* `Database.tables.invoices` resolve by declaration order. It does not: the
|
|
1145
|
+
* bare name is always public's, and everything else is asked for by schema.
|
|
1146
|
+
*
|
|
1147
|
+
* The name is `keyof Schemas`, so a schema the project never declared is a
|
|
1148
|
+
* compile error. On the wire the table travels schema-qualified
|
|
1149
|
+
* (`billing.invoices`); `public` stays bare.
|
|
1150
|
+
*
|
|
1151
|
+
* Declaring a schema does not publish it — reachability over HTTP is the
|
|
1152
|
+
* schema's own `exposed` flag, checked by the broker.
|
|
1153
|
+
*
|
|
1154
|
+
* @example
|
|
1155
|
+
* const inv = await Database.schema("billing").tables.invoices.findById(id);
|
|
1156
|
+
*/
|
|
1157
|
+
schema<S extends keyof Schemas>(name: S): EnvSchemas[S];
|
|
1016
1158
|
/**
|
|
1017
1159
|
* Run a transaction. The callback DESCRIBES the operations; the whole
|
|
1018
1160
|
* description travels in one request and the broker runs it inside a single
|
|
@@ -1070,4 +1212,4 @@ interface EnvTypedDatabase extends Omit<DBClient, "txPlan" | "asService"> {
|
|
|
1070
1212
|
asService(): EnvServiceDatabase;
|
|
1071
1213
|
}
|
|
1072
1214
|
|
|
1073
|
-
export {
|
|
1215
|
+
export { type AnyColumn as A, defineSchema as B, ColumnBuilder as C, defineTable as D, type EnvTypedDatabase as E, enumType as F, installationRef as G, integer as H, type InsertShape as I, isPalbaseExtension as J, jsonb as K, makeTypedDB as L, numeric as M, openai as N, type OnDeleteAction as O, PALBASE_EXTENSIONS as P, ownedByUser as Q, type RawConstraintDef as R, type SchemaDef as S, TABLE_META as T, policy as U, raw as V, text as W, timestamp as X, userRef as Y, uuid as Z, vector as _, type ColumnDef as a, type ColumnMap as b, type ColumnType as c, EXTENSION_DEPENDENCIES as d, type EmbeddingModelRef as e, type EnvSchemas as f, type EnvServiceDatabase as g, type EnvTables as h, type EnvTypedTable as i, type PalbaseExtension as j, PolicyBuilder as k, type PolicyCommand as l, type PolicyDef as m, type PolicyMode as n, type RowShape as o, type SchemaInput as p, type TableDef as q, type TableHandle as r, type TableInput as s, type TxPlan as t, type TxTables as u, type TypedDB as v, type TypedTable as w, type TypedTx as x, bigint as y, boolean as z };
|