@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.
Files changed (40) hide show
  1. package/README.md +94 -18
  2. package/classes/api-controller.class.d.ts +1 -0
  3. package/classes/api-service.class.d.ts +7 -2
  4. package/classes/hybrid-cache.class.d.ts +17 -4
  5. package/constants/index.d.ts +1 -0
  6. package/constants/permissions.d.ts +9 -0
  7. package/fesm/183.js +7 -7
  8. package/fesm/{282.js → 47.js} +98 -158
  9. package/fesm/470.js +333 -382
  10. package/fesm/667.js +17 -17
  11. package/fesm/681.js +326 -129
  12. package/fesm/{948.js → 997.js} +45 -23
  13. package/fesm/chunks/123.js +17 -9
  14. package/fesm/chunks/37.js +5 -5
  15. package/fesm/classes/index.js +4 -3
  16. package/fesm/constants/index.js +18 -7
  17. package/fesm/decorators/index.js +120 -39
  18. package/fesm/dtos/index.js +1 -1
  19. package/fesm/entities/index.js +8 -8
  20. package/fesm/enums/index.js +2 -2
  21. package/fesm/exceptions/index.js +12 -12
  22. package/fesm/guards/index.js +201 -68
  23. package/fesm/index.js +50 -41
  24. package/fesm/interceptors/index.js +290 -590
  25. package/fesm/interfaces/index.js +17 -8
  26. package/fesm/middlewares/index.js +4 -4
  27. package/fesm/modules/index.js +2 -2
  28. package/fesm/pipes/index.js +8 -8
  29. package/fesm/utils/index.js +137 -478
  30. package/interceptors/idempotency.interceptor.d.ts +14 -2
  31. package/interceptors/slug.interceptor.d.ts +1 -0
  32. package/interfaces/permission-action-registry.interface.d.ts +1 -0
  33. package/interfaces/permission.interface.d.ts +1 -0
  34. package/modules/shared-permission-cache/shared-permission-cache.service.d.ts +3 -1
  35. package/modules/utils/utils.service.d.ts +6 -6
  36. package/package.json +2 -2
  37. package/utils/date-time.util.d.ts +0 -1
  38. package/utils/event-pattern.util.d.ts +1 -0
  39. package/utils/permission-cache-key.util.d.ts +3 -0
  40. package/utils/query-helpers.util.d.ts +2 -2
@@ -2,9 +2,9 @@ export const __rspack_esm_id = 405;
2
2
  export const __rspack_esm_ids = [405];
