@palbase/backend 24.2.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.
Files changed (61) hide show
  1. package/dist/bin/palbase-backend.cjs +101 -60
  2. package/dist/bin/palbase-backend.cjs.map +1 -1
  3. package/dist/bin/palbase-backend.js +17 -13
  4. package/dist/bin/palbase-backend.js.map +1 -1
  5. package/dist/{chunk-EIXCY4SS.js → chunk-43A3KGWL.js} +80 -49
  6. package/dist/chunk-43A3KGWL.js.map +1 -0
  7. package/dist/{chunk-ERDL5VAE.js → chunk-5CMLOAEF.js} +2 -2
  8. package/dist/chunk-OEQBHE2Z.js +825 -0
  9. package/dist/chunk-OEQBHE2Z.js.map +1 -0
  10. package/dist/{chunk-7Z6MGMXQ.js → chunk-XJ2RSHEU.js} +11 -5
  11. package/dist/chunk-XJ2RSHEU.js.map +1 -0
  12. package/dist/{chunk-UWSYTUGM.js → chunk-ZQRWW37O.js} +44 -1
  13. package/dist/chunk-ZQRWW37O.js.map +1 -0
  14. package/dist/db/env.cjs.map +1 -1
  15. package/dist/db/env.d.cts +29 -13
  16. package/dist/db/env.d.ts +29 -13
  17. package/dist/db/index.cjs +233 -110
  18. package/dist/db/index.cjs.map +1 -1
  19. package/dist/db/index.d.cts +1 -1
  20. package/dist/db/index.d.ts +1 -1
  21. package/dist/db/index.js +11 -1
  22. package/dist/engine/index.cjs +87 -50
  23. package/dist/engine/index.cjs.map +1 -1
  24. package/dist/engine/index.d.cts +2 -2
  25. package/dist/engine/index.d.ts +2 -2
  26. package/dist/engine/index.js +3 -3
  27. package/dist/{index-C0PMn5jl.d.ts → index-BF1f0DfA.d.ts} +5 -2
  28. package/dist/{index-DAwHMppB.d.cts → index-CoaDN9dL.d.cts} +5 -2
  29. package/dist/{index-ByBMibIJ.d.ts → index-Ct1iiB4N.d.ts} +232 -60
  30. package/dist/{index-D4rts8T7.d.cts → index-CwaWRhyc.d.cts} +232 -60
  31. package/dist/index.cjs +572 -296
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +124 -20
  34. package/dist/index.d.ts +124 -20
  35. package/dist/index.js +164 -216
  36. package/dist/index.js.map +1 -1
  37. package/dist/openapi/index.cjs +100 -36
  38. package/dist/openapi/index.cjs.map +1 -1
  39. package/dist/openapi/index.js +59 -2
  40. package/dist/openapi/index.js.map +1 -1
  41. package/docs/README.md +64 -31
  42. package/docs/endpoints.md +25 -28
  43. package/docs/llms-full.txt +465 -148
  44. package/docs/schema.md +338 -86
  45. package/docs/services.md +39 -4
  46. package/package.json +1 -1
  47. package/template/AGENTS.md +119 -314
  48. package/template/CLAUDE.md +13 -0
  49. package/template/controllers/notes.controller.ts +6 -13
  50. package/template/db/public.ts +38 -0
  51. package/template/models/notes/create.ts +38 -0
  52. package/template/package.json +6 -3
  53. package/template/services/note.service.test.ts +45 -0
  54. package/template/services/note.service.ts +2 -2
  55. package/dist/chunk-7Z6MGMXQ.js.map +0 -1
  56. package/dist/chunk-EIXCY4SS.js.map +0 -1
  57. package/dist/chunk-LCL7TUAI.js +0 -534
  58. package/dist/chunk-LCL7TUAI.js.map +0 -1
  59. package/dist/chunk-UWSYTUGM.js.map +0 -1
  60. package/template/db/schema.ts +0 -35
  61. /package/dist/{chunk-ERDL5VAE.js.map → chunk-5CMLOAEF.js.map} +0 -0
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  getErrorRegistry
3
- } from "../chunk-ERDL5VAE.js";
3
+ } from "../chunk-5CMLOAEF.js";
4
4
  import {
5
+ getRoom,
5
6
  getRoutes,
6
7
  isController,
7
8
  resolveController,
8
9
  resolveEffectiveAuth
9
- } from "../chunk-UWSYTUGM.js";
10
+ } from "../chunk-ZQRWW37O.js";
10
11
  import {
11
12
  __commonJS,
12
13
  __require,
@@ -5832,6 +5833,9 @@ var DEFAULT_IGNORE = [
5832
5833
  "**/node_modules/**"
5833
5834
  ];
5834
5835
  function flattenController(controller) {
5836
+ if (getRoom(controller) !== void 0 && !isController(controller)) {
5837
+ return [];
5838
+ }
5835
5839
  const meta = resolveController(controller);
5836
5840
  const controllerName = deriveControllerName(controller.name);
5837
5841
  const routes = getRoutes(controller);
@@ -6161,6 +6165,44 @@ function isRefinedSchema(schema) {
6161
6165
  if (!typeName) return false;
6162
6166
  return typeName === "ZodEffects" || typeName === "ZodPreprocess" || typeName === "ZodTransform";
6163
6167
  }
6168
+ function firstUntypedField(schema) {
6169
+ const shape = schema?.shape;
6170
+ if (!shape) return void 0;
6171
+ for (const [field, sub] of Object.entries(shape)) {
6172
+ const kind = sub?._def?.typeName;
6173
+ if (kind === "ZodUnknown" || kind === "ZodAny") return field;
6174
+ }
6175
+ return void 0;
6176
+ }
6177
+ function assertRoomFieldsTyped(pattern, room) {
6178
+ for (const [event, schema] of Object.entries(room.events)) {
6179
+ const field = firstUntypedField(schema);
6180
+ if (field !== void 0) {
6181
+ throw new Error(
6182
+ `@Room("${pattern}") event "${event}" has an untyped field "${field}". An untyped payload makes every generated client opaque \u2014 declare its shape.`
6183
+ );
6184
+ }
6185
+ }
6186
+ for (const [message, meta] of Object.entries(room.messages)) {
6187
+ const field = firstUntypedField(meta.schema);
6188
+ if (field !== void 0) {
6189
+ throw new Error(
6190
+ `@Room("${pattern}") message "${message}" has an untyped field "${field}". Inbound payloads reach the server \u2014 declare the shape so it can be validated.`
6191
+ );
6192
+ }
6193
+ }
6194
+ }
6195
+ function roomExtension(room, register) {
6196
+ const events = {};
6197
+ for (const [name, schema] of Object.entries(room.events)) {
6198
+ events[name] = { $ref: register(name, schema) };
6199
+ }
6200
+ const messages = {};
6201
+ for (const [name, meta] of Object.entries(room.messages)) {
6202
+ messages[name] = { $ref: register(name, meta.schema) };
6203
+ }
6204
+ return { events, messages, graceMs: room.graceMs };
6205
+ }
6164
6206
 
6165
6207
  // src/openapi/aggregate.ts
6166
6208
  extendZodWithOpenApi2(z2);
@@ -6186,6 +6228,18 @@ async function aggregateOpenAPI(projectRoot, options = {}) {
6186
6228
  registerControllerRoute(registry, route);
6187
6229
  }
6188
6230
  const generator = new OpenApiGeneratorV312(registry.definitions);
6231
+ const roomExt = {};
6232
+ for (const lc of loadedControllers) {
6233
+ const room = getRoom(lc.controller);
6234
+ if (room === void 0) continue;
6235
+ assertRoomFieldsTyped(room.pattern, room);
6236
+ const slug = room.pattern.replace(/[^A-Za-z0-9]+/g, "_").replace(/^_|_$/g, "");
6237
+ roomExt[room.pattern] = roomExtension(room, (name, schema) => {
6238
+ const componentName = `Room_${slug}_${name}`;
6239
+ registry.register(componentName, schema);
6240
+ return `#/components/schemas/${componentName}`;
6241
+ });
6242
+ }
6189
6243
  const document = generator.generateDocument({
6190
6244
  openapi: "3.2.0",
6191
6245
  info: {
@@ -6194,6 +6248,9 @@ async function aggregateOpenAPI(projectRoot, options = {}) {
6194
6248
  description: "Auto-generated from class controllers (@Controller/@Get/@Post + @Body/@QueryParams/@Param) Zod schemas + method return types at deploy time. Do not edit by hand."
6195
6249
  }
6196
6250
  });
6251
+ if (Object.keys(roomExt).length > 0) {
6252
+ document["x-palbase-room"] = roomExt;
6253
+ }
6197
6254
  return {
6198
6255
  document,
6199
6256
  endpointCount: controllerRoutes.length,