@palbase/backend 30.0.1 → 33.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 +210 -24
- package/dist/bin/palbase-backend.cjs.map +1 -1
- package/dist/bin/palbase-backend.js +7 -7
- package/dist/{chunk-TWX6JTGJ.js → chunk-26GH54D2.js} +3 -5
- package/dist/{chunk-TWX6JTGJ.js.map → chunk-26GH54D2.js.map} +1 -1
- package/dist/{chunk-VVMJEVQP.js → chunk-BRLJOXWS.js} +2 -2
- package/dist/{chunk-3TUJWHC2.js → chunk-C4ZA5AT2.js} +378 -19
- package/dist/chunk-C4ZA5AT2.js.map +1 -0
- package/dist/{chunk-RADVOY7Y.js → chunk-DCDHAKF3.js} +147 -33
- package/dist/chunk-DCDHAKF3.js.map +1 -0
- package/dist/{chunk-ENZ2RFFJ.js → chunk-GOPZPM2A.js} +3 -310
- package/dist/chunk-GOPZPM2A.js.map +1 -0
- package/dist/{chunk-CGNN2PUH.js → chunk-KATPXCJ5.js} +37 -4
- package/dist/{chunk-CGNN2PUH.js.map → chunk-KATPXCJ5.js.map} +1 -1
- package/dist/{chunk-YRVIWHJC.js → chunk-N54QZER3.js} +23 -323
- package/dist/chunk-N54QZER3.js.map +1 -0
- package/dist/chunk-QMFOL2K6.js +371 -0
- package/dist/chunk-QMFOL2K6.js.map +1 -0
- package/dist/chunk-XOX6RFPZ.js +383 -0
- package/dist/chunk-XOX6RFPZ.js.map +1 -0
- package/dist/db/index.cjs +41 -2
- 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 +12 -13
- package/dist/engine/index.cjs +210 -24
- 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 +7 -7
- package/dist/{index-DtCgaZAg.d.cts → index-BWgnGj68.d.cts} +185 -35
- package/dist/{index-b-Q3l7W5.d.ts → index-Bi74dcOu.d.ts} +9 -2
- package/dist/{index-8qy3kIuA.d.ts → index-Dg10RnZO.d.ts} +185 -35
- package/dist/{index-Zi7MptvP.d.cts → index-g6iQyYci.d.cts} +9 -2
- package/dist/index.cjs +135 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -23
- package/dist/index.d.ts +6 -23
- package/dist/index.js +48 -48
- 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/openapi/index.js +3 -4
- package/dist/openapi/index.js.map +1 -1
- package/dist/{registry-CEYLH-Iz.d.cts → registry-6VT5RPeO.d.cts} +1 -1
- package/dist/{registry-BGJ-Al6F.d.ts → registry-B-sxJJN0.d.ts} +1 -1
- package/dist/test/index.cjs +733 -17
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.d.cts +59 -4
- package/dist/test/index.d.ts +59 -4
- package/dist/test/index.js +56 -16
- package/dist/test/index.js.map +1 -1
- package/docs/README.md +1 -1
- package/docs/auth.md +102 -20
- package/docs/database.md +54 -0
- package/docs/llms-full.txt +215 -21
- package/docs/schema.md +58 -0
- package/package.json +1 -1
- package/template/db/public.ts +23 -0
- package/template/package.json +1 -1
- package/dist/chunk-3TUJWHC2.js.map +0 -1
- package/dist/chunk-ENZ2RFFJ.js.map +0 -1
- package/dist/chunk-RADVOY7Y.js.map +0 -1
- package/dist/chunk-SG4UTNOP.js +0 -374
- package/dist/chunk-SG4UTNOP.js.map +0 -1
- package/dist/chunk-VXPNPVAG.js +0 -40
- package/dist/chunk-VXPNPVAG.js.map +0 -1
- package/dist/chunk-YRVIWHJC.js.map +0 -1
- /package/dist/{chunk-VVMJEVQP.js.map → chunk-BRLJOXWS.js.map} +0 -0
package/dist/engine/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import '../index-
|
|
2
|
-
export { A as App, g as AuthVerifier, B as BootRefused, h as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, j as EngineConfig, M as ModuleClients, R as RateLimiter, k as RequestDatabase, l as RouteEntry, m as RuntimeHooks, S as ScrubResult, n as SqlDriver, o as SqlTx, p as buildRouteTable, q as createApp, r as createLazyTransaction, s as createOps, t as createRequestDatabase, u as effectiveAuth, v as hostAllowed, w as installEgressFence, i as isDeclarationRefused, x as loadConfig, y as makeMemoryCache, z as matchRoute, F as quoteIdent, G as scrubSecrets, H as withTables } from '../index-
|
|
1
|
+
import '../index-BWgnGj68.cjs';
|
|
2
|
+
export { A as App, g as AuthVerifier, B as BootRefused, h as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, j as EngineConfig, M as ModuleClients, R as RateLimiter, k as RequestDatabase, l as RouteEntry, m as RuntimeHooks, S as ScrubResult, n as SqlDriver, o as SqlTx, p as buildRouteTable, q as createApp, r as createLazyTransaction, s as createOps, t as createRequestDatabase, u as effectiveAuth, v as hostAllowed, w as installEgressFence, i as isDeclarationRefused, x as loadConfig, y as makeMemoryCache, z as matchRoute, F as quoteIdent, G as scrubSecrets, H as withTables } from '../index-g6iQyYci.cjs';
|
|
3
3
|
import '../db/env.cjs';
|
|
4
4
|
import '../stack.cjs';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'node:async_hooks';
|
|
7
7
|
import '../module-Dl1KFVtc.cjs';
|
|
8
|
-
import '../registry-
|
|
8
|
+
import '../registry-6VT5RPeO.cjs';
|
package/dist/engine/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import '../index-
|
|
2
|
-
export { A as App, g as AuthVerifier, B as BootRefused, h as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, j as EngineConfig, M as ModuleClients, R as RateLimiter, k as RequestDatabase, l as RouteEntry, m as RuntimeHooks, S as ScrubResult, n as SqlDriver, o as SqlTx, p as buildRouteTable, q as createApp, r as createLazyTransaction, s as createOps, t as createRequestDatabase, u as effectiveAuth, v as hostAllowed, w as installEgressFence, i as isDeclarationRefused, x as loadConfig, y as makeMemoryCache, z as matchRoute, F as quoteIdent, G as scrubSecrets, H as withTables } from '../index-
|
|
1
|
+
import '../index-Dg10RnZO.js';
|
|
2
|
+
export { A as App, g as AuthVerifier, B as BootRefused, h as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, j as EngineConfig, M as ModuleClients, R as RateLimiter, k as RequestDatabase, l as RouteEntry, m as RuntimeHooks, S as ScrubResult, n as SqlDriver, o as SqlTx, p as buildRouteTable, q as createApp, r as createLazyTransaction, s as createOps, t as createRequestDatabase, u as effectiveAuth, v as hostAllowed, w as installEgressFence, i as isDeclarationRefused, x as loadConfig, y as makeMemoryCache, z as matchRoute, F as quoteIdent, G as scrubSecrets, H as withTables } from '../index-Bi74dcOu.js';
|
|
3
3
|
import '../db/env.js';
|
|
4
4
|
import '../stack.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'node:async_hooks';
|
|
7
7
|
import '../module-Dl1KFVtc.js';
|
|
8
|
-
import '../registry-
|
|
8
|
+
import '../registry-B-sxJJN0.js';
|
package/dist/engine/index.js
CHANGED
|
@@ -16,17 +16,17 @@ import {
|
|
|
16
16
|
quoteIdent,
|
|
17
17
|
scrubSecrets,
|
|
18
18
|
withTables
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-DCDHAKF3.js";
|
|
20
20
|
import {
|
|
21
21
|
DECLARATION_REFUSAL,
|
|
22
22
|
DeclarationRefused,
|
|
23
23
|
isDeclarationRefused
|
|
24
|
-
} from "../chunk-
|
|
25
|
-
import "../chunk-
|
|
26
|
-
import "../chunk-
|
|
27
|
-
import "../chunk-
|
|
28
|
-
import "../chunk-
|
|
29
|
-
import "../chunk-
|
|
24
|
+
} from "../chunk-N54QZER3.js";
|
|
25
|
+
import "../chunk-QMFOL2K6.js";
|
|
26
|
+
import "../chunk-XOX6RFPZ.js";
|
|
27
|
+
import "../chunk-C4ZA5AT2.js";
|
|
28
|
+
import "../chunk-BRLJOXWS.js";
|
|
29
|
+
import "../chunk-KATPXCJ5.js";
|
|
30
30
|
export {
|
|
31
31
|
AuthVerifier,
|
|
32
32
|
BootRefused,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Tables, TableTypes
|
|
1
|
+
import { Schemas, Tables, TableTypes } from './db/env.cjs';
|
|
2
2
|
import { ZodSchema, z } from 'zod';
|
|
3
3
|
import { PalbaseFlagKey, Buckets, BucketTypes, PalbaseSecretName } from './stack.cjs';
|
|
4
4
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
@@ -28,16 +28,32 @@ interface User {
|
|
|
28
28
|
/**
|
|
29
29
|
* Whether that email address has been confirmed.
|
|
30
30
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* READ FROM THE VERIFIED TOKEN (`email_verified`), so it says what was true
|
|
32
|
+
* when that token was minted: a user who confirms their address mid-session
|
|
33
|
+
* keeps reporting `false` until their next one. {@link User.roles} is the
|
|
34
|
+
* deliberate exception — it is read from the table on every request.
|
|
35
|
+
*
|
|
36
|
+
* This paragraph used to claim the opposite ("server-resolved from the
|
|
37
|
+
* verified profile, not read from the JWT") and to describe a ~30-second
|
|
38
|
+
* profile cache. Measured 2026-09-04: the engine fills this field from
|
|
39
|
+
* `claims.email_verified` and no such cache exists anywhere in the runtime.
|
|
40
|
+
* Whether the claim or a profile read is the RIGHT source is a separate
|
|
41
|
+
* question and an open one — but the type may not answer it wrongly while it
|
|
42
|
+
* is open.
|
|
34
43
|
*
|
|
35
44
|
* `false` for a phone-only user (no address to confirm) and for any user who
|
|
36
|
-
* has not clicked through yet.
|
|
37
|
-
* address confirmed" in a handler cost an extra network round-trip PER
|
|
38
|
-
* REQUEST for one boolean the runtime already had.
|
|
45
|
+
* has not clicked through yet.
|
|
39
46
|
*/
|
|
40
47
|
emailVerified: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* The caller's DATABASE role — the string RLS reads, not an application role.
|
|
50
|
+
*
|
|
51
|
+
* It is the literal `"authenticated"` for every signed-in caller and
|
|
52
|
+
* `"anon"` for every unauthenticated one, so `user.role === "admin"` is
|
|
53
|
+
* ALWAYS false and reads like a working check. Application roles are
|
|
54
|
+
* {@link User.roles}; this field says which Postgres role the request runs
|
|
55
|
+
* as, and that is the only question it answers.
|
|
56
|
+
*/
|
|
41
57
|
role: string;
|
|
42
58
|
/**
|
|
43
59
|
* The caller's APPLICATION roles, as assigned in `auth.user_roles`.
|
|
@@ -226,6 +242,13 @@ interface ColumnDef {
|
|
|
226
242
|
* is never serialized into a migration. It exists so the row surface can hand
|
|
227
243
|
* back the type the application actually works with.
|
|
228
244
|
*/
|
|
245
|
+
/**
|
|
246
|
+
* The named codec this column declares (FR-001). Unlike `transform`, the NAME
|
|
247
|
+
* survives into the runtime object, so `makeEnvDts` can emit the matching
|
|
248
|
+
* TypeScript type instead of falling back to the storage type. Not part of
|
|
249
|
+
* the DDL: the column's Postgres type is unchanged.
|
|
250
|
+
*/
|
|
251
|
+
codec?: CodecName;
|
|
229
252
|
transform?: ColumnTransform;
|
|
230
253
|
}
|
|
231
254
|
/**
|
|
@@ -240,6 +263,21 @@ interface ColumnTransform<T = unknown> {
|
|
|
240
263
|
fromDb: (value: unknown) => T;
|
|
241
264
|
toDb: (value: T) => unknown;
|
|
242
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* The closed set of named column codecs (FR-001).
|
|
268
|
+
*
|
|
269
|
+
* WHY A CLOSED SET rather than `.transform<T>()`. A transform's target type is
|
|
270
|
+
* a TYPE parameter — erased at runtime — so the generator that reads the
|
|
271
|
+
* bundled schema object cannot learn it. `palbase-env.d.ts` therefore said
|
|
272
|
+
* `string` while the engine handed the application a number, and a consumer
|
|
273
|
+
* project wrote a hand-rolled codec module plus 141 call sites to compensate.
|
|
274
|
+
*
|
|
275
|
+
* A codec is NAMED instead of typed: the name lands in `_def.codec`, travels in
|
|
276
|
+
* the runtime object to every reader, and BOTH the conversion and the emitted
|
|
277
|
+
* TypeScript type are derived from it. One declaration, one truth, and no way
|
|
278
|
+
* for the two to disagree.
|
|
279
|
+
*/
|
|
280
|
+
type CodecName = 'number' | 'decimal';
|
|
243
281
|
declare const __colKind: unique symbol;
|
|
244
282
|
declare const __colNullable: unique symbol;
|
|
245
283
|
declare const __colHasDefault: unique symbol;
|
|
@@ -418,6 +456,22 @@ declare class ColumnBuilder<K extends ColumnType = ColumnType, N extends boolean
|
|
|
418
456
|
* A transform is a PROJECTION, never a constraint: it lives only in this
|
|
419
457
|
* process, so it can neither validate nor migrate what is stored.
|
|
420
458
|
*/
|
|
459
|
+
/**
|
|
460
|
+
* Surface this exact-precision column as a JS `number` (FR-001).
|
|
461
|
+
*
|
|
462
|
+
* `numeric`/`bigint` arrive as strings because a JS number cannot hold their
|
|
463
|
+
* full range — correct, and exactly why this exists: application code that
|
|
464
|
+
* does arithmetic on the column otherwise rewrites the same `Number(row.x)` /
|
|
465
|
+
* `String(v)` pair in every caller, and each rewrite is a place the two
|
|
466
|
+
* directions can drift apart.
|
|
467
|
+
*/
|
|
468
|
+
asNumber(): ColumnBuilder<K, N, D, E, P, number>;
|
|
469
|
+
/**
|
|
470
|
+
* Surface this exact-precision column as a `string` — the value Postgres
|
|
471
|
+
* sent, DECLARED rather than defaulted (FR-001).
|
|
472
|
+
*/
|
|
473
|
+
asDecimal(): ColumnBuilder<K, N, D, E, P, string>;
|
|
474
|
+
private withCodec;
|
|
421
475
|
transform<Target>(fns: ColumnTransform<Target>): ColumnBuilder<K, N, D, E, P, Target>;
|
|
422
476
|
}
|
|
423
477
|
/**
|
|
@@ -741,6 +795,22 @@ interface PolicyDef {
|
|
|
741
795
|
withCheck: string | PolicyExpr | null;
|
|
742
796
|
permissive: boolean;
|
|
743
797
|
}
|
|
798
|
+
/**
|
|
799
|
+
* Bir politikanın adreslenebileceği Postgres rolleri.
|
|
800
|
+
*
|
|
801
|
+
* Serbest string DEĞİL, çünkü küme SABİT: bunları palbase provision ediyor,
|
|
802
|
+
* kiracı yeni bir PG rolü yaratmıyor. Serbest bırakıldığında `authenitcated`
|
|
803
|
+
* gibi bir harf hatası derlenip migration'a kadar gidiyordu — Drizzle'da da
|
|
804
|
+
* aynı boşluk ölçüldü (`to` tipi `(string & {})`, yazım hatası DDL'e geçiyor).
|
|
805
|
+
*
|
|
806
|
+
* Çalışma anı zaten fail-closed (bilinmeyen rol kapıyı kapatıyor,
|
|
807
|
+
* `session_rls_fail_closed_integration_test.go`); bu, aynı cevabı derleme
|
|
808
|
+
* anına taşıyor.
|
|
809
|
+
*
|
|
810
|
+
* `backend_*` ikizleri elle YAZILMAZ — `NormalizeDeclaredPolicies` onları
|
|
811
|
+
* kendisi ekliyor; yine de kabul ediliyor ki elle yazan kod kırılmasın.
|
|
812
|
+
*/
|
|
813
|
+
type PolicyRole = "anon" | "authenticated" | "service_role" | "backend_anon" | "backend_authenticated" | "backend_service_role";
|
|
744
814
|
declare class PolicyBuilder {
|
|
745
815
|
readonly _def: PolicyDef;
|
|
746
816
|
constructor(name: string);
|
|
@@ -755,7 +825,7 @@ declare class PolicyBuilder {
|
|
|
755
825
|
* policy("p").to("authenticated", "service_role")
|
|
756
826
|
* policy("p").to() // PUBLIC
|
|
757
827
|
*/
|
|
758
|
-
to(...roles:
|
|
828
|
+
to(...roles: PolicyRole[]): this;
|
|
759
829
|
/**
|
|
760
830
|
* `USING (...)` satır görünürlüğü ifadesi.
|
|
761
831
|
*
|
|
@@ -2549,7 +2619,7 @@ interface PalbaseLinksClient {
|
|
|
2549
2619
|
* \@Controller("/todos")
|
|
2550
2620
|
* export default class TodosController {
|
|
2551
2621
|
* \@Post("") create(\@Body(CreateTodoBody) body: CreateTodoBody): unknown {
|
|
2552
|
-
* return Database.insert(
|
|
2622
|
+
* return Database.public.todos.insert({ title: body.title });
|
|
2553
2623
|
* }
|
|
2554
2624
|
* }
|
|
2555
2625
|
*
|
|
@@ -2622,15 +2692,6 @@ interface RequestStore {
|
|
|
2622
2692
|
* client's retry replay its first result instead of charging twice. */
|
|
2623
2693
|
idempotencyKey?: string | null;
|
|
2624
2694
|
}
|
|
2625
|
-
/**
|
|
2626
|
-
* Per-request store. The persistent runtime runs each request inside
|
|
2627
|
-
* {@link __runWithRuntime}, so every async continuation of that request reads
|
|
2628
|
-
* its OWN `runtime` (and any other request-scoped fields the runtime adds).
|
|
2629
|
-
*
|
|
2630
|
-
* Exported with a `__` prefix so the runtime (worker.js) shares the SAME ALS
|
|
2631
|
-
* instance across the one module instance — two ALS instances would silently
|
|
2632
|
-
* not see each other's stores. NOT part of the public author-facing API.
|
|
2633
|
-
*/
|
|
2634
2695
|
declare const __requestALS: AsyncLocalStorage<RequestStore>;
|
|
2635
2696
|
/** Install the live clients in the process-global fallback slot.
|
|
2636
2697
|
*
|
|
@@ -2643,11 +2704,6 @@ declare function __setRuntime(services: RuntimeServices): void;
|
|
|
2643
2704
|
* The persistent worker calls this once per request so concurrent requests
|
|
2644
2705
|
* never share a services slot. NOT part of the public author-facing API. */
|
|
2645
2706
|
declare function __runWithRuntime<T>(services: RuntimeServices, fn: () => T): T;
|
|
2646
|
-
/** Read the live clients, throwing if accessed outside a request scope.
|
|
2647
|
-
*
|
|
2648
|
-
* Resolves the ALS store first (persistent server, per-request), then the
|
|
2649
|
-
* process-global fallback (dev-server / tests). NOT part of the public
|
|
2650
|
-
* author-facing API — used by the runtime and the singleton Proxies. */
|
|
2651
2707
|
declare function __getRuntime(): RuntimeServices;
|
|
2652
2708
|
/** A lifecycle hook. Sync or async; the runtime awaits what it returns. */
|
|
2653
2709
|
type LifecycleHook = () => void | Promise<void>;
|
|
@@ -2737,13 +2793,15 @@ interface RecoOps {
|
|
|
2737
2793
|
/**
|
|
2738
2794
|
* The project's own Postgres (pgx, schema `env_<envId>`).
|
|
2739
2795
|
*
|
|
2740
|
-
* Typed by default: `Database.
|
|
2796
|
+
* Typed by default: `Database.public.<name>.insert({...})` is typed against
|
|
2741
2797
|
* the project's generated `palbase-env.d.ts` with NO import and NO generic.
|
|
2742
|
-
* The raw string ops (`query
|
|
2743
|
-
* are also available for
|
|
2798
|
+
* The raw string ops (`Database.$query`/`$insert`/`$update`/`$delete`/
|
|
2799
|
+
* `$findById`/`$findMany`) are also available for read-only SQL and for a table
|
|
2800
|
+
* name only known at runtime — which the typed surface cannot express past
|
|
2801
|
+
* seven tables (see `db/tx-union-key.test-d.ts`).
|
|
2744
2802
|
*
|
|
2745
2803
|
* RLS is enforced by default (the runtime runs each op as `authenticated` with
|
|
2746
|
-
* the verified user's claims). To bypass RLS, call `Database
|
|
2804
|
+
* the verified user's claims). To bypass RLS, call `Database.$asService()` —
|
|
2747
2805
|
* explicit and greppable — which runs as the `service_role` (BYPASSRLS).
|
|
2748
2806
|
*
|
|
2749
2807
|
* @example
|
|
@@ -2758,7 +2816,7 @@ declare const Database: EnvTypedDatabase;
|
|
|
2758
2816
|
/** Firestore-like document client (PalDocs). */
|
|
2759
2817
|
declare const Documents: PalbaseDocsClient;
|
|
2760
2818
|
/**
|
|
2761
|
-
* `buckets.<name>` — the storage twin of `Database.
|
|
2819
|
+
* `buckets.<name>` — the storage twin of `Database.public.<name>`, and the same
|
|
2762
2820
|
* mechanism: `config/storage.ts` generates a `Buckets` augmentation into
|
|
2763
2821
|
* `palbase-env.d.ts`, so a bucket name is a property with no import and no
|
|
2764
2822
|
* generic, and a typo is a compile error.
|
|
@@ -2822,21 +2880,46 @@ declare const Notifications: PalbaseNotificationsClient;
|
|
|
2822
2880
|
/**
|
|
2823
2881
|
* Feature flags.
|
|
2824
2882
|
*
|
|
2825
|
-
* Mirrors the `Database` / `Database
|
|
2883
|
+
* Mirrors the `Database` / `Database.$asService()` model. The default surface is
|
|
2826
2884
|
* RLS-equivalent for flags: reads resolve against the CURRENT request user and
|
|
2827
2885
|
* `Flags.setOverride(key, value)` writes an override for that same signed-in
|
|
2828
2886
|
* user (no userId argument, no admin power). Cross-user admin writes
|
|
2829
|
-
* (`setOverrideForUser`, …) live behind `Flags
|
|
2830
|
-
* greppable, just like `Database
|
|
2887
|
+
* (`setOverrideForUser`, …) live behind `Flags.$asService()` — explicit and
|
|
2888
|
+
* greppable, just like `Database.$asService()`.
|
|
2831
2889
|
*
|
|
2832
2890
|
* @example
|
|
2833
2891
|
* import { Flags } from "@palbase/backend";
|
|
2834
2892
|
*
|
|
2835
2893
|
* if (await Flags.isEnabled("new_checkout")) { ... } // current user
|
|
2836
2894
|
* await Flags.setOverride("new_checkout", true); // current user
|
|
2837
|
-
* await Flags
|
|
2895
|
+
* await Flags.$asService().setOverrideForUser("u_9", "x", true); // cross-user
|
|
2838
2896
|
*/
|
|
2839
|
-
|
|
2897
|
+
/**
|
|
2898
|
+
* The ambient `Flags` singleton's own surface — NOT the raw client's.
|
|
2899
|
+
*
|
|
2900
|
+
* MEASURED, as a consumer, against the built tarball: annotating the singleton
|
|
2901
|
+
* as `PalbaseFlagsClient` ERASED the `$asService` that `Object.assign` adds, so
|
|
2902
|
+
* `Flags.$asService()` did not exist for anyone outside this package —
|
|
2903
|
+
*
|
|
2904
|
+
* TS2551: Property '$asService' does not exist on type 'PalbaseFlagsClient'.
|
|
2905
|
+
* Did you mean 'asService'?
|
|
2906
|
+
*
|
|
2907
|
+
* — while the only path that DID compile (`asService()`) throws by design. The
|
|
2908
|
+
* feature was written and unreachable, which is the defect class this surface
|
|
2909
|
+
* exists to remove.
|
|
2910
|
+
*
|
|
2911
|
+
* `Database` never had the problem because its singleton carries its OWN type
|
|
2912
|
+
* (`EnvTypedDatabase`) rather than the raw client's (`DBClient`). This is that,
|
|
2913
|
+
* for `Flags`. The raw `PalbaseFlagsClient.asService()` is untouched (FR-023) —
|
|
2914
|
+
* it is the seam this forwards to.
|
|
2915
|
+
*/
|
|
2916
|
+
type PalbaseFlagsAmbient = Omit<PalbaseFlagsClient, "asService"> & {
|
|
2917
|
+
/** RLS'i aşan, kullanıcılar arası yazma yüzeyi. */
|
|
2918
|
+
$asService(): PalbaseFlagsServiceClient;
|
|
2919
|
+
/** 31.0.0 öncesinin adı — SESSİZCE çalışmaz, yerini söyleyerek fırlatır. */
|
|
2920
|
+
asService(): never;
|
|
2921
|
+
};
|
|
2922
|
+
declare const Flags: PalbaseFlagsAmbient;
|
|
2840
2923
|
/**
|
|
2841
2924
|
* The Realtime broadcast singleton for the current request scope. Backend-side
|
|
2842
2925
|
* Realtime is BROADCAST-ONLY (a stateless handler can push but not subscribe —
|
|
@@ -3376,6 +3459,52 @@ type HasOnly<Rels> = [unknown] extends [Rels] ? unknown : [keyof Rels] extends [
|
|
|
3376
3459
|
* (ölçüldü: kapı yeşil, çalışma anında "böyle bir ilişki yok" hatası).
|
|
3377
3460
|
*/
|
|
3378
3461
|
type HasBranch<Row, Rels> = [unknown] extends [Rels] ? never : [keyof Rels] extends [never] ? never : WhereWithRelations<Row, Rels>;
|
|
3462
|
+
/**
|
|
3463
|
+
* `with` — İLİŞKİLİ SATIRLARI GETİR (`has` süzer, `with` getirir).
|
|
3464
|
+
*
|
|
3465
|
+
* `true` bütün kolonları, bir nesne ise `select`/`where`/`orderBy`/`limit` ile
|
|
3466
|
+
* daraltılmış hâlini getiriyor. Tek sorgu: LATERAL + `json_agg`.
|
|
3467
|
+
*/
|
|
3468
|
+
type WithOpts<To> = {
|
|
3469
|
+
select?: readonly Extract<keyof RelatedRow<To>, string>[];
|
|
3470
|
+
where?: WhereFilter<RelatedRow<To>>;
|
|
3471
|
+
orderBy?: OrderBySpec<RelatedRow<To>> | readonly OrderBySpec<RelatedRow<To>>[];
|
|
3472
|
+
limit?: number;
|
|
3473
|
+
};
|
|
3474
|
+
type WithInput<Rels> = {
|
|
3475
|
+
[R in keyof Rels]?: Rels[R] extends {
|
|
3476
|
+
to: infer To;
|
|
3477
|
+
} ? true | WithOpts<To> : never;
|
|
3478
|
+
};
|
|
3479
|
+
/** Bir `with` dalının DÖNÜŞ tipi — `many` dizi, `one` tekil ya da null. */
|
|
3480
|
+
type WithRowOf<Rels, R extends keyof Rels, Q> = Rels[R] extends {
|
|
3481
|
+
to: infer To;
|
|
3482
|
+
kind: infer K;
|
|
3483
|
+
} ? (Q extends {
|
|
3484
|
+
select: readonly (infer C extends keyof RelatedRow<To>)[];
|
|
3485
|
+
} ? Pick<RelatedRow<To>, C> : RelatedRow<To>) extends infer Row ? [K] extends ["many"] ? Row[] : Row | null : never : never;
|
|
3486
|
+
/**
|
|
3487
|
+
* `with` istenmediğinde `unknown` — kesişimde YOK OLSUN diye.
|
|
3488
|
+
*
|
|
3489
|
+
* Boş bir nesne (`{}`) dönseydi `Pick<Row, K> & {}` satır tipini "aynı ama
|
|
3490
|
+
* özdeş değil" hâle getirirdi ve tam eşitlik iddiaları kırılırdı. Ölçüldü:
|
|
3491
|
+
* `toEqualTypeOf` dört yerde düştü.
|
|
3492
|
+
*/
|
|
3493
|
+
/**
|
|
3494
|
+
* Yalnız GERÇEKTEN istenen dallar. `undefined extends W[R]` olan anahtarlar
|
|
3495
|
+
* düşüyor — ve bu, `ReturnType<typeof t.findMany>` yazan herkes için kritik:
|
|
3496
|
+
* generic bir imzada `ReturnType` tip parametrelerini VARSAYILANLA değil
|
|
3497
|
+
* KISITLA örnekliyor, yani `W = WithInput<Rels>` oluyor ve her ilişki
|
|
3498
|
+
* (`?:` ile, dolayısıyla `| undefined`) zorunlu bir alana dönüşüyordu.
|
|
3499
|
+
* Gerçek projede ölçüldü: `type MemberRow = Awaited<ReturnType<…findMany>>[number]`
|
|
3500
|
+
* 32 ilişkiyi birden ister hâle geldi ve 4 yerde kırıldı.
|
|
3501
|
+
*/
|
|
3502
|
+
type RequestedWith<W> = {
|
|
3503
|
+
[R in keyof W]-?: undefined extends W[R] ? never : R;
|
|
3504
|
+
}[keyof W];
|
|
3505
|
+
type WithResult<Rels, W> = [RequestedWith<W>] extends [never] ? unknown : {
|
|
3506
|
+
[R in RequestedWith<W> & keyof Rels]: WithRowOf<Rels, R, W[R]>;
|
|
3507
|
+
};
|
|
3379
3508
|
type QueryInput<Row, K extends keyof Row = keyof Row, Rels = unknown> = {
|
|
3380
3509
|
/**
|
|
3381
3510
|
* Filtre — ya tipli filtre dili ya da bir `sqlFragment` (FR-018). İkisi de
|
|
@@ -3383,6 +3512,25 @@ type QueryInput<Row, K extends keyof Row = keyof Row, Rels = unknown> = {
|
|
|
3383
3512
|
* yolu değil (P1).
|
|
3384
3513
|
*/
|
|
3385
3514
|
where?: WhereFilter<Row> | SqlFragment | HasBranch<Row, Rels>;
|
|
3515
|
+
/**
|
|
3516
|
+
* İlişkili satırları da getir — TEK sorguda.
|
|
3517
|
+
*
|
|
3518
|
+
* ```ts
|
|
3519
|
+
* const rows = await Database.public.users.findMany({
|
|
3520
|
+
* where: { active: true },
|
|
3521
|
+
* with: { orders: { select: ["id", "amount"], limit: 5 } },
|
|
3522
|
+
* });
|
|
3523
|
+
* rows[0].orders[0].amount; // string — KAYIPSIZ
|
|
3524
|
+
* ```
|
|
3525
|
+
*
|
|
3526
|
+
* `many` ilişki DİZİ döner (boşsa `[]`, `null` değil — `.map()` guard
|
|
3527
|
+
* istemesin); `one` ilişki tekil satır ya da `null`.
|
|
3528
|
+
*
|
|
3529
|
+
* PARA: `numeric`/`bigint` kolonları JSON'a `::text` ile giriyor. Cast
|
|
3530
|
+
* olmadan `numeric` bir JSON SAYISI olur ve kesinliğini kaybeder — ölçüldü,
|
|
3531
|
+
* `100000000000000000000000000` → `1e+26`.
|
|
3532
|
+
*/
|
|
3533
|
+
with?: [unknown] extends [Rels] ? never : [keyof Rels] extends [never] ? never : WithInput<Rels>;
|
|
3386
3534
|
/**
|
|
3387
3535
|
* Projeksiyon (FR-009): yalnız bu kolonlar çekilir ve DÖNÜŞ TİPİ buna daralır.
|
|
3388
3536
|
*
|
|
@@ -3655,7 +3803,9 @@ interface EnvTypedTableBase<T extends TableTypes> {
|
|
|
3655
3803
|
findById(id: string): Promise<T["row"] | null>;
|
|
3656
3804
|
/** Rows matching the filter. See {@link WhereFilter} / {@link FindManyOpts} —
|
|
3657
3805
|
* this declaration is what makes the engine's operators callable. */
|
|
3658
|
-
findMany<K extends keyof T["row"] = keyof T["row"]
|
|
3806
|
+
findMany<K extends keyof T["row"] = keyof T["row"], W extends WithInput<RelsOf<T>> = Record<never, never>>(q?: QueryInput<T["row"], K, RelsOf<T>> & {
|
|
3807
|
+
with?: W;
|
|
3808
|
+
}): Promise<Array<Pick<T["row"], K> & WithResult<RelsOf<T>, W>>>;
|
|
3659
3809
|
/**
|
|
3660
3810
|
* Update every matching row in one statement; an empty filter is refused.
|
|
3661
3811
|
*
|
|
@@ -5160,4 +5310,4 @@ type Middleware = (ctx: MiddlewareContext, next: () => Promise<void>) => Promise
|
|
|
5160
5310
|
*/
|
|
5161
5311
|
type AuthSpec = boolean | Partial<AuthConfig>;
|
|
5162
5312
|
|
|
5163
|
-
export {
|
|
5313
|
+
export { type Materialized as $, type AuthSpec as A, BadRequest as B, type CacheClient as C, type DBClient as D, type EnvServiceDatabase as E, type EnvTypedTable as F, type ErrorDef as G, HttpError as H, type ErrorMap as I, type ErrorThrowers as J, type FileContext as K, type FindManyOpts as L, Flags as M, Forbidden as N, type HttpMethod as O, type PalbaseResult as P, IndexBuilder as Q, type RateLimitConfig as R, type SchemaDef as S, type TxPlanBody as T, type IndexDef as U, type InsertShape as V, type InsertValues as W, type LifecycleHook as X, Log as Y, type Logger as Z, __runWithRuntime as _, type RuntimeServices as a, type PalbaseInitialLink as a$, type Middleware as a0, type MiddlewareContext as a1, type MiddlewareHandler as a2, type MutateInput as a3, NotFound as a4, Notifications as a5, type OnDeleteAction as a6, type OrderBySpec as a7, PALBASE_EXTENSIONS as a8, type PBRequest as a9, type PalbaseDocumentRef as aA, type PalbaseDocumentSnapshot as aB, type PalbaseEmailClient as aC, type PalbaseEmailSendParams as aD, type PalbaseEmailSendResponse as aE, type PalbaseEventNamesResult as aF, type PalbaseEventsQueryInput as aG, type PalbaseEventsResult as aH, type PalbaseExtension as aI, type PalbaseFileObject as aJ, type PalbaseFlag as aK, type PalbaseFlagContext as aL, type PalbaseFlagSource as aM, type PalbaseFlagValue as aN, type PalbaseFlagVariant as aO, type PalbaseFlagsClient as aP, type PalbaseFlagsServiceClient as aQ, type PalbaseFunctionsClient as aR, type PalbaseFunnelQueryInput as aS, type PalbaseFunnelResult as aT, type PalbaseIdentifyTraits as aU, type PalbaseInboxClient as aV, type PalbaseInboxListOptions as aW, type PalbaseInboxListResult as aX, type PalbaseInboxMessage as aY, type PalbaseInboxSendParams as aZ, type PalbaseInboxSendResponse as a_, PalError as aa, type PalbaseAnalyticsClient as ab, type PalbaseAnalyticsManagementNamespace as ac, type PalbaseAnalyticsProperties as ad, type PalbaseAnalyticsQueryNamespace as ae, type PalbaseAttestAndroidParams as af, type PalbaseAttestAndroidResult as ag, type PalbaseAttestiOSParams as ah, type PalbaseAttestiOSResult as ai, type PalbaseAuthAdminClient as aj, type PalbaseAuthClient as ak, type PalbaseBatchOverrideOperation as al, type PalbaseBatchSetOverridesResult as am, type PalbaseBindDeviceParams as an, type PalbaseBucketClient as ao, type PalbaseClearAllOverridesResult as ap, type PalbaseClearOverrideResult as aq, type PalbaseCohortQueryInput as ar, type PalbaseCohortResult as as, type PalbaseCollectionRef as at, type PalbaseCountQueryInput as au, type PalbaseCountResult as av, type PalbaseCreateLinkParams as aw, type PalbaseDeviceInfo as ax, type PalbaseDeviceTokenView as ay, type PalbaseDocsClient as az, type DBOps as b, type TableDef as b$, type PalbaseInvokeOptions as b0, type PalbaseLink as b1, type PalbaseLinkAnalytics as b2, type PalbaseLinkDetails as b3, type PalbaseLinksClient as b4, type PalbaseListLinksOptions as b5, type PalbaseListLinksResult as b6, type PalbaseListOptions as b7, type PalbaseMatchParams as b8, type PalbaseMultiChannelResponse as b9, type PalbaseUsersQueryInput as bA, type PalbaseUsersResult as bB, type PalbaseVerifyRequestSignatureParams as bC, type PalbaseWhereOperator as bD, type PolicyBinOp as bE, PolicyBuilder as bF, type PolicyCommand as bG, type PolicyDef as bH, type PolicyExprCtx as bI, PolicyExprRef as bJ, type PolicyMode as bK, type PolicyOperand as bL, type QueryInput as bM, type RawConstraintDef as bN, Realtime as bO, type Ref as bP, type RequestStore as bQ, type RowShape as bR, Secrets as bS, type SecretsService as bT, SerializationFailure as bU, type SetShape as bV, type SetValue as bW, type ShutdownRunner as bX, type SqlFragment as bY, Storage as bZ, TABLE_META as b_, type PalbaseNotificationsClient as ba, type PalbaseOverviewResult as bb, type PalbasePreferences as bc, type PalbasePreferencesClient as bd, type PalbasePushClient as be, type PalbasePushSendParams as bf, type PalbasePushSendResponse as bg, type PalbaseQrCodeOptions as bh, type PalbaseQuerySnapshot as bi, type PalbaseRealtimeClient as bj, type PalbaseRegisterDeviceParams as bk, type PalbaseRetentionQueryInput as bl, type PalbaseRetentionResult as bm, type PalbaseSession as bn, type PalbaseSetOverrideResult as bo, type PalbaseSetOverridesResult as bp, type PalbaseSignedUrlResponse as bq, type PalbaseSmsClient as br, type PalbaseSmsSendParams as bs, type PalbaseSmsSendResponse as bt, type PalbaseStorageClient as bu, type PalbaseTransformOptions as bv, type PalbaseUpdateLinkParams as bw, type PalbaseUploadOptions as bx, type PalbaseUser as by, type PalbaseUserDetailResult as bz, type TxPlanResponse as c, ownedByUser as c$, type TableHandle as c0, type TableInput as c1, TooManyRequests as c2, type TxColumnExpr as c3, type TxInsertShape as c4, type TxInsertValue as c5, type TxNow as c6, type TxPlan as c7, TxPlanError as c8, type TxPlanHandle as c9, __resetLifecycleHooks as cA, __runStartHooks as cB, __setRuntime as cC, bigint as cD, boolean as cE, col as cF, dec as cG, decrement as cH, defineMiddleware as cI, defineSchema as cJ, defineTable as cK, enumType as cL, exprCtx as cM, inc as cN, increment as cO, index as cP, installationRef as cQ, integer as cR, isPalbaseExtension as cS, isRetryable as cT, jsonb as cU, makeTypedDB as cV, now as cW, numeric as cX, onShutdown as cY, onStart as cZ, openai as c_, type TxPlanOpResult as ca, type TxPlanRejection as cb, TxRefError as cc, type TxRow as cd, type TxRows as ce, type TxSelectOptions as cf, type TxSetShape as cg, type TxSetValue as ch, type TxTable as ci, type TxTables as cj, type TxWhere as ck, type TxWireExpr as cl, type TxWireGuard as cm, type TxWireOp as cn, type TxWireRef as co, type TxWireValue as cp, type TypedDB as cq, type TypedTable as cr, type TypedTx as cs, Unauthorized as ct, UniqueViolation as cu, type User as cv, type VerifiedDevice as cw, type WhereFilter as cx, type WhereOp as cy, __getRuntime as cz, __requestALS as d, policy as d0, raw as d1, sqlFragment as d2, text as d3, timestamp as d4, userRef as d5, uuid as d6, vector as d7, withRetry as d8, type PolicyExpr as e, type AggregateInput as f, type AggregateResult as g, type AnyColumn as h, Auth as i, type AuthConfig as j, Cache as k, type ClientInfo as l, type ColRef as m, ColumnBuilder as n, type ColumnDef as o, type ColumnMap as p, type ColumnType as q, Conflict as r, Database as s, DeadlockDetected as t, Documents as u, EXTENSION_DEPENDENCIES as v, type EmbeddingModelRef as w, type EnvSchemas as x, type EnvTables as y, type EnvTypedDatabase as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DBClient,
|
|
1
|
+
import { D as DBClient, b as DBOps, T as TxPlanBody, c as TxPlanResponse, A as AuthSpec, C as CacheClient, a as RuntimeServices, _ as __runWithRuntime, d as __requestALS } from './index-Dg10RnZO.js';
|
|
2
2
|
import { T as Token } from './module-Dl1KFVtc.js';
|
|
3
|
-
import { R as RouteMeta } from './registry-
|
|
3
|
+
import { R as RouteMeta } from './registry-B-sxJJN0.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* engine/config.ts — settings from the environment, and the gate that refuses
|
|
@@ -174,6 +174,13 @@ interface FindManyOptions {
|
|
|
174
174
|
/** Projeksiyon (FR-009): verilmezse `SELECT *`. Kolon adları ŞEMAYA karşı
|
|
175
175
|
* doğrulanır — bilinmeyen ad SQL'e ulaşmadan, adıyla reddedilir. */
|
|
176
176
|
select?: string[];
|
|
177
|
+
/**
|
|
178
|
+
* İLİŞKİLİ SATIRLARI da getir — TEK sorguda, LATERAL ile.
|
|
179
|
+
*
|
|
180
|
+
* `has` ilişki üzerinden SÜZER, `with` GETİRİR. İkisi aynı ilişki grafiğini
|
|
181
|
+
* okuyor (yabancı anahtarlardan türetilmiş), yani ilişki adları aynı.
|
|
182
|
+
*/
|
|
183
|
+
with?: Record<string, unknown>;
|
|
177
184
|
limit?: number;
|
|
178
185
|
/** Rows to skip before the page starts. Only meaningful with `limit`, and
|
|
179
186
|
* refused without it — see `offsetClause`. */
|