@palbase/backend 25.0.2 → 25.0.4

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/index.js CHANGED
@@ -17,15 +17,13 @@ import {
17
17
  openai,
18
18
  ownedByUser,
19
19
  policy,
20
- qualifiedTableKey,
21
20
  raw,
22
21
  text,
23
22
  timestamp,
24
- toSchemaJSON,
25
23
  userRef,
26
24
  uuid,
27
25
  vector
28
- } from "./chunk-7JSEN7UR.js";
26
+ } from "./chunk-G4R6BTLV.js";
29
27
  import {
30
28
  defineError,
31
29
  getErrorRegistry
@@ -48,14 +46,16 @@ import {
48
46
  __setRuntime,
49
47
  onShutdown,
50
48
  onStart
51
- } from "./chunk-XJ2RSHEU.js";
49
+ } from "./chunk-CRQKCRGF.js";
52
50
  import {
53
51
  TxPlanError,
54
52
  TxRefError,
55
53
  dec,
56
54
  inc,
57
- now
58
- } from "./chunk-P2Q27SGP.js";
55
+ now,
56
+ qualifiedTableKey,
57
+ toSchemaJSON
58
+ } from "./chunk-CJSKYY76.js";
59
59
  import {
60
60
  BadRequest,
61
61
  Conflict,
package/docs/README.md CHANGED
@@ -178,28 +178,28 @@ export default class TodosController {
178
178
 
179
179
  ```ts
180
180
  // db/public.ts — config-as-code; the deploy auto-migrates additive changes.
181
- import { defineSchema, uuid, text, boolean, timestamp, policy } from "@palbase/backend";
182
- export default defineSchema({
183
- tables: {
184
- todos: {
185
- columns: {
186
- id: uuid().primaryKey().defaultRandom(),
187
- user_id: text().notNull(), // palauth user id (TEXT, e.g. "usr_…")
188
- title: text().notNull(),
189
- completed: boolean().default(false),
190
- created_at: timestamp().defaultNow(),
191
- },
192
- rls: true, // every Database.* query runs as the request user
193
- policies: [
194
- policy("pb_owner_all")
195
- .for("all")
196
- .to("authenticated")
197
- .using("user_id = (select auth.uid())")
198
- .withCheck("user_id = (select auth.uid())"),
199
- ],
200
- },
181
+ // ONE SCHEMA PER FILE: this is `public`; a sibling `db/billing.ts` declares its own.
182
+ import { defineSchema, defineTable, uuid, text, boolean, timestamp, policy, ownedByUser } from "@palbase/backend";
183
+
184
+ export const todos = defineTable("todos", {
185
+ columns: {
186
+ id: uuid().primaryKey().defaultRandom(),
187
+ user_id: ownedByUser(), // owns the row: text, NOT NULL, ON DELETE cascade
188
+ title: text().notNull(),
189
+ completed: boolean().default(false),
190
+ created_at: timestamp().defaultNow(),
201
191
  },
192
+ rls: true, // every Database.* query runs as the request user
193
+ policies: [
194
+ policy("pb_owner_all")
195
+ .for("all")
196
+ .to("authenticated")
197
+ .using("user_id = (select auth.uid())")
198
+ .withCheck("user_id = (select auth.uid())"),
199
+ ],
202
200
  });
201
+
202
+ export default defineSchema("public", { tables: [todos] });
203
203
  ```
204
204
 
205
205
  ### operationId — what the generated clients call
@@ -186,28 +186,28 @@ export default class TodosController {
186
186
 
187
187
  ```ts
188
188
  // db/public.ts — config-as-code; the deploy auto-migrates additive changes.
189
- import { defineSchema, uuid, text, boolean, timestamp, policy } from "@palbase/backend";
190
- export default defineSchema({
191
- tables: {
192
- todos: {
193
- columns: {
194
- id: uuid().primaryKey().defaultRandom(),
195
- user_id: text().notNull(), // palauth user id (TEXT, e.g. "usr_…")
196
- title: text().notNull(),
197
- completed: boolean().default(false),
198
- created_at: timestamp().defaultNow(),
199
- },
200
- rls: true, // every Database.* query runs as the request user
201
- policies: [
202
- policy("pb_owner_all")
203
- .for("all")
204
- .to("authenticated")
205
- .using("user_id = (select auth.uid())")
206
- .withCheck("user_id = (select auth.uid())"),
207
- ],
208
- },
189
+ // ONE SCHEMA PER FILE: this is `public`; a sibling `db/billing.ts` declares its own.
190
+ import { defineSchema, defineTable, uuid, text, boolean, timestamp, policy, ownedByUser } from "@palbase/backend";
191
+
192
+ export const todos = defineTable("todos", {
193
+ columns: {
194
+ id: uuid().primaryKey().defaultRandom(),
195
+ user_id: ownedByUser(), // owns the row: text, NOT NULL, ON DELETE cascade
196
+ title: text().notNull(),
197
+ completed: boolean().default(false),
198
+ created_at: timestamp().defaultNow(),
209
199
  },
200
+ rls: true, // every Database.* query runs as the request user
201
+ policies: [
202
+ policy("pb_owner_all")
203
+ .for("all")
204
+ .to("authenticated")
205
+ .using("user_id = (select auth.uid())")
206
+ .withCheck("user_id = (select auth.uid())"),
207
+ ],
210
208
  });
209
+
210
+ export default defineSchema("public", { tables: [todos] });
211
211
  ```
212
212
 
213
213
  ### operationId — what the generated clients call
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@palbase/backend",
3
- "version": "25.0.2",
3
+ "version": "25.0.4",
4
4
  "description": "Palbase Backend SDK — class controllers (@Controller/@Get/@Post + @Body/@QueryParams/@Param), error classes, schema DSL",
5
5
  "license": "MIT",
6
6
  "repository": {