@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.
- package/dist/bin/palbase-backend.cjs +439 -18
- package/dist/bin/palbase-backend.cjs.map +1 -1
- package/dist/bin/palbase-backend.js +4 -4
- package/dist/{chunk-SQC5EIWY.js → chunk-FSGSB42K.js} +11 -6
- package/dist/chunk-FSGSB42K.js.map +1 -0
- package/dist/{chunk-I3ON7MYF.js → chunk-HAF67F2H.js} +73 -16
- package/dist/chunk-HAF67F2H.js.map +1 -0
- package/dist/{chunk-QMVK4X3V.js → chunk-OMRTHM4X.js} +98 -98
- package/dist/chunk-OMRTHM4X.js.map +1 -0
- package/dist/{chunk-74XDEF5J.js → chunk-REZU6UKT.js} +432 -17
- package/dist/chunk-REZU6UKT.js.map +1 -0
- package/dist/{chunk-YL4C5NRY.js → chunk-Y5HXVUMP.js} +2 -2
- package/dist/{chunk-N32VDWKH.js → chunk-ZC6Q2BRD.js} +4 -59
- package/dist/chunk-ZC6Q2BRD.js.map +1 -0
- package/dist/db/env.cjs.map +1 -1
- package/dist/db/env.d.cts +3 -21
- package/dist/db/env.d.ts +3 -21
- package/dist/db/index.cjs +72 -15
- package/dist/db/index.cjs.map +1 -1
- package/dist/db/index.d.cts +3 -2
- package/dist/db/index.d.ts +3 -2
- package/dist/db/index.js +1 -1
- package/dist/{endpoint-BVT6jcVW.d.cts → endpoint-BavvbW4P.d.ts} +77 -7
- package/dist/{endpoint-BVT6jcVW.d.ts → endpoint-i8TTCohk.d.cts} +77 -7
- package/dist/engine/index.cjs +439 -18
- package/dist/engine/index.cjs.map +1 -1
- package/dist/engine/index.d.cts +6 -5
- package/dist/engine/index.d.ts +6 -5
- package/dist/engine/index.js +3 -3
- package/dist/{index-vwHoS0l2.d.ts → index-B3jmmItD.d.ts} +111 -5
- package/dist/{index-CCZqzych.d.ts → index-B7YBEG5w.d.ts} +96 -71
- package/dist/{index-BqCiHao8.d.cts → index-Bmvx1EvJ.d.cts} +111 -5
- package/dist/{index-BS1gW4nV.d.cts → index-E7OscPJT.d.cts} +96 -71
- package/dist/index.cjs +285 -1099
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +89 -1134
- package/dist/index.d.ts +89 -1134
- package/dist/index.js +107 -902
- package/dist/index.js.map +1 -1
- package/dist/openapi/index.cjs +3 -57
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.d.cts +3 -2
- package/dist/openapi/index.d.ts +3 -2
- package/dist/openapi/index.js +5 -22
- package/dist/openapi/index.js.map +1 -1
- package/dist/{registry-Bsuf-orT.d.ts → registry-C3H2uPeZ.d.cts} +13 -169
- package/dist/{registry-BWttGlaT.d.cts → registry-DY3d9l1k.d.ts} +13 -169
- package/dist/{purchases/keys.cjs → stack.cjs} +4 -4
- package/dist/stack.cjs.map +1 -0
- package/dist/stack.d.cts +76 -0
- package/dist/stack.d.ts +76 -0
- package/dist/stack.js +1 -0
- package/docs/README.md +7 -6
- package/docs/llms-full.txt +7 -260
- package/docs/llms.txt +0 -2
- package/package.json +6 -6
- package/template/package.json +1 -1
- package/dist/chunk-74XDEF5J.js.map +0 -1
- package/dist/chunk-I3ON7MYF.js.map +0 -1
- package/dist/chunk-N32VDWKH.js.map +0 -1
- package/dist/chunk-QMVK4X3V.js.map +0 -1
- package/dist/chunk-SQC5EIWY.js.map +0 -1
- package/dist/purchases/keys.cjs.map +0 -1
- package/dist/purchases/keys.d.cts +0 -42
- package/dist/purchases/keys.d.ts +0 -42
- package/dist/purchases/keys.js +0 -1
- package/docs/config.md +0 -147
- package/docs/resources.md +0 -97
- package/template/config/secrets.ts +0 -24
- /package/dist/{chunk-YL4C5NRY.js.map → chunk-Y5HXVUMP.js.map} +0 -0
- /package/dist/{purchases/keys.js.map → stack.js.map} +0 -0
|
@@ -1,63 +1,8 @@
|
|
|
1
|
-
import { Buckets, BucketTypes } from './
|
|
1
|
+
import { Buckets, BucketTypes } from './stack.cjs';
|
|
2
2
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
|
-
import { C as CacheClient, P as PalbaseDocsClient, a as PalbaseFlagsClient, L as Logger, b as PalbaseNotificationsClient, c as PalbaseRealtimeClient, D as DBClient, S as SecretsService, d as PalbaseStorageClient, e as PalbaseBucketClient, T as TxPlanBody, f as TxPlanResponse } from './endpoint-
|
|
4
|
-
import { E as EnvTypedDatabase } from './index-
|
|
5
|
-
import { R as RouteMeta } from './registry-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The purchases surface the decorators need, declared as a NARROW STRUCTURAL
|
|
9
|
-
* interface rather than an import of `@palstore/purchases`.
|
|
10
|
-
*
|
|
11
|
-
* `PurchasesClient` (palstore's `sk_` backend SDK) satisfies this shape as-is,
|
|
12
|
-
* so the runtime injects the real client with no adapter — but `@palbase/backend`
|
|
13
|
-
* itself gains no dependency on it. That matters: this package is published
|
|
14
|
-
* public and baked into the br-pod image from a tarball, so a dependency on an
|
|
15
|
-
* unpublished sibling would break `npm install palbase-backend.tgz`. It is also
|
|
16
|
-
* the pattern `withSpend` already uses for the same reason (`SpendCapableClient`
|
|
17
|
-
* in palstore's own spend.ts: "a narrow structural interface … so this file has
|
|
18
|
-
* no dependency on client.ts").
|
|
19
|
-
*
|
|
20
|
-
* The methods here are a SUBSET of `PurchasesClient` — only what the two
|
|
21
|
-
* decorators call. Grants, refunds, credits and customer-info reads stay off
|
|
22
|
-
* this interface: a tenant that wants them imports the palstore SDK directly.
|
|
23
|
-
*/
|
|
24
|
-
/** Store environment a subject is fixed to. Mirrors `StoreEnv` in `@palstore/purchases`. */
|
|
25
|
-
type StoreEnv = "production" | "sandbox";
|
|
26
|
-
/** Quota/credit state carried by a 429. Mirrors `LimitState` in `@palstore/purchases`
|
|
27
|
-
* (SPEC-purchases-v1 §11) — re-declared, not imported, for the reason above. */
|
|
28
|
-
interface LimitState {
|
|
29
|
-
key: string;
|
|
30
|
-
scope: string;
|
|
31
|
-
window: string;
|
|
32
|
-
used: number;
|
|
33
|
-
reserved: number;
|
|
34
|
-
max: number;
|
|
35
|
-
remaining: number;
|
|
36
|
-
resetAt: string;
|
|
37
|
-
}
|
|
38
|
-
/** Options for one spend. `idempotencyKey` is required by the server (§9). */
|
|
39
|
-
interface SpendOptions {
|
|
40
|
-
/** Defaults to 1. */
|
|
41
|
-
count?: number;
|
|
42
|
-
idempotencyKey: string;
|
|
43
|
-
}
|
|
44
|
-
interface PurchasesService {
|
|
45
|
-
/** Map a tenant-side user reference to its palstore subject, creating one on
|
|
46
|
-
* first sight. Server-authoritative — the caller never names a subject. */
|
|
47
|
-
resolveSubject(input: {
|
|
48
|
-
userRef: string;
|
|
49
|
-
storeEnv: StoreEnv;
|
|
50
|
-
}): Promise<{
|
|
51
|
-
subjectId: string;
|
|
52
|
-
}>;
|
|
53
|
-
/** Resolve silently when `entitlementKey` is active for `subjectId`; throw
|
|
54
|
-
* `EntitlementRequiredError` otherwise. Consumes nothing. */
|
|
55
|
-
require(subjectId: string, entitlementKey: string): Promise<void>;
|
|
56
|
-
/** Reserve → run `handler` → commit on success, cancel on throw, always
|
|
57
|
-
* rethrowing the handler's own error. The whole reason the decorators are a
|
|
58
|
-
* thin layer: this lifecycle is already written and tested in palstore's SDK. */
|
|
59
|
-
withSpend<T>(subjectId: string, key: string, opts: SpendOptions, handler: () => Promise<T>): Promise<T>;
|
|
60
|
-
}
|
|
3
|
+
import { C as CacheClient, P as PalbaseDocsClient, a as PalbaseFlagsClient, L as Logger, b as PalbaseNotificationsClient, c as PalbaseRealtimeClient, D as DBClient, S as SecretsService, d as PalbaseStorageClient, e as PalbaseBucketClient, T as TxPlanBody, f as TxPlanResponse } from './endpoint-i8TTCohk.cjs';
|
|
4
|
+
import { E as EnvTypedDatabase } from './index-Bmvx1EvJ.cjs';
|
|
5
|
+
import { R as RouteMeta } from './registry-C3H2uPeZ.cjs';
|
|
61
6
|
|
|
62
7
|
/**
|
|
63
8
|
* runtime.ts — request-scoped service singletons.
|
|
@@ -118,7 +63,6 @@ interface RuntimeServices {
|
|
|
118
63
|
Notifications: PalbaseNotificationsClient;
|
|
119
64
|
Flags: PalbaseFlagsClient;
|
|
120
65
|
Realtime: PalbaseRealtimeClient;
|
|
121
|
-
Purchases: PurchasesService;
|
|
122
66
|
}
|
|
123
67
|
/**
|
|
124
68
|
* The per-request ALS box.
|
|
@@ -239,15 +183,6 @@ declare const Secrets: SecretsService;
|
|
|
239
183
|
declare const Log: Logger;
|
|
240
184
|
/** Push / email / SMS / in-app notifications. */
|
|
241
185
|
declare const Notifications: PalbaseNotificationsClient;
|
|
242
|
-
/**
|
|
243
|
-
* Palstore purchases (entitlements + quota/credit spend).
|
|
244
|
-
*
|
|
245
|
-
* Reached by handlers through the `@RequireEntitlement` / `@Spend` decorators
|
|
246
|
-
* rather than called directly in the common case; exposed as a singleton for
|
|
247
|
-
* the cases the decorators deliberately do not cover (a dynamic spend count,
|
|
248
|
-
* which must run BEFORE the billable side-effect).
|
|
249
|
-
*/
|
|
250
|
-
declare const Purchases: PurchasesService;
|
|
251
186
|
/**
|
|
252
187
|
* Feature flags.
|
|
253
188
|
*
|
|
@@ -448,7 +383,97 @@ declare function createOps(tx: TxLike): {
|
|
|
448
383
|
limit?: number;
|
|
449
384
|
using?: string;
|
|
450
385
|
mode?: "hybrid" | "text" | "vector";
|
|
386
|
+
/** Nihai (RRF-sonrası) skor alt eşiği — süzme LIMIT'ten ÖNCE (FR-001). */
|
|
387
|
+
minScore?: number;
|
|
388
|
+
/** RRF-sonrası üstel tazelik çürümesi: _score * exp(-ln(2)*yaş/halfLife) (FR-004). */
|
|
389
|
+
recency?: {
|
|
390
|
+
field: string;
|
|
391
|
+
halfLife: string;
|
|
392
|
+
};
|
|
393
|
+
/** Chunk-modunda satır başına dönen en iyi blok sayısı (1..10, vars. 3; FR-015). */
|
|
394
|
+
blocksPerRow?: number;
|
|
395
|
+
/** Filtrelenmiş küme üzerinde kolon başına top-20 değer sayacı —
|
|
396
|
+
* dönüş dizisinin `_facets` özelliği (FR-027). */
|
|
397
|
+
facets?: string[];
|
|
398
|
+
/** Satır-modunda FTS eşleşme vurgusu: ts_headline ile `_highlight`
|
|
399
|
+
* alanı; chunk-modda no-op — bloklar zaten eşleşen kesittir (FR-025). */
|
|
400
|
+
highlight?: boolean;
|
|
401
|
+
/** Validity'li tabloda zaman penceresi: varsayılan yalnız güncel;
|
|
402
|
+
* "all" tüm versiyonlar; {asOf} o andaki geçerli versiyon (FR-029). */
|
|
403
|
+
validity?: "all" | {
|
|
404
|
+
asOf: string;
|
|
405
|
+
};
|
|
406
|
+
/** Alan-boost (FR-030): skor * (1 + w·x/(1+x)) — sınırlı, dış servissiz. */
|
|
407
|
+
boost?: {
|
|
408
|
+
field: string;
|
|
409
|
+
weight: number;
|
|
410
|
+
};
|
|
451
411
|
}): Promise<Row[]>;
|
|
412
|
+
/**
|
|
413
|
+
* similar (T018, FR-022): "bu satıra benzeyenler". Hedef vektör DB'den
|
|
414
|
+
* okunur — satır-modu satırın kendi kolonu, chunk-modu parent chunk'larının
|
|
415
|
+
* şema-nitelikli avg'ı — ve ana arama search'ün vector yoluyla koşar;
|
|
416
|
+
* kaynak satır sonuçtan düşer. İKİ tur BİLİNÇLİ (plan T018): target-CTE'li
|
|
417
|
+
* tek SQL'de "id yok" ile "0 komşu" ayrılamazdı; +1 küçük turla id-yokluğu
|
|
418
|
+
* adlandırılmış hataya çevrilir. Sonuç şekli search ile aynı (FR-015).
|
|
419
|
+
*/
|
|
420
|
+
similar(table: string, id: string, opts?: {
|
|
421
|
+
where?: Record<string, unknown>;
|
|
422
|
+
limit?: number;
|
|
423
|
+
using?: string;
|
|
424
|
+
minScore?: number;
|
|
425
|
+
recency?: {
|
|
426
|
+
field: string;
|
|
427
|
+
halfLife: string;
|
|
428
|
+
};
|
|
429
|
+
blocksPerRow?: number;
|
|
430
|
+
validity?: "all" | {
|
|
431
|
+
asOf: string;
|
|
432
|
+
};
|
|
433
|
+
boost?: {
|
|
434
|
+
field: string;
|
|
435
|
+
weight: number;
|
|
436
|
+
};
|
|
437
|
+
}): Promise<Row[]>;
|
|
438
|
+
/**
|
|
439
|
+
* recommend (T018, FR-023): positive/negative id kümelerinden öneri.
|
|
440
|
+
* Hedef vektör DB-İÇİ CTE'lerle türer: pos = avg(embedding of positives),
|
|
441
|
+
* negative varsa hedef = pos.v + (pos.v - neg.v) — pgvector avg agregası
|
|
442
|
+
* ve +/- operatörleri ŞEMA-NİTELİKLİ (M-1: search_path'e güvenilmez).
|
|
443
|
+
* Vektör matematiği istemciye inmez; bulunamayan positive/negative
|
|
444
|
+
* adlandırılmış hatadır ve kaynak id'ler sonuçtan düşer.
|
|
445
|
+
*/
|
|
446
|
+
recommend(table: string, opts: {
|
|
447
|
+
positive: unknown[];
|
|
448
|
+
negative?: unknown[];
|
|
449
|
+
where?: Record<string, unknown>;
|
|
450
|
+
limit?: number;
|
|
451
|
+
using?: string;
|
|
452
|
+
minScore?: number;
|
|
453
|
+
recency?: {
|
|
454
|
+
field: string;
|
|
455
|
+
halfLife: string;
|
|
456
|
+
};
|
|
457
|
+
blocksPerRow?: number;
|
|
458
|
+
validity?: "all" | {
|
|
459
|
+
asOf: string;
|
|
460
|
+
};
|
|
461
|
+
boost?: {
|
|
462
|
+
field: string;
|
|
463
|
+
weight: number;
|
|
464
|
+
};
|
|
465
|
+
}): Promise<Row[]>;
|
|
466
|
+
/**
|
|
467
|
+
* supersede (T021, FR-029, C-9): validity'li tabloda satırın YENİ
|
|
468
|
+
* versiyonunu TEK savepoint'te yazar — eski satır kapatılır
|
|
469
|
+
* (valid_to = now(), superseded_by = yeni pk), yeni satır eklenir, dönüş
|
|
470
|
+
* yeni satırdır. Yeni pk CLIENT'ta üretilir (row'da verilmemişse
|
|
471
|
+
* randomUUID — declared şemaların uuid().defaultRandom() standardı) ki
|
|
472
|
+
* kapatma UPDATE'i INSERT'ten ÖNCE koşabilsin: 0 satır = zaten superseded
|
|
473
|
+
* ya da yok → INSERT hiç denenmez; INSERT hatası ise savepoint'le
|
|
474
|
+
* kapatmayı da geri sarar — yarım supersede diye bir durum yoktur.
|
|
475
|
+
*/
|
|
476
|
+
supersede(table: string, id: string, row: Row): Promise<Row>;
|
|
452
477
|
/** A real SAVEPOINT inside the request's transaction. */
|
|
453
478
|
transaction<T>(cb: (t: unknown) => Promise<T>): Promise<T>;
|
|
454
479
|
/**
|
|
@@ -800,7 +825,7 @@ interface RuntimeHooks {
|
|
|
800
825
|
__requestALS: typeof __requestALS;
|
|
801
826
|
}
|
|
802
827
|
/** The module singletons the engine injects, minus the two it owns itself. */
|
|
803
|
-
type ModuleClients = Partial<Pick<RuntimeServices, "Documents" | "Storage" | "Notifications" | "Flags" | "Realtime" | "
|
|
828
|
+
type ModuleClients = Partial<Pick<RuntimeServices, "Documents" | "Storage" | "Notifications" | "Flags" | "Realtime" | "Secrets">>;
|
|
804
829
|
interface CreateAppOptions {
|
|
805
830
|
/**
|
|
806
831
|
* Vault'tan TEK secret okuma (FR-025): sorgu-anı embedding'in anahtarı
|
|
@@ -854,4 +879,4 @@ interface App {
|
|
|
854
879
|
*/
|
|
855
880
|
declare function createApp(opts: CreateAppOptions): Promise<App>;
|
|
856
881
|
|
|
857
|
-
export { type App as A, BootRefused as B, Cache as C, Database as D, type EgressPolicy as E, Flags as F,
|
|
882
|
+
export { type App as A, BootRefused as B, Cache as C, Database as D, type EgressPolicy as E, Flags as F, makeMemoryCache as G, matchRoute as H, quoteIdent as I, scrubSecrets as J, withTables as K, Log as L, type ModuleClients as M, Notifications as N, Realtime as R, Secrets as S, __getRuntime as _, Documents as a, type RequestStore as b, type RuntimeServices as c, Storage as d, __requestALS as e, __runWithRuntime as f, __setRuntime as g, AuthVerifier as h, type CreateAppOptions as i, type EngineConfig as j, RateLimiter as k, type RequestDatabase as l, type RouteEntry as m, type RuntimeHooks as n, type ScrubResult as o, type SqlDriver as p, type SqlTx as q, buildRouteTable as r, createApp as s, createLazyTransaction as t, createOps as u, createRequestDatabase as v, effectiveAuth as w, hostAllowed as x, installEgressFence as y, loadConfig as z };
|