@palbase/backend 23.0.0 → 24.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 (74) hide show
  1. package/dist/bin/palbase-backend.cjs +695 -61
  2. package/dist/bin/palbase-backend.cjs.map +1 -1
  3. package/dist/bin/palbase-backend.js +4 -5
  4. package/dist/bin/palbase-backend.js.map +1 -1
  5. package/dist/{chunk-FSGSB42K.js → chunk-7Z6MGMXQ.js} +64 -4
  6. package/dist/chunk-7Z6MGMXQ.js.map +1 -0
  7. package/dist/{chunk-OMRTHM4X.js → chunk-H3JAISUY.js} +136 -1
  8. package/dist/chunk-H3JAISUY.js.map +1 -0
  9. package/dist/{chunk-REZU6UKT.js → chunk-NXDH6VQJ.js} +549 -42
  10. package/dist/chunk-NXDH6VQJ.js.map +1 -0
  11. package/dist/{chunk-W5ODXPY3.js → chunk-P2Q27SGP.js} +32 -3
  12. package/dist/chunk-P2Q27SGP.js.map +1 -0
  13. package/dist/{chunk-ZC6Q2BRD.js → chunk-T5IOSOE5.js} +7 -2
  14. package/dist/chunk-T5IOSOE5.js.map +1 -0
  15. package/dist/{chunk-HAF67F2H.js → chunk-ZUGY7RGS.js} +86 -3
  16. package/dist/chunk-ZUGY7RGS.js.map +1 -0
  17. package/dist/db/index.cjs +115 -3
  18. package/dist/db/index.cjs.map +1 -1
  19. package/dist/db/index.d.cts +2 -2
  20. package/dist/db/index.d.ts +2 -2
  21. package/dist/db/index.js +2 -2
  22. package/dist/{endpoint-BavvbW4P.d.ts → endpoint-0_DGBajf.d.ts} +168 -9
  23. package/dist/{endpoint-i8TTCohk.d.cts → endpoint-CcQ1a36a.d.cts} +168 -9
  24. package/dist/engine/index.cjs +684 -48
  25. package/dist/engine/index.cjs.map +1 -1
  26. package/dist/engine/index.d.cts +4 -4
  27. package/dist/engine/index.d.ts +4 -4
  28. package/dist/engine/index.js +4 -4
  29. package/dist/{index-B3jmmItD.d.ts → index-CJiJU9ux.d.ts} +209 -36
  30. package/dist/{index-Bmvx1EvJ.d.cts → index-D-4-PNuQ.d.cts} +209 -36
  31. package/dist/{index-B7YBEG5w.d.ts → index-D17r-MKb.d.ts} +177 -7
  32. package/dist/{index-E7OscPJT.d.cts → index-DRFxf07H.d.cts} +177 -7
  33. package/dist/index.cjs +269 -7
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +54 -12
  36. package/dist/index.d.ts +54 -12
  37. package/dist/index.js +54 -11
  38. package/dist/index.js.map +1 -1
  39. package/dist/openapi/index.cjs +45 -5
  40. package/dist/openapi/index.cjs.map +1 -1
  41. package/dist/openapi/index.d.cts +9 -4
  42. package/dist/openapi/index.d.ts +9 -4
  43. package/dist/openapi/index.js +35 -11
  44. package/dist/openapi/index.js.map +1 -1
  45. package/dist/{registry-C3H2uPeZ.d.cts → registry-1X-skBNu.d.cts} +101 -7
  46. package/dist/{registry-DY3d9l1k.d.ts → registry-CEod_5sz.d.ts} +101 -7
  47. package/dist/test/index.cjs +509 -9
  48. package/dist/test/index.cjs.map +1 -1
  49. package/dist/test/index.d.cts +35 -3
  50. package/dist/test/index.d.ts +35 -3
  51. package/dist/test/index.js +507 -8
  52. package/dist/test/index.js.map +1 -1
  53. package/docs/README.md +4 -4
  54. package/docs/database.md +115 -11
  55. package/docs/getting-started.md +5 -4
  56. package/docs/llms-full.txt +385 -89
  57. package/docs/migrations.md +81 -59
  58. package/docs/schema.md +82 -2
  59. package/docs/services.md +98 -9
  60. package/package.json +3 -2
  61. package/stager/return_types.js +23 -0
  62. package/template/AGENTS.md +121 -41
  63. package/template/controllers/notes.controller.ts +64 -0
  64. package/template/package.json +1 -1
  65. package/template/services/note.service.ts +74 -0
  66. package/template/tsconfig.json +11 -1
  67. package/dist/chunk-FSGSB42K.js.map +0 -1
  68. package/dist/chunk-HAF67F2H.js.map +0 -1
  69. package/dist/chunk-OMRTHM4X.js.map +0 -1
  70. package/dist/chunk-REZU6UKT.js.map +0 -1
  71. package/dist/chunk-W5ODXPY3.js.map +0 -1
  72. package/dist/chunk-Y5HXVUMP.js +0 -90
  73. package/dist/chunk-Y5HXVUMP.js.map +0 -1
  74. package/dist/chunk-ZC6Q2BRD.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { OpenApiGeneratorV31 } from '@asteasolutions/zod-to-openapi';
