@palbase/backend 33.0.2 → 34.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.
- package/dist/bin/palbase-backend.cjs +2020 -350
- package/dist/bin/palbase-backend.cjs.map +1 -1
- package/dist/bin/palbase-backend.js +9 -7
- package/dist/bin/palbase-backend.js.map +1 -1
- package/dist/{chunk-SI4KGEM3.js → chunk-FOWA7PF4.js} +97 -96
- package/dist/chunk-FOWA7PF4.js.map +1 -0
- package/dist/chunk-GHNC2UHS.js +20 -0
- package/dist/chunk-GHNC2UHS.js.map +1 -0
- package/dist/{chunk-AAT5G7KY.js → chunk-JJW3L62T.js} +2 -2
- package/dist/chunk-JJW3L62T.js.map +1 -0
- package/dist/{chunk-TVCCR6SO.js → chunk-LOGL2ZHD.js} +58 -9
- package/dist/chunk-LOGL2ZHD.js.map +1 -0
- package/dist/{chunk-C6COAB3E.js → chunk-MNGZE2MM.js} +1651 -186
- package/dist/chunk-MNGZE2MM.js.map +1 -0
- package/dist/{chunk-XOX6RFPZ.js → chunk-PRH45NZU.js} +46 -3
- package/dist/chunk-PRH45NZU.js.map +1 -0
- package/dist/{chunk-26GH54D2.js → chunk-RZLY4BOY.js} +5 -3
- package/dist/{chunk-26GH54D2.js.map → chunk-RZLY4BOY.js.map} +1 -1
- package/dist/{chunk-YIQ4RS4F.js → chunk-SEM36BWY.js} +283 -5
- package/dist/chunk-SEM36BWY.js.map +1 -0
- package/dist/{chunk-KATPXCJ5.js → chunk-UMESJJRS.js} +19 -40
- package/dist/chunk-UMESJJRS.js.map +1 -0
- package/dist/chunk-VXPNPVAG.js +40 -0
- package/dist/chunk-VXPNPVAG.js.map +1 -0
- package/dist/{chunk-WWUG2QXF.js → chunk-YX7UA7VC.js} +53 -4
- package/dist/chunk-YX7UA7VC.js.map +1 -0
- package/dist/db/env.cjs.map +1 -1
- package/dist/db/env.d.cts +2 -0
- package/dist/db/env.d.ts +2 -0
- package/dist/db/index.cjs +261 -2
- package/dist/db/index.cjs.map +1 -1
- package/dist/db/index.d.cts +46 -3
- package/dist/db/index.d.ts +46 -3
- package/dist/db/index.js +14 -5
- package/dist/{index-DMZG3kpo.d.ts → endpoint-DpNUx-ON.d.ts} +315 -57
- package/dist/{index-DB_nW-AV.d.cts → endpoint-kYgEHrrV.d.cts} +315 -57
- package/dist/engine/index.cjs +2026 -348
- package/dist/engine/index.cjs.map +1 -1
- package/dist/engine/index.d.cts +5 -5
- package/dist/engine/index.d.ts +5 -5
- package/dist/engine/index.js +17 -7
- package/dist/{index-D-3duy8Y.d.ts → index-JrHqNsjQ.d.ts} +108 -50
- package/dist/{index-DLveQoOf.d.cts → index-pnDsEfxJ.d.cts} +108 -50
- package/dist/index.cjs +616 -254
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +25 -15
- package/dist/index.js.map +1 -1
- package/dist/openapi/index.cjs +7 -0
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.d.cts +3 -3
- package/dist/openapi/index.d.ts +3 -3
- package/dist/openapi/index.js +4 -3
- package/dist/openapi/index.js.map +1 -1
- package/dist/{registry-DSTThhKf.d.cts → registry-BcOd8Zhf.d.cts} +3 -1
- package/dist/{registry-JjF5lcj4.d.ts → registry-BoX5iNyY.d.ts} +3 -1
- package/dist/test/index.cjs +103 -66
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.d.cts +3 -3
- package/dist/test/index.d.ts +3 -3
- package/dist/test/index.js +33 -7
- package/dist/test/index.js.map +1 -1
- package/docs/README.md +1 -1
- package/docs/database.md +308 -0
- package/docs/examples/check-query-contracts.ts +5 -0
- package/docs/examples/database-dx.contract.json +65 -0
- package/docs/examples/database-dx.ts +63 -0
- package/docs/examples/money-transfer.ts +73 -0
- package/docs/llms-full.txt +309 -1
- package/package.json +1 -2
- package/template/package.json +1 -1
- package/dist/chunk-AAT5G7KY.js.map +0 -1
- package/dist/chunk-C6COAB3E.js.map +0 -1
- package/dist/chunk-KATPXCJ5.js.map +0 -1
- package/dist/chunk-SI4KGEM3.js.map +0 -1
- package/dist/chunk-TVCCR6SO.js.map +0 -1
- package/dist/chunk-WWUG2QXF.js.map +0 -1
- package/dist/chunk-XOX6RFPZ.js.map +0 -1
- package/dist/chunk-YIQ4RS4F.js.map +0 -1
- package/stack-images.json +0 -24
package/dist/db/index.d.cts
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { P as PreparedRead, c3 as QueryDatabase, U as EnvQueryDatabase, C as CompiledRead, F as ColumnMap, ck as TableHandle, cS as WhereFilter, dx as ColValue, a2 as FindManyOpts } from '../endpoint-kYgEHrrV.cjs';
|
|
2
|
+
export { q as AnyColumn, r as AtomicDatabase, s as AtomicOptions, y as ColumnBuilder, z as ColumnDef, G as ColumnType, i as CommandOptions, D as DatabaseBudget, d as DatabaseDiagnostics, c as DatabaseDiagnosticsOptions, K as DatabaseQueryEvent, L as DatabaseWorkload, O as EXTENSION_DEPENDENCIES, Q as EmbeddingModelRef, E as EnvServiceDatabase, X as EnvTypedDatabase, a8 as InsertManyOptions, a9 as InsertShape, ae as Materialized, al as OnDeleteAction, an as PALBASE_EXTENSIONS, g as Page, ap as PageInfo, aq as PageInput, ar as PageNavigation, a_ as PalbaseExtension, bX as PolicyBuilder, bY as PolicyCommand, bZ as PolicyDef, c0 as PolicyMode, c2 as QueryColumnContract, c5 as RawConstraintDef, f as RawPageOptions, c7 as Ref, c9 as RowShape, S as SchemaDef, ci as TABLE_META, cj as TableDef, cl as TableInput, T as TransactionIsolation, cn as TxColumnExpr, co as TxInsertShape, cq as TxNow, cr as TxPlan, h as TxPlanBody, cs as TxPlanError, ct as TxPlanHandle, cu as TxPlanOpResult, cv as TxPlanRejection, j as TxPlanResponse, cw as TxRefError, cx as TxRow, cy as TxRows, cz as TxSelectOptions, cA as TxSetShape, cC as TxTable, cD as TxTables, cE as TxWhere, cK as TypedDB, cL as TypedTable, cM as TypedTx, cP as UniqueWhere, cU as WorkloadOptions, cZ as bigint, c_ as boolean, d0 as dec, d3 as defineSchema, d4 as defineTable, d5 as defineWorkload, d6 as enumType, d8 as inc, db as installationRef, dc as integer, dd as isPalbaseExtension, df as jsonb, dg as makeTypedDB, dh as now, dl as openai, dm as ownedByUser, dn as policy, dp as raw, dr as text, ds as timestamp, dt as userRef, du as uuid, dv as vector } from '../endpoint-kYgEHrrV.cjs';
|
|
3
|
+
import { z } from 'zod';
|
|
3
4
|
import '../stack.cjs';
|
|
4
|
-
import '
|
|
5
|
+
import './env.cjs';
|
|
5
6
|
import 'node:async_hooks';
|
|
7
|
+
|
|
8
|
+
type QueryRow<C extends ColumnMap> = {
|
|
9
|
+
[K in keyof C]: ColValue<C[K]>;
|
|
10
|
+
};
|
|
11
|
+
type Database = QueryDatabase | EnvQueryDatabase;
|
|
12
|
+
/** The query IS its response Zod schema, so the existing return-type binder,
|
|
13
|
+
* OpenAPI generator and clients use the same declaration without a second DTO. */
|
|
14
|
+
type QueryDefinition<Row, Input extends z.ZodTypeAny> = z.ZodArray<z.ZodType<Row>> & {
|
|
15
|
+
readonly queryName: string;
|
|
16
|
+
readonly input: Input;
|
|
17
|
+
prepare(input: z.input<Input>): PreparedRead;
|
|
18
|
+
run(database: Database, input: z.input<Input>): Promise<Row[]>;
|
|
19
|
+
sql(database: Database, input: z.input<Input>): CompiledRead;
|
|
20
|
+
/** Plain EXPLAIN only: never ANALYZE, and always under the caller's RLS identity. */
|
|
21
|
+
explain(database: Database, input: z.input<Input>): Promise<unknown[]>;
|
|
22
|
+
contract(): Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
/** Declare a reusable SELECT with an explicit response projection. */
|
|
25
|
+
declare function defineQuery<C extends ColumnMap, const K extends readonly Extract<keyof C, string>[], Input extends z.ZodTypeAny>(name: string, options: {
|
|
26
|
+
table: TableHandle<C>;
|
|
27
|
+
input: Input;
|
|
28
|
+
select: K;
|
|
29
|
+
where?: (input: z.output<Input>) => WhereFilter<QueryRow<NoInfer<C>>>;
|
|
30
|
+
orderBy?: FindManyOpts<QueryRow<NoInfer<C>>>["orderBy"];
|
|
31
|
+
limit?: number | ((input: z.output<Input>) => number);
|
|
32
|
+
/** Required for jsonb; can also explicitly narrow another response field. */
|
|
33
|
+
fields?: {
|
|
34
|
+
[P in K[number]]?: z.ZodType<QueryRow<NoInfer<C>>[P]>;
|
|
35
|
+
};
|
|
36
|
+
}): QueryDefinition<Pick<QueryRow<C>, K[number]>, Input>;
|
|
37
|
+
declare function queryManifest(queries: readonly {
|
|
38
|
+
queryName: string;
|
|
39
|
+
contract(): Record<string, unknown>;
|
|
40
|
+
}[]): Record<string, unknown>;
|
|
41
|
+
/** Commit the manifest; CI compares the generated value before accepting a
|
|
42
|
+
* changed response. A reviewed baseline update is explicit, never automatic. */
|
|
43
|
+
declare function assertQueryManifest(queries: readonly {
|
|
44
|
+
queryName: string;
|
|
45
|
+
contract(): Record<string, unknown>;
|
|
46
|
+
}[], baseline: unknown): void;
|
|
47
|
+
|
|
48
|
+
export { ColumnMap, CompiledRead, EnvQueryDatabase, PreparedRead, QueryDatabase, type QueryDefinition, TableHandle, assertQueryManifest, defineQuery, queryManifest };
|
package/dist/db/index.d.ts
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { P as PreparedRead, c3 as QueryDatabase, U as EnvQueryDatabase, C as CompiledRead, F as ColumnMap, ck as TableHandle, cS as WhereFilter, dx as ColValue, a2 as FindManyOpts } from '../endpoint-DpNUx-ON.js';
|
|
2
|
+
export { q as AnyColumn, r as AtomicDatabase, s as AtomicOptions, y as ColumnBuilder, z as ColumnDef, G as ColumnType, i as CommandOptions, D as DatabaseBudget, d as DatabaseDiagnostics, c as DatabaseDiagnosticsOptions, K as DatabaseQueryEvent, L as DatabaseWorkload, O as EXTENSION_DEPENDENCIES, Q as EmbeddingModelRef, E as EnvServiceDatabase, X as EnvTypedDatabase, a8 as InsertManyOptions, a9 as InsertShape, ae as Materialized, al as OnDeleteAction, an as PALBASE_EXTENSIONS, g as Page, ap as PageInfo, aq as PageInput, ar as PageNavigation, a_ as PalbaseExtension, bX as PolicyBuilder, bY as PolicyCommand, bZ as PolicyDef, c0 as PolicyMode, c2 as QueryColumnContract, c5 as RawConstraintDef, f as RawPageOptions, c7 as Ref, c9 as RowShape, S as SchemaDef, ci as TABLE_META, cj as TableDef, cl as TableInput, T as TransactionIsolation, cn as TxColumnExpr, co as TxInsertShape, cq as TxNow, cr as TxPlan, h as TxPlanBody, cs as TxPlanError, ct as TxPlanHandle, cu as TxPlanOpResult, cv as TxPlanRejection, j as TxPlanResponse, cw as TxRefError, cx as TxRow, cy as TxRows, cz as TxSelectOptions, cA as TxSetShape, cC as TxTable, cD as TxTables, cE as TxWhere, cK as TypedDB, cL as TypedTable, cM as TypedTx, cP as UniqueWhere, cU as WorkloadOptions, cZ as bigint, c_ as boolean, d0 as dec, d3 as defineSchema, d4 as defineTable, d5 as defineWorkload, d6 as enumType, d8 as inc, db as installationRef, dc as integer, dd as isPalbaseExtension, df as jsonb, dg as makeTypedDB, dh as now, dl as openai, dm as ownedByUser, dn as policy, dp as raw, dr as text, ds as timestamp, dt as userRef, du as uuid, dv as vector } from '../endpoint-DpNUx-ON.js';
|
|
3
|
+
import { z } from 'zod';
|
|
3
4
|
import '../stack.js';
|
|
4
|
-
import '
|
|
5
|
+
import './env.js';
|
|
5
6
|
import 'node:async_hooks';
|
|
7
|
+
|
|
8
|
+
type QueryRow<C extends ColumnMap> = {
|
|
9
|
+
[K in keyof C]: ColValue<C[K]>;
|
|
10
|
+
};
|
|
11
|
+
type Database = QueryDatabase | EnvQueryDatabase;
|
|
12
|
+
/** The query IS its response Zod schema, so the existing return-type binder,
|
|
13
|
+
* OpenAPI generator and clients use the same declaration without a second DTO. */
|
|
14
|
+
type QueryDefinition<Row, Input extends z.ZodTypeAny> = z.ZodArray<z.ZodType<Row>> & {
|
|
15
|
+
readonly queryName: string;
|
|
16
|
+
readonly input: Input;
|
|
17
|
+
prepare(input: z.input<Input>): PreparedRead;
|
|
18
|
+
run(database: Database, input: z.input<Input>): Promise<Row[]>;
|
|
19
|
+
sql(database: Database, input: z.input<Input>): CompiledRead;
|
|
20
|
+
/** Plain EXPLAIN only: never ANALYZE, and always under the caller's RLS identity. */
|
|
21
|
+
explain(database: Database, input: z.input<Input>): Promise<unknown[]>;
|
|
22
|
+
contract(): Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
/** Declare a reusable SELECT with an explicit response projection. */
|
|
25
|
+
declare function defineQuery<C extends ColumnMap, const K extends readonly Extract<keyof C, string>[], Input extends z.ZodTypeAny>(name: string, options: {
|
|
26
|
+
table: TableHandle<C>;
|
|
27
|
+
input: Input;
|
|
28
|
+
select: K;
|
|
29
|
+
where?: (input: z.output<Input>) => WhereFilter<QueryRow<NoInfer<C>>>;
|
|
30
|
+
orderBy?: FindManyOpts<QueryRow<NoInfer<C>>>["orderBy"];
|
|
31
|
+
limit?: number | ((input: z.output<Input>) => number);
|
|
32
|
+
/** Required for jsonb; can also explicitly narrow another response field. */
|
|
33
|
+
fields?: {
|
|
34
|
+
[P in K[number]]?: z.ZodType<QueryRow<NoInfer<C>>[P]>;
|
|
35
|
+
};
|
|
36
|
+
}): QueryDefinition<Pick<QueryRow<C>, K[number]>, Input>;
|
|
37
|
+
declare function queryManifest(queries: readonly {
|
|
38
|
+
queryName: string;
|
|
39
|
+
contract(): Record<string, unknown>;
|
|
40
|
+
}[]): Record<string, unknown>;
|
|
41
|
+
/** Commit the manifest; CI compares the generated value before accepting a
|
|
42
|
+
* changed response. A reviewed baseline update is explicit, never automatic. */
|
|
43
|
+
declare function assertQueryManifest(queries: readonly {
|
|
44
|
+
queryName: string;
|
|
45
|
+
contract(): Record<string, unknown>;
|
|
46
|
+
}[], baseline: unknown): void;
|
|
47
|
+
|
|
48
|
+
export { ColumnMap, CompiledRead, EnvQueryDatabase, PreparedRead, QueryDatabase, type QueryDefinition, TableHandle, assertQueryManifest, defineQuery, queryManifest };
|
package/dist/db/index.js
CHANGED
|
@@ -3,13 +3,17 @@ import {
|
|
|
3
3
|
PALBASE_EXTENSIONS,
|
|
4
4
|
PolicyBuilder,
|
|
5
5
|
TABLE_META,
|
|
6
|
+
assertQueryManifest,
|
|
7
|
+
defineQuery,
|
|
6
8
|
defineSchema,
|
|
7
9
|
defineTable,
|
|
8
10
|
isPalbaseExtension,
|
|
11
|
+
makeTypedDB,
|
|
9
12
|
openai,
|
|
10
13
|
policy,
|
|
14
|
+
queryManifest,
|
|
11
15
|
raw
|
|
12
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-SEM36BWY.js";
|
|
13
17
|
import {
|
|
14
18
|
bigint,
|
|
15
19
|
boolean,
|
|
@@ -23,16 +27,17 @@ import {
|
|
|
23
27
|
userRef,
|
|
24
28
|
uuid,
|
|
25
29
|
vector
|
|
26
|
-
} from "../chunk-
|
|
30
|
+
} from "../chunk-PRH45NZU.js";
|
|
27
31
|
import {
|
|
28
32
|
TxPlanError,
|
|
29
33
|
TxRefError,
|
|
30
34
|
dec,
|
|
35
|
+
defineWorkload,
|
|
31
36
|
inc,
|
|
32
|
-
makeTypedDB,
|
|
33
37
|
now
|
|
34
|
-
} from "../chunk-
|
|
35
|
-
import "../chunk-
|
|
38
|
+
} from "../chunk-FOWA7PF4.js";
|
|
39
|
+
import "../chunk-UMESJJRS.js";
|
|
40
|
+
import "../chunk-VXPNPVAG.js";
|
|
36
41
|
export {
|
|
37
42
|
EXTENSION_DEPENDENCIES,
|
|
38
43
|
PALBASE_EXTENSIONS,
|
|
@@ -40,11 +45,14 @@ export {
|
|
|
40
45
|
TABLE_META,
|
|
41
46
|
TxPlanError,
|
|
42
47
|
TxRefError,
|
|
48
|
+
assertQueryManifest,
|
|
43
49
|
bigint,
|
|
44
50
|
boolean,
|
|
45
51
|
dec,
|
|
52
|
+
defineQuery,
|
|
46
53
|
defineSchema,
|
|
47
54
|
defineTable,
|
|
55
|
+
defineWorkload,
|
|
48
56
|
enumType,
|
|
49
57
|
inc,
|
|
50
58
|
installationRef,
|
|
@@ -56,6 +64,7 @@ export {
|
|
|
56
64
|
openai,
|
|
57
65
|
ownedByUser,
|
|
58
66
|
policy,
|
|
67
|
+
queryManifest,
|
|
59
68
|
raw,
|
|
60
69
|
text,
|
|
61
70
|
timestamp,
|