@palbase/backend 34.0.0 → 34.1.1
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/LICENSE +21 -0
- package/dist/bin/palbase-backend.cjs +275 -30
- package/dist/bin/palbase-backend.cjs.map +1 -1
- package/dist/bin/palbase-backend.js +4 -4
- package/dist/{chunk-SEM36BWY.js → chunk-5UGPXKMJ.js} +60 -12
- package/dist/chunk-5UGPXKMJ.js.map +1 -0
- package/dist/{chunk-FOWA7PF4.js → chunk-P7MGSAFT.js} +6 -1
- package/dist/{chunk-FOWA7PF4.js.map → chunk-P7MGSAFT.js.map} +1 -1
- package/dist/{chunk-YX7UA7VC.js → chunk-X2UYIXDS.js} +8 -2
- package/dist/chunk-X2UYIXDS.js.map +1 -0
- package/dist/{chunk-MNGZE2MM.js → chunk-XZPDPYVY.js} +279 -34
- package/dist/chunk-XZPDPYVY.js.map +1 -0
- package/dist/{chunk-LOGL2ZHD.js → chunk-YO5GYM73.js} +2 -2
- package/dist/db/index.cjs +34 -10
- package/dist/db/index.cjs.map +1 -1
- package/dist/db/index.d.cts +2 -2
- package/dist/db/index.d.ts +2 -2
- package/dist/db/index.js +2 -2
- package/dist/{endpoint-DpNUx-ON.d.ts → endpoint-BXPdsTA5.d.ts} +56 -2
- package/dist/{endpoint-kYgEHrrV.d.cts → endpoint-DqhUP7RT.d.cts} +56 -2
- package/dist/engine/index.cjs +275 -30
- package/dist/engine/index.cjs.map +1 -1
- package/dist/engine/index.d.cts +3 -3
- package/dist/engine/index.d.ts +3 -3
- package/dist/engine/index.js +4 -4
- package/dist/{index-pnDsEfxJ.d.cts → index-Co0Hj_aO.d.cts} +2 -2
- package/dist/{index-JrHqNsjQ.d.ts → index-MhCL7ll4.d.ts} +2 -2
- package/dist/index.cjs +79 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/openapi/index.d.cts +2 -2
- package/dist/openapi/index.d.ts +2 -2
- package/dist/{registry-BcOd8Zhf.d.cts → registry-BkIVHPzB.d.cts} +1 -1
- package/dist/{registry-BoX5iNyY.d.ts → registry-CvGLR5j1.d.ts} +1 -1
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.d.cts +1 -1
- package/dist/test/index.d.ts +1 -1
- package/dist/test/index.js +2 -2
- package/dist/test/index.js.map +1 -1
- package/docs/auth.md +58 -0
- package/docs/llms-full.txt +73 -0
- package/docs/schema.md +15 -0
- package/package.json +15 -15
- package/template/db/public.ts +12 -0
- package/template/scripts/test.sh +0 -0
- package/dist/chunk-MNGZE2MM.js.map +0 -1
- package/dist/chunk-SEM36BWY.js.map +0 -1
- package/dist/chunk-YX7UA7VC.js.map +0 -1
- /package/dist/{chunk-LOGL2ZHD.js.map → chunk-YO5GYM73.js.map} +0 -0
package/dist/engine/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import '../endpoint-
|
|
2
|
-
export { A as App, g as AuthVerifier, B as BootRefused, h as COMMAND_EXECUTOR_DDL, j as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, k as EngineConfig, M as ModuleClients, R as RateLimiter, l as RequestDatabase, m as RouteEntry, n as RuntimeHooks, S as ScrubResult, o as SqlDriver, p as SqlTx, q as buildRouteTable, r as createApp, s as createLazyTransaction, t as createOps, u as createRequestDatabase, v as effectiveAuth, w as hostAllowed, x as installCommandExecutor, y as installEgressFence, i as isDeclarationRefused, z as loadConfig, F as makeMemoryCache, G as matchRoute, H as quoteIdent, I as scrubSecrets, J as setCursorKey, K as withQueryCancellation, L as withTables } from '../index-
|
|
1
|
+
import '../endpoint-DqhUP7RT.cjs';
|
|
2
|
+
export { A as App, g as AuthVerifier, B as BootRefused, h as COMMAND_EXECUTOR_DDL, j as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, k as EngineConfig, M as ModuleClients, R as RateLimiter, l as RequestDatabase, m as RouteEntry, n as RuntimeHooks, S as ScrubResult, o as SqlDriver, p as SqlTx, q as buildRouteTable, r as createApp, s as createLazyTransaction, t as createOps, u as createRequestDatabase, v as effectiveAuth, w as hostAllowed, x as installCommandExecutor, y as installEgressFence, i as isDeclarationRefused, z as loadConfig, F as makeMemoryCache, G as matchRoute, H as quoteIdent, I as scrubSecrets, J as setCursorKey, K as withQueryCancellation, L as withTables } from '../index-Co0Hj_aO.cjs';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '../stack.cjs';
|
|
5
5
|
import '../db/env.cjs';
|
|
6
6
|
import 'node:async_hooks';
|
|
7
7
|
import '../module-Dl1KFVtc.cjs';
|
|
8
|
-
import '../registry-
|
|
8
|
+
import '../registry-BkIVHPzB.cjs';
|
package/dist/engine/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import '../endpoint-
|
|
2
|
-
export { A as App, g as AuthVerifier, B as BootRefused, h as COMMAND_EXECUTOR_DDL, j as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, k as EngineConfig, M as ModuleClients, R as RateLimiter, l as RequestDatabase, m as RouteEntry, n as RuntimeHooks, S as ScrubResult, o as SqlDriver, p as SqlTx, q as buildRouteTable, r as createApp, s as createLazyTransaction, t as createOps, u as createRequestDatabase, v as effectiveAuth, w as hostAllowed, x as installCommandExecutor, y as installEgressFence, i as isDeclarationRefused, z as loadConfig, F as makeMemoryCache, G as matchRoute, H as quoteIdent, I as scrubSecrets, J as setCursorKey, K as withQueryCancellation, L as withTables } from '../index-
|
|
1
|
+
import '../endpoint-BXPdsTA5.js';
|
|
2
|
+
export { A as App, g as AuthVerifier, B as BootRefused, h as COMMAND_EXECUTOR_DDL, j as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, k as EngineConfig, M as ModuleClients, R as RateLimiter, l as RequestDatabase, m as RouteEntry, n as RuntimeHooks, S as ScrubResult, o as SqlDriver, p as SqlTx, q as buildRouteTable, r as createApp, s as createLazyTransaction, t as createOps, u as createRequestDatabase, v as effectiveAuth, w as hostAllowed, x as installCommandExecutor, y as installEgressFence, i as isDeclarationRefused, z as loadConfig, F as makeMemoryCache, G as matchRoute, H as quoteIdent, I as scrubSecrets, J as setCursorKey, K as withQueryCancellation, L as withTables } from '../index-MhCL7ll4.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '../stack.js';
|
|
5
5
|
import '../db/env.js';
|
|
6
6
|
import 'node:async_hooks';
|
|
7
7
|
import '../module-Dl1KFVtc.js';
|
|
8
|
-
import '../registry-
|
|
8
|
+
import '../registry-CvGLR5j1.js';
|
package/dist/engine/index.js
CHANGED
|
@@ -20,16 +20,16 @@ import {
|
|
|
20
20
|
setCursorKey,
|
|
21
21
|
withQueryCancellation,
|
|
22
22
|
withTables
|
|
23
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-XZPDPYVY.js";
|
|
24
24
|
import {
|
|
25
25
|
DECLARATION_REFUSAL,
|
|
26
26
|
DeclarationRefused,
|
|
27
27
|
isDeclarationRefused
|
|
28
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-X2UYIXDS.js";
|
|
29
29
|
import "../chunk-GHNC2UHS.js";
|
|
30
|
-
import "../chunk-
|
|
30
|
+
import "../chunk-YO5GYM73.js";
|
|
31
31
|
import "../chunk-PRH45NZU.js";
|
|
32
|
-
import "../chunk-
|
|
32
|
+
import "../chunk-P7MGSAFT.js";
|
|
33
33
|
import "../chunk-JJW3L62T.js";
|
|
34
34
|
import "../chunk-UMESJJRS.js";
|
|
35
35
|
import "../chunk-VXPNPVAG.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as DatabaseDiagnosticsOptions, d as DatabaseDiagnostics, a as DBClient, T as TransactionIsolation, e as DBOps, P as PreparedRead, C as CompiledRead, f as RawPageOptions, g as Page, h as TxPlanBody, i as CommandOptions, j as TxPlanResponse, A as AuthSpec, k as CacheClient, b as RuntimeServices, _ as __runWithRuntime, l as __requestALS } from './endpoint-
|
|
1
|
+
import { c as DatabaseDiagnosticsOptions, d as DatabaseDiagnostics, a as DBClient, T as TransactionIsolation, e as DBOps, P as PreparedRead, C as CompiledRead, f as RawPageOptions, g as Page, h as TxPlanBody, i as CommandOptions, j as TxPlanResponse, A as AuthSpec, k as CacheClient, b as RuntimeServices, _ as __runWithRuntime, l as __requestALS } from './endpoint-DqhUP7RT.cjs';
|
|
2
2
|
import { T as Token } from './module-Dl1KFVtc.cjs';
|
|
3
|
-
import { R as RouteMeta } from './registry-
|
|
3
|
+
import { R as RouteMeta } from './registry-BkIVHPzB.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* engine/config.ts — settings from the environment, and the gate that refuses
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as DatabaseDiagnosticsOptions, d as DatabaseDiagnostics, a as DBClient, T as TransactionIsolation, e as DBOps, P as PreparedRead, C as CompiledRead, f as RawPageOptions, g as Page, h as TxPlanBody, i as CommandOptions, j as TxPlanResponse, A as AuthSpec, k as CacheClient, b as RuntimeServices, _ as __runWithRuntime, l as __requestALS } from './endpoint-
|
|
1
|
+
import { c as DatabaseDiagnosticsOptions, d as DatabaseDiagnostics, a as DBClient, T as TransactionIsolation, e as DBOps, P as PreparedRead, C as CompiledRead, f as RawPageOptions, g as Page, h as TxPlanBody, i as CommandOptions, j as TxPlanResponse, A as AuthSpec, k as CacheClient, b as RuntimeServices, _ as __runWithRuntime, l as __requestALS } from './endpoint-BXPdsTA5.js';
|
|
2
2
|
import { T as Token } from './module-Dl1KFVtc.js';
|
|
3
|
-
import { R as RouteMeta } from './registry-
|
|
3
|
+
import { R as RouteMeta } from './registry-CvGLR5j1.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* engine/config.ts — settings from the environment, and the gate that refuses
|
package/dist/index.cjs
CHANGED
|
@@ -108,6 +108,7 @@ __export(src_exports, {
|
|
|
108
108
|
boolean: () => boolean,
|
|
109
109
|
buildContainer: () => buildContainer,
|
|
110
110
|
buildModuleClients: () => buildModuleClients,
|
|
111
|
+
can: () => can,
|
|
111
112
|
col: () => col,
|
|
112
113
|
controllersOf: () => controllersOf,
|
|
113
114
|
dec: () => dec,
|
|
@@ -169,7 +170,7 @@ __export(src_exports, {
|
|
|
169
170
|
vector: () => vector,
|
|
170
171
|
webhooksOf: () => webhooksOf,
|
|
171
172
|
withRetry: () => withRetry,
|
|
172
|
-
z: () =>
|
|
173
|
+
z: () => import_zod4.z
|
|
173
174
|
});
|
|
174
175
|
module.exports = __toCommonJS(src_exports);
|
|
175
176
|
|
|
@@ -975,6 +976,11 @@ function tableToJSON(table, schemaName) {
|
|
|
975
976
|
// drifts — the direction it drifted last time was "expose everything", and
|
|
976
977
|
// the live proof was one user reading another's rows.
|
|
977
978
|
rls: table.rls,
|
|
979
|
+
// KOŞAN SÜRÜMÜN SÖZÜ TELE ÇIKAR — yoksa daralma kapısı onu göremez.
|
|
980
|
+
// `ColumnJSON.ignored` ile aynı sözleşme: işaretlenmemişse alan YOK.
|
|
981
|
+
...table.ignored === true ? {
|
|
982
|
+
ignored: true
|
|
983
|
+
} : {},
|
|
978
984
|
policies: (table.policies ?? []).map(policyToJSON)
|
|
979
985
|
};
|
|
980
986
|
if (table.primaryKey !== void 0 && table.primaryKey.length > 0) {
|
|
@@ -2585,6 +2591,7 @@ function buildModuleClients(cfg) {
|
|
|
2585
2591
|
__name(buildModuleClients, "buildModuleClients");
|
|
2586
2592
|
|
|
2587
2593
|
// src/db/policy.ts
|
|
2594
|
+
var import_zod = require("zod");
|
|
2588
2595
|
var PolicyExprRef = class _PolicyExprRef {
|
|
2589
2596
|
static {
|
|
2590
2597
|
__name(this, "PolicyExprRef");
|
|
@@ -2817,6 +2824,45 @@ function policy(name) {
|
|
|
2817
2824
|
return new PolicyBuilder(name);
|
|
2818
2825
|
}
|
|
2819
2826
|
__name(policy, "policy");
|
|
2827
|
+
function can(table) {
|
|
2828
|
+
const def = table;
|
|
2829
|
+
if (typeof def.name !== "string" || def.columns === null || typeof def.columns !== "object" || !Array.isArray(def.policies)) {
|
|
2830
|
+
throw new Error("can(<table>): expects the schema's table definition \u2014 can(publicSchema.tables.notes) \u2014 not the defineTable handle (`notes`)");
|
|
2831
|
+
}
|
|
2832
|
+
if (Object.prototype.hasOwnProperty.call(table.columns, "can")) {
|
|
2833
|
+
throw new Error(`can(${table.name}): the table declares a column named "can", so the row carries that column and no policy echo \u2014 rename the column to get can`);
|
|
2834
|
+
}
|
|
2835
|
+
const rel = reservedCanRelation(table.name, table.columns);
|
|
2836
|
+
if (rel !== null) {
|
|
2837
|
+
throw new Error(`can(${table.name}): ${rel}`);
|
|
2838
|
+
}
|
|
2839
|
+
const names = table.policies.filter((p) => p.command === "update" && p.permissive !== false && Buffer.byteLength(`can:${p.name}`, "utf8") <= 63).map((p) => p.name);
|
|
2840
|
+
if (names.length === 0) {
|
|
2841
|
+
const all = table.policies.filter((p) => p.command === "all").map((p) => p.name);
|
|
2842
|
+
const hint = all.length > 0 ? ` The table's ${all.map((n) => `"${n}"`).join(", ")} ${all.length === 1 ? "policy is" : "policies are"} for("all") \u2014 for("all") governs UPDATE but is not a named update policy and never appears in can.` : "";
|
|
2843
|
+
throw new Error(`can(${table.name}): the table declares no update policy \u2014 there is nothing a row could echo. Name one with policy("<name>").for("update").using(\u2026) first.${hint}`);
|
|
2844
|
+
}
|
|
2845
|
+
return import_zod.z.array(import_zod.z.enum(names));
|
|
2846
|
+
}
|
|
2847
|
+
__name(can, "can");
|
|
2848
|
+
function reservedCanRelation(tableName, columns) {
|
|
2849
|
+
if (tableName === "can") {
|
|
2850
|
+
return `a table named "can" would put a relation named "can" on every parent it references \u2014 rename the table`;
|
|
2851
|
+
}
|
|
2852
|
+
for (const [col2, b] of Object.entries(columns)) {
|
|
2853
|
+
const def = b._def;
|
|
2854
|
+
if (def.referencesThunk === void 0 && def.selfRefColumn === void 0) continue;
|
|
2855
|
+
if (def.reverseAs === "can") {
|
|
2856
|
+
return `column "${col2}" names its reverse relation "can" \u2014 the parent's rows would carry a relation where can is reserved; pick another reverseAs`;
|
|
2857
|
+
}
|
|
2858
|
+
const forward = def.owns === true ? "owner" : def.refAs ?? (col2.endsWith("_id") ? col2.slice(0, -3) : col2);
|
|
2859
|
+
if (forward === "can") {
|
|
2860
|
+
return `column "${col2}" would be read as a relation named "can" (${def.refAs === void 0 ? "derived from the column name" : "its as: option"}) \u2014 can is reserved for the policy echo; rename it`;
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
return null;
|
|
2864
|
+
}
|
|
2865
|
+
__name(reservedCanRelation, "reservedCanRelation");
|
|
2820
2866
|
|
|
2821
2867
|
// src/db/schema.ts
|
|
2822
2868
|
var IndexBuilder = class {
|
|
@@ -2894,6 +2940,10 @@ function defineTable(name, input) {
|
|
|
2894
2940
|
if (name.trim() === "") {
|
|
2895
2941
|
throw new Error("defineTable(name, \u2026): name must not be empty");
|
|
2896
2942
|
}
|
|
2943
|
+
{
|
|
2944
|
+
const reserved = reservedCanRelation(name, input.columns);
|
|
2945
|
+
if (reserved !== null) throw new Error(`defineTable(${JSON.stringify(name)}): ${reserved}`);
|
|
2946
|
+
}
|
|
2897
2947
|
const policies = (input.policies?.(exprCtx(Object.keys(input.columns), 0, name)) ?? []).map(toPolicyDef);
|
|
2898
2948
|
const rls = policies.length > 0 || input.rls !== false;
|
|
2899
2949
|
const owned2 = {};
|
|
@@ -2922,6 +2972,7 @@ function defineTable(name, input) {
|
|
|
2922
2972
|
const declaredIndexes = (input.indexes?.(exprCtx(Object.keys(input.columns), 0, name)) ?? []).map((i) => i instanceof IndexBuilder ? i._def : i);
|
|
2923
2973
|
if (declaredIndexes.length > 0) def.indexes = declaredIndexes;
|
|
2924
2974
|
if (input.appendOnly === true) def.appendOnly = true;
|
|
2975
|
+
if (input.ignored === true) def.ignored = true;
|
|
2925
2976
|
if (input.search !== void 0) {
|
|
2926
2977
|
const s = input.search;
|
|
2927
2978
|
if (s.from !== void 0) {
|
|
@@ -4078,6 +4129,9 @@ function tableBlock(table, relations, indent) {
|
|
|
4078
4129
|
const rowLines = cols.map(([col2, builder]) => {
|
|
4079
4130
|
return `${indent} ${col2}: ${rowType(builder._def)};`;
|
|
4080
4131
|
});
|
|
4132
|
+
const hasCanColumn = Object.prototype.hasOwnProperty.call(table.columns, "can") || relations.some((r) => r.name === "can");
|
|
4133
|
+
const canNames = (table.policies ?? []).filter((p) => p.command === "update" && p.permissive !== false && Buffer.byteLength(`can:${p.name}`, "utf8") <= 63).map((p) => JSON.stringify(p.name));
|
|
4134
|
+
const canLine = hasCanColumn ? null : `${indent} can: ${canNames.length === 0 ? "never[]" : `(${canNames.join(" | ")})[]`};`;
|
|
4081
4135
|
const insertLines = cols.map(([col2, builder]) => {
|
|
4082
4136
|
const def = builder._def;
|
|
4083
4137
|
const opt = optionalOnInsert(def) ? "?" : "";
|
|
@@ -4088,6 +4142,9 @@ function tableBlock(table, relations, indent) {
|
|
|
4088
4142
|
`${indent}${table.name}: {`,
|
|
4089
4143
|
`${indent} row: {`,
|
|
4090
4144
|
...rowLines,
|
|
4145
|
+
...canLine === null ? [] : [
|
|
4146
|
+
canLine
|
|
4147
|
+
],
|
|
4091
4148
|
`${indent} };`,
|
|
4092
4149
|
`${indent} insert: {`,
|
|
4093
4150
|
...insertLines,
|
|
@@ -4910,18 +4967,18 @@ __name(defineMiddleware, "defineMiddleware");
|
|
|
4910
4967
|
|
|
4911
4968
|
// src/error-registry.ts
|
|
4912
4969
|
var import_zod_to_openapi = require("@asteasolutions/zod-to-openapi");
|
|
4913
|
-
var
|
|
4914
|
-
(0, import_zod_to_openapi.extendZodWithOpenApi)(
|
|
4970
|
+
var import_zod2 = require("zod");
|
|
4971
|
+
(0, import_zod_to_openapi.extendZodWithOpenApi)(import_zod2.z);
|
|
4915
4972
|
var ERROR_REGISTRY = /* @__PURE__ */ Symbol.for("palbase.backend.errorRegistry");
|
|
4916
4973
|
var BUILTIN_DATA_SCHEMAS = {
|
|
4917
|
-
bad_request:
|
|
4918
|
-
fields:
|
|
4919
|
-
field:
|
|
4920
|
-
message:
|
|
4974
|
+
bad_request: import_zod2.z.object({
|
|
4975
|
+
fields: import_zod2.z.array(import_zod2.z.object({
|
|
4976
|
+
field: import_zod2.z.string(),
|
|
4977
|
+
message: import_zod2.z.string()
|
|
4921
4978
|
}))
|
|
4922
4979
|
}),
|
|
4923
|
-
too_many_requests:
|
|
4924
|
-
retryAfter:
|
|
4980
|
+
too_many_requests: import_zod2.z.object({
|
|
4981
|
+
retryAfter: import_zod2.z.number().int()
|
|
4925
4982
|
})
|
|
4926
4983
|
};
|
|
4927
4984
|
function getErrorRegistry() {
|
|
@@ -5038,7 +5095,7 @@ __name(defineError, "defineError");
|
|
|
5038
5095
|
function digestOf(code, dataSchema) {
|
|
5039
5096
|
const TMP_REF = "__PalbaseErrorDataDigest";
|
|
5040
5097
|
const tmpRegistry = new import_zod_to_openapi.OpenAPIRegistry();
|
|
5041
|
-
tmpRegistry.register(TMP_REF,
|
|
5098
|
+
tmpRegistry.register(TMP_REF, import_zod2.z.object({
|
|
5042
5099
|
data: dataSchema
|
|
5043
5100
|
}).openapi(TMP_REF));
|
|
5044
5101
|
const generated = new import_zod_to_openapi.OpenApiGeneratorV31(tmpRegistry.definitions).generateComponents();
|
|
@@ -5632,10 +5689,10 @@ function getJobConfig(ctor, container) {
|
|
|
5632
5689
|
__name(getJobConfig, "getJobConfig");
|
|
5633
5690
|
|
|
5634
5691
|
// src/index.ts
|
|
5635
|
-
var
|
|
5692
|
+
var import_zod4 = require("zod");
|
|
5636
5693
|
|
|
5637
5694
|
// src/db/query.ts
|
|
5638
|
-
var
|
|
5695
|
+
var import_zod3 = require("zod");
|
|
5639
5696
|
var import_zod_to_openapi2 = require("@asteasolutions/zod-to-openapi");
|
|
5640
5697
|
|
|
5641
5698
|
// src/db/query-contract.ts
|
|
@@ -5668,27 +5725,27 @@ function stableContract(value) {
|
|
|
5668
5725
|
__name(stableContract, "stableContract");
|
|
5669
5726
|
|
|
5670
5727
|
// src/db/query.ts
|
|
5671
|
-
(0, import_zod_to_openapi2.extendZodWithOpenApi)(
|
|
5728
|
+
(0, import_zod_to_openapi2.extendZodWithOpenApi)(import_zod3.z);
|
|
5672
5729
|
function responseColumn(column, validator) {
|
|
5673
5730
|
const contract = queryColumnContract(column);
|
|
5674
5731
|
let schema;
|
|
5675
5732
|
if (validator) return validator;
|
|
5676
|
-
if (contract.codec === "number") schema =
|
|
5677
|
-
else if (contract.codec === "decimal") schema =
|
|
5733
|
+
if (contract.codec === "number") schema = import_zod3.z.number().finite();
|
|
5734
|
+
else if (contract.codec === "decimal") schema = import_zod3.z.string();
|
|
5678
5735
|
else switch (contract.type) {
|
|
5679
5736
|
case "integer":
|
|
5680
|
-
schema =
|
|
5737
|
+
schema = import_zod3.z.number().int().min(-2147483648).max(2147483647);
|
|
5681
5738
|
break;
|
|
5682
5739
|
case "boolean":
|
|
5683
|
-
schema =
|
|
5740
|
+
schema = import_zod3.z.boolean();
|
|
5684
5741
|
break;
|
|
5685
5742
|
case "vector":
|
|
5686
|
-
schema =
|
|
5743
|
+
schema = import_zod3.z.array(import_zod3.z.number().finite());
|
|
5687
5744
|
break;
|
|
5688
5745
|
case "enum": {
|
|
5689
5746
|
const values = contract.enumValues;
|
|
5690
5747
|
if (!values?.length) throw new Error("Query response requires declared enum values");
|
|
5691
|
-
schema =
|
|
5748
|
+
schema = import_zod3.z.enum(values);
|
|
5692
5749
|
break;
|
|
5693
5750
|
}
|
|
5694
5751
|
case "uuid":
|
|
@@ -5696,7 +5753,7 @@ function responseColumn(column, validator) {
|
|
|
5696
5753
|
case "timestamp":
|
|
5697
5754
|
case "numeric":
|
|
5698
5755
|
case "bigint":
|
|
5699
|
-
schema =
|
|
5756
|
+
schema = import_zod3.z.string();
|
|
5700
5757
|
break;
|
|
5701
5758
|
case "jsonb":
|
|
5702
5759
|
throw new Error("Query response requires a fields validator for a selected jsonb column: its TypeScript payload is erased at runtime");
|
|
@@ -5719,7 +5776,7 @@ function defineQuery(name, options) {
|
|
|
5719
5776
|
columns[key] = queryColumnContract(options.table[key]);
|
|
5720
5777
|
shape[key] = responseColumn(options.table[key], options.fields?.[key]);
|
|
5721
5778
|
}
|
|
5722
|
-
const response =
|
|
5779
|
+
const response = import_zod3.z.array(import_zod3.z.object(shape).strict());
|
|
5723
5780
|
const queryInput = options.input, where = options.where, limit = options.limit;
|
|
5724
5781
|
const orderBy = options.orderBy === void 0 ? void 0 : JSON.parse(JSON.stringify(options.orderBy));
|
|
5725
5782
|
const prepare = /* @__PURE__ */ __name((input) => {
|
|
@@ -5903,6 +5960,7 @@ __name(assertQueryManifest, "assertQueryManifest");
|
|
|
5903
5960
|
boolean,
|
|
5904
5961
|
buildContainer,
|
|
5905
5962
|
buildModuleClients,
|
|
5963
|
+
can,
|
|
5906
5964
|
col,
|
|
5907
5965
|
controllersOf,
|
|
5908
5966
|
dec,
|