@palbase/backend 22.1.0 → 23.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.
Files changed (71) hide show
  1. package/dist/bin/palbase-backend.cjs +439 -18
  2. package/dist/bin/palbase-backend.cjs.map +1 -1
  3. package/dist/bin/palbase-backend.js +4 -4
  4. package/dist/{chunk-SQC5EIWY.js → chunk-FSGSB42K.js} +11 -6
  5. package/dist/chunk-FSGSB42K.js.map +1 -0
  6. package/dist/{chunk-I3ON7MYF.js → chunk-HAF67F2H.js} +73 -16
  7. package/dist/chunk-HAF67F2H.js.map +1 -0
  8. package/dist/{chunk-QMVK4X3V.js → chunk-OMRTHM4X.js} +98 -98
  9. package/dist/chunk-OMRTHM4X.js.map +1 -0
  10. package/dist/{chunk-74XDEF5J.js → chunk-REZU6UKT.js} +432 -17
  11. package/dist/chunk-REZU6UKT.js.map +1 -0
  12. package/dist/{chunk-YL4C5NRY.js → chunk-Y5HXVUMP.js} +2 -2
  13. package/dist/{chunk-N32VDWKH.js → chunk-ZC6Q2BRD.js} +4 -59
  14. package/dist/chunk-ZC6Q2BRD.js.map +1 -0
  15. package/dist/db/env.cjs.map +1 -1
  16. package/dist/db/env.d.cts +3 -21
  17. package/dist/db/env.d.ts +3 -21
  18. package/dist/db/index.cjs +72 -15
  19. package/dist/db/index.cjs.map +1 -1
  20. package/dist/db/index.d.cts +3 -2
  21. package/dist/db/index.d.ts +3 -2
  22. package/dist/db/index.js +1 -1
  23. package/dist/{endpoint-BVT6jcVW.d.cts → endpoint-BavvbW4P.d.ts} +77 -7
  24. package/dist/{endpoint-BVT6jcVW.d.ts → endpoint-i8TTCohk.d.cts} +77 -7
  25. package/dist/engine/index.cjs +439 -18
  26. package/dist/engine/index.cjs.map +1 -1
  27. package/dist/engine/index.d.cts +6 -5
  28. package/dist/engine/index.d.ts +6 -5
  29. package/dist/engine/index.js +3 -3
  30. package/dist/{index-vwHoS0l2.d.ts → index-B3jmmItD.d.ts} +111 -5
  31. package/dist/{index-CCZqzych.d.ts → index-B7YBEG5w.d.ts} +96 -71
  32. package/dist/{index-BqCiHao8.d.cts → index-Bmvx1EvJ.d.cts} +111 -5
  33. package/dist/{index-BS1gW4nV.d.cts → index-E7OscPJT.d.cts} +96 -71
  34. package/dist/index.cjs +285 -1099
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +89 -1134
  37. package/dist/index.d.ts +89 -1134
  38. package/dist/index.js +107 -902
  39. package/dist/index.js.map +1 -1
  40. package/dist/openapi/index.cjs +3 -57
  41. package/dist/openapi/index.cjs.map +1 -1
  42. package/dist/openapi/index.d.cts +3 -2
  43. package/dist/openapi/index.d.ts +3 -2
  44. package/dist/openapi/index.js +5 -22
  45. package/dist/openapi/index.js.map +1 -1
  46. package/dist/{registry-Bsuf-orT.d.ts → registry-C3H2uPeZ.d.cts} +13 -169
  47. package/dist/{registry-BWttGlaT.d.cts → registry-DY3d9l1k.d.ts} +13 -169
  48. package/dist/{purchases/keys.cjs → stack.cjs} +4 -4
  49. package/dist/stack.cjs.map +1 -0
  50. package/dist/stack.d.cts +76 -0
  51. package/dist/stack.d.ts +76 -0
  52. package/dist/stack.js +1 -0
  53. package/docs/README.md +7 -6
  54. package/docs/llms-full.txt +7 -260
  55. package/docs/llms.txt +0 -2
  56. package/package.json +6 -6
  57. package/template/package.json +1 -1
  58. package/dist/chunk-74XDEF5J.js.map +0 -1
  59. package/dist/chunk-I3ON7MYF.js.map +0 -1
  60. package/dist/chunk-N32VDWKH.js.map +0 -1
  61. package/dist/chunk-QMVK4X3V.js.map +0 -1
  62. package/dist/chunk-SQC5EIWY.js.map +0 -1
  63. package/dist/purchases/keys.cjs.map +0 -1
  64. package/dist/purchases/keys.d.cts +0 -42
  65. package/dist/purchases/keys.d.ts +0 -42
  66. package/dist/purchases/keys.js +0 -1
  67. package/docs/config.md +0 -147
  68. package/docs/resources.md +0 -97
  69. package/template/config/secrets.ts +0 -24
  70. /package/dist/{chunk-YL4C5NRY.js.map → chunk-Y5HXVUMP.js.map} +0 -0
  71. /package/dist/{purchases/keys.js.map → stack.js.map} +0 -0
