itlab-internal-services 2.16.4 → 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 (48) 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 -34
  30. package/dist/classes/task-manager.class.js +0 -54
  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/middleware/http-logging.middleware.js +1 -11
  35. package/dist/modules/services/providers/accounts.service.d.ts +15 -0
  36. package/dist/modules/services/providers/accounts.service.js +45 -2
  37. package/dist/modules/services/providers/mail/dtos/event-cancel-mail.dto.d.ts +4 -0
  38. package/dist/pipes/restricted-fields.pipe.d.ts +1 -24
  39. package/dist/pipes/restricted-fields.pipe.js +22 -20
  40. package/dist/types/has-timestamps.type.d.ts +4 -0
  41. package/dist/types/has-timestamps.type.js +2 -0
  42. package/dist/types/index.d.ts +1 -0
  43. package/dist/types/index.js +1 -0
  44. package/package.json +1 -1
  45. package/dist/interceptors/attribute-sanitizer.interceptor.d.ts +0 -68
  46. package/dist/interceptors/attribute-sanitizer.interceptor.js +0 -154
  47. package/dist/interceptors/index.d.ts +0 -1
  48. package/dist/interceptors/index.js +0 -17
@@ -1,4 +1,5 @@
1
1
  export { CommentableDocument } from './commentable-document.class';
2
2
  export { ContentDocument } from './content-document.class';
3
3
  export { LikeableDocument } from './likeable-document.class';
4
+ export { TimestampsDocument } from './timestamps-document.class';
4
5
  export { ViewableDocument } from './viewable-document.class';
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ViewableDocument = exports.LikeableDocument = exports.ContentDocument = exports.CommentableDocument = void 0;
3
+ exports.ViewableDocument = exports.TimestampsDocument = exports.LikeableDocument = exports.ContentDocument = exports.CommentableDocument = void 0;
4
4
  var commentable_document_class_1 = require("./commentable-document.class");
5
5
  Object.defineProperty(exports, "CommentableDocument", { enumerable: true, get: function () { return commentable_document_class_1.CommentableDocument; } });
6
6
  var content_document_class_1 = require("./content-document.class");
7
7
  Object.defineProperty(exports, "ContentDocument", { enumerable: true, get: function () { return content_document_class_1.ContentDocument; } });
8
8
  var likeable_document_class_1 = require("./likeable-document.class");
9
9
  Object.defineProperty(exports, "LikeableDocument", { enumerable: true, get: function () { return likeable_document_class_1.LikeableDocument; } });
10
+ var timestamps_document_class_1 = require("./timestamps-document.class");
11
+ Object.defineProperty(exports, "TimestampsDocument", { enumerable: true, get: function () { return timestamps_document_class_1.TimestampsDocument; } });
10
12
  var viewable_document_class_1 = require("./viewable-document.class");
11
13
  Object.defineProperty(exports, "ViewableDocument", { enumerable: true, get: function () { return viewable_document_class_1.ViewableDocument; } });
@@ -1,6 +1,8 @@
1
1
  import { Document } from 'mongoose';
2
2
  import { User } from '../../models';
