@flusys/nestjs-shared 5.0.3 → 5.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/README.md CHANGED
@@ -27,8 +27,8 @@ import { ResponseMetaInterceptor } from '@flusys/nestjs-shared/interceptors';
27
27
 
28
28
  @Module({
29
29
  imports: [
30
- CacheModule.forRoot(true), // true = global; provides 'CACHE_INSTANCE' token
31
- UtilsModule, // provides UtilsService
30
+ CacheModule.forRoot(true), // true = global; provides 'CACHE_INSTANCE' token
31
+ UtilsModule, // provides UtilsService
32
32
  ],
33
33
  })
34
34
  export class AppModule implements NestModule {
@@ -75,8 +75,7 @@ export class ProductService extends RequestScopedApiService<
75
75
  CreateProductDto,
76
76
  UpdateProductDto,
77
77
  IProduct,
78
- Product,
79
- Repository<Product>
78
+ Product
80
79
  > {
81
80
  constructor(
82
81
  @Inject('CACHE_INSTANCE') protected override cacheManager: HybridCache,
@@ -114,16 +113,16 @@ export class ProductController extends createApiController<
114
113
  >(CreateProductDto, UpdateProductDto, ProductResponseDto, {
115
114
  entityName: 'product',
116
115
  security: {
117
- insert: { level: 'permission', permissions: ['product.create'] },
116
+ insert: { level: 'permission', permissions: ['product.create'] },
118
117
  insertMany: { level: 'permission', permissions: ['product.create'] },
119
- getAll: { level: 'permission', permissions: ['product.read'] },
120
- getById: { level: 'permission', permissions: ['product.read'] },
121
- update: { level: 'permission', permissions: ['product.update'] },
118
+ getAll: { level: 'permission', permissions: ['product.read'] },
119
+ getById: { level: 'permission', permissions: ['product.read'] },
120
+ update: { level: 'permission', permissions: ['product.update'] },
122
121
  updateMany: { level: 'permission', permissions: ['product.update'] },
123
- delete: { level: 'permission', permissions: ['product.delete'] },
122
+ delete: { level: 'permission', permissions: ['product.delete'] },
124
123
  bulkUpsert: { level: 'permission', permissions: ['product.create'] },
125
- getByIds: { level: 'permission', permissions: ['product.read'] },
126
- getByFilter:{ level: 'permission', permissions: ['product.read'] },
124
+ getByIds: { level: 'permission', permissions: ['product.read'] },
125
+ getByFilter: { level: 'permission', permissions: ['product.read'] },
127
126
  },
128
127
  }) {
129
128
  constructor(@Inject(ProductService) public override service: ProductService) {
@@ -169,10 +168,10 @@ All controllers return one of these shapes:
169
168
 
170
169
  ```typescript
171
170
  import {
172
- SingleResponseDto, // insert, update, getById
173
- ListResponseDto, // getAll, getByIds
174
- BulkResponseDto, // insertMany, updateMany, bulkUpsert
175
- MessageResponseDto, // delete
171
+ SingleResponseDto, // insert, update, getById
172
+ ListResponseDto, // getAll, getByIds
173
+ BulkResponseDto, // insertMany, updateMany, bulkUpsert
174
+ MessageResponseDto, // delete
176
175
  } from '@flusys/nestjs-shared/dtos';
177
176
 
178
177
  // All shapes include: success, message, messageKey (for i18n), _meta (requestId, timestamp, duration)
@@ -192,13 +191,13 @@ import {
192
191
  } from '@flusys/nestjs-shared/exceptions';
193
192
 
194
193
  throw new NotFoundException({
195
- message: 'User not found',
196
- messageKey: USER_MESSAGES.NOT_FOUND,
194
+ message: 'User not found',
195
+ messageKey: USER_MESSAGES.NOT_FOUND,
197
196
  });
198
197
  throw new ConflictException({
199
- message: `User already assigned to this ${typeName}. Please refresh and try again.`,
200
- messageKey: USER_PERMISSION_MESSAGES.ALREADY_ASSIGNED,
201
- messageVariables: { type: typeName },
198
+ message: `User already assigned to this ${typeName}. Please refresh and try again.`,
199
+ messageKey: USER_PERMISSION_MESSAGES.ALREADY_ASSIGNED,
200
+ messageVariables: { type: typeName },
202
201
  });
203
202
  throw new ValidationException([{ field: 'email', message: 'Invalid format' }]);
204
203
  ```
@@ -222,14 +221,17 @@ export class MyService {
222
221
  return data;
223
222
  }
224
223
 
225
- async invalidate(key: string) { await this.cache.delete(key); }
226
- async invalidatePrefix(prefix: string) { await this.cache.deleteByPrefix(prefix); }
224
+ async invalidate(key: string) {
225
+ await this.cache.delete(key);
226
+ }
227
+ async invalidatePrefix(prefix: string) {
228
+ await this.cache.deleteByPrefix(prefix);
229
+ }
227
230
  }
228
231
  ```
229
232
 
230
233
  `CacheModule.forRoot(true)` connects to Redis automatically when `REDIS_URL` is set; otherwise uses in-memory only.
231
234
 
232
-
233
235
  ## License
234
236
 
235
237
  MIT © FLUSYS
@@ -67,6 +67,9 @@ _export(exports, {
67
67
  get TRANSLATION_PERMISSIONS () {
68
68
  return TRANSLATION_PERMISSIONS;
69
69
  },
70
+ get UPLOAD_CONFIG_PERMISSIONS () {
71
+ return UPLOAD_CONFIG_PERMISSIONS;
72
+ },
70
73
  get USER_ACTION_PERMISSIONS () {
71
74
  return USER_ACTION_PERMISSIONS;
72
75
  },
@@ -141,6 +144,9 @@ const STORAGE_CONFIG_PERMISSIONS = {
141
144
  UPDATE: 'storage-config.update',
142
145
  DELETE: 'storage-config.delete'
143
146
  };
147
+ const UPLOAD_CONFIG_PERMISSIONS = {
148
+ DELETE: 'upload-config.delete'
149
+ };
144
150
  const EMAIL_CONFIG_PERMISSIONS = {
145
151
  CREATE: 'email-config.create',
146
152
  READ: 'email-config.read',
@@ -6,15 +6,15 @@ import { UtilsService } from '../modules/utils/utils.service';
6
6
  import { HybridCache } from './hybrid-cache.class';
7
7
  export declare abstract class ApiService<CreateDtoT extends object, UpdateDtoT extends {
8
8
  id: string;
9
- }, InterfaceT extends Identity, EntityT extends Identity, RepositoryT extends Repository<EntityT>> implements IService<CreateDtoT, UpdateDtoT, InterfaceT> {
9
+ }, InterfaceT extends Identity, EntityT extends Identity> implements IService<CreateDtoT, UpdateDtoT, InterfaceT> {
10
10
  protected entityName: string;
11
- protected repository: RepositoryT;
11
+ protected repository: Repository<EntityT>;
12
12
  protected cacheManager: HybridCache;
13
13
  protected utilsService: UtilsService;
14
14
  protected _loggerName: string;
15
15
  protected isCacheable: boolean;
16
16
  protected moduleName?: string;
17
- constructor(entityName: string, repository: RepositoryT, cacheManager: HybridCache, utilsService: UtilsService, _loggerName: string, isCacheable?: boolean, moduleName?: string);
17
+ constructor(entityName: string, repository: Repository<EntityT>, cacheManager: HybridCache, utilsService: UtilsService, _loggerName: string, isCacheable?: boolean, moduleName?: string);
18
18
  insert(dto: CreateDtoT, user: ILoggedUserInfo | null): Promise<InterfaceT>;
19
19
  insertMany(dtos: Array<CreateDtoT>, user: ILoggedUserInfo | null): Promise<InterfaceT[]>;
20
20
  update(dto: UpdateDtoT, user: ILoggedUserInfo | null): Promise<InterfaceT>;
@@ -4,7 +4,7 @@ import { IDataSourceProvider } from '../interfaces';
4
4
  import { ApiService } from './api-service.class';
5
5
  export declare abstract class RequestScopedApiService<CreateDtoT extends object, UpdateDtoT extends {
6
6
  id: string;
7
- }, InterfaceT extends Identity, EntityT extends Identity, RepositoryT extends Repository<EntityT>> extends ApiService<CreateDtoT, UpdateDtoT, InterfaceT, EntityT, RepositoryT> {
7
+ }, InterfaceT extends Identity, EntityT extends Identity> extends ApiService<CreateDtoT, UpdateDtoT, InterfaceT, EntityT> {
8
8
  private repositoryInitialized;
9
9
  protected abstract resolveEntity(): EntityTarget<EntityT>;
10
10
  protected abstract getDataSourceProvider(): IDataSourceProvider;
@@ -62,6 +62,9 @@ export declare const STORAGE_CONFIG_PERMISSIONS: {
62
62
  readonly UPDATE: "storage-config.update";
63
63
  readonly DELETE: "storage-config.delete";
64
64
  };
65
+ export declare const UPLOAD_CONFIG_PERMISSIONS: {
66
+ readonly DELETE: "upload-config.delete";
67
+ };
65
68
  export declare const EMAIL_CONFIG_PERMISSIONS: {
66
69
  readonly CREATE: "email-config.create";
67
70
  readonly READ: "email-config.read";
@@ -65,6 +65,9 @@ export const STORAGE_CONFIG_PERMISSIONS = {
65
65
  UPDATE: 'storage-config.update',
66
66
  DELETE: 'storage-config.delete'
67
67
  };
68
+ export const UPLOAD_CONFIG_PERMISSIONS = {
69
+ DELETE: 'upload-config.delete'
70
+ };
68
71
  // ==================== EMAIL MODULE ====================
69
72
  export const EMAIL_CONFIG_PERMISSIONS = {
70
73
  CREATE: 'email-config.create',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flusys/nestjs-shared",
3
- "version": "5.0.3",
3
+ "version": "5.1.0",
4
4
  "description": "Common shared utilities for Flusys NestJS applications",
5
5
  "main": "cjs/index.js",
6
6
  "module": "fesm/index.js",
@@ -112,6 +112,6 @@
112
112
  "rxjs": "^7.8.0"
113
113
  },
114
114
  "dependencies": {
115
- "@flusys/nestjs-core": "5.0.3"
115
+ "@flusys/nestjs-core": "5.1.0"
116
116
  }
117
117
  }