itlab-internal-services 2.16.5 → 2.16.6

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 (47) hide show
  1. package/dist/classes/document/index.d.ts +1 -0
  2. package/dist/classes/document/index.js +3 -1
  3. package/dist/classes/document/likeable-document.class.d.ts +3 -1
  4. package/dist/classes/document/likeable-document.class.js +5 -1
  5. package/dist/classes/document/timestamps-document.class.d.ts +200 -0
  6. package/dist/classes/document/timestamps-document.class.js +27 -0
  7. package/dist/classes/document/viewable-document.class.d.ts +3 -1
  8. package/dist/classes/document/viewable-document.class.js +5 -1
  9. package/dist/classes/entity-map.class.d.ts +21 -0
  10. package/dist/classes/entity-map.class.js +28 -0
  11. package/dist/classes/fetch-options/base-options.class.d.ts +2 -0
  12. package/dist/classes/fetch-options/base-options.class.js +17 -0
  13. package/dist/classes/fetch-options/comments-options.class.d.ts +8 -0
  14. package/dist/classes/fetch-options/comments-options.class.js +14 -0
  15. package/dist/classes/fetch-options/content-options.class.d.ts +8 -1
  16. package/dist/classes/fetch-options/content-options.class.js +14 -0
  17. package/dist/classes/fetch-options/drafted-options.class.d.ts +7 -2
  18. package/dist/classes/fetch-options/drafted-options.class.js +12 -1
  19. package/dist/classes/fetch-options/index.d.ts +7 -6
  20. package/dist/classes/fetch-options/index.js +21 -13
  21. package/dist/classes/fetch-options/liked-by-options.class.d.ts +7 -0
  22. package/dist/classes/fetch-options/liked-by-options.class.js +27 -0
  23. package/dist/classes/fetch-options/timestamps-options.class.d.ts +12 -0
  24. package/dist/classes/fetch-options/timestamps-options.class.js +38 -0
  25. package/dist/classes/fetch-options/viewed-by-options.class.d.ts +10 -2
  26. package/dist/classes/fetch-options/viewed-by-options.class.js +35 -1
  27. package/dist/classes/index.d.ts +1 -0
  28. package/dist/classes/index.js +3 -1
  29. package/dist/classes/task-manager.class.d.ts +0 -38
  30. package/dist/classes/task-manager.class.js +0 -58
  31. package/dist/decorators/authenticated-account.decorator.d.ts +1 -1
  32. package/dist/index.d.ts +0 -1
  33. package/dist/index.js +0 -1
  34. package/dist/modules/services/providers/accounts.service.d.ts +15 -0
  35. package/dist/modules/services/providers/accounts.service.js +33 -0
  36. package/dist/modules/services/providers/mail/dtos/event-cancel-mail.dto.d.ts +4 -0
  37. package/dist/pipes/restricted-fields.pipe.d.ts +1 -24
  38. package/dist/pipes/restricted-fields.pipe.js +22 -20
  39. package/dist/types/has-timestamps.type.d.ts +4 -0
  40. package/dist/types/has-timestamps.type.js +2 -0
  41. package/dist/types/index.d.ts +1 -0
  42. package/dist/types/index.js +1 -0
  43. package/package.json +1 -1
  44. package/dist/interceptors/attribute-sanitizer.interceptor.d.ts +0 -68
  45. package/dist/interceptors/attribute-sanitizer.interceptor.js +0 -154
  46. package/dist/interceptors/index.d.ts +0 -1
  47. package/dist/interceptors/index.js +0 -17
