@palbase/backend 22.1.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 (81) hide show
  1. package/dist/bin/palbase-backend.cjs +750 -40
  2. package/dist/bin/palbase-backend.cjs.map +1 -1
  3. package/dist/bin/palbase-backend.js +5 -5
  4. package/dist/{chunk-YL4C5NRY.js → chunk-HQRJDARQ.js} +2 -2
  5. package/dist/{chunk-74XDEF5J.js → chunk-M5MCBWJI.js} +723 -37
  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-SQC5EIWY.js → chunk-OHALWEOG.js} +19 -9
  10. package/dist/chunk-OHALWEOG.js.map +1 -0
  11. package/dist/{chunk-I3ON7MYF.js → chunk-PY7YJDCT.js} +129 -18
  12. package/dist/chunk-PY7YJDCT.js.map +1 -0
  13. package/dist/{chunk-N32VDWKH.js → chunk-R3KN6RHD.js} +4 -59
  14. package/dist/chunk-R3KN6RHD.js.map +1 -0
  15. package/dist/{chunk-QMVK4X3V.js → chunk-RCLNBJCM.js} +98 -98
  16. package/dist/chunk-RCLNBJCM.js.map +1 -0
  17. package/dist/db/env.cjs.map +1 -1
  18. package/dist/db/env.d.cts +3 -21
  19. package/dist/db/env.d.ts +3 -21
  20. package/dist/db/index.cjs +140 -16
  21. package/dist/db/index.cjs.map +1 -1
  22. package/dist/db/index.d.cts +3 -2
  23. package/dist/db/index.d.ts +3 -2
  24. package/dist/db/index.js +2 -2
  25. package/dist/{endpoint-BVT6jcVW.d.cts → endpoint-CVWXh6oG.d.ts} +147 -15
  26. package/dist/{endpoint-BVT6jcVW.d.ts → endpoint-c9h5jriX.d.cts} +147 -15
  27. package/dist/engine/index.cjs +750 -40
  28. package/dist/engine/index.cjs.map +1 -1
  29. package/dist/engine/index.d.cts +6 -5
  30. package/dist/engine/index.d.ts +6 -5
  31. package/dist/engine/index.js +4 -4
  32. package/dist/{index-BS1gW4nV.d.cts → index-BZrJXnVh.d.ts} +142 -72
  33. package/dist/{index-BqCiHao8.d.cts → index-By8Dle5U.d.cts} +196 -21
  34. package/dist/{index-vwHoS0l2.d.ts → index-CwAJ7HEe.d.ts} +196 -21
  35. package/dist/{index-CCZqzych.d.ts → index-CxeQSfJP.d.cts} +142 -72
  36. package/dist/index.cjs +388 -1101
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +89 -1134
  39. package/dist/index.d.ts +89 -1134
  40. package/dist/index.js +133 -902
  41. package/dist/index.js.map +1 -1
  42. package/dist/openapi/index.cjs +32 -61
  43. package/dist/openapi/index.cjs.map +1 -1
  44. package/dist/openapi/index.d.cts +6 -2
  45. package/dist/openapi/index.d.ts +6 -2
  46. package/dist/openapi/index.js +34 -26
  47. package/dist/openapi/index.js.map +1 -1
  48. package/dist/{registry-Bsuf-orT.d.ts → registry-B3niOVYp.d.ts} +108 -170
  49. package/dist/{registry-BWttGlaT.d.cts → registry-CqPK2Qby.d.cts} +108 -170
  50. package/dist/{purchases/keys.cjs → stack.cjs} +4 -4
  51. package/dist/stack.cjs.map +1 -0
  52. package/dist/stack.d.cts +76 -0
  53. package/dist/stack.d.ts +76 -0
  54. package/dist/stack.js +1 -0
  55. package/dist/test/index.cjs +482 -9
  56. package/dist/test/index.cjs.map +1 -1
  57. package/dist/test/index.d.cts +35 -3
  58. package/dist/test/index.d.ts +35 -3
  59. package/dist/test/index.js +480 -8
  60. package/dist/test/index.js.map +1 -1
  61. package/docs/README.md +7 -6
  62. package/docs/llms-full.txt +7 -260
  63. package/docs/llms.txt +0 -2
  64. package/package.json +9 -8
  65. package/stager/return_types.js +23 -0
  66. package/template/package.json +1 -1
  67. package/dist/chunk-74XDEF5J.js.map +0 -1
  68. package/dist/chunk-I3ON7MYF.js.map +0 -1
  69. package/dist/chunk-N32VDWKH.js.map +0 -1
  70. package/dist/chunk-QMVK4X3V.js.map +0 -1
  71. package/dist/chunk-SQC5EIWY.js.map +0 -1
  72. package/dist/chunk-W5ODXPY3.js.map +0 -1
  73. package/dist/purchases/keys.cjs.map +0 -1
  74. package/dist/purchases/keys.d.cts +0 -42
  75. package/dist/purchases/keys.d.ts +0 -42
  76. package/dist/purchases/keys.js +0 -1
  77. package/docs/config.md +0 -147
  78. package/docs/resources.md +0 -97
  79. package/template/config/secrets.ts +0 -24
  80. /package/dist/{chunk-YL4C5NRY.js.map → chunk-HQRJDARQ.js.map} +0 -0
  81. /package/dist/{purchases/keys.js.map → stack.js.map} +0 -0
