@palbase/backend 25.0.1 → 25.0.3
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 +7 -7
- package/dist/bin/palbase-backend.cjs.map +1 -1
- package/dist/bin/palbase-backend.js +1 -1
- package/dist/{chunk-HBOJLP2Z.js → chunk-7JSEN7UR.js} +2 -1
- package/dist/chunk-7JSEN7UR.js.map +1 -0
- package/dist/{chunk-34I4GB7D.js → chunk-WH2EV2LT.js} +8 -8
- package/dist/{chunk-34I4GB7D.js.map → chunk-WH2EV2LT.js.map} +1 -1
- 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 +1 -1
- package/dist/{endpoint-DMwJjEHQ.d.ts → endpoint-CTEHhb7A.d.ts} +19 -8
- package/dist/{endpoint-BSGw1pTu.d.cts → endpoint-DYHMo6cC.d.cts} +19 -8
- package/dist/engine/index.cjs +7 -7
- package/dist/engine/index.cjs.map +1 -1
- package/dist/engine/index.d.cts +4 -4
- package/dist/engine/index.d.ts +4 -4
- package/dist/engine/index.js +1 -1
- package/dist/{index-B8v6hVyU.d.ts → index-CUomTA3e.d.ts} +3 -3
- package/dist/{index-B4CcpqLb.d.ts → index-CW21M9Z3.d.ts} +1 -1
- package/dist/{index-VsjBQ4Kw.d.cts → index-ClpDeSos.d.cts} +3 -3
- package/dist/{index-DmVyY6N7.d.cts → index-CmBK76nx.d.cts} +1 -1
- package/dist/index.cjs +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +5 -3
- 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-CgJvDYUW.d.cts → registry-CC0WBQq6.d.cts} +1 -1
- package/dist/{registry-B8pld3fj.d.ts → registry-dZZ5JKYg.d.ts} +1 -1
- package/dist/test/index.d.cts +1 -1
- package/dist/test/index.d.ts +1 -1
- package/docs/README.md +29 -28
- package/docs/database.md +2 -2
- package/docs/endpoints.md +6 -5
- package/docs/getting-started.md +1 -1
- package/docs/llms-full.txt +58 -53
- package/docs/migrations.md +16 -14
- package/docs/schema.md +2 -2
- package/docs/services.md +2 -1
- package/package.json +1 -1
- package/dist/chunk-HBOJLP2Z.js.map +0 -1
package/dist/db/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as AnyColumn, C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EmbeddingModelRef, g as EnvServiceDatabase, E as EnvTypedDatabase, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, j as PalbaseExtension, k as PolicyBuilder, l as PolicyCommand, m as PolicyDef, n as PolicyMode, R as RawConstraintDef, o as RowShape, S as SchemaDef, T as TABLE_META, p as TableDef, q as TableHandle, r as TableInput, s as TxPlan, t as TxTables, u as TypedDB, v as TypedTable, w as TypedTx, x as bigint, y as boolean, z as defineSchema, B as defineTable, D as enumType, F as installationRef, G as integer, H as isPalbaseExtension, J as jsonb, K as makeTypedDB, M as openai, N as ownedByUser, Q as policy, U as raw, V as text, W as timestamp, X as userRef, Y as uuid, Z as vector } from '../index-
|
|
2
|
-
export { M as Materialized, b1 as Ref, b3 as TxColumnExpr, b4 as TxInsertShape, b6 as TxNow, T as TxPlanBody, b7 as TxPlanError, b8 as TxPlanHandle, b9 as TxPlanOpResult, ba as TxPlanRejection, g as TxPlanResponse, bb as TxRefError, bc as TxRow, bd as TxRows, be as TxSelectOptions, bf as TxSetShape, bh as TxTable, bi as TxWhere, bs as dec, bu as inc, bv as now } from '../endpoint-
|
|
1
|
+
export { A as AnyColumn, C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EmbeddingModelRef, g as EnvServiceDatabase, E as EnvTypedDatabase, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, j as PalbaseExtension, k as PolicyBuilder, l as PolicyCommand, m as PolicyDef, n as PolicyMode, R as RawConstraintDef, o as RowShape, S as SchemaDef, T as TABLE_META, p as TableDef, q as TableHandle, r as TableInput, s as TxPlan, t as TxTables, u as TypedDB, v as TypedTable, w as TypedTx, x as bigint, y as boolean, z as defineSchema, B as defineTable, D as enumType, F as installationRef, G as integer, H as isPalbaseExtension, J as jsonb, K as makeTypedDB, M as openai, N as ownedByUser, Q as policy, U as raw, V as text, W as timestamp, X as userRef, Y as uuid, Z as vector } from '../index-CmBK76nx.cjs';
|
|
2
|
+
export { M as Materialized, b1 as Ref, b3 as TxColumnExpr, b4 as TxInsertShape, b6 as TxNow, T as TxPlanBody, b7 as TxPlanError, b8 as TxPlanHandle, b9 as TxPlanOpResult, ba as TxPlanRejection, g as TxPlanResponse, bb as TxRefError, bc as TxRow, bd as TxRows, be as TxSelectOptions, bf as TxSetShape, bh as TxTable, bi as TxWhere, bs as dec, bu as inc, bv as now } from '../endpoint-DYHMo6cC.cjs';
|
|
3
3
|
import './env.cjs';
|
|
4
4
|
import '../stack.cjs';
|
|
5
5
|
import 'zod';
|
package/dist/db/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as AnyColumn, C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EmbeddingModelRef, g as EnvServiceDatabase, E as EnvTypedDatabase, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, j as PalbaseExtension, k as PolicyBuilder, l as PolicyCommand, m as PolicyDef, n as PolicyMode, R as RawConstraintDef, o as RowShape, S as SchemaDef, T as TABLE_META, p as TableDef, q as TableHandle, r as TableInput, s as TxPlan, t as TxTables, u as TypedDB, v as TypedTable, w as TypedTx, x as bigint, y as boolean, z as defineSchema, B as defineTable, D as enumType, F as installationRef, G as integer, H as isPalbaseExtension, J as jsonb, K as makeTypedDB, M as openai, N as ownedByUser, Q as policy, U as raw, V as text, W as timestamp, X as userRef, Y as uuid, Z as vector } from '../index-
|
|
2
|
-
export { M as Materialized, b1 as Ref, b3 as TxColumnExpr, b4 as TxInsertShape, b6 as TxNow, T as TxPlanBody, b7 as TxPlanError, b8 as TxPlanHandle, b9 as TxPlanOpResult, ba as TxPlanRejection, g as TxPlanResponse, bb as TxRefError, bc as TxRow, bd as TxRows, be as TxSelectOptions, bf as TxSetShape, bh as TxTable, bi as TxWhere, bs as dec, bu as inc, bv as now } from '../endpoint-
|
|
1
|
+
export { A as AnyColumn, C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EmbeddingModelRef, g as EnvServiceDatabase, E as EnvTypedDatabase, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, j as PalbaseExtension, k as PolicyBuilder, l as PolicyCommand, m as PolicyDef, n as PolicyMode, R as RawConstraintDef, o as RowShape, S as SchemaDef, T as TABLE_META, p as TableDef, q as TableHandle, r as TableInput, s as TxPlan, t as TxTables, u as TypedDB, v as TypedTable, w as TypedTx, x as bigint, y as boolean, z as defineSchema, B as defineTable, D as enumType, F as installationRef, G as integer, H as isPalbaseExtension, J as jsonb, K as makeTypedDB, M as openai, N as ownedByUser, Q as policy, U as raw, V as text, W as timestamp, X as userRef, Y as uuid, Z as vector } from '../index-CW21M9Z3.js';
|
|
2
|
+
export { M as Materialized, b1 as Ref, b3 as TxColumnExpr, b4 as TxInsertShape, b6 as TxNow, T as TxPlanBody, b7 as TxPlanError, b8 as TxPlanHandle, b9 as TxPlanOpResult, ba as TxPlanRejection, g as TxPlanResponse, bb as TxRefError, bc as TxRow, bd as TxRows, be as TxSelectOptions, bf as TxSetShape, bh as TxTable, bi as TxWhere, bs as dec, bu as inc, bv as now } from '../endpoint-CTEHhb7A.js';
|
|
3
3
|
import './env.js';
|
|
4
4
|
import '../stack.js';
|
|
5
5
|
import 'zod';
|
package/dist/db/index.js
CHANGED
|
@@ -77,17 +77,28 @@ interface MiddlewareContext extends PalbaseModuleClients {
|
|
|
77
77
|
/** Middleware function signature — receives context and next function. */
|
|
78
78
|
type MiddlewareHandler = (ctx: MiddlewareContext, next: () => Promise<void>) => Promise<void>;
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
81
|
-
* as endpoint-specific middleware.
|
|
80
|
+
* REMOVED IN BEHAVIOUR, KEPT IN NAME.
|
|
82
81
|
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
82
|
+
* There is no middleware pipeline in this runtime. No bundler reads a
|
|
83
|
+
* `middleware/` directory, the engine never calls a handler defined here, and
|
|
84
|
+
* measured on 2026-08-31 this function had no caller anywhere in the runtime or
|
|
85
|
+
* the CLI. It returned its argument unchanged, so code written against it
|
|
86
|
+
* compiled, deployed, and then never ran — with nothing reporting that.
|
|
86
87
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
88
|
+
* A silent shell is the worst version of a retired feature: it lets a user (or a
|
|
89
|
+
* coding assistant, which is how this surfaced) ship a request logger, an auth
|
|
90
|
+
* check or a rate limiter that simply does not exist in production. So the call
|
|
91
|
+
* refuses, and says where the work belongs.
|
|
92
|
+
*
|
|
93
|
+
* The SYMBOL survives because removing a published export costs a major and
|
|
94
|
+
* 25.0.1 had just shipped. Deleting it is a proposal for the next one; the types
|
|
95
|
+
* below stay either way, so a file that only annotates with them still compiles.
|
|
96
|
+
*
|
|
97
|
+
* This is the shape the SDK already uses for a retired surface: `@Query(schema)`
|
|
98
|
+
* on a parameter throws at decoration time with a message naming its
|
|
99
|
+
* replacement.
|
|
89
100
|
*/
|
|
90
|
-
declare function defineMiddleware(
|
|
101
|
+
declare function defineMiddleware(_fn: MiddlewareHandler): never;
|
|
91
102
|
|
|
92
103
|
/**
|
|
93
104
|
* tx-plan.ts — `Database.transaction()` as a PLAN, not a pinned session.
|
|
@@ -77,17 +77,28 @@ interface MiddlewareContext extends PalbaseModuleClients {
|
|
|
77
77
|
/** Middleware function signature — receives context and next function. */
|
|
78
78
|
type MiddlewareHandler = (ctx: MiddlewareContext, next: () => Promise<void>) => Promise<void>;
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
81
|
-
* as endpoint-specific middleware.
|
|
80
|
+
* REMOVED IN BEHAVIOUR, KEPT IN NAME.
|
|
82
81
|
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
82
|
+
* There is no middleware pipeline in this runtime. No bundler reads a
|
|
83
|
+
* `middleware/` directory, the engine never calls a handler defined here, and
|
|
84
|
+
* measured on 2026-08-31 this function had no caller anywhere in the runtime or
|
|
85
|
+
* the CLI. It returned its argument unchanged, so code written against it
|
|
86
|
+
* compiled, deployed, and then never ran — with nothing reporting that.
|
|
86
87
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
88
|
+
* A silent shell is the worst version of a retired feature: it lets a user (or a
|
|
89
|
+
* coding assistant, which is how this surfaced) ship a request logger, an auth
|
|
90
|
+
* check or a rate limiter that simply does not exist in production. So the call
|
|
91
|
+
* refuses, and says where the work belongs.
|
|
92
|
+
*
|
|
93
|
+
* The SYMBOL survives because removing a published export costs a major and
|
|
94
|
+
* 25.0.1 had just shipped. Deleting it is a proposal for the next one; the types
|
|
95
|
+
* below stay either way, so a file that only annotates with them still compiles.
|
|
96
|
+
*
|
|
97
|
+
* This is the shape the SDK already uses for a retired surface: `@Query(schema)`
|
|
98
|
+
* on a parameter throws at decoration time with a message naming its
|
|
99
|
+
* replacement.
|
|
89
100
|
*/
|
|
90
|
-
declare function defineMiddleware(
|
|
101
|
+
declare function defineMiddleware(_fn: MiddlewareHandler): never;
|
|
91
102
|
|
|
92
103
|
/**
|
|
93
104
|
* tx-plan.ts — `Database.transaction()` as a PLAN, not a pinned session.
|
package/dist/engine/index.cjs
CHANGED
|
@@ -1892,7 +1892,7 @@ function createOps(tx) {
|
|
|
1892
1892
|
let exactOrderC = "";
|
|
1893
1893
|
if (userWhereC !== "") {
|
|
1894
1894
|
const probeRows = await liveC.unsafe(
|
|
1895
|
-
`SELECT count(*)::int AS n FROM (SELECT 1 FROM ${
|
|
1895
|
+
`SELECT count(*)::int AS n FROM (SELECT 1 FROM ${quoteTable(ck.table)} c${parentJoinC}c.embedding IS NOT NULL LIMIT ${SELECTIVITY_EXACT_THRESHOLD + 1}) s`,
|
|
1896
1896
|
bindC.slice()
|
|
1897
1897
|
);
|
|
1898
1898
|
const n = probeRows?.[0]?.n;
|
|
@@ -1901,7 +1901,7 @@ function createOps(tx) {
|
|
|
1901
1901
|
}
|
|
1902
1902
|
}
|
|
1903
1903
|
const vp = addC(toVectorLiteral(qvC));
|
|
1904
|
-
semC = `SELECT c.${pidQ} AS pid, c.chunk_seq, ROW_NUMBER() OVER (ORDER BY (c.embedding OPERATOR(${quoteIdent(sch)}.${op}) ${vp}::${quoteIdent(sch)}.vector)${exactOrderC}) AS r FROM ${
|
|
1904
|
+
semC = `SELECT c.${pidQ} AS pid, c.chunk_seq, ROW_NUMBER() OVER (ORDER BY (c.embedding OPERATOR(${quoteIdent(sch)}.${op}) ${vp}::${quoteIdent(sch)}.vector)${exactOrderC}) AS r FROM ${quoteTable(ck.table)} c${parentJoinC}c.embedding IS NOT NULL ORDER BY r LIMIT ${cpool}`;
|
|
1905
1905
|
}
|
|
1906
1906
|
let qpC = "";
|
|
1907
1907
|
let qpCIdx = -1;
|
|
@@ -1909,7 +1909,7 @@ function createOps(tx) {
|
|
|
1909
1909
|
const qTextC = cfg.synonyms !== void 0 ? expandSynonyms(params.query, cfg.synonyms) : params.query;
|
|
1910
1910
|
qpC = addC(qTextC);
|
|
1911
1911
|
qpCIdx = bindC.length - 1;
|
|
1912
|
-
kwC = `SELECT c.${pidQ} AS pid, c.chunk_seq, ROW_NUMBER() OVER (ORDER BY ts_rank_cd(c.palbase_fts, websearch_to_tsquery('simple', ${qpC})) DESC) AS r FROM ${
|
|
1912
|
+
kwC = `SELECT c.${pidQ} AS pid, c.chunk_seq, ROW_NUMBER() OVER (ORDER BY ts_rank_cd(c.palbase_fts, websearch_to_tsquery('simple', ${qpC})) DESC) AS r FROM ${quoteTable(ck.table)} c${parentJoinC}c.palbase_fts @@ websearch_to_tsquery('simple', ${qpC}) ORDER BY r LIMIT ${cpool}`;
|
|
1913
1913
|
}
|
|
1914
1914
|
const msC = params.minScore === void 0 ? "" : addC(params.minScore);
|
|
1915
1915
|
const colListC = cfg.cols.map((c) => `t.${quoteIdent(c)}`).join(", ");
|
|
@@ -1924,13 +1924,13 @@ function createOps(tx) {
|
|
|
1924
1924
|
} else {
|
|
1925
1925
|
fusedSrc = `WITH kw AS (${kwIn}), fused AS (SELECT kw.pid, kw.chunk_seq, (1.0/(${K2} + kw.r))::float8 AS cscore FROM kw)`;
|
|
1926
1926
|
}
|
|
1927
|
-
const inner = `${fusedSrc}, ranked AS (SELECT f.pid, f.chunk_seq, f.cscore, ROW_NUMBER() OVER (PARTITION BY f.pid ORDER BY f.cscore DESC, f.chunk_seq) AS rn FROM fused f), grouped AS (SELECT r.pid, MAX(r.cscore) AS _score, json_agg(json_build_object('content', c.content, 'score', r.cscore, 'chunkSeq', r.chunk_seq, 'charStart', c.char_start) ORDER BY r.cscore DESC, r.chunk_seq) FILTER (WHERE r.rn <= ${bpr}) AS blocks FROM ranked r JOIN ${
|
|
1927
|
+
const inner = `${fusedSrc}, ranked AS (SELECT f.pid, f.chunk_seq, f.cscore, ROW_NUMBER() OVER (PARTITION BY f.pid ORDER BY f.cscore DESC, f.chunk_seq) AS rn FROM fused f), grouped AS (SELECT r.pid, MAX(r.cscore) AS _score, json_agg(json_build_object('content', c.content, 'score', r.cscore, 'chunkSeq', r.chunk_seq, 'charStart', c.char_start) ORDER BY r.cscore DESC, r.chunk_seq) FILTER (WHERE r.rn <= ${bpr}) AS blocks FROM ranked r JOIN ${quoteTable(ck.table)} c ON c.${pidQ} = r.pid AND c.chunk_seq = r.chunk_seq GROUP BY r.pid) SELECT ${colListC}, ${scoreC}::float8 AS _score, g.blocks AS blocks${kwnCol} FROM grouped g JOIN ${quoteTable(table)} t ON t.${quoteIdent(cfg.pk)} = g.pid`;
|
|
1928
1928
|
return msC === "" ? `SELECT * FROM (${inner}) q ORDER BY q._score DESC, q.${quoteIdent(cfg.pk)} LIMIT ${limit}` : `SELECT * FROM (${inner}) q WHERE q._score >= ${msC} ORDER BY q._score DESC, q.${quoteIdent(cfg.pk)} LIMIT ${limit}`;
|
|
1929
1929
|
};
|
|
1930
1930
|
let rowsC = await liveC.unsafe(assembleC(kwC, kwC !== ""), bindC);
|
|
1931
1931
|
if (wantTextC && kwC !== "" && (rowsC.length === 0 || rowsC[0]._kwn === 0)) {
|
|
1932
1932
|
const tsch = await trgmSchemaOf(liveC);
|
|
1933
|
-
const trgmKwC = `SELECT c.${pidQ} AS pid, c.chunk_seq, ROW_NUMBER() OVER (ORDER BY ${quoteIdent(tsch)}.word_similarity(${qpC}, coalesce(c.content,'')) DESC) AS r FROM ${
|
|
1933
|
+
const trgmKwC = `SELECT c.${pidQ} AS pid, c.chunk_seq, ROW_NUMBER() OVER (ORDER BY ${quoteIdent(tsch)}.word_similarity(${qpC}, coalesce(c.content,'')) DESC) AS r FROM ${quoteTable(ck.table)} c${parentJoinC}${quoteIdent(tsch)}.word_similarity(${qpC}, coalesce(c.content,'')) > 0.3 ORDER BY r LIMIT ${cpool}`;
|
|
1934
1934
|
const retryBindC = bindC.slice();
|
|
1935
1935
|
if (qpCIdx >= 0) retryBindC[qpCIdx] = params.query;
|
|
1936
1936
|
rowsC = await liveC.unsafe(assembleC(trgmKwC, false), retryBindC);
|
|
@@ -2078,7 +2078,7 @@ function createOps(tx) {
|
|
|
2078
2078
|
if (cfg.chunk !== void 0) {
|
|
2079
2079
|
const sch = await vectorSchemaWithGuc(live);
|
|
2080
2080
|
const rows = await live.unsafe(
|
|
2081
|
-
`SELECT ${quoteIdent(sch)}.avg(c.embedding) AS v FROM ${
|
|
2081
|
+
`SELECT ${quoteIdent(sch)}.avg(c.embedding) AS v FROM ${quoteTable(cfg.chunk.table)} c WHERE c.${quoteIdent(`parent_${cfg.pk}`)} = $1 AND c.embedding IS NOT NULL`,
|
|
2082
2082
|
[id]
|
|
2083
2083
|
);
|
|
2084
2084
|
v = rows?.[0]?.v;
|
|
@@ -2145,7 +2145,7 @@ function createOps(tx) {
|
|
|
2145
2145
|
};
|
|
2146
2146
|
const avgSel = (ids) => {
|
|
2147
2147
|
const inList = ids.map((x) => add(x)).join(", ");
|
|
2148
|
-
return cfg.chunk !== void 0 ? `SELECT ${quoteIdent(sch)}.avg(c.embedding) AS v FROM ${
|
|
2148
|
+
return cfg.chunk !== void 0 ? `SELECT ${quoteIdent(sch)}.avg(c.embedding) AS v FROM ${quoteTable(cfg.chunk.table)} c WHERE c.${quoteIdent(`parent_${cfg.pk}`)} IN (${inList}) AND c.embedding IS NOT NULL` : `SELECT ${quoteIdent(sch)}.avg(t.${quoteIdent(leg.column)}) AS v FROM ${quoteTable(table)} t WHERE t.${quoteIdent(cfg.pk)} IN (${inList}) AND t.${quoteIdent(leg.column)} IS NOT NULL`;
|
|
2149
2149
|
};
|
|
2150
2150
|
const targetSql = negative.length === 0 ? `WITH pos AS (${avgSel(positive)}) SELECT pos.v AS v, (pos.v IS NULL) AS pos_missing FROM pos` : `WITH pos AS (${avgSel(positive)}), neg AS (${avgSel(negative)}) SELECT (pos.v OPERATOR(${quoteIdent(sch)}.+) (pos.v OPERATOR(${quoteIdent(sch)}.-) neg.v)) AS v, (pos.v IS NULL) AS pos_missing, (neg.v IS NULL) AS neg_missing FROM pos, neg`;
|
|
2151
2151
|
const rows = await live.unsafe(targetSql, bind);
|