@palbase/backend 28.0.0 → 30.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 +166 -12
- package/dist/bin/palbase-backend.cjs.map +1 -1
- package/dist/bin/palbase-backend.js +3 -3
- package/dist/{chunk-RVP6BTEZ.js → chunk-5J5W75A6.js} +15 -4
- package/dist/chunk-5J5W75A6.js.map +1 -0
- package/dist/{chunk-IVZERLTM.js → chunk-ENZ2RFFJ.js} +2 -2
- package/dist/{chunk-SNDXY565.js → chunk-SG4UTNOP.js} +5 -2
- package/dist/chunk-SG4UTNOP.js.map +1 -0
- package/dist/{chunk-75YROPRZ.js → chunk-VN7NMDUH.js} +166 -15
- package/dist/chunk-VN7NMDUH.js.map +1 -0
- package/dist/db/index.cjs +4 -1
- 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 +2 -2
- package/dist/engine/index.cjs +166 -12
- 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 +3 -3
- package/dist/{index-dTTLlHIn.d.ts → index-8qy3kIuA.d.ts} +228 -12
- package/dist/{index-DtISj9QX.d.cts → index-DtCgaZAg.d.cts} +228 -12
- package/dist/{index-9C3JHxg-.d.cts → index-Zi7MptvP.d.cts} +30 -8
- package/dist/{index-BbvOoZFr.d.ts → index-b-Q3l7W5.d.ts} +30 -8
- package/dist/index.cjs +66 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -11
- package/dist/index.d.ts +51 -11
- package/dist/index.js +52 -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-JQNIX-eA.d.ts → registry-BGJ-Al6F.d.ts} +1 -1
- package/dist/{registry-qIPM5BQe.d.cts → registry-CEYLH-Iz.d.cts} +1 -1
- package/dist/test/index.cjs +56 -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 +56 -0
- package/dist/test/index.js.map +1 -1
- package/docs/README.md +1 -1
- package/docs/database.md +49 -0
- package/docs/llms-full.txt +50 -1
- package/package.json +1 -1
- package/template/package.json +1 -1
- package/dist/chunk-75YROPRZ.js.map +0 -1
- package/dist/chunk-RVP6BTEZ.js.map +0 -1
- package/dist/chunk-SNDXY565.js.map +0 -1
- /package/dist/{chunk-IVZERLTM.js.map → chunk-ENZ2RFFJ.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/index.ts
|
|
22
22
|
var src_exports = {};
|
|
23
23
|
__export(src_exports, {
|
|
24
|
+
Auth: () => Auth,
|
|
24
25
|
BadRequest: () => BadRequest,
|
|
25
26
|
Body: () => Body,
|
|
26
27
|
Cache: () => Cache,
|
|
@@ -71,6 +72,7 @@ __export(src_exports, {
|
|
|
71
72
|
Realtime: () => Realtime,
|
|
72
73
|
Req: () => Req,
|
|
73
74
|
RequestId: () => RequestId,
|
|
75
|
+
RoleNotDefined: () => RoleNotDefined,
|
|
74
76
|
Room: () => Room,
|
|
75
77
|
Secrets: () => Secrets,
|
|
76
78
|
SerializationFailure: () => SerializationFailure,
|
|
@@ -918,6 +920,7 @@ var TooManyRequests = class extends NamedHttpError {
|
|
|
918
920
|
function makeTypedTable(name, raw2) {
|
|
919
921
|
return {
|
|
920
922
|
insert: /* @__PURE__ */ __name((data) => raw2.insert(name, data), "insert"),
|
|
923
|
+
aggregate: /* @__PURE__ */ __name((q) => raw2.aggregate(name, q), "aggregate"),
|
|
921
924
|
insertMany: /* @__PURE__ */ __name((rows, opts) => raw2.insertMany(name, rows, opts), "insertMany"),
|
|
922
925
|
put: /* @__PURE__ */ __name((q) => raw2.put(name, q.data, {
|
|
923
926
|
onConflict: q.onConflict
|
|
@@ -929,7 +932,9 @@ function makeTypedTable(name, raw2) {
|
|
|
929
932
|
const { where, ...opts } = q ?? {};
|
|
930
933
|
return raw2.findMany(name, where, opts);
|
|
931
934
|
}, "findMany"),
|
|
932
|
-
updateMany: /* @__PURE__ */ __name((q) => raw2.updateMany(name, q.where, q.set
|
|
935
|
+
updateMany: /* @__PURE__ */ __name((q) => raw2.updateMany(name, q.where, q.set, q.returning === void 0 ? void 0 : {
|
|
936
|
+
returning: q.returning
|
|
937
|
+
}), "updateMany"),
|
|
933
938
|
deleteMany: /* @__PURE__ */ __name((q) => raw2.deleteMany(name, q.where), "deleteMany"),
|
|
934
939
|
count: /* @__PURE__ */ __name((q) => raw2.count(name, q?.where), "count")
|
|
935
940
|
};
|
|
@@ -1373,6 +1378,7 @@ function makeTableProxy(ops, prefix) {
|
|
|
1373
1378
|
// DÖRDÜNCÜ FİİL, aynı gerekçeyle: tip söz veriyor, ops katmanı
|
|
1374
1379
|
// uyguluyor, ve bir handler'ın gerçekten dokunduğu yer BURASI.
|
|
1375
1380
|
// `runtime-table-verbs` kapısı bunu adıyla saydı.
|
|
1381
|
+
aggregate: /* @__PURE__ */ __name((q) => ops().aggregate(name, q), "aggregate"),
|
|
1376
1382
|
insertMany: /* @__PURE__ */ __name((rows, opts) => ops().insertMany(name, rows, opts), "insertMany"),
|
|
1377
1383
|
update: /* @__PURE__ */ __name((q) => ops().update(name, q.where.id, q.set), "update"),
|
|
1378
1384
|
delete: /* @__PURE__ */ __name((id) => ops().delete(name, id), "delete"),
|
|
@@ -1430,6 +1436,7 @@ function makeTypedSurface(raw2) {
|
|
|
1430
1436
|
$claim: /* @__PURE__ */ __name((table, unique, extra) => reco.claim(table, unique, extra), "$claim"),
|
|
1431
1437
|
$lockRows: /* @__PURE__ */ __name((table, ids) => reco.lockRows(table, ids), "$lockRows"),
|
|
1432
1438
|
$advisoryXactLock: /* @__PURE__ */ __name((key) => reco.advisoryXactLock(key), "$advisoryXactLock"),
|
|
1439
|
+
$aggregate: /* @__PURE__ */ __name((table, q) => raw2.aggregate(table, q), "$aggregate"),
|
|
1433
1440
|
$insertMany: /* @__PURE__ */ __name((table, rows, opts) => raw2.insertMany(table, rows, opts), "$insertMany"),
|
|
1434
1441
|
$supersede: /* @__PURE__ */ __name((table, id, row) => raw2.supersede(table, id, row), "$supersede")
|
|
1435
1442
|
};
|
|
@@ -1515,6 +1522,7 @@ var Storage = Object.assign({
|
|
|
1515
1522
|
});
|
|
1516
1523
|
var Cache = makeServiceProxy("Cache");
|
|
1517
1524
|
var Secrets = makeServiceProxy("Secrets");
|
|
1525
|
+
var Auth = makeServiceProxy("Auth");
|
|
1518
1526
|
var Log = makeServiceProxy("Log");
|
|
1519
1527
|
var Notifications = makeServiceProxy("Notifications");
|
|
1520
1528
|
var rawFlags = makeServiceProxy("Flags");
|
|
@@ -1642,6 +1650,48 @@ function makeHttpClient(cfg) {
|
|
|
1642
1650
|
}
|
|
1643
1651
|
__name(makeHttpClient, "makeHttpClient");
|
|
1644
1652
|
|
|
1653
|
+
// src/clients/auth.ts
|
|
1654
|
+
var RoleNotDefined = class extends Error {
|
|
1655
|
+
static {
|
|
1656
|
+
__name(this, "RoleNotDefined");
|
|
1657
|
+
}
|
|
1658
|
+
role;
|
|
1659
|
+
constructor(role, message) {
|
|
1660
|
+
super(message ?? `No role named "${role}" is defined for this stack`);
|
|
1661
|
+
this.name = "RoleNotDefined";
|
|
1662
|
+
this.role = role;
|
|
1663
|
+
}
|
|
1664
|
+
};
|
|
1665
|
+
function refuse(error, role) {
|
|
1666
|
+
if (error.code === "role_not_defined") throw new RoleNotDefined(role, error.message);
|
|
1667
|
+
if (error instanceof PalbaseModuleError) throw error;
|
|
1668
|
+
throw new PalbaseModuleError(error.code ?? "unknown_error", error.message ?? "request failed", 0);
|
|
1669
|
+
}
|
|
1670
|
+
__name(refuse, "refuse");
|
|
1671
|
+
function rolesPath(userId, role) {
|
|
1672
|
+
const base = `/admin/users/${encodeURIComponent(userId)}/roles`;
|
|
1673
|
+
return role === void 0 ? base : `${base}/${encodeURIComponent(role)}`;
|
|
1674
|
+
}
|
|
1675
|
+
__name(rolesPath, "rolesPath");
|
|
1676
|
+
function buildAuthClient(http) {
|
|
1677
|
+
return {
|
|
1678
|
+
async assignRole(userId, role) {
|
|
1679
|
+
const { error } = await http.request("PUT", rolesPath(userId, role));
|
|
1680
|
+
if (error) refuse(error, role);
|
|
1681
|
+
},
|
|
1682
|
+
async revokeRole(userId, role) {
|
|
1683
|
+
const { error } = await http.request("DELETE", rolesPath(userId, role));
|
|
1684
|
+
if (error) refuse(error, role);
|
|
1685
|
+
},
|
|
1686
|
+
async rolesOf(userId) {
|
|
1687
|
+
const { data, error } = await http.request("GET", rolesPath(userId));
|
|
1688
|
+
if (error) refuse(error, "");
|
|
1689
|
+
return data?.roles ?? [];
|
|
1690
|
+
}
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
__name(buildAuthClient, "buildAuthClient");
|
|
1694
|
+
|
|
1645
1695
|
// src/clients/documents.ts
|
|
1646
1696
|
var SEGMENT_RE = /^[A-Za-z0-9_-]+$/;
|
|
1647
1697
|
function validateSegment(segment, label) {
|
|
@@ -2626,6 +2676,10 @@ function buildModuleClients(cfg) {
|
|
|
2626
2676
|
fetchImpl: cfg.fetchImpl
|
|
2627
2677
|
});
|
|
2628
2678
|
return {
|
|
2679
|
+
// The ROLE half of auth only (`clients/auth.ts` says why the rest is not
|
|
2680
|
+
// here). It rides the same service-role transport, which is exactly the
|
|
2681
|
+
// credential the assignment routes demand.
|
|
2682
|
+
Auth: buildAuthClient(http),
|
|
2629
2683
|
Documents: buildDocumentsClient(http),
|
|
2630
2684
|
Storage: buildStorageClient(http, cfg.publicOrigin),
|
|
2631
2685
|
Notifications: buildNotificationsClient(http),
|
|
@@ -3607,7 +3661,7 @@ function baseTsType(def) {
|
|
|
3607
3661
|
case "boolean":
|
|
3608
3662
|
return "boolean";
|
|
3609
3663
|
case "jsonb":
|
|
3610
|
-
return "
|
|
3664
|
+
return "Json";
|
|
3611
3665
|
// FR-008: the authoring type of a pgvector column. The default `unknown`
|
|
3612
3666
|
// branch below STAYS — an unknown wire type is refused on the Go side
|
|
3613
3667
|
// (FR-005), never papered over here.
|
|
@@ -3635,7 +3689,6 @@ function pgBrand(def) {
|
|
|
3635
3689
|
__name(pgBrand, "pgBrand");
|
|
3636
3690
|
function rowType(def) {
|
|
3637
3691
|
const base = baseTsType(def);
|
|
3638
|
-
if (base === "unknown") return def.nullable ? `${base} | null` : base;
|
|
3639
3692
|
const branded = `Pg<${base}, ${JSON.stringify(pgBrand(def))}>`;
|
|
3640
3693
|
return def.nullable ? `${branded} | null` : branded;
|
|
3641
3694
|
}
|
|
@@ -3799,6 +3852,14 @@ ${schemaBlocks.join("\n")}
|
|
|
3799
3852
|
*/
|
|
3800
3853
|
type Pg<T, N extends string> = T & { readonly __pg?: N };
|
|
3801
3854
|
|
|
3855
|
+
/**
|
|
3856
|
+
* Bir jsonb kolonunun tasiyabilecegi deger.
|
|
3857
|
+
*
|
|
3858
|
+
* undefined DAHIL, cunku JSON.stringify undefined alanlari duserur ve
|
|
3859
|
+
* { a: undefined } yazan kod her yerde var \u2014 reddetmek dogru olmazdi.
|
|
3860
|
+
*/
|
|
3861
|
+
type Json = string | number | boolean | null | undefined | Json[] | { [k: string]: Json };
|
|
3862
|
+
|
|
3802
3863
|
declare module "@palbase/backend/env" {
|
|
3803
3864
|
interface Tables {${body}}
|
|
3804
3865
|
interface Schemas {${schemasBody}}
|
|
@@ -5268,6 +5329,7 @@ __name(getJobConfig, "getJobConfig");
|
|
|
5268
5329
|
var import_zod2 = require("zod");
|
|
5269
5330
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5270
5331
|
0 && (module.exports = {
|
|
5332
|
+
Auth,
|
|
5271
5333
|
BadRequest,
|
|
5272
5334
|
Body,
|
|
5273
5335
|
Cache,
|
|
@@ -5318,6 +5380,7 @@ var import_zod2 = require("zod");
|
|
|
5318
5380
|
Realtime,
|
|
5319
5381
|
Req,
|
|
5320
5382
|
RequestId,
|
|
5383
|
+
RoleNotDefined,
|
|
5321
5384
|
Room,
|
|
5322
5385
|
Secrets,
|
|
5323
5386
|
SerializationFailure,
|