@@ -1,7 +1,8 @@
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-BVT6jcVW.cjs';
4
- import { P as ParamMeta, T as ThrowDescriptor, U as UploadConfig } from '../registry-BWttGlaT.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
+ import '../stack.cjs';
5
6
 
6
7
  /** A controller class (constructor). Kept loose — the only contract is that it
7
8
  * is a `@Controller`-decorated class, asserted via {@link isController}. */
@@ -57,6 +58,9 @@ interface FlatRoute {
57
58
  * presence MARKS this as an upload route through openapi + codegen (the bytes
58
59
  * go client→storage; the method body is the completion handler). */
59
60
  uploadConfig?: UploadConfig;
61
+ /** Present ONLY on `@Sse` routes — the marker the converter turns into
62
+ * `x-palbase-sse`. */
63
+ sseConfig?: SseConfig;
60
64
  }
61
65
  /**
62
66
  * Flatten a `@Controller` class into its route entries. The full path is
@@ -1,7 +1,8 @@
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-BVT6jcVW.js';
4
- import { P as ParamMeta, T as ThrowDescriptor, U as UploadConfig } from '../registry-Bsuf-orT.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
+ import '../stack.js';
5
6
 
6
7
  /** A controller class (constructor). Kept loose — the only contract is that it
7
8
  * is a `@Controller`-decorated class, asserted via {@link isController}. */
@@ -57,6 +58,9 @@ interface FlatRoute {
57
58
  * presence MARKS this as an upload route through openapi + codegen (the bytes
58
59
  * go client→storage; the method body is the completion handler). */
59
60
  uploadConfig?: UploadConfig;
61
+ /** Present ONLY on `@Sse` routes — the marker the converter turns into
62
+ * `x-palbase-sse`. */
63
+ sseConfig?: SseConfig;
60
64
  }