3
- export declare function LikeableDocument<TBase extends new (...args: any[]) => Document>(Base: TBase): {
3
+ export declare function LikeableDocument<TBase extends new (...args: any[]) => Document>(Base: TBase, options?: {
4
+ requiredPermissions?: string[];
5
+ }): {
4
6
  new (...args: any[]): {
5
7
  _likedBy: string[];
6
8
  likes: number;
@@ -14,7 +14,8 @@ const mongoose_1 = require("@nestjs/mongoose");
14
14
  const swagger_1 = require("@nestjs/swagger");
15
15
  const class_validator_1 = require("class-validator");
16
16
  const models_1 = require("../../models");
17
- function LikeableDocument(Base) {
17
+ const pipes_1 = require("../../pipes");
18
+ function LikeableDocument(Base, options) {
18
19
  class LikeableDocument extends Base {
19
20
  hasLiked(accountId) {
20
21
  return this._likedBy.includes(accountId);
@@ -44,6 +45,7 @@ function LikeableDocument(Base) {
44
45
  default: [],
45
46
  }),
46
47
  (0, mongoose_1.Prop)({ type: [String], default: [] }),
48
+ (0, pipes_1.Restricted)(options === null || options === void 0 ? void 0 : options.requiredPermissions),
47
49
  __metadata("design:type", Array)
48
50
  ], LikeableDocument.prototype, "_likedBy", void 0);
49
51
  __decorate([
@@ -54,6 +56,7 @@ function LikeableDocument(Base) {
54
56
  default: 0,
55
57
  }),
56
58
  (0, mongoose_1.Prop)({ type: Number, default: 0 }),
59
+ (0, pipes_1.Restricted)(options === null || options === void 0 ? void 0 : options.requiredPermissions),
57
60
  __metadata("design:type", Number)
58
61
  ], LikeableDocument.prototype, "likes", void 0);
59
62
  __decorate([
@@ -64,6 +67,7 @@ function LikeableDocument(Base) {
64
67
  default: [],
65
68
  }),
66
69
  (0, mongoose_1.Virtual)(),
70
+ (0, pipes_1.Restricted)(options === null || options === void 0 ? void 0 : options.requiredPermissions),
67
71
  __metadata("design:type", Array)
68
72
  ], LikeableDocument.prototype, "likedBy", void 0);
69
73
  return LikeableDocument;
@@ -0,0 +1,200 @@
1
+ import { Document } from 'mongoose';
2
+ export declare function TimestampsDocument<TBase extends new (...args: any[]) => Document>(Base: TBase): {
3
+ new (...args: any[]): {
4
+ createdAt: Date;
5
+ updatedAt: Date;
6
+ _id: unknown;
7
+ $assertPopulated<Paths = {}>(path: string | string[], values?: Partial<Paths>): Omit</*elided*/ any, keyof Paths> & Paths;
8
+ $clearModifiedPaths(): /*elided*/ any;
9
+ $clone(): /*elided*/ any;
10
+ $createModifiedPathsSnapshot(): import("mongoose").ModifiedPathsSnapshot;
11
+ $getAllSubdocs(): Document[];
12
+ $ignore(path: string): void;
13
+ $isDefault(path?: string): boolean;
14
+ $isDeleted(val?: boolean): boolean;
15
+ $getPopulatedDocs(): Document[];
16
+ $inc(path: string | string[], val?: number): /*elided*/ any;
17
+ $isEmpty(path: string): boolean;
18
+ $isValid(path: string): boolean;
19
+ $locals: Record<string, unknown>;
20
+ $markValid(path: string): void;
21
+ $model<ModelType = import("mongoose").Model<unknown, {}, {}, {}, Document<unknown, {}, unknown, {}, {}> & Required<{
22
+ _id: unknown;
23
+ }> & {
24
+ __v: number;
25
+ }, any>>(name: string): ModelType;
26
+ $model<ModelType = import("mongoose").Model<any, {}, {}, {}, any, any>>(): ModelType;
27
+ $op: "save" | "validate" | "remove" | null;
28
+ $restoreModifiedPathsSnapshot(snapshot: import("mongoose").ModifiedPathsSnapshot): /*elided*/ any;
29
+ $session(session?: import("mongoose").ClientSession | null): import("mongoose").ClientSession | null;
30
+ $set(path: string | Record<string, any>, val: any, type: any, options?: import("mongoose").DocumentSetOptions): /*elided*/ any;
31
+ $set(path: string | Record<string, any>, val: any, options?: import("mongoose").DocumentSetOptions): /*elided*/ any;
32
+ $set(value: string | Record<string, any>): /*elided*/ any;
33
+ $where: Record<string, unknown>;
34
+ baseModelName?: string;
35
+ collection: import("mongoose").Collection;
36
+ db: import("mongoose").Connection;
37
+ deleteOne(options?: import("mongoose").QueryOptions): any;
38
+ depopulate<Paths = {}>(path?: string | string[]): import("mongoose").MergeType</*elided*/ any, Paths>;
39
+ directModifiedPaths(): Array<string>;
40
+ equals(doc: Document<unknown, any, any, Record<string, any>, {}>): boolean;
41
+ errors?: import("mongoose").Error.ValidationError;
42
+ get<T extends string | number | symbol>(path: T, type?: any, options?: any): any;
43
+ get(path: string, type?: any, options?: any): any;
44
+ getChanges(): import("mongoose").UpdateQuery</*elided*/ any>;
45
+ id?: any;
46
+ increment(): /*elided*/ any;
47
+ init(obj: import("mongoose").AnyObject, opts?: import("mongoose").AnyObject): /*elided*/ any;
48
+ invalidate<T extends string | number | symbol>(path: T, errorMsg: string | NativeError, value?: any, kind?: string): NativeError | null;
49
+ invalidate(path: string, errorMsg: string | NativeError, value?: any, kind?: string): NativeError | null;
50
+ isDirectModified<T extends string | number | symbol>(path: T | T[]): boolean;
51
+ isDirectModified(path: string | Array<string>): boolean;
52
+ isDirectSelected<T extends string | number | symbol>(path: T): boolean;
53
+ isDirectSelected(path: string): boolean;
54
+ isInit<T extends string | number | symbol>(path: T): boolean;
55
+ isInit(path: string): boolean;
56
+ isModified<T extends string | number | symbol>(path?: T | T[], options?: {
57
+ ignoreAtomics?: boolean;
58
+ } | null): boolean;
59
+ isModified(path?: string | Array<string>, options?: {
60
+ ignoreAtomics?: boolean;
61
+ } | null): boolean;
62
+ isNew: boolean;
63
+ isSelected<T extends string | number | symbol>(path: T): boolean;
64
+ isSelected(path: string): boolean;
65
+ markModified<T extends string | number | symbol>(path: T, scope?: any): void;
66
+ markModified(path: string, scope?: any): void;
67
+ model<ModelType = import("mongoose").Model<unknown, {}, {}, {}, Document<unknown, {}, unknown, {}, {}> & Required<{
68
+ _id: unknown;
69
+ }> & {
70
+ __v: number;
71
+ }, any>>(name: string): ModelType;
72
+ model<ModelType = import("mongoose").Model<any, {}, {}, {}, any, any>>(): ModelType;
73
+ modifiedPaths(options?: {
74
+ includeChildren?: boolean;
75
+ }): Array<string>;
76
+ overwrite(obj: import("mongoose").AnyObject): /*elided*/ any;
77
+ $parent(): Document | undefined;
78
+ populate<Paths = {}>(path: string | import("mongoose").PopulateOptions | (string | import("mongoose").PopulateOptions)[]): Promise<import("mongoose").MergeType</*elided*/ any, Paths>>;
79
+ populate<Paths = {}>(path: string, select?: string | import("mongoose").AnyObject, model?: import("mongoose").Model<any>, match?: import("mongoose").AnyObject, options?: import("mongoose").PopulateOptions): Promise<import("mongoose").MergeType</*elided*/ any, Paths>>;
80
+ populated(path: string): any;
81
+ replaceOne(replacement?: import("mongoose").AnyObject, options?: import("mongoose").QueryOptions | null): import("mongoose").Query<any, /*elided*/ any, {}, unknown, "find", Record<string, never>>;
82
+ save(options?: import("mongoose").SaveOptions): Promise</*elided*/ any>;
83
+ schema: import("mongoose").Schema;
84
+ set<T extends string | number | symbol>(path: T, val: any, type: any, options?: import("mongoose").DocumentSetOptions): /*elided*/ any;
85
+ set(path: string | Record<string, any>, val: any, type: any, options?: import("mongoose").DocumentSetOptions): /*elided*/ any;
86
+ set(path: string | Record<string, any>, val: any, options?: import("mongoose").DocumentSetOptions): /*elided*/ any;
87
+ set(value: string | Record<string, any>): /*elided*/ any;
88
+ toJSON(options: import("mongoose").ToObjectOptions & {
89
+ versionKey: false;
90
+ virtuals: true;
91
+ flattenObjectIds: true;
92
+ }): Omit<{
93
+ [x: string]: any;
94
+ }, "__v">;
95
+ toJSON(options: import("mongoose").ToObjectOptions & {
96
+ virtuals: true;
97
+ flattenObjectIds: true;
98
+ }): {
99
+ [x: string]: any;
100
+ };
101
+ toJSON(options: import("mongoose").ToObjectOptions & {
102
+ versionKey: false;
103
+ virtuals: true;
104
+ }): Omit<any, "__v">;
105
+ toJSON(options: import("mongoose").ToObjectOptions & {
106
+ versionKey: false;
107
+ flattenObjectIds: true;
108
+ }): {
109
+ [x: string]: any;
110
+ [x: number]: any;
111
+ [x: symbol]: any;
112
+ };
113
+ toJSON(options: import("mongoose").ToObjectOptions & {
114
+ virtuals: true;
115
+ }): any;
116
+ toJSON(options: import("mongoose").ToObjectOptions & {
117
+ versionKey: false;
118
+ }): Omit<any, "__v">;
119
+ toJSON(options?: import("mongoose").ToObjectOptions & {
120
+ flattenMaps?: true;
121
+ flattenObjectIds?: false;
122
+ }): import("mongoose").FlattenMaps<any>;
123
+ toJSON(options: import("mongoose").ToObjectOptions & {
124
+ flattenObjectIds: false;
125
+ }): import("mongoose").FlattenMaps<any>;
126
+ toJSON(options: import("mongoose").ToObjectOptions & {
127
+ flattenObjectIds: true;
128
+ }): {
129
+ [x: string]: any;
130
+ };
131
+ toJSON(options: import("mongoose").ToObjectOptions & {
132
+ flattenMaps: false;
133
+ }): any;
134
+ toJSON(options: import("mongoose").ToObjectOptions & {
135
+ flattenMaps: false;
136
+ flattenObjectIds: true;
137
+ }): any;
138
+ toJSON<T = any>(options?: import("mongoose").ToObjectOptions & {
139
+ flattenMaps?: true;
140
+ flattenObjectIds?: false;
141
+ }): import("mongoose").FlattenMaps<T>;
142
+ toJSON<T = any>(options: import("mongoose").ToObjectOptions & {
143
+ flattenObjectIds: false;
144
+ }): import("mongoose").FlattenMaps<T>;
145
+ toJSON<T = any>(options: import("mongoose").ToObjectOptions & {
146
+ flattenObjectIds: true;
147
+ }): import("mongoose").ObjectIdToString<import("mongoose").FlattenMaps<T>>;
148
+ toJSON<T = any>(options: import("mongoose").ToObjectOptions & {
149
+ flattenMaps: false;
150
+ }): T;
151
+ toJSON<T = any>(options: import("mongoose").ToObjectOptions & {
152
+ flattenMaps: false;
153
+ flattenObjectIds: true;
154
+ }): import("mongoose").ObjectIdToString<T>;
155
+ toObject(options: import("mongoose").ToObjectOptions & {
156
+ versionKey: false;
157
+ virtuals: true;
158
+ flattenObjectIds: true;
159
+ }): Omit<any, "__v">;
160
+ toObject(options: import("mongoose").ToObjectOptions & {
161
+ virtuals: true;
162
+ flattenObjectIds: true;
163
+ }): any;
164
+ toObject(options: import("mongoose").ToObjectOptions & {
165
+ versionKey: false;
166
+ flattenObjectIds: true;
167
+ }): Omit<any, "__v">;
168
+ toObject(options: import("mongoose").ToObjectOptions & {
169
+ versionKey: false;
170
+ virtuals: true;
171
+ }): Omit<any, "__v">;
172
+ toObject(options: import("mongoose").ToObjectOptions & {
173
+ virtuals: true;
174
+ }): any;
175
+ toObject(options: import("mongoose").ToObjectOptions & {
176
+ versionKey: false;
177
+ }): Omit<any, "__v">;
178
+ toObject(options: import("mongoose").ToObjectOptions & {
179
+ flattenObjectIds: true;
180
+ }): any;
181
+ toObject(options?: import("mongoose").ToObjectOptions): any;
182
+ toObject<T>(options?: import("mongoose").ToObjectOptions): import("mongoose").Require_id<T> & {
183
+ __v: number;
184
+ };
185
+ unmarkModified<T extends string | number | symbol>(path: T): void;
186
+ unmarkModified(path: string): void;
187
+ updateOne(update?: import("mongoose").UpdateWithAggregationPipeline | import("mongoose").UpdateQuery</*elided*/ any>, options?: import("mongoose").QueryOptions | null): import("mongoose").Query<any, /*elided*/ any, {}, unknown, "find", Record<string, never>>;
188
+ validate<T extends string | number | symbol>(pathsToValidate?: T | T[], options?: import("mongoose").AnyObject): Promise<void>;
189
+ validate(pathsToValidate?: import("mongoose").pathsToValidate, options?: import("mongoose").AnyObject): Promise<void>;
190
+ validate(options: {
191
+ pathsToSkip?: import("mongoose").pathsToSkip;
192
+ }): Promise<void>;
193
+ validateSync(options: {
194
+ pathsToSkip?: import("mongoose").pathsToSkip;
195
+ [k: string]: any;
196
+ }): import("mongoose").Error.ValidationError | null;
197
+ validateSync<T extends string | number | symbol>(pathsToValidate?: T | T[], options?: import("mongoose").AnyObject): import("mongoose").Error.ValidationError | null;
198
+ validateSync(pathsToValidate?: import("mongoose").pathsToValidate, options?: import("mongoose").AnyObject): import("mongoose").Error.ValidationError | null;
199
+ };
200
+ } & TBase;
@@ -0,0 +1,27 @@
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.TimestampsDocument = TimestampsDocument;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ function TimestampsDocument(Base) {
15
+ class TimestampsDocument extends Base {
16
+ }
17
+ __decorate([
18
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Timestamps' }),
19
+ (0, swagger_1.ApiPropertyOptional)(),
20
+ __metadata("design:type", Date)
21
+ ], TimestampsDocument.prototype, "createdAt", void 0);
22
+ __decorate([
23
+ (0, swagger_1.ApiPropertyOptional)(),
24
+ __metadata("design:type", Date)
25
+ ], TimestampsDocument.prototype, "updatedAt", void 0);
26
+ return TimestampsDocument;
27
+ }
@@ -1,6 +1,8 @@
1
1
  import { Document } from 'mongoose';
2
2
  import { User } from '../../models';
3
- export declare function ViewableDocument<TBase extends new (...args: any[]) => Document>(Base: TBase): {
3
+ export declare function ViewableDocument<TBase extends new (...args: any[]) => Document>(Base: TBase, options?: {
4
+ requiredPermissions?: string[];
5
+ }): {
4
6
  new (...args: any[]): {
5
7
  _viewedBy: string[];
6
8
  views: number;
@@ -14,7 +14,8 @@ const mongoose_1 = require("@nestjs/mongoose");
14
14
  const swagger_1 = require("@nestjs/swagger");
15
15
  const class_validator_1 = require("class-validator");
16
16
  const models_1 = require("../../models");
17
- function ViewableDocument(Base) {
17
+ const pipes_1 = require("../../pipes");
18
+ function ViewableDocument(Base, options) {
18
19
  class ViewableDocument extends Base {
19
20
  hasViewed(accountId) {
20
21
  return this._viewedBy.includes(accountId);
@@ -43,6 +44,7 @@ function ViewableDocument(Base) {
43
44
  default: [],
44
45
  }),
45
46
  (0, mongoose_1.Prop)({ type: [String], default: [] }),
47
+ (0, pipes_1.Restricted)(options === null || options === void 0 ? void 0 : options.requiredPermissions),
46
48
  __metadata("design:type", Array)
47
49
  ], ViewableDocument.prototype, "_viewedBy", void 0);
48
50
  __decorate([
@@ -52,6 +54,7 @@ function ViewableDocument(Base) {
52
54
  default: 0,
53
55
  }),
54
56
  (0, mongoose_1.Prop)({ type: Number, default: 0 }),
57
+ (0, pipes_1.Restricted)(options === null || options === void 0 ? void 0 : options.requiredPermissions),
55
58
  __metadata("design:type", Number)
56
59
  ], ViewableDocument.prototype, "views", void 0);
57
60
  __decorate([
@@ -61,6 +64,7 @@ function ViewableDocument(Base) {
61
64
  default: [],
62
65
  }),
63
66
  (0, mongoose_1.Virtual)(),
67
+ (0, pipes_1.Restricted)(options === null || options === void 0 ? void 0 : options.requiredPermissions),
64
68
  __metadata("design:type", Array)
65
69
  ], ViewableDocument.prototype, "viewedBy", void 0);
66
70
  return ViewableDocument;
@@ -0,0 +1,21 @@
1
+ export declare class EntityMap<T extends {
2
+ id: string;
3
+ }> {
4
+ private readonly map;
5
+ constructor(items?: T[]);
6
+ /**
7
+ * Maps a single ID to an user/account object using a user/account Map.
8
+ * @param id ID of user/account to map
9
+ * @param map Map of id -> user/account object
10
+ * @returns user/account object
11
+ */
12
+ get(id: string): T;
13
+ /**
14
+ * Maps an array of IDs to user/account objects using a user/account Map.
15
+ * Filters out any IDs that don’t have a corresponding entity.
16
+ * @param ids Array of user/account IDs to map
17
+ * @param map Map of id -> user/account object
18
+ * @returns Array of user/account objects
19
+ */
20
+ getMultiple(ids: string[]): T[];
21
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntityMap = void 0;
4
+ class EntityMap {
5
+ constructor(items = []) {
6
+ this.map = new Map(items.map((item) => [item.id, item]));
7
+ }
8
+ /**
9
+ * Maps a single ID to an user/account object using a user/account Map.
10
+ * @param id ID of user/account to map
11
+ * @param map Map of id -> user/account object
12
+ * @returns user/account object
13
+ */
14
+ get(id) {
15
+ return this.map.get(id);
16
+ }
17
+ /**
18
+ * Maps an array of IDs to user/account objects using a user/account Map.
19
+ * Filters out any IDs that don’t have a corresponding entity.
20
+ * @param ids Array of user/account IDs to map
21
+ * @param map Map of id -> user/account object
22
+ * @returns Array of user/account objects
23
+ */
24
+ getMultiple(ids) {
25
+ return ids.map((id) => this.map.get(id)).filter(Boolean);
26
+ }
27
+ }
28
+ exports.EntityMap = EntityMap;
@@ -1,3 +1,4 @@
1
+ import { Document, FilterQuery, QueryOptions } from 'mongoose';
1
2
  export declare class BaseOptions {
2
3
  /**
3
4
  * Basic
@@ -16,3 +17,4 @@ export declare class BaseOptions {
16
17
  skip?: number;
17
18
  limit?: number;
18
19
  }
20
+ export declare function parseBaseOptions<TOptions extends BaseOptions, TDocument extends Document>(options: TOptions, filterQuery: FilterQuery<TDocument>, queryOptions: QueryOptions<TDocument>): void;
@@ -10,6 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.BaseOptions = void 0;
13
+ exports.parseBaseOptions = parseBaseOptions;
13
14
  const swagger_1 = require("@nestjs/swagger");
14
15
  const class_validator_1 = require("class-validator");
15
16
  const transform_1 = require("../../transform");
@@ -79,3 +80,19 @@ __decorate([
79
80
  (0, class_validator_1.IsOptional)(),
80
81
  __metadata("design:type", Number)
81
82
  ], BaseOptions.prototype, "limit", void 0);
83
+ function parseBaseOptions(options, filterQuery, queryOptions) {
84
+ var _a, _b, _c, _d, _e, _f;
85
+ // Handle IDs: Combine single and multiple document IDs into a single $in filter.
86
+ const idSet = new Set([...(options.id ? [options.id] : []), ...((_a = options.ids) !== null && _a !== void 0 ? _a : [])]);
87
+ if (idSet.size > 0)
88
+ filterQuery._id = { $in: Array.from(idSet) };
89
+ // Sorting: Default sort by _id descending unless overridden in filterQuery.
90
+ const sortField = (_b = options.sortField) !== null && _b !== void 0 ? _b : '_id';
91
+ const sortDirection = (_c = options.sortDirection) !== null && _c !== void 0 ? _c : -1;
92
+ (_d = queryOptions.sort) !== null && _d !== void 0 ? _d : (queryOptions.sort = { [sortField]: sortDirection });
93
+ // Pagination: Respect limit and skip if explicitly set in filterQuery.
94
+ if (options.limit !== undefined)
95
+ (_e = queryOptions.limit) !== null && _e !== void 0 ? _e : (queryOptions.limit = options.limit);
96
+ if (options.skip !== undefined)
97
+ (_f = queryOptions.skip) !== null && _f !== void 0 ? _f : (queryOptions.skip = options.skip);
98
+ }
@@ -1,6 +1,14 @@
1
+ import { LabComment } from 'itlab-functions';
2
+ import { CommentsService } from '../../modules';
1
3
  export declare function CommentsOptions<TBase extends new (...args: any[]) => any>(Base: TBase): {
2
4
  new (...args: any[]): {
3
5
  [x: string]: any;
4
6
  includeComments?: boolean;
5
7
  };
6
8
  } & TBase;
9
+ export declare function populateComments(options: {
10
+ includeComments?: boolean;
11
+ }, items: {
12
+ _id: unknown;
13
+ comments?: LabComment[];
14
+ }[], commentsService: CommentsService): Promise<void>;
@@ -10,9 +10,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CommentsOptions = CommentsOptions;
13
+ exports.populateComments = populateComments;
13
14
  const swagger_1 = require("@nestjs/swagger");
14
15
  const class_validator_1 = require("class-validator");
15
16
  const transform_1 = require("../../transform");
17
+ const task_manager_class_1 = require("../task-manager.class");
16
18
  function CommentsOptions(Base) {
17
19
  class CommentsOptions extends Base {
18
20
  }
@@ -24,3 +26,15 @@ function CommentsOptions(Base) {
24
26
  ], CommentsOptions.prototype, "includeComments", void 0);
25
27
  return CommentsOptions;
26
28
  }
29
+ async function populateComments(options, items, commentsService) {
30
+ if (options.includeComments) {
31
+ const taskManager = new task_manager_class_1.TaskManager();
32
+ items.forEach((item) => {
33
+ const itemId = item._id.toString();
34
+ taskManager.add(async () => {
35
+ item.comments = await commentsService.getCachedPopulatedComments(itemId);
36
+ });
37
+ });
38
+ return taskManager.run();
39
+ }
40
+ }
@@ -1,7 +1,14 @@
1
- import { ContentReturnType } from '../../modules';
1
+ import { LabContent, LabContentPopulated } from 'itlab-functions';
2
+ import { ContentReturnType, ContentService } from '../../modules';
2
3
  export declare function ContentOptions<TBase extends new (...args: any[]) => any>(Base: TBase): {
3
4
  new (...args: any[]): {
4
5
  [x: string]: any;
5
6
  includeContent?: ContentReturnType;
6
7
  };
7
8
  } & TBase;
9
+ export declare function populateContent(options: {
10
+ includeContent?: ContentReturnType;
11
+ }, items: {
12
+ _id: unknown;
13
+ content?: LabContent | LabContentPopulated | string;
14
+ }[], contentService: ContentService): Promise<void>;
@@ -10,11 +10,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ContentOptions = ContentOptions;
13
+ exports.populateContent = populateContent;
13
14
  const swagger_1 = require("@nestjs/swagger");
14
15
  const class_transformer_1 = require("class-transformer");
15
16
  const class_validator_1 = require("class-validator");
16
17
  const content_return_types_1 = require("../../modules/services/providers/content/content-return-types");
17
18
  const properties_1 = require("../../properties");
19
+ const task_manager_class_1 = require("../task-manager.class");
18
20
  function ContentOptions(Base) {
19
21
  class ContentOptions extends Base {
20
22
  }
@@ -30,3 +32,15 @@ function ContentOptions(Base) {
30
32
  ], ContentOptions.prototype, "includeContent", void 0);
31
33
  return ContentOptions;
32
34
  }
35
+ async function populateContent(options, items, contentService) {
36
+ if (options.includeContent) {
37
+ const taskManager = new task_manager_class_1.TaskManager();
38
+ items.forEach((item) => {
39
+ const itemId = item._id.toString();
40
+ taskManager.add(async () => {
41
+ item.content = await contentService.getCachedContent(itemId, options.includeContent);
42
+ });
43
+ });
44
+ return taskManager.run();
45
+ }
46
+ }
@@ -1,5 +1,6 @@
1
- export declare function DraftedOptions<TBase extends new (...args: any[]) => any>(Base: TBase, options?: {
2
- requiredPermissions?: string[];
1
+ import { Document, FilterQuery } from 'mongoose';
2
+ export declare function DraftedOptions<TBase extends new (...args: any[]) => any>(Base: TBase, options: {
3
+ requiredPermissions: string[];
3
4
  }): {
4
5
  new (...args: any[]): {
5
6
  [x: string]: any;
@@ -7,3 +8,7 @@ export declare function DraftedOptions<TBase extends new (...args: any[]) => any
7
8
  isDraft?: boolean;
8
9
  };
9
10
  } & TBase;
11
+ export declare function parseDraftedOptions<TOptions extends {
12
+ includeDrafted?: boolean;
13
+ isDraft?: boolean;
14
+ }>(options: TOptions, filterQuery: FilterQuery<Document>, onDraftsExcluded?: VoidFunction): void;
@@ -10,6 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.DraftedOptions = DraftedOptions;
13
+ exports.parseDraftedOptions = parseDraftedOptions;
13
14
  const swagger_1 = require("@nestjs/swagger");
14
15
  const class_validator_1 = require("class-validator");
15
16
  const pipes_1 = require("../../pipes");
@@ -21,14 +22,24 @@ function DraftedOptions(Base, options) {
21
22
  (0, swagger_1.ApiPropertyOptional)({ example: true }),
22
23
  (0, transform_1.BooleanTransform)(),
23
24
  (0, class_validator_1.IsOptional)(),
24
- (0, pipes_1.Restricted)(options === null || options === void 0 ? void 0 : options.requiredPermissions),
25
+ (0, pipes_1.Restricted)(options.requiredPermissions),
25
26
  __metadata("design:type", Boolean)
26
27
  ], DraftedOptions.prototype, "includeDrafted", void 0);
27
28
  __decorate([
28
29
  (0, swagger_1.ApiPropertyOptional)(),
29
30
  (0, transform_1.BooleanTransform)(),
30
31
  (0, class_validator_1.IsOptional)(),
32
+ (0, pipes_1.Restricted)(options.requiredPermissions),
31
33
  __metadata("design:type", Boolean)
32
34
  ], DraftedOptions.prototype, "isDraft", void 0);
33
35
  return DraftedOptions;
34
36
  }
37
+ function parseDraftedOptions(options, filterQuery, onDraftsExcluded) {
38
+ // Include draft status in filter if explicitly set
39
+ if (options.isDraft !== undefined)
40
+ filterQuery.draft = options.isDraft;
41
+ if (options.includeDrafted === undefined && options.isDraft === undefined) {
42
+ filterQuery.draft = false;
43
+ onDraftsExcluded === null || onDraftsExcluded === void 0 ? void 0 : onDraftsExcluded();
44
+ }
45
+ }
@@ -1,6 +1,7 @@
1
- export { BaseOptions } from './base-options.class';
2
- export { CommentsOptions } from './comments-options.class';
3
- export { ContentOptions } from './content-options.class';
4
- export { DraftedOptions } from './drafted-options.class';
5
- export { LikedByOptions } from './liked-by-options.class';
6
- export { ViewedByOptions } from './viewed-by-options.class';
1
+ export * from './base-options.class';
2
+ export * from './comments-options.class';
3
+ export * from './content-options.class';
4
+ export * from './drafted-options.class';
5
+ export * from './liked-by-options.class';
6
+ export * from './timestamps-options.class';
7
+ export * from './viewed-by-options.class';
@@ -1,15 +1,23 @@
1
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
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ViewedByOptions = exports.LikedByOptions = exports.DraftedOptions = exports.ContentOptions = exports.CommentsOptions = exports.BaseOptions = void 0;
4
- var base_options_class_1 = require("./base-options.class");
5
- Object.defineProperty(exports, "BaseOptions", { enumerable: true, get: function () { return base_options_class_1.BaseOptions; } });
6
- var comments_options_class_1 = require("./comments-options.class");
7
- Object.defineProperty(exports, "CommentsOptions", { enumerable: true, get: function () { return comments_options_class_1.CommentsOptions; } });
8
- var content_options_class_1 = require("./content-options.class");
9
- Object.defineProperty(exports, "ContentOptions", { enumerable: true, get: function () { return content_options_class_1.ContentOptions; } });
10
- var drafted_options_class_1 = require("./drafted-options.class");
11
- Object.defineProperty(exports, "DraftedOptions", { enumerable: true, get: function () { return drafted_options_class_1.DraftedOptions; } });
12
- var liked_by_options_class_1 = require("./liked-by-options.class");
13
- Object.defineProperty(exports, "LikedByOptions", { enumerable: true, get: function () { return liked_by_options_class_1.LikedByOptions; } });
14
- var viewed_by_options_class_1 = require("./viewed-by-options.class");
15
- Object.defineProperty(exports, "ViewedByOptions", { enumerable: true, get: function () { return viewed_by_options_class_1.ViewedByOptions; } });
17
+ __exportStar(require("./base-options.class"), exports);
18
+ __exportStar(require("./comments-options.class"), exports);
19
+ __exportStar(require("./content-options.class"), exports);
20
+ __exportStar(require("./drafted-options.class"), exports);
21
+ __exportStar(require("./liked-by-options.class"), exports);
22
+ __exportStar(require("./timestamps-options.class"), exports);
23
+ __exportStar(require("./viewed-by-options.class"), exports);
@@ -1,6 +1,13 @@
1
+ import { AccountsService } from '../../modules';
2
+ import { IsLikeable } from '../../types';
1
3
  export declare function LikedByOptions<TBase extends new (...args: any[]) => any>(Base: TBase): {
2
4
  new (...args: any[]): {
3
5
  [x: string]: any;
4
6
  includeLikedBy?: boolean;
7
+ includeLikedByIds?: boolean;
5
8
  };
6
9
  } & TBase;
10
+ export declare function populateLikedBy(options: {
11
+ includeLikedBy?: boolean;
12
+ includeLikedByIds?: boolean;
13
+ }, items: IsLikeable[], accountsService: AccountsService): Promise<void>;