@vritti/api-sdk 0.1.4 → 0.1.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.cjs +163 -150
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -156,6 +156,30 @@ declare const Onboarding: () => _nestjs_common.CustomDecorator<string>;
|
|
|
156
156
|
*/
|
|
157
157
|
declare const Public: () => _nestjs_common.CustomDecorator<string>;
|
|
158
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Parameter decorator to extract user ID from authenticated request
|
|
161
|
+
*
|
|
162
|
+
* This decorator retrieves the user ID from the request object,
|
|
163
|
+
* which is set by authentication guards (JwtAuthGuard, VrittiAuthGuard).
|
|
164
|
+
*
|
|
165
|
+
* @returns The user's ID as a string (UUID)
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* @Post('verify-email')
|
|
169
|
+
* @Onboarding()
|
|
170
|
+
* async verifyEmail(@UserId() userId: string) {
|
|
171
|
+
* await this.service.verify(userId);
|
|
172
|
+
* }
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* @Post('logout-all')
|
|
176
|
+
* @UseGuards(JwtAuthGuard)
|
|
177
|
+
* async logoutAll(@UserId() userId: string) {
|
|
178
|
+
* await this.authService.logoutAll(userId);
|
|
179
|
+
* }
|
|
180
|
+
*/
|
|
181
|
+
declare const UserId: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
182
|
+
|
|
159
183
|
/**
|
|
160
184
|
* Schema Registry Interface
|
|
161
185
|
*
|
|
@@ -2491,4 +2515,4 @@ declare function generateCorrelationId(): string;
|
|
|
2491
2515
|
*/
|
|
2492
2516
|
declare function addCorrelationIdToResponse(reply: FastifyReply, correlationId: string, headerName?: string): void;
|
|
2493
2517
|
|
|
2494
|
-
export { type ApiErrorResponse, type ApiSdkConfig, AuthConfigModule, BadGatewayException, BadRequestException, BaseFieldException, ConflictException, type CookieConfig, type CorrelationContext, CorrelationIdMiddleware, CsrfGuard, DEFAULT_CORRELATION_HEADER, DatabaseModule, type DatabaseModuleOptions, type FieldError, ForbiddenException, GoneException, type GuardConfig, HttpExceptionFilter, HttpLoggerInterceptor, type HttpLoggerOptions, HttpModule, InternalServerErrorException, type JwtConfig, LOGGER_MODULE_OPTIONS, type LogFormat, type LogLevel, type LogMetadata, LoggerModule, type LoggerModuleAsyncOptions, type LoggerModuleOptions, type LoggerOptionsFactory, LoggerService, MethodNotAllowedException, NotAcceptableException, NotFoundException, NotImplementedException, Onboarding, PayloadTooLargeException, PrimaryBaseRepository, PrimaryDatabaseService, type PrimaryDbConfig, type ProblemDetails, Public, type RegisteredSchema, RequestTimeoutException, ServiceUnavailableException, Tenant, TenantBaseRepository, TenantContextService, TenantDatabaseService, type TenantInfo, TooManyRequestsException, type TypedDrizzleClient, UnauthorizedException, UnprocessableEntityException, UnsupportedMediaTypeException, ValidationException, VrittiAuthGuard, addCorrelationIdToResponse, configureApiSdk, correlationStorage, defineConfig, generateCorrelationId, getConfig, getCorrelationContext, getHttpStatusTitle, getJwtExpiry, getRefreshCookieOptions, hashToken, resetConfig, runWithCorrelationContext, updateCorrelationContext, verifyTokenHash };
|
|
2518
|
+
export { type ApiErrorResponse, type ApiSdkConfig, AuthConfigModule, BadGatewayException, BadRequestException, BaseFieldException, ConflictException, type CookieConfig, type CorrelationContext, CorrelationIdMiddleware, CsrfGuard, DEFAULT_CORRELATION_HEADER, DatabaseModule, type DatabaseModuleOptions, type FieldError, ForbiddenException, GoneException, type GuardConfig, HttpExceptionFilter, HttpLoggerInterceptor, type HttpLoggerOptions, HttpModule, InternalServerErrorException, type JwtConfig, LOGGER_MODULE_OPTIONS, type LogFormat, type LogLevel, type LogMetadata, LoggerModule, type LoggerModuleAsyncOptions, type LoggerModuleOptions, type LoggerOptionsFactory, LoggerService, MethodNotAllowedException, NotAcceptableException, NotFoundException, NotImplementedException, Onboarding, PayloadTooLargeException, PrimaryBaseRepository, PrimaryDatabaseService, type PrimaryDbConfig, type ProblemDetails, Public, type RegisteredSchema, RequestTimeoutException, ServiceUnavailableException, Tenant, TenantBaseRepository, TenantContextService, TenantDatabaseService, type TenantInfo, TooManyRequestsException, type TypedDrizzleClient, UnauthorizedException, UnprocessableEntityException, UnsupportedMediaTypeException, UserId, ValidationException, VrittiAuthGuard, addCorrelationIdToResponse, configureApiSdk, correlationStorage, defineConfig, generateCorrelationId, getConfig, getCorrelationContext, getHttpStatusTitle, getJwtExpiry, getRefreshCookieOptions, hashToken, resetConfig, runWithCorrelationContext, updateCorrelationContext, verifyTokenHash };
|
package/dist/index.d.ts
CHANGED
|
@@ -156,6 +156,30 @@ declare const Onboarding: () => _nestjs_common.CustomDecorator<string>;
|
|
|
156
156
|
*/
|
|
157
157
|
declare const Public: () => _nestjs_common.CustomDecorator<string>;
|
|
158
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Parameter decorator to extract user ID from authenticated request
|
|
161
|
+
*
|
|
162
|
+
* This decorator retrieves the user ID from the request object,
|
|
163
|
+
* which is set by authentication guards (JwtAuthGuard, VrittiAuthGuard).
|
|
164
|
+
*
|
|
165
|
+
* @returns The user's ID as a string (UUID)
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* @Post('verify-email')
|
|
169
|
+
* @Onboarding()
|
|
170
|
+
* async verifyEmail(@UserId() userId: string) {
|
|
171
|
+
* await this.service.verify(userId);
|
|
172
|
+
* }
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* @Post('logout-all')
|
|
176
|
+
* @UseGuards(JwtAuthGuard)
|
|
177
|
+
* async logoutAll(@UserId() userId: string) {
|
|
178
|
+
* await this.authService.logoutAll(userId);
|
|
179
|
+
* }
|
|
180
|
+
*/
|
|
181
|
+
declare const UserId: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
182
|
+
|
|
159
183
|
/**
|
|
160
184
|
* Schema Registry Interface
|
|
161
185
|
*
|
|
@@ -2491,4 +2515,4 @@ declare function generateCorrelationId(): string;
|
|
|
2491
2515
|
*/
|
|
2492
2516
|
declare function addCorrelationIdToResponse(reply: FastifyReply, correlationId: string, headerName?: string): void;
|
|
2493
2517
|
|
|
2494
|
-
export { type ApiErrorResponse, type ApiSdkConfig, AuthConfigModule, BadGatewayException, BadRequestException, BaseFieldException, ConflictException, type CookieConfig, type CorrelationContext, CorrelationIdMiddleware, CsrfGuard, DEFAULT_CORRELATION_HEADER, DatabaseModule, type DatabaseModuleOptions, type FieldError, ForbiddenException, GoneException, type GuardConfig, HttpExceptionFilter, HttpLoggerInterceptor, type HttpLoggerOptions, HttpModule, InternalServerErrorException, type JwtConfig, LOGGER_MODULE_OPTIONS, type LogFormat, type LogLevel, type LogMetadata, LoggerModule, type LoggerModuleAsyncOptions, type LoggerModuleOptions, type LoggerOptionsFactory, LoggerService, MethodNotAllowedException, NotAcceptableException, NotFoundException, NotImplementedException, Onboarding, PayloadTooLargeException, PrimaryBaseRepository, PrimaryDatabaseService, type PrimaryDbConfig, type ProblemDetails, Public, type RegisteredSchema, RequestTimeoutException, ServiceUnavailableException, Tenant, TenantBaseRepository, TenantContextService, TenantDatabaseService, type TenantInfo, TooManyRequestsException, type TypedDrizzleClient, UnauthorizedException, UnprocessableEntityException, UnsupportedMediaTypeException, ValidationException, VrittiAuthGuard, addCorrelationIdToResponse, configureApiSdk, correlationStorage, defineConfig, generateCorrelationId, getConfig, getCorrelationContext, getHttpStatusTitle, getJwtExpiry, getRefreshCookieOptions, hashToken, resetConfig, runWithCorrelationContext, updateCorrelationContext, verifyTokenHash };
|
|
2518
|
+
export { type ApiErrorResponse, type ApiSdkConfig, AuthConfigModule, BadGatewayException, BadRequestException, BaseFieldException, ConflictException, type CookieConfig, type CorrelationContext, CorrelationIdMiddleware, CsrfGuard, DEFAULT_CORRELATION_HEADER, DatabaseModule, type DatabaseModuleOptions, type FieldError, ForbiddenException, GoneException, type GuardConfig, HttpExceptionFilter, HttpLoggerInterceptor, type HttpLoggerOptions, HttpModule, InternalServerErrorException, type JwtConfig, LOGGER_MODULE_OPTIONS, type LogFormat, type LogLevel, type LogMetadata, LoggerModule, type LoggerModuleAsyncOptions, type LoggerModuleOptions, type LoggerOptionsFactory, LoggerService, MethodNotAllowedException, NotAcceptableException, NotFoundException, NotImplementedException, Onboarding, PayloadTooLargeException, PrimaryBaseRepository, PrimaryDatabaseService, type PrimaryDbConfig, type ProblemDetails, Public, type RegisteredSchema, RequestTimeoutException, ServiceUnavailableException, Tenant, TenantBaseRepository, TenantContextService, TenantDatabaseService, type TenantInfo, TooManyRequestsException, type TypedDrizzleClient, UnauthorizedException, UnprocessableEntityException, UnsupportedMediaTypeException, UserId, ValidationException, VrittiAuthGuard, addCorrelationIdToResponse, configureApiSdk, correlationStorage, defineConfig, generateCorrelationId, getConfig, getCorrelationContext, getHttpStatusTitle, getJwtExpiry, getRefreshCookieOptions, hashToken, resetConfig, runWithCorrelationContext, updateCorrelationContext, verifyTokenHash };
|
package/dist/index.js
CHANGED
|
@@ -726,6 +726,17 @@ var Onboarding = /* @__PURE__ */ __name(() => SetMetadata("isOnboarding", true),
|
|
|
726
726
|
import { SetMetadata as SetMetadata2 } from "@nestjs/common";
|
|
727
727
|
var Public = /* @__PURE__ */ __name(() => SetMetadata2("isPublic", true), "Public");
|
|
728
728
|
|
|
729
|
+
// src/auth/decorators/user-id.decorator.ts
|
|
730
|
+
import { createParamDecorator } from "@nestjs/common";
|
|
731
|
+
var UserId = createParamDecorator((_data, ctx) => {
|
|
732
|
+
const request = ctx.switchToHttp().getRequest();
|
|
733
|
+
const user = request.user;
|
|
734
|
+
if (!user?.id) {
|
|
735
|
+
throw new Error("User ID not found on request. Ensure route is protected by auth guard.");
|
|
736
|
+
}
|
|
737
|
+
return user.id;
|
|
738
|
+
});
|
|
739
|
+
|
|
729
740
|
// src/database/database.module.ts
|
|
730
741
|
import { Global as Global3, Module as Module3 } from "@nestjs/common";
|
|
731
742
|
import { APP_INTERCEPTOR } from "@nestjs/core";
|
|
@@ -1296,8 +1307,8 @@ DatabaseModule = _ts_decorate10([
|
|
|
1296
1307
|
], DatabaseModule);
|
|
1297
1308
|
|
|
1298
1309
|
// src/database/decorators/tenant.decorator.ts
|
|
1299
|
-
import { createParamDecorator } from "@nestjs/common";
|
|
1300
|
-
var Tenant =
|
|
1310
|
+
import { createParamDecorator as createParamDecorator2 } from "@nestjs/common";
|
|
1311
|
+
var Tenant = createParamDecorator2((_data, ctx) => {
|
|
1301
1312
|
const request = ctx.switchToHttp().getRequest();
|
|
1302
1313
|
const tenantContext = request.app?.get?.(TenantContextService);
|
|
1303
1314
|
if (!tenantContext) {
|
|
@@ -3387,6 +3398,7 @@ export {
|
|
|
3387
3398
|
UnauthorizedException4 as UnauthorizedException,
|
|
3388
3399
|
UnprocessableEntityException,
|
|
3389
3400
|
UnsupportedMediaTypeException,
|
|
3401
|
+
UserId,
|
|
3390
3402
|
ValidationException,
|
|
3391
3403
|
VrittiAuthGuard,
|
|
3392
3404
|
addCorrelationIdToResponse,
|