@@ -1,154 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AttributeSanitizerInterceptor = void 0;
13
- exports.UseAttributeSanitizer = UseAttributeSanitizer;
14
- const common_1 = require("@nestjs/common");
15
- const operators_1 = require("rxjs/operators");
16
- /**
17
- * AttributeSanitizerInterceptor
18
- *
19
- * This interceptor removes specified attributes from response objects.
20
- * It works with plain objects, arrays, sets, maps and also with Mongoose
21
- * documents by normalizing them to plain objects before sanitization.
22
- *
23
- * This is especially useful for removing sensitive fields (e.g., passwords,
24
- * tokens, SSNs) consistently across deeply nested response structures.
25
- */
26
- let AttributeSanitizerInterceptor = class AttributeSanitizerInterceptor {
27
- /**
28
- * @param keys - One or more property names to remove from every object.
29
- * @param mongooseToObjectOptions - Options forwarded to Mongoose `.toObject()`
30
- * when normalizing documents.
31
- */
32
- constructor(keys, mongooseToObjectOptions = {
33
- virtuals: true,
34
- getters: true,
35
- versionKey: false,
36
- }) {
37
- this.keys = keys;
38
- this.mongooseToObjectOptions = mongooseToObjectOptions;
39
- }
40
- /**
41
- * Intercepts the response and removes the targeted attributes.
42
- *
43
- * @param _context - Execution context (unused here).
44
- * @param next - Next handler in the pipeline.
45
- * @returns Sanitized response data.
46
- */
47
- intercept(_context, next) {
48
- return next.handle().pipe((0, operators_1.map)((data) => this.sanitizeRecursively(data)));
49
- }
50
- /**
51
- * Recursively removes targeted keys from objects, arrays, and nested structures.
52
- *
53
- * @param value - Any response value.
54
- * @returns A sanitized value without the targeted attributes.
55
- */
56
- sanitizeRecursively(value) {
57
- const normalized = this.normalizeIfMongooseDocument(value);
58
- if (normalized === null || typeof normalized !== 'object') {
59
- return normalized;
60
- }
61
- // Handle arrays
62
- if (Array.isArray(normalized)) {
63
- return normalized.map((item) => this.sanitizeRecursively(item));
64
- }
65
- // Handle Set → array
66
- if (normalized instanceof Set) {
67
- return Array.from(normalized).map((item) => this.sanitizeRecursively(item));
68
- }
69
- // Handle Map → plain object
70
- if (normalized instanceof Map) {
71
- const obj = {};
72
- for (const [k, v] of normalized.entries()) {
73
- obj[String(k)] = this.sanitizeRecursively(v);
74
- }
75
- return obj;
76
- }
77
- // Handle plain objects
78
- if (this.isPlainObject(normalized)) {
79
- const forbidden = this.ensureKeySet(this.keys);
80
- const result = {};
81
- for (const [prop, nested] of Object.entries(normalized)) {
82
- if (forbidden.has(prop))
83
- continue;
84
- result[prop] = this.sanitizeRecursively(nested);
85
- }
86
- return result;
87
- }
88
- // Other complex types (Date, Buffer, etc.) → leave unchanged
89
- return normalized;
90
- }
91
- /**
92
- * Converts a Mongoose document to a plain object if needed.
93
- *
94
- * @param value - Possible Mongoose document.
95
- * @returns A plain object if conversion is possible, otherwise the value itself.
96
- */
97
- normalizeIfMongooseDocument(value) {
98
- // Heuristic: Mongoose documents expose `.toObject()` and an internal `$__`.
99
- // We avoid importing `mongoose` to keep this interceptor framework-agnostic.
100
- const maybeDoc = value;
101
- if (maybeDoc &&
102
- typeof maybeDoc === 'object' &&
103
- (typeof maybeDoc.toObject === 'function' || typeof maybeDoc.toJSON === 'function') &&
104
- '$__' in maybeDoc) {
105
- try {
106
- if (typeof maybeDoc.toObject === 'function')
107
- return maybeDoc.toObject(this.mongooseToObjectOptions);
108
- if (typeof maybeDoc.toJSON === 'function')
109
- return maybeDoc.toJSON(this.mongooseToObjectOptions);
110
- }
111
- catch (_a) {
112
- // If normalization fails, fall back to the original value—better to
113
- // return data than to throw at the last step.
114
- return value;
115
- }
116
- }
117
- return value;
118
- }
119
- /**
120
- * Checks whether a value is a plain object (and not a class instance, Date, etc.).
121
- *
122
- * @param value - Any value.
123
- * @returns True if the value is a plain object.
124
- */
125
- isPlainObject(value) {
126
- return Object.prototype.toString.call(value) === '[object Object]';
127
- }
128
- /**
129
- * Converts the user-provided keys into a Set for O(1) lookup.
130
- *
131
- * @param keys - String or array of strings.
132
- * @returns A Set of keys.
133
- */
134
- ensureKeySet(keys) {
135
- return Array.isArray(keys) ? new Set(keys) : new Set([keys]);
136
- }
137
- };
138
- exports.AttributeSanitizerInterceptor = AttributeSanitizerInterceptor;
139
- exports.AttributeSanitizerInterceptor = AttributeSanitizerInterceptor = __decorate([
140
- (0, common_1.Injectable)(),
141
- __metadata("design:paramtypes", [Object, Object])
142
- ], AttributeSanitizerInterceptor);
143
- /**
144
- * @UseAttributeSanitizer
145
- *
146
- * Convenience decorator that applies the AttributeSanitizerInterceptor
147
- * to a route or controller.
148
- *
149
- * @param keys - One or more keys to remove from all response objects.
150
- * @param mongooseToObjectOptions - Options for Mongoose `.toObject()` normalization.
151
- */
152
- function UseAttributeSanitizer(keys, mongooseToObjectOptions) {
153
- return (0, common_1.UseInterceptors)(new AttributeSanitizerInterceptor(keys, mongooseToObjectOptions));
154
- }
@@ -1 +0,0 @@
1
- export * from './attribute-sanitizer.interceptor';
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./attribute-sanitizer.interceptor"), exports);