61
65
  /**
62
66
  * Flatten a `@Controller` class into its route entries. The full path is
@@ -1,15 +1,13 @@
1
1
  import {
2
- entitlementFor,
3
- getErrorRegistry,
4
- spendFor
5
- } from "../chunk-N32VDWKH.js";
2
+ getErrorRegistry
3
+ } from "../chunk-R3KN6RHD.js";
6
4
  import {
7
5
  isController,
8
6
  resolveController
9
- } from "../chunk-YL4C5NRY.js";
7
+ } from "../chunk-HQRJDARQ.js";
10
8
  import {
11
9
  getRoutes
12
- } from "../chunk-QMVK4X3V.js";
10
+ } from "../chunk-RCLNBJCM.js";
13
11
  import {
14
12
  __commonJS,
15
13
  __require,
@@ -5792,19 +5790,6 @@ var import_fast_glob = __toESM(require_out4(), 1);
5792
5790
  import path from "path";
5793
5791
  import { pathToFileURL } from "url";
5794
5792
 
5795
- // src/purchases/openapi.ts
5796
- function purchaseThrows(ctor, fnName) {
5797
- const out = [];
5798
- if (entitlementFor(ctor, fnName) !== void 0) {
5799
- out.push({ name: "EntitlementRequired", code: "entitlement_required" });
5800
- }
5801
- if (spendFor(ctor, fnName) !== void 0) {
5802
- out.push({ name: "QuotaExceeded", code: "quota_exceeded" });
5803
- out.push({ name: "CreditInsufficient", code: "credit_insufficient" });
5804
- }
5805
- return out;
5806
- }
5807
-
5808
5793
  // src/openapi/discover.ts
5809
5794
  function capitalizeSegment(s) {
5810
5795
  if (s.length === 0) return s;
@@ -5851,6 +5836,20 @@ function flattenController(controller) {
5851
5836
  const meta = resolveController(controller);
5852
5837
  const controllerName = deriveControllerName(controller.name);
5853
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
+ }
5854
5853
  const out = [];
5855
5854
  for (const route of routes) {
5856
5855
  const fullPath = joinControllerPath(meta.basePath, route.subpath);
@@ -5875,11 +5874,9 @@ function flattenController(controller) {
5875
5874
  break;
5876
5875
  }
5877
5876
  }
5878
- const purchases = purchaseThrows(controller, route.fnName);
5879
5877
  const seen = new Set((route.throws ?? []).map((t) => t.code));
5880
5878
  const allThrows = [
5881
- ...route.throws ?? [],
5882
- ...purchases.filter((t) => !seen.has(t.code))
5879
+ ...route.throws ?? []
5883
5880
  ];
5884
5881
  out.push({
5885
5882
  method: route.method,
@@ -5893,7 +5890,8 @@ function flattenController(controller) {
5893
5890
  ...route.returnSchema !== void 0 ? { returnSchema: route.returnSchema } : {},
5894
5891
  ...route.options.rateLimit !== void 0 ? { rateLimit: route.options.rateLimit } : {},
5895
5892
  ...allThrows.length > 0 ? { throws: allThrows } : {},
5896
- ...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 } : {}
5897
5895
  });
5898
5896
  }
5899
5897
  return out;
@@ -5991,7 +5989,8 @@ function registerControllerRoute(registry, route) {
5991
5989
  returnSchema: route.returnSchema,
5992
5990
  effectiveAuth: route.effectiveAuth,
5993
5991
  throws: route.throws,
5994
- ...route.uploadConfig !== void 0 ? { uploadConfig: route.uploadConfig } : {}
5992
+ ...route.uploadConfig !== void 0 ? { uploadConfig: route.uploadConfig } : {},
5993
+ ...route.sseConfig !== void 0 ? { sseConfig: route.sseConfig } : {}
5995
5994
  });
5996
5995
  }
5997
5996
  function registerOperation(registry, op) {
@@ -6012,7 +6011,11 @@ function registerOperation(registry, op) {
6012
6011
  description: "Success",
6013
6012
  content: {
6014
6013
  "application/json": {
6015
- 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()
6016
6019
  }
6017
6020
  }
6018
6021
  },
@@ -6059,7 +6062,12 @@ function registerOperation(registry, op) {
6059
6062
  bucket: op.uploadConfig.bucket,
6060
6063
  pathTemplate: op.uploadConfig.pathTemplate
6061
6064
  }
6062
- } : {}
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": {} } : {}
6063
6071
  });
6064
6072
  }
6065
6073
  function resolveThrows(throws) {