@palbase/backend 38.0.16 → 39.1.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 +46 -1
- package/dist/bin/palbase-backend.cjs.map +1 -1
- package/dist/bin/palbase-backend.js +5 -5
- package/dist/{chunk-LFUNRWUE.js → chunk-4J6I4KVQ.js} +67 -3
- package/dist/{chunk-LFUNRWUE.js.map → chunk-4J6I4KVQ.js.map} +1 -1
- package/dist/{chunk-7WAGQ3VR.js → chunk-AR2I4M7I.js} +497 -17
- package/dist/chunk-AR2I4M7I.js.map +1 -0
- package/dist/{chunk-YANGWAIM.js → chunk-H7EKL6HC.js} +2 -2
- package/dist/{chunk-EHKEMHB4.js → chunk-JJSR4BUX.js} +49 -5
- package/dist/chunk-JJSR4BUX.js.map +1 -0
- package/dist/{chunk-CS6NQ6PO.js → chunk-JPTFYHP3.js} +2 -2
- package/dist/{chunk-CS6NQ6PO.js.map → chunk-JPTFYHP3.js.map} +1 -1
- package/dist/{chunk-X7UR3VXA.js → chunk-XZWOMPD3.js} +3 -2
- package/dist/chunk-XZWOMPD3.js.map +1 -0
- package/dist/{chunk-PDD55QWN.js → chunk-ZNQDL466.js} +2 -2
- package/dist/db/index.cjs +378 -14
- 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 +3 -3
- package/dist/engine/index.cjs +46 -1
- 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 +5 -5
- package/dist/{index-CI7S0Wqv.d.cts → index-B0mjUnxy.d.cts} +25 -2
- package/dist/{index-CUy50OLU.d.ts → index-eN4KzGa5.d.ts} +555 -29
- package/dist/{index-DRx880KY.d.cts → index-pK2At5Yc.d.cts} +555 -29
- package/dist/{index-Ogi30dbt.d.ts → index-yDno9Ju9.d.ts} +25 -2
- package/dist/index.cjs +629 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +216 -8
- package/dist/index.d.ts +216 -8
- package/dist/index.js +75 -6
- package/dist/index.js.map +1 -1
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.d.cts +2 -2
- package/dist/openapi/index.d.ts +2 -2
- package/dist/openapi/index.js +2 -2
- package/dist/{registry-C7UCkQf0.d.cts → registry-9dNeVN5d.d.cts} +1 -1
- package/dist/{registry-DJcvbomD.d.ts → registry-B8ddZiMY.d.ts} +1 -1
- package/dist/test/index.cjs +19 -0
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.d.cts +1 -1
- package/dist/test/index.d.ts +1 -1
- package/dist/test/index.js +20 -2
- package/dist/test/index.js.map +1 -1
- package/docs/README.md +1 -1
- package/docs/database.md +129 -0
- package/docs/llms-full.txt +512 -33
- package/docs/schema.md +382 -32
- package/package.json +1 -1
- package/template/package.json +1 -1
- package/dist/chunk-7WAGQ3VR.js.map +0 -1
- package/dist/chunk-EHKEMHB4.js.map +0 -1
- package/dist/chunk-X7UR3VXA.js.map +0 -1
- /package/dist/{chunk-YANGWAIM.js.map → chunk-H7EKL6HC.js.map} +0 -0
- /package/dist/{chunk-PDD55QWN.js.map → chunk-ZNQDL466.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { k as PalbaseResult, l as PolicyExpr, S as SchemaDef, A as AuthSpec, H as HttpError } from './index-
|
|
2
|
-
export { m as AggregateInput, n as AggregateResult, o as AnyColumn, p as AtomicDatabase, q as AtomicOptions, r as Auth, s as AuthConfig, B as
|
|
3
|
-
import { M as ModuleClients, C as Container } from './index-
|
|
4
|
-
export { D as DECLARATION_REFUSAL, a as DeclarationRefused, b as DiError, c as DiKind, d as ModulePressure, e as assertNoOrphanEntryPoints, f as buildContainer, i as isDeclarationRefused } from './index-
|
|
1
|
+
import { k as PalbaseResult, l as PolicyExpr, S as SchemaDef, A as AuthSpec, H as HttpError } from './index-pK2At5Yc.cjs';
|
|
2
|
+
export { m as AggregateInput, n as AggregateResult, o as AnyColumn, p as AtomicDatabase, q as AtomicOptions, r as Auth, s as AuthConfig, B as BackfillDef, t as BadRequest, u as Cache, i as CacheClient, v as CheckDef, w as ClientInfo, x as ColRef, y as ColumnBuilder, z as ColumnDef, F as ColumnMap, G as ColumnType, C as CommandOptions, I as Conflict, a as DBClient, e as DBOps, J as Database, D as DatabaseBudget, d as DatabaseDiagnostics, c as DatabaseDiagnosticsOptions, K as DatabaseQueryEvent, L as DeadlockDetected, M as Documents, N as EXTENSION_DEPENDENCIES, O as EmbeddingModelRef, Q as EnvSchemas, E as EnvServiceDatabase, U as EnvTables, V as EnvTypedDatabase, W as EnvTypedTable, X as ErrorDef, Y as ErrorMap, Z as ErrorThrowers, $ as FileContext, a0 as FindManyOpts, a1 as FkAction, a2 as FkMatch, a3 as Flags, a4 as Forbidden, a5 as ForeignKeyBuilder, a6 as ForeignKeyDef, a7 as FreezeBuilder, a8 as FreezeDef, a9 as GuardBuilder, aa as GuardDef, ab as GuardEvent, ac as HttpMethod, ad as IndexBuilder, ae as IndexDef, af as InsertManyOptions, ag as InsertShape, ah as InsertValues, ai as LifecycleHook, aj as Log, ak as Logger, al as Materialized, am as Middleware, an as MiddlewareContext, ao as MiddlewareHandler, ap as MutateInput, aq as NotFound, ar as Notifications, as as OnDeleteAction, at as OrderBySpec, au as PALBASE_EXTENSIONS, av as PBRequest, P as Page, aw as PageInfo, ax as PageInput, ay as PageNavigation, az as PalError, aA as PalbaseAnalyticsClient, aB as PalbaseAnalyticsManagementNamespace, aC as PalbaseAnalyticsProperties, aD as PalbaseAnalyticsQueryNamespace, aE as PalbaseAttestAndroidParams, aF as PalbaseAttestAndroidResult, aG as PalbaseAttestiOSParams, aH as PalbaseAttestiOSResult, aI as PalbaseAuthAdminClient, aJ as PalbaseAuthClient, aK as PalbaseBatchOverrideOperation, aL as PalbaseBatchSetOverridesResult, aM as PalbaseBindDeviceParams, aN as PalbaseBucketClient, aO as PalbaseClearAllOverridesResult, aP as PalbaseClearOverrideResult, aQ as PalbaseCohortQueryInput, aR as PalbaseCohortResult, aS as PalbaseCollectionRef, aT as PalbaseCountQueryInput, aU as PalbaseCountResult, aV as PalbaseCreateLinkParams, aW as PalbaseDeviceInfo, aX as PalbaseDeviceTokenView, aY as PalbaseDocsClient, aZ as PalbaseDocumentRef, a_ as PalbaseDocumentSnapshot, a$ as PalbaseEmailClient, b0 as PalbaseEmailSendParams, b1 as PalbaseEmailSendResponse, b2 as PalbaseEventNamesResult, b3 as PalbaseEventsQueryInput, b4 as PalbaseEventsResult, b5 as PalbaseExtension, b6 as PalbaseFileObject, b7 as PalbaseFlag, b8 as PalbaseFlagContext, b9 as PalbaseFlagSource, ba as PalbaseFlagValue, bb as PalbaseFlagVariant, bc as PalbaseFlagsClient, bd as PalbaseFlagsServiceClient, be as PalbaseFunctionsClient, bf as PalbaseFunnelQueryInput, bg as PalbaseFunnelResult, bh as PalbaseIdentifyTraits, bi as PalbaseInboxClient, bj as PalbaseInboxListOptions, bk as PalbaseInboxListResult, bl as PalbaseInboxMessage, bm as PalbaseInboxSendParams, bn as PalbaseInboxSendResponse, bo as PalbaseInitialLink, bp as PalbaseInvokeOptions, bq as PalbaseLink, br as PalbaseLinkAnalytics, bs as PalbaseLinkDetails, bt as PalbaseLinksClient, bu as PalbaseListLinksOptions, bv as PalbaseListLinksResult, bw as PalbaseListOptions, bx as PalbaseMatchParams, by as PalbaseMultiChannelResponse, bz as PalbaseNotificationChannel, bA as PalbaseNotificationsClient, bB as PalbaseOverviewResult, bC as PalbasePreferences, bD as PalbasePreferencesClient, bE as PalbasePushClient, bF as PalbasePushSendParams, bG as PalbasePushSendResponse, bH as PalbaseQrCodeOptions, bI as PalbaseQuerySnapshot, bJ as PalbaseRealtimeClient, bK as PalbaseRegisterDeviceParams, bL as PalbaseRetentionQueryInput, bM as PalbaseRetentionResult, bN as PalbaseSession, bO as PalbaseSetOverrideResult, bP as PalbaseSetOverridesResult, bQ as PalbaseSignedUrlResponse, bR as PalbaseSmsClient, bS as PalbaseSmsSendParams, bT as PalbaseSmsSendResponse, bU as PalbaseStorageClient, bV as PalbaseTransformOptions, bW as PalbaseUpdateLinkParams, bX as PalbaseUploadOptions, bY as PalbaseUser, bZ as PalbaseUserDetailResult, b_ as PalbaseUsersQueryInput, b$ as PalbaseUsersResult, c0 as PalbaseVerifyRequestSignatureParams, c1 as PalbaseWhatsAppClient, c2 as PalbaseWhatsAppEvent, c3 as PalbaseWhatsAppSendParams, c4 as PalbaseWhatsAppSendResponse, c5 as PalbaseWhatsAppTemplate, c6 as PalbaseWhereOperator, c7 as PolicyBinOp, c8 as PolicyBuilder, c9 as PolicyCommand, ca as PolicyDef, cb as PolicyExprCtx, cc as PolicyExprRef, cd as PolicyMode, ce as PolicyOperand, cf as QueryInput, R as RateLimitConfig, cg as RawConstraintDef, f as RawPageOptions, ch as Realtime, ci as Ref, cj as RequestStore, ck as RowShape, b as RuntimeServices, cl as Secrets, cm as SecretsService, cn as SerializationFailure, co as SetShape, cp as SetValue, cq as ShutdownRunner, cr as SqlFragment, cs as Storage, ct as TABLE_META, cu as TableDef, cv as TableHandle, cw as TableInput, cx as TableRef, cy as TooManyRequests, T as TransactionIsolation, cz as TxColumnExpr, cA as TxInsertShape, cB as TxInsertValue, cC as TxNow, cD as TxPlan, g as TxPlanBody, cE as TxPlanError, cF as TxPlanHandle, cG as TxPlanOpResult, cH as TxPlanRejection, h as TxPlanResponse, cI as TxRefError, cJ as TxRow, cK as TxRows, cL as TxSelectOptions, cM as TxSetShape, cN as TxSetValue, cO as TxTable, cP as TxTables, cQ as TxWhere, cR as TxWireExpr, cS as TxWireGuard, cT as TxWireOp, cU as TxWireRef, cV as TxWireValue, cW as TypedDB, cX as TypedTable, cY as TypedTx, cZ as Unauthorized, c_ as UniqueViolation, c$ as UniqueWhere, d0 as UserT, d1 as VerifiedDevice, d2 as WhereFilter, d3 as WhereOp, d4 as __getRuntime, j as __requestALS, d5 as __resetLifecycleHooks, d6 as __runStartHooks, _ as __runWithRuntime, d7 as __setRuntime, d8 as backfill, d9 as bigint, da as boolean, db as can, dc as check, dd as col, de as dec, df as decrement, dg as defineMiddleware, dh as defineSchema, di as defineTable, dj as enumType, dk as exprCtx, dl as foreignKey, dm as freeze, dn as guard, dp as inc, dq as increment, dr as index, ds as installationRef, dt as integer, du as isPalbaseExtension, dv as isRetryable, dw as jsonb, dx as makeTypedDB, dy as now, dz as numeric, dA as onShutdown, dB as onStart, dC as openai, dD as ownedByUser, dE as policy, dF as raw, dG as sqlFragment, dH as text, dI as timestamp, dJ as userRef, dK as uuid, dL as vector, dM as withRetry } from './index-pK2At5Yc.cjs';
|
|
3
|
+
import { M as ModuleClients, C as Container } from './index-B0mjUnxy.cjs';
|
|
4
|
+
export { D as DECLARATION_REFUSAL, a as DeclarationRefused, b as DiError, c as DiKind, d as ModulePressure, e as assertNoOrphanEntryPoints, f as buildContainer, i as isDeclarationRefused } from './index-B0mjUnxy.cjs';
|
|
5
5
|
export { TableTypes, Tables } from './db/env.cjs';
|
|
6
6
|
export { PalbaseBucketName, PalbaseFlagKey, PalbaseSecretName } from './stack.cjs';
|
|
7
|
-
import { a as RouteOptions } from './registry-
|
|
8
|
-
export { H as HttpMethodUpper, b as ParamKind, P as ParamMeta, R as RouteMeta, c as Signal, d as Sse, S as SseConfig, e as SseOut, f as SseWriter, T as ThrowDescriptor, g as Upload, U as UploadConfig, h as UploadedObject, i as getRoutes, r as recordThrows } from './registry-
|
|
7
|
+
import { a as RouteOptions } from './registry-9dNeVN5d.cjs';
|
|
8
|
+
export { H as HttpMethodUpper, b as ParamKind, P as ParamMeta, R as RouteMeta, c as Signal, d as Sse, S as SseConfig, e as SseOut, f as SseWriter, T as ThrowDescriptor, g as Upload, U as UploadConfig, h as UploadedObject, i as getRoutes, r as recordThrows } from './registry-9dNeVN5d.cjs';
|
|
9
9
|
import { ZodTypeAny, z } from 'zod';
|
|
10
10
|
export { z } from 'zod';
|
|
11
11
|
import { T as Token } from './module-Dl1KFVtc.cjs';
|
|
@@ -233,13 +233,22 @@ interface TableJSON {
|
|
|
233
233
|
rawConstraints?: {
|
|
234
234
|
name: string;
|
|
235
235
|
up: string;
|
|
236
|
-
down: string | null;
|
|
237
236
|
}[];
|
|
238
237
|
checks?: {
|
|
239
238
|
name: string;
|
|
240
239
|
expr: string;
|
|
241
240
|
}[];
|
|
242
241
|
indexes?: IndexJSON[];
|
|
242
|
+
/** Canlıdan düşürülecek constraint adları (FR-008). Sıfır değerde OMIT. */
|
|
243
|
+
dropConstraints?: string[];
|
|
244
|
+
/** Tablo düzeyi çok sütunlu FOREIGN KEY'ler (FR-001). Sıfır değerde OMIT. */
|
|
245
|
+
foreignKeys?: ForeignKeyJSON[];
|
|
246
|
+
/** Koşullu FK'lar — donan demetler (FR-012). Sıfır değerde OMIT. */
|
|
247
|
+
freeze?: FreezeJSON[];
|
|
248
|
+
/** Guard'lar — bildirimsel kısıtın yetişemediği yazma redleri (FR-015). Sıfır değerde OMIT. */
|
|
249
|
+
guards?: GuardJSON[];
|
|
250
|
+
/** Bir kez koşacak veri düzeltmeleri (FR-033). Sıfır değerde OMIT. */
|
|
251
|
+
backfills?: BackfillJSON[];
|
|
243
252
|
/**
|
|
244
253
|
* appendOnly (FR-030): tablo yalnız INSERT kabul eder. Sıfır değerde OMIT —
|
|
245
254
|
* bildirmeyen tablolar wire'da bayt-aynı kalır.
|
|
@@ -257,6 +266,8 @@ interface TableJSON {
|
|
|
257
266
|
*/
|
|
258
267
|
interface IndexJSON {
|
|
259
268
|
name: string;
|
|
269
|
+
/** `CREATE UNIQUE INDEX` (FR-007). Sıfır değerde OMIT. */
|
|
270
|
+
unique?: boolean;
|
|
260
271
|
columns: string[];
|
|
261
272
|
/** Partial index koşulu (FR-042) — filtre şekli `WhereFilter` ile aynı. */
|
|
262
273
|
where?: unknown;
|
|
@@ -269,6 +280,75 @@ interface IndexJSON {
|
|
|
269
280
|
/** Covering index — `INCLUDE (...)` (FR-043). */
|
|
270
281
|
include?: string[];
|
|
271
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Tablo düzeyi çok sütunlu FOREIGN KEY'in wire şekli — Go'nun `ForeignKeyJSON`'ı
|
|
285
|
+
* ile ALAN-ADI SÖZLEŞMESİ (FR-001). Bir ad değişirse wire sessizce kopar.
|
|
286
|
+
*
|
|
287
|
+
* `onUpdate`/`onDelete`/`match` sıfır değerinde OMIT: bildirmeyen bir FK
|
|
288
|
+
* Postgres'in varsayılanını (NO ACTION / MATCH SIMPLE) alır ve telde yer
|
|
289
|
+
* kaplamaz (NFR-006).
|
|
290
|
+
*/
|
|
291
|
+
interface ForeignKeyJSON {
|
|
292
|
+
name: string;
|
|
293
|
+
columns: string[];
|
|
294
|
+
refTable: string;
|
|
295
|
+
refColumns: string[];
|
|
296
|
+
onUpdate?: string;
|
|
297
|
+
onDelete?: string;
|
|
298
|
+
match?: string;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Koşullu FK'nın ("donan demet") wire şekli — Go'nun `FreezeJSON`'ı ile
|
|
302
|
+
* ALAN-ADI SÖZLEŞMESİ (C-8, FR-012).
|
|
303
|
+
*
|
|
304
|
+
* `when` politika ifade yapısının ta kendisi — `IndexJSON.where` ile aynı
|
|
305
|
+
* duruş: üçüncü bir yüklem lehçesi açmak, aynı sorunun iki yazımı demekti.
|
|
306
|
+
* Alanların hiçbiri opsiyonel değil: bir freeze'in koşulu, donan sütunları ve
|
|
307
|
+
* hedefi olmadan anlamı yok ve `toFreezeDef` bunları bildirim anında şart
|
|
308
|
+
* koşuyor. Sıfır değerde OMIT edilen şey DİZİNİN KENDİSİ (`TableJSON.freeze`).
|
|
309
|
+
*/
|
|
310
|
+
interface FreezeJSON {
|
|
311
|
+
name: string;
|
|
312
|
+
when: unknown;
|
|
313
|
+
columns: string[];
|
|
314
|
+
refTable: string;
|
|
315
|
+
refColumns: string[];
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Bir guard'ın wire şekli — Go'nun `GuardJSON`'ı ile ALAN-ADI SÖZLEŞMESİ
|
|
319
|
+
* (C-4/C-8, FR-015).
|
|
320
|
+
*
|
|
321
|
+
* `when` ile `exists` AYRI alanlar: Postgres bir trigger'ın `WHEN` yan
|
|
322
|
+
* tümcesinde alt sorguya izin vermiyor (`cannot use subquery in trigger WHEN
|
|
323
|
+
* condition`), yani çapraz satır yüklemi gövdedeki `EXISTS` bloğuna inmek
|
|
324
|
+
* zorunda (FR-019). Ayrımı emitter'ın yükleme bakıp tahmin etmesi yerine wire'da
|
|
325
|
+
* taşımak, o kuralı bildirimin kendi şekline yazar.
|
|
326
|
+
*
|
|
327
|
+
* `detail`/`hint`/`column` sıfır değerde OMIT — bildirmeyen bir guard telde yer
|
|
328
|
+
* kaplamaz (NFR-006). `message` her zaman var: reddin kullanıcıya ulaşan tek
|
|
329
|
+
* çıktısı o.
|
|
330
|
+
*/
|
|
331
|
+
interface GuardJSON {
|
|
332
|
+
name: string;
|
|
333
|
+
event: string;
|
|
334
|
+
when?: unknown;
|
|
335
|
+
exists?: unknown;
|
|
336
|
+
message: string;
|
|
337
|
+
detail?: string;
|
|
338
|
+
hint?: string;
|
|
339
|
+
column?: string;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Bir backfill'in wire şekli — Go'nun `BackfillJSON`'ı ile ALAN-ADI SÖZLEŞMESİ
|
|
343
|
+
* (C-8, FR-033).
|
|
344
|
+
*
|
|
345
|
+
* `name` kimliğin TAMAMI: "koştu mu" sorusu ona göre cevaplanıyor, `sql`'e göre
|
|
346
|
+
* değil. Aynı adın altında değişen bir gövde ikinci bir koşu üretmez.
|
|
347
|
+
*/
|
|
348
|
+
interface BackfillJSON {
|
|
349
|
+
name: string;
|
|
350
|
+
sql: string;
|
|
351
|
+
}
|
|
272
352
|
/** C-11 wire şekli — Go'nun MemoryJSON'ıyla alan-adı sözleşmesi (D-019).
|
|
273
353
|
* Beyansız tablolarda alan OMIT — eski şemalar bayt-aynı (NFR-B1). */
|
|
274
354
|
interface MemoryJSON {
|
|
@@ -431,6 +511,134 @@ declare function publicChannel(opts?: {
|
|
|
431
511
|
}): PublicEntry;
|
|
432
512
|
declare function defineChannels(map: ChannelsInput): ChannelsDef;
|
|
433
513
|
|
|
514
|
+
/**
|
|
515
|
+
* repository.ts — kiracıya kapsanmış CRUD'un TEK yazımı.
|
|
516
|
+
*
|
|
517
|
+
* Ölçülen kusur: tüketici katmanında 61 forwarding metodu vardı ve her biri
|
|
518
|
+
* aynı iki satırı tekrar ediyordu — kiracı kolonunu yükleme ekle, sonucu
|
|
519
|
+
* çevir. Aynı olan bir şeyi 61 kez yazmak onu 61 kez UNUTULABİLİR yapar; ve
|
|
520
|
+
* unutulan tek bir yüklem, RLS'in altında bir kiracının satırını başka bir
|
|
521
|
+
* kiracıya gösterir.
|
|
522
|
+
*
|
|
523
|
+
* ```ts
|
|
524
|
+
* export class TodoRepository extends defineRepository(
|
|
525
|
+
* Database.public.todos,
|
|
526
|
+
* { tenant: "household_id" },
|
|
527
|
+
* ) {}
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* Satır anahtarı `id` DEĞİLSE adıyla verilir — `defineTable` bir `id` kolonu
|
|
531
|
+
* şart koşmuyor, birincil anahtar herhangi bir kolonda olabilir:
|
|
532
|
+
*
|
|
533
|
+
* ```ts
|
|
534
|
+
* export class DocRepository extends defineRepository(
|
|
535
|
+
* Database.public.docs,
|
|
536
|
+
* { tenant: "org_id", key: "slug" },
|
|
537
|
+
* ) {}
|
|
538
|
+
* ```
|
|
539
|
+
*
|
|
540
|
+
* `Database` AMBIENT kalır ve enjekte EDİLMEZ: istek kapsamlıdır, yani bir
|
|
541
|
+
* kurucuya kapatılan bir referans bir isteğin istemcisini bir başkasına
|
|
542
|
+
* taşırdı. Tablo erişimcisi argüman olarak geçer ve her çağrıda güncel istek
|
|
543
|
+
* kapsamını çözen proxy'ye iner; taban sınıfın kurucusu ARGÜMANSIZ kalır, o
|
|
544
|
+
* yüzden container onu ek metadata olmadan çözer.
|
|
545
|
+
*/
|
|
546
|
+
/**
|
|
547
|
+
* Repo'nun tablodan İSTEDİĞİ dört üye — `Database.public.<t>`'nin alt kümesi.
|
|
548
|
+
*
|
|
549
|
+
* Yüklemler `Record<string, unknown>`: kiracı kolonunun adı ÇALIŞMA ANINDA
|
|
550
|
+
* gelen bir değer, ve TypeScript jenerik bir anahtarla kurulan nesne
|
|
551
|
+
* literalini mapped type'a bağlayamaz (ölçüldü: `{ [k]: v }` → `{ [x: string]:
|
|
552
|
+
* V }`, `{ [P in K]: V }`'ye atanamaz). Kapsamı DAR tutup burada gevşetmek,
|
|
553
|
+
* çağıranın tarafında `as` yazmaktan farklıdır: dışa bakan yüzey — `list`,
|
|
554
|
+
* `find`, `insert`, `update`, `updateScoped`, `delete` — tamamen tipli kalır.
|
|
555
|
+
*
|
|
556
|
+
* `NoInfer`: `Row` YALNIZ `insert`'ün dönüşünden çıkarılır. `findMany` motorda
|
|
557
|
+
* jenerik (`select`/`with`) ve kısıtlarıyla örneklendiğinde ilişki anahtarları
|
|
558
|
+
* taşıyan BAŞKA bir satır tipi önerir; iki aday birleşince satır tipi sessizce
|
|
559
|
+
* genişlerdi.
|
|
560
|
+
*/
|
|
561
|
+
interface RepositoryTable<Row, Insert, Patch> {
|
|
562
|
+
insert(data: Insert): Promise<Row>;
|
|
563
|
+
findMany(q: {
|
|
564
|
+
where: Record<string, unknown>;
|
|
565
|
+
limit?: number;
|
|
566
|
+
}): Promise<NoInfer<Row>[]>;
|
|
567
|
+
updateMany(q: {
|
|
568
|
+
where: Record<string, unknown>;
|
|
569
|
+
set: Patch;
|
|
570
|
+
}): Promise<NoInfer<Row>[]>;
|
|
571
|
+
deleteMany(q: {
|
|
572
|
+
where: Record<string, unknown>;
|
|
573
|
+
}): Promise<number>;
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Satır anahtarının VARSAYILANI: tablo bir `id` kolonu taşıyorsa `"id"`.
|
|
577
|
+
*
|
|
578
|
+
* `defineTable` bir `id` kolonu ŞART KOŞMUYOR — birincil anahtar herhangi bir
|
|
579
|
+
* kolonda `.primaryKey()` ile ya da `primaryKey: [...]` ile bildirilebiliyor.
|
|
580
|
+
* Bu yüzden anahtar sabit değil, PARAMETRE; ama `id` taşıyan tabloların
|
|
581
|
+
* (çoğunluk) hiçbir şey yazmaması gerekiyor.
|
|
582
|
+
*/
|
|
583
|
+
type DefaultRowKey<Row> = Extract<keyof Row & string, "id">;
|
|
584
|
+
/**
|
|
585
|
+
* Anahtar bulunamadığında REDDİ ADIYLA söyleyen tip.
|
|
586
|
+
*
|
|
587
|
+
* `id`'si olmayan bir tabloda `key` verilmezse {@link DefaultRowKey} `never`
|
|
588
|
+
* olur ve `Row[never]` de `never`'dır: kapı doğru kapanır ama "type 'string' is
|
|
589
|
+
* not assignable to type 'never'" diyerek ÇAREYİ söylemez. Buradaki tek alanlı
|
|
590
|
+
* arayüz aynı reddi verir ve alanın adı hatanın içinde çareyi yazar.
|
|
591
|
+
*/
|
|
592
|
+
interface MissingRowKey {
|
|
593
|
+
"defineRepository: bu satırda `id` kolonu yok — anahtarı { key: \"...\" } ile adlandır": never;
|
|
594
|
+
}
|
|
595
|
+
/** Anahtar kolonunun DEĞER tipi; anahtar bilinmiyorsa {@link MissingRowKey}. */
|
|
596
|
+
type RowKey<Row, PK extends keyof Row & string> = [PK] extends [never] ? MissingRowKey : Row[PK];
|
|
597
|
+
/**
|
|
598
|
+
* Kiracıya kapsanmış repo yüzeyi. `K` kiracı kolonu, `Row[K]` onun DEĞERİ.
|
|
599
|
+
*
|
|
600
|
+
* `insert` yükünde kiracı kolonu YOKTUR: onu repo yazar — `Omit` bunu ifade
|
|
601
|
+
* edilemez kılıyor, anlatmıyor. `update`/`updateScoped` patch'i tablonun kendi
|
|
602
|
+
* `set` şeklidir ve kiracı kolonunu DIŞLAMAZ: satırı başka bir kiracıya
|
|
603
|
+
* taşımak tablonun `WITH CHECK` politikasının kararıdır, repo'nun değil — ve
|
|
604
|
+
* repo'nun yüklemi zaten çağıranın kiracısına kapanmış durumda.
|
|
605
|
+
*/
|
|
606
|
+
interface RepositoryOf<Row, Insert, Patch, K extends keyof Row & string, PK extends keyof Row & string = DefaultRowKey<Row>> {
|
|
607
|
+
/** Kiracının tüm satırları. */
|
|
608
|
+
list(tenant: Row[K]): Promise<Row[]>;
|
|
609
|
+
/** Kiracının bu anahtarlı satırı, ya da yoksa `null` — yokluk bir DEĞER. */
|
|
610
|
+
find(tenant: Row[K], id: RowKey<Row, PK>): Promise<Row | null>;
|
|
611
|
+
/** Satırı kiracıya YAZAR: kiracı kolonu yükte değil, burada. */
|
|
612
|
+
insert(tenant: Row[K], values: Omit<Insert, K>): Promise<Row>;
|
|
613
|
+
/**
|
|
614
|
+
* Kiracının bu id'li satırını günceller ve GÜNCEL satırı döner.
|
|
615
|
+
*
|
|
616
|
+
* Eşleşen satır yoksa `NotFound` ATAR — çağıran `!` yazmak ya da `null`
|
|
617
|
+
* dallanması yazmak zorunda kalmasın. Yokluğu DEĞER olarak isteyen
|
|
618
|
+
* {@link RepositoryOf.updateScoped} kullanır.
|
|
619
|
+
*/
|
|
620
|
+
update(tenant: Row[K], id: RowKey<Row, PK>, patch: Patch): Promise<Row>;
|
|
621
|
+
/**
|
|
622
|
+
* {@link RepositoryOf.update} ile AYNI yüklem, ama bulunamazsa `null` döner.
|
|
623
|
+
*
|
|
624
|
+
* Tüketicinin bugün elle yazdığı `updateMany(…).then(rows => rows[0] ?? null)`
|
|
625
|
+
* kalıbının adı budur.
|
|
626
|
+
*/
|
|
627
|
+
updateScoped(tenant: Row[K], id: RowKey<Row, PK>, patch: Patch): Promise<Row | null>;
|
|
628
|
+
/** Kiracının bu anahtarlı satırını siler. Yoksa bir şey olmaz. */
|
|
629
|
+
delete(tenant: Row[K], id: RowKey<Row, PK>): Promise<void>;
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Kiracıya kapsanmış bir repo TABAN SINIFI üretir.
|
|
633
|
+
*
|
|
634
|
+
* Dönen sınıf `abstract`: doğrudan `new` edilemez, çünkü DI'ın çözeceği ad alt
|
|
635
|
+
* sınıfın adıdır (`TodoRepository`), üretilen anonim sınıfınki değil.
|
|
636
|
+
*/
|
|
637
|
+
declare function defineRepository<Row, Insert, Patch, K extends keyof Row & string, PK extends keyof Row & string = DefaultRowKey<Row>>(table: RepositoryTable<Row, Insert, Patch>, opts: {
|
|
638
|
+
tenant: K;
|
|
639
|
+
key?: PK;
|
|
640
|
+
}): abstract new () => RepositoryOf<Row, Insert, Patch, K, PK>;
|
|
641
|
+
|
|
434
642
|
declare function makeEnvDts(schemas: readonly SchemaDef[]): string;
|
|
435
643
|
|
|
436
644
|
/**
|
|
@@ -1079,4 +1287,4 @@ declare function getJobManifest(ctor: object): JobManifest;
|
|
|
1079
1287
|
*/
|
|
1080
1288
|
declare function getJobConfig(ctor: object, container: Container): ResolvedJob;
|
|
1081
1289
|
|
|
1082
|
-
export { type AuthHookEvent, Body, type ChannelAuthorizeCtx, type ChannelEntry, type ChannelGrant, type ChannelsDef, type ChannelsInput, Client, type ColumnJSON, Container, Controller, type ControllerOptions, type DefinedError, type DefinedErrorWithData, Delete, Deny, type DocumentHookEvent, type FileDeletedEvent, type FileUploadedEvent, Get, Headers, Hook, type HookFn, type HookMeta, HttpError, Injectable, Job, type JobMeta, type JobOptions, type ModuleClientsConfig, type ModuleTransport, On, OnAuthorize, OnEmpty, OnFirst, OnJoin, OnLeave, OnMessage, OptionalUser, PalbaseModuleError, PalbaseResult, Param, Patch, PolicyExpr, type PolicyJSON, Post, Put, Query, QueryParams, type RegisteredError, Req, RequestId, type RequestOptions, type ResolvedHookClass, type ResolvedJob, type ResolvedWebhook, RoleNotDefined, Room, type RoomOptions, RouteOptions, SchemaDef, type SchemaJSON, type SignatureSpec, type StackNames, type TableJSON, Token, TraceId, type TransportConfig, User, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __claimInjectables, __resetDefaultAuth, __resetRegisteredControllers, assertZeroArgConstructor, buildModuleClients, controllersOf, defineChannels, defineDefaultAuth, defineError, getErrorRegistry, getHookConfig, getHookManifest, getJobConfig, getJobManifest, getRegisteredControllers, getWebhookConfig, getWebhookManifest, hooksOf, jobsOf, makeEnvDts, makeHttpClient, makeStackDts, ownerOnly, publicChannel, resolveEffectiveAuth, roomsOf, toSchemaJSON, webhooksOf };
|
|
1290
|
+
export { type AuthHookEvent, type BackfillJSON, Body, type ChannelAuthorizeCtx, type ChannelEntry, type ChannelGrant, type ChannelsDef, type ChannelsInput, Client, type ColumnJSON, Container, Controller, type ControllerOptions, type DefaultRowKey, type DefinedError, type DefinedErrorWithData, Delete, Deny, type DocumentHookEvent, type FileDeletedEvent, type FileUploadedEvent, type ForeignKeyJSON, type FreezeJSON, Get, type GuardJSON, Headers, Hook, type HookFn, type HookMeta, HttpError, Injectable, Job, type JobMeta, type JobOptions, type MissingRowKey, type ModuleClientsConfig, type ModuleTransport, On, OnAuthorize, OnEmpty, OnFirst, OnJoin, OnLeave, OnMessage, OptionalUser, PalbaseModuleError, PalbaseResult, Param, Patch, PolicyExpr, type PolicyJSON, Post, Put, Query, QueryParams, type RegisteredError, type RepositoryOf, type RepositoryTable, Req, RequestId, type RequestOptions, type ResolvedHookClass, type ResolvedJob, type ResolvedWebhook, RoleNotDefined, Room, type RoomOptions, RouteOptions, type RowKey, SchemaDef, type SchemaJSON, type SignatureSpec, type StackNames, type TableJSON, Token, TraceId, type TransportConfig, User, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __claimInjectables, __resetDefaultAuth, __resetRegisteredControllers, assertZeroArgConstructor, buildModuleClients, controllersOf, defineChannels, defineDefaultAuth, defineError, defineRepository, getErrorRegistry, getHookConfig, getHookManifest, getJobConfig, getJobManifest, getRegisteredControllers, getWebhookConfig, getWebhookManifest, hooksOf, jobsOf, makeEnvDts, makeHttpClient, makeStackDts, ownerOnly, publicChannel, resolveEffectiveAuth, roomsOf, toSchemaJSON, webhooksOf };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { k as PalbaseResult, l as PolicyExpr, S as SchemaDef, A as AuthSpec, H as HttpError } from './index-
|
|
2
|
-
export { m as AggregateInput, n as AggregateResult, o as AnyColumn, p as AtomicDatabase, q as AtomicOptions, r as Auth, s as AuthConfig, B as
|
|
3
|
-
import { M as ModuleClients, C as Container } from './index-
|
|
4
|
-
export { D as DECLARATION_REFUSAL, a as DeclarationRefused, b as DiError, c as DiKind, d as ModulePressure, e as assertNoOrphanEntryPoints, f as buildContainer, i as isDeclarationRefused } from './index-
|
|
1
|
+
import { k as PalbaseResult, l as PolicyExpr, S as SchemaDef, A as AuthSpec, H as HttpError } from './index-eN4KzGa5.js';
|
|
2
|
+
export { m as AggregateInput, n as AggregateResult, o as AnyColumn, p as AtomicDatabase, q as AtomicOptions, r as Auth, s as AuthConfig, B as BackfillDef, t as BadRequest, u as Cache, i as CacheClient, v as CheckDef, w as ClientInfo, x as ColRef, y as ColumnBuilder, z as ColumnDef, F as ColumnMap, G as ColumnType, C as CommandOptions, I as Conflict, a as DBClient, e as DBOps, J as Database, D as DatabaseBudget, d as DatabaseDiagnostics, c as DatabaseDiagnosticsOptions, K as DatabaseQueryEvent, L as DeadlockDetected, M as Documents, N as EXTENSION_DEPENDENCIES, O as EmbeddingModelRef, Q as EnvSchemas, E as EnvServiceDatabase, U as EnvTables, V as EnvTypedDatabase, W as EnvTypedTable, X as ErrorDef, Y as ErrorMap, Z as ErrorThrowers, $ as FileContext, a0 as FindManyOpts, a1 as FkAction, a2 as FkMatch, a3 as Flags, a4 as Forbidden, a5 as ForeignKeyBuilder, a6 as ForeignKeyDef, a7 as FreezeBuilder, a8 as FreezeDef, a9 as GuardBuilder, aa as GuardDef, ab as GuardEvent, ac as HttpMethod, ad as IndexBuilder, ae as IndexDef, af as InsertManyOptions, ag as InsertShape, ah as InsertValues, ai as LifecycleHook, aj as Log, ak as Logger, al as Materialized, am as Middleware, an as MiddlewareContext, ao as MiddlewareHandler, ap as MutateInput, aq as NotFound, ar as Notifications, as as OnDeleteAction, at as OrderBySpec, au as PALBASE_EXTENSIONS, av as PBRequest, P as Page, aw as PageInfo, ax as PageInput, ay as PageNavigation, az as PalError, aA as PalbaseAnalyticsClient, aB as PalbaseAnalyticsManagementNamespace, aC as PalbaseAnalyticsProperties, aD as PalbaseAnalyticsQueryNamespace, aE as PalbaseAttestAndroidParams, aF as PalbaseAttestAndroidResult, aG as PalbaseAttestiOSParams, aH as PalbaseAttestiOSResult, aI as PalbaseAuthAdminClient, aJ as PalbaseAuthClient, aK as PalbaseBatchOverrideOperation, aL as PalbaseBatchSetOverridesResult, aM as PalbaseBindDeviceParams, aN as PalbaseBucketClient, aO as PalbaseClearAllOverridesResult, aP as PalbaseClearOverrideResult, aQ as PalbaseCohortQueryInput, aR as PalbaseCohortResult, aS as PalbaseCollectionRef, aT as PalbaseCountQueryInput, aU as PalbaseCountResult, aV as PalbaseCreateLinkParams, aW as PalbaseDeviceInfo, aX as PalbaseDeviceTokenView, aY as PalbaseDocsClient, aZ as PalbaseDocumentRef, a_ as PalbaseDocumentSnapshot, a$ as PalbaseEmailClient, b0 as PalbaseEmailSendParams, b1 as PalbaseEmailSendResponse, b2 as PalbaseEventNamesResult, b3 as PalbaseEventsQueryInput, b4 as PalbaseEventsResult, b5 as PalbaseExtension, b6 as PalbaseFileObject, b7 as PalbaseFlag, b8 as PalbaseFlagContext, b9 as PalbaseFlagSource, ba as PalbaseFlagValue, bb as PalbaseFlagVariant, bc as PalbaseFlagsClient, bd as PalbaseFlagsServiceClient, be as PalbaseFunctionsClient, bf as PalbaseFunnelQueryInput, bg as PalbaseFunnelResult, bh as PalbaseIdentifyTraits, bi as PalbaseInboxClient, bj as PalbaseInboxListOptions, bk as PalbaseInboxListResult, bl as PalbaseInboxMessage, bm as PalbaseInboxSendParams, bn as PalbaseInboxSendResponse, bo as PalbaseInitialLink, bp as PalbaseInvokeOptions, bq as PalbaseLink, br as PalbaseLinkAnalytics, bs as PalbaseLinkDetails, bt as PalbaseLinksClient, bu as PalbaseListLinksOptions, bv as PalbaseListLinksResult, bw as PalbaseListOptions, bx as PalbaseMatchParams, by as PalbaseMultiChannelResponse, bz as PalbaseNotificationChannel, bA as PalbaseNotificationsClient, bB as PalbaseOverviewResult, bC as PalbasePreferences, bD as PalbasePreferencesClient, bE as PalbasePushClient, bF as PalbasePushSendParams, bG as PalbasePushSendResponse, bH as PalbaseQrCodeOptions, bI as PalbaseQuerySnapshot, bJ as PalbaseRealtimeClient, bK as PalbaseRegisterDeviceParams, bL as PalbaseRetentionQueryInput, bM as PalbaseRetentionResult, bN as PalbaseSession, bO as PalbaseSetOverrideResult, bP as PalbaseSetOverridesResult, bQ as PalbaseSignedUrlResponse, bR as PalbaseSmsClient, bS as PalbaseSmsSendParams, bT as PalbaseSmsSendResponse, bU as PalbaseStorageClient, bV as PalbaseTransformOptions, bW as PalbaseUpdateLinkParams, bX as PalbaseUploadOptions, bY as PalbaseUser, bZ as PalbaseUserDetailResult, b_ as PalbaseUsersQueryInput, b$ as PalbaseUsersResult, c0 as PalbaseVerifyRequestSignatureParams, c1 as PalbaseWhatsAppClient, c2 as PalbaseWhatsAppEvent, c3 as PalbaseWhatsAppSendParams, c4 as PalbaseWhatsAppSendResponse, c5 as PalbaseWhatsAppTemplate, c6 as PalbaseWhereOperator, c7 as PolicyBinOp, c8 as PolicyBuilder, c9 as PolicyCommand, ca as PolicyDef, cb as PolicyExprCtx, cc as PolicyExprRef, cd as PolicyMode, ce as PolicyOperand, cf as QueryInput, R as RateLimitConfig, cg as RawConstraintDef, f as RawPageOptions, ch as Realtime, ci as Ref, cj as RequestStore, ck as RowShape, b as RuntimeServices, cl as Secrets, cm as SecretsService, cn as SerializationFailure, co as SetShape, cp as SetValue, cq as ShutdownRunner, cr as SqlFragment, cs as Storage, ct as TABLE_META, cu as TableDef, cv as TableHandle, cw as TableInput, cx as TableRef, cy as TooManyRequests, T as TransactionIsolation, cz as TxColumnExpr, cA as TxInsertShape, cB as TxInsertValue, cC as TxNow, cD as TxPlan, g as TxPlanBody, cE as TxPlanError, cF as TxPlanHandle, cG as TxPlanOpResult, cH as TxPlanRejection, h as TxPlanResponse, cI as TxRefError, cJ as TxRow, cK as TxRows, cL as TxSelectOptions, cM as TxSetShape, cN as TxSetValue, cO as TxTable, cP as TxTables, cQ as TxWhere, cR as TxWireExpr, cS as TxWireGuard, cT as TxWireOp, cU as TxWireRef, cV as TxWireValue, cW as TypedDB, cX as TypedTable, cY as TypedTx, cZ as Unauthorized, c_ as UniqueViolation, c$ as UniqueWhere, d0 as UserT, d1 as VerifiedDevice, d2 as WhereFilter, d3 as WhereOp, d4 as __getRuntime, j as __requestALS, d5 as __resetLifecycleHooks, d6 as __runStartHooks, _ as __runWithRuntime, d7 as __setRuntime, d8 as backfill, d9 as bigint, da as boolean, db as can, dc as check, dd as col, de as dec, df as decrement, dg as defineMiddleware, dh as defineSchema, di as defineTable, dj as enumType, dk as exprCtx, dl as foreignKey, dm as freeze, dn as guard, dp as inc, dq as increment, dr as index, ds as installationRef, dt as integer, du as isPalbaseExtension, dv as isRetryable, dw as jsonb, dx as makeTypedDB, dy as now, dz as numeric, dA as onShutdown, dB as onStart, dC as openai, dD as ownedByUser, dE as policy, dF as raw, dG as sqlFragment, dH as text, dI as timestamp, dJ as userRef, dK as uuid, dL as vector, dM as withRetry } from './index-eN4KzGa5.js';
|
|
3
|
+
import { M as ModuleClients, C as Container } from './index-yDno9Ju9.js';
|
|
4
|
+
export { D as DECLARATION_REFUSAL, a as DeclarationRefused, b as DiError, c as DiKind, d as ModulePressure, e as assertNoOrphanEntryPoints, f as buildContainer, i as isDeclarationRefused } from './index-yDno9Ju9.js';
|
|
5
5
|
export { TableTypes, Tables } from './db/env.js';
|
|
6
6
|
export { PalbaseBucketName, PalbaseFlagKey, PalbaseSecretName } from './stack.js';
|
|
7
|
-
import { a as RouteOptions } from './registry-
|
|
8
|
-
export { H as HttpMethodUpper, b as ParamKind, P as ParamMeta, R as RouteMeta, c as Signal, d as Sse, S as SseConfig, e as SseOut, f as SseWriter, T as ThrowDescriptor, g as Upload, U as UploadConfig, h as UploadedObject, i as getRoutes, r as recordThrows } from './registry-
|
|
7
|
+
import { a as RouteOptions } from './registry-B8ddZiMY.js';
|
|
8
|
+
export { H as HttpMethodUpper, b as ParamKind, P as ParamMeta, R as RouteMeta, c as Signal, d as Sse, S as SseConfig, e as SseOut, f as SseWriter, T as ThrowDescriptor, g as Upload, U as UploadConfig, h as UploadedObject, i as getRoutes, r as recordThrows } from './registry-B8ddZiMY.js';
|
|
9
9
|
import { ZodTypeAny, z } from 'zod';
|
|
10
10
|
export { z } from 'zod';
|
|
11
11
|
import { T as Token } from './module-Dl1KFVtc.js';
|
|
@@ -233,13 +233,22 @@ interface TableJSON {
|
|
|
233
233
|
rawConstraints?: {
|
|
234
234
|
name: string;
|
|
235
235
|
up: string;
|
|
236
|
-
down: string | null;
|
|
237
236
|
}[];
|
|
238
237
|
checks?: {
|
|
239
238
|
name: string;
|
|
240
239
|
expr: string;
|
|
241
240
|
}[];
|
|
242
241
|
indexes?: IndexJSON[];
|
|
242
|
+
/** Canlıdan düşürülecek constraint adları (FR-008). Sıfır değerde OMIT. */
|
|
243
|
+
dropConstraints?: string[];
|
|
244
|
+
/** Tablo düzeyi çok sütunlu FOREIGN KEY'ler (FR-001). Sıfır değerde OMIT. */
|
|
245
|
+
foreignKeys?: ForeignKeyJSON[];
|
|
246
|
+
/** Koşullu FK'lar — donan demetler (FR-012). Sıfır değerde OMIT. */
|
|
247
|
+
freeze?: FreezeJSON[];
|
|
248
|
+
/** Guard'lar — bildirimsel kısıtın yetişemediği yazma redleri (FR-015). Sıfır değerde OMIT. */
|
|
249
|
+
guards?: GuardJSON[];
|
|
250
|
+
/** Bir kez koşacak veri düzeltmeleri (FR-033). Sıfır değerde OMIT. */
|
|
251
|
+
backfills?: BackfillJSON[];
|
|
243
252
|
/**
|
|
244
253
|
* appendOnly (FR-030): tablo yalnız INSERT kabul eder. Sıfır değerde OMIT —
|
|
245
254
|
* bildirmeyen tablolar wire'da bayt-aynı kalır.
|
|
@@ -257,6 +266,8 @@ interface TableJSON {
|
|
|
257
266
|
*/
|
|
258
267
|
interface IndexJSON {
|
|
259
268
|
name: string;
|
|
269
|
+
/** `CREATE UNIQUE INDEX` (FR-007). Sıfır değerde OMIT. */
|
|
270
|
+
unique?: boolean;
|
|
260
271
|
columns: string[];
|
|
261
272
|
/** Partial index koşulu (FR-042) — filtre şekli `WhereFilter` ile aynı. */
|
|
262
273
|
where?: unknown;
|
|
@@ -269,6 +280,75 @@ interface IndexJSON {
|
|
|
269
280
|
/** Covering index — `INCLUDE (...)` (FR-043). */
|
|
270
281
|
include?: string[];
|
|
271
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Tablo düzeyi çok sütunlu FOREIGN KEY'in wire şekli — Go'nun `ForeignKeyJSON`'ı
|
|
285
|
+
* ile ALAN-ADI SÖZLEŞMESİ (FR-001). Bir ad değişirse wire sessizce kopar.
|
|
286
|
+
*
|
|
287
|
+
* `onUpdate`/`onDelete`/`match` sıfır değerinde OMIT: bildirmeyen bir FK
|
|
288
|
+
* Postgres'in varsayılanını (NO ACTION / MATCH SIMPLE) alır ve telde yer
|
|
289
|
+
* kaplamaz (NFR-006).
|
|
290
|
+
*/
|
|
291
|
+
interface ForeignKeyJSON {
|
|
292
|
+
name: string;
|
|
293
|
+
columns: string[];
|
|
294
|
+
refTable: string;
|
|
295
|
+
refColumns: string[];
|
|
296
|
+
onUpdate?: string;
|
|
297
|
+
onDelete?: string;
|
|
298
|
+
match?: string;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Koşullu FK'nın ("donan demet") wire şekli — Go'nun `FreezeJSON`'ı ile
|
|
302
|
+
* ALAN-ADI SÖZLEŞMESİ (C-8, FR-012).
|
|
303
|
+
*
|
|
304
|
+
* `when` politika ifade yapısının ta kendisi — `IndexJSON.where` ile aynı
|
|
305
|
+
* duruş: üçüncü bir yüklem lehçesi açmak, aynı sorunun iki yazımı demekti.
|
|
306
|
+
* Alanların hiçbiri opsiyonel değil: bir freeze'in koşulu, donan sütunları ve
|
|
307
|
+
* hedefi olmadan anlamı yok ve `toFreezeDef` bunları bildirim anında şart
|
|
308
|
+
* koşuyor. Sıfır değerde OMIT edilen şey DİZİNİN KENDİSİ (`TableJSON.freeze`).
|
|
309
|
+
*/
|
|
310
|
+
interface FreezeJSON {
|
|
311
|
+
name: string;
|
|
312
|
+
when: unknown;
|
|
313
|
+
columns: string[];
|
|
314
|
+
refTable: string;
|
|
315
|
+
refColumns: string[];
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Bir guard'ın wire şekli — Go'nun `GuardJSON`'ı ile ALAN-ADI SÖZLEŞMESİ
|
|
319
|
+
* (C-4/C-8, FR-015).
|
|
320
|
+
*
|
|
321
|
+
* `when` ile `exists` AYRI alanlar: Postgres bir trigger'ın `WHEN` yan
|
|
322
|
+
* tümcesinde alt sorguya izin vermiyor (`cannot use subquery in trigger WHEN
|
|
323
|
+
* condition`), yani çapraz satır yüklemi gövdedeki `EXISTS` bloğuna inmek
|
|
324
|
+
* zorunda (FR-019). Ayrımı emitter'ın yükleme bakıp tahmin etmesi yerine wire'da
|
|
325
|
+
* taşımak, o kuralı bildirimin kendi şekline yazar.
|
|
326
|
+
*
|
|
327
|
+
* `detail`/`hint`/`column` sıfır değerde OMIT — bildirmeyen bir guard telde yer
|
|
328
|
+
* kaplamaz (NFR-006). `message` her zaman var: reddin kullanıcıya ulaşan tek
|
|
329
|
+
* çıktısı o.
|
|
330
|
+
*/
|
|
331
|
+
interface GuardJSON {
|
|
332
|
+
name: string;
|
|
333
|
+
event: string;
|
|
334
|
+
when?: unknown;
|
|
335
|
+
exists?: unknown;
|
|
336
|
+
message: string;
|
|
337
|
+
detail?: string;
|
|
338
|
+
hint?: string;
|
|
339
|
+
column?: string;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Bir backfill'in wire şekli — Go'nun `BackfillJSON`'ı ile ALAN-ADI SÖZLEŞMESİ
|
|
343
|
+
* (C-8, FR-033).
|
|
344
|
+
*
|
|
345
|
+
* `name` kimliğin TAMAMI: "koştu mu" sorusu ona göre cevaplanıyor, `sql`'e göre
|
|
346
|
+
* değil. Aynı adın altında değişen bir gövde ikinci bir koşu üretmez.
|
|
347
|
+
*/
|
|
348
|
+
interface BackfillJSON {
|
|
349
|
+
name: string;
|
|
350
|
+
sql: string;
|
|
351
|
+
}
|
|
272
352
|
/** C-11 wire şekli — Go'nun MemoryJSON'ıyla alan-adı sözleşmesi (D-019).
|
|
273
353
|
* Beyansız tablolarda alan OMIT — eski şemalar bayt-aynı (NFR-B1). */
|
|
274
354
|
interface MemoryJSON {
|
|
@@ -431,6 +511,134 @@ declare function publicChannel(opts?: {
|
|
|
431
511
|
}): PublicEntry;
|
|
432
512
|
declare function defineChannels(map: ChannelsInput): ChannelsDef;
|
|
433
513
|
|
|
514
|
+
/**
|
|
515
|
+
* repository.ts — kiracıya kapsanmış CRUD'un TEK yazımı.
|
|
516
|
+
*
|
|
517
|
+
* Ölçülen kusur: tüketici katmanında 61 forwarding metodu vardı ve her biri
|
|
518
|
+
* aynı iki satırı tekrar ediyordu — kiracı kolonunu yükleme ekle, sonucu
|
|
519
|
+
* çevir. Aynı olan bir şeyi 61 kez yazmak onu 61 kez UNUTULABİLİR yapar; ve
|
|
520
|
+
* unutulan tek bir yüklem, RLS'in altında bir kiracının satırını başka bir
|
|
521
|
+
* kiracıya gösterir.
|
|
522
|
+
*
|
|
523
|
+
* ```ts
|
|
524
|
+
* export class TodoRepository extends defineRepository(
|
|
525
|
+
* Database.public.todos,
|
|
526
|
+
* { tenant: "household_id" },
|
|
527
|
+
* ) {}
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* Satır anahtarı `id` DEĞİLSE adıyla verilir — `defineTable` bir `id` kolonu
|
|
531
|
+
* şart koşmuyor, birincil anahtar herhangi bir kolonda olabilir:
|
|
532
|
+
*
|
|
533
|
+
* ```ts
|
|
534
|
+
* export class DocRepository extends defineRepository(
|
|
535
|
+
* Database.public.docs,
|
|
536
|
+
* { tenant: "org_id", key: "slug" },
|
|
537
|
+
* ) {}
|
|
538
|
+
* ```
|
|
539
|
+
*
|
|
540
|
+
* `Database` AMBIENT kalır ve enjekte EDİLMEZ: istek kapsamlıdır, yani bir
|
|
541
|
+
* kurucuya kapatılan bir referans bir isteğin istemcisini bir başkasına
|
|
542
|
+
* taşırdı. Tablo erişimcisi argüman olarak geçer ve her çağrıda güncel istek
|
|
543
|
+
* kapsamını çözen proxy'ye iner; taban sınıfın kurucusu ARGÜMANSIZ kalır, o
|
|
544
|
+
* yüzden container onu ek metadata olmadan çözer.
|
|
545
|
+
*/
|
|
546
|
+
/**
|
|
547
|
+
* Repo'nun tablodan İSTEDİĞİ dört üye — `Database.public.<t>`'nin alt kümesi.
|
|
548
|
+
*
|
|
549
|
+
* Yüklemler `Record<string, unknown>`: kiracı kolonunun adı ÇALIŞMA ANINDA
|
|
550
|
+
* gelen bir değer, ve TypeScript jenerik bir anahtarla kurulan nesne
|
|
551
|
+
* literalini mapped type'a bağlayamaz (ölçüldü: `{ [k]: v }` → `{ [x: string]:
|
|
552
|
+
* V }`, `{ [P in K]: V }`'ye atanamaz). Kapsamı DAR tutup burada gevşetmek,
|
|
553
|
+
* çağıranın tarafında `as` yazmaktan farklıdır: dışa bakan yüzey — `list`,
|
|
554
|
+
* `find`, `insert`, `update`, `updateScoped`, `delete` — tamamen tipli kalır.
|
|
555
|
+
*
|
|
556
|
+
* `NoInfer`: `Row` YALNIZ `insert`'ün dönüşünden çıkarılır. `findMany` motorda
|
|
557
|
+
* jenerik (`select`/`with`) ve kısıtlarıyla örneklendiğinde ilişki anahtarları
|
|
558
|
+
* taşıyan BAŞKA bir satır tipi önerir; iki aday birleşince satır tipi sessizce
|
|
559
|
+
* genişlerdi.
|
|
560
|
+
*/
|
|
561
|
+
interface RepositoryTable<Row, Insert, Patch> {
|
|
562
|
+
insert(data: Insert): Promise<Row>;
|
|
563
|
+
findMany(q: {
|
|
564
|
+
where: Record<string, unknown>;
|
|
565
|
+
limit?: number;
|
|
566
|
+
}): Promise<NoInfer<Row>[]>;
|
|
567
|
+
updateMany(q: {
|
|
568
|
+
where: Record<string, unknown>;
|
|
569
|
+
set: Patch;
|
|
570
|
+
}): Promise<NoInfer<Row>[]>;
|
|
571
|
+
deleteMany(q: {
|
|
572
|
+
where: Record<string, unknown>;
|
|
573
|
+
}): Promise<number>;
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Satır anahtarının VARSAYILANI: tablo bir `id` kolonu taşıyorsa `"id"`.
|
|
577
|
+
*
|
|
578
|
+
* `defineTable` bir `id` kolonu ŞART KOŞMUYOR — birincil anahtar herhangi bir
|
|
579
|
+
* kolonda `.primaryKey()` ile ya da `primaryKey: [...]` ile bildirilebiliyor.
|
|
580
|
+
* Bu yüzden anahtar sabit değil, PARAMETRE; ama `id` taşıyan tabloların
|
|
581
|
+
* (çoğunluk) hiçbir şey yazmaması gerekiyor.
|
|
582
|
+
*/
|
|
583
|
+
type DefaultRowKey<Row> = Extract<keyof Row & string, "id">;
|
|
584
|
+
/**
|
|
585
|
+
* Anahtar bulunamadığında REDDİ ADIYLA söyleyen tip.
|
|
586
|
+
*
|
|
587
|
+
* `id`'si olmayan bir tabloda `key` verilmezse {@link DefaultRowKey} `never`
|
|
588
|
+
* olur ve `Row[never]` de `never`'dır: kapı doğru kapanır ama "type 'string' is
|
|
589
|
+
* not assignable to type 'never'" diyerek ÇAREYİ söylemez. Buradaki tek alanlı
|
|
590
|
+
* arayüz aynı reddi verir ve alanın adı hatanın içinde çareyi yazar.
|
|
591
|
+
*/
|
|
592
|
+
interface MissingRowKey {
|
|
593
|
+
"defineRepository: bu satırda `id` kolonu yok — anahtarı { key: \"...\" } ile adlandır": never;
|
|
594
|
+
}
|
|
595
|
+
/** Anahtar kolonunun DEĞER tipi; anahtar bilinmiyorsa {@link MissingRowKey}. */
|
|
596
|
+
type RowKey<Row, PK extends keyof Row & string> = [PK] extends [never] ? MissingRowKey : Row[PK];
|
|
597
|
+
/**
|
|
598
|
+
* Kiracıya kapsanmış repo yüzeyi. `K` kiracı kolonu, `Row[K]` onun DEĞERİ.
|
|
599
|
+
*
|
|
600
|
+
* `insert` yükünde kiracı kolonu YOKTUR: onu repo yazar — `Omit` bunu ifade
|
|
601
|
+
* edilemez kılıyor, anlatmıyor. `update`/`updateScoped` patch'i tablonun kendi
|
|
602
|
+
* `set` şeklidir ve kiracı kolonunu DIŞLAMAZ: satırı başka bir kiracıya
|
|
603
|
+
* taşımak tablonun `WITH CHECK` politikasının kararıdır, repo'nun değil — ve
|
|
604
|
+
* repo'nun yüklemi zaten çağıranın kiracısına kapanmış durumda.
|
|
605
|
+
*/
|
|
606
|
+
interface RepositoryOf<Row, Insert, Patch, K extends keyof Row & string, PK extends keyof Row & string = DefaultRowKey<Row>> {
|
|
607
|
+
/** Kiracının tüm satırları. */
|
|
608
|
+
list(tenant: Row[K]): Promise<Row[]>;
|
|
609
|
+
/** Kiracının bu anahtarlı satırı, ya da yoksa `null` — yokluk bir DEĞER. */
|
|
610
|
+
find(tenant: Row[K], id: RowKey<Row, PK>): Promise<Row | null>;
|
|
611
|
+
/** Satırı kiracıya YAZAR: kiracı kolonu yükte değil, burada. */
|
|
612
|
+
insert(tenant: Row[K], values: Omit<Insert, K>): Promise<Row>;
|
|
613
|
+
/**
|
|
614
|
+
* Kiracının bu id'li satırını günceller ve GÜNCEL satırı döner.
|
|
615
|
+
*
|
|
616
|
+
* Eşleşen satır yoksa `NotFound` ATAR — çağıran `!` yazmak ya da `null`
|
|
617
|
+
* dallanması yazmak zorunda kalmasın. Yokluğu DEĞER olarak isteyen
|
|
618
|
+
* {@link RepositoryOf.updateScoped} kullanır.
|
|
619
|
+
*/
|
|
620
|
+
update(tenant: Row[K], id: RowKey<Row, PK>, patch: Patch): Promise<Row>;
|
|
621
|
+
/**
|
|
622
|
+
* {@link RepositoryOf.update} ile AYNI yüklem, ama bulunamazsa `null` döner.
|
|
623
|
+
*
|
|
624
|
+
* Tüketicinin bugün elle yazdığı `updateMany(…).then(rows => rows[0] ?? null)`
|
|
625
|
+
* kalıbının adı budur.
|
|
626
|
+
*/
|
|
627
|
+
updateScoped(tenant: Row[K], id: RowKey<Row, PK>, patch: Patch): Promise<Row | null>;
|
|
628
|
+
/** Kiracının bu anahtarlı satırını siler. Yoksa bir şey olmaz. */
|
|
629
|
+
delete(tenant: Row[K], id: RowKey<Row, PK>): Promise<void>;
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Kiracıya kapsanmış bir repo TABAN SINIFI üretir.
|
|
633
|
+
*
|
|
634
|
+
* Dönen sınıf `abstract`: doğrudan `new` edilemez, çünkü DI'ın çözeceği ad alt
|
|
635
|
+
* sınıfın adıdır (`TodoRepository`), üretilen anonim sınıfınki değil.
|
|
636
|
+
*/
|
|
637
|
+
declare function defineRepository<Row, Insert, Patch, K extends keyof Row & string, PK extends keyof Row & string = DefaultRowKey<Row>>(table: RepositoryTable<Row, Insert, Patch>, opts: {
|
|
638
|
+
tenant: K;
|
|
639
|
+
key?: PK;
|
|
640
|
+
}): abstract new () => RepositoryOf<Row, Insert, Patch, K, PK>;
|
|
641
|
+
|
|
434
642
|
declare function makeEnvDts(schemas: readonly SchemaDef[]): string;
|
|
435
643
|
|
|
436
644
|
/**
|
|
@@ -1079,4 +1287,4 @@ declare function getJobManifest(ctor: object): JobManifest;
|
|
|
1079
1287
|
*/
|
|
1080
1288
|
declare function getJobConfig(ctor: object, container: Container): ResolvedJob;
|
|
1081
1289
|
|
|
1082
|
-
export { type AuthHookEvent, Body, type ChannelAuthorizeCtx, type ChannelEntry, type ChannelGrant, type ChannelsDef, type ChannelsInput, Client, type ColumnJSON, Container, Controller, type ControllerOptions, type DefinedError, type DefinedErrorWithData, Delete, Deny, type DocumentHookEvent, type FileDeletedEvent, type FileUploadedEvent, Get, Headers, Hook, type HookFn, type HookMeta, HttpError, Injectable, Job, type JobMeta, type JobOptions, type ModuleClientsConfig, type ModuleTransport, On, OnAuthorize, OnEmpty, OnFirst, OnJoin, OnLeave, OnMessage, OptionalUser, PalbaseModuleError, PalbaseResult, Param, Patch, PolicyExpr, type PolicyJSON, Post, Put, Query, QueryParams, type RegisteredError, Req, RequestId, type RequestOptions, type ResolvedHookClass, type ResolvedJob, type ResolvedWebhook, RoleNotDefined, Room, type RoomOptions, RouteOptions, SchemaDef, type SchemaJSON, type SignatureSpec, type StackNames, type TableJSON, Token, TraceId, type TransportConfig, User, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __claimInjectables, __resetDefaultAuth, __resetRegisteredControllers, assertZeroArgConstructor, buildModuleClients, controllersOf, defineChannels, defineDefaultAuth, defineError, getErrorRegistry, getHookConfig, getHookManifest, getJobConfig, getJobManifest, getRegisteredControllers, getWebhookConfig, getWebhookManifest, hooksOf, jobsOf, makeEnvDts, makeHttpClient, makeStackDts, ownerOnly, publicChannel, resolveEffectiveAuth, roomsOf, toSchemaJSON, webhooksOf };
|
|
1290
|
+
export { type AuthHookEvent, type BackfillJSON, Body, type ChannelAuthorizeCtx, type ChannelEntry, type ChannelGrant, type ChannelsDef, type ChannelsInput, Client, type ColumnJSON, Container, Controller, type ControllerOptions, type DefaultRowKey, type DefinedError, type DefinedErrorWithData, Delete, Deny, type DocumentHookEvent, type FileDeletedEvent, type FileUploadedEvent, type ForeignKeyJSON, type FreezeJSON, Get, type GuardJSON, Headers, Hook, type HookFn, type HookMeta, HttpError, Injectable, Job, type JobMeta, type JobOptions, type MissingRowKey, type ModuleClientsConfig, type ModuleTransport, On, OnAuthorize, OnEmpty, OnFirst, OnJoin, OnLeave, OnMessage, OptionalUser, PalbaseModuleError, PalbaseResult, Param, Patch, PolicyExpr, type PolicyJSON, Post, Put, Query, QueryParams, type RegisteredError, type RepositoryOf, type RepositoryTable, Req, RequestId, type RequestOptions, type ResolvedHookClass, type ResolvedJob, type ResolvedWebhook, RoleNotDefined, Room, type RoomOptions, RouteOptions, type RowKey, SchemaDef, type SchemaJSON, type SignatureSpec, type StackNames, type TableJSON, Token, TraceId, type TransportConfig, User, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __claimInjectables, __resetDefaultAuth, __resetRegisteredControllers, assertZeroArgConstructor, buildModuleClients, controllersOf, defineChannels, defineDefaultAuth, defineError, defineRepository, getErrorRegistry, getHookConfig, getHookManifest, getJobConfig, getJobManifest, getRegisteredControllers, getWebhookConfig, getWebhookManifest, hooksOf, jobsOf, makeEnvDts, makeHttpClient, makeStackDts, ownerOnly, publicChannel, resolveEffectiveAuth, roomsOf, toSchemaJSON, webhooksOf };
|