3
3
  export const __webpack_modules__ = {
4
4
  997(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
5
- /* import */ var _dtos_index_js__rspack_import_0 = __webpack_require__(746);
6
- /* import */ var _nestjs_common__rspack_import_1 = __webpack_require__(157);
7
- /* import */ var _nestjs_swagger__rspack_import_2 = __webpack_require__(176);
5
+ /* import */ var _dtos_index_js__rspack_import_0 = __webpack_require__(3746);
6
+ /* import */ var _nestjs_common__rspack_import_1 = __webpack_require__(6157);
7
+ /* import */ var _nestjs_swagger__rspack_import_2 = __webpack_require__(6176);
8
8
 
9
9
 
10
10
 
@@ -55,7 +55,7 @@ __webpack_require__.d(__webpack_exports__, {
55
55
 
56
56
 
57
57
  },
58
- 523(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
58
+ 9523(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
59
59
 
60
60
  // EXPORTS
61
61
  __webpack_require__.d(__webpack_exports__, {
@@ -72,7 +72,7 @@ __webpack_require__.d(__webpack_exports__, {
72
72
  // EXTERNAL MODULE: ./projects/nestjs-shared/src/decorators/api-response.decorator.ts
73
73
  var api_response_decorator = __webpack_require__(997);
74
74
  // EXTERNAL MODULE: external "@nestjs/common"
75
- var common_ = __webpack_require__(157);
75
+ var common_ = __webpack_require__(6157);
76
76
  ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/decorators/current-user.decorator.ts
77
77
 
78
78
  /**
@@ -94,9 +94,9 @@ var common_ = __webpack_require__(157);
94
94
  });
95
95
 
96
96
  // EXTERNAL MODULE: ./projects/nestjs-shared/src/decorators/log-action.decorator.ts
97
- var log_action_decorator = __webpack_require__(946);
97
+ var log_action_decorator = __webpack_require__(1946);
98
98
  // EXTERNAL MODULE: ./projects/nestjs-shared/src/constants/index.ts
99
- var constants = __webpack_require__(43);
99
+ var constants = __webpack_require__(6043);
100
100
  ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/decorators/on-domain-event.decorator.ts
101
101
 
102
102
 
@@ -170,10 +170,12 @@ var constants = __webpack_require__(43);
170
170
 
171
171
 
172
172
  },
173
- 946(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
174
- /* import */ var _nestjs_common__rspack_import_0 = __webpack_require__(157);
175
- /* import */ var _classes_winston_logger_class_js__rspack_import_1 = __webpack_require__(245);
176
- /* import */ var _middlewares_logger_middleware_js__rspack_import_2 = __webpack_require__(591);
173
+ 1946(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
174
+ /* import */ var _nestjs_common__rspack_import_0 = __webpack_require__(6157);
175
+ /* import */ var _classes_winston_logger_class_js__rspack_import_1 = __webpack_require__(6245);
176
+ /* import */ var _middlewares_logger_middleware_js__rspack_import_2 = __webpack_require__(8244);
177
+ /* import */ var _utils_event_pattern_util_js__rspack_import_3 = __webpack_require__(8456);
178
+
177
179
 
178
180
 
179
181
 
@@ -213,7 +215,6 @@ function LogAction(options = {}) {
213
215
  const methodName = String(propertyKey);
214
216
  descriptor.value = async function(...args) {
215
217
  const startTime = Date.now();
216
- // Resolve module: decorator option > instance property > undefined
217
218
  const moduleName = options.module || this.moduleName;
218
219
  const logger = createLoggerAdapter(className, moduleName);
219
220
  const action = options.action || `${this.entityName || className}.${methodName}`;
@@ -229,7 +230,7 @@ function LogAction(options = {}) {
229
230
  const startMessage = `Executing action method "${action}"`;
230
231
  const startContext = options.includeParams ? {
231
232
  ...context,
232
- params: sanitizeParams(args)
233
+ params: (0,_utils_event_pattern_util_js__rspack_import_3/* .sanitizeEventPayload */.IN)(args)
233
234
  } : context;
234
235
  logger.log(logLevel, startMessage, startContext);
235
236
  try {
@@ -263,30 +264,6 @@ function LogAction(options = {}) {
263
264
  return descriptor;
264
265
  };
265
266
  }
266
- function sanitizeParams(args) {
267
- return args.map((arg)=>{
268
- if (arg === null || arg === undefined) return arg;
269
- if (typeof arg === 'object') {
270
- const sanitized = {
271
- ...arg
272
- };
273
- const sensitiveKeys = [
274
- 'password',
275
- 'secret',
276
- 'token',
277
- 'apiKey',
278
- 'authorization'
279
- ];
280
- for (const key of Object.keys(sanitized)){
281
- if (sensitiveKeys.some((sk)=>key.toLowerCase().includes(sk))) {
282
- sanitized[key] = '[REDACTED]';
283
- }
284
- }
285
- return sanitized;
286
- }
287
- return arg;
288
- });
289
- }
290
267
  function getResultType(result) {
291
268
  if (result === null) return 'null';
292
269
  if (result === undefined) return 'undefined';
@@ -319,18 +296,122 @@ __webpack_require__.d(__webpack_exports__, {
319
296
  });
320
297
 
321
298
 
299
+ },
300
+ 8456(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
301
+ const SENSITIVE_KEYS = [
302
+ 'password',
303
+ 'secret',
304
+ 'token',
305
+ 'apikey',
306
+ 'authorization',
307
+ 'salt',
308
+ 'hash',
309
+ 'credential',
310
+ 'accesskey',
311
+ 'accountkey',
312
+ 'privatekey',
313
+ 'connectionstring',
314
+ 'passphrase'
315
+ ];
316
+ /**
317
+ * Matched whole, not as a substring - `pass` must be redacted without also
318
+ * redacting `bypassCache`, and a storage row's `key` is a path, not a secret.
319
+ *
320
+ * `config` is the provider settings blob on the storage and email config rows:
321
+ * S3, Azure, SFTP and SMTP credentials live in it, so it never leaves the
322
+ * process, even though the row itself still publishes.
323
+ */ const SENSITIVE_EXACT_KEYS = [
324
+ 'pass',
325
+ 'pwd',
326
+ 'config'
327
+ ];
328
+ const REDACTED = '[REDACTED]';
329
+ const CIRCULAR = '[CIRCULAR]';
330
+ const TRUNCATED = '[TRUNCATED]';
331
+ const BINARY = '[BINARY]';
332
+ const MAX_DEPTH = 8;
333
+ /**
334
+ * Matches a dot separated event name against a routing pattern.
335
+ * `*` matches exactly one segment, `#` and `**` match zero or more segments.
336
+ */ function matchEventPattern(pattern, eventName) {
337
+ if (pattern === eventName) return true;
338
+ return matchSegments(pattern.split('.'), eventName.split('.'));
339
+ }
340
+ function isMultiWildcard(segment) {
341
+ return segment === '#' || segment === '**';
342
+ }
343
+ /** Linear in pattern x name length: each (pattern, name) position is decided once, however many `#` there are. */ function matchSegments(pattern, name) {
344
+ let matches = new Array(name.length + 1).fill(false);
345
+ matches[name.length] = true;
346
+ for(let p = pattern.length - 1; p >= 0; p--){
347
+ const segment = pattern[p];
348
+ const next = new Array(name.length + 1).fill(false);
349
+ for(let n = name.length; n >= 0; n--){
350
+ if (isMultiWildcard(segment)) {
351
+ next[n] = matches[n] || n < name.length && next[n + 1];
352
+ } else {
353
+ next[n] = n < name.length && (segment === '*' || segment === name[n]) && matches[n + 1];
354
+ }
355
+ }
356
+ matches = next;
357
+ }
358
+ return matches[0];
359
+ }
360
+ /**
361
+ * Strips credential-like fields before a row leaves the process on an event.
362
+ *
363
+ * Saved TypeORM rows routinely carry bidirectional relations, so the walk
364
+ * tracks the current path and caps its depth - a cycle or a very deep graph
365
+ * must never turn an event into a stack overflow.
366
+ */ function sanitizeEventPayload(value) {
367
+ return sanitizeValue(value, new WeakSet(), 0);
368
+ }
369
+ function sanitizeValue(value, ancestors, depth) {
370
+ if (value === null || typeof value !== 'object') return value;
371
+ if (value instanceof Date) return value;
372
+ if (Buffer.isBuffer(value)) return BINARY;
373
+ if (ancestors.has(value)) return CIRCULAR;
374
+ if (depth >= MAX_DEPTH) return TRUNCATED;
375
+ ancestors.add(value);
376
+ try {
377
+ if (Array.isArray(value)) {
378
+ return value.map((item)=>sanitizeValue(item, ancestors, depth + 1));
379
+ }
380
+ const sanitized = {};
381
+ for (const [key, entry] of Object.entries(value)){
382
+ sanitized[key] = isSensitiveKey(key) ? REDACTED : sanitizeValue(entry, ancestors, depth + 1);
383
+ }
384
+ return sanitized;
385
+ } finally{
386
+ ancestors.delete(value);
387
+ }
388
+ }
389
+ /** Case and separator blind, so `apiKey`, `api_key`, `X-API-KEY` and `private-key` all match. */ function isSensitiveKey(key) {
390
+ const normalized = key.toLowerCase().replace(/[\s_.-]/g, '');
391
+ if (SENSITIVE_EXACT_KEYS.includes(normalized)) return true;
392
+ return SENSITIVE_KEYS.some((sensitive)=>normalized.includes(sensitive));
393
+ }
394
+
395
+ __webpack_require__.d(__webpack_exports__, {
396
+ Gd: () => (isSensitiveKey),
397
+ IN: () => (sanitizeEventPayload),
398
+ _c: () => (isMultiWildcard),
399
+ qe: () => (matchEventPattern)
400
+ });
401
+
402
+
322
403
  },
323
404
 
324
405
  };
325
406
  import { __webpack_require__ } from '../runtime.js';
326
407
  var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
327
- import * as __rspack_chunk_1 from '../948.js';
408
+ import * as __rspack_chunk_1 from '../997.js';
328
409
  __webpack_require__.C(__rspack_chunk_1);
329
410
  import * as __rspack_chunk_2 from '../183.js';
330
411
  __webpack_require__.C(__rspack_chunk_2);
331
412
  import * as __rspack_chunk_3 from './index.js';
332
413
  __webpack_require__.C(__rspack_chunk_3);
333
- var __webpack_exports__ = __webpack_exec__(523);var __webpack_exports__ApiResponseDto = __webpack_exports__.x_;
414
+ var __webpack_exports__ = __webpack_exec__(9523);var __webpack_exports__ApiResponseDto = __webpack_exports__.x_;
334
415
  var __webpack_exports__CurrentUser = __webpack_exports__.NO;
335
416
  var __webpack_exports__LogAction = __webpack_exports__.Jz;
336
417
  var __webpack_exports__OnDomainEvent = __webpack_exports__.kd;
@@ -7,7 +7,7 @@ import * as __rspack_chunk_1 from '../183.js';
7
7
  __webpack_require__.C(__rspack_chunk_1);
8
8
  import * as __rspack_chunk_2 from './index.js';
9
9
  __webpack_require__.C(__rspack_chunk_2);
10
- var __webpack_exports__ = __webpack_exec__(746);var __webpack_exports__BulkMetaDto = __webpack_exports__.L3;
10
+ var __webpack_exports__ = __webpack_exec__(3746);var __webpack_exports__BulkMetaDto = __webpack_exports__.L3;
11
11
  var __webpack_exports__BulkResponseDto = __webpack_exports__.jS;
12
12
  var __webpack_exports__DeleteDto = __webpack_exports__.TG;
13
13
  var __webpack_exports__FilterAndPaginationDto = __webpack_exports__.x;
@@ -3,8 +3,8 @@ import * as __rspack_external_typeorm from "typeorm";
3
3
  export const __rspack_esm_id = 604;
4
4
  export const __rspack_esm_ids = [604];
5
5
  export const __webpack_modules__ = {
6
- 504(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
7
- /* import */ var _flusys_nestjs_core__rspack_import_0 = __webpack_require__(436);
6
+ 8504(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
7
+ /* import */ var _flusys_nestjs_core__rspack_import_0 = __webpack_require__(8436);
8
8
 
9
9
  function getJsonColumnType() {
10
10
  const driver = _flusys_nestjs_core__rspack_import_0.envConfig.getTypeOrmConfig().type;
@@ -33,7 +33,7 @@ __webpack_require__.d(__webpack_exports__, {
33
33
 
34
34
 
35
35
  },
36
- 768(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
36
+ 1768(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
37
37
 
38
38
  // EXPORTS
39
39
  __webpack_require__.d(__webpack_exports__, {
@@ -42,7 +42,7 @@ __webpack_require__.d(__webpack_exports__, {
42
42
  });
43
43
 
44
44
  // EXTERNAL MODULE: external "typeorm"
45
- var external_typeorm_ = __webpack_require__(158);
45
+ var external_typeorm_ = __webpack_require__(7158);
46
46
  ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/entities/identity.ts
47
47
  function _ts_decorate(decorators, target, key, desc) {
48
48
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -130,7 +130,7 @@ _ts_decorate([
130
130
  ], Identity.prototype, "deletedById", void 0);
131
131
 
132
132
  // EXTERNAL MODULE: ./projects/nestjs-shared/src/classes/handle-custome-db.ts
133
- var handle_custome_db = __webpack_require__(504);
133
+ var handle_custome_db = __webpack_require__(8504);
134
134
  ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/entities/user-root.ts
135
135
  function user_root_ts_decorate(decorators, target, key, desc) {
136
136
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -313,13 +313,13 @@ user_root_ts_decorate([
313
313
 
314
314
 
315
315
  },
316
- 436(module) {
316
+ 8436(module) {
317
317
 
318
318
  module.exports = __rspack_external__flusys_nestjs_core_ff4ca4e2;
319
319
 
320
320
 
321
321
  },
322
- 158(module) {
322
+ 7158(module) {
323
323
 
324
324
  module.exports = __rspack_external_typeorm;
325
325
 
@@ -331,6 +331,6 @@ import { __webpack_require__ } from '../runtime.js';
331
331
  var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
332
332
  import * as __rspack_chunk_1 from './index.js';
333
333
  __webpack_require__.C(__rspack_chunk_1);
334
- var __webpack_exports__ = __webpack_exec__(768);var __webpack_exports__Identity = __webpack_exports__.l;
334
+ var __webpack_exports__ = __webpack_exec__(1768);var __webpack_exports__Identity = __webpack_exports__.l;
335
335
  var __webpack_exports__UserRoot = __webpack_exports__.q;
336
336
  export { __webpack_exports__Identity as Identity, __webpack_exports__UserRoot as UserRoot };
@@ -1,7 +1,7 @@
1
1
  export const __rspack_esm_id = 743;
2
2
  export const __rspack_esm_ids = [743];
3
3
  export const __webpack_modules__ = {
4
- 664(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
4
+ 7664(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
5
5
 
6
6
  // EXPORTS
7
7
  __webpack_require__.d(__webpack_exports__, {
@@ -51,7 +51,7 @@ import { __webpack_require__ } from '../runtime.js';
51
51
  var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
52
52
  import * as __rspack_chunk_1 from './index.js';
53
53
  __webpack_require__.C(__rspack_chunk_1);
54
- var __webpack_exports__ = __webpack_exec__(664);var __webpack_exports__NotificationType = __webpack_exports__._n;
54
+ var __webpack_exports__ = __webpack_exec__(7664);var __webpack_exports__NotificationType = __webpack_exports__._n;
55
55
  var __webpack_exports__ParticipantStatus = __webpack_exports__.cD;
56
56
  var __webpack_exports__RecurrenceType = __webpack_exports__.V5;
57
57
  export { __webpack_exports__NotificationType as NotificationType, __webpack_exports__ParticipantStatus as ParticipantStatus, __webpack_exports__RecurrenceType as RecurrenceType };
@@ -2,7 +2,7 @@ import * as __rspack_external__nestjs_common_a04939da from "@nestjs/common";
2
2
  export const __rspack_esm_id = 413;
3
3
  export const __rspack_esm_ids = [413];
4
4
  export const __webpack_modules__ = {
5
- 389(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
5
+ 4389(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
6
6
  // ==================== AUTH (Shared across guards/interceptors) ====================
7
7
  // These are duplicated in nestjs-auth but needed here to avoid circular dependencies
8
8
  const AUTH_MESSAGES = {
@@ -62,9 +62,9 @@ __webpack_require__.d(__webpack_exports__, {
62
62
 
63
63
 
64
64
  },
65
- 514(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
66
- /* import */ var _nestjs_common__rspack_import_0 = __webpack_require__(157);
67
- /* import */ var _constants_message_keys_js__rspack_import_1 = __webpack_require__(389);
65
+ 5514(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
66
+ /* import */ var _nestjs_common__rspack_import_0 = __webpack_require__(6157);
67
+ /* import */ var _constants_message_keys_js__rspack_import_1 = __webpack_require__(4389);
68
68
 
69
69
 
70
70
  class BaseAppException extends _nestjs_common__rspack_import_0.HttpException {
@@ -185,9 +185,9 @@ __webpack_require__.d(__webpack_exports__, {
185
185
 
186
186
 
187
187
  },
188
- 448(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
189
- /* import */ var _base_app_exception_js__rspack_import_0 = __webpack_require__(514);
190
- /* import */ var _permission_exception_js__rspack_import_1 = __webpack_require__(374);
188
+ 9448(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
189
+ /* import */ var _base_app_exception_js__rspack_import_0 = __webpack_require__(5514);
190
+ /* import */ var _permission_exception_js__rspack_import_1 = __webpack_require__(8374);
191
191
 
192
192
 
193
193
 
@@ -207,9 +207,9 @@ __webpack_require__.d(__webpack_exports__, {
207
207
 
208
208
 
209
209
  },
210
- 374(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
211
- /* import */ var _nestjs_common__rspack_import_0 = __webpack_require__(157);
212
- /* import */ var _constants_message_keys_js__rspack_import_1 = __webpack_require__(389);
210
+ 8374(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
211
+ /* import */ var _nestjs_common__rspack_import_0 = __webpack_require__(6157);
212
+ /* import */ var _constants_message_keys_js__rspack_import_1 = __webpack_require__(4389);
213
213
 
214
214
 
215
215
  class PermissionSystemUnavailableException extends _nestjs_common__rspack_import_0.InternalServerErrorException {
@@ -254,7 +254,7 @@ __webpack_require__.d(__webpack_exports__, {
254
254
 
255
255
 
256
256
  },
257
- 157(module) {
257
+ 6157(module) {
258
258
 
259
259
  module.exports = __rspack_external__nestjs_common_a04939da;
260
260
 
@@ -266,7 +266,7 @@ import { __webpack_require__ } from '../runtime.js';
266
266
  var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
267
267
  import * as __rspack_chunk_1 from './index.js';
268
268
  __webpack_require__.C(__rspack_chunk_1);
269
- var __webpack_exports__ = __webpack_exec__(448);var __webpack_exports__BaseAppException = __webpack_exports__.m8;
269
+ var __webpack_exports__ = __webpack_exec__(9448);var __webpack_exports__BaseAppException = __webpack_exports__.m8;
270
270
  var __webpack_exports__ConflictException = __webpack_exports__.cb;
271
271
  var __webpack_exports__ForbiddenException = __webpack_exports__.ZT;
272
272
  var __webpack_exports__InsufficientPermissionsException = __webpack_exports__.z8;