2
2
  import { ZodTypeAny } from 'zod';
3
- import { A as AuthSpec, R as RateLimitConfig } from '../endpoint-i8TTCohk.cjs';
4
- import { P as ParamMeta, T as ThrowDescriptor, U as UploadConfig } from '../registry-C3H2uPeZ.cjs';
3
+ import { A as AuthSpec, R as RateLimitConfig } from '../endpoint-CcQ1a36a.cjs';
4
+ import { P as ParamMeta, T as ThrowDescriptor, U as UploadConfig, S as SseConfig } from '../registry-1X-skBNu.cjs';
5
5
  import '../stack.cjs';
6
6
 
7
7
  /** A controller class (constructor). Kept loose — the only contract is that it
@@ -39,7 +39,8 @@ interface FlatRoute {
39
39
  * (MembersController → "members"). "" when the derivation is empty — the
40
40
  * operationId then falls back to the flat verb-prefixed form. */
41
41
  controllerName: string;
42
- /** Resolved auth: route option ?? controller default ?? true (secure). */
42
+ /** Resolved auth: route option ?? controller default ?? application default
43
+ * ?? true (secure) — the cascade lives in `resolveEffectiveAuth`. */
43
44
  effectiveAuth: AuthSpec;
44
45
  /** All parameter metas for this route (ordered by index). */
45
46
  params: ParamMeta[];
@@ -58,6 +59,9 @@ interface FlatRoute {
58
59
  * presence MARKS this as an upload route through openapi + codegen (the bytes
59
60
  * go client→storage; the method body is the completion handler). */
60
61
  uploadConfig?: UploadConfig;
62
+ /** Present ONLY on `@Sse` routes — the marker the converter turns into
63
+ * `x-palbase-sse`. */
64
+ sseConfig?: SseConfig;
61
65
  }
62
66
  /**
63
67
  * Flatten a `@Controller` class into its route entries. The full path is
@@ -65,7 +69,8 @@ interface FlatRoute {
65
69
  * `<controllerName>.<fnName>` id (PlacesController.importNearby →
66
70
  * places.importNearby) — matching the Go runtime (extract_meta.js derives the
67
71
  * namespace from the class name; generator.go joins). Effective auth resolves
68
- * the cascade (route ?? controller default ?? secure-by-default).
72
+ * the cascade (route ?? controller default ?? application default ??
73
+ * secure-by-default) through the one resolver the route table asks too.
69
74
  */
70
75
  declare function flattenController(controller: ControllerClass): FlatRoute[];
