@palbase/backend 38.0.15 → 39.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 +46 -1
- package/dist/bin/palbase-backend.cjs.map +1 -1
- package/dist/bin/palbase-backend.js +5 -5
- package/dist/{chunk-LFUNRWUE.js → chunk-4J6I4KVQ.js} +67 -3
- package/dist/{chunk-LFUNRWUE.js.map → chunk-4J6I4KVQ.js.map} +1 -1
- package/dist/{chunk-7WAGQ3VR.js → chunk-AR2I4M7I.js} +497 -17
- package/dist/chunk-AR2I4M7I.js.map +1 -0
- package/dist/{chunk-YANGWAIM.js → chunk-H7EKL6HC.js} +2 -2
- package/dist/{chunk-EHKEMHB4.js → chunk-JJSR4BUX.js} +49 -5
- package/dist/chunk-JJSR4BUX.js.map +1 -0
- package/dist/{chunk-CS6NQ6PO.js → chunk-JPTFYHP3.js} +2 -2
- package/dist/{chunk-CS6NQ6PO.js.map → chunk-JPTFYHP3.js.map} +1 -1
- package/dist/{chunk-X7UR3VXA.js → chunk-XZWOMPD3.js} +3 -2
- package/dist/chunk-XZWOMPD3.js.map +1 -0
- package/dist/{chunk-PDD55QWN.js → chunk-ZNQDL466.js} +2 -2
- package/dist/db/index.cjs +378 -14
- package/dist/db/index.cjs.map +1 -1
- package/dist/db/index.d.cts +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.js +3 -3
- package/dist/engine/index.cjs +46 -1
- 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 +5 -5
- package/dist/{index-CI7S0Wqv.d.cts → index-B0mjUnxy.d.cts} +25 -2
- package/dist/{index-CUy50OLU.d.ts → index-eN4KzGa5.d.ts} +555 -29
- package/dist/{index-DRx880KY.d.cts → index-pK2At5Yc.d.cts} +555 -29
- package/dist/{index-Ogi30dbt.d.ts → index-yDno9Ju9.d.ts} +25 -2
- package/dist/index.cjs +628 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +183 -8
- package/dist/index.d.ts +183 -8
- package/dist/index.js +74 -6
- package/dist/index.js.map +1 -1
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.d.cts +2 -2
- package/dist/openapi/index.d.ts +2 -2
- package/dist/openapi/index.js +2 -2
- package/dist/{registry-C7UCkQf0.d.cts → registry-9dNeVN5d.d.cts} +1 -1
- package/dist/{registry-DJcvbomD.d.ts → registry-B8ddZiMY.d.ts} +1 -1
- package/dist/test/index.cjs +19 -0
- 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 +20 -2
- package/dist/test/index.js.map +1 -1
- package/docs/README.md +1 -1
- package/docs/database.md +79 -0
- package/docs/llms-full.txt +462 -33
- package/docs/schema.md +382 -32
- package/package.json +1 -1
- package/template/package.json +1 -1
- package/dist/chunk-7WAGQ3VR.js.map +0 -1
- package/dist/chunk-EHKEMHB4.js.map +0 -1
- package/dist/chunk-X7UR3VXA.js.map +0 -1
- /package/dist/{chunk-YANGWAIM.js.map → chunk-H7EKL6HC.js.map} +0 -0
- /package/dist/{chunk-PDD55QWN.js.map → chunk-ZNQDL466.js.map} +0 -0
package/dist/db/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { o as AnyColumn, p as AtomicDatabase, q as AtomicOptions,
|
|
1
|
+
export { o as AnyColumn, p as AtomicDatabase, q as AtomicOptions, y as ColumnBuilder, z as ColumnDef, F as ColumnMap, G as ColumnType, C as CommandOptions, D as DatabaseBudget, d as DatabaseDiagnostics, c as DatabaseDiagnosticsOptions, K as DatabaseQueryEvent, N as EXTENSION_DEPENDENCIES, O as EmbeddingModelRef, E as EnvServiceDatabase, V as EnvTypedDatabase, af as InsertManyOptions, ag as InsertShape, al as Materialized, as as OnDeleteAction, au as PALBASE_EXTENSIONS, P as Page, aw as PageInfo, ax as PageInput, ay as PageNavigation, b5 as PalbaseExtension, c8 as PolicyBuilder, c9 as PolicyCommand, ca as PolicyDef, cd as PolicyMode, cg as RawConstraintDef, f as RawPageOptions, ci as Ref, ck as RowShape, S as SchemaDef, ct as TABLE_META, cu as TableDef, cv as TableHandle, cw as TableInput, T as TransactionIsolation, cz as TxColumnExpr, cA as TxInsertShape, cC as TxNow, cD as TxPlan, g as TxPlanBody, cE as TxPlanError, cF as TxPlanHandle, cG as TxPlanOpResult, cH as TxPlanRejection, h as TxPlanResponse, cI as TxRefError, cJ as TxRow, cK as TxRows, cL as TxSelectOptions, cM as TxSetShape, cO as TxTable, cP as TxTables, cQ as TxWhere, cW as TypedDB, cX as TypedTable, cY as TypedTx, c$ as UniqueWhere, d9 as bigint, da as boolean, de as dec, dh as defineSchema, di as defineTable, dj as enumType, dp as inc, ds as installationRef, dt as integer, du as isPalbaseExtension, dw as jsonb, dx as makeTypedDB, dy as now, dC as openai, dD as ownedByUser, dE as policy, dF as raw, dH as text, dI as timestamp, dJ as userRef, dK as uuid, dL as vector } from '../index-pK2At5Yc.cjs';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import './env.cjs';
|
|
4
4
|
import '../stack.cjs';
|
package/dist/db/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { o as AnyColumn, p as AtomicDatabase, q as AtomicOptions,
|
|
1
|
+
export { o as AnyColumn, p as AtomicDatabase, q as AtomicOptions, y as ColumnBuilder, z as ColumnDef, F as ColumnMap, G as ColumnType, C as CommandOptions, D as DatabaseBudget, d as DatabaseDiagnostics, c as DatabaseDiagnosticsOptions, K as DatabaseQueryEvent, N as EXTENSION_DEPENDENCIES, O as EmbeddingModelRef, E as EnvServiceDatabase, V as EnvTypedDatabase, af as InsertManyOptions, ag as InsertShape, al as Materialized, as as OnDeleteAction, au as PALBASE_EXTENSIONS, P as Page, aw as PageInfo, ax as PageInput, ay as PageNavigation, b5 as PalbaseExtension, c8 as PolicyBuilder, c9 as PolicyCommand, ca as PolicyDef, cd as PolicyMode, cg as RawConstraintDef, f as RawPageOptions, ci as Ref, ck as RowShape, S as SchemaDef, ct as TABLE_META, cu as TableDef, cv as TableHandle, cw as TableInput, T as TransactionIsolation, cz as TxColumnExpr, cA as TxInsertShape, cC as TxNow, cD as TxPlan, g as TxPlanBody, cE as TxPlanError, cF as TxPlanHandle, cG as TxPlanOpResult, cH as TxPlanRejection, h as TxPlanResponse, cI as TxRefError, cJ as TxRow, cK as TxRows, cL as TxSelectOptions, cM as TxSetShape, cO as TxTable, cP as TxTables, cQ as TxWhere, cW as TypedDB, cX as TypedTable, cY as TypedTx, c$ as UniqueWhere, d9 as bigint, da as boolean, de as dec, dh as defineSchema, di as defineTable, dj as enumType, dp as inc, ds as installationRef, dt as integer, du as isPalbaseExtension, dw as jsonb, dx as makeTypedDB, dy as now, dC as openai, dD as ownedByUser, dE as policy, dF as raw, dH as text, dI as timestamp, dJ as userRef, dK as uuid, dL as vector } from '../index-eN4KzGa5.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import './env.js';
|
|
4
4
|
import '../stack.js';
|
package/dist/db/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
openai,
|
|
11
11
|
policy,
|
|
12
12
|
raw
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-AR2I4M7I.js";
|
|
14
14
|
import {
|
|
15
15
|
bigint,
|
|
16
16
|
boolean,
|
|
@@ -31,8 +31,8 @@ import {
|
|
|
31
31
|
dec,
|
|
32
32
|
inc,
|
|
33
33
|
now
|
|
34
|
-
} from "../chunk-
|
|
35
|
-
import "../chunk-
|
|
34
|
+
} from "../chunk-4J6I4KVQ.js";
|
|
35
|
+
import "../chunk-JPTFYHP3.js";
|
|
36
36
|
import "../chunk-VXPNPVAG.js";
|
|
37
37
|
export {
|
|
38
38
|
EXTENSION_DEPENDENCIES,
|
package/dist/engine/index.cjs
CHANGED
|
@@ -937,6 +937,7 @@ function makeTypedSurface(raw) {
|
|
|
937
937
|
$facets: /* @__PURE__ */ __name((table, params) => reco.facets(table, params), "$facets"),
|
|
938
938
|
$claim: /* @__PURE__ */ __name((table, unique, extra) => reco.claim(table, unique, extra), "$claim"),
|
|
939
939
|
$lockRows: /* @__PURE__ */ __name((table, ids) => reco.lockRows(table, ids), "$lockRows"),
|
|
940
|
+
$lockRowsWhere: /* @__PURE__ */ __name((table, where, opts) => reco.lockRowsWhere(table, where, opts), "$lockRowsWhere"),
|
|
940
941
|
$advisoryXactLock: /* @__PURE__ */ __name((key2) => reco.advisoryXactLock(key2), "$advisoryXactLock"),
|
|
941
942
|
$aggregate: /* @__PURE__ */ __name((table, q) => raw.aggregate(table, q), "$aggregate"),
|
|
942
943
|
$insertMany: /* @__PURE__ */ __name((table, rows, opts) => raw.insertMany(table, rows, opts), "$insertMany"),
|
|
@@ -1271,7 +1272,7 @@ var DeadlockDetected = class extends Conflict {
|
|
|
1271
1272
|
return typeof e === "object" && e !== null && e.name === "DeadlockDetected";
|
|
1272
1273
|
}
|
|
1273
1274
|
constructor(sqlstate = SQLSTATE.deadlockDetected, message, data) {
|
|
1274
|
-
super(message ?? "deadlock: iki i\u015Flem birbirinin kilidini bekledi ve bu i\u015Flem iptal edildi \u2014 kilit s\u0131ras\u0131n\u0131
|
|
1275
|
+
super(message ?? "deadlock: iki i\u015Flem birbirinin kilidini bekledi ve bu i\u015Flem iptal edildi \u2014 kilit s\u0131ras\u0131n\u0131 sabitleyin: id'ler elinizdeyse Database.$lockRows(tablo, id'ler), elinizde bir filtre varsa Database.$lockRowsWhere(tablo, filtre) kullan\u0131n", "deadlock_detected", data);
|
|
1275
1276
|
this.name = "DeadlockDetected";
|
|
1276
1277
|
this.sqlstate = sqlstate;
|
|
1277
1278
|
}
|
|
@@ -3060,6 +3061,11 @@ var WHERE_OPS = {
|
|
|
3060
3061
|
lte: "<=",
|
|
3061
3062
|
neq: "<>"
|
|
3062
3063
|
};
|
|
3064
|
+
var LOCK_MODES = {
|
|
3065
|
+
update: "FOR UPDATE",
|
|
3066
|
+
share: "FOR SHARE",
|
|
3067
|
+
noKeyUpdate: "FOR NO KEY UPDATE"
|
|
3068
|
+
};
|
|
3063
3069
|
function ftsExprOf(ftsCols) {
|
|
3064
3070
|
return [
|
|
3065
3071
|
...ftsCols
|
|
@@ -4053,6 +4059,45 @@ function createOps(tx, context = {}) {
|
|
|
4053
4059
|
await (await at()).unsafe(`SELECT t.${quoteIdent(pk)} FROM ${quoteTable(table)} t WHERE t.${quoteIdent(pk)} IN (${list}) ORDER BY t.${quoteIdent(pk)} FOR NO KEY UPDATE`, params);
|
|
4054
4060
|
},
|
|
4055
4061
|
/**
|
|
4062
|
+
* Bir FİLTRENİN eşleştiği satırları kilitle — sırayı yine KATMAN koyar
|
|
4063
|
+
* (FR-037).
|
|
4064
|
+
*
|
|
4065
|
+
* `lockRows` kilitlenecek kümeyi çağıranın SAYMASINI istiyor. "Bu hesabın
|
|
4066
|
+
* bekleyen bütün hareketlerini kilitle" bunu yapamaz: id listesi ancak bir
|
|
4067
|
+
* sorguyla çıkar, ve SORGU İLE KİLİT ARASINDAKİ BOŞLUK tam olarak kilidin
|
|
4068
|
+
* kapatması gereken yarıştır — araya giren bir INSERT o listede yoktur ve
|
|
4069
|
+
* kilitlenmez. Burada küme TEK statement'ta hem seçiliyor hem kilitleniyor.
|
|
4070
|
+
*
|
|
4071
|
+
* `ORDER BY <pk>`: `updateMany`'nin kilit CTE'siyle AYNI sıra (FR-037b).
|
|
4072
|
+
* Sırayı iki yolun da katmandan alması, aynı satır kümesine giren iki
|
|
4073
|
+
* transaction'ın ters sırada kilitlemesini imkânsız kılıyor — deadlock'un
|
|
4074
|
+
* bedeli ucuz değil, `deadlock_timeout` varsayılanı 1 SANİYE.
|
|
4075
|
+
*
|
|
4076
|
+
* KİLİT MODU EŞİTLENMEZ (FR-037b): `updateMany` işi UPDATE olduğu için
|
|
4077
|
+
* `FOR NO KEY UPDATE` kullanıyor, ama burada mod ÇAĞIRANIN seçimi. Herkesi
|
|
4078
|
+
* o moda zorlamak, yalnız okuma kilidi isteyeni ihtiyacından fazlasını
|
|
4079
|
+
* almaya zorlardı. Deadlock'u önleyen SIRADIR, mod değil.
|
|
4080
|
+
*/
|
|
4081
|
+
async lockRowsWhere(table, where, opts) {
|
|
4082
|
+
const mode = opts?.mode ?? "update";
|
|
4083
|
+
const clause = LOCK_MODES[mode];
|
|
4084
|
+
if (clause === void 0) {
|
|
4085
|
+
throw new Error(`lockRowsWhere(${table}): bilinmeyen mode "${String(mode)}" \u2014 "update" (FOR UPDATE), "share" (FOR SHARE) ya da "noKeyUpdate" (FOR NO KEY UPDATE).`);
|
|
4086
|
+
}
|
|
4087
|
+
const pk = primaryKeyOf(table);
|
|
4088
|
+
if (pk === null) {
|
|
4089
|
+
throw new Error(`lockRowsWhere(${table}): tek-kolon primary key bulunamad\u0131 \u2014 kilit s\u0131ras\u0131 bir anahtar ister (FR-037).`);
|
|
4090
|
+
}
|
|
4091
|
+
const params = [];
|
|
4092
|
+
const add = /* @__PURE__ */ __name((v) => {
|
|
4093
|
+
params.push(v);
|
|
4094
|
+
return `$${params.length}`;
|
|
4095
|
+
}, "add");
|
|
4096
|
+
const whereSql = compileWhere(table, schemaColumns(table), where, add, "lockRowsWhere");
|
|
4097
|
+
assertHasPredicate(whereSql, "lockRowsWhere", table);
|
|
4098
|
+
await (await at()).unsafe(`SELECT t.${quoteIdent(pk)} FROM ${quoteTable(table)} t WHERE true${whereSql} ORDER BY t.${quoteIdent(pk)} ${clause}`, params);
|
|
4099
|
+
},
|
|
4100
|
+
/**
|
|
4056
4101
|
* Bir idempotency anahtarını SAHİPLEN (FR-033).
|
|
4057
4102
|
*
|
|
4058
4103
|
* `{ inserted: true, row }` → bu çağrı yazdı.
|