@intlayer/backend 7.2.1-canary.1 → 7.2.3
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/esm/utils/AI/aiSdk.mjs +7 -1
- package/dist/esm/utils/AI/aiSdk.mjs.map +1 -1
- package/dist/types/controllers/dictionary.controller.d.ts.map +1 -1
- package/dist/types/controllers/tag.controller.d.ts.map +1 -1
- package/dist/types/emails/InviteUserEmail.d.ts +4 -4
- package/dist/types/emails/InviteUserEmail.d.ts.map +1 -1
- package/dist/types/emails/MagicLinkEmail.d.ts +4 -4
- package/dist/types/emails/MagicLinkEmail.d.ts.map +1 -1
- package/dist/types/emails/OAuthTokenCreatedEmail.d.ts +4 -4
- package/dist/types/emails/PasswordChangeConfirmation.d.ts +4 -4
- package/dist/types/emails/PasswordChangeConfirmation.d.ts.map +1 -1
- package/dist/types/emails/ResetUserPassword.d.ts +4 -4
- package/dist/types/emails/ResetUserPassword.d.ts.map +1 -1
- package/dist/types/emails/SubscriptionPaymentCancellation.d.ts +4 -4
- package/dist/types/emails/SubscriptionPaymentCancellation.d.ts.map +1 -1
- package/dist/types/emails/SubscriptionPaymentError.d.ts +4 -4
- package/dist/types/emails/SubscriptionPaymentSuccess.d.ts +4 -4
- package/dist/types/emails/ValidateUserEmail.d.ts +4 -4
- package/dist/types/emails/Welcome.d.ts +4 -4
- package/dist/types/emails/Welcome.d.ts.map +1 -1
- package/dist/types/models/dictionary.model.d.ts +4 -4
- package/dist/types/models/discussion.model.d.ts +2 -2
- package/dist/types/models/discussion.model.d.ts.map +1 -1
- package/dist/types/models/oAuth2.model.d.ts +3 -3
- package/dist/types/routes/eventListener.routes.d.ts.map +1 -1
- package/dist/types/schemas/dictionary.schema.d.ts +6 -6
- package/dist/types/schemas/dictionary.schema.d.ts.map +1 -1
- package/dist/types/schemas/discussion.schema.d.ts +6 -6
- package/dist/types/schemas/oAuth2.schema.d.ts +5 -5
- package/dist/types/schemas/oAuth2.schema.d.ts.map +1 -1
- package/dist/types/schemas/organization.schema.d.ts +6 -6
- package/dist/types/schemas/plans.schema.d.ts +6 -6
- package/dist/types/schemas/project.schema.d.ts +6 -6
- package/dist/types/schemas/project.schema.d.ts.map +1 -1
- package/dist/types/schemas/tag.schema.d.ts +6 -6
- package/dist/types/schemas/user.schema.d.ts +6 -6
- package/dist/types/utils/filtersAndPagination/getDiscussionFiltersAndPagination.d.ts +2 -2
- package/dist/types/utils/filtersAndPagination/getOrganizationFiltersAndPagination.d.ts +2 -2
- package/dist/types/utils/filtersAndPagination/getProjectFiltersAndPagination.d.ts +2 -2
- package/dist/types/utils/filtersAndPagination/getTagFiltersAndPagination.d.ts +2 -2
- package/package.json +17 -18
- package/dist/cjs/_virtual/_utils_asset.cjs +0 -98
- package/dist/cjs/_virtual/rolldown_runtime.cjs +0 -25
- package/dist/cjs/controllers/ai.controller.cjs +0 -381
- package/dist/cjs/controllers/ai.controller.cjs.map +0 -1
- package/dist/cjs/controllers/dictionary.controller.cjs +0 -463
- package/dist/cjs/controllers/dictionary.controller.cjs.map +0 -1
- package/dist/cjs/controllers/eventListener.controller.cjs +0 -53
- package/dist/cjs/controllers/eventListener.controller.cjs.map +0 -1
- package/dist/cjs/controllers/newsletter.controller.cjs +0 -164
- package/dist/cjs/controllers/newsletter.controller.cjs.map +0 -1
- package/dist/cjs/controllers/oAuth2.controller.cjs +0 -22
- package/dist/cjs/controllers/oAuth2.controller.cjs.map +0 -1
- package/dist/cjs/controllers/organization.controller.cjs +0 -492
- package/dist/cjs/controllers/organization.controller.cjs.map +0 -1
- package/dist/cjs/controllers/project.controller.cjs +0 -430
- package/dist/cjs/controllers/project.controller.cjs.map +0 -1
- package/dist/cjs/controllers/projectAccessKey.controller.cjs +0 -161
- package/dist/cjs/controllers/projectAccessKey.controller.cjs.map +0 -1
- package/dist/cjs/controllers/search.controller.cjs +0 -14
- package/dist/cjs/controllers/search.controller.cjs.map +0 -1
- package/dist/cjs/controllers/stripe.controller.cjs +0 -149
- package/dist/cjs/controllers/stripe.controller.cjs.map +0 -1
- package/dist/cjs/controllers/tag.controller.cjs +0 -226
- package/dist/cjs/controllers/tag.controller.cjs.map +0 -1
- package/dist/cjs/controllers/user.controller.cjs +0 -269
- package/dist/cjs/controllers/user.controller.cjs.map +0 -1
- package/dist/cjs/emails/InviteUserEmail.cjs +0 -325
- package/dist/cjs/emails/InviteUserEmail.cjs.map +0 -1
- package/dist/cjs/emails/MagicLinkEmail.cjs +0 -242
- package/dist/cjs/emails/MagicLinkEmail.cjs.map +0 -1
- package/dist/cjs/emails/OAuthTokenCreatedEmail.cjs +0 -301
- package/dist/cjs/emails/OAuthTokenCreatedEmail.cjs.map +0 -1
- package/dist/cjs/emails/PasswordChangeConfirmation.cjs +0 -177
- package/dist/cjs/emails/PasswordChangeConfirmation.cjs.map +0 -1
- package/dist/cjs/emails/ResetUserPassword.cjs +0 -240
- package/dist/cjs/emails/ResetUserPassword.cjs.map +0 -1
- package/dist/cjs/emails/SubscriptionPaymentCancellation.cjs +0 -202
- package/dist/cjs/emails/SubscriptionPaymentCancellation.cjs.map +0 -1
- package/dist/cjs/emails/SubscriptionPaymentError.cjs +0 -202
- package/dist/cjs/emails/SubscriptionPaymentError.cjs.map +0 -1
- package/dist/cjs/emails/SubscriptionPaymentSuccess.cjs +0 -208
- package/dist/cjs/emails/SubscriptionPaymentSuccess.cjs.map +0 -1
- package/dist/cjs/emails/ValidateUserEmail.cjs +0 -240
- package/dist/cjs/emails/ValidateUserEmail.cjs.map +0 -1
- package/dist/cjs/emails/Welcome.cjs +0 -216
- package/dist/cjs/emails/Welcome.cjs.map +0 -1
- package/dist/cjs/emails/index.cjs +0 -25
- package/dist/cjs/export.cjs +0 -24
- package/dist/cjs/index.cjs +0 -91
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/logger/index.cjs +0 -13
- package/dist/cjs/logger/index.cjs.map +0 -1
- package/dist/cjs/middlewares/oAuth2.middleware.cjs +0 -42
- package/dist/cjs/middlewares/oAuth2.middleware.cjs.map +0 -1
- package/dist/cjs/middlewares/request.middleware.cjs +0 -17
- package/dist/cjs/middlewares/request.middleware.cjs.map +0 -1
- package/dist/cjs/middlewares/sessionAuth.middleware.cjs +0 -22
- package/dist/cjs/middlewares/sessionAuth.middleware.cjs.map +0 -1
- package/dist/cjs/models/dictionary.model.cjs +0 -10
- package/dist/cjs/models/dictionary.model.cjs.map +0 -1
- package/dist/cjs/models/discussion.model.cjs +0 -10
- package/dist/cjs/models/discussion.model.cjs.map +0 -1
- package/dist/cjs/models/oAuth2.model.cjs +0 -10
- package/dist/cjs/models/oAuth2.model.cjs.map +0 -1
- package/dist/cjs/models/organization.model.cjs +0 -10
- package/dist/cjs/models/organization.model.cjs.map +0 -1
- package/dist/cjs/models/project.model.cjs +0 -10
- package/dist/cjs/models/project.model.cjs.map +0 -1
- package/dist/cjs/models/session.model.cjs +0 -10
- package/dist/cjs/models/session.model.cjs.map +0 -1
- package/dist/cjs/models/tag.model.cjs +0 -10
- package/dist/cjs/models/tag.model.cjs.map +0 -1
- package/dist/cjs/models/user.model.cjs +0 -10
- package/dist/cjs/models/user.model.cjs.map +0 -1
- package/dist/cjs/routes/ai.routes.cjs +0 -75
- package/dist/cjs/routes/ai.routes.cjs.map +0 -1
- package/dist/cjs/routes/dictionary.routes.cjs +0 -64
- package/dist/cjs/routes/dictionary.routes.cjs.map +0 -1
- package/dist/cjs/routes/eventListener.routes.cjs +0 -20
- package/dist/cjs/routes/eventListener.routes.cjs.map +0 -1
- package/dist/cjs/routes/newsletter.routes.cjs +0 -34
- package/dist/cjs/routes/newsletter.routes.cjs.map +0 -1
- package/dist/cjs/routes/organization.routes.cjs +0 -70
- package/dist/cjs/routes/organization.routes.cjs.map +0 -1
- package/dist/cjs/routes/project.routes.cjs +0 -83
- package/dist/cjs/routes/project.routes.cjs.map +0 -1
- package/dist/cjs/routes/search.routes.cjs +0 -20
- package/dist/cjs/routes/search.routes.cjs.map +0 -1
- package/dist/cjs/routes/stripe.routes.cjs +0 -34
- package/dist/cjs/routes/stripe.routes.cjs.map +0 -1
- package/dist/cjs/routes/tags.routes.cjs +0 -40
- package/dist/cjs/routes/tags.routes.cjs.map +0 -1
- package/dist/cjs/routes/user.routes.cjs +0 -58
- package/dist/cjs/routes/user.routes.cjs.map +0 -1
- package/dist/cjs/schemas/dictionary.schema.cjs +0 -73
- package/dist/cjs/schemas/dictionary.schema.cjs.map +0 -1
- package/dist/cjs/schemas/discussion.schema.cjs +0 -81
- package/dist/cjs/schemas/discussion.schema.cjs.map +0 -1
- package/dist/cjs/schemas/oAuth2.schema.cjs +0 -49
- package/dist/cjs/schemas/oAuth2.schema.cjs.map +0 -1
- package/dist/cjs/schemas/organization.schema.cjs +0 -62
- package/dist/cjs/schemas/organization.schema.cjs.map +0 -1
- package/dist/cjs/schemas/plans.schema.cjs +0 -75
- package/dist/cjs/schemas/plans.schema.cjs.map +0 -1
- package/dist/cjs/schemas/project.schema.cjs +0 -112
- package/dist/cjs/schemas/project.schema.cjs.map +0 -1
- package/dist/cjs/schemas/session.schema.cjs +0 -43
- package/dist/cjs/schemas/session.schema.cjs.map +0 -1
- package/dist/cjs/schemas/tag.schema.cjs +0 -62
- package/dist/cjs/schemas/tag.schema.cjs.map +0 -1
- package/dist/cjs/schemas/user.schema.cjs +0 -87
- package/dist/cjs/schemas/user.schema.cjs.map +0 -1
- package/dist/cjs/services/dictionary.service.cjs +0 -176
- package/dist/cjs/services/dictionary.service.cjs.map +0 -1
- package/dist/cjs/services/email.service.cjs +0 -155
- package/dist/cjs/services/email.service.cjs.map +0 -1
- package/dist/cjs/services/oAuth2.service.cjs +0 -211
- package/dist/cjs/services/oAuth2.service.cjs.map +0 -1
- package/dist/cjs/services/organization.service.cjs +0 -106
- package/dist/cjs/services/organization.service.cjs.map +0 -1
- package/dist/cjs/services/project.service.cjs +0 -89
- package/dist/cjs/services/project.service.cjs.map +0 -1
- package/dist/cjs/services/projectAccessKey.service.cjs +0 -111
- package/dist/cjs/services/projectAccessKey.service.cjs.map +0 -1
- package/dist/cjs/services/subscription.service.cjs +0 -184
- package/dist/cjs/services/subscription.service.cjs.map +0 -1
- package/dist/cjs/services/tag.service.cjs +0 -88
- package/dist/cjs/services/tag.service.cjs.map +0 -1
- package/dist/cjs/services/user.service.cjs +0 -120
- package/dist/cjs/services/user.service.cjs.map +0 -1
- package/dist/cjs/types/Routes.cjs +0 -0
- package/dist/cjs/types/dictionary.types.cjs +0 -0
- package/dist/cjs/types/discussion.types.cjs +0 -0
- package/dist/cjs/types/oAuth2.types.cjs +0 -0
- package/dist/cjs/types/organization.types.cjs +0 -0
- package/dist/cjs/types/plan.types.cjs +0 -0
- package/dist/cjs/types/project.types.cjs +0 -0
- package/dist/cjs/types/session.types.cjs +0 -0
- package/dist/cjs/types/tag.types.cjs +0 -0
- package/dist/cjs/types/user.types.cjs +0 -10
- package/dist/cjs/types/user.types.cjs.map +0 -1
- package/dist/cjs/utils/AI/aiSdk.cjs +0 -94
- package/dist/cjs/utils/AI/aiSdk.cjs.map +0 -1
- package/dist/cjs/utils/AI/askDocQuestion/askDocQuestion.cjs +0 -201
- package/dist/cjs/utils/AI/askDocQuestion/askDocQuestion.cjs.map +0 -1
- package/dist/cjs/utils/AI/askDocQuestion/indexMarkdownFiles.cjs +0 -150
- package/dist/cjs/utils/AI/askDocQuestion/indexMarkdownFiles.cjs.map +0 -1
- package/dist/cjs/utils/AI/auditDictionary/index.cjs +0 -60
- package/dist/cjs/utils/AI/auditDictionary/index.cjs.map +0 -1
- package/dist/cjs/utils/AI/auditDictionaryField/index.cjs +0 -63
- package/dist/cjs/utils/AI/auditDictionaryField/index.cjs.map +0 -1
- package/dist/cjs/utils/AI/auditDictionaryMetadata/index.cjs +0 -45
- package/dist/cjs/utils/AI/auditDictionaryMetadata/index.cjs.map +0 -1
- package/dist/cjs/utils/AI/auditTag/index.cjs +0 -40
- package/dist/cjs/utils/AI/auditTag/index.cjs.map +0 -1
- package/dist/cjs/utils/AI/autocomplete/index.cjs +0 -41
- package/dist/cjs/utils/AI/autocomplete/index.cjs.map +0 -1
- package/dist/cjs/utils/AI/customQuery/index.cjs +0 -27
- package/dist/cjs/utils/AI/customQuery/index.cjs.map +0 -1
- package/dist/cjs/utils/AI/translateJSON/index.cjs +0 -71
- package/dist/cjs/utils/AI/translateJSON/index.cjs.map +0 -1
- package/dist/cjs/utils/access.cjs +0 -0
- package/dist/cjs/utils/accessControl.cjs +0 -133
- package/dist/cjs/utils/accessControl.cjs.map +0 -1
- package/dist/cjs/utils/auth/getAuth.cjs +0 -218
- package/dist/cjs/utils/auth/getAuth.cjs.map +0 -1
- package/dist/cjs/utils/cors.cjs +0 -33
- package/dist/cjs/utils/cors.cjs.map +0 -1
- package/dist/cjs/utils/ensureArrayQueryFilter.cjs +0 -13
- package/dist/cjs/utils/ensureArrayQueryFilter.cjs.map +0 -1
- package/dist/cjs/utils/ensureMongoDocumentToObject.cjs +0 -16
- package/dist/cjs/utils/ensureMongoDocumentToObject.cjs.map +0 -1
- package/dist/cjs/utils/errors/ErrorHandler.cjs +0 -76
- package/dist/cjs/utils/errors/ErrorHandler.cjs.map +0 -1
- package/dist/cjs/utils/errors/ErrorsClass.cjs +0 -54
- package/dist/cjs/utils/errors/ErrorsClass.cjs.map +0 -1
- package/dist/cjs/utils/errors/errorCodes.cjs +0 -1387
- package/dist/cjs/utils/errors/errorCodes.cjs.map +0 -1
- package/dist/cjs/utils/errors/index.cjs +0 -8
- package/dist/cjs/utils/extractJSON.cjs +0 -61
- package/dist/cjs/utils/extractJSON.cjs.map +0 -1
- package/dist/cjs/utils/filtersAndPagination/getDictionaryFiltersAndPagination.cjs +0 -94
- package/dist/cjs/utils/filtersAndPagination/getDictionaryFiltersAndPagination.cjs.map +0 -1
- package/dist/cjs/utils/filtersAndPagination/getDiscussionFiltersAndPagination.cjs +0 -65
- package/dist/cjs/utils/filtersAndPagination/getDiscussionFiltersAndPagination.cjs.map +0 -1
- package/dist/cjs/utils/filtersAndPagination/getFiltersAndPaginationFromBody.cjs +0 -36
- package/dist/cjs/utils/filtersAndPagination/getFiltersAndPaginationFromBody.cjs.map +0 -1
- package/dist/cjs/utils/filtersAndPagination/getOrganizationFiltersAndPagination.cjs +0 -49
- package/dist/cjs/utils/filtersAndPagination/getOrganizationFiltersAndPagination.cjs.map +0 -1
- package/dist/cjs/utils/filtersAndPagination/getProjectFiltersAndPagination.cjs +0 -53
- package/dist/cjs/utils/filtersAndPagination/getProjectFiltersAndPagination.cjs.map +0 -1
- package/dist/cjs/utils/filtersAndPagination/getTagFiltersAndPagination.cjs +0 -57
- package/dist/cjs/utils/filtersAndPagination/getTagFiltersAndPagination.cjs.map +0 -1
- package/dist/cjs/utils/filtersAndPagination/getUserFiltersAndPagination.cjs +0 -74
- package/dist/cjs/utils/filtersAndPagination/getUserFiltersAndPagination.cjs.map +0 -1
- package/dist/cjs/utils/httpStatusCodes.cjs +0 -401
- package/dist/cjs/utils/httpStatusCodes.cjs.map +0 -1
- package/dist/cjs/utils/mapper/dictionary.cjs +0 -29
- package/dist/cjs/utils/mapper/dictionary.cjs.map +0 -1
- package/dist/cjs/utils/mapper/organization.cjs +0 -19
- package/dist/cjs/utils/mapper/organization.cjs.map +0 -1
- package/dist/cjs/utils/mapper/project.cjs +0 -26
- package/dist/cjs/utils/mapper/project.cjs.map +0 -1
- package/dist/cjs/utils/mapper/session.cjs +0 -15
- package/dist/cjs/utils/mapper/session.cjs.map +0 -1
- package/dist/cjs/utils/mapper/tag.cjs +0 -25
- package/dist/cjs/utils/mapper/tag.cjs.map +0 -1
- package/dist/cjs/utils/mapper/user.cjs +0 -24
- package/dist/cjs/utils/mapper/user.cjs.map +0 -1
- package/dist/cjs/utils/mergeFunctionTypes.cjs +0 -0
- package/dist/cjs/utils/mongoDB/connectDB.cjs +0 -32
- package/dist/cjs/utils/mongoDB/connectDB.cjs.map +0 -1
- package/dist/cjs/utils/mongoDB/types.cjs +0 -0
- package/dist/cjs/utils/oAuth2.cjs +0 -25
- package/dist/cjs/utils/oAuth2.cjs.map +0 -1
- package/dist/cjs/utils/permissions.cjs +0 -103
- package/dist/cjs/utils/permissions.cjs.map +0 -1
- package/dist/cjs/utils/plan.cjs +0 -63
- package/dist/cjs/utils/plan.cjs.map +0 -1
- package/dist/cjs/utils/rateLimiter.cjs +0 -48
- package/dist/cjs/utils/rateLimiter.cjs.map +0 -1
- package/dist/cjs/utils/removeObjectKeys.cjs +0 -11
- package/dist/cjs/utils/removeObjectKeys.cjs.map +0 -1
- package/dist/cjs/utils/responseData.cjs +0 -33
- package/dist/cjs/utils/responseData.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateArray.cjs +0 -31
- package/dist/cjs/utils/validation/validateArray.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateDictionary.cjs +0 -35
- package/dist/cjs/utils/validation/validateDictionary.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateEmail.cjs +0 -20
- package/dist/cjs/utils/validation/validateEmail.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateOrganization.cjs +0 -43
- package/dist/cjs/utils/validation/validateOrganization.cjs.map +0 -1
- package/dist/cjs/utils/validation/validatePhone.cjs +0 -20
- package/dist/cjs/utils/validation/validatePhone.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateProject.cjs +0 -55
- package/dist/cjs/utils/validation/validateProject.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateString.cjs +0 -21
- package/dist/cjs/utils/validation/validateString.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateTag.cjs +0 -47
- package/dist/cjs/utils/validation/validateTag.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateUser.cjs +0 -47
- package/dist/cjs/utils/validation/validateUser.cjs.map +0 -1
- package/dist/cjs/webhooks/stripe.webhook.cjs +0 -116
- package/dist/cjs/webhooks/stripe.webhook.cjs.map +0 -1
|
@@ -1,463 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_utils_ensureMongoDocumentToObject = require('../utils/ensureMongoDocumentToObject.cjs');
|
|
3
|
-
const require_logger_index = require('../logger/index.cjs');
|
|
4
|
-
const require_utils_responseData = require('../utils/responseData.cjs');
|
|
5
|
-
const require_utils_errors_ErrorHandler = require('../utils/errors/ErrorHandler.cjs');
|
|
6
|
-
const require_services_dictionary_service = require('../services/dictionary.service.cjs');
|
|
7
|
-
const require_controllers_eventListener_controller = require('./eventListener.controller.cjs');
|
|
8
|
-
const require_utils_filtersAndPagination_getDictionaryFiltersAndPagination = require('../utils/filtersAndPagination/getDictionaryFiltersAndPagination.cjs');
|
|
9
|
-
const require_utils_mapper_dictionary = require('../utils/mapper/dictionary.cjs');
|
|
10
|
-
const require_utils_permissions = require('../utils/permissions.cjs');
|
|
11
|
-
let express_intlayer = require("express-intlayer");
|
|
12
|
-
let node_util = require("node:util");
|
|
13
|
-
|
|
14
|
-
//#region src/controllers/dictionary.controller.ts
|
|
15
|
-
const removeMetadata = (obj) => {
|
|
16
|
-
if (Array.isArray(obj)) return obj.map(removeMetadata);
|
|
17
|
-
if (obj && typeof obj === "object") {
|
|
18
|
-
const clone = {};
|
|
19
|
-
for (const key in obj) if (key !== "metadata") clone[key] = removeMetadata(obj[key]);
|
|
20
|
-
return clone;
|
|
21
|
-
}
|
|
22
|
-
return obj;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Retrieves a list of dictionaries based on filters and pagination.
|
|
26
|
-
*/
|
|
27
|
-
const getDictionaries = async (req, res, _next) => {
|
|
28
|
-
const { user, project, roles } = res.locals;
|
|
29
|
-
const { filters, sortOptions, pageSize, skip, page, getNumberOfPages } = require_utils_filtersAndPagination_getDictionaryFiltersAndPagination.getDictionaryFiltersAndPagination(req, res);
|
|
30
|
-
if (!project) {
|
|
31
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_DEFINED");
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
if (!user) {
|
|
35
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "USER_NOT_DEFINED");
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
try {
|
|
39
|
-
const dictionaries = await require_services_dictionary_service.findDictionaries({
|
|
40
|
-
...filters,
|
|
41
|
-
projectIds: project.id
|
|
42
|
-
}, skip, pageSize, sortOptions);
|
|
43
|
-
if (!require_utils_permissions.hasPermission(roles, "dictionary:read")({
|
|
44
|
-
...res.locals,
|
|
45
|
-
targetDictionaries: dictionaries
|
|
46
|
-
})) {
|
|
47
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PERMISSION_DENIED");
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const totalItems = await require_services_dictionary_service.countDictionaries(filters);
|
|
51
|
-
const responseData = require_utils_responseData.formatPaginatedResponse({
|
|
52
|
-
data: dictionaries.map((el) => require_utils_mapper_dictionary.mapDictionaryToAPI(el)),
|
|
53
|
-
page,
|
|
54
|
-
pageSize,
|
|
55
|
-
totalPages: getNumberOfPages(totalItems),
|
|
56
|
-
totalItems
|
|
57
|
-
});
|
|
58
|
-
res.json(responseData);
|
|
59
|
-
return;
|
|
60
|
-
} catch (error) {
|
|
61
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleAppErrorResponse(res, error);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Retrieves a list of dictionaries keys based on filters and pagination.
|
|
67
|
-
*/
|
|
68
|
-
const getDictionariesKeys = async (_req, res, _next) => {
|
|
69
|
-
const { project, roles } = res.locals;
|
|
70
|
-
if (!project) {
|
|
71
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_DEFINED");
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
const dictionaries = await require_services_dictionary_service.findDictionaries({ projectIds: project.id });
|
|
76
|
-
if (!require_utils_permissions.hasPermission(roles, "dictionary:read")({
|
|
77
|
-
...res.locals,
|
|
78
|
-
targetDictionaries: dictionaries
|
|
79
|
-
})) {
|
|
80
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PERMISSION_DENIED");
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const responseData = require_utils_responseData.formatResponse({ data: dictionaries.map((dictionary) => dictionary.key) });
|
|
84
|
-
res.json(responseData);
|
|
85
|
-
return;
|
|
86
|
-
} catch (error) {
|
|
87
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleAppErrorResponse(res, error);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Retrieves a list of dictionaries keys based on filters and pagination.
|
|
93
|
-
*/
|
|
94
|
-
const getDictionariesUpdateTimestamp = async (_req, res, _next) => {
|
|
95
|
-
const { project, roles } = res.locals;
|
|
96
|
-
if (!project) {
|
|
97
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_DEFINED");
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
try {
|
|
101
|
-
const dictionaries = await require_services_dictionary_service.findDictionaries({ projectIds: project.id });
|
|
102
|
-
if (!require_utils_permissions.hasPermission(roles, "dictionary:read")({
|
|
103
|
-
...res.locals,
|
|
104
|
-
targetDictionaries: dictionaries
|
|
105
|
-
})) {
|
|
106
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PERMISSION_DENIED");
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const responseData = require_utils_responseData.formatResponse({ data: dictionaries.reduce((acc, dictionary) => ({
|
|
110
|
-
...acc,
|
|
111
|
-
[dictionary.id]: {
|
|
112
|
-
key: dictionary.key,
|
|
113
|
-
updatedAt: new Date(dictionary.updatedAt).getTime()
|
|
114
|
-
}
|
|
115
|
-
}), {}) });
|
|
116
|
-
res.json(responseData);
|
|
117
|
-
return;
|
|
118
|
-
} catch (error) {
|
|
119
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleAppErrorResponse(res, error);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* Retrieves a list of dictionaries based on filters and pagination.
|
|
125
|
-
*/
|
|
126
|
-
const getDictionaryByKey = async (req, res, _next) => {
|
|
127
|
-
const { project, user, roles } = res.locals;
|
|
128
|
-
const { dictionaryKey } = req.params;
|
|
129
|
-
const version = req.query.version;
|
|
130
|
-
if (!project) {
|
|
131
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_DEFINED");
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
if (!user) {
|
|
135
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "USER_NOT_DEFINED");
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
try {
|
|
139
|
-
const dictionary = await require_services_dictionary_service.getDictionaryByKey(dictionaryKey, project.id);
|
|
140
|
-
if (!require_utils_permissions.hasPermission(roles, "dictionary:read")({
|
|
141
|
-
...res.locals,
|
|
142
|
-
targetDictionaries: [dictionary]
|
|
143
|
-
})) {
|
|
144
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PERMISSION_DENIED");
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (!dictionary.projectIds.map(String).includes(String(project.id))) {
|
|
148
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_PROJECT_MISMATCH");
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
const responseData = require_utils_responseData.formatResponse({ data: require_utils_mapper_dictionary.mapDictionaryToAPI(dictionary, version) });
|
|
152
|
-
res.json(responseData);
|
|
153
|
-
return;
|
|
154
|
-
} catch (error) {
|
|
155
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleAppErrorResponse(res, error);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* Adds a new dictionary to the database.
|
|
161
|
-
*/
|
|
162
|
-
const addDictionary = async (req, res, _next) => {
|
|
163
|
-
const { project, user, roles } = res.locals;
|
|
164
|
-
const dictionaryData = req.body.dictionary;
|
|
165
|
-
if (!dictionaryData) {
|
|
166
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_DATA_NOT_FOUND");
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
if (!project) {
|
|
170
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_DEFINED");
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
if (!user) {
|
|
174
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "USER_NOT_DEFINED");
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
if (!dictionaryData.projectIds?.includes(String(project.id))) {
|
|
178
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_PROJECT_MISMATCH");
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
const dictionary = {
|
|
182
|
-
key: dictionaryData.key,
|
|
183
|
-
title: dictionaryData.title,
|
|
184
|
-
description: dictionaryData.description,
|
|
185
|
-
content: new Map([["v1", { content: removeMetadata(dictionaryData.content ?? {}) }]]),
|
|
186
|
-
creatorId: user.id,
|
|
187
|
-
projectIds: dictionaryData.projectIds ?? [String(project.id)]
|
|
188
|
-
};
|
|
189
|
-
if (!require_utils_permissions.hasPermission(roles, "dictionary:write")(res.locals)) {
|
|
190
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PERMISSION_DENIED");
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
try {
|
|
194
|
-
const newDictionary = await require_services_dictionary_service.createDictionary(dictionary);
|
|
195
|
-
const apiResult = require_utils_mapper_dictionary.mapDictionaryToAPI(newDictionary);
|
|
196
|
-
const responseData = require_utils_responseData.formatResponse({
|
|
197
|
-
message: (0, express_intlayer.t)({
|
|
198
|
-
en: "Dictionary created successfully",
|
|
199
|
-
fr: "Dictionnaire créé avec succès",
|
|
200
|
-
es: "Diccionario creado con éxito"
|
|
201
|
-
}),
|
|
202
|
-
description: (0, express_intlayer.t)({
|
|
203
|
-
en: "Your dictionary has been created successfully",
|
|
204
|
-
fr: "Votre dictionnaire a été créé avec succès",
|
|
205
|
-
es: "Su diccionario ha sido creado con éxito"
|
|
206
|
-
}),
|
|
207
|
-
data: apiResult
|
|
208
|
-
});
|
|
209
|
-
res.json(responseData);
|
|
210
|
-
require_controllers_eventListener_controller.sendDictionaryUpdate([{
|
|
211
|
-
dictionary: require_utils_mapper_dictionary.mapDictionaryToAPI(newDictionary),
|
|
212
|
-
status: "ADDED"
|
|
213
|
-
}]);
|
|
214
|
-
return;
|
|
215
|
-
} catch (error) {
|
|
216
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleAppErrorResponse(res, error);
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
/**
|
|
221
|
-
* Check each dictionaries, add the new ones and update the existing ones.
|
|
222
|
-
* @param req - Express request object.
|
|
223
|
-
* @param res - Express response object.
|
|
224
|
-
* @returns Response containing the created dictionary.
|
|
225
|
-
*/
|
|
226
|
-
const pushDictionaries = async (req, res, _next) => {
|
|
227
|
-
const { project, user, roles } = res.locals;
|
|
228
|
-
const dictionaryData = req.body.dictionaries;
|
|
229
|
-
if (typeof dictionaryData === "object" && Array.isArray(dictionaryData) && dictionaryData.length === 0) {
|
|
230
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARIES_NOT_PROVIDED");
|
|
231
|
-
return;
|
|
232
|
-
} else if (!dictionaryData) {
|
|
233
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_DATA_NOT_FOUND");
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
if (!project) {
|
|
237
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_DEFINED");
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
if (!user) {
|
|
241
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "USER_NOT_DEFINED");
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
if (!require_utils_permissions.hasPermission(roles, "dictionary:write")(res.locals)) {
|
|
245
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PERMISSION_DENIED");
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
try {
|
|
249
|
-
const existingDictionaries = dictionaryData.filter((dictionary) => dictionary.id !== void 0);
|
|
250
|
-
const newDictionaries = dictionaryData.filter((dictionary) => dictionary.id === void 0);
|
|
251
|
-
const newDictionariesResult = [];
|
|
252
|
-
const updatedDictionariesResult = [];
|
|
253
|
-
const errorResult = [];
|
|
254
|
-
for (const dictionaryDataEl of newDictionaries) {
|
|
255
|
-
const dictionary = {
|
|
256
|
-
title: dictionaryDataEl.title,
|
|
257
|
-
description: dictionaryDataEl.description,
|
|
258
|
-
projectIds: [String(project.id)],
|
|
259
|
-
creatorId: user.id,
|
|
260
|
-
content: new Map([["v1", { content: removeMetadata(dictionaryDataEl.content) ?? {} }]]),
|
|
261
|
-
key: dictionaryDataEl.key
|
|
262
|
-
};
|
|
263
|
-
try {
|
|
264
|
-
const newDictionary = await require_services_dictionary_service.createDictionary(dictionary);
|
|
265
|
-
newDictionariesResult.push({
|
|
266
|
-
key: newDictionary.key,
|
|
267
|
-
localId: dictionaryDataEl.localId,
|
|
268
|
-
id: newDictionary.id
|
|
269
|
-
});
|
|
270
|
-
} catch (error) {
|
|
271
|
-
errorResult.push({
|
|
272
|
-
id: dictionaryDataEl.id,
|
|
273
|
-
key: dictionaryDataEl.key,
|
|
274
|
-
localId: dictionaryDataEl.localId,
|
|
275
|
-
message: error.message
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
for (const dictionaryDataEl of existingDictionaries) {
|
|
280
|
-
const remoteDictionary = await require_services_dictionary_service.getDictionaryById(dictionaryDataEl.id);
|
|
281
|
-
const cleanedContent = removeMetadata(dictionaryDataEl.content);
|
|
282
|
-
const versionList = [...remoteDictionary.content.keys() ?? []];
|
|
283
|
-
const lastVersion = versionList[versionList.length - 1];
|
|
284
|
-
const isSameContent = (0, node_util.isDeepStrictEqual)(remoteDictionary.content.get(lastVersion)?.content ?? null, cleanedContent);
|
|
285
|
-
const newContent = new Map(remoteDictionary.content);
|
|
286
|
-
if (!isSameContent) {
|
|
287
|
-
const newContentVersion = require_services_dictionary_service.incrementVersion(remoteDictionary);
|
|
288
|
-
newContent.set(newContentVersion, { content: cleanedContent });
|
|
289
|
-
}
|
|
290
|
-
const dictionary = {
|
|
291
|
-
...require_utils_ensureMongoDocumentToObject.ensureMongoDocumentToObject(remoteDictionary),
|
|
292
|
-
...dictionaryDataEl,
|
|
293
|
-
content: newContent,
|
|
294
|
-
projectIds: [String(project.id)],
|
|
295
|
-
creatorId: user.id,
|
|
296
|
-
key: remoteDictionary.key
|
|
297
|
-
};
|
|
298
|
-
try {
|
|
299
|
-
const updatedDictionary = await require_services_dictionary_service.updateDictionaryByKey(remoteDictionary.key, dictionary, project.id);
|
|
300
|
-
updatedDictionariesResult.push({
|
|
301
|
-
key: updatedDictionary.key,
|
|
302
|
-
localId: dictionaryDataEl.localId,
|
|
303
|
-
id: updatedDictionary.id
|
|
304
|
-
});
|
|
305
|
-
} catch (error) {
|
|
306
|
-
errorResult.push({
|
|
307
|
-
id: dictionaryDataEl.id,
|
|
308
|
-
key: dictionaryDataEl.key,
|
|
309
|
-
localId: dictionaryDataEl.localId,
|
|
310
|
-
message: error.message
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
const result = {
|
|
315
|
-
newDictionaries: newDictionariesResult,
|
|
316
|
-
updatedDictionaries: updatedDictionariesResult,
|
|
317
|
-
error: errorResult
|
|
318
|
-
};
|
|
319
|
-
const responseData = require_utils_responseData.formatResponse({
|
|
320
|
-
message: (0, express_intlayer.t)({
|
|
321
|
-
en: "Dictionaries updated successfully",
|
|
322
|
-
fr: "Dictionnaires mis à jour avec succès",
|
|
323
|
-
es: "Diccionarios actualizados con éxito"
|
|
324
|
-
}),
|
|
325
|
-
description: (0, express_intlayer.t)({
|
|
326
|
-
en: "Your dictionaries have been updated successfully",
|
|
327
|
-
fr: "Vos dictionnaires ont été mis à jour avec succès",
|
|
328
|
-
es: "Sus diccionarios han sido actualizados con éxito"
|
|
329
|
-
}),
|
|
330
|
-
data: result
|
|
331
|
-
});
|
|
332
|
-
require_controllers_eventListener_controller.sendDictionaryUpdate([...newDictionariesResult.map((dictionary) => ({
|
|
333
|
-
dictionary,
|
|
334
|
-
status: "ADDED"
|
|
335
|
-
})), ...updatedDictionariesResult.map((dictionary) => ({
|
|
336
|
-
dictionary,
|
|
337
|
-
status: "UPDATED"
|
|
338
|
-
}))]);
|
|
339
|
-
res.json(responseData);
|
|
340
|
-
return;
|
|
341
|
-
} catch (error) {
|
|
342
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleAppErrorResponse(res, error);
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
/**
|
|
347
|
-
* Updates an existing dictionary in the database.
|
|
348
|
-
*/
|
|
349
|
-
const updateDictionary = async (req, res, _next) => {
|
|
350
|
-
const { dictionaryId } = req.params;
|
|
351
|
-
const { project, roles } = res.locals;
|
|
352
|
-
const dictionaryData = req.body;
|
|
353
|
-
if (!dictionaryData) {
|
|
354
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_DATA_NOT_FOUND");
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
if (!project) {
|
|
358
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_DEFINED");
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
if (!dictionaryData.projectIds?.includes(String(project.id))) {
|
|
362
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_PROJECT_MISMATCH");
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
if (typeof dictionaryId === "undefined") {
|
|
366
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_ID_NOT_FOUND");
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
|
-
if (!require_utils_permissions.hasPermission(roles, "dictionary:write")(res.locals)) {
|
|
370
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PERMISSION_DENIED");
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
try {
|
|
374
|
-
const apiResult = require_utils_mapper_dictionary.mapDictionaryToAPI(await require_services_dictionary_service.updateDictionaryById(dictionaryId, dictionaryData));
|
|
375
|
-
const responseData = require_utils_responseData.formatResponse({
|
|
376
|
-
message: (0, express_intlayer.t)({
|
|
377
|
-
en: "Dictionary updated successfully",
|
|
378
|
-
fr: "Dictionnaire mis à jour avec succès",
|
|
379
|
-
es: "Diccionario actualizado con éxito"
|
|
380
|
-
}),
|
|
381
|
-
description: (0, express_intlayer.t)({
|
|
382
|
-
en: "Your dictionary has been updated successfully",
|
|
383
|
-
fr: "Votre dictionnaire a été mis à jour avec succès",
|
|
384
|
-
es: "Su diccionario ha sido actualizado con éxito"
|
|
385
|
-
}),
|
|
386
|
-
data: apiResult
|
|
387
|
-
});
|
|
388
|
-
require_controllers_eventListener_controller.sendDictionaryUpdate([{
|
|
389
|
-
dictionary: apiResult,
|
|
390
|
-
status: "UPDATED"
|
|
391
|
-
}]);
|
|
392
|
-
res.json(responseData);
|
|
393
|
-
return;
|
|
394
|
-
} catch (error) {
|
|
395
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleAppErrorResponse(res, error);
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
/**
|
|
400
|
-
* Deletes a dictionary from the database by its ID.
|
|
401
|
-
*/
|
|
402
|
-
const deleteDictionary = async (req, res, _next) => {
|
|
403
|
-
const { project, roles } = res.locals;
|
|
404
|
-
const { dictionaryId } = req.params;
|
|
405
|
-
if (!dictionaryId) {
|
|
406
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_ID_NOT_FOUND");
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
if (!project) {
|
|
410
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_DEFINED");
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
if (!require_utils_permissions.hasPermission(roles, "dictionary:admin")(res.locals)) {
|
|
414
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PERMISSION_DENIED");
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
try {
|
|
418
|
-
if (!(await require_services_dictionary_service.getDictionaryById(dictionaryId)).projectIds.includes(project.id)) {
|
|
419
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_PROJECT_MISMATCH");
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
const deletedDictionary = await require_services_dictionary_service.deleteDictionaryById(dictionaryId);
|
|
423
|
-
if (!deletedDictionary) {
|
|
424
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_NOT_FOUND", { dictionaryId });
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
require_logger_index.logger.info(`Dictionary deleted: ${String(deletedDictionary.id)}`);
|
|
428
|
-
const apiResult = require_utils_mapper_dictionary.mapDictionaryToAPI(deletedDictionary);
|
|
429
|
-
const responseData = require_utils_responseData.formatResponse({
|
|
430
|
-
message: (0, express_intlayer.t)({
|
|
431
|
-
en: "Dictionary deleted successfully",
|
|
432
|
-
fr: "Dictionnaire supprimé avec succès",
|
|
433
|
-
es: "Diccionario eliminado con éxito"
|
|
434
|
-
}),
|
|
435
|
-
description: (0, express_intlayer.t)({
|
|
436
|
-
en: "Your dictionary has been deleted successfully",
|
|
437
|
-
fr: "Votre dictionnaire a été supprimé avec succès",
|
|
438
|
-
es: "Su diccionario ha sido eliminado con éxito"
|
|
439
|
-
}),
|
|
440
|
-
data: apiResult
|
|
441
|
-
});
|
|
442
|
-
res.json(responseData);
|
|
443
|
-
require_controllers_eventListener_controller.sendDictionaryUpdate([{
|
|
444
|
-
dictionary: apiResult,
|
|
445
|
-
status: "DELETED"
|
|
446
|
-
}]);
|
|
447
|
-
return;
|
|
448
|
-
} catch (error) {
|
|
449
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleAppErrorResponse(res, error);
|
|
450
|
-
return;
|
|
451
|
-
}
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
//#endregion
|
|
455
|
-
exports.addDictionary = addDictionary;
|
|
456
|
-
exports.deleteDictionary = deleteDictionary;
|
|
457
|
-
exports.getDictionaries = getDictionaries;
|
|
458
|
-
exports.getDictionariesKeys = getDictionariesKeys;
|
|
459
|
-
exports.getDictionariesUpdateTimestamp = getDictionariesUpdateTimestamp;
|
|
460
|
-
exports.getDictionaryByKey = getDictionaryByKey;
|
|
461
|
-
exports.pushDictionaries = pushDictionaries;
|
|
462
|
-
exports.updateDictionary = updateDictionary;
|
|
463
|
-
//# sourceMappingURL=dictionary.controller.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.controller.cjs","names":["clone: T","getDictionaryFiltersAndPagination","hasPermission","formatPaginatedResponse","mapDictionaryToAPI","formatResponse","dictionary: DictionaryData","newDictionariesResult: PushDictionariesResultData['newDictionaries']","updatedDictionariesResult: PushDictionariesResultData['updatedDictionaries']","errorResult: PushDictionariesResultData['error']","newContent: VersionedContent","ensureMongoDocumentToObject","result: PushDictionariesResultData"],"sources":["../../../src/controllers/dictionary.controller.ts"],"sourcesContent":["import { isDeepStrictEqual } from 'node:util';\nimport * as eventListener from '@controllers/eventListener.controller';\nimport type {\n ContentNode,\n DictionaryId,\n Dictionary as LocalDictionary,\n LocalDictionaryId,\n} from '@intlayer/types';\nimport { logger } from '@logger';\nimport type { ResponseWithSession } from '@middlewares/sessionAuth.middleware';\nimport * as dictionaryService from '@services/dictionary.service';\nimport { ensureMongoDocumentToObject } from '@utils/ensureMongoDocumentToObject';\nimport { type AppError, ErrorHandler } from '@utils/errors';\nimport {\n type DictionaryFiltersParams,\n getDictionaryFiltersAndPagination,\n} from '@utils/filtersAndPagination/getDictionaryFiltersAndPagination';\nimport type { FiltersAndPagination } from '@utils/filtersAndPagination/getFiltersAndPaginationFromBody';\nimport { mapDictionaryToAPI } from '@utils/mapper/dictionary';\nimport { hasPermission } from '@utils/permissions';\nimport {\n formatPaginatedResponse,\n formatResponse,\n type PaginatedResponse,\n type ResponseData,\n} from '@utils/responseData';\nimport type { NextFunction, Request } from 'express';\nimport { t } from 'express-intlayer';\nimport type {\n Dictionary,\n DictionaryAPI,\n DictionaryCreationData,\n DictionaryData,\n VersionedContent,\n} from '@/types/dictionary.types';\n\nexport type GetDictionariesParams =\n FiltersAndPagination<DictionaryFiltersParams>;\nexport type GetDictionariesResult = PaginatedResponse<DictionaryAPI>;\n\nconst removeMetadata = <T extends Record<string, any>>(obj: T): T => {\n if (Array.isArray(obj)) {\n return obj.map(removeMetadata) as unknown as T;\n }\n\n if (obj && typeof obj === 'object') {\n const clone: T = {} as T;\n for (const key in obj) {\n if (key !== 'metadata') {\n clone[key] = removeMetadata(obj[key]);\n }\n }\n return clone as T;\n }\n\n return obj as T;\n};\n\n/**\n * Retrieves a list of dictionaries based on filters and pagination.\n */\nexport const getDictionaries = async (\n req: Request<GetDictionariesParams>,\n res: ResponseWithSession<GetDictionariesResult>,\n _next: NextFunction\n): Promise<void> => {\n const { user, project, roles } = res.locals;\n const { filters, sortOptions, pageSize, skip, page, getNumberOfPages } =\n getDictionaryFiltersAndPagination(req, res);\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n\n try {\n const dictionaries = await dictionaryService.findDictionaries(\n {\n ...filters,\n projectIds: project.id,\n },\n skip,\n pageSize,\n sortOptions\n );\n\n if (\n !hasPermission(\n roles,\n 'dictionary:read'\n )({\n ...res.locals,\n targetDictionaries: dictionaries,\n })\n ) {\n ErrorHandler.handleGenericErrorResponse(res, 'PERMISSION_DENIED');\n return;\n }\n\n const totalItems = await dictionaryService.countDictionaries(filters);\n\n const dictionariesAPI = dictionaries.map((el) => mapDictionaryToAPI(el));\n\n const responseData = formatPaginatedResponse<DictionaryAPI>({\n data: dictionariesAPI,\n page,\n pageSize,\n totalPages: getNumberOfPages(totalItems),\n totalItems,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type GetDictionariesKeysResult = ResponseData<string[]>;\n\n/**\n * Retrieves a list of dictionaries keys based on filters and pagination.\n */\nexport const getDictionariesKeys = async (\n _req: Request,\n res: ResponseWithSession<GetDictionariesKeysResult>,\n _next: NextFunction\n) => {\n const { project, roles } = res.locals;\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n try {\n const dictionaries = await dictionaryService.findDictionaries({\n projectIds: project.id,\n });\n\n if (\n !hasPermission(\n roles,\n 'dictionary:read'\n )({\n ...res.locals,\n targetDictionaries: dictionaries,\n })\n ) {\n ErrorHandler.handleGenericErrorResponse(res, 'PERMISSION_DENIED');\n return;\n }\n\n const dictionariesKeys = dictionaries.map((dictionary) => dictionary.key);\n\n const responseData = formatResponse<string[]>({\n data: dictionariesKeys,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type GetDictionariesUpdateTimestampResult = ResponseData<\n Record<DictionaryId, { key: string; updatedAt: number }>\n>;\n\n/**\n * Retrieves a list of dictionaries keys based on filters and pagination.\n */\nexport const getDictionariesUpdateTimestamp = async (\n _req: Request,\n res: ResponseWithSession<GetDictionariesUpdateTimestampResult>,\n _next: NextFunction\n) => {\n const { project, roles } = res.locals;\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n try {\n const dictionaries = await dictionaryService.findDictionaries({\n projectIds: project.id,\n });\n\n if (\n !hasPermission(\n roles,\n 'dictionary:read'\n )({\n ...res.locals,\n targetDictionaries: dictionaries,\n })\n ) {\n ErrorHandler.handleGenericErrorResponse(res, 'PERMISSION_DENIED');\n return;\n }\n\n const dictionariesUpdateTimestamp = dictionaries.reduce(\n (acc, dictionary) => ({\n ...acc,\n [dictionary.id]: {\n key: dictionary.key,\n updatedAt: new Date(dictionary.updatedAt).getTime(),\n },\n }),\n {}\n );\n\n const responseData = formatResponse<\n Record<string, { key: string; updatedAt: number }>\n >({\n data: dictionariesUpdateTimestamp,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type GetDictionaryParams = { dictionaryKey: string };\nexport type GetDictionaryQuery = { version?: string };\nexport type GetDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Retrieves a list of dictionaries based on filters and pagination.\n */\nexport const getDictionaryByKey = async (\n req: Request<GetDictionaryParams, any, any, GetDictionaryQuery>,\n res: ResponseWithSession<GetDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project, user, roles } = res.locals;\n const { dictionaryKey } = req.params;\n const version = req.query.version;\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n\n try {\n const dictionary = await dictionaryService.getDictionaryByKey(\n dictionaryKey,\n project.id\n );\n\n if (\n !hasPermission(\n roles,\n 'dictionary:read'\n )({\n ...res.locals,\n targetDictionaries: [dictionary],\n })\n ) {\n ErrorHandler.handleGenericErrorResponse(res, 'PERMISSION_DENIED');\n return;\n }\n\n if (!dictionary.projectIds.map(String).includes(String(project.id))) {\n ErrorHandler.handleGenericErrorResponse(\n res,\n 'DICTIONARY_PROJECT_MISMATCH'\n );\n return;\n }\n\n const apiResult = mapDictionaryToAPI(dictionary, version);\n\n const responseData = formatResponse<DictionaryAPI>({\n data: apiResult,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type AddDictionaryBody = { dictionary: DictionaryCreationData };\nexport type AddDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Adds a new dictionary to the database.\n */\nexport const addDictionary = async (\n req: Request<any, any, AddDictionaryBody>,\n res: ResponseWithSession<AddDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project, user, roles } = res.locals;\n const dictionaryData = req.body.dictionary;\n\n if (!dictionaryData) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_DATA_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n\n if (!dictionaryData.projectIds?.includes(String(project.id))) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_PROJECT_MISMATCH');\n return;\n }\n\n const dictionary: DictionaryData = {\n key: dictionaryData.key,\n title: dictionaryData.title,\n description: dictionaryData.description,\n content: new Map([\n [\n 'v1',\n {\n // Remove metadata as markdown metadata are dynamic data inserted at build time\n content: removeMetadata(dictionaryData.content ?? {}) as ContentNode,\n },\n ],\n ]),\n creatorId: user.id,\n projectIds: dictionaryData.projectIds ?? [String(project.id)],\n };\n\n if (!hasPermission(roles, 'dictionary:write')(res.locals)) {\n ErrorHandler.handleGenericErrorResponse(res, 'PERMISSION_DENIED');\n return;\n }\n\n try {\n const newDictionary = await dictionaryService.createDictionary(dictionary);\n\n const apiResult = mapDictionaryToAPI(newDictionary);\n\n const responseData = formatResponse<DictionaryAPI>({\n message: t({\n en: 'Dictionary created successfully',\n fr: 'Dictionnaire créé avec succès',\n es: 'Diccionario creado con éxito',\n }),\n description: t({\n en: 'Your dictionary has been created successfully',\n fr: 'Votre dictionnaire a été créé avec succès',\n es: 'Su diccionario ha sido creado con éxito',\n }),\n data: apiResult,\n });\n\n res.json(responseData);\n\n eventListener.sendDictionaryUpdate([\n {\n dictionary: mapDictionaryToAPI(newDictionary),\n status: 'ADDED',\n },\n ]);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type PushDictionariesBody = {\n dictionaries: LocalDictionary[];\n};\ntype PushDictionariesResultData = {\n newDictionaries: {\n key: string;\n localId: LocalDictionaryId;\n id: string | undefined;\n }[];\n updatedDictionaries: {\n key: string;\n localId: LocalDictionaryId;\n id: string | undefined;\n }[];\n error: {\n id: string | undefined;\n key: string;\n localId: LocalDictionaryId | undefined;\n message: string;\n }[];\n};\nexport type PushDictionariesResult = ResponseData<PushDictionariesResultData>;\n\n/**\n * Check each dictionaries, add the new ones and update the existing ones.\n * @param req - Express request object.\n * @param res - Express response object.\n * @returns Response containing the created dictionary.\n */\nexport const pushDictionaries = async (\n req: Request<any, any, PushDictionariesBody>,\n res: ResponseWithSession<PushDictionariesResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project, user, roles } = res.locals;\n\n const dictionaryData = req.body.dictionaries;\n\n if (\n typeof dictionaryData === 'object' &&\n Array.isArray(dictionaryData) &&\n dictionaryData.length === 0\n ) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARIES_NOT_PROVIDED');\n return;\n } else if (!dictionaryData) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_DATA_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n\n if (!hasPermission(roles, 'dictionary:write')(res.locals)) {\n ErrorHandler.handleGenericErrorResponse(res, 'PERMISSION_DENIED');\n return;\n }\n\n try {\n const existingDictionaries = dictionaryData.filter(\n (dictionary) => dictionary.id !== undefined\n );\n const newDictionaries = dictionaryData.filter(\n (dictionary) => dictionary.id === undefined\n );\n\n const newDictionariesResult: PushDictionariesResultData['newDictionaries'] =\n [];\n const updatedDictionariesResult: PushDictionariesResultData['updatedDictionaries'] =\n [];\n const errorResult: PushDictionariesResultData['error'] = [];\n\n for (const dictionaryDataEl of newDictionaries) {\n const dictionary: DictionaryData = {\n title: dictionaryDataEl.title,\n description: dictionaryDataEl.description,\n projectIds: [String(project.id)],\n creatorId: user.id,\n content: new Map([\n // Remove metadata as markdown metadata are dynamic data inserted at build time\n\n [\n 'v1',\n {\n content:\n removeMetadata(dictionaryDataEl.content) ?? ({} as ContentNode),\n },\n ],\n ]),\n key: dictionaryDataEl.key,\n };\n\n try {\n const newDictionary =\n await dictionaryService.createDictionary(dictionary);\n newDictionariesResult.push({\n key: newDictionary.key,\n localId: dictionaryDataEl.localId!,\n id: newDictionary.id,\n });\n } catch (error) {\n errorResult.push({\n id: dictionaryDataEl.id!,\n key: dictionaryDataEl.key,\n localId: dictionaryDataEl.localId!,\n message: (error as AppError).message,\n });\n }\n }\n\n for (const dictionaryDataEl of existingDictionaries) {\n const remoteDictionary = await dictionaryService.getDictionaryById(\n dictionaryDataEl.id!\n );\n\n // Remove metadata as markdown metadata are dynamic data inserted at build time\n const cleanedContent = removeMetadata(dictionaryDataEl.content);\n\n const versionList = [...(remoteDictionary.content.keys() ?? [])];\n const lastVersion = versionList[versionList.length - 1];\n\n const lastContent =\n (remoteDictionary.content.get(lastVersion)\n ?.content as DictionaryAPI['content']) ?? null;\n\n const isSameContent = isDeepStrictEqual(lastContent, cleanedContent);\n\n const newContent: VersionedContent = new Map(remoteDictionary.content);\n\n if (!isSameContent) {\n const newContentVersion =\n dictionaryService.incrementVersion(remoteDictionary);\n\n newContent.set(newContentVersion, {\n // Remove metadata as markdown metadata are dynamic data inserted at build time\n content: cleanedContent,\n });\n }\n\n const dictionary: DictionaryData = {\n ...ensureMongoDocumentToObject(remoteDictionary),\n ...dictionaryDataEl,\n content: newContent,\n projectIds: [String(project.id)],\n creatorId: user.id,\n key: remoteDictionary.key,\n };\n\n try {\n const updatedDictionary = await dictionaryService.updateDictionaryByKey(\n remoteDictionary.key,\n dictionary,\n project.id\n );\n updatedDictionariesResult.push({\n key: updatedDictionary.key,\n localId: dictionaryDataEl.localId!,\n id: updatedDictionary.id,\n });\n } catch (error) {\n errorResult.push({\n id: dictionaryDataEl.id!,\n key: dictionaryDataEl.key,\n localId: dictionaryDataEl.localId!,\n message: (error as AppError).message,\n });\n }\n }\n\n const result: PushDictionariesResultData = {\n newDictionaries: newDictionariesResult,\n updatedDictionaries: updatedDictionariesResult,\n error: errorResult,\n };\n\n const responseData = formatResponse<PushDictionariesResultData>({\n message: t({\n en: 'Dictionaries updated successfully',\n fr: 'Dictionnaires mis à jour avec succès',\n es: 'Diccionarios actualizados con éxito',\n }),\n description: t({\n en: 'Your dictionaries have been updated successfully',\n fr: 'Vos dictionnaires ont été mis à jour avec succès',\n es: 'Sus diccionarios han sido actualizados con éxito',\n }),\n data: result,\n });\n\n eventListener.sendDictionaryUpdate([\n ...newDictionariesResult.map(\n (dictionary) =>\n ({\n dictionary,\n status: 'ADDED',\n }) as eventListener.SendDictionaryUpdateArg\n ),\n ...updatedDictionariesResult.map(\n (dictionary) =>\n ({\n dictionary,\n status: 'UPDATED',\n }) as eventListener.SendDictionaryUpdateArg\n ),\n ]);\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type UpdateDictionaryParam = { dictionaryId: string };\nexport type UpdateDictionaryBody = Partial<Dictionary>;\nexport type UpdateDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Updates an existing dictionary in the database.\n */\nexport const updateDictionary = async (\n req: Request<UpdateDictionaryParam, any, UpdateDictionaryBody>,\n res: ResponseWithSession<UpdateDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { dictionaryId } = req.params;\n const { project, roles } = res.locals;\n const dictionaryData = req.body;\n\n if (!dictionaryData) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_DATA_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n if (!dictionaryData.projectIds?.includes(String(project.id))) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_PROJECT_MISMATCH');\n return;\n }\n\n if (typeof dictionaryId === 'undefined') {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_ID_NOT_FOUND');\n return;\n }\n\n if (!hasPermission(roles, 'dictionary:write')(res.locals)) {\n ErrorHandler.handleGenericErrorResponse(res, 'PERMISSION_DENIED');\n return;\n }\n\n try {\n const updatedDictionary = await dictionaryService.updateDictionaryById(\n dictionaryId,\n dictionaryData\n );\n\n const apiResult = mapDictionaryToAPI(updatedDictionary);\n\n const responseData = formatResponse<DictionaryAPI>({\n message: t({\n en: 'Dictionary updated successfully',\n fr: 'Dictionnaire mis à jour avec succès',\n es: 'Diccionario actualizado con éxito',\n }),\n description: t({\n en: 'Your dictionary has been updated successfully',\n fr: 'Votre dictionnaire a été mis à jour avec succès',\n es: 'Su diccionario ha sido actualizado con éxito',\n }),\n data: apiResult,\n });\n\n eventListener.sendDictionaryUpdate([\n {\n dictionary: apiResult,\n status: 'UPDATED',\n },\n ]);\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type DeleteDictionaryParam = { dictionaryId: string };\nexport type DeleteDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Deletes a dictionary from the database by its ID.\n */\nexport const deleteDictionary = async (\n req: Request<DeleteDictionaryParam>,\n res: ResponseWithSession<DeleteDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project, roles } = res.locals;\n const { dictionaryId } = req.params as Partial<DeleteDictionaryParam>;\n\n if (!dictionaryId) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_ID_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n if (!hasPermission(roles, 'dictionary:admin')(res.locals)) {\n ErrorHandler.handleGenericErrorResponse(res, 'PERMISSION_DENIED');\n return;\n }\n\n try {\n const dictionaryToDelete =\n await dictionaryService.getDictionaryById(dictionaryId);\n\n if (!dictionaryToDelete.projectIds.includes(project.id)) {\n ErrorHandler.handleGenericErrorResponse(\n res,\n 'DICTIONARY_PROJECT_MISMATCH'\n );\n return;\n }\n\n const deletedDictionary =\n await dictionaryService.deleteDictionaryById(dictionaryId);\n\n if (!deletedDictionary) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_NOT_FOUND', {\n dictionaryId,\n });\n return;\n }\n\n logger.info(`Dictionary deleted: ${String(deletedDictionary.id)}`);\n\n const apiResult = mapDictionaryToAPI(deletedDictionary);\n\n const responseData = formatResponse<DictionaryAPI>({\n message: t({\n en: 'Dictionary deleted successfully',\n fr: 'Dictionnaire supprimé avec succès',\n es: 'Diccionario eliminado con éxito',\n }),\n description: t({\n en: 'Your dictionary has been deleted successfully',\n fr: 'Votre dictionnaire a été supprimé avec succès',\n es: 'Su diccionario ha sido eliminado con éxito',\n }),\n data: apiResult,\n });\n\n res.json(responseData);\n\n eventListener.sendDictionaryUpdate([\n {\n dictionary: apiResult,\n status: 'DELETED',\n },\n ]);\n\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;AAwCA,MAAM,kBAAiD,QAAc;AACnE,KAAI,MAAM,QAAQ,IAAI,CACpB,QAAO,IAAI,IAAI,eAAe;AAGhC,KAAI,OAAO,OAAO,QAAQ,UAAU;EAClC,MAAMA,QAAW,EAAE;AACnB,OAAK,MAAM,OAAO,IAChB,KAAI,QAAQ,WACV,OAAM,OAAO,eAAe,IAAI,KAAK;AAGzC,SAAO;;AAGT,QAAO;;;;;AAMT,MAAa,kBAAkB,OAC7B,KACA,KACA,UACkB;CAClB,MAAM,EAAE,MAAM,SAAS,UAAU,IAAI;CACrC,MAAM,EAAE,SAAS,aAAa,UAAU,MAAM,MAAM,qBAClDC,uGAAkC,KAAK,IAAI;AAE7C,KAAI,CAAC,SAAS;AACZ,iDAAa,2BAA2B,KAAK,sBAAsB;AACnE;;AAGF,KAAI,CAAC,MAAM;AACT,iDAAa,2BAA2B,KAAK,mBAAmB;AAChE;;AAGF,KAAI;EACF,MAAM,eAAe,2DACnB;GACE,GAAG;GACH,YAAY,QAAQ;GACrB,EACD,MACA,UACA,YACD;AAED,MACE,CAACC,wCACC,OACA,kBACD,CAAC;GACA,GAAG,IAAI;GACP,oBAAoB;GACrB,CAAC,EACF;AACA,kDAAa,2BAA2B,KAAK,oBAAoB;AACjE;;EAGF,MAAM,aAAa,4DAA0C,QAAQ;EAIrE,MAAM,eAAeC,mDAAuC;GAC1D,MAHsB,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KACA,8BACD;AACD;;EAGF,MAAM,oBACJ,+DAA6C,aAAa;AAE5D,MAAI,CAAC,mBAAmB;AACtB,kDAAa,2BAA2B,KAAK,wBAAwB,EACnE,cACD,CAAC;AACF;;AAGF,8BAAO,KAAK,uBAAuB,OAAO,kBAAkB,GAAG,GAAG;EAElE,MAAM,YAAYE,mDAAmB,kBAAkB;EAEvD,MAAM,eAAeC,0CAA8B;GACjD,iCAAW;IACT,IAAI;IACJ,IAAI;IACJ,IAAI;IACL,CAAC;GACF,qCAAe;IACb,IAAI;IACJ,IAAI;IACJ,IAAI;IACL,CAAC;GACF,MAAM;GACP,CAAC;AAEF,MAAI,KAAK,aAAa;AAEtB,oEAAmC,CACjC;GACE,YAAY;GACZ,QAAQ;GACT,CACF,CAAC;AAEF;UACO,OAAO;AACd,iDAAa,uBAAuB,KAAK,MAAkB;AAC3D"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
const require_logger_index = require('../logger/index.cjs');
|
|
2
|
-
const require_utils_errors_ErrorHandler = require('../utils/errors/ErrorHandler.cjs');
|
|
3
|
-
|
|
4
|
-
//#region src/controllers/eventListener.controller.ts
|
|
5
|
-
let clients = [];
|
|
6
|
-
const MAX_SSE_CONNECTIONS = 10;
|
|
7
|
-
const sendDictionaryUpdate = (args) => {
|
|
8
|
-
const projectIds = args.flatMap((arg) => arg.dictionary.projectIds);
|
|
9
|
-
const filteredClients = clients.filter((client) => projectIds.map((id) => String(id)).includes(String(client.projectId)));
|
|
10
|
-
const data = args.map((arg) => ({
|
|
11
|
-
object: "DICTIONARY",
|
|
12
|
-
status: arg.status,
|
|
13
|
-
data: arg.dictionary
|
|
14
|
-
}));
|
|
15
|
-
process.nextTick(() => {
|
|
16
|
-
for (const client of filteredClients) {
|
|
17
|
-
client.res.write(`data: ${JSON.stringify(data)}\n\n`);
|
|
18
|
-
client.res.flush?.();
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* SSE to check the email verification status
|
|
24
|
-
*/
|
|
25
|
-
const listenChangeSSE = async (req, res) => {
|
|
26
|
-
const { project } = res.locals;
|
|
27
|
-
if (clients.length >= MAX_SSE_CONNECTIONS) {
|
|
28
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "TOO_MANY_CONNECTIONS");
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
res.setHeader("Content-Type", "text/event-stream;charset=utf-8");
|
|
32
|
-
res.setHeader("Cache-Control", "no-cache, no-transform");
|
|
33
|
-
res.setHeader("Connection", "keep-alive");
|
|
34
|
-
res.setHeader("X-Accel-Buffering", "no");
|
|
35
|
-
res.write(":\n\n");
|
|
36
|
-
res.flushHeaders?.();
|
|
37
|
-
const clientId = Date.now();
|
|
38
|
-
const newClient = {
|
|
39
|
-
id: clientId,
|
|
40
|
-
projectId: String(project.id),
|
|
41
|
-
res
|
|
42
|
-
};
|
|
43
|
-
clients.push(newClient);
|
|
44
|
-
require_logger_index.logger.info(`New client connected to SSE. Total clients: ${clients.length ?? 0}`);
|
|
45
|
-
req.on("close", () => {
|
|
46
|
-
clients = clients.filter((client) => client.id !== clientId);
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
|
-
exports.listenChangeSSE = listenChangeSSE;
|
|
52
|
-
exports.sendDictionaryUpdate = sendDictionaryUpdate;
|
|
53
|
-
//# sourceMappingURL=eventListener.controller.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventListener.controller.cjs","names":["clients: Array<{ id: number; projectId: string; res: Response }>","data: MessageEventData[]"],"sources":["../../../src/controllers/eventListener.controller.ts"],"sourcesContent":["import { logger } from '@logger';\nimport { ErrorHandler } from '@utils/errors';\nimport type { Request, Response } from 'express';\nimport type { DictionaryAPI } from '@/types/dictionary.types';\n\nexport type Object = 'DICTIONARY';\nexport type Status = 'ADDED' | 'UPDATED' | 'DELETED' | 'CREATED';\n\nexport type MessageEventData = {\n object: Object;\n status: Status;\n data: any;\n};\n\nlet clients: Array<{ id: number; projectId: string; res: Response }> = [];\nconst MAX_SSE_CONNECTIONS = 10;\n\nexport type SendDictionaryUpdateArg = {\n dictionary: DictionaryAPI;\n status: 'ADDED' | 'UPDATED' | 'DELETED' | 'CREATED';\n};\n\nexport const sendDictionaryUpdate = (args: SendDictionaryUpdateArg[]) => {\n const projectIds = args.flatMap((arg) => arg.dictionary.projectIds);\n\n const filteredClients = clients.filter((client) =>\n projectIds.map((id) => String(id)).includes(String(client.projectId))\n );\n\n const data: MessageEventData[] = args.map((arg) => ({\n object: 'DICTIONARY',\n status: arg.status,\n data: arg.dictionary,\n }));\n\n process.nextTick(() => {\n for (const client of filteredClients) {\n client.res.write(`data: ${JSON.stringify(data)}\\n\\n`);\n client.res.flush?.(); // Ensure the data is sent immediately\n }\n });\n};\n\nexport type CheckDictionaryChangeSSEParams = { accessToken: string };\n\n/**\n * SSE to check the email verification status\n */\nexport const listenChangeSSE = async (\n req: Request<CheckDictionaryChangeSSEParams, any, any>,\n res: Response\n) => {\n const { project } = res.locals;\n\n if (clients.length >= MAX_SSE_CONNECTIONS) {\n ErrorHandler.handleGenericErrorResponse(res, 'TOO_MANY_CONNECTIONS');\n return;\n }\n\n // Set headers for SSE\n res.setHeader('Content-Type', 'text/event-stream;charset=utf-8');\n res.setHeader('Cache-Control', 'no-cache, no-transform');\n res.setHeader('Connection', 'keep-alive');\n res.setHeader('X-Accel-Buffering', 'no'); // For Nginx buffering\n\n // Send initial data to ensure the connection is open\n res.write(':\\n\\n'); // Comment to keep connection alive\n res.flushHeaders?.();\n\n const clientId = Date.now();\n\n // Add client to the list\n const newClient = {\n id: clientId,\n projectId: String(project.id),\n res,\n };\n clients.push(newClient);\n\n logger.info(\n `New client connected to SSE. Total clients: ${clients.length ?? 0}`\n );\n\n // Remove client on connection close\n req.on('close', () => {\n clients = clients.filter((client) => client.id !== clientId);\n });\n};\n"],"mappings":";;;;AAcA,IAAIA,UAAmE,EAAE;AACzE,MAAM,sBAAsB;AAO5B,MAAa,wBAAwB,SAAoC;CACvE,MAAM,aAAa,KAAK,SAAS,QAAQ,IAAI,WAAW,WAAW;CAEnE,MAAM,kBAAkB,QAAQ,QAAQ,WACtC,WAAW,KAAK,OAAO,OAAO,GAAG,CAAC,CAAC,SAAS,OAAO,OAAO,UAAU,CAAC,CACtE;CAED,MAAMC,OAA2B,KAAK,KAAK,SAAS;EAClD,QAAQ;EACR,QAAQ,IAAI;EACZ,MAAM,IAAI;EACX,EAAE;AAEH,SAAQ,eAAe;AACrB,OAAK,MAAM,UAAU,iBAAiB;AACpC,UAAO,IAAI,MAAM,SAAS,KAAK,UAAU,KAAK,CAAC,MAAM;AACrD,UAAO,IAAI,SAAS;;GAEtB;;;;;AAQJ,MAAa,kBAAkB,OAC7B,KACA,QACG;CACH,MAAM,EAAE,YAAY,IAAI;AAExB,KAAI,QAAQ,UAAU,qBAAqB;AACzC,iDAAa,2BAA2B,KAAK,uBAAuB;AACpE;;AAIF,KAAI,UAAU,gBAAgB,kCAAkC;AAChE,KAAI,UAAU,iBAAiB,yBAAyB;AACxD,KAAI,UAAU,cAAc,aAAa;AACzC,KAAI,UAAU,qBAAqB,KAAK;AAGxC,KAAI,MAAM,QAAQ;AAClB,KAAI,gBAAgB;CAEpB,MAAM,WAAW,KAAK,KAAK;CAG3B,MAAM,YAAY;EAChB,IAAI;EACJ,WAAW,OAAO,QAAQ,GAAG;EAC7B;EACD;AACD,SAAQ,KAAK,UAAU;AAEvB,6BAAO,KACL,+CAA+C,QAAQ,UAAU,IAClE;AAGD,KAAI,GAAG,eAAe;AACpB,YAAU,QAAQ,QAAQ,WAAW,OAAO,OAAO,SAAS;GAC5D"}
|