71
76
  /** The operationId for a route — exposed so callers (convert/aggregate)
@@ -1,7 +1,7 @@
1
1
  import { OpenApiGeneratorV31 } from '@asteasolutions/zod-to-openapi';
2
2
  import { ZodTypeAny } from 'zod';
3
- import { A as AuthSpec, R as RateLimitConfig } from '../endpoint-BavvbW4P.js';
4
- import { P as ParamMeta, T as ThrowDescriptor, U as UploadConfig } from '../registry-DY3d9l1k.js';
3
+ import { A as AuthSpec, R as RateLimitConfig } from '../endpoint-0_DGBajf.js';
4
+ import { P as ParamMeta, T as ThrowDescriptor, U as UploadConfig, S as SseConfig } from '../registry-CEod_5sz.js';
5
5
  import '../stack.js';
6
6
 
7
7
  /** A controller class (constructor). Kept loose — the only contract is that it
@@ -39,7 +39,8 @@ interface FlatRoute {
39
39
  * (MembersController → "members"). "" when the derivation is empty — the
40
40
  * operationId then falls back to the flat verb-prefixed form. */
41
41
  controllerName: string;
42
- /** Resolved auth: route option ?? controller default ?? true (secure). */
42
+ /** Resolved auth: route option ?? controller default ?? application default
43
+ * ?? true (secure) — the cascade lives in `resolveEffectiveAuth`. */
43
44
  effectiveAuth: AuthSpec;
44
45
  /** All parameter metas for this route (ordered by index). */
45
46
  params: ParamMeta[];
@@ -58,6 +59,9 @@ interface FlatRoute {
58
59
  * presence MARKS this as an upload route through openapi + codegen (the bytes
59
60
  * go client→storage; the method body is the completion handler). */
60
61
  uploadConfig?: UploadConfig;
62
+ /** Present ONLY on `@Sse` routes — the marker the converter turns into
63
+ * `x-palbase-sse`. */
64
+ sseConfig?: SseConfig;
61
65
  }
62
66
  /**
63
67
  * Flatten a `@Controller` class into its route entries. The full path is
@@ -65,7 +69,8 @@ interface FlatRoute {
65
69
  * `<controllerName>.<fnName>` id (PlacesController.importNearby →
66
70
  * places.importNearby) — matching the Go runtime (extract_meta.js derives the
67
71
  * namespace from the class name; generator.go joins). Effective auth resolves
68
- * the cascade (route ?? controller default ?? secure-by-default).
72
+ * the cascade (route ?? controller default ?? application default ??
73
+ * secure-by-default) through the one resolver the route table asks too.
69
74
  */
70
75
  declare function flattenController(controller: ControllerClass): FlatRoute[];
71
76
  /** The operationId for a route — exposed so callers (convert/aggregate)
@@ -1,13 +1,12 @@
1
1
  import {
2
2
  getErrorRegistry
3
- } from "../chunk-ZC6Q2BRD.js";
3
+ } from "../chunk-T5IOSOE5.js";
4
4
  import {
5
+ getRoutes,
5
6
  isController,
6
- resolveController
7
- } from "../chunk-Y5HXVUMP.js";
8
- import {
9
- getRoutes
10
- } from "../chunk-OMRTHM4X.js";
7
+ resolveController,
8
+ resolveEffectiveAuth
9
+ } from "../chunk-H3JAISUY.js";
11
10
  import {
12
11
  __commonJS,
13
12
  __require,
@@ -5836,10 +5835,24 @@ function flattenController(controller) {
5836
5835
  const meta = resolveController(controller);
5837
5836
  const controllerName = deriveControllerName(controller.name);
5838
5837
  const routes = getRoutes(controller);
5838
+ const kindsByMethod = /* @__PURE__ */ new Map();
5839
+ for (const route of routes) {
5840
+ const seen = kindsByMethod.get(route.fnName) ?? { sse: false, upload: false };
5841
+ if (route.options.sseConfig !== void 0) seen.sse = true;
5842
+ if (route.options.uploadConfig !== void 0) seen.upload = true;
5843
+ kindsByMethod.set(route.fnName, seen);
5844
+ }
5845
+ for (const [fnName, seen] of kindsByMethod) {
5846
+ if (seen.sse && seen.upload) {
5847
+ throw new Error(
5848
+ `${controller.name}.${fnName} declares BOTH @Sse and @Upload. One method cannot be both a streaming response and an upload completion handler \u2014 the two describe the same handler twice and the second one read silently wins. Split them into two methods.`
5849
+ );
5850
+ }
5851
+ }
5839
5852
  const out = [];
