@palbase/backend 23.0.0 → 23.1.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 (60) hide show
  1. package/dist/bin/palbase-backend.cjs +313 -24
  2. package/dist/bin/palbase-backend.cjs.map +1 -1
  3. package/dist/bin/palbase-backend.js +5 -5
  4. package/dist/{chunk-Y5HXVUMP.js → chunk-HQRJDARQ.js} +2 -2
  5. package/dist/{chunk-REZU6UKT.js → chunk-M5MCBWJI.js} +296 -25
  6. package/dist/chunk-M5MCBWJI.js.map +1 -0
  7. package/dist/{chunk-W5ODXPY3.js → chunk-NS5V43YQ.js} +14 -1
  8. package/dist/chunk-NS5V43YQ.js.map +1 -0
  9. package/dist/{chunk-FSGSB42K.js → chunk-OHALWEOG.js} +9 -4
  10. package/dist/chunk-OHALWEOG.js.map +1 -0
  11. package/dist/{chunk-HAF67F2H.js → chunk-PY7YJDCT.js} +57 -3
  12. package/dist/chunk-PY7YJDCT.js.map +1 -0
  13. package/dist/{chunk-ZC6Q2BRD.js → chunk-R3KN6RHD.js} +2 -2
  14. package/dist/{chunk-OMRTHM4X.js → chunk-RCLNBJCM.js} +1 -1
  15. package/dist/chunk-RCLNBJCM.js.map +1 -0
  16. package/dist/db/index.cjs +68 -1
  17. package/dist/db/index.cjs.map +1 -1
  18. package/dist/db/index.d.cts +2 -2
  19. package/dist/db/index.d.ts +2 -2
  20. package/dist/db/index.js +2 -2
  21. package/dist/{endpoint-BavvbW4P.d.ts → endpoint-CVWXh6oG.d.ts} +70 -8
  22. package/dist/{endpoint-i8TTCohk.d.cts → endpoint-c9h5jriX.d.cts} +70 -8
  23. package/dist/engine/index.cjs +313 -24
  24. package/dist/engine/index.cjs.map +1 -1
  25. package/dist/engine/index.d.cts +4 -4
  26. package/dist/engine/index.d.ts +4 -4
  27. package/dist/engine/index.js +4 -4
  28. package/dist/{index-B7YBEG5w.d.ts → index-BZrJXnVh.d.ts} +49 -4
  29. package/dist/{index-Bmvx1EvJ.d.cts → index-By8Dle5U.d.cts} +86 -17
  30. package/dist/{index-B3jmmItD.d.ts → index-CwAJ7HEe.d.ts} +86 -17
  31. package/dist/{index-E7OscPJT.d.cts → index-CxeQSfJP.d.cts} +49 -4
  32. package/dist/index.cjs +104 -3
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +8 -8
  35. package/dist/index.d.ts +8 -8
  36. package/dist/index.js +32 -6
  37. package/dist/index.js.map +1 -1
  38. package/dist/openapi/index.cjs +29 -4
  39. package/dist/openapi/index.cjs.map +1 -1
  40. package/dist/openapi/index.d.cts +5 -2
  41. package/dist/openapi/index.d.ts +5 -2
  42. package/dist/openapi/index.js +32 -7
  43. package/dist/openapi/index.js.map +1 -1
  44. package/dist/{registry-DY3d9l1k.d.ts → registry-B3niOVYp.d.ts} +101 -7
  45. package/dist/{registry-C3H2uPeZ.d.cts → registry-CqPK2Qby.d.cts} +101 -7
  46. package/dist/test/index.cjs +482 -9
  47. package/dist/test/index.cjs.map +1 -1
  48. package/dist/test/index.d.cts +35 -3
  49. package/dist/test/index.d.ts +35 -3
  50. package/dist/test/index.js +480 -8
  51. package/dist/test/index.js.map +1 -1
  52. package/package.json +4 -3
  53. package/stager/return_types.js +23 -0
  54. package/dist/chunk-FSGSB42K.js.map +0 -1
  55. package/dist/chunk-HAF67F2H.js.map +0 -1
  56. package/dist/chunk-OMRTHM4X.js.map +0 -1
  57. package/dist/chunk-REZU6UKT.js.map +0 -1
  58. package/dist/chunk-W5ODXPY3.js.map +0 -1
  59. /package/dist/{chunk-Y5HXVUMP.js.map → chunk-HQRJDARQ.js.map} +0 -0
  60. /package/dist/{chunk-ZC6Q2BRD.js.map → chunk-R3KN6RHD.js.map} +0 -0
@@ -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-c9h5jriX.cjs';
4
+ import { P as ParamMeta, T as ThrowDescriptor, U as UploadConfig, S as SseConfig } from '../registry-CqPK2Qby.cjs';
5
5
  import '../stack.cjs';
6
6
 
7
7
  /** A controller class (constructor). Kept loose — the only contract is that it
@@ -58,6 +58,9 @@ interface FlatRoute {
58
58
  * presence MARKS this as an upload route through openapi + codegen (the bytes
59
59
  * go client→storage; the method body is the completion handler). */
60
60
  uploadConfig?: UploadConfig;
61
+ /** Present ONLY on `@Sse` routes — the marker the converter turns into
62
+ * `x-palbase-sse`. */
63
+ sseConfig?: SseConfig;
61
64
  }
