@palbase/backend 22.0.1 → 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 (73) hide show
  1. package/dist/bin/palbase-backend.cjs +764 -25
  2. package/dist/bin/palbase-backend.cjs.map +1 -1
  3. package/dist/bin/palbase-backend.js +4 -4
  4. package/dist/{chunk-POYAFBLF.js → chunk-FSGSB42K.js} +13 -6
  5. package/dist/chunk-FSGSB42K.js.map +1 -0
  6. package/dist/{chunk-SSGAMC26.js → chunk-HAF67F2H.js} +114 -5
  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-QYOHMVUW.js → chunk-REZU6UKT.js} +755 -24
  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 +117 -6
  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 +7 -3
  23. package/dist/{endpoint-B0LpZixz.d.cts → endpoint-BavvbW4P.d.ts} +116 -14
  24. package/dist/{endpoint-B0LpZixz.d.ts → endpoint-i8TTCohk.d.cts} +116 -14
  25. package/dist/engine/index.cjs +764 -25
  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-g-EzitI-.d.ts → index-B3jmmItD.d.ts} +203 -7
  31. package/dist/{index-BCNtlG1w.d.ts → index-B7YBEG5w.d.ts} +117 -93
  32. package/dist/{index-BGSCWlUa.d.cts → index-Bmvx1EvJ.d.cts} +203 -7
  33. package/dist/{index-B4W6d2VJ.d.cts → index-E7OscPJT.d.cts} +117 -93
  34. package/dist/index.cjs +509 -1085
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +203 -1133
  37. package/dist/index.d.ts +203 -1133
  38. package/dist/index.js +288 -900
  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-3BLYv4si.d.ts → registry-C3H2uPeZ.d.cts} +13 -169
  47. package/dist/{registry-Cw0YEYCg.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/endpoints.md +1 -1
  55. package/docs/errors.md +9 -0
  56. package/docs/llms-full.txt +17 -261
  57. package/docs/llms.txt +0 -2
  58. package/package.json +7 -7
  59. package/template/package.json +1 -1
  60. package/dist/chunk-N32VDWKH.js.map +0 -1
  61. package/dist/chunk-POYAFBLF.js.map +0 -1
  62. package/dist/chunk-QMVK4X3V.js.map +0 -1
  63. package/dist/chunk-QYOHMVUW.js.map +0 -1
  64. package/dist/chunk-SSGAMC26.js.map +0 -1
  65. package/dist/purchases/keys.cjs.map +0 -1
  66. package/dist/purchases/keys.d.cts +0 -42
  67. package/dist/purchases/keys.d.ts +0 -42
  68. package/dist/purchases/keys.js +0 -1
  69. package/docs/config.md +0 -147
  70. package/docs/resources.md +0 -97
  71. package/template/config/secrets.ts +0 -24
  72. /package/dist/{chunk-YL4C5NRY.js.map → chunk-Y5HXVUMP.js.map} +0 -0
  73. /package/dist/{purchases/keys.js.map → stack.js.map} +0 -0
package/dist/db/index.js CHANGED
@@ -10,12 +10,14 @@ import {
10
10
  isPalbaseExtension,
11
11
  jsonb,
12
12
  makeTypedDB,
13
+ openai,
13
14
  policy,
14
15
  raw,
15
16
  text,
16
17
  timestamp,
17
- uuid
18
- } from "../chunk-SSGAMC26.js";
18
+ uuid,
19
+ vector
20
+ } from "../chunk-HAF67F2H.js";
19
21
  import {
20
22
  TxPlanError,
21
23
  TxRefError,
@@ -41,10 +43,12 @@ export {
41
43
  jsonb,
42
44
  makeTypedDB,
43
45
  now,
46
+ openai,
44
47
  policy,
45
48
  raw,
46
49
  text,
47
50
  timestamp,
48
- uuid
51
+ uuid,
52
+ vector
49
53
  };
50
54
  //# sourceMappingURL=index.js.map
@@ -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
@@ -1562,6 +1563,22 @@ interface PalbaseFlagsClient {
1562
1563
  * await Realtime.broadcast("room:42", "message", { text, from: user.id });
1563
1564
  */
1564
1565
  interface PalbaseRealtimeClient {
1566
+ /**
1567
+ * A channel's SHARED STATE — a keyed map every subscriber sees, including
1568
+ * the ones that join later.
1569
+ *
1570
+ * That is the whole difference from `broadcast`: a broadcast reaches whoever
1571
+ * is listening at that instant, and a client connecting a second afterwards
1572
+ * learns nothing until the next one. State is handed to every joiner in the
1573
+ * snapshot they get, so "the score is 3-1" or "this flag is now on" arrives
1574
+ * even for a client that was not there when it changed.
1575
+ */
1576
+ state: {
1577
+ /** Write one entry. Fire-and-forget, like `broadcast`. */
1578
+ set(topic: string, key: string, value: Record<string, unknown>): Promise<PalbaseResult<void>>;
1579
+ /** Remove one entry. */
1580
+ clear(topic: string, key: string): Promise<PalbaseResult<void>>;
1581
+ };
1565
1582
  /**
1566
1583
  * Broadcast `event` with `payload` to everyone subscribed to `channel`.
1567
1584
  *
@@ -1811,7 +1828,72 @@ interface DBOps {
1811
1828
  update(table: string, id: string, data: Record<string, unknown>): Promise<Record<string, unknown> | null>;
1812
1829
  delete(table: string, id: string): Promise<void>;
1813
1830
  findById(table: string, id: string): Promise<Record<string, unknown> | null>;
1831
+ /** Hibrit arama (FR-013/014) — tek SQL, RRF; engine implement eder (T017). */
1832
+ search(table: string, params?: {
1833
+ query?: string;
1834
+ vector?: number[];
1835
+ where?: Record<string, unknown>;
1836
+ limit?: number;
1837
+ using?: string;
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
+ };
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>>;
1814
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>[]>;
1815
1897
  }
1816
1898
  /** Database client interface injected into endpoint context. */
1817
1899
  interface DBClient extends DBOps {
@@ -1868,7 +1950,20 @@ interface Logger {
1868
1950
  * a restart and a hot path pays a map lookup.
1869
1951
  */
1870
1952
  interface SecretsService {
1871
- 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>;
1872
1967
  }
1873
1968
  interface CacheClient {
1874
1969
  /** Read a value. Returns `null` on a cache miss. */
@@ -1963,19 +2058,26 @@ interface PalbaseDocsClient {
1963
2058
  }
1964
2059
  /** Calling-client metadata, derived from request headers.
1965
2060
  *
1966
- * Populated from the `X-Palbase-*-Version` / platform headers the client SDKs
1967
- * send. All fields are nullable: a request may come from a non-SDK caller
1968
- * (curl, server-to-server) that sends none of them. The semver comparison
1969
- * helpers (`appVersionAtLeast`, …) arrive in Phase 2 Phase 1 surfaces only
1970
- * the raw data fields. */
2061
+ * Every header is named here, because the previous version of this comment named
2062
+ * only two of the four and the next reader invented `X-Palbase-Platform` for the
2063
+ * third. The four are canonical across the platform the same names the Go
2064
+ * side reads in user-flags/internal/middleware/clientcontext.goand the deploy
2065
+ * gate REFUSES an `@Headers` schema that declares an `x-palbase-*` key, which
2066
+ * makes `@Client()` the only sanctioned way to read them.
2067
+ *
2068
+ * All fields are nullable: a request may come from a non-SDK caller (curl,
2069
+ * server-to-server) that sends none of them. Note that the web SDK does not
2070
+ * send `X-Palbase-Sdk-Version` at all, so `sdkVersion` is null for every browser
2071
+ * caller. The semver comparison helpers (`appVersionAtLeast`, …) arrive in
2072
+ * Phase 2 — Phase 1 surfaces only the raw data fields. */
1971
2073
  interface ClientInfo {
1972
2074
  /** Palbase SDK version (`X-Palbase-Sdk-Version`), or null. */
1973
2075
  sdkVersion: string | null;
1974
2076
  /** Calling app's own version (`X-Palbase-Client-Version`), or null. */
1975
2077
  appVersion: string | null;
1976
- /** Platform identifier (e.g. "ios", "android", "web"), or null. */
2078
+ /** Platform identifier (`X-Platform`, e.g. "ios", "android", "web"), or null. */
1977
2079
  platform: string | null;
1978
- /** OS version string, or null. */
2080
+ /** OS version string (`X-OS-Version`), or null. */
1979
2081
  osVersion: string | null;
1980
2082
  }
1981
2083
  /** Palbase module clients, as a structural bundle.
@@ -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
@@ -1562,6 +1563,22 @@ interface PalbaseFlagsClient {
1562
1563
  * await Realtime.broadcast("room:42", "message", { text, from: user.id });
1563
1564
  */
1564
1565
  interface PalbaseRealtimeClient {
1566
+ /**
1567
+ * A channel's SHARED STATE — a keyed map every subscriber sees, including
1568
+ * the ones that join later.
1569
+ *
1570
+ * That is the whole difference from `broadcast`: a broadcast reaches whoever
1571
+ * is listening at that instant, and a client connecting a second afterwards
1572
+ * learns nothing until the next one. State is handed to every joiner in the
1573
+ * snapshot they get, so "the score is 3-1" or "this flag is now on" arrives
1574
+ * even for a client that was not there when it changed.
1575
+ */
1576
+ state: {
1577
+ /** Write one entry. Fire-and-forget, like `broadcast`. */
1578
+ set(topic: string, key: string, value: Record<string, unknown>): Promise<PalbaseResult<void>>;
1579
+ /** Remove one entry. */
1580
+ clear(topic: string, key: string): Promise<PalbaseResult<void>>;
1581
+ };
1565
1582
  /**
1566
1583
  * Broadcast `event` with `payload` to everyone subscribed to `channel`.
1567
1584
  *
@@ -1811,7 +1828,72 @@ interface DBOps {
1811
1828
  update(table: string, id: string, data: Record<string, unknown>): Promise<Record<string, unknown> | null>;
1812
1829
  delete(table: string, id: string): Promise<void>;
1813
1830
  findById(table: string, id: string): Promise<Record<string, unknown> | null>;
1831
+ /** Hibrit arama (FR-013/014) — tek SQL, RRF; engine implement eder (T017). */
1832
+ search(table: string, params?: {
1833
+ query?: string;
1834
+ vector?: number[];
1835
+ where?: Record<string, unknown>;
1836
+ limit?: number;
1837
+ using?: string;
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
+ };
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>>;
1814
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>[]>;
1815
1897
  }
1816
1898
  /** Database client interface injected into endpoint context. */
1817
1899
  interface DBClient extends DBOps {
@@ -1868,7 +1950,20 @@ interface Logger {
1868
1950
  * a restart and a hot path pays a map lookup.
1869
1951
  */
1870
1952
  interface SecretsService {
1871
- 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>;
1872
1967
  }
1873
1968
  interface CacheClient {
1874
1969
  /** Read a value. Returns `null` on a cache miss. */
@@ -1963,19 +2058,26 @@ interface PalbaseDocsClient {
1963
2058
  }
1964
2059
  /** Calling-client metadata, derived from request headers.
1965
2060
  *
1966
- * Populated from the `X-Palbase-*-Version` / platform headers the client SDKs
1967
- * send. All fields are nullable: a request may come from a non-SDK caller
1968
- * (curl, server-to-server) that sends none of them. The semver comparison
1969
- * helpers (`appVersionAtLeast`, …) arrive in Phase 2 Phase 1 surfaces only
1970
- * the raw data fields. */
2061
+ * Every header is named here, because the previous version of this comment named
2062
+ * only two of the four and the next reader invented `X-Palbase-Platform` for the
2063
+ * third. The four are canonical across the platform the same names the Go
2064
+ * side reads in user-flags/internal/middleware/clientcontext.goand the deploy
2065
+ * gate REFUSES an `@Headers` schema that declares an `x-palbase-*` key, which
2066
+ * makes `@Client()` the only sanctioned way to read them.
2067
+ *
2068
+ * All fields are nullable: a request may come from a non-SDK caller (curl,
2069
+ * server-to-server) that sends none of them. Note that the web SDK does not
2070
+ * send `X-Palbase-Sdk-Version` at all, so `sdkVersion` is null for every browser
2071
+ * caller. The semver comparison helpers (`appVersionAtLeast`, …) arrive in
2072
+ * Phase 2 — Phase 1 surfaces only the raw data fields. */
1971
2073
  interface ClientInfo {
1972
2074
  /** Palbase SDK version (`X-Palbase-Sdk-Version`), or null. */
1973
2075
  sdkVersion: string | null;
1974
2076
  /** Calling app's own version (`X-Palbase-Client-Version`), or null. */
1975
2077
  appVersion: string | null;
1976
- /** Platform identifier (e.g. "ios", "android", "web"), or null. */
2078
+ /** Platform identifier (`X-Platform`, e.g. "ios", "android", "web"), or null. */
1977
2079
  platform: string | null;
1978
- /** OS version string, or null. */
2080
+ /** OS version string (`X-OS-Version`), or null. */
1979
2081
  osVersion: string | null;
1980
2082
  }
1981
2083
  /** Palbase module clients, as a structural bundle.