@flusys/nestjs-shared 9.1.2 → 9.2.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/README.md +94 -18
- package/classes/api-controller.class.d.ts +1 -0
- package/classes/api-service.class.d.ts +7 -2
- package/classes/hybrid-cache.class.d.ts +17 -4
- package/constants/index.d.ts +1 -0
- package/constants/permissions.d.ts +9 -0
- package/fesm/183.js +7 -7
- package/fesm/{282.js → 47.js} +98 -158
- package/fesm/470.js +333 -382
- package/fesm/667.js +17 -17
- package/fesm/681.js +326 -129
- package/fesm/{948.js → 997.js} +45 -23
- package/fesm/chunks/123.js +17 -9
- package/fesm/chunks/37.js +5 -5
- package/fesm/classes/index.js +4 -3
- package/fesm/constants/index.js +18 -7
- package/fesm/decorators/index.js +120 -39
- package/fesm/dtos/index.js +1 -1
- package/fesm/entities/index.js +8 -8
- package/fesm/enums/index.js +2 -2
- package/fesm/exceptions/index.js +12 -12
- package/fesm/guards/index.js +201 -68
- package/fesm/index.js +50 -41
- package/fesm/interceptors/index.js +290 -590
- package/fesm/interfaces/index.js +17 -8
- package/fesm/middlewares/index.js +4 -4
- package/fesm/modules/index.js +2 -2
- package/fesm/pipes/index.js +8 -8
- package/fesm/utils/index.js +137 -478
- package/interceptors/idempotency.interceptor.d.ts +14 -2
- package/interceptors/slug.interceptor.d.ts +1 -0
- package/interfaces/permission-action-registry.interface.d.ts +1 -0
- package/interfaces/permission.interface.d.ts +1 -0
- package/modules/shared-permission-cache/shared-permission-cache.service.d.ts +3 -1
- package/modules/utils/utils.service.d.ts +6 -6
- package/package.json +2 -2
- package/utils/date-time.util.d.ts +0 -1
- package/utils/event-pattern.util.d.ts +1 -0
- package/utils/permission-cache-key.util.d.ts +3 -0
- package/utils/query-helpers.util.d.ts +2 -2
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { type CallHandler, type ExecutionContext, type NestInterceptor } from '@nestjs/common';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { HybridCache } from '../classes/hybrid-cache.class.js';
|
|
4
|
+
interface IIdempotentRequest {
|
|
5
|
+
headers: Record<string, string | string[] | undefined>;
|
|
6
|
+
method?: string;
|
|
7
|
+
originalUrl?: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
route?: {
|
|
10
|
+
path?: string;
|
|
11
|
+
};
|
|
12
|
+
user?: {
|
|
13
|
+
id?: string;
|
|
14
|
+
} | null;
|
|
15
|
+
}
|
|
16
|
+
export declare function buildIdempotencyCacheKey(request: IIdempotentRequest, idempotencyKey: string): string;
|
|
4
17
|
export declare class IdempotencyInterceptor implements NestInterceptor {
|
|
5
18
|
private readonly cache?;
|
|
6
|
-
private readonly CACHE_TTL;
|
|
7
|
-
private readonly PROCESSING_MARKER;
|
|
8
19
|
constructor(cache?: HybridCache | undefined);
|
|
9
20
|
intercept<T = any>(context: ExecutionContext, next: CallHandler<T>): Promise<Observable<T>>;
|
|
10
21
|
}
|
|
22
|
+
export {};
|
|
@@ -9,4 +9,5 @@ export interface IPermissionActionInput {
|
|
|
9
9
|
export interface IPermissionActionRegistry {
|
|
10
10
|
registerActions(actions: IPermissionActionInput[]): Promise<void>;
|
|
11
11
|
removeActionsByCodes(codes: string[]): Promise<void>;
|
|
12
|
+
findMissingCodes?(codes: string[]): Promise<string[]>;
|
|
12
13
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { HybridCache } from '../../classes/hybrid-cache.class.js';
|
|
2
2
|
import type { ILogicNode, PermissionGuardConfig } from '../../interfaces/index.js';
|
|
3
|
+
import { type IPermissionResolver } from '../../interfaces/permission-resolver.interface.js';
|
|
3
4
|
import { type PermissionCacheKeyOptions } from '../../utils/permission-cache-key.util.js';
|
|
4
5
|
export declare class SharedPermissionCacheService {
|
|
5
6
|
private readonly cache?;
|
|
7
|
+
private readonly resolver?;
|
|
6
8
|
private readonly config;
|
|
7
|
-
constructor(cache?: HybridCache | undefined, config?: PermissionGuardConfig);
|
|
9
|
+
constructor(cache?: HybridCache | undefined, config?: PermissionGuardConfig, resolver?: IPermissionResolver | undefined);
|
|
8
10
|
getPermissions(options: PermissionCacheKeyOptions): Promise<string[]>;
|
|
9
11
|
setPermissions(options: PermissionCacheKeyOptions, permissions: string[], ttl?: number): Promise<void>;
|
|
10
12
|
clearPermissions(options: PermissionCacheKeyOptions): Promise<void>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { HybridCache } from '../../classes/hybrid-cache.class.js';
|
|
2
2
|
export declare class UtilsService {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
private readonly logger;
|
|
4
|
+
getCacheStamp(cacheManager: HybridCache, entityNames: string[], tenantId?: string): Promise<string>;
|
|
5
|
+
getCacheKey(entityName: string, params: unknown, entityId: string | undefined, tenantId: string | undefined, stamp: string): string;
|
|
6
|
+
clearCache(entityName: string, cacheManager: HybridCache, tenantId?: string): Promise<void>;
|
|
7
|
+
getStampName(entityName: string, tenantId?: string): string;
|
|
8
|
+
transformToSlug(value: string): string;
|
|
8
9
|
private buildTenantPrefix;
|
|
9
|
-
private buildTrackingKey;
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/nestjs-shared",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "Common shared utilities for Flusys NestJS applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./fesm/index.js",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"rxjs": "^7.8.0"
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
|
-
"@flusys/nestjs-core": "9.
|
|
107
|
+
"@flusys/nestjs-core": "9.2.0",
|
|
108
108
|
"re2js": "^2.8.6"
|
|
109
109
|
}
|
|
110
110
|
}
|
|
@@ -5,4 +5,3 @@ export declare function utcToLocal(utcDate: Date | string, timezone: string): {
|
|
|
5
5
|
display: string;
|
|
6
6
|
};
|
|
7
7
|
export declare function formatInTimezone(utcDate: Date | string, timezone: string, options?: Intl.DateTimeFormatOptions): string;
|
|
8
|
-
export declare function getTodayInTimezone(timezone: string): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare function matchEventPattern(pattern: string, eventName: string): boolean;
|
|
2
2
|
export declare function isMultiWildcard(segment: string): boolean;
|
|
3
3
|
export declare function sanitizeEventPayload<T>(value: T): T;
|
|
4
|
+
export declare function isSensitiveKey(key: string): boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type HybridCache } from '../classes/hybrid-cache.class.js';
|
|
1
2
|
import { type PermissionGuardConfig } from '../interfaces/permission.interface.js';
|
|
2
3
|
export interface PermissionCacheKeyOptions {
|
|
3
4
|
userId: string;
|
|
@@ -7,3 +8,5 @@ export interface PermissionCacheKeyOptions {
|
|
|
7
8
|
export declare const DEFAULT_USER_PERMISSION_KEY_FORMAT = "my-permissions:user:{userId}";
|
|
8
9
|
export declare const DEFAULT_COMPANY_PERMISSION_KEY_FORMAT = "my-permissions:company:{companyId}:branch:{branchId}:user:{userId}";
|
|
9
10
|
export declare function buildPermissionCacheKey(options: PermissionCacheKeyOptions, config?: PermissionGuardConfig): string;
|
|
11
|
+
export declare function resolvePermissionCacheKey(cache: Pick<HybridCache, 'getStamp'>, options: PermissionCacheKeyOptions, config?: PermissionGuardConfig): Promise<string>;
|
|
12
|
+
export declare function invalidatePermissionCache(cache: Pick<HybridCache, 'bumpStamp'>, userId: string, config?: PermissionGuardConfig): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ObjectLiteral, type QueryRunner, SelectQueryBuilder } from 'typeorm';
|
|
1
|
+
import { type FindOperator, type ObjectLiteral, type QueryRunner, SelectQueryBuilder } from 'typeorm';
|
|
2
2
|
import { type ILoggedUserInfo } from '../interfaces/index.js';
|
|
3
3
|
export interface ICompanyFilterConfig {
|
|
4
4
|
isCompanyFeatureEnabled: boolean;
|
|
@@ -13,7 +13,7 @@ export interface IBranchFilterConfig {
|
|
|
13
13
|
}
|
|
14
14
|
export declare function applyBranchFilter<T extends ObjectLiteral>(query: SelectQueryBuilder<T>, config: IBranchFilterConfig, branchIds: ReadonlyArray<string | null | undefined>): SelectQueryBuilder<T>;
|
|
15
15
|
export declare function buildCompanyWhereCondition<T extends Record<string, unknown>>(baseWhere: T, isCompanyFeatureEnabled: boolean, user: ILoggedUserInfo | null | undefined): T & {
|
|
16
|
-
companyId?: string
|
|
16
|
+
companyId?: string | FindOperator<string>;
|
|
17
17
|
};
|
|
18
18
|
export interface ICompanyEnabled {
|
|
19
19
|
companyId?: string | null;
|