@palbase/backend 39.0.0 → 39.1.1
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 +70 -40
- package/dist/bin/palbase-backend.cjs.map +1 -1
- package/dist/bin/palbase-backend.js +1 -1
- package/dist/{chunk-JJSR4BUX.js → chunk-C525N4OW.js} +71 -41
- package/dist/chunk-C525N4OW.js.map +1 -0
- package/dist/engine/index.cjs +70 -40
- package/dist/engine/index.cjs.map +1 -1
- package/dist/engine/index.d.cts +1 -1
- package/dist/engine/index.d.ts +1 -1
- package/dist/engine/index.js +1 -1
- package/dist/{index-B0mjUnxy.d.cts → index-Brhp8cxj.d.cts} +9 -15
- package/dist/{index-yDno9Ju9.d.ts → index-Dlu2b9-f.d.ts} +9 -15
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -12
- package/dist/index.d.ts +45 -12
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/docs/auth.md +20 -0
- package/docs/database.md +50 -0
- package/docs/llms-full.txt +70 -0
- package/package.json +1 -1
- package/dist/chunk-JJSR4BUX.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { k as PalbaseResult, l as PolicyExpr, S as SchemaDef, A as AuthSpec, H as HttpError } from './index-pK2At5Yc.cjs';
|
|
2
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-
|
|
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-
|
|
3
|
+
import { M as ModuleClients, C as Container } from './index-Brhp8cxj.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-Brhp8cxj.cjs';
|
|
5
5
|
export { TableTypes, Tables } from './db/env.cjs';
|
|
6
6
|
export { PalbaseBucketName, PalbaseFlagKey, PalbaseSecretName } from './stack.cjs';
|
|
7
7
|
import { a as RouteOptions } from './registry-9dNeVN5d.cjs';
|
|
@@ -527,6 +527,16 @@ declare function defineChannels(map: ChannelsInput): ChannelsDef;
|
|
|
527
527
|
* ) {}
|
|
528
528
|
* ```
|
|
529
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
|
+
*
|
|
530
540
|
* `Database` AMBIENT kalır ve enjekte EDİLMEZ: istek kapsamlıdır, yani bir
|
|
531
541
|
* kurucuya kapatılan bir referans bir isteğin istemcisini bir başkasına
|
|
532
542
|
* taşırdı. Tablo erişimcisi argüman olarak geçer ve her çağrıda güncel istek
|
|
@@ -562,6 +572,28 @@ interface RepositoryTable<Row, Insert, Patch> {
|
|
|
562
572
|
where: Record<string, unknown>;
|
|
563
573
|
}): Promise<number>;
|
|
564
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];
|
|
565
597
|
/**
|
|
566
598
|
* Kiracıya kapsanmış repo yüzeyi. `K` kiracı kolonu, `Row[K]` onun DEĞERİ.
|
|
567
599
|
*
|
|
@@ -571,11 +603,11 @@ interface RepositoryTable<Row, Insert, Patch> {
|
|
|
571
603
|
* taşımak tablonun `WITH CHECK` politikasının kararıdır, repo'nun değil — ve
|
|
572
604
|
* repo'nun yüklemi zaten çağıranın kiracısına kapanmış durumda.
|
|
573
605
|
*/
|
|
574
|
-
interface RepositoryOf<Row, Insert, Patch, K extends keyof Row & string
|
|
606
|
+
interface RepositoryOf<Row, Insert, Patch, K extends keyof Row & string, PK extends keyof Row & string = DefaultRowKey<Row>> {
|
|
575
607
|
/** Kiracının tüm satırları. */
|
|
576
608
|
list(tenant: Row[K]): Promise<Row[]>;
|
|
577
|
-
/** Kiracının bu
|
|
578
|
-
find(tenant: Row[K], id:
|
|
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>;
|
|
579
611
|
/** Satırı kiracıya YAZAR: kiracı kolonu yükte değil, burada. */
|
|
580
612
|
insert(tenant: Row[K], values: Omit<Insert, K>): Promise<Row>;
|
|
581
613
|
/**
|
|
@@ -585,16 +617,16 @@ interface RepositoryOf<Row, Insert, Patch, K extends keyof Row & string> {
|
|
|
585
617
|
* dallanması yazmak zorunda kalmasın. Yokluğu DEĞER olarak isteyen
|
|
586
618
|
* {@link RepositoryOf.updateScoped} kullanır.
|
|
587
619
|
*/
|
|
588
|
-
update(tenant: Row[K], id:
|
|
620
|
+
update(tenant: Row[K], id: RowKey<Row, PK>, patch: Patch): Promise<Row>;
|
|
589
621
|
/**
|
|
590
622
|
* {@link RepositoryOf.update} ile AYNI yüklem, ama bulunamazsa `null` döner.
|
|
591
623
|
*
|
|
592
624
|
* Tüketicinin bugün elle yazdığı `updateMany(…).then(rows => rows[0] ?? null)`
|
|
593
625
|
* kalıbının adı budur.
|
|
594
626
|
*/
|
|
595
|
-
updateScoped(tenant: Row[K], id:
|
|
596
|
-
/** Kiracının bu
|
|
597
|
-
delete(tenant: Row[K], id:
|
|
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>;
|
|
598
630
|
}
|
|
599
631
|
/**
|
|
600
632
|
* Kiracıya kapsanmış bir repo TABAN SINIFI üretir.
|
|
@@ -602,9 +634,10 @@ interface RepositoryOf<Row, Insert, Patch, K extends keyof Row & string> {
|
|
|
602
634
|
* Dönen sınıf `abstract`: doğrudan `new` edilemez, çünkü DI'ın çözeceği ad alt
|
|
603
635
|
* sınıfın adıdır (`TodoRepository`), üretilen anonim sınıfınki değil.
|
|
604
636
|
*/
|
|
605
|
-
declare function defineRepository<Row, Insert, Patch, K extends keyof Row & string
|
|
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: {
|
|
606
638
|
tenant: K;
|
|
607
|
-
|
|
639
|
+
key?: PK;
|
|
640
|
+
}): abstract new () => RepositoryOf<Row, Insert, Patch, K, PK>;
|
|
608
641
|
|
|
609
642
|
declare function makeEnvDts(schemas: readonly SchemaDef[]): string;
|
|
610
643
|
|
|
@@ -1254,4 +1287,4 @@ declare function getJobManifest(ctor: object): JobManifest;
|
|
|
1254
1287
|
*/
|
|
1255
1288
|
declare function getJobConfig(ctor: object, container: Container): ResolvedJob;
|
|
1256
1289
|
|
|
1257
|
-
export { type AuthHookEvent, type BackfillJSON, 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, type ForeignKeyJSON, type FreezeJSON, Get, type GuardJSON, 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, type RepositoryOf, type RepositoryTable, 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, defineRepository, 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,7 +1,7 @@
|
|
|
1
1
|
import { k as PalbaseResult, l as PolicyExpr, S as SchemaDef, A as AuthSpec, H as HttpError } from './index-eN4KzGa5.js';
|
|
2
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-
|
|
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-
|
|
3
|
+
import { M as ModuleClients, C as Container } from './index-Dlu2b9-f.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-Dlu2b9-f.js';
|
|
5
5
|
export { TableTypes, Tables } from './db/env.js';
|
|
6
6
|
export { PalbaseBucketName, PalbaseFlagKey, PalbaseSecretName } from './stack.js';
|
|
7
7
|
import { a as RouteOptions } from './registry-B8ddZiMY.js';
|
|
@@ -527,6 +527,16 @@ declare function defineChannels(map: ChannelsInput): ChannelsDef;
|
|
|
527
527
|
* ) {}
|
|
528
528
|
* ```
|
|
529
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
|
+
*
|
|
530
540
|
* `Database` AMBIENT kalır ve enjekte EDİLMEZ: istek kapsamlıdır, yani bir
|
|
531
541
|
* kurucuya kapatılan bir referans bir isteğin istemcisini bir başkasına
|
|
532
542
|
* taşırdı. Tablo erişimcisi argüman olarak geçer ve her çağrıda güncel istek
|
|
@@ -562,6 +572,28 @@ interface RepositoryTable<Row, Insert, Patch> {
|
|
|
562
572
|
where: Record<string, unknown>;
|
|
563
573
|
}): Promise<number>;
|
|
564
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];
|
|
565
597
|
/**
|
|
566
598
|
* Kiracıya kapsanmış repo yüzeyi. `K` kiracı kolonu, `Row[K]` onun DEĞERİ.
|
|
567
599
|
*
|
|
@@ -571,11 +603,11 @@ interface RepositoryTable<Row, Insert, Patch> {
|
|
|
571
603
|
* taşımak tablonun `WITH CHECK` politikasının kararıdır, repo'nun değil — ve
|
|
572
604
|
* repo'nun yüklemi zaten çağıranın kiracısına kapanmış durumda.
|
|
573
605
|
*/
|
|
574
|
-
interface RepositoryOf<Row, Insert, Patch, K extends keyof Row & string
|
|
606
|
+
interface RepositoryOf<Row, Insert, Patch, K extends keyof Row & string, PK extends keyof Row & string = DefaultRowKey<Row>> {
|
|
575
607
|
/** Kiracının tüm satırları. */
|
|
576
608
|
list(tenant: Row[K]): Promise<Row[]>;
|
|
577
|
-
/** Kiracının bu
|
|
578
|
-
find(tenant: Row[K], id:
|
|
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>;
|
|
579
611
|
/** Satırı kiracıya YAZAR: kiracı kolonu yükte değil, burada. */
|
|
580
612
|
insert(tenant: Row[K], values: Omit<Insert, K>): Promise<Row>;
|
|
581
613
|
/**
|
|
@@ -585,16 +617,16 @@ interface RepositoryOf<Row, Insert, Patch, K extends keyof Row & string> {
|
|
|
585
617
|
* dallanması yazmak zorunda kalmasın. Yokluğu DEĞER olarak isteyen
|
|
586
618
|
* {@link RepositoryOf.updateScoped} kullanır.
|
|
587
619
|
*/
|
|
588
|
-
update(tenant: Row[K], id:
|
|
620
|
+
update(tenant: Row[K], id: RowKey<Row, PK>, patch: Patch): Promise<Row>;
|
|
589
621
|
/**
|
|
590
622
|
* {@link RepositoryOf.update} ile AYNI yüklem, ama bulunamazsa `null` döner.
|
|
591
623
|
*
|
|
592
624
|
* Tüketicinin bugün elle yazdığı `updateMany(…).then(rows => rows[0] ?? null)`
|
|
593
625
|
* kalıbının adı budur.
|
|
594
626
|
*/
|
|
595
|
-
updateScoped(tenant: Row[K], id:
|
|
596
|
-
/** Kiracının bu
|
|
597
|
-
delete(tenant: Row[K], id:
|
|
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>;
|
|
598
630
|
}
|
|
599
631
|
/**
|
|
600
632
|
* Kiracıya kapsanmış bir repo TABAN SINIFI üretir.
|
|
@@ -602,9 +634,10 @@ interface RepositoryOf<Row, Insert, Patch, K extends keyof Row & string> {
|
|
|
602
634
|
* Dönen sınıf `abstract`: doğrudan `new` edilemez, çünkü DI'ın çözeceği ad alt
|
|
603
635
|
* sınıfın adıdır (`TodoRepository`), üretilen anonim sınıfınki değil.
|
|
604
636
|
*/
|
|
605
|
-
declare function defineRepository<Row, Insert, Patch, K extends keyof Row & string
|
|
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: {
|
|
606
638
|
tenant: K;
|
|
607
|
-
|
|
639
|
+
key?: PK;
|
|
640
|
+
}): abstract new () => RepositoryOf<Row, Insert, Patch, K, PK>;
|
|
608
641
|
|
|
609
642
|
declare function makeEnvDts(schemas: readonly SchemaDef[]): string;
|
|
610
643
|
|
|
@@ -1254,4 +1287,4 @@ declare function getJobManifest(ctor: object): JobManifest;
|
|
|
1254
1287
|
*/
|
|
1255
1288
|
declare function getJobConfig(ctor: object, container: Container): ResolvedJob;
|
|
1256
1289
|
|
|
1257
|
-
export { type AuthHookEvent, type BackfillJSON, 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, type ForeignKeyJSON, type FreezeJSON, Get, type GuardJSON, 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, type RepositoryOf, type RepositoryTable, 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, defineRepository, 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.js
CHANGED
|
@@ -1360,12 +1360,13 @@ __name(sameDeclaration, "sameDeclaration");
|
|
|
1360
1360
|
// src/db/repository.ts
|
|
1361
1361
|
function defineRepository(table, opts) {
|
|
1362
1362
|
const tenantColumn = opts.tenant;
|
|
1363
|
+
const rowKey = opts.key ?? "id";
|
|
1363
1364
|
const scope = /* @__PURE__ */ __name((tenant) => ({
|
|
1364
1365
|
[tenantColumn]: tenant
|
|
1365
1366
|
}), "scope");
|
|
1366
1367
|
const scopeRow = /* @__PURE__ */ __name((tenant, id) => ({
|
|
1367
1368
|
[tenantColumn]: tenant,
|
|
1368
|
-
id
|
|
1369
|
+
[rowKey]: id
|
|
1369
1370
|
}), "scopeRow");
|
|
1370
1371
|
const scopedPayload = /* @__PURE__ */ __name((values, tenant) => ({
|
|
1371
1372
|
...values,
|
|
@@ -1393,7 +1394,7 @@ function defineRepository(table, opts) {
|
|
|
1393
1394
|
async update(tenant, id, patch) {
|
|
1394
1395
|
const row = await this.updateScoped(tenant, id, patch);
|
|
1395
1396
|
if (row === null) {
|
|
1396
|
-
throw new NotFound(`${String(tenantColumn)}=${String(tenant)} kapsam\u0131nda ${id} bulunamad\u0131`);
|
|
1397
|
+
throw new NotFound(`${String(tenantColumn)}=${String(tenant)} kapsam\u0131nda ${rowKey}=${String(id)} bulunamad\u0131`);
|
|
1397
1398
|
}
|
|
1398
1399
|
return row;
|
|
1399
1400
|
}
|