itlab-internal-services 2.2.2 → 2.4.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/dist/axios.d.ts +16 -0
- package/dist/{modules/services/services.module-utils.js → axios.js} +6 -1
- package/dist/env.d.ts +14 -0
- package/dist/env.js +14 -0
- package/dist/exceptions/bad-body.exception.d.ts +22 -1
- package/dist/exceptions/bad-body.exception.js +42 -1
- package/dist/exceptions/duplicate.exception.d.ts +22 -1
- package/dist/exceptions/duplicate.exception.js +42 -1
- package/dist/exceptions/index.d.ts +18 -0
- package/dist/exceptions/index.js +11 -0
- package/dist/exceptions/not-found.exception.d.ts +22 -1
- package/dist/exceptions/not-found.exception.js +42 -1
- package/dist/favicon.controller.d.ts +12 -0
- package/dist/favicon.controller.js +13 -0
- package/dist/guards/perms.guard.d.ts +28 -0
- package/dist/guards/perms.guard.js +40 -2
- package/dist/guards/puplic.guard.d.ts +5 -0
- package/dist/guards/puplic.guard.js +5 -0
- package/dist/http.logger.d.ts +6 -0
- package/dist/http.logger.js +9 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/interceptors/errors.interceptor.d.ts +33 -1
- package/dist/interceptors/errors.interceptor.js +41 -3
- package/dist/liveness.probe.d.ts +11 -0
- package/dist/liveness.probe.js +11 -0
- package/dist/models/content.d.ts +8 -0
- package/dist/models/content.js +21 -0
- package/dist/models/filter/index.d.ts +49 -0
- package/dist/models/filter/index.js +88 -0
- package/dist/models/filter/limit.property.d.ts +4 -0
- package/dist/models/filter/limit.property.js +11 -0
- package/dist/models/filter/skip.property.d.ts +4 -0
- package/dist/models/filter/skip.property.js +16 -0
- package/dist/models/filter/sort-direction.property.d.ts +4 -0
- package/dist/models/filter/sort-direction.property.js +16 -0
- package/dist/models/filter/sort-field.property.d.ts +4 -0
- package/dist/models/filter/sort-field.property.js +17 -0
- package/dist/models/index.d.ts +4 -0
- package/dist/models/index.js +20 -0
- package/dist/models/search-result.d.ts +14 -0
- package/dist/models/search-result.js +32 -0
- package/dist/models/thumbnail/alt.property.d.ts +8 -0
- package/dist/models/thumbnail/alt.property.js +18 -0
- package/dist/models/thumbnail/background.property.d.ts +8 -0
- package/dist/models/thumbnail/background.property.js +27 -0
- package/dist/models/thumbnail/contain.property.d.ts +8 -0
- package/dist/models/thumbnail/contain.property.js +18 -0
- package/dist/models/thumbnail/index.d.ts +30 -0
- package/dist/models/thumbnail/index.js +68 -0
- package/dist/models/thumbnail/max-height.property.d.ts +8 -0
- package/dist/models/thumbnail/max-height.property.js +20 -0
- package/dist/models/thumbnail/src.property.d.ts +8 -0
- package/dist/models/thumbnail/src.property.js +21 -0
- package/dist/modules/account/account.module.d.ts +12 -0
- package/dist/modules/account/account.module.js +34 -0
- package/dist/modules/account/account.service.d.ts +23 -0
- package/dist/modules/{services/account-service → account}/account.service.js +18 -3
- package/dist/modules/account/index.d.ts +2 -0
- package/dist/modules/account/index.js +7 -0
- package/dist/modules/authentication/authentication.module.d.ts +9 -4
- package/dist/modules/authentication/authentication.module.js +10 -2
- package/dist/modules/authentication/index.d.ts +1 -1
- package/dist/modules/authentication/internal/internal.constants.d.ts +4 -0
- package/dist/modules/authentication/internal/internal.constants.js +4 -0
- package/dist/modules/authentication/internal/internal.decorators.d.ts +4 -0
- package/dist/modules/authentication/internal/internal.decorators.js +4 -0
- package/dist/modules/authentication/internal/internal.guard.d.ts +5 -0
- package/dist/modules/authentication/internal/internal.guard.js +5 -0
- package/dist/modules/authentication/internal/internal.strategy.d.ts +17 -0
- package/dist/modules/authentication/internal/internal.strategy.js +17 -0
- package/dist/modules/authentication/jwt/jwt.constants.d.ts +20 -0
- package/dist/modules/authentication/jwt/jwt.constants.js +12 -0
- package/dist/modules/authentication/jwt/jwt.decorators.d.ts +15 -3
- package/dist/modules/authentication/jwt/jwt.decorators.js +16 -7
- package/dist/modules/authentication/jwt/jwt.guard.d.ts +15 -0
- package/dist/modules/authentication/jwt/jwt.guard.js +17 -0
- package/dist/modules/authentication/jwt/jwt.strategy.d.ts +16 -1
- package/dist/modules/authentication/jwt/jwt.strategy.js +16 -1
- package/dist/modules/comment/comment.controller.d.ts +24 -0
- package/dist/modules/comment/comment.controller.js +78 -0
- package/dist/modules/comment/comment.module-options.d.ts +18 -0
- package/dist/modules/{services/comment-service/comment-service.definitions.js → comment/comment.module-options.js} +10 -0
- package/dist/modules/comment/comment.module.d.ts +19 -0
- package/dist/modules/comment/comment.module.js +57 -0
- package/dist/modules/comment/comment.service.d.ts +42 -0
- package/dist/modules/comment/comment.service.js +113 -0
- package/dist/modules/comment/index.d.ts +3 -0
- package/dist/modules/comment/index.js +12 -0
- package/dist/modules/content/content.module.d.ts +18 -0
- package/dist/modules/content/content.module.js +46 -0
- package/dist/modules/content/content.service.d.ts +43 -0
- package/dist/modules/{services/content-service → content}/content.service.js +53 -17
- package/dist/modules/content/index.d.ts +2 -0
- package/dist/modules/content/index.js +7 -0
- package/dist/modules/database/database.module-options.d.ts +6 -0
- package/dist/modules/database/database.module.d.ts +19 -0
- package/dist/modules/database/database.module.js +41 -0
- package/dist/modules/database/index.js +12 -0
- package/dist/modules/database/model-service/model.service.d.ts +29 -0
- package/dist/modules/database/model-service/model.service.js +31 -0
- package/dist/modules/database/model-service/schemas/hub-account.schemas.d.ts +10 -0
- package/dist/modules/database/model-service/schemas/hub-account.schemas.js +7 -0
- package/dist/modules/database/model-service/schemas/hub-hackschool.schemas.js +3 -0
- package/dist/modules/database/model-service/schemas/hub-tech-radar.schemas.js +2 -0
- package/dist/modules/database/populate-service/populate.service.d.ts +35 -0
- package/dist/modules/database/populate-service/populate.service.js +35 -0
- package/dist/modules/database/service-mapper-service/service-mapper.service.d.ts +23 -0
- package/dist/modules/database/service-mapper-service/service-mapper.service.js +23 -0
- package/dist/modules/index.d.ts +6 -1
- package/dist/modules/index.js +6 -1
- package/dist/modules/like/index.d.ts +1 -0
- package/dist/modules/like/index.js +8 -0
- package/dist/modules/like/like.controller.d.ts +38 -0
- package/dist/modules/like/like.controller.js +119 -0
- package/dist/modules/like/like.module-options.d.ts +17 -0
- package/dist/modules/like/like.module-options.js +17 -0
- package/dist/modules/like/like.module.d.ts +18 -0
- package/dist/modules/like/like.module.js +45 -0
- package/dist/modules/like/like.service.d.ts +48 -0
- package/dist/modules/like/like.service.js +107 -0
- package/dist/modules/mail/index.d.ts +3 -0
- package/dist/modules/mail/index.js +10 -0
- package/dist/modules/mail/mail.models.d.ts +28 -0
- package/dist/modules/{services/mail-service/mail-service.definitions.js → mail/mail.models.js} +6 -0
- package/dist/modules/mail/mail.module.d.ts +12 -0
- package/dist/modules/mail/mail.module.js +34 -0
- package/dist/modules/mail/mail.service.d.ts +42 -0
- package/dist/modules/{services/mail-service → mail}/mail.service.js +34 -3
- package/dist/modules/search/index.d.ts +3 -0
- package/dist/modules/search/index.js +9 -0
- package/dist/modules/search/search.models.d.ts +19 -0
- package/dist/modules/{services/search-service/search-service.definitions.js → search/search.models.js} +9 -0
- package/dist/modules/search/search.module.d.ts +18 -0
- package/dist/modules/search/search.module.js +46 -0
- package/dist/modules/search/search.service.d.ts +35 -0
- package/dist/modules/{services/search-service → search}/search.service.js +44 -15
- package/dist/pipes/hid.pipe.d.ts +30 -0
- package/dist/pipes/hid.pipe.js +49 -5
- package/dist/pipes/id.pipe.d.ts +20 -0
- package/dist/pipes/id.pipe.js +40 -4
- package/dist/pipes/target.pipe.d.ts +23 -0
- package/dist/pipes/target.pipe.js +48 -6
- package/dist/schema.transformer.d.ts +2 -0
- package/dist/schema.transformer.js +10 -0
- package/dist/swagger.config.d.ts +36 -2
- package/dist/swagger.config.js +40 -3
- package/dist/transform/_trim.d.ts +7 -0
- package/dist/transform/_trim.js +16 -0
- package/dist/transform/index.d.ts +6 -0
- package/dist/transform/index.js +17 -0
- package/dist/transform/transformImage.d.ts +4 -0
- package/dist/transform/transformImage.js +16 -0
- package/dist/transform/transformString.d.ts +5 -0
- package/dist/transform/transformString.js +16 -0
- package/dist/transform/transformStringArray.d.ts +6 -0
- package/dist/transform/transformStringArray.js +24 -0
- package/dist/transform/transformStringLike.d.ts +20 -0
- package/dist/transform/transformStringLike.js +37 -0
- package/dist/transform/transformStringLowerCase.d.ts +5 -0
- package/dist/transform/transformStringLowerCase.js +16 -0
- package/dist/transform/transformStringSet.d.ts +6 -0
- package/dist/transform/transformStringSet.js +25 -0
- package/dist/virtuals.factory.d.ts +57 -0
- package/dist/virtuals.factory.js +117 -0
- package/package.json +3 -1
- package/dist/modules/services/account-service/account.service.d.ts +0 -8
- package/dist/modules/services/comment-service/comment-service.definitions.d.ts +0 -5
- package/dist/modules/services/comment-service/comment.service.d.ts +0 -12
- package/dist/modules/services/comment-service/comment.service.js +0 -75
- package/dist/modules/services/content-service/content.service.d.ts +0 -12
- package/dist/modules/services/index.d.ts +0 -9
- package/dist/modules/services/index.js +0 -22
- package/dist/modules/services/mail-service/mail-service.definitions.d.ts +0 -13
- package/dist/modules/services/mail-service/mail.service.d.ts +0 -11
- package/dist/modules/services/search-service/search-service.definitions.d.ts +0 -6
- package/dist/modules/services/search-service/search.service.d.ts +0 -11
- package/dist/modules/services/services.module-utils.d.ts +0 -7
- package/dist/modules/services/services.module.d.ts +0 -7
- package/dist/modules/services/services.module.js +0 -30
- package/dist/virtuals.d.ts +0 -8
- package/dist/virtuals.js +0 -77
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContentService = exports.ContentModule = void 0;
|
|
4
|
+
var content_module_1 = require("./content.module");
|
|
5
|
+
Object.defineProperty(exports, "ContentModule", { enumerable: true, get: function () { return content_module_1.ContentModule; } });
|
|
6
|
+
var content_service_1 = require("./content.service");
|
|
7
|
+
Object.defineProperty(exports, "ContentService", { enumerable: true, get: function () { return content_service_1.ContentService; } });
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { ModelDefinition } from '@nestjs/mongoose';
|
|
2
3
|
import { DatabaseModuleOptions } from './database.module-options';
|
|
4
|
+
/**
|
|
5
|
+
* Database module
|
|
6
|
+
* @class DatabaseModule
|
|
7
|
+
*/
|
|
3
8
|
export declare class DatabaseModule {
|
|
9
|
+
/** The Logger instance */
|
|
4
10
|
private static logger;
|
|
11
|
+
/**
|
|
12
|
+
* Register mongodb models to use in the module
|
|
13
|
+
*
|
|
14
|
+
* @param {ModelDefinition[]} models - array of model definitions
|
|
15
|
+
* @return {DynamicModule} Module with registered models
|
|
16
|
+
*/
|
|
17
|
+
static forFeature(...models: ModelDefinition[]): DynamicModule;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a DatabaseModule for the root, with the provided options
|
|
20
|
+
*
|
|
21
|
+
* @param {DatabaseModuleOptions} options - the options for the DatabaseModule
|
|
22
|
+
* @return {DynamicModule} the DatabaseModule
|
|
23
|
+
*/
|
|
5
24
|
static forRoot(options: DatabaseModuleOptions): DynamicModule;
|
|
6
25
|
}
|
|
@@ -57,7 +57,26 @@ const env_1 = require("../../env");
|
|
|
57
57
|
const model_service_1 = require("./model-service/model.service");
|
|
58
58
|
const populate_service_1 = require("./populate-service/populate.service");
|
|
59
59
|
const service_mapper_service_1 = require("./service-mapper-service/service-mapper.service");
|
|
60
|
+
/**
|
|
61
|
+
* Database module
|
|
62
|
+
* @class DatabaseModule
|
|
63
|
+
*/
|
|
60
64
|
let DatabaseModule = DatabaseModule_1 = class DatabaseModule {
|
|
65
|
+
/**
|
|
66
|
+
* Register mongodb models to use in the module
|
|
67
|
+
*
|
|
68
|
+
* @param {ModelDefinition[]} models - array of model definitions
|
|
69
|
+
* @return {DynamicModule} Module with registered models
|
|
70
|
+
*/
|
|
71
|
+
static forFeature(...models) {
|
|
72
|
+
return mongoose_1.MongooseModule.forFeature(models);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Creates a DatabaseModule for the root, with the provided options
|
|
76
|
+
*
|
|
77
|
+
* @param {DatabaseModuleOptions} options - the options for the DatabaseModule
|
|
78
|
+
* @return {DynamicModule} the DatabaseModule
|
|
79
|
+
*/
|
|
61
80
|
static forRoot(options) {
|
|
62
81
|
return {
|
|
63
82
|
global: true,
|
|
@@ -76,6 +95,7 @@ let DatabaseModule = DatabaseModule_1 = class DatabaseModule {
|
|
|
76
95
|
const tlsDir = (0, path_1.join)(process.cwd(), configService.get(env_1.ENV_MONGO_CERT_DIR, 'mongo-tls'));
|
|
77
96
|
const tlsCAFile = (0, path_1.join)(tlsDir, 'hub-services-mongodb.ca.pem');
|
|
78
97
|
const tlsCertificateKeyFile = (0, path_1.join)(tlsDir, 'hub-services-mongodb.cert-key.pem');
|
|
98
|
+
// Production
|
|
79
99
|
if (production) {
|
|
80
100
|
this.logger.log('Running in production mode... Creating certificates');
|
|
81
101
|
(0, fs_1.mkdirSync)(tlsDir, { recursive: true });
|
|
@@ -89,6 +109,7 @@ let DatabaseModule = DatabaseModule_1 = class DatabaseModule {
|
|
|
89
109
|
(0, fs_1.writeFileSync)(tlsCertificateKeyFile, `${tlsCrt}\n${tlsKey}`);
|
|
90
110
|
this.logger.log('Created Client Certificate and Key (.pem)');
|
|
91
111
|
}
|
|
112
|
+
// Development
|
|
92
113
|
else {
|
|
93
114
|
this.logger.log(`Running in development mode... Using local certificates in ${tlsDir}`);
|
|
94
115
|
if (!(0, fs_1.existsSync)(tlsCAFile))
|
|
@@ -117,30 +138,50 @@ let DatabaseModule = DatabaseModule_1 = class DatabaseModule {
|
|
|
117
138
|
};
|
|
118
139
|
}
|
|
119
140
|
};
|
|
141
|
+
/** The Logger instance */
|
|
120
142
|
DatabaseModule.logger = new common_1.Logger(DatabaseModule_1.name);
|
|
121
143
|
DatabaseModule = DatabaseModule_1 = __decorate([
|
|
122
144
|
(0, common_1.Module)({})
|
|
123
145
|
], DatabaseModule);
|
|
124
146
|
exports.DatabaseModule = DatabaseModule;
|
|
147
|
+
/**
|
|
148
|
+
* Controller for kubernetes liveness probe
|
|
149
|
+
* @class DatabaseLivenessProbe
|
|
150
|
+
*/
|
|
125
151
|
let DatabaseLivenessProbe = class DatabaseLivenessProbe {
|
|
152
|
+
/**
|
|
153
|
+
* Constructor
|
|
154
|
+
* @param connection - The connection to the database
|
|
155
|
+
*/
|
|
126
156
|
constructor(connection) {
|
|
127
157
|
this.connection = connection;
|
|
128
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Checks if the database is connected
|
|
161
|
+
*
|
|
162
|
+
* @param {Response} response - The response object
|
|
163
|
+
* @return {Promise<void>} Promise that resolves to void
|
|
164
|
+
*/
|
|
129
165
|
getAlive(response) {
|
|
130
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
// If the database is not connected, return an error
|
|
131
168
|
if (!this.connection || this.connection.readyState !== 1) {
|
|
132
169
|
response.status(500).send('Not connected to MongoDB');
|
|
133
170
|
return;
|
|
134
171
|
}
|
|
135
172
|
try {
|
|
173
|
+
// Ping the database
|
|
136
174
|
const result = yield this.connection.db.admin().ping();
|
|
175
|
+
// If the ping was successful, return 200
|
|
137
176
|
if (!!((result === null || result === void 0 ? void 0 : result.ok) === 1)) {
|
|
138
177
|
response.status(200).send({ ok: 1, db: 1 });
|
|
139
178
|
return;
|
|
140
179
|
}
|
|
180
|
+
// Otherwise, return an error
|
|
141
181
|
throw new Error('Could not connect to MongoDB');
|
|
142
182
|
}
|
|
143
183
|
catch (error) {
|
|
184
|
+
// If the ping failed, return an error
|
|
144
185
|
response.status(500).send("Couldn't connect to MongoDB");
|
|
145
186
|
}
|
|
146
187
|
});
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ServiceMapperService = exports.PopulateService = exports.ModelService = exports.DatabaseModule = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Database Module
|
|
6
|
+
*/
|
|
4
7
|
var database_module_1 = require("./database.module");
|
|
5
8
|
Object.defineProperty(exports, "DatabaseModule", { enumerable: true, get: function () { return database_module_1.DatabaseModule; } });
|
|
9
|
+
/*
|
|
10
|
+
* Model Service
|
|
11
|
+
*/
|
|
6
12
|
var model_service_1 = require("./model-service/model.service");
|
|
7
13
|
Object.defineProperty(exports, "ModelService", { enumerable: true, get: function () { return model_service_1.ModelService; } });
|
|
14
|
+
/*
|
|
15
|
+
* Populate Service
|
|
16
|
+
*/
|
|
8
17
|
var populate_service_1 = require("./populate-service/populate.service");
|
|
9
18
|
Object.defineProperty(exports, "PopulateService", { enumerable: true, get: function () { return populate_service_1.PopulateService; } });
|
|
19
|
+
/*
|
|
20
|
+
* ServiceMapper Service
|
|
21
|
+
*/
|
|
10
22
|
var service_mapper_service_1 = require("./service-mapper-service/service-mapper.service");
|
|
11
23
|
Object.defineProperty(exports, "ServiceMapperService", { enumerable: true, get: function () { return service_mapper_service_1.ServiceMapperService; } });
|
|
@@ -34,10 +34,26 @@ import { NewsModel } from './schemas/hub-newsroom.schemas';
|
|
|
34
34
|
import { PodcastModel } from './schemas/hub-podcasts.schemas';
|
|
35
35
|
import { MemberModel } from './schemas/hub-team.schemas';
|
|
36
36
|
import { BlipModel, RadarModel } from './schemas/hub-tech-radar.schemas';
|
|
37
|
+
/**
|
|
38
|
+
* Model service
|
|
39
|
+
* @class ModelService
|
|
40
|
+
*/
|
|
37
41
|
export declare class ModelService {
|
|
38
42
|
private readonly connection;
|
|
43
|
+
/**
|
|
44
|
+
* Constructor
|
|
45
|
+
* @param connection - the connection
|
|
46
|
+
*/
|
|
39
47
|
constructor(connection: Connection);
|
|
48
|
+
/**
|
|
49
|
+
* Returns a model for the given database, name and schema
|
|
50
|
+
* @param database - the database of the model
|
|
51
|
+
* @param name - the name of the model
|
|
52
|
+
* @param schema - the schema of the model
|
|
53
|
+
* @returns {Model<T>} the model
|
|
54
|
+
*/
|
|
40
55
|
private useModel;
|
|
56
|
+
/** Returns the account model */
|
|
41
57
|
accountModel: () => import("mongoose").Model<AccountModel, {}, {}, {}, import("mongoose").Document<unknown, {}, AccountModel> & AccountModel & {
|
|
42
58
|
_id: import("mongoose").Types.ObjectId;
|
|
43
59
|
}, Schema<AccountModel, import("mongoose").Model<AccountModel, any, any, any, import("mongoose").Document<unknown, any, AccountModel> & AccountModel & {
|
|
@@ -45,6 +61,7 @@ export declare class ModelService {
|
|
|
45
61
|
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, AccountModel, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<AccountModel>> & import("mongoose").FlatRecord<AccountModel> & {
|
|
46
62
|
_id: import("mongoose").Types.ObjectId;
|
|
47
63
|
}>>;
|
|
64
|
+
/** Returns the comment model */
|
|
48
65
|
commentModel: () => import("mongoose").Model<CommentModel, {}, {}, {}, import("mongoose").Document<unknown, {}, CommentModel> & CommentModel & {
|
|
49
66
|
_id: import("mongoose").Types.ObjectId;
|
|
50
67
|
}, Schema<CommentModel, import("mongoose").Model<CommentModel, any, any, any, import("mongoose").Document<unknown, any, CommentModel> & CommentModel & {
|
|
@@ -52,6 +69,7 @@ export declare class ModelService {
|
|
|
52
69
|
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, CommentModel, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<CommentModel>> & import("mongoose").FlatRecord<CommentModel> & {
|
|
53
70
|
_id: import("mongoose").Types.ObjectId;
|
|
54
71
|
}>>;
|
|
72
|
+
/** Returns the content model */
|
|
55
73
|
contentModel: () => import("mongoose").Model<ContentModel, {}, {}, {}, import("mongoose").Document<unknown, {}, ContentModel> & ContentModel & {
|
|
56
74
|
_id: import("mongoose").Types.ObjectId;
|
|
57
75
|
}, Schema<ContentModel, import("mongoose").Model<ContentModel, any, any, any, import("mongoose").Document<unknown, any, ContentModel> & ContentModel & {
|
|
@@ -59,6 +77,7 @@ export declare class ModelService {
|
|
|
59
77
|
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, ContentModel, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<ContentModel>> & import("mongoose").FlatRecord<ContentModel> & {
|
|
60
78
|
_id: import("mongoose").Types.ObjectId;
|
|
61
79
|
}>>;
|
|
80
|
+
/** Returns the book model */
|
|
62
81
|
bookModel: () => import("mongoose").Model<BookModel, {}, {}, {}, import("mongoose").Document<unknown, {}, BookModel> & BookModel & {
|
|
63
82
|
_id: import("mongoose").Types.ObjectId;
|
|
64
83
|
}, Schema<BookModel, import("mongoose").Model<BookModel, any, any, any, import("mongoose").Document<unknown, any, BookModel> & BookModel & {
|
|
@@ -66,6 +85,7 @@ export declare class ModelService {
|
|
|
66
85
|
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, BookModel, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<BookModel>> & import("mongoose").FlatRecord<BookModel> & {
|
|
67
86
|
_id: import("mongoose").Types.ObjectId;
|
|
68
87
|
}>>;
|
|
88
|
+
/** Returns the demo model */
|
|
69
89
|
demoModel: () => import("mongoose").Model<DemoModel, {}, {}, {}, import("mongoose").Document<unknown, {}, DemoModel> & DemoModel & {
|
|
70
90
|
_id: import("mongoose").Types.ObjectId;
|
|
71
91
|
}, Schema<DemoModel, import("mongoose").Model<DemoModel, any, any, any, import("mongoose").Document<unknown, any, DemoModel> & DemoModel & {
|
|
@@ -73,6 +93,7 @@ export declare class ModelService {
|
|
|
73
93
|
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, DemoModel, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<DemoModel>> & import("mongoose").FlatRecord<DemoModel> & {
|
|
74
94
|
_id: import("mongoose").Types.ObjectId;
|
|
75
95
|
}>>;
|
|
96
|
+
/** Returns the event model */
|
|
76
97
|
eventModel: () => import("mongoose").Model<EventModel, {}, {}, {}, import("mongoose").Document<unknown, {}, EventModel> & EventModel & {
|
|
77
98
|
_id: import("mongoose").Types.ObjectId;
|
|
78
99
|
}, Schema<EventModel, import("mongoose").Model<EventModel, any, any, any, import("mongoose").Document<unknown, any, EventModel> & EventModel & {
|
|
@@ -80,6 +101,7 @@ export declare class ModelService {
|
|
|
80
101
|
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, EventModel, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<EventModel>> & import("mongoose").FlatRecord<EventModel> & {
|
|
81
102
|
_id: import("mongoose").Types.ObjectId;
|
|
82
103
|
}>>;
|
|
104
|
+
/** Returns the hackschool course model */
|
|
83
105
|
courseModel: () => import("mongoose").Model<CourseModel, {}, {}, {}, import("mongoose").Document<unknown, {}, CourseModel> & CourseModel & {
|
|
84
106
|
_id: import("mongoose").Types.ObjectId;
|
|
85
107
|
}, Schema<CourseModel, import("mongoose").Model<CourseModel, any, any, any, import("mongoose").Document<unknown, any, CourseModel> & CourseModel & {
|
|
@@ -87,6 +109,7 @@ export declare class ModelService {
|
|
|
87
109
|
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, CourseModel, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<CourseModel>> & import("mongoose").FlatRecord<CourseModel> & {
|
|
88
110
|
_id: import("mongoose").Types.ObjectId;
|
|
89
111
|
}>>;
|
|
112
|
+
/** Returns the hackschool documentation model */
|
|
90
113
|
docModel: () => import("mongoose").Model<DocModel, {}, {}, {}, import("mongoose").Document<unknown, {}, DocModel> & DocModel & {
|
|
91
114
|
_id: import("mongoose").Types.ObjectId;
|
|
92
115
|
}, Schema<DocModel, import("mongoose").Model<DocModel, any, any, any, import("mongoose").Document<unknown, any, DocModel> & DocModel & {
|
|
@@ -94,6 +117,7 @@ export declare class ModelService {
|
|
|
94
117
|
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, DocModel, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<DocModel>> & import("mongoose").FlatRecord<DocModel> & {
|
|
95
118
|
_id: import("mongoose").Types.ObjectId;
|
|
96
119
|
}>>;
|
|
120
|
+
/** Returns the hackschool thread model */
|
|
97
121
|
threadModel: () => import("mongoose").Model<ThreadModel, {}, {}, {}, import("mongoose").Document<unknown, {}, ThreadModel> & ThreadModel & {
|
|
98
122
|
_id: import("mongoose").Types.ObjectId;
|
|
99
123
|
}, Schema<ThreadModel, import("mongoose").Model<ThreadModel, any, any, any, import("mongoose").Document<unknown, any, ThreadModel> & ThreadModel & {
|
|
@@ -101,6 +125,7 @@ export declare class ModelService {
|
|
|
101
125
|
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, ThreadModel, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<ThreadModel>> & import("mongoose").FlatRecord<ThreadModel> & {
|
|
102
126
|
_id: import("mongoose").Types.ObjectId;
|
|
103
127
|
}>>;
|
|
128
|
+
/** Returns the news model */
|
|
104
129
|
newsModel: () => import("mongoose").Model<NewsModel, {}, {}, {}, import("mongoose").Document<unknown, {}, NewsModel> & NewsModel & {
|
|
105
130
|
_id: import("mongoose").Types.ObjectId;
|
|
106
131
|
}, Schema<NewsModel, import("mongoose").Model<NewsModel, any, any, any, import("mongoose").Document<unknown, any, NewsModel> & NewsModel & {
|
|
@@ -108,6 +133,7 @@ export declare class ModelService {
|
|
|
108
133
|
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, NewsModel, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<NewsModel>> & import("mongoose").FlatRecord<NewsModel> & {
|
|
109
134
|
_id: import("mongoose").Types.ObjectId;
|
|
110
135
|
}>>;
|
|
136
|
+
/** Returns the podcast model */
|
|
111
137
|
podcastModel: () => import("mongoose").Model<PodcastModel, {}, {}, {}, import("mongoose").Document<unknown, {}, PodcastModel> & PodcastModel & {
|
|
112
138
|
_id: import("mongoose").Types.ObjectId;
|
|
113
139
|
}, Schema<PodcastModel, import("mongoose").Model<PodcastModel, any, any, any, import("mongoose").Document<unknown, any, PodcastModel> & PodcastModel & {
|
|
@@ -115,6 +141,7 @@ export declare class ModelService {
|
|
|
115
141
|
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, PodcastModel, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<PodcastModel>> & import("mongoose").FlatRecord<PodcastModel> & {
|
|
116
142
|
_id: import("mongoose").Types.ObjectId;
|
|
117
143
|
}>>;
|
|
144
|
+
/** Returns the member model */
|
|
118
145
|
memberModel: () => import("mongoose").Model<MemberModel, {}, {}, {}, import("mongoose").Document<unknown, {}, MemberModel> & MemberModel & {
|
|
119
146
|
_id: import("mongoose").Types.ObjectId;
|
|
120
147
|
}, Schema<MemberModel, import("mongoose").Model<MemberModel, any, any, any, import("mongoose").Document<unknown, any, MemberModel> & MemberModel & {
|
|
@@ -122,6 +149,7 @@ export declare class ModelService {
|
|
|
122
149
|
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, MemberModel, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<MemberModel>> & import("mongoose").FlatRecord<MemberModel> & {
|
|
123
150
|
_id: import("mongoose").Types.ObjectId;
|
|
124
151
|
}>>;
|
|
152
|
+
/** Returns the tech radar blip model */
|
|
125
153
|
blipModel: () => import("mongoose").Model<BlipModel, {}, {}, {}, import("mongoose").Document<unknown, {}, BlipModel> & BlipModel & {
|
|
126
154
|
_id: import("mongoose").Types.ObjectId;
|
|
127
155
|
}, Schema<BlipModel, import("mongoose").Model<BlipModel, any, any, any, import("mongoose").Document<unknown, any, BlipModel> & BlipModel & {
|
|
@@ -129,6 +157,7 @@ export declare class ModelService {
|
|
|
129
157
|
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, BlipModel, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<BlipModel>> & import("mongoose").FlatRecord<BlipModel> & {
|
|
130
158
|
_id: import("mongoose").Types.ObjectId;
|
|
131
159
|
}>>;
|
|
160
|
+
/** Returns the tech radar radar model */
|
|
132
161
|
radarModel: () => import("mongoose").Model<RadarModel, {}, {}, {}, import("mongoose").Document<unknown, {}, RadarModel> & RadarModel & {
|
|
133
162
|
_id: import("mongoose").Types.ObjectId;
|
|
134
163
|
}, Schema<RadarModel, import("mongoose").Model<RadarModel, any, any, any, import("mongoose").Document<unknown, any, RadarModel> & RadarModel & {
|
|
@@ -27,24 +27,55 @@ const hub_newsroom_schemas_1 = require("./schemas/hub-newsroom.schemas");
|
|
|
27
27
|
const hub_podcasts_schemas_1 = require("./schemas/hub-podcasts.schemas");
|
|
28
28
|
const hub_team_schemas_1 = require("./schemas/hub-team.schemas");
|
|
29
29
|
const hub_tech_radar_schemas_1 = require("./schemas/hub-tech-radar.schemas");
|
|
30
|
+
/**
|
|
31
|
+
* Model service
|
|
32
|
+
* @class ModelService
|
|
33
|
+
*/
|
|
30
34
|
let ModelService = class ModelService {
|
|
35
|
+
/**
|
|
36
|
+
* Constructor
|
|
37
|
+
* @param connection - the connection
|
|
38
|
+
*/
|
|
31
39
|
constructor(connection) {
|
|
32
40
|
this.connection = connection;
|
|
41
|
+
// General
|
|
42
|
+
/** Returns the account model */
|
|
33
43
|
this.accountModel = () => this.useModel(hub_account_schemas_1.AccountDB, hub_account_schemas_1.AccountModel.name, hub_account_schemas_1.AccountSchema);
|
|
44
|
+
/** Returns the comment model */
|
|
34
45
|
this.commentModel = () => this.useModel(hub_comments_schemas_1.CommentDB, hub_comments_schemas_1.CommentModel.name, hub_comments_schemas_1.CommentSchema);
|
|
46
|
+
/** Returns the content model */
|
|
35
47
|
this.contentModel = () => this.useModel(hub_content_schemas_1.ContentDB, hub_content_schemas_1.ContentModel.name, hub_content_schemas_1.ContentSchema);
|
|
48
|
+
// Services
|
|
49
|
+
/** Returns the book model */
|
|
36
50
|
this.bookModel = () => this.useModel(hub_books_schemas_1.BooksDB, hub_books_schemas_1.BookModel.name, hub_books_schemas_1.BookSchema);
|
|
51
|
+
/** Returns the demo model */
|
|
37
52
|
this.demoModel = () => this.useModel(hub_demo_hive_schemas_1.DemoHiveDB, hub_demo_hive_schemas_1.DemoModel.name, hub_demo_hive_schemas_1.DemoSchema);
|
|
53
|
+
/** Returns the event model */
|
|
38
54
|
this.eventModel = () => this.useModel(hub_events_schemas_1.EventsDB, hub_events_schemas_1.EventModel.name, hub_events_schemas_1.EventSchema);
|
|
55
|
+
/** Returns the hackschool course model */
|
|
39
56
|
this.courseModel = () => this.useModel(hub_hackschool_schemas_1.HackschoolDB, hub_hackschool_schemas_1.CourseModel.name, hub_hackschool_schemas_1.CourseSchema);
|
|
57
|
+
/** Returns the hackschool documentation model */
|
|
40
58
|
this.docModel = () => this.useModel(hub_hackschool_schemas_1.HackschoolDB, hub_hackschool_schemas_1.DocModel.name, hub_hackschool_schemas_1.DocSchema);
|
|
59
|
+
/** Returns the hackschool thread model */
|
|
41
60
|
this.threadModel = () => this.useModel(hub_hackschool_schemas_1.HackschoolDB, hub_hackschool_schemas_1.ThreadModel.name, hub_hackschool_schemas_1.ThreadSchema);
|
|
61
|
+
/** Returns the news model */
|
|
42
62
|
this.newsModel = () => this.useModel(hub_newsroom_schemas_1.NewsroomDB, hub_newsroom_schemas_1.NewsModel.name, hub_newsroom_schemas_1.NewsSchema);
|
|
63
|
+
/** Returns the podcast model */
|
|
43
64
|
this.podcastModel = () => this.useModel(hub_podcasts_schemas_1.PodcastsDB, hub_podcasts_schemas_1.PodcastModel.name, hub_podcasts_schemas_1.PodcastSchema);
|
|
65
|
+
/** Returns the member model */
|
|
44
66
|
this.memberModel = () => this.useModel(hub_team_schemas_1.TeamDB, hub_team_schemas_1.MemberModel.name, hub_team_schemas_1.MemberSchema);
|
|
67
|
+
/** Returns the tech radar blip model */
|
|
45
68
|
this.blipModel = () => this.useModel(hub_tech_radar_schemas_1.TechRadarDB, hub_tech_radar_schemas_1.BlipModel.name, hub_tech_radar_schemas_1.BlipSchema);
|
|
69
|
+
/** Returns the tech radar radar model */
|
|
46
70
|
this.radarModel = () => this.useModel(hub_tech_radar_schemas_1.TechRadarDB, hub_tech_radar_schemas_1.RadarModel.name, hub_tech_radar_schemas_1.RadarSchema);
|
|
47
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns a model for the given database, name and schema
|
|
74
|
+
* @param database - the database of the model
|
|
75
|
+
* @param name - the name of the model
|
|
76
|
+
* @param schema - the schema of the model
|
|
77
|
+
* @returns {Model<T>} the model
|
|
78
|
+
*/
|
|
48
79
|
useModel(database, name, schema) {
|
|
49
80
|
return this.connection.useDb(database).model(name, schema);
|
|
50
81
|
}
|
|
@@ -23,9 +23,19 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import { Document } from 'mongoose';
|
|
26
|
+
/**
|
|
27
|
+
* Account avatar model
|
|
28
|
+
* @class AvatarModel
|
|
29
|
+
* @property {string} extension - The extension of the avatar
|
|
30
|
+
* @property {string} mimetype - The mimetype of the avatar
|
|
31
|
+
* @property {number} size - The size of the avatar
|
|
32
|
+
*/
|
|
26
33
|
declare class AvatarModel {
|
|
34
|
+
/** The extension of the avatar */
|
|
27
35
|
extension: string;
|
|
36
|
+
/** The mimetype of the avatar */
|
|
28
37
|
mimetype: string;
|
|
38
|
+
/** The size of the avatar */
|
|
29
39
|
size: number;
|
|
30
40
|
}
|
|
31
41
|
declare class AccountModel extends Document {
|
|
@@ -12,6 +12,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.AccountDB = exports.AccountSchema = exports.AccountModel = void 0;
|
|
13
13
|
const mongoose_1 = require("@nestjs/mongoose");
|
|
14
14
|
const mongoose_2 = require("mongoose");
|
|
15
|
+
/**
|
|
16
|
+
* Account avatar model
|
|
17
|
+
* @class AvatarModel
|
|
18
|
+
* @property {string} extension - The extension of the avatar
|
|
19
|
+
* @property {string} mimetype - The mimetype of the avatar
|
|
20
|
+
* @property {number} size - The size of the avatar
|
|
21
|
+
*/
|
|
15
22
|
class AvatarModel {
|
|
16
23
|
}
|
|
17
24
|
const transform = {
|
|
@@ -35,6 +35,7 @@ CourseModel = __decorate([
|
|
|
35
35
|
exports.CourseModel = CourseModel;
|
|
36
36
|
const CourseSchema = mongoose_1.SchemaFactory.createForClass(CourseModel);
|
|
37
37
|
exports.CourseSchema = CourseSchema;
|
|
38
|
+
// ================================================================================
|
|
38
39
|
const transformDoc = {
|
|
39
40
|
virtuals: true,
|
|
40
41
|
transform: (_, { title, _hid }) => {
|
|
@@ -58,6 +59,7 @@ DocModel = __decorate([
|
|
|
58
59
|
exports.DocModel = DocModel;
|
|
59
60
|
const DocSchema = mongoose_1.SchemaFactory.createForClass(DocModel);
|
|
60
61
|
exports.DocSchema = DocSchema;
|
|
62
|
+
// ================================================================================
|
|
61
63
|
const transformThread = {
|
|
62
64
|
virtuals: true,
|
|
63
65
|
transform: (_, { title, _hid }) => {
|
|
@@ -81,5 +83,6 @@ ThreadModel = __decorate([
|
|
|
81
83
|
exports.ThreadModel = ThreadModel;
|
|
82
84
|
const ThreadSchema = mongoose_1.SchemaFactory.createForClass(ThreadModel);
|
|
83
85
|
exports.ThreadSchema = ThreadSchema;
|
|
86
|
+
// ================================================================================
|
|
84
87
|
const HackschoolDB = 'hub-hackschool';
|
|
85
88
|
exports.HackschoolDB = HackschoolDB;
|
|
@@ -35,6 +35,7 @@ BlipModel = __decorate([
|
|
|
35
35
|
exports.BlipModel = BlipModel;
|
|
36
36
|
const BlipSchema = mongoose_1.SchemaFactory.createForClass(BlipModel);
|
|
37
37
|
exports.BlipSchema = BlipSchema;
|
|
38
|
+
// ================================================================================
|
|
38
39
|
const toTitle = Intl.DateTimeFormat('de-DE', { month: 'long', year: 'numeric' }).format;
|
|
39
40
|
const transformRadar = {
|
|
40
41
|
virtuals: true,
|
|
@@ -65,5 +66,6 @@ RadarModel = __decorate([
|
|
|
65
66
|
exports.RadarModel = RadarModel;
|
|
66
67
|
const RadarSchema = mongoose_1.SchemaFactory.createForClass(RadarModel);
|
|
67
68
|
exports.RadarSchema = RadarSchema;
|
|
69
|
+
// ================================================================================
|
|
68
70
|
const TechRadarDB = 'hub-tech-radar';
|
|
69
71
|
exports.TechRadarDB = TechRadarDB;
|
|
@@ -1,12 +1,47 @@
|
|
|
1
1
|
import { PopulateOptions } from 'mongoose';
|
|
2
2
|
import { ModelService } from '../model-service/model.service';
|
|
3
|
+
/**
|
|
4
|
+
* Populate service
|
|
5
|
+
* @class PopulateService
|
|
6
|
+
*/
|
|
3
7
|
export declare class PopulateService {
|
|
4
8
|
private readonly modelService;
|
|
9
|
+
/**
|
|
10
|
+
* Constructor
|
|
11
|
+
* @param modelService - the model service
|
|
12
|
+
*/
|
|
5
13
|
constructor(modelService: ModelService);
|
|
14
|
+
/**
|
|
15
|
+
* Populates an account
|
|
16
|
+
* @param {string} path - the path to populate
|
|
17
|
+
* @returns {PopulateOptions} the populate options
|
|
18
|
+
*/
|
|
6
19
|
account: (path: string) => PopulateOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Populates an array of accounts
|
|
22
|
+
* @param path - the path to populate
|
|
23
|
+
* @returns {PopulateOptions} the populate options
|
|
24
|
+
*/
|
|
7
25
|
accounts: (path: string) => PopulateOptions;
|
|
26
|
+
/**
|
|
27
|
+
* Populates the comments field of a document with its comments but without replies
|
|
28
|
+
* @returns {PopulateOptions} the populate options
|
|
29
|
+
*/
|
|
8
30
|
comments: () => PopulateOptions;
|
|
31
|
+
/**
|
|
32
|
+
* Populates the commentsCount field of a document with the number of comments
|
|
33
|
+
* @returns {PopulateOptions} the populate options
|
|
34
|
+
*/
|
|
9
35
|
commentsCount: () => PopulateOptions;
|
|
36
|
+
/**
|
|
37
|
+
* Populates the comments field of a document with its comments and replies
|
|
38
|
+
* @returns {PopulateOptions} the populate options
|
|
39
|
+
*/
|
|
10
40
|
commentsAndReplies: () => PopulateOptions;
|
|
41
|
+
/**
|
|
42
|
+
* Populates the content field of a document
|
|
43
|
+
* @param {string} contentAs - the format of the content
|
|
44
|
+
* @returns {PopulateOptions} the populate options
|
|
45
|
+
*/
|
|
11
46
|
content: (contentAs?: 'json' | 'text' | 'html') => PopulateOptions;
|
|
12
47
|
}
|
|
@@ -12,29 +12,59 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.PopulateService = void 0;
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
14
|
const model_service_1 = require("../model-service/model.service");
|
|
15
|
+
/**
|
|
16
|
+
* Populate service
|
|
17
|
+
* @class PopulateService
|
|
18
|
+
*/
|
|
15
19
|
let PopulateService = class PopulateService {
|
|
20
|
+
/**
|
|
21
|
+
* Constructor
|
|
22
|
+
* @param modelService - the model service
|
|
23
|
+
*/
|
|
16
24
|
constructor(modelService) {
|
|
17
25
|
this.modelService = modelService;
|
|
26
|
+
/**
|
|
27
|
+
* Populates an account
|
|
28
|
+
* @param {string} path - the path to populate
|
|
29
|
+
* @returns {PopulateOptions} the populate options
|
|
30
|
+
*/
|
|
18
31
|
this.account = (path) => ({
|
|
19
32
|
path,
|
|
20
33
|
justOne: true,
|
|
21
34
|
model: this.modelService.accountModel(),
|
|
22
35
|
});
|
|
36
|
+
/**
|
|
37
|
+
* Populates an array of accounts
|
|
38
|
+
* @param path - the path to populate
|
|
39
|
+
* @returns {PopulateOptions} the populate options
|
|
40
|
+
*/
|
|
23
41
|
this.accounts = (path) => ({
|
|
24
42
|
path,
|
|
25
43
|
justOne: false,
|
|
26
44
|
model: this.modelService.accountModel(),
|
|
27
45
|
});
|
|
46
|
+
/**
|
|
47
|
+
* Populates the comments field of a document with its comments but without replies
|
|
48
|
+
* @returns {PopulateOptions} the populate options
|
|
49
|
+
*/
|
|
28
50
|
this.comments = () => ({
|
|
29
51
|
path: 'comments',
|
|
30
52
|
justOne: false,
|
|
31
53
|
model: this.modelService.commentModel(),
|
|
32
54
|
options: { populate: [this.account('author')] },
|
|
33
55
|
});
|
|
56
|
+
/**
|
|
57
|
+
* Populates the commentsCount field of a document with the number of comments
|
|
58
|
+
* @returns {PopulateOptions} the populate options
|
|
59
|
+
*/
|
|
34
60
|
this.commentsCount = () => ({
|
|
35
61
|
path: 'commentsCount',
|
|
36
62
|
model: this.modelService.commentModel(),
|
|
37
63
|
});
|
|
64
|
+
/**
|
|
65
|
+
* Populates the comments field of a document with its comments and replies
|
|
66
|
+
* @returns {PopulateOptions} the populate options
|
|
67
|
+
*/
|
|
38
68
|
this.commentsAndReplies = () => ({
|
|
39
69
|
path: 'comments',
|
|
40
70
|
justOne: false,
|
|
@@ -46,6 +76,11 @@ let PopulateService = class PopulateService {
|
|
|
46
76
|
],
|
|
47
77
|
},
|
|
48
78
|
});
|
|
79
|
+
/**
|
|
80
|
+
* Populates the content field of a document
|
|
81
|
+
* @param {string} contentAs - the format of the content
|
|
82
|
+
* @returns {PopulateOptions} the populate options
|
|
83
|
+
*/
|
|
49
84
|
this.content = (contentAs = 'html') => ({
|
|
50
85
|
path: 'content',
|
|
51
86
|
justOne: true,
|
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
import { PopulateOptions } from 'mongoose';
|
|
2
2
|
import { ModelService } from '../model-service/model.service';
|
|
3
|
+
/**
|
|
4
|
+
* Service mapper service
|
|
5
|
+
* @class ServiceMapperService
|
|
6
|
+
*/
|
|
3
7
|
export declare class ServiceMapperService {
|
|
4
8
|
private readonly modelService;
|
|
9
|
+
/**
|
|
10
|
+
* Constructor
|
|
11
|
+
* @param modelService - the model service
|
|
12
|
+
*/
|
|
5
13
|
constructor(modelService: ModelService);
|
|
14
|
+
/** Map of Targets and their corresponding Model */
|
|
6
15
|
private targets;
|
|
16
|
+
/**
|
|
17
|
+
* Transforms a target into a PopulateOptions
|
|
18
|
+
* @param {string} target - the target
|
|
19
|
+
* @param {Model<any>} model - the model
|
|
20
|
+
*/
|
|
7
21
|
private transformTarget;
|
|
22
|
+
/**
|
|
23
|
+
* Maps all targets to their corresponding PopulateOptions
|
|
24
|
+
* @returns {PopulateOptions[]} the populate options for all targets
|
|
25
|
+
*/
|
|
8
26
|
all: () => PopulateOptions[];
|
|
27
|
+
/**
|
|
28
|
+
* Maps filtered targets to their corresponding PopulateOptions
|
|
29
|
+
* @param {string[]} targets - the targets
|
|
30
|
+
* @returns {PopulateOptions[]} the populate options for filtered targets
|
|
31
|
+
*/
|
|
9
32
|
filtered: (targets?: string[]) => PopulateOptions[];
|
|
10
33
|
}
|
|
@@ -12,9 +12,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.ServiceMapperService = void 0;
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
14
|
const model_service_1 = require("../model-service/model.service");
|
|
15
|
+
/**
|
|
16
|
+
* Service mapper service
|
|
17
|
+
* @class ServiceMapperService
|
|
18
|
+
*/
|
|
15
19
|
let ServiceMapperService = class ServiceMapperService {
|
|
20
|
+
/**
|
|
21
|
+
* Constructor
|
|
22
|
+
* @param modelService - the model service
|
|
23
|
+
*/
|
|
16
24
|
constructor(modelService) {
|
|
17
25
|
this.modelService = modelService;
|
|
26
|
+
/** Map of Targets and their corresponding Model */
|
|
18
27
|
this.targets = {
|
|
19
28
|
book: this.modelService.bookModel(),
|
|
20
29
|
demo: this.modelService.demoModel(),
|
|
@@ -28,11 +37,25 @@ let ServiceMapperService = class ServiceMapperService {
|
|
|
28
37
|
'tech-radar-blip': this.modelService.blipModel(),
|
|
29
38
|
'tech-radar-radar': this.modelService.radarModel(),
|
|
30
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Transforms a target into a PopulateOptions
|
|
42
|
+
* @param {string} target - the target
|
|
43
|
+
* @param {Model<any>} model - the model
|
|
44
|
+
*/
|
|
31
45
|
this.transformTarget = (target, model) => ({
|
|
32
46
|
path: `ref-${target}`,
|
|
33
47
|
model,
|
|
34
48
|
});
|
|
49
|
+
/**
|
|
50
|
+
* Maps all targets to their corresponding PopulateOptions
|
|
51
|
+
* @returns {PopulateOptions[]} the populate options for all targets
|
|
52
|
+
*/
|
|
35
53
|
this.all = () => Object.entries(this.targets).map(([target, model]) => this.transformTarget(target, model));
|
|
54
|
+
/**
|
|
55
|
+
* Maps filtered targets to their corresponding PopulateOptions
|
|
56
|
+
* @param {string[]} targets - the targets
|
|
57
|
+
* @returns {PopulateOptions[]} the populate options for filtered targets
|
|
58
|
+
*/
|
|
36
59
|
this.filtered = (targets) => {
|
|
37
60
|
if (!targets || !targets.length)
|
|
38
61
|
return this.all();
|
package/dist/modules/index.d.ts
CHANGED
package/dist/modules/index.js
CHANGED
|
@@ -14,6 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./account"), exports);
|
|
17
18
|
__exportStar(require("./authentication"), exports);
|
|
19
|
+
__exportStar(require("./comment"), exports);
|
|
20
|
+
__exportStar(require("./content"), exports);
|
|
18
21
|
__exportStar(require("./database"), exports);
|
|
19
|
-
__exportStar(require("./
|
|
22
|
+
__exportStar(require("./like"), exports);
|
|
23
|
+
__exportStar(require("./mail"), exports);
|
|
24
|
+
__exportStar(require("./search"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LikeModule } from './like.module';
|