@vritti/api-sdk 0.2.4 → 0.2.5

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/index.d.cts CHANGED
@@ -12,21 +12,6 @@ import { PgTable } from 'drizzle-orm/pg-core';
12
12
  import { Observable } from 'rxjs';
13
13
  import { AsyncLocalStorage } from 'node:async_hooks';
14
14
 
15
- interface TenantInfo {
16
- id: string;
17
- subdomain: string;
18
- type: 'SHARED' | 'DEDICATED';
19
- status: string;
20
- schemaName?: string;
21
- databaseName?: string;
22
- databaseHost?: string;
23
- databasePort?: number;
24
- databaseUsername?: string;
25
- databasePassword?: string;
26
- databaseSslMode?: string;
27
- connectionPoolSize?: number;
28
- }
29
-
30
15
  declare module 'fastify' {
31
16
  interface FastifyRequest {
32
17
  sessionInfo?: {
@@ -34,7 +19,6 @@ declare module 'fastify' {
34
19
  sessionId: string;
35
20
  sessionType: string;
36
21
  };
37
- tenant?: TenantInfo;
38
22
  cookies?: Record<string, string>;
39
23
  }
40
24
  }
@@ -47,16 +31,16 @@ declare const AccessToken: (...dataOrPipes: unknown[]) => ParameterDecorator;
47
31
 
48
32
  declare const CookieDomain: (...dataOrPipes: unknown[]) => ParameterDecorator;
49
33
 
50
- declare const Onboarding: () => _nestjs_common.CustomDecorator<string>;
51
-
52
34
  declare const Public: () => _nestjs_common.CustomDecorator<string>;
53
35
 
54
36
  declare const RefreshCookieOptions: (...dataOrPipes: unknown[]) => ParameterDecorator;
55
37
 
56
38
  declare const RefreshTokenCookie: (...dataOrPipes: unknown[]) => ParameterDecorator;
57
39
 
58
- declare const RESET_KEY = "isReset";
59
- declare const Reset: () => _nestjs_common.CustomDecorator<string>;
40
+ declare const REQUIRE_SESSION_KEY = "requiredSessionTypes";
41
+ declare const RequireSession: (...types: string[]) => _nestjs_common.CustomDecorator<string>;
42
+
43
+ declare const Subdomain: (...dataOrPipes: unknown[]) => ParameterDecorator;
60
44
 
61
45
  interface SessionInfo {
62
46
  userId: string;
@@ -204,6 +188,7 @@ interface GuardConfig {
204
188
  tenantHeaderName: string;
205
189
  authHeaderName: string;
206
190
  tokenPrefix: string;
191
+ defaultSessionTypes: string[];
207
192
  }
208
193
  interface ApiSdkConfig {
209
194
  cookie?: Partial<CookieConfig>;
@@ -248,9 +233,7 @@ interface DatabaseModuleOptions {
248
233
  primaryDb: PrimaryDbConfig;
249
234
  drizzleSchema: RegisteredSchema;
250
235
  drizzleRelations?: Record<string, any>;
251
- connectionCacheTTL?: number;
252
236
  maxConnections?: number;
253
- encryptionKey?: string;
254
237
  }
255
238
 
256
239
  declare class DatabaseModule {
@@ -258,14 +241,56 @@ declare class DatabaseModule {
258
241
  useFactory: (...args: unknown[]) => Promise<DatabaseModuleOptions> | DatabaseModuleOptions;
259
242
  inject?: InjectionToken[];
260
243
  }): DynamicModule;
261
- static forMicroservice(options: {
262
- useFactory: (...args: unknown[]) => Promise<DatabaseModuleOptions> | DatabaseModuleOptions;
263
- inject?: InjectionToken[];
264
- }): DynamicModule;
265
- private static createDynamicModule;
266
244
  }
267
245
 
268
- declare const Tenant: (...dataOrPipes: unknown[]) => ParameterDecorator;
246
+ interface UploadedFileResult {
247
+ buffer: Buffer;
248
+ filename: string;
249
+ mimetype: string;
250
+ }
251
+ /**
252
+ * Extracts a single uploaded file from a Fastify multipart request.
253
+ *
254
+ * Requires `@fastify/multipart` to be registered on the Fastify instance.
255
+ * Throws `BadRequestException` if no file is present in the request.
256
+ *
257
+ * @example
258
+ * ```typescript
259
+ * @Post('upload')
260
+ * @ApiConsumes('multipart/form-data')
261
+ * async upload(@UploadedFile() file: UploadedFileResult) {
262
+ * // file.buffer, file.filename, file.mimetype
263
+ * }
264
+ * ```
265
+ */
266
+ declare const UploadedFile: (...dataOrPipes: unknown[]) => ParameterDecorator;
267
+
268
+ declare class CreateResponseDto<T> {
269
+ success: boolean;
270
+ message: string;
271
+ data: T;
272
+ }
273
+
274
+ declare class ValidatedRowDto {
275
+ index: number;
276
+ data: Record<string, string>;
277
+ valid: boolean;
278
+ errors: string[];
279
+ }
280
+ declare class ImportSummaryDto {
281
+ total: number;
282
+ valid: number;
283
+ invalid: number;
284
+ }
285
+ declare class ImportResponseDto {
286
+ success: boolean;
287
+ message: string;
288
+ created?: number;
289
+ updated?: number;
290
+ skipped?: number;
291
+ rows?: ValidatedRowDto[];
292
+ summary?: ImportSummaryDto;
293
+ }
269
294
 
270
295
  declare class SelectOptionsQueryDto {
271
296
  search?: string;
@@ -347,18 +372,11 @@ declare class PrimaryDatabaseService implements OnModuleInit, OnModuleDestroy {
347
372
  private readonly logger;
348
373
  private pool;
349
374
  private db;
350
- private readonly tenantConfigCache;
351
- private readonly cacheTTL;
352
375
  constructor(options: DatabaseModuleOptions);
353
376
  onModuleInit(): Promise<void>;
354
377
  private initializeDrizzleClient;
355
- getTenantInfo(tenantIdentifier: string): Promise<TenantInfo | null>;
356
- private cacheInfo;
357
- clearTenantCache(tenantIdentifier: string): void;
358
- clearAllCaches(): void;
359
378
  get drizzleClient(): TypedDrizzleClient;
360
379
  get schema(): typeof this$1.options.drizzleSchema;
361
- private decrypt;
362
380
  onModuleDestroy(): Promise<void>;
363
381
  }
364
382
 
@@ -401,6 +419,7 @@ interface FindForSelectConfig {
401
419
  groupIdKey?: string;
402
420
  joins?: FindForSelectJoin[];
403
421
  conditions?: SQL[];
422
+ distinct?: boolean;
404
423
  }
405
424
 
406
425
  type RelationsWhereFilter = Record<string, unknown>;
@@ -427,7 +446,7 @@ declare abstract class PrimaryBaseRepository<TTable extends PgTable, TInsert = I
427
446
  protected get db(): TypedDrizzleClient;
428
447
  protected get model(): TypedRelationalQueryBuilder<TSelect>;
429
448
  constructor(database: PrimaryDatabaseService, table: TTable);
430
- create(data: TInsert): Promise<TSelect>;
449
+ create(data: TInsert, tx?: TypedDrizzleClient): Promise<TSelect>;
431
450
  findById(id: string): Promise<TSelect | undefined>;
432
451
  findOne(where: RelationsWhereFilter): Promise<TSelect | undefined>;
433
452
  findMany(options?: {
@@ -445,87 +464,28 @@ declare abstract class PrimaryBaseRepository<TTable extends PgTable, TInsert = I
445
464
  offset?: number;
446
465
  leftJoin?: {
447
466
  table: PgTable;
448
- on: SQL;
467
+ on: SQL | undefined;
449
468
  };
469
+ leftJoins?: {
470
+ table: PgTable;
471
+ on: SQL | undefined;
472
+ }[];
473
+ groupBy?: (Column | SQL)[];
450
474
  }): Promise<{
451
475
  result: TResult[];
452
476
  count: number;
453
477
  }>;
454
- update(id: string, data: Partial<TInsert>): Promise<TSelect>;
455
- updateMany(where: SQL, data: Partial<TInsert>): Promise<{
456
- count: number;
457
- }>;
458
- delete(id: string): Promise<TSelect>;
459
- deleteMany(where: SQL): Promise<{
460
- count: number;
461
- }>;
462
- count(where?: SQL): Promise<number>;
463
- exists(where: SQL): Promise<boolean>;
464
- findForSelect(config: FindForSelectConfig): Promise<SelectQueryResult>;
465
- }
466
-
467
- declare class TenantContextService {
468
- private tenantInfo;
469
- setTenant(tenantInfo: TenantInfo): void;
470
- getTenant(): TenantInfo;
471
- hasTenant(): boolean;
472
- clearTenant(): void;
473
- getTenantIdSafe(): string | null;
474
- getTenantSubdomainSafe(): string | null;
475
- }
476
-
477
- declare class TenantDatabaseService implements OnModuleDestroy {
478
- private readonly options;
479
- private readonly tenantContext;
480
- private readonly logger;
481
- private readonly clients;
482
- private readonly clientLastUsed;
483
- private cleanupInterval?;
484
- constructor(options: DatabaseModuleOptions, tenantContext: TenantContextService);
485
- get drizzleClient(): TypedDrizzleClient;
486
- get schema(): Record<string, unknown>;
487
- private getDbClient;
488
- private createDbClientSync;
489
- private buildTenantDbUrl;
490
- private buildCacheKey;
491
- private startConnectionCleaner;
492
- private cleanupIdleConnections;
493
- getPoolStats(): {
494
- activeConnections: number;
495
- tenants: string[];
496
- };
497
- private maskPassword;
498
- onModuleDestroy(): Promise<void>;
499
- }
500
-
501
- type ExtractTableName<TTable extends PgTable> = TTable['_']['name'];
502
- declare abstract class TenantBaseRepository<TTable extends PgTable, TInsert = InferInsertModel<TTable>, TSelect = InferSelectModel<TTable>> {
503
- protected readonly database: TenantDatabaseService;
504
- protected readonly table: TTable;
505
- protected readonly logger: Logger;
506
- private readonly tableName;
507
- protected get db(): TypedDrizzleClient;
508
- protected get model(): TypedDrizzleClient['query'][ExtractTableName<TTable> & keyof TypedDrizzleClient['query']];
509
- constructor(database: TenantDatabaseService, table: TTable);
510
- create(data: TInsert): Promise<TSelect>;
511
- findById(id: string): Promise<TSelect | null>;
512
- findOne(where: SQL): Promise<TSelect | null>;
513
- findMany(options?: {
514
- where?: SQL;
515
- orderBy?: SQL;
516
- limit?: number;
517
- offset?: number;
518
- }): Promise<TSelect[]>;
519
- update(id: string, data: Partial<TInsert>): Promise<TSelect>;
520
- updateMany(where: SQL, data: Partial<TInsert>): Promise<{
478
+ update(id: string, data: Partial<TInsert>, tx?: TypedDrizzleClient): Promise<TSelect>;
479
+ updateMany(where: SQL, data: Partial<TInsert>, tx?: TypedDrizzleClient): Promise<{
521
480
  count: number;
522
481
  }>;
523
- delete(id: string): Promise<TSelect>;
524
- deleteMany(where: SQL): Promise<{
482
+ delete(id: string, tx?: TypedDrizzleClient): Promise<TSelect>;
483
+ deleteMany(where: SQL, tx?: TypedDrizzleClient): Promise<{
525
484
  count: number;
526
485
  }>;
527
486
  count(where?: SQL): Promise<number>;
528
487
  exists(where: SQL): Promise<boolean>;
488
+ transaction<T>(callback: (tx: TypedDrizzleClient) => Promise<T>): Promise<T>;
529
489
  findForSelect(config: FindForSelectConfig): Promise<SelectQueryResult>;
530
490
  }
531
491
 
@@ -543,6 +503,11 @@ declare class EmailService {
543
503
  sendPasswordResetEmail(email: string, otp: string, expiresAt: Date, displayName?: string): Promise<void>;
544
504
  sendEmailChangeNotification(oldEmail: string, newEmail: string, revertToken: string, revertExpiresAt: Date, displayName?: string): Promise<void>;
545
505
  sendEmailRevertConfirmation(email: string, displayName?: string): Promise<void>;
506
+ sendInviteEmail(params: {
507
+ to: string;
508
+ name: string;
509
+ inviteUrl: string;
510
+ }): Promise<void>;
546
511
  verifyConnection(): Promise<boolean>;
547
512
  private sendEmail;
548
513
  }
@@ -887,4 +852,4 @@ declare class ToggleShareDataTableViewDto {
887
852
  isShared: boolean;
888
853
  }
889
854
 
890
- export { AccessToken, type AccessTokenPayload, type ApiErrorResponse, type ApiSdkConfig, AuthConfigModule, BadGatewayException, BadRequestException, CACHE_PROVIDER, CacheModule, CacheService, type ColumnPinning, ConflictException, type CookieConfig, CookieDomain, type CookieSerializeOptions, type CorrelationContext, CorrelationIdMiddleware, CreateDataTableViewDto, DATA_TABLE_VIEWS_TABLE, DEFAULT_CORRELATION_HEADER, DataTableModule, type DataTableModuleOptions, DataTableStateService, DataTableViewDto, type DataTableViewRecord, DataTableViewsService, DatabaseModule, type DatabaseModuleOptions, type DensityType, EmailModule, EmailService, type FieldDefinition, type FieldError, type FieldMap, type FilterCondition, type FilterOperator, FilterProcessor, type FindForSelectConfig, type FindForSelectJoin, ForbiddenException, GoneException, type GuardConfig, HttpExceptionFilter, HttpLoggerInterceptor, type HttpLoggerOptions, HttpProblemException, type ICacheProvider, InternalServerErrorException, JwtAuthService, type JwtConfig, LOGGER_MODULE_OPTIONS, type LogFormat, type LogLevel, type LogMetadata, LoggerModule, type LoggerModuleAsyncOptions, type LoggerModuleOptions, type LoggerOptionsFactory, LoggerService, MethodNotAllowedException, type NewDataTableViewRecord, NotAcceptableException, NotFoundException, NotImplementedException, Onboarding, PayloadTooLargeException, PrimaryBaseRepository, PrimaryDatabaseService, type PrimaryDbConfig, type ProblemDetails, type ProblemOptions, Public, RESET_KEY, RedisCacheProvider, RefreshCookieOptions, RefreshTokenCookie, type RefreshTokenPayload, type RegisteredSchema, RenameDataTableViewDto, RequestTimeoutException, Reset, RootModule, SKIP_CSRF_KEY, SelectOptionsQueryDto, type SelectQueryGroup, type SelectQueryOption, type SelectQueryResult, ServiceUnavailableException, SessionData, type SessionInfo, SkipCsrf, type SortCondition, SuccessResponseDto, TableResponseDto, type TableViewState, Tenant, TenantBaseRepository, TenantContextService, TenantDatabaseService, type TenantInfo, ToggleShareDataTableViewDto, type TokenExpiry, TokenType, TooManyRequestsException, type TypedDrizzleClient, UnauthorizedException, UnprocessableEntityException, UnsupportedMediaTypeException, UpdateDataTableViewDto, UpsertDataTableStateDto, UserId, ValidationException, VrittiAuthGuard, addCorrelationIdToResponse, configureApiSdk, correlationStorage, dataTableViewsColumns, dataTableViewsIndexes, defineConfig, extractCountryFromPhone, generateCorrelationId, getConfig, getCorrelationContext, getHttpStatusTitle, getJwtExpiry, getRefreshCookieOptions, getRefreshCookieOptionsForHost, getTokenExpiry, hashToken, jwtConfigFactory, normalizePhoneNumber, parseExpiryToMs, resetConfig, runWithCorrelationContext, updateCorrelationContext, verifyTokenHash };
855
+ export { AccessToken, type AccessTokenPayload, type ApiErrorResponse, type ApiSdkConfig, AuthConfigModule, BadGatewayException, BadRequestException, CACHE_PROVIDER, CacheModule, CacheService, type ColumnPinning, ConflictException, type CookieConfig, CookieDomain, type CookieSerializeOptions, type CorrelationContext, CorrelationIdMiddleware, CreateDataTableViewDto, CreateResponseDto, DATA_TABLE_VIEWS_TABLE, DEFAULT_CORRELATION_HEADER, DataTableModule, type DataTableModuleOptions, DataTableStateService, DataTableViewDto, type DataTableViewRecord, DataTableViewsService, DatabaseModule, type DatabaseModuleOptions, type DensityType, EmailModule, EmailService, type FieldDefinition, type FieldError, type FieldMap, type FilterCondition, type FilterOperator, FilterProcessor, type FindForSelectConfig, type FindForSelectJoin, ForbiddenException, GoneException, type GuardConfig, HttpExceptionFilter, HttpLoggerInterceptor, type HttpLoggerOptions, HttpProblemException, type ICacheProvider, ImportResponseDto, ImportSummaryDto, InternalServerErrorException, JwtAuthService, type JwtConfig, LOGGER_MODULE_OPTIONS, type LogFormat, type LogLevel, type LogMetadata, LoggerModule, type LoggerModuleAsyncOptions, type LoggerModuleOptions, type LoggerOptionsFactory, LoggerService, MethodNotAllowedException, type NewDataTableViewRecord, NotAcceptableException, NotFoundException, NotImplementedException, PayloadTooLargeException, PrimaryBaseRepository, PrimaryDatabaseService, type PrimaryDbConfig, type ProblemDetails, type ProblemOptions, Public, REQUIRE_SESSION_KEY, RedisCacheProvider, RefreshCookieOptions, RefreshTokenCookie, type RefreshTokenPayload, type RegisteredSchema, RenameDataTableViewDto, RequestTimeoutException, RequireSession, RootModule, SKIP_CSRF_KEY, type SearchState, SelectOptionsQueryDto, type SelectQueryGroup, type SelectQueryOption, type SelectQueryResult, ServiceUnavailableException, SessionData, type SessionInfo, SkipCsrf, type SortCondition, Subdomain, SuccessResponseDto, TableResponseDto, type TableViewState, ToggleShareDataTableViewDto, type TokenExpiry, TokenType, TooManyRequestsException, type TypedDrizzleClient, UnauthorizedException, UnprocessableEntityException, UnsupportedMediaTypeException, UpdateDataTableViewDto, UploadedFile, type UploadedFileResult, UpsertDataTableStateDto, UserId, ValidatedRowDto, ValidationException, VrittiAuthGuard, addCorrelationIdToResponse, configureApiSdk, correlationStorage, dataTableViewsColumns, dataTableViewsIndexes, defineConfig, extractCountryFromPhone, generateCorrelationId, getConfig, getCorrelationContext, getHttpStatusTitle, getJwtExpiry, getRefreshCookieOptions, getRefreshCookieOptionsForHost, getTokenExpiry, hashToken, jwtConfigFactory, normalizePhoneNumber, parseExpiryToMs, resetConfig, runWithCorrelationContext, updateCorrelationContext, verifyTokenHash };
package/dist/index.d.ts CHANGED
@@ -12,21 +12,6 @@ import { PgTable } from 'drizzle-orm/pg-core';
12
12
  import { Observable } from 'rxjs';
13
13
  import { AsyncLocalStorage } from 'node:async_hooks';
14
14
 
15
- interface TenantInfo {
16
- id: string;
17
- subdomain: string;
18
- type: 'SHARED' | 'DEDICATED';
19
- status: string;
20
- schemaName?: string;
21
- databaseName?: string;
22
- databaseHost?: string;
23
- databasePort?: number;
24
- databaseUsername?: string;
25
- databasePassword?: string;
26
- databaseSslMode?: string;
27
- connectionPoolSize?: number;
28
- }
29
-
30
15
  declare module 'fastify' {
31
16
  interface FastifyRequest {
32
17
  sessionInfo?: {
@@ -34,7 +19,6 @@ declare module 'fastify' {
34
19
  sessionId: string;
35
20
  sessionType: string;
36
21
  };
37
- tenant?: TenantInfo;
38
22
  cookies?: Record<string, string>;
39
23
  }
40
24
  }
@@ -47,16 +31,16 @@ declare const AccessToken: (...dataOrPipes: unknown[]) => ParameterDecorator;
47
31
 
48
32
  declare const CookieDomain: (...dataOrPipes: unknown[]) => ParameterDecorator;
49
33
 
50
- declare const Onboarding: () => _nestjs_common.CustomDecorator<string>;
51
-
52
34
  declare const Public: () => _nestjs_common.CustomDecorator<string>;
53
35
 
54
36
  declare const RefreshCookieOptions: (...dataOrPipes: unknown[]) => ParameterDecorator;
55
37
 
56
38
  declare const RefreshTokenCookie: (...dataOrPipes: unknown[]) => ParameterDecorator;
57
39
 
58
- declare const RESET_KEY = "isReset";
59
- declare const Reset: () => _nestjs_common.CustomDecorator<string>;
40
+ declare const REQUIRE_SESSION_KEY = "requiredSessionTypes";
41
+ declare const RequireSession: (...types: string[]) => _nestjs_common.CustomDecorator<string>;
42
+
43
+ declare const Subdomain: (...dataOrPipes: unknown[]) => ParameterDecorator;
60
44
 
61
45
  interface SessionInfo {
62
46
  userId: string;
@@ -204,6 +188,7 @@ interface GuardConfig {
204
188
  tenantHeaderName: string;
205
189
  authHeaderName: string;
206
190
  tokenPrefix: string;
191
+ defaultSessionTypes: string[];
207
192
  }
208
193
  interface ApiSdkConfig {
209
194
  cookie?: Partial<CookieConfig>;
@@ -248,9 +233,7 @@ interface DatabaseModuleOptions {
248
233
  primaryDb: PrimaryDbConfig;
249
234
  drizzleSchema: RegisteredSchema;
250
235
  drizzleRelations?: Record<string, any>;
251
- connectionCacheTTL?: number;
252
236
  maxConnections?: number;
253
- encryptionKey?: string;
254
237
  }
255
238
 
256
239
  declare class DatabaseModule {
@@ -258,14 +241,56 @@ declare class DatabaseModule {
258
241
  useFactory: (...args: unknown[]) => Promise<DatabaseModuleOptions> | DatabaseModuleOptions;
259
242
  inject?: InjectionToken[];
260
243
  }): DynamicModule;
261
- static forMicroservice(options: {
262
- useFactory: (...args: unknown[]) => Promise<DatabaseModuleOptions> | DatabaseModuleOptions;
263
- inject?: InjectionToken[];
264
- }): DynamicModule;
265
- private static createDynamicModule;
266
244
  }
267
245
 
268
- declare const Tenant: (...dataOrPipes: unknown[]) => ParameterDecorator;
246
+ interface UploadedFileResult {
247
+ buffer: Buffer;
248
+ filename: string;
249
+ mimetype: string;
250
+ }
251
+ /**
252
+ * Extracts a single uploaded file from a Fastify multipart request.
253
+ *
254
+ * Requires `@fastify/multipart` to be registered on the Fastify instance.
255
+ * Throws `BadRequestException` if no file is present in the request.
256
+ *
257
+ * @example
258
+ * ```typescript
259
+ * @Post('upload')
260
+ * @ApiConsumes('multipart/form-data')
261
+ * async upload(@UploadedFile() file: UploadedFileResult) {
262
+ * // file.buffer, file.filename, file.mimetype
263
+ * }
264
+ * ```
265
+ */
266
+ declare const UploadedFile: (...dataOrPipes: unknown[]) => ParameterDecorator;
267
+
268
+ declare class CreateResponseDto<T> {
269
+ success: boolean;
270
+ message: string;
271
+ data: T;
272
+ }
273
+
274
+ declare class ValidatedRowDto {
275
+ index: number;
276
+ data: Record<string, string>;
277
+ valid: boolean;
278
+ errors: string[];
279
+ }
280
+ declare class ImportSummaryDto {
281
+ total: number;
282
+ valid: number;
283
+ invalid: number;
284
+ }
285
+ declare class ImportResponseDto {
286
+ success: boolean;
287
+ message: string;
288
+ created?: number;
289
+ updated?: number;
290
+ skipped?: number;
291
+ rows?: ValidatedRowDto[];
292
+ summary?: ImportSummaryDto;
293
+ }
269
294
 
270
295
  declare class SelectOptionsQueryDto {
271
296
  search?: string;
@@ -347,18 +372,11 @@ declare class PrimaryDatabaseService implements OnModuleInit, OnModuleDestroy {
347
372
  private readonly logger;
348
373
  private pool;
349
374
  private db;
350
- private readonly tenantConfigCache;
351
- private readonly cacheTTL;
352
375
  constructor(options: DatabaseModuleOptions);
353
376
  onModuleInit(): Promise<void>;
354
377
  private initializeDrizzleClient;
355
- getTenantInfo(tenantIdentifier: string): Promise<TenantInfo | null>;
356
- private cacheInfo;
357
- clearTenantCache(tenantIdentifier: string): void;
358
- clearAllCaches(): void;
359
378
  get drizzleClient(): TypedDrizzleClient;
360
379
  get schema(): typeof this$1.options.drizzleSchema;
361
- private decrypt;
362
380
  onModuleDestroy(): Promise<void>;
363
381
  }
364
382
 
@@ -401,6 +419,7 @@ interface FindForSelectConfig {
401
419
  groupIdKey?: string;
402
420
  joins?: FindForSelectJoin[];
403
421
  conditions?: SQL[];
422
+ distinct?: boolean;
404
423
  }
405
424
 
406
425
  type RelationsWhereFilter = Record<string, unknown>;
@@ -427,7 +446,7 @@ declare abstract class PrimaryBaseRepository<TTable extends PgTable, TInsert = I
427
446
  protected get db(): TypedDrizzleClient;
428
447
  protected get model(): TypedRelationalQueryBuilder<TSelect>;
429
448
  constructor(database: PrimaryDatabaseService, table: TTable);
430
- create(data: TInsert): Promise<TSelect>;
449
+ create(data: TInsert, tx?: TypedDrizzleClient): Promise<TSelect>;
431
450
  findById(id: string): Promise<TSelect | undefined>;
432
451
  findOne(where: RelationsWhereFilter): Promise<TSelect | undefined>;
433
452
  findMany(options?: {
@@ -445,87 +464,28 @@ declare abstract class PrimaryBaseRepository<TTable extends PgTable, TInsert = I
445
464
  offset?: number;
446
465
  leftJoin?: {
447
466
  table: PgTable;
448
- on: SQL;
467
+ on: SQL | undefined;
449
468
  };
469
+ leftJoins?: {
470
+ table: PgTable;
471
+ on: SQL | undefined;
472
+ }[];
473
+ groupBy?: (Column | SQL)[];
450
474
  }): Promise<{
451
475
  result: TResult[];
452
476
  count: number;
453
477
  }>;
454
- update(id: string, data: Partial<TInsert>): Promise<TSelect>;
455
- updateMany(where: SQL, data: Partial<TInsert>): Promise<{
456
- count: number;
457
- }>;
458
- delete(id: string): Promise<TSelect>;
459
- deleteMany(where: SQL): Promise<{
460
- count: number;
461
- }>;
462
- count(where?: SQL): Promise<number>;
463
- exists(where: SQL): Promise<boolean>;
464
- findForSelect(config: FindForSelectConfig): Promise<SelectQueryResult>;
465
- }
466
-
467
- declare class TenantContextService {
468
- private tenantInfo;
469
- setTenant(tenantInfo: TenantInfo): void;
470
- getTenant(): TenantInfo;
471
- hasTenant(): boolean;
472
- clearTenant(): void;
473
- getTenantIdSafe(): string | null;
474
- getTenantSubdomainSafe(): string | null;
475
- }
476
-
477
- declare class TenantDatabaseService implements OnModuleDestroy {
478
- private readonly options;
479
- private readonly tenantContext;
480
- private readonly logger;
481
- private readonly clients;
482
- private readonly clientLastUsed;
483
- private cleanupInterval?;
484
- constructor(options: DatabaseModuleOptions, tenantContext: TenantContextService);
485
- get drizzleClient(): TypedDrizzleClient;
486
- get schema(): Record<string, unknown>;
487
- private getDbClient;
488
- private createDbClientSync;
489
- private buildTenantDbUrl;
490
- private buildCacheKey;
491
- private startConnectionCleaner;
492
- private cleanupIdleConnections;
493
- getPoolStats(): {
494
- activeConnections: number;
495
- tenants: string[];
496
- };
497
- private maskPassword;
498
- onModuleDestroy(): Promise<void>;
499
- }
500
-
501
- type ExtractTableName<TTable extends PgTable> = TTable['_']['name'];
502
- declare abstract class TenantBaseRepository<TTable extends PgTable, TInsert = InferInsertModel<TTable>, TSelect = InferSelectModel<TTable>> {
503
- protected readonly database: TenantDatabaseService;
504
- protected readonly table: TTable;
505
- protected readonly logger: Logger;
506
- private readonly tableName;
507
- protected get db(): TypedDrizzleClient;
508
- protected get model(): TypedDrizzleClient['query'][ExtractTableName<TTable> & keyof TypedDrizzleClient['query']];
509
- constructor(database: TenantDatabaseService, table: TTable);
510
- create(data: TInsert): Promise<TSelect>;
511
- findById(id: string): Promise<TSelect | null>;
512
- findOne(where: SQL): Promise<TSelect | null>;
513
- findMany(options?: {
514
- where?: SQL;
515
- orderBy?: SQL;
516
- limit?: number;
517
- offset?: number;
518
- }): Promise<TSelect[]>;
519
- update(id: string, data: Partial<TInsert>): Promise<TSelect>;
520
- updateMany(where: SQL, data: Partial<TInsert>): Promise<{
478
+ update(id: string, data: Partial<TInsert>, tx?: TypedDrizzleClient): Promise<TSelect>;
479
+ updateMany(where: SQL, data: Partial<TInsert>, tx?: TypedDrizzleClient): Promise<{
521
480
  count: number;
522
481
  }>;
523
- delete(id: string): Promise<TSelect>;
524
- deleteMany(where: SQL): Promise<{
482
+ delete(id: string, tx?: TypedDrizzleClient): Promise<TSelect>;
483
+ deleteMany(where: SQL, tx?: TypedDrizzleClient): Promise<{
525
484
  count: number;
526
485
  }>;
527
486
  count(where?: SQL): Promise<number>;
528
487
  exists(where: SQL): Promise<boolean>;
488
+ transaction<T>(callback: (tx: TypedDrizzleClient) => Promise<T>): Promise<T>;
529
489
  findForSelect(config: FindForSelectConfig): Promise<SelectQueryResult>;
530
490
  }
531
491
 
@@ -543,6 +503,11 @@ declare class EmailService {
543
503
  sendPasswordResetEmail(email: string, otp: string, expiresAt: Date, displayName?: string): Promise<void>;
544
504
  sendEmailChangeNotification(oldEmail: string, newEmail: string, revertToken: string, revertExpiresAt: Date, displayName?: string): Promise<void>;
545
505
  sendEmailRevertConfirmation(email: string, displayName?: string): Promise<void>;
506
+ sendInviteEmail(params: {
507
+ to: string;
508
+ name: string;
509
+ inviteUrl: string;
510
+ }): Promise<void>;
546
511
  verifyConnection(): Promise<boolean>;
547
512
  private sendEmail;
548
513
  }
@@ -887,4 +852,4 @@ declare class ToggleShareDataTableViewDto {
887
852
  isShared: boolean;
888
853
  }
889
854
 
890
- export { AccessToken, type AccessTokenPayload, type ApiErrorResponse, type ApiSdkConfig, AuthConfigModule, BadGatewayException, BadRequestException, CACHE_PROVIDER, CacheModule, CacheService, type ColumnPinning, ConflictException, type CookieConfig, CookieDomain, type CookieSerializeOptions, type CorrelationContext, CorrelationIdMiddleware, CreateDataTableViewDto, DATA_TABLE_VIEWS_TABLE, DEFAULT_CORRELATION_HEADER, DataTableModule, type DataTableModuleOptions, DataTableStateService, DataTableViewDto, type DataTableViewRecord, DataTableViewsService, DatabaseModule, type DatabaseModuleOptions, type DensityType, EmailModule, EmailService, type FieldDefinition, type FieldError, type FieldMap, type FilterCondition, type FilterOperator, FilterProcessor, type FindForSelectConfig, type FindForSelectJoin, ForbiddenException, GoneException, type GuardConfig, HttpExceptionFilter, HttpLoggerInterceptor, type HttpLoggerOptions, HttpProblemException, type ICacheProvider, InternalServerErrorException, JwtAuthService, type JwtConfig, LOGGER_MODULE_OPTIONS, type LogFormat, type LogLevel, type LogMetadata, LoggerModule, type LoggerModuleAsyncOptions, type LoggerModuleOptions, type LoggerOptionsFactory, LoggerService, MethodNotAllowedException, type NewDataTableViewRecord, NotAcceptableException, NotFoundException, NotImplementedException, Onboarding, PayloadTooLargeException, PrimaryBaseRepository, PrimaryDatabaseService, type PrimaryDbConfig, type ProblemDetails, type ProblemOptions, Public, RESET_KEY, RedisCacheProvider, RefreshCookieOptions, RefreshTokenCookie, type RefreshTokenPayload, type RegisteredSchema, RenameDataTableViewDto, RequestTimeoutException, Reset, RootModule, SKIP_CSRF_KEY, SelectOptionsQueryDto, type SelectQueryGroup, type SelectQueryOption, type SelectQueryResult, ServiceUnavailableException, SessionData, type SessionInfo, SkipCsrf, type SortCondition, SuccessResponseDto, TableResponseDto, type TableViewState, Tenant, TenantBaseRepository, TenantContextService, TenantDatabaseService, type TenantInfo, ToggleShareDataTableViewDto, type TokenExpiry, TokenType, TooManyRequestsException, type TypedDrizzleClient, UnauthorizedException, UnprocessableEntityException, UnsupportedMediaTypeException, UpdateDataTableViewDto, UpsertDataTableStateDto, UserId, ValidationException, VrittiAuthGuard, addCorrelationIdToResponse, configureApiSdk, correlationStorage, dataTableViewsColumns, dataTableViewsIndexes, defineConfig, extractCountryFromPhone, generateCorrelationId, getConfig, getCorrelationContext, getHttpStatusTitle, getJwtExpiry, getRefreshCookieOptions, getRefreshCookieOptionsForHost, getTokenExpiry, hashToken, jwtConfigFactory, normalizePhoneNumber, parseExpiryToMs, resetConfig, runWithCorrelationContext, updateCorrelationContext, verifyTokenHash };
855
+ export { AccessToken, type AccessTokenPayload, type ApiErrorResponse, type ApiSdkConfig, AuthConfigModule, BadGatewayException, BadRequestException, CACHE_PROVIDER, CacheModule, CacheService, type ColumnPinning, ConflictException, type CookieConfig, CookieDomain, type CookieSerializeOptions, type CorrelationContext, CorrelationIdMiddleware, CreateDataTableViewDto, CreateResponseDto, DATA_TABLE_VIEWS_TABLE, DEFAULT_CORRELATION_HEADER, DataTableModule, type DataTableModuleOptions, DataTableStateService, DataTableViewDto, type DataTableViewRecord, DataTableViewsService, DatabaseModule, type DatabaseModuleOptions, type DensityType, EmailModule, EmailService, type FieldDefinition, type FieldError, type FieldMap, type FilterCondition, type FilterOperator, FilterProcessor, type FindForSelectConfig, type FindForSelectJoin, ForbiddenException, GoneException, type GuardConfig, HttpExceptionFilter, HttpLoggerInterceptor, type HttpLoggerOptions, HttpProblemException, type ICacheProvider, ImportResponseDto, ImportSummaryDto, InternalServerErrorException, JwtAuthService, type JwtConfig, LOGGER_MODULE_OPTIONS, type LogFormat, type LogLevel, type LogMetadata, LoggerModule, type LoggerModuleAsyncOptions, type LoggerModuleOptions, type LoggerOptionsFactory, LoggerService, MethodNotAllowedException, type NewDataTableViewRecord, NotAcceptableException, NotFoundException, NotImplementedException, PayloadTooLargeException, PrimaryBaseRepository, PrimaryDatabaseService, type PrimaryDbConfig, type ProblemDetails, type ProblemOptions, Public, REQUIRE_SESSION_KEY, RedisCacheProvider, RefreshCookieOptions, RefreshTokenCookie, type RefreshTokenPayload, type RegisteredSchema, RenameDataTableViewDto, RequestTimeoutException, RequireSession, RootModule, SKIP_CSRF_KEY, type SearchState, SelectOptionsQueryDto, type SelectQueryGroup, type SelectQueryOption, type SelectQueryResult, ServiceUnavailableException, SessionData, type SessionInfo, SkipCsrf, type SortCondition, Subdomain, SuccessResponseDto, TableResponseDto, type TableViewState, ToggleShareDataTableViewDto, type TokenExpiry, TokenType, TooManyRequestsException, type TypedDrizzleClient, UnauthorizedException, UnprocessableEntityException, UnsupportedMediaTypeException, UpdateDataTableViewDto, UploadedFile, type UploadedFileResult, UpsertDataTableStateDto, UserId, ValidatedRowDto, ValidationException, VrittiAuthGuard, addCorrelationIdToResponse, configureApiSdk, correlationStorage, dataTableViewsColumns, dataTableViewsIndexes, defineConfig, extractCountryFromPhone, generateCorrelationId, getConfig, getCorrelationContext, getHttpStatusTitle, getJwtExpiry, getRefreshCookieOptions, getRefreshCookieOptionsForHost, getTokenExpiry, hashToken, jwtConfigFactory, normalizePhoneNumber, parseExpiryToMs, resetConfig, runWithCorrelationContext, updateCorrelationContext, verifyTokenHash };