@palbase/backend 24.0.2 → 24.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.
Files changed (48) hide show
  1. package/dist/bin/palbase-backend.cjs +86 -9
  2. package/dist/bin/palbase-backend.cjs.map +1 -1
  3. package/dist/bin/palbase-backend.js +3 -2
  4. package/dist/bin/palbase-backend.js.map +1 -1
  5. package/dist/{chunk-RPZNHY7J.js → chunk-2A62DDVO.js} +36 -11
  6. package/dist/chunk-2A62DDVO.js.map +1 -0
  7. package/dist/{chunk-T5IOSOE5.js → chunk-ERDL5VAE.js} +2 -2
  8. package/dist/{chunk-H3JAISUY.js → chunk-UWSYTUGM.js} +11 -1
  9. package/dist/{chunk-H3JAISUY.js.map → chunk-UWSYTUGM.js.map} +1 -1
  10. package/dist/chunk-XABBC7JP.js +55 -0
  11. package/dist/chunk-XABBC7JP.js.map +1 -0
  12. package/dist/db/index.d.cts +2 -2
  13. package/dist/db/index.d.ts +2 -2
  14. package/dist/engine/index.cjs +86 -9
  15. package/dist/engine/index.cjs.map +1 -1
  16. package/dist/engine/index.d.cts +4 -4
  17. package/dist/engine/index.d.ts +4 -4
  18. package/dist/engine/index.js +3 -2
  19. package/dist/{index-BOS_rFBO.d.ts → index-ByBMibIJ.d.ts} +1 -1
  20. package/dist/{index-dJNhDZ7j.d.ts → index-C0PMn5jl.d.ts} +3 -3
  21. package/dist/{index-MoQ31B6M.d.cts → index-D4rts8T7.d.cts} +1 -1
  22. package/dist/{index-C84bLgeO.d.cts → index-DAwHMppB.d.cts} +3 -3
  23. package/dist/index.cjs +8 -0
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +23 -9
  26. package/dist/index.d.ts +23 -9
  27. package/dist/index.js +5 -3
  28. package/dist/index.js.map +1 -1
  29. package/dist/openapi/index.cjs.map +1 -1
  30. package/dist/openapi/index.d.cts +2 -2
  31. package/dist/openapi/index.d.ts +2 -2
  32. package/dist/openapi/index.js +2 -2
  33. package/dist/{registry-CEod_5sz.d.ts → registry-B8pld3fj.d.ts} +1 -1
  34. package/dist/{registry-1X-skBNu.d.cts → registry-CgJvDYUW.d.cts} +1 -1
  35. package/dist/test/index.cjs +58 -0
  36. package/dist/test/index.cjs.map +1 -1
  37. package/dist/test/index.d.cts +1 -1
  38. package/dist/test/index.d.ts +1 -1
  39. package/dist/test/index.js +12 -0
  40. package/dist/test/index.js.map +1 -1
  41. package/docs/README.md +5 -1
  42. package/docs/llms-full.txt +5 -1
  43. package/package.json +1 -1
  44. package/template/AGENTS.md +34 -22
  45. package/dist/chunk-RPZNHY7J.js.map +0 -1
  46. package/dist/{chunk-T5IOSOE5.js.map → chunk-ERDL5VAE.js.map} +0 -0
  47. package/dist/{endpoint-CcQ1a36a.d.cts → endpoint-BSGw1pTu.d.cts} +16 -16
  48. package/dist/{endpoint-0_DGBajf.d.ts → endpoint-DMwJjEHQ.d.ts} +16 -16
@@ -1,7 +1,7 @@
1
1
  import { OpenApiGeneratorV31 } from '@asteasolutions/zod-to-openapi';
2
2
  import { ZodTypeAny } from 'zod';
3
- import { A as AuthSpec, R as RateLimitConfig } from '../endpoint-CcQ1a36a.cjs';
4
- import { P as ParamMeta, T as ThrowDescriptor, U as UploadConfig, S as SseConfig } from '../registry-1X-skBNu.cjs';
3
+ import { A as AuthSpec, R as RateLimitConfig } from '../endpoint-BSGw1pTu.cjs';
4
+ import { P as ParamMeta, T as ThrowDescriptor, U as UploadConfig, S as SseConfig } from '../registry-CgJvDYUW.cjs';
5
5
  import '../stack.cjs';
6
6
 
7
7
  /** A controller class (constructor). Kept loose — the only contract is that it
@@ -1,7 +1,7 @@
1
1
  import { OpenApiGeneratorV31 } from '@asteasolutions/zod-to-openapi';
2
2
  import { ZodTypeAny } from 'zod';
3
- import { A as AuthSpec, R as RateLimitConfig } from '../endpoint-0_DGBajf.js';
4
- import { P as ParamMeta, T as ThrowDescriptor, U as UploadConfig, S as SseConfig } from '../registry-CEod_5sz.js';
3
+ import { A as AuthSpec, R as RateLimitConfig } from '../endpoint-DMwJjEHQ.js';
4
+ import { P as ParamMeta, T as ThrowDescriptor, U as UploadConfig, S as SseConfig } from '../registry-B8pld3fj.js';
5
5
  import '../stack.js';
6
6
 
7
7
  /** A controller class (constructor). Kept loose — the only contract is that it
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  getErrorRegistry
3
- } from "../chunk-T5IOSOE5.js";
3
+ } from "../chunk-ERDL5VAE.js";
4
4
  import {
5
5
  getRoutes,
6
6
  isController,
7
7
  resolveController,
8
8
  resolveEffectiveAuth
9
- } from "../chunk-H3JAISUY.js";
9
+ } from "../chunk-UWSYTUGM.js";
10
10
  import {
11
11
  __commonJS,
12
12
  __require,
@@ -1,4 +1,4 @@
1
- import { A as AuthSpec, R as RateLimitConfig } from './endpoint-0_DGBajf.js';
1
+ import { A as AuthSpec, R as RateLimitConfig } from './endpoint-DMwJjEHQ.js';
2
2
  import { ZodTypeAny } from 'zod';
3
3
  import { PalbaseBucketName } from './stack.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { A as AuthSpec, R as RateLimitConfig } from './endpoint-CcQ1a36a.cjs';
1
+ import { A as AuthSpec, R as RateLimitConfig } from './endpoint-BSGw1pTu.cjs';
2
2
  import { ZodTypeAny } from 'zod';
3
3
  import { PalbaseBucketName } from './stack.cjs';
4
4
 
@@ -304,6 +304,56 @@ var api = new Proxy({}, {
304
304
  }
305
305
  });
306
306
 
307
+ // src/db/input-guards.ts
308
+ var KNOWN_OPS = /* @__PURE__ */ new Set(["gt", "gte", "lt", "lte", "neq", "eq", "in"]);
309
+ function assertUsableFilter(caller, table, where) {
310
+ if (!where) return;
311
+ for (const [col, cond] of Object.entries(where)) {
312
+ if (cond === void 0) {
313
+ throw new Error(
314
+ `${caller}(${table}): where.${col} de\u011Feri undefined \u2014 bu bir filtre de\u011Feri de\u011Fil. Ba\u011Flan\u0131nca NULL olur ve '= NULL' hi\xE7bir sat\u0131ra uymaz, yani sorgu sessizce bo\u015F sonu\xE7 d\xF6nerdi. De\u011Fer yoksa anahtar\u0131 filtreye hi\xE7 koymay\u0131n.`
315
+ );
316
+ }
317
+ if (cond === null || typeof cond !== "object" || Array.isArray(cond)) continue;
318
+ const entries = Object.entries(cond);
319
+ if (entries.length === 0) {
320
+ throw new Error(
321
+ `${caller}(${table}): where.${col} bo\u015F bir operat\xF6r nesnesi ({}) \u2014 hi\xE7bir ko\u015Ful \xFCretmez, yani bu alan filtreden sessizce D\xDC\u015EERD\u0130. Ko\u015Ful kurulmayacaksa anahtar\u0131 filtreye hi\xE7 koymay\u0131n (D-21).`
322
+ );
323
+ }
324
+ for (const [op, v] of entries) {
325
+ if (op === "in") {
326
+ if (!Array.isArray(v)) throw new Error(`${caller}(${table}): where.${col}.in bir dizi olmal\u0131`);
327
+ if (v.some((x) => x === void 0)) {
328
+ throw new Error(
329
+ `${caller}(${table}): where.${col}.in listesinde undefined var \u2014 sessizce NULL'a ba\u011Flan\u0131r ve o eleman hi\xE7bir sat\u0131rla e\u015Fle\u015Fmez. Listeyi kurarken eleyin.`
330
+ );
331
+ }
332
+ continue;
333
+ }
334
+ if (!KNOWN_OPS.has(op)) {
335
+ throw new Error(
336
+ `${caller}(${table}): where.${col} bilinmeyen operat\xF6r "${op}" (gt/gte/lt/lte/neq/in)`
337
+ );
338
+ }
339
+ if (v === void 0) {
340
+ throw new Error(
341
+ `${caller}(${table}): where.${col}.${op} de\u011Feri undefined \u2014 kar\u015F\u0131la\u015Ft\u0131rman\u0131n sa\u011F taraf\u0131 NULL olur ve sonu\xE7 hi\xE7bir sat\u0131ra uymaz. Ko\u015Fulu kurmay\u0131n.`
342
+ );
343
+ }
344
+ }
345
+ }
346
+ }
347
+ function assertUsableWriteValues(caller, table, cols, data) {
348
+ for (const c of cols) {
349
+ if (data[c] === void 0) {
350
+ throw new Error(
351
+ `${caller}(${table}): "${c}" de\u011Feri undefined \u2014 bu bir yazma de\u011Feri de\u011Fil. Kolonu bo\u015Faltmak istiyorsan null yaz; kolonu de\u011Fi\u015Ftirmek istemiyorsan nesneye hi\xE7 koyma (bir eksik istek alan\u0131 sessizce NULL yaz\u0131yordu \u2014 FR-016).`
352
+ );
353
+ }
354
+ }
355
+ }
356
+
307
357
  // src/__tests__/helpers/mock-db.ts
308
358
  function createMockDB() {
309
359
  const store = /* @__PURE__ */ new Map();
@@ -332,6 +382,8 @@ function createMockDB() {
332
382
  // tests meant to prove it works.
333
383
  async updateMany(table, where, set) {
334
384
  if (Object.keys(where).length === 0) throw new Error(`updateMany(${table}): bo\u015F filtre`);
385
+ assertUsableFilter("updateMany", table, where);
386
+ assertUsableWriteValues("updateMany", table, Object.keys(set), set);
335
387
  const hit = (store.get(table) ?? []).filter(
336
388
  (r) => Object.entries(where).every(([k, v]) => r[k] === v)
337
389
  );
@@ -340,12 +392,14 @@ function createMockDB() {
340
392
  },
341
393
  async deleteMany(table, where) {
342
394
  if (Object.keys(where).length === 0) throw new Error(`deleteMany(${table}): bo\u015F filtre`);
395
+ assertUsableFilter("deleteMany", table, where);
343
396
  const list = store.get(table) ?? [];
344
397
  const keep = list.filter((r) => !Object.entries(where).every(([k, v]) => r[k] === v));
345
398
  store.set(table, keep);
346
399
  return list.length - keep.length;
347
400
  },
348
401
  async count(table, where = {}) {
402
+ assertUsableFilter("count", table, where);
349
403
  return (store.get(table) ?? []).filter(
350
404
  (r) => Object.entries(where).every(([k, v]) => r[k] === v)
351
405
  ).length;
@@ -369,6 +423,7 @@ function createMockDB() {
369
423
  return [];
370
424
  },
371
425
  async insert(table, data) {
426
+ assertUsableWriteValues("insert", table, Object.keys(data), data);
372
427
  const record = { id: crypto.randomUUID(), ...data };
373
428
  rowsOf(table).push(record);
374
429
  track(tracked.inserted, table, record);
@@ -380,6 +435,7 @@ function createMockDB() {
380
435
  if (opts.onConflict.length === 0) {
381
436
  throw new Error(`upsert into ${table}: onConflict en az bir kolon ad\u0131 ister`);
382
437
  }
438
+ assertUsableWriteValues("upsert", table, Object.keys(data), data);
383
439
  const rows = rowsOf(table);
384
440
  const existing = rows.find((r) => opts.onConflict.every((c) => r[c] === data[c]));
385
441
  if (existing) {
@@ -394,6 +450,7 @@ function createMockDB() {
394
450
  return record;
395
451
  },
396
452
  async update(table, id, data) {
453
+ assertUsableWriteValues("update", table, Object.keys(data), data);
397
454
  const rows = store.get(table) ?? [];
398
455
  const idx = rows.findIndex((r) => r["id"] === id);
399
456
  const updated = idx >= 0 ? { ...rows[idx], ...data } : { id, ...data };
@@ -420,6 +477,7 @@ function createMockDB() {
420
477
  // pass a service test that the live database then fails — which is the one
421
478
  // thing a stand-in must never do.
422
479
  async findMany(table, query, opts) {
480
+ assertUsableFilter("findMany", table, query);
423
481
  const rows = store.get(table) ?? [];
424
482
  const matches2 = (row, key, cond) => {
425
483
  if (cond !== null && typeof cond === "object" && !Array.isArray(cond)) {