62
65
  /**
63
66
  * Flatten a `@Controller` class into its route entries. The full path is
@@ -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-CVWXh6oG.js';
4
+ import { P as ParamMeta, T as ThrowDescriptor, U as UploadConfig, S as SseConfig } from '../registry-B3niOVYp.js';
5
5
  import '../stack.js';
6
6
 
7
7
  /** A controller class (constructor). Kept loose — the only contract is that it
@@ -58,6 +58,9 @@ interface FlatRoute {
58
58
  * presence MARKS this as an upload route through openapi + codegen (the bytes
59
59
  * go client→storage; the method body is the completion handler). */
60
60
  uploadConfig?: UploadConfig;
61
+ /** Present ONLY on `@Sse` routes — the marker the converter turns into
62
+ * `x-palbase-sse`. */
63
+ sseConfig?: SseConfig;
61
64
  }
62
65
  /**
63
66
  * Flatten a `@Controller` class into its route entries. The full path is
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  getErrorRegistry
3
- } from "../chunk-ZC6Q2BRD.js";
3
+ } from "../chunk-R3KN6RHD.js";
4
4
  import {
5
5
  isController,
6
6
  resolveController
7
- } from "../chunk-Y5HXVUMP.js";
7
+ } from "../chunk-HQRJDARQ.js";
8
8
  import {
9
9
  getRoutes
10
- } from "../chunk-OMRTHM4X.js";
10
+ } from "../chunk-RCLNBJCM.js";
11
11
  import {
12
12
  __commonJS,
13
13
  __require,
@@ -5836,6 +5836,20 @@ function flattenController(controller) {
5836
5836
  const meta = resolveController(controller);
5837
5837
  const controllerName = deriveControllerName(controller.name);
5838
5838
  const routes = getRoutes(controller);
5839
+ const kindsByMethod = /* @__PURE__ */ new Map();
5840
+ for (const route of routes) {
5841
+ const seen = kindsByMethod.get(route.fnName) ?? { sse: false, upload: false };
5842
+ if (route.options.sseConfig !== void 0) seen.sse = true;
5843
+ if (route.options.uploadConfig !== void 0) seen.upload = true;
5844
+ kindsByMethod.set(route.fnName, seen);
5845
+ }
5846
+ for (const [fnName, seen] of kindsByMethod) {
5847
+ if (seen.sse && seen.upload) {
5848
+ throw new Error(
5849
+ `${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.`
5850
+ );
5851
+ }
5852
+ }
5839
5853
  const out = [];
5840
5854
  for (const route of routes) {
5841
5855
  const fullPath = joinControllerPath(meta.basePath, route.subpath);
@@ -5876,7 +5890,8 @@ function flattenController(controller) {
5876
5890
  ...route.returnSchema !== void 0 ? { returnSchema: route.returnSchema } : {},
5877
5891
  ...route.options.rateLimit !== void 0 ? { rateLimit: route.options.rateLimit } : {},
5878
5892
  ...allThrows.length > 0 ? { throws: allThrows } : {},
5879
- ...route.options.uploadConfig !== void 0 ? { uploadConfig: route.options.uploadConfig } : {}
5893
+ ...route.options.uploadConfig !== void 0 ? { uploadConfig: route.options.uploadConfig } : {},
5894
+ ...route.options.sseConfig !== void 0 ? { sseConfig: route.options.sseConfig } : {}
5880
5895
  });
5881
5896
  }
5882
5897
  return out;
@@ -5974,7 +5989,8 @@ function registerControllerRoute(registry, route) {
5974
5989
  returnSchema: route.returnSchema,
5975
5990
  effectiveAuth: route.effectiveAuth,
5976
5991
  throws: route.throws,
5977
- ...route.uploadConfig !== void 0 ? { uploadConfig: route.uploadConfig } : {}
5992
+ ...route.uploadConfig !== void 0 ? { uploadConfig: route.uploadConfig } : {},
5993
+ ...route.sseConfig !== void 0 ? { sseConfig: route.sseConfig } : {}
5978
5994
  });
5979
5995
  }
5980
5996
  function registerOperation(registry, op) {
@@ -5995,7 +6011,11 @@ function registerOperation(registry, op) {
5995
6011
  description: "Success",
5996
6012
  content: {
5997
6013
  "application/json": {
5998
- schema: op.returnSchema !== void 0 ? op.returnSchema : z.unknown()
6014
+ // A streaming operation's response is ONE FRAME, and its schema is the
6015
+ // declared frame — not the handler's return type, which is void. Without
6016
+ // this the document describes an untyped response and every generated
6017
+ // client is opaque (measured live: the contract gate refuses the deploy).
6018
+ schema: op.sseConfig !== void 0 ? op.sseConfig.frame : op.returnSchema !== void 0 ? op.returnSchema : z.unknown()
5999
6019
  }
6000
6020
  }
6001
6021
  },
@@ -6042,7 +6062,12 @@ function registerOperation(registry, op) {
6042
6062
  bucket: op.uploadConfig.bucket,
6043
6063
  pathTemplate: op.uploadConfig.pathTemplate
6044
6064
  }
6045
- } : {}
6065
+ } : {},
6066
+ // Without this extension the document describes a streaming route as a
6067
+ // plain POST, and every client generated from it reads the body ONCE
6068
+ // instead of iterating frames — a generated client that compiles, runs and
6069
+ // is simply wrong. Same failure class as the upload extension above.
6070
+ ...op.sseConfig !== void 0 ? { "x-palbase-sse": {} } : {}
6046
6071
  });
6047
6072
  }
6048
6073
  function resolveThrows(throws) {