package/dist/db/index.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  timestamp,
18
18
  uuid,
19
19
  vector
20
- } from "../chunk-I3ON7MYF.js";
20
+ } from "../chunk-HAF67F2H.js";
21
21
  import {
22
22
  TxPlanError,
23
23
  TxRefError,
@@ -1,4 +1,5 @@
1
1
  import { ZodSchema, z } from 'zod';
2
+ import { PalbaseFlagKey, PalbaseSecretName } from './stack.js';
2
3
 
3
4
  /** Supported HTTP methods for endpoints. */
4
5
  type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
@@ -1471,11 +1472,11 @@ interface PalbaseFlagsServiceClient {
1471
1472
  * Set (or replace) a single feature-flag override for one user. The override
1472
1473
  * shadows the project (system) default for that user until cleared.
1473
1474
  */
1474
- setOverrideForUser(userId: string, key: string, value: PalbaseFlagValue): Promise<PalbaseResult<PalbaseSetOverrideResult>>;
1475
+ setOverrideForUser(userId: string, key: PalbaseFlagKey, value: PalbaseFlagValue): Promise<PalbaseResult<PalbaseSetOverrideResult>>;
1475
1476
  /** Set multiple overrides for one user in a single call. */
1476
1477
  setOverridesForUser(userId: string, values: Record<string, PalbaseFlagValue>): Promise<PalbaseResult<PalbaseSetOverridesResult>>;
1477
1478
  /** Clear one override for a user, restoring the project (system) default. */
1478
- clearOverrideForUser(userId: string, key: string): Promise<PalbaseResult<PalbaseClearOverrideResult>>;
1479
+ clearOverrideForUser(userId: string, key: PalbaseFlagKey): Promise<PalbaseResult<PalbaseClearOverrideResult>>;
1479
1480
  /** Clear all overrides for a user, restoring project (system) defaults. */
1480
1481
  clearAllOverridesForUser(userId: string): Promise<PalbaseResult<PalbaseClearAllOverridesResult>>;
1481
1482
  /** Apply override writes across many users in one request (max 1000 ops). */
@@ -1499,9 +1500,9 @@ interface PalbaseFlagsServiceClient {
1499
1500
  */
1500
1501
  interface PalbaseFlagsClient {
1501
1502
  /** Is a flag enabled for the given context? */
1502
- isEnabled(flagName: string, context?: PalbaseFlagContext): Promise<PalbaseResult<boolean>>;
1503
+ isEnabled(flagName: PalbaseFlagKey, context?: PalbaseFlagContext): Promise<PalbaseResult<boolean>>;
1503
1504
  /** Get the active variant of a multivariate flag. */
1504
- getVariant(flagName: string, context?: PalbaseFlagContext): Promise<PalbaseResult<PalbaseFlagVariant>>;
1505
+ getVariant(flagName: PalbaseFlagKey, context?: PalbaseFlagContext): Promise<PalbaseResult<PalbaseFlagVariant>>;
1505
1506
  /** Get all flags for the project. */
1506
1507
  getAll(context?: PalbaseFlagContext): Promise<PalbaseResult<PalbaseFlag[]>>;
1507
1508
  /**
@@ -1518,7 +1519,7 @@ interface PalbaseFlagsClient {
1518
1519
  * `Documents.doc(...)` — declared and never implemented — seen from the other
1519
1520
  * side, and moving the implementation into this package is what surfaced it.
1520
1521
  */
1521
- get(flagName: string, defaultOrContext?: PalbaseFlagValue | PalbaseFlagContext, maybeContext?: PalbaseFlagContext): Promise<PalbaseResult<PalbaseFlagValue>>;
1522
+ get(flagName: PalbaseFlagKey, defaultOrContext?: PalbaseFlagValue | PalbaseFlagContext, maybeContext?: PalbaseFlagContext): Promise<PalbaseResult<PalbaseFlagValue>>;
1522
1523
  /**
1523
1524
  * Set (or replace) a single feature-flag override for the CURRENT REQUEST
1524
1525
  * USER. No userId argument — the override is bound to the signed-in user the
@@ -1533,7 +1534,7 @@ interface PalbaseFlagsClient {
1533
1534
  * @example
1534
1535
  * await Flags.setOverride("new_checkout", true);
1535
1536
  */
1536
- setOverride(key: string, value: PalbaseFlagValue): Promise<PalbaseResult<PalbaseSetOverrideResult>>;
1537
+ setOverride(key: PalbaseFlagKey, value: PalbaseFlagValue): Promise<PalbaseResult<PalbaseSetOverrideResult>>;
1537
1538
  /**
1538
1539
  * Return the cross-user admin write surface ({@link PalbaseFlagsServiceClient}).
1539
1540
  * Use sparingly and explicitly — the default `Flags.setOverride(...)` path is
@@ -1835,8 +1836,64 @@ interface DBOps {
1835
1836
  limit?: number;
1836
1837
  using?: string;
1837
1838
  mode?: "hybrid" | "text" | "vector";
1839
+ /** Nihai (RRF-sonrası) skor alt eşiği (FR-001). */
1840
+ minScore?: number;
1841
+ /** RRF-sonrası üstel tazelik çürümesi (FR-004; feed/haber düğmesi). */
1842
+ recency?: {
1843
+ field: string;
1844
+ halfLife: string;
1845
+ };
1846
+ /** Chunk-modunda satır başına en iyi blok sayısı (FR-015). */
1847
+ blocksPerRow?: number;
1848
+ /** Kolon başına top-20 değer sayacı — dönüş dizisinin `_facets` özelliği (FR-027). */
1849
+ facets?: string[];
1850
+ /** Satır-modunda ts_headline vurgusu: satırlara `_highlight` (FR-025; chunk-modda no-op). */
1851
+ highlight?: boolean;
1852
+ /** Validity'li tabloda zaman penceresi: vars. yalnız güncel; "all" tümü; {asOf} o an (FR-029). */
1853
+ validity?: "all" | {
1854
+ asOf: string;
1855
+ };
1856
+ /** Alan-boost (FR-030): skor * (1 + w·x/(1+x)) — sınırlı çarpan, dış servissiz. */
1857
+ boost?: {
1858
+ field: string;
1859
+ weight: number;
1860
+ };
1838
1861
  }): Promise<Record<string, unknown>[]>;
1862
+ /** Validity'li tabloda satırın yeni versiyonu — eski kapanır (valid_to/superseded_by),
1863
+ * yenisi eklenir; TEK savepoint, dönüş yeni satır (FR-029, C-9). */
1864
+ supersede(table: string, id: string, row: Record<string, unknown>): Promise<Record<string, unknown>>;
1839
1865
  findMany(table: string, query?: Record<string, unknown>): Promise<Record<string, unknown>[]>;
1866
+ /** "Bu satıra benzer satırlar" (FR-022) — satır-modunda kolon vektörüyle,
1867
+ * chunk-modunda chunk-ortalamasıyla; kendisi hariç. */
1868
+ similar(table: string, id: string, opts?: {
1869
+ limit?: number;
1870
+ where?: Record<string, unknown>;
1871
+ minScore?: number;
1872
+ blocksPerRow?: number;
1873
+ validity?: "all" | {
1874
+ asOf: string;
1875
+ };
1876
+ boost?: {
1877
+ field: string;
1878
+ weight: number;
1879
+ };
1880
+ }): Promise<Record<string, unknown>[]>;
1881
+ /** Çok-örnekli öneri (FR-023): avg(pos) + (avg(pos) − avg(neg)); positive'ler sonuç dışı. */
1882
+ recommend(table: string, opts: {
1883
+ positive: string[];
1884
+ negative?: string[];
1885
+ limit?: number;
1886
+ where?: Record<string, unknown>;
1887
+ minScore?: number;
1888
+ blocksPerRow?: number;
1889
+ validity?: "all" | {
1890
+ asOf: string;
1891
+ };
1892
+ boost?: {
1893
+ field: string;
1894
+ weight: number;
1895
+ };
1896
+ }): Promise<Record<string, unknown>[]>;
1840
1897
  }
1841
1898
  /** Database client interface injected into endpoint context. */
1842
1899
  interface DBClient extends DBOps {
@@ -1893,7 +1950,20 @@ interface Logger {
1893
1950
  * a restart and a hot path pays a map lookup.
1894
1951
  */
1895
1952
  interface SecretsService {
1896
- get(name: string): Promise<string | null>;
1953
+ /**
1954
+ * A secret's value, or `null` when this backend's vault holds no value under
1955
+ * that name.
1956
+ *
1957
+ * The name is a `PalbaseSecretName`, not a `string`: it comes from the
1958
+ * generated `palbase-stack.d.ts`, so a secret the stack does not hold cannot
1959
+ * be spelled here at all. THE GATE IS THE COMPILER.
1960
+ *
1961
+ * That gate replaced a declaration. `config/secrets.ts` used to restate, in
1962
+ * the repo, names the vault already held, and the push compared the two lists
1963
+ * — a check that only ran at deploy, and only if the author remembered to
1964
+ * declare. The type runs on every keystroke and cannot be forgotten.
1965
+ */
1966
+ get(name: PalbaseSecretName): Promise<string | null>;
1897
1967
  }
1898
1968
  interface CacheClient {
1899
1969
  /** Read a value. Returns `null` on a cache miss. */
@@ -1,4 +1,5 @@
1
1
  import { ZodSchema, z } from 'zod';
2
+ import { PalbaseFlagKey, PalbaseSecretName } from './stack.cjs';
2
3
 
3
4
  /** Supported HTTP methods for endpoints. */
4
5
  type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
@@ -1471,11 +1472,11 @@ interface PalbaseFlagsServiceClient {
1471
1472
  * Set (or replace) a single feature-flag override for one user. The override
1472
1473
  * shadows the project (system) default for that user until cleared.
1473
1474
  */
1474
- setOverrideForUser(userId: string, key: string, value: PalbaseFlagValue): Promise<PalbaseResult<PalbaseSetOverrideResult>>;
1475
+ setOverrideForUser(userId: string, key: PalbaseFlagKey, value: PalbaseFlagValue): Promise<PalbaseResult<PalbaseSetOverrideResult>>;
1475
1476
  /** Set multiple overrides for one user in a single call. */
1476
1477
  setOverridesForUser(userId: string, values: Record<string, PalbaseFlagValue>): Promise<PalbaseResult<PalbaseSetOverridesResult>>;
1477
1478
  /** Clear one override for a user, restoring the project (system) default. */
1478
- clearOverrideForUser(userId: string, key: string): Promise<PalbaseResult<PalbaseClearOverrideResult>>;
1479
+ clearOverrideForUser(userId: string, key: PalbaseFlagKey): Promise<PalbaseResult<PalbaseClearOverrideResult>>;
1479
1480
  /** Clear all overrides for a user, restoring project (system) defaults. */
1480
1481
  clearAllOverridesForUser(userId: string): Promise<PalbaseResult<PalbaseClearAllOverridesResult>>;
1481
1482
  /** Apply override writes across many users in one request (max 1000 ops). */
@@ -1499,9 +1500,9 @@ interface PalbaseFlagsServiceClient {
1499
1500
  */
1500
1501
  interface PalbaseFlagsClient {
1501
1502
  /** Is a flag enabled for the given context? */
1502
- isEnabled(flagName: string, context?: PalbaseFlagContext): Promise<PalbaseResult<boolean>>;
1503
+ isEnabled(flagName: PalbaseFlagKey, context?: PalbaseFlagContext): Promise<PalbaseResult<boolean>>;
1503
1504
  /** Get the active variant of a multivariate flag. */
1504
- getVariant(flagName: string, context?: PalbaseFlagContext): Promise<PalbaseResult<PalbaseFlagVariant>>;
1505
+ getVariant(flagName: PalbaseFlagKey, context?: PalbaseFlagContext): Promise<PalbaseResult<PalbaseFlagVariant>>;
1505
1506
  /** Get all flags for the project. */
1506
1507
  getAll(context?: PalbaseFlagContext): Promise<PalbaseResult<PalbaseFlag[]>>;
1507
1508
  /**
@@ -1518,7 +1519,7 @@ interface PalbaseFlagsClient {
1518
1519
  * `Documents.doc(...)` — declared and never implemented — seen from the other
1519
1520
  * side, and moving the implementation into this package is what surfaced it.
1520
1521
  */
1521
- get(flagName: string, defaultOrContext?: PalbaseFlagValue | PalbaseFlagContext, maybeContext?: PalbaseFlagContext): Promise<PalbaseResult<PalbaseFlagValue>>;
1522
+ get(flagName: PalbaseFlagKey, defaultOrContext?: PalbaseFlagValue | PalbaseFlagContext, maybeContext?: PalbaseFlagContext): Promise<PalbaseResult<PalbaseFlagValue>>;
1522
1523
  /**
1523
1524
  * Set (or replace) a single feature-flag override for the CURRENT REQUEST
1524
1525
  * USER. No userId argument — the override is bound to the signed-in user the
@@ -1533,7 +1534,7 @@ interface PalbaseFlagsClient {
1533
1534
  * @example
1534
1535
  * await Flags.setOverride("new_checkout", true);
1535
1536
  */
1536
- setOverride(key: string, value: PalbaseFlagValue): Promise<PalbaseResult<PalbaseSetOverrideResult>>;
1537
+ setOverride(key: PalbaseFlagKey, value: PalbaseFlagValue): Promise<PalbaseResult<PalbaseSetOverrideResult>>;
1537
1538
  /**
1538
1539
  * Return the cross-user admin write surface ({@link PalbaseFlagsServiceClient}).
1539
1540
  * Use sparingly and explicitly — the default `Flags.setOverride(...)` path is
@@ -1835,8 +1836,64 @@ interface DBOps {
1835
1836
  limit?: number;
1836
1837
  using?: string;
1837
1838
  mode?: "hybrid" | "text" | "vector";
1839
+ /** Nihai (RRF-sonrası) skor alt eşiği (FR-001). */
1840
+ minScore?: number;
1841
+ /** RRF-sonrası üstel tazelik çürümesi (FR-004; feed/haber düğmesi). */
1842
+ recency?: {
1843
+ field: string;
1844
+ halfLife: string;
1845
+ };
1846
+ /** Chunk-modunda satır başına en iyi blok sayısı (FR-015). */
1847
+ blocksPerRow?: number;
1848
+ /** Kolon başına top-20 değer sayacı — dönüş dizisinin `_facets` özelliği (FR-027). */
1849
+ facets?: string[];
1850
+ /** Satır-modunda ts_headline vurgusu: satırlara `_highlight` (FR-025; chunk-modda no-op). */
1851
+ highlight?: boolean;
1852
+ /** Validity'li tabloda zaman penceresi: vars. yalnız güncel; "all" tümü; {asOf} o an (FR-029). */
1853
+ validity?: "all" | {
1854
+ asOf: string;
1855
+ };
1856
+ /** Alan-boost (FR-030): skor * (1 + w·x/(1+x)) — sınırlı çarpan, dış servissiz. */
1857
+ boost?: {
1858
+ field: string;
1859
+ weight: number;
1860
+ };
1838
1861
  }): Promise<Record<string, unknown>[]>;
1862
+ /** Validity'li tabloda satırın yeni versiyonu — eski kapanır (valid_to/superseded_by),
1863
+ * yenisi eklenir; TEK savepoint, dönüş yeni satır (FR-029, C-9). */
1864
+ supersede(table: string, id: string, row: Record<string, unknown>): Promise<Record<string, unknown>>;
1839
1865
  findMany(table: string, query?: Record<string, unknown>): Promise<Record<string, unknown>[]>;
1866
+ /** "Bu satıra benzer satırlar" (FR-022) — satır-modunda kolon vektörüyle,
1867
+ * chunk-modunda chunk-ortalamasıyla; kendisi hariç. */
1868
+ similar(table: string, id: string, opts?: {
1869
+ limit?: number;
1870
+ where?: Record<string, unknown>;
1871
+ minScore?: number;
1872
+ blocksPerRow?: number;
1873
+ validity?: "all" | {
1874
+ asOf: string;
1875
+ };
1876
+ boost?: {
1877
+ field: string;
1878
+ weight: number;
1879
+ };
1880
+ }): Promise<Record<string, unknown>[]>;
1881
+ /** Çok-örnekli öneri (FR-023): avg(pos) + (avg(pos) − avg(neg)); positive'ler sonuç dışı. */
1882
+ recommend(table: string, opts: {
1883
+ positive: string[];
1884
+ negative?: string[];
1885
+ limit?: number;
1886
+ where?: Record<string, unknown>;
1887
+ minScore?: number;
1888
+ blocksPerRow?: number;
1889
+ validity?: "all" | {
1890
+ asOf: string;
1891
+ };
1892
+ boost?: {
1893
+ field: string;
1894
+ weight: number;
1895
+ };
1896
+ }): Promise<Record<string, unknown>[]>;
1840
1897
  }
1841
1898
  /** Database client interface injected into endpoint context. */
1842
1899
  interface DBClient extends DBOps {
@@ -1893,7 +1950,20 @@ interface Logger {
1893
1950
  * a restart and a hot path pays a map lookup.
1894
1951
  */
1895
1952
  interface SecretsService {
1896
- get(name: string): Promise<string | null>;
1953
+ /**
1954
+ * A secret's value, or `null` when this backend's vault holds no value under
1955
+ * that name.
1956
+ *
1957
+ * The name is a `PalbaseSecretName`, not a `string`: it comes from the
1958
+ * generated `palbase-stack.d.ts`, so a secret the stack does not hold cannot
1959
+ * be spelled here at all. THE GATE IS THE COMPILER.
1960
+ *
1961
+ * That gate replaced a declaration. `config/secrets.ts` used to restate, in
1962
+ * the repo, names the vault already held, and the push compared the two lists
1963
+ * — a check that only ran at deploy, and only if the author remembered to
1964
+ * declare. The type runs on every keystroke and cannot be forgotten.
1965
+ */
1966
+ get(name: PalbaseSecretName): Promise<string | null>;
1897
1967
  }
1898
1968
  interface CacheClient {
1899
1969
  /** Read a value. Returns `null` on a cache miss. */