5840
5853
  for (const route of routes) {
5841
5854
  const fullPath = joinControllerPath(meta.basePath, route.subpath);
5842
- const effectiveAuth = route.options.auth ?? meta.defaultAuth ?? true;
5855
+ const effectiveAuth = resolveEffectiveAuth(route.options.auth, meta.defaultAuth);
5843
5856
  const inputSchemas = {};
5844
5857
  const pathParams = [];
5845
5858
  for (const p of route.params) {
@@ -5876,7 +5889,8 @@ function flattenController(controller) {
5876
5889
  ...route.returnSchema !== void 0 ? { returnSchema: route.returnSchema } : {},
5877
5890
  ...route.options.rateLimit !== void 0 ? { rateLimit: route.options.rateLimit } : {},
5878
5891
  ...allThrows.length > 0 ? { throws: allThrows } : {},
5879
- ...route.options.uploadConfig !== void 0 ? { uploadConfig: route.options.uploadConfig } : {}
5892
+ ...route.options.uploadConfig !== void 0 ? { uploadConfig: route.options.uploadConfig } : {},
5893
+ ...route.options.sseConfig !== void 0 ? { sseConfig: route.options.sseConfig } : {}
5880
5894
  });
5881
5895
  }
5882
5896
  return out;
@@ -5974,7 +5988,8 @@ function registerControllerRoute(registry, route) {
5974
5988
  returnSchema: route.returnSchema,
5975
5989
  effectiveAuth: route.effectiveAuth,
5976
5990
  throws: route.throws,
5977
- ...route.uploadConfig !== void 0 ? { uploadConfig: route.uploadConfig } : {}
5991
+ ...route.uploadConfig !== void 0 ? { uploadConfig: route.uploadConfig } : {},
5992
+ ...route.sseConfig !== void 0 ? { sseConfig: route.sseConfig } : {}
5978
5993
  });
5979
5994
  }
5980
5995
  function registerOperation(registry, op) {
@@ -5995,7 +6010,11 @@ function registerOperation(registry, op) {
5995
6010
  description: "Success",
5996
6011
  content: {
5997
6012
  "application/json": {
5998
- schema: op.returnSchema !== void 0 ? op.returnSchema : z.unknown()
6013
+ // A streaming operation's response is ONE FRAME, and its schema is the
6014
+ // declared frame — not the handler's return type, which is void. Without
6015
+ // this the document describes an untyped response and every generated
6016
+ // client is opaque (measured live: the contract gate refuses the deploy).
6017
+ schema: op.sseConfig !== void 0 ? op.sseConfig.frame : op.returnSchema !== void 0 ? op.returnSchema : z.unknown()
5999
6018
  }
6000
6019
  }
6001
6020
  },
@@ -6042,7 +6061,12 @@ function registerOperation(registry, op) {
6042
6061
  bucket: op.uploadConfig.bucket,
6043
6062
  pathTemplate: op.uploadConfig.pathTemplate
6044
6063
  }
6045
- } : {}
6064
+ } : {},
6065
+ // Without this extension the document describes a streaming route as a
6066
+ // plain POST, and every client generated from it reads the body ONCE
6067
+ // instead of iterating frames — a generated client that compiles, runs and
6068
+ // is simply wrong. Same failure class as the upload extension above.
6069
+ ...op.sseConfig !== void 0 ? { "x-palbase-sse": {} } : {}
6046
6070
  });
6047
6071
  }
6048
6072
  function resolveThrows(throws) {