@intlayer/backend 3.5.4 → 3.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/controllers/ai.controller.cjs +238 -0
- package/dist/cjs/controllers/ai.controller.cjs.map +1 -0
- package/dist/cjs/controllers/dictionary.controller.cjs +50 -17
- package/dist/cjs/controllers/dictionary.controller.cjs.map +1 -1
- package/dist/cjs/controllers/project.controller.cjs +2 -6
- package/dist/cjs/controllers/project.controller.cjs.map +1 -1
- package/dist/cjs/controllers/tag.controller.cjs +235 -0
- package/dist/cjs/controllers/tag.controller.cjs.map +1 -0
- package/dist/cjs/controllers/user.controller.cjs +1 -0
- package/dist/cjs/controllers/user.controller.cjs.map +1 -1
- package/dist/cjs/export.cjs.map +1 -1
- package/dist/cjs/index.cjs +4 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/middlewares/request.middleware.cjs +4 -0
- package/dist/cjs/middlewares/request.middleware.cjs.map +1 -1
- package/dist/cjs/models/tag.model.cjs +31 -0
- package/dist/cjs/models/tag.model.cjs.map +1 -0
- package/dist/cjs/routes/ai.routes.cjs +69 -0
- package/dist/cjs/routes/ai.routes.cjs.map +1 -0
- package/dist/cjs/routes/dictionary.routes.cjs +4 -4
- package/dist/cjs/routes/dictionary.routes.cjs.map +1 -1
- package/dist/cjs/routes/tags.routes.cjs +60 -0
- package/dist/cjs/routes/tags.routes.cjs.map +1 -0
- package/dist/cjs/schemas/dictionary.schema.cjs +31 -6
- package/dist/cjs/schemas/dictionary.schema.cjs.map +1 -1
- package/dist/cjs/schemas/project.schema.cjs +5 -0
- package/dist/cjs/schemas/project.schema.cjs.map +1 -1
- package/dist/cjs/schemas/tag.schema.cjs +64 -0
- package/dist/cjs/schemas/tag.schema.cjs.map +1 -0
- package/dist/cjs/services/dictionary.service.cjs +139 -27
- package/dist/cjs/services/dictionary.service.cjs.map +1 -1
- package/dist/cjs/services/project.service.cjs +14 -5
- package/dist/cjs/services/project.service.cjs.map +1 -1
- package/dist/cjs/services/tag.service.cjs +91 -0
- package/dist/cjs/services/tag.service.cjs.map +1 -0
- package/dist/cjs/types/dictionary.types.cjs.map +1 -1
- package/dist/cjs/types/project.types.cjs.map +1 -1
- package/dist/cjs/types/tag.types.cjs +17 -0
- package/dist/cjs/types/tag.types.cjs.map +1 -0
- package/dist/cjs/utils/auditDictionary/CJS_FORMAT.md +23 -0
- package/dist/cjs/utils/auditDictionary/JSON_FORMAT.md +26 -0
- package/dist/cjs/utils/auditDictionary/JSX_FORMAT.md +28 -0
- package/dist/cjs/utils/auditDictionary/MJS_FORMAT.md +23 -0
- package/dist/cjs/utils/auditDictionary/PROMPT.md +151 -0
- package/dist/cjs/utils/auditDictionary/TSX_FORMAT.md +28 -0
- package/dist/cjs/utils/auditDictionary/TS_FORMAT.md +22 -0
- package/dist/cjs/utils/auditDictionary/index.cjs +98 -0
- package/dist/cjs/utils/auditDictionary/index.cjs.map +1 -0
- package/dist/cjs/utils/auditDictionaryField/PROMPT.md +115 -0
- package/dist/cjs/utils/auditDictionaryField/index.cjs +81 -0
- package/dist/cjs/utils/auditDictionaryField/index.cjs.map +1 -0
- package/dist/cjs/utils/auditDictionaryMetadata/PROMPT.md +76 -0
- package/dist/cjs/utils/auditDictionaryMetadata/index.cjs +78 -0
- package/dist/cjs/utils/auditDictionaryMetadata/index.cjs.map +1 -0
- package/dist/cjs/utils/auditTag/PROMPT.md +34 -0
- package/dist/cjs/utils/auditTag/index.cjs +74 -0
- package/dist/cjs/utils/auditTag/index.cjs.map +1 -0
- package/dist/cjs/utils/ensureArrayQueryFilter.cjs +39 -0
- package/dist/cjs/utils/ensureArrayQueryFilter.cjs.map +1 -0
- package/dist/cjs/utils/ensureMongoDocumentToObject.cjs +35 -0
- package/dist/cjs/utils/ensureMongoDocumentToObject.cjs.map +1 -0
- package/dist/cjs/utils/errors/ErrorHandler.cjs +1 -1
- package/dist/cjs/utils/errors/ErrorHandler.cjs.map +1 -1
- package/dist/cjs/utils/errors/errorCodes.cjs +104 -0
- package/dist/cjs/utils/errors/errorCodes.cjs.map +1 -1
- package/dist/cjs/utils/filtersAndPagination/getDictionaryFiltersAndPagination.cjs +10 -11
- package/dist/cjs/utils/filtersAndPagination/getDictionaryFiltersAndPagination.cjs.map +1 -1
- package/dist/cjs/utils/filtersAndPagination/getOrganizationFiltersAndPagination.cjs +6 -10
- package/dist/cjs/utils/filtersAndPagination/getOrganizationFiltersAndPagination.cjs.map +1 -1
- package/dist/cjs/utils/filtersAndPagination/getProjectFiltersAndPagination.cjs +6 -10
- package/dist/cjs/utils/filtersAndPagination/getProjectFiltersAndPagination.cjs.map +1 -1
- package/dist/cjs/utils/filtersAndPagination/getTagFiltersAndPagination.cjs +51 -0
- package/dist/cjs/utils/filtersAndPagination/getTagFiltersAndPagination.cjs.map +1 -0
- package/dist/cjs/utils/filtersAndPagination/getUserFiltersAndPagination.cjs +2 -9
- package/dist/cjs/utils/filtersAndPagination/getUserFiltersAndPagination.cjs.map +1 -1
- package/dist/cjs/utils/mapper/dictionary.cjs +8 -4
- package/dist/cjs/utils/mapper/dictionary.cjs.map +1 -1
- package/dist/cjs/utils/mapper/organization.cjs +2 -4
- package/dist/cjs/utils/mapper/organization.cjs.map +1 -1
- package/dist/cjs/utils/mapper/project.cjs +2 -4
- package/dist/cjs/utils/mapper/project.cjs.map +1 -1
- package/dist/cjs/utils/mapper/tag.cjs +37 -0
- package/dist/cjs/utils/mapper/tag.cjs.map +1 -0
- package/dist/cjs/utils/mapper/user.cjs +2 -4
- package/dist/cjs/utils/mapper/user.cjs.map +1 -1
- package/dist/cjs/utils/removeObjectKeys.cjs +35 -0
- package/dist/cjs/utils/removeObjectKeys.cjs.map +1 -0
- package/dist/cjs/utils/validation/validateProject.cjs +17 -10
- package/dist/cjs/utils/validation/validateProject.cjs.map +1 -1
- package/dist/cjs/utils/validation/validateTag.cjs +93 -0
- package/dist/cjs/utils/validation/validateTag.cjs.map +1 -0
- package/dist/esm/controllers/ai.controller.mjs +201 -0
- package/dist/esm/controllers/ai.controller.mjs.map +1 -0
- package/dist/esm/controllers/dictionary.controller.mjs +50 -17
- package/dist/esm/controllers/dictionary.controller.mjs.map +1 -1
- package/dist/esm/controllers/project.controller.mjs +2 -6
- package/dist/esm/controllers/project.controller.mjs.map +1 -1
- package/dist/esm/controllers/tag.controller.mjs +203 -0
- package/dist/esm/controllers/tag.controller.mjs.map +1 -0
- package/dist/esm/controllers/user.controller.mjs +1 -0
- package/dist/esm/controllers/user.controller.mjs.map +1 -1
- package/dist/esm/export.mjs.map +1 -1
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/middlewares/request.middleware.mjs +4 -0
- package/dist/esm/middlewares/request.middleware.mjs.map +1 -1
- package/dist/esm/models/tag.model.mjs +7 -0
- package/dist/esm/models/tag.model.mjs.map +1 -0
- package/dist/esm/routes/ai.routes.mjs +49 -0
- package/dist/esm/routes/ai.routes.mjs.map +1 -0
- package/dist/esm/routes/dictionary.routes.mjs +4 -4
- package/dist/esm/routes/dictionary.routes.mjs.map +1 -1
- package/dist/esm/routes/tags.routes.mjs +40 -0
- package/dist/esm/routes/tags.routes.mjs.map +1 -0
- package/dist/esm/schemas/dictionary.schema.mjs +31 -6
- package/dist/esm/schemas/dictionary.schema.mjs.map +1 -1
- package/dist/esm/schemas/project.schema.mjs +5 -0
- package/dist/esm/schemas/project.schema.mjs.map +1 -1
- package/dist/esm/schemas/tag.schema.mjs +45 -0
- package/dist/esm/schemas/tag.schema.mjs.map +1 -0
- package/dist/esm/services/dictionary.service.mjs +137 -27
- package/dist/esm/services/dictionary.service.mjs.map +1 -1
- package/dist/esm/services/project.service.mjs +14 -5
- package/dist/esm/services/project.service.mjs.map +1 -1
- package/dist/esm/services/tag.service.mjs +61 -0
- package/dist/esm/services/tag.service.mjs.map +1 -0
- package/dist/esm/types/tag.types.mjs +1 -0
- package/dist/esm/types/tag.types.mjs.map +1 -0
- package/dist/esm/utils/auditDictionary/CJS_FORMAT.md +23 -0
- package/dist/esm/utils/auditDictionary/JSON_FORMAT.md +26 -0
- package/dist/esm/utils/auditDictionary/JSX_FORMAT.md +28 -0
- package/dist/esm/utils/auditDictionary/MJS_FORMAT.md +23 -0
- package/dist/esm/utils/auditDictionary/PROMPT.md +151 -0
- package/dist/esm/utils/auditDictionary/TSX_FORMAT.md +28 -0
- package/dist/esm/utils/auditDictionary/TS_FORMAT.md +22 -0
- package/dist/esm/utils/auditDictionary/index.mjs +73 -0
- package/dist/esm/utils/auditDictionary/index.mjs.map +1 -0
- package/dist/esm/utils/auditDictionaryField/PROMPT.md +115 -0
- package/dist/esm/utils/auditDictionaryField/index.mjs +56 -0
- package/dist/esm/utils/auditDictionaryField/index.mjs.map +1 -0
- package/dist/esm/utils/auditDictionaryMetadata/PROMPT.md +76 -0
- package/dist/esm/utils/auditDictionaryMetadata/index.mjs +53 -0
- package/dist/esm/utils/auditDictionaryMetadata/index.mjs.map +1 -0
- package/dist/esm/utils/auditTag/PROMPT.md +34 -0
- package/dist/esm/utils/auditTag/index.mjs +49 -0
- package/dist/esm/utils/auditTag/index.mjs.map +1 -0
- package/dist/esm/utils/ensureArrayQueryFilter.mjs +15 -0
- package/dist/esm/utils/ensureArrayQueryFilter.mjs.map +1 -0
- package/dist/esm/utils/ensureMongoDocumentToObject.mjs +11 -0
- package/dist/esm/utils/ensureMongoDocumentToObject.mjs.map +1 -0
- package/dist/esm/utils/errors/ErrorHandler.mjs +1 -1
- package/dist/esm/utils/errors/ErrorHandler.mjs.map +1 -1
- package/dist/esm/utils/errors/errorCodes.mjs +104 -0
- package/dist/esm/utils/errors/errorCodes.mjs.map +1 -1
- package/dist/esm/utils/filtersAndPagination/getDictionaryFiltersAndPagination.mjs +10 -11
- package/dist/esm/utils/filtersAndPagination/getDictionaryFiltersAndPagination.mjs.map +1 -1
- package/dist/esm/utils/filtersAndPagination/getOrganizationFiltersAndPagination.mjs +6 -10
- package/dist/esm/utils/filtersAndPagination/getOrganizationFiltersAndPagination.mjs.map +1 -1
- package/dist/esm/utils/filtersAndPagination/getProjectFiltersAndPagination.mjs +6 -10
- package/dist/esm/utils/filtersAndPagination/getProjectFiltersAndPagination.mjs.map +1 -1
- package/dist/esm/utils/filtersAndPagination/getTagFiltersAndPagination.mjs +29 -0
- package/dist/esm/utils/filtersAndPagination/getTagFiltersAndPagination.mjs.map +1 -0
- package/dist/esm/utils/filtersAndPagination/getUserFiltersAndPagination.mjs +2 -9
- package/dist/esm/utils/filtersAndPagination/getUserFiltersAndPagination.mjs.map +1 -1
- package/dist/esm/utils/mapper/dictionary.mjs +8 -4
- package/dist/esm/utils/mapper/dictionary.mjs.map +1 -1
- package/dist/esm/utils/mapper/organization.mjs +2 -4
- package/dist/esm/utils/mapper/organization.mjs.map +1 -1
- package/dist/esm/utils/mapper/project.mjs +2 -4
- package/dist/esm/utils/mapper/project.mjs.map +1 -1
- package/dist/esm/utils/mapper/tag.mjs +12 -0
- package/dist/esm/utils/mapper/tag.mjs.map +1 -0
- package/dist/esm/utils/mapper/user.mjs +2 -4
- package/dist/esm/utils/mapper/user.mjs.map +1 -1
- package/dist/esm/utils/removeObjectKeys.mjs +11 -0
- package/dist/esm/utils/removeObjectKeys.mjs.map +1 -0
- package/dist/esm/utils/validation/validateProject.mjs +17 -10
- package/dist/esm/utils/validation/validateProject.mjs.map +1 -1
- package/dist/esm/utils/validation/validateTag.mjs +65 -0
- package/dist/esm/utils/validation/validateTag.mjs.map +1 -0
- package/dist/types/controllers/ai.controller.d.ts +61 -0
- package/dist/types/controllers/ai.controller.d.ts.map +1 -0
- package/dist/types/controllers/dictionary.controller.d.ts +6 -3
- package/dist/types/controllers/dictionary.controller.d.ts.map +1 -1
- package/dist/types/controllers/project.controller.d.ts +2 -4
- package/dist/types/controllers/project.controller.d.ts.map +1 -1
- package/dist/types/controllers/tag.controller.d.ts +39 -0
- package/dist/types/controllers/tag.controller.d.ts.map +1 -0
- package/dist/types/controllers/user.controller.d.ts.map +1 -1
- package/dist/types/export.d.ts +3 -0
- package/dist/types/export.d.ts.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/models/dictionary.model.d.ts +1 -0
- package/dist/types/models/dictionary.model.d.ts.map +1 -1
- package/dist/types/models/tag.model.d.ts +3 -0
- package/dist/types/models/tag.model.d.ts.map +1 -0
- package/dist/types/routes/ai.routes.d.ts +25 -0
- package/dist/types/routes/ai.routes.d.ts.map +1 -0
- package/dist/types/routes/dictionary.routes.d.ts +6 -2
- package/dist/types/routes/dictionary.routes.d.ts.map +1 -1
- package/dist/types/routes/tags.routes.d.ts +29 -0
- package/dist/types/routes/tags.routes.d.ts.map +1 -0
- package/dist/types/schemas/dictionary.schema.d.ts +1 -0
- package/dist/types/schemas/dictionary.schema.d.ts.map +1 -1
- package/dist/types/schemas/project.schema.d.ts.map +1 -1
- package/dist/types/schemas/tag.schema.d.ts +16 -0
- package/dist/types/schemas/tag.schema.d.ts.map +1 -0
- package/dist/types/services/dictionary.service.d.ts +10 -2
- package/dist/types/services/dictionary.service.d.ts.map +1 -1
- package/dist/types/services/project.service.d.ts.map +1 -1
- package/dist/types/services/tag.service.d.ts +45 -0
- package/dist/types/services/tag.service.d.ts.map +1 -0
- package/dist/types/types/dictionary.types.d.ts +14 -4
- package/dist/types/types/dictionary.types.d.ts.map +1 -1
- package/dist/types/types/project.types.d.ts +3 -0
- package/dist/types/types/project.types.d.ts.map +1 -1
- package/dist/types/types/tag.types.d.ts +26 -0
- package/dist/types/types/tag.types.d.ts.map +1 -0
- package/dist/types/utils/audit/index.d.ts +28 -0
- package/dist/types/utils/audit/index.d.ts.map +1 -0
- package/dist/types/utils/auditDictionary/index.d.ts +24 -0
- package/dist/types/utils/auditDictionary/index.d.ts.map +1 -0
- package/dist/types/utils/auditDictionaryField/index.d.ts +24 -0
- package/dist/types/utils/auditDictionaryField/index.d.ts.map +1 -0
- package/dist/types/utils/auditDictionaryMetadata/index.d.ts +21 -0
- package/dist/types/utils/auditDictionaryMetadata/index.d.ts.map +1 -0
- package/dist/types/utils/auditTag/index.d.ts +27 -0
- package/dist/types/utils/auditTag/index.d.ts.map +1 -0
- package/dist/types/utils/ensureArrayQueryFilter.d.ts +2 -0
- package/dist/types/utils/ensureArrayQueryFilter.d.ts.map +1 -0
- package/dist/types/utils/ensureMongoDocumentToObject.d.ts +8 -0
- package/dist/types/utils/ensureMongoDocumentToObject.d.ts.map +1 -0
- package/dist/types/utils/errors/ErrorHandler.d.ts.map +1 -1
- package/dist/types/utils/errors/errorCodes.d.ts +104 -0
- package/dist/types/utils/errors/errorCodes.d.ts.map +1 -1
- package/dist/types/utils/filtersAndPagination/getDictionaryFiltersAndPagination.d.ts +2 -0
- package/dist/types/utils/filtersAndPagination/getDictionaryFiltersAndPagination.d.ts.map +1 -1
- package/dist/types/utils/filtersAndPagination/getOrganizationFiltersAndPagination.d.ts.map +1 -1
- package/dist/types/utils/filtersAndPagination/getProjectFiltersAndPagination.d.ts.map +1 -1
- package/dist/types/utils/filtersAndPagination/getTagFiltersAndPagination.d.ts +24 -0
- package/dist/types/utils/filtersAndPagination/getTagFiltersAndPagination.d.ts.map +1 -0
- package/dist/types/utils/filtersAndPagination/getUserFiltersAndPagination.d.ts.map +1 -1
- package/dist/types/utils/mapper/dictionary.d.ts +1 -1
- package/dist/types/utils/mapper/dictionary.d.ts.map +1 -1
- package/dist/types/utils/mapper/organization.d.ts.map +1 -1
- package/dist/types/utils/mapper/project.d.ts.map +1 -1
- package/dist/types/utils/mapper/tag.d.ts +16 -0
- package/dist/types/utils/mapper/tag.d.ts.map +1 -0
- package/dist/types/utils/mapper/user.d.ts +2 -2
- package/dist/types/utils/mapper/user.d.ts.map +1 -1
- package/dist/types/utils/removeObjectKeys.d.ts +2 -0
- package/dist/types/utils/removeObjectKeys.d.ts.map +1 -0
- package/dist/types/utils/validation/validateProject.d.ts.map +1 -1
- package/dist/types/utils/validation/validateTag.d.ts +16 -0
- package/dist/types/utils/validation/validateTag.d.ts.map +1 -0
- package/package.json +6 -5
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var ai_routes_exports = {};
|
|
20
|
+
__export(ai_routes_exports, {
|
|
21
|
+
aiRouter: () => aiRouter,
|
|
22
|
+
aiRoutes: () => aiRoutes
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(ai_routes_exports);
|
|
25
|
+
var import_ai = require('./../controllers/ai.controller.cjs');
|
|
26
|
+
var import_express = require("express");
|
|
27
|
+
const aiRouter = (0, import_express.Router)();
|
|
28
|
+
const baseURL = `${process.env.BACKEND_URL}/api/ai`;
|
|
29
|
+
const aiRoutes = {
|
|
30
|
+
auditContentDeclaration: {
|
|
31
|
+
urlModel: "/audit/content-declaration",
|
|
32
|
+
url: `${baseURL}/audit/content-declaration`,
|
|
33
|
+
method: "POST"
|
|
34
|
+
},
|
|
35
|
+
auditContentDeclarationField: {
|
|
36
|
+
urlModel: "/audit/content-declaration/field",
|
|
37
|
+
url: `${baseURL}/audit/content-declaration/field`,
|
|
38
|
+
method: "POST"
|
|
39
|
+
},
|
|
40
|
+
auditContentDeclarationMetadata: {
|
|
41
|
+
urlModel: "/audit/content-declaration/metadata",
|
|
42
|
+
url: `${baseURL}/audit/content-declaration/metadata`,
|
|
43
|
+
method: "POST"
|
|
44
|
+
},
|
|
45
|
+
auditTag: {
|
|
46
|
+
urlModel: "/audit/tag",
|
|
47
|
+
url: `${baseURL}/audit/tag`,
|
|
48
|
+
method: "POST"
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
aiRouter.post(
|
|
52
|
+
aiRoutes.auditContentDeclaration.urlModel,
|
|
53
|
+
import_ai.auditContentDeclaration
|
|
54
|
+
);
|
|
55
|
+
aiRouter.post(
|
|
56
|
+
aiRoutes.auditContentDeclarationField.urlModel,
|
|
57
|
+
import_ai.auditContentDeclarationField
|
|
58
|
+
);
|
|
59
|
+
aiRouter.post(
|
|
60
|
+
aiRoutes.auditContentDeclarationMetadata.urlModel,
|
|
61
|
+
import_ai.auditContentDeclarationMetadata
|
|
62
|
+
);
|
|
63
|
+
aiRouter.post(aiRoutes.auditTag.urlModel, import_ai.auditTag);
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
aiRouter,
|
|
67
|
+
aiRoutes
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=ai.routes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/routes/ai.routes.ts"],"sourcesContent":["import {\n auditContentDeclaration,\n auditContentDeclarationField,\n auditContentDeclarationMetadata,\n auditTag,\n} from '@controllers/ai.controller';\nimport { Router } from 'express';\nimport { Routes } from '@/types/Routes';\n\nexport const aiRouter: Router = Router();\n\nconst baseURL = `${process.env.BACKEND_URL}/api/ai`;\n\nexport const aiRoutes = {\n auditContentDeclaration: {\n urlModel: '/audit/content-declaration',\n url: `${baseURL}/audit/content-declaration`,\n method: 'POST',\n },\n auditContentDeclarationField: {\n urlModel: '/audit/content-declaration/field',\n url: `${baseURL}/audit/content-declaration/field`,\n method: 'POST',\n },\n auditContentDeclarationMetadata: {\n urlModel: '/audit/content-declaration/metadata',\n url: `${baseURL}/audit/content-declaration/metadata`,\n method: 'POST',\n },\n auditTag: {\n urlModel: '/audit/tag',\n url: `${baseURL}/audit/tag`,\n method: 'POST',\n },\n} satisfies Routes;\n\naiRouter.post(\n aiRoutes.auditContentDeclaration.urlModel,\n auditContentDeclaration\n);\naiRouter.post(\n aiRoutes.auditContentDeclarationField.urlModel,\n auditContentDeclarationField\n);\naiRouter.post(\n aiRoutes.auditContentDeclarationMetadata.urlModel,\n auditContentDeclarationMetadata\n);\n\naiRouter.post(aiRoutes.auditTag.urlModel, auditTag);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAKO;AACP,qBAAuB;AAGhB,MAAM,eAAmB,uBAAO;AAEvC,MAAM,UAAU,GAAG,QAAQ,IAAI,WAAW;AAEnC,MAAM,WAAW;AAAA,EACtB,yBAAyB;AAAA,IACvB,UAAU;AAAA,IACV,KAAK,GAAG,OAAO;AAAA,IACf,QAAQ;AAAA,EACV;AAAA,EACA,8BAA8B;AAAA,IAC5B,UAAU;AAAA,IACV,KAAK,GAAG,OAAO;AAAA,IACf,QAAQ;AAAA,EACV;AAAA,EACA,iCAAiC;AAAA,IAC/B,UAAU;AAAA,IACV,KAAK,GAAG,OAAO;AAAA,IACf,QAAQ;AAAA,EACV;AAAA,EACA,UAAU;AAAA,IACR,UAAU;AAAA,IACV,KAAK,GAAG,OAAO;AAAA,IACf,QAAQ;AAAA,EACV;AACF;AAEA,SAAS;AAAA,EACP,SAAS,wBAAwB;AAAA,EACjC;AACF;AACA,SAAS;AAAA,EACP,SAAS,6BAA6B;AAAA,EACtC;AACF;AACA,SAAS;AAAA,EACP,SAAS,gCAAgC;AAAA,EACzC;AACF;AAEA,SAAS,KAAK,SAAS,SAAS,UAAU,kBAAQ;","names":[]}
|
|
@@ -53,13 +53,13 @@ const dictionaryRoutes = {
|
|
|
53
53
|
method: "PATCH"
|
|
54
54
|
},
|
|
55
55
|
updateDictionary: {
|
|
56
|
-
urlModel: "
|
|
57
|
-
url: baseURL
|
|
56
|
+
urlModel: "/:dictionaryId",
|
|
57
|
+
url: ({ dictionaryId }) => `${baseURL}/${dictionaryId}`,
|
|
58
58
|
method: "PUT"
|
|
59
59
|
},
|
|
60
60
|
deleteDictionary: {
|
|
61
|
-
urlModel: "
|
|
62
|
-
url: baseURL
|
|
61
|
+
urlModel: "/:dictionaryId",
|
|
62
|
+
url: ({ dictionaryId }) => `${baseURL}/${dictionaryId}`,
|
|
63
63
|
method: "DELETE"
|
|
64
64
|
}
|
|
65
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/routes/dictionary.routes.ts"],"sourcesContent":["import {\n pushDictionaries,\n addDictionary,\n deleteDictionary,\n getDictionaries,\n updateDictionary,\n getDictionaryByKey,\n getDictionariesKeys,\n} from '@controllers/dictionary.controller';\nimport { Router } from 'express';\nimport { Routes } from '@/types/Routes';\n\nexport const dictionaryRouter: Router = Router();\n\nconst baseURL = `${process.env.BACKEND_URL}/api/dictionary`;\n\nexport const dictionaryRoutes = {\n getDictionaries: {\n urlModel: '/',\n url: baseURL,\n method: 'GET',\n },\n getDictionariesKeys: {\n urlModel: '/keys',\n url: `${baseURL}/keys`,\n method: 'GET',\n },\n getDictionary: {\n urlModel: '/:dictionaryKey',\n url: ({ dictionaryKey }: { dictionaryKey: string }) =>\n `${baseURL}/${dictionaryKey}`,\n method: 'GET',\n },\n addDictionary: {\n urlModel: '/',\n url: baseURL,\n method: 'POST',\n },\n pushDictionaries: {\n urlModel: '/',\n url: baseURL,\n method: 'PATCH',\n },\n updateDictionary: {\n urlModel: '
|
|
1
|
+
{"version":3,"sources":["../../../src/routes/dictionary.routes.ts"],"sourcesContent":["import {\n pushDictionaries,\n addDictionary,\n deleteDictionary,\n getDictionaries,\n updateDictionary,\n getDictionaryByKey,\n getDictionariesKeys,\n} from '@controllers/dictionary.controller';\nimport { Router } from 'express';\nimport { Routes } from '@/types/Routes';\n\nexport const dictionaryRouter: Router = Router();\n\nconst baseURL = `${process.env.BACKEND_URL}/api/dictionary`;\n\nexport const dictionaryRoutes = {\n getDictionaries: {\n urlModel: '/',\n url: baseURL,\n method: 'GET',\n },\n getDictionariesKeys: {\n urlModel: '/keys',\n url: `${baseURL}/keys`,\n method: 'GET',\n },\n getDictionary: {\n urlModel: '/:dictionaryKey',\n url: ({ dictionaryKey }: { dictionaryKey: string }) =>\n `${baseURL}/${dictionaryKey}`,\n method: 'GET',\n },\n addDictionary: {\n urlModel: '/',\n url: baseURL,\n method: 'POST',\n },\n pushDictionaries: {\n urlModel: '/',\n url: baseURL,\n method: 'PATCH',\n },\n updateDictionary: {\n urlModel: '/:dictionaryId',\n url: ({ dictionaryId }: { dictionaryId: string }) =>\n `${baseURL}/${dictionaryId}`,\n method: 'PUT',\n },\n deleteDictionary: {\n urlModel: '/:dictionaryId',\n url: ({ dictionaryId }: { dictionaryId: string }) =>\n `${baseURL}/${dictionaryId}`,\n method: 'DELETE',\n },\n} satisfies Routes;\n\ndictionaryRouter.get(\n dictionaryRoutes.getDictionaries.urlModel,\n getDictionaries\n);\n\ndictionaryRouter.get(\n dictionaryRoutes.getDictionariesKeys.urlModel,\n getDictionariesKeys\n);\n\ndictionaryRouter.get(\n dictionaryRoutes.getDictionary.urlModel,\n getDictionaryByKey\n);\n\ndictionaryRouter.post(dictionaryRoutes.addDictionary.urlModel, addDictionary);\ndictionaryRouter.patch(\n dictionaryRoutes.pushDictionaries.urlModel,\n pushDictionaries\n);\ndictionaryRouter.put(\n dictionaryRoutes.updateDictionary.urlModel,\n updateDictionary\n);\ndictionaryRouter.delete(\n dictionaryRoutes.deleteDictionary.urlModel,\n deleteDictionary\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAQO;AACP,qBAAuB;AAGhB,MAAM,uBAA2B,uBAAO;AAE/C,MAAM,UAAU,GAAG,QAAQ,IAAI,WAAW;AAEnC,MAAM,mBAAmB;AAAA,EAC9B,iBAAiB;AAAA,IACf,UAAU;AAAA,IACV,KAAK;AAAA,IACL,QAAQ;AAAA,EACV;AAAA,EACA,qBAAqB;AAAA,IACnB,UAAU;AAAA,IACV,KAAK,GAAG,OAAO;AAAA,IACf,QAAQ;AAAA,EACV;AAAA,EACA,eAAe;AAAA,IACb,UAAU;AAAA,IACV,KAAK,CAAC,EAAE,cAAc,MACpB,GAAG,OAAO,IAAI,aAAa;AAAA,IAC7B,QAAQ;AAAA,EACV;AAAA,EACA,eAAe;AAAA,IACb,UAAU;AAAA,IACV,KAAK;AAAA,IACL,QAAQ;AAAA,EACV;AAAA,EACA,kBAAkB;AAAA,IAChB,UAAU;AAAA,IACV,KAAK;AAAA,IACL,QAAQ;AAAA,EACV;AAAA,EACA,kBAAkB;AAAA,IAChB,UAAU;AAAA,IACV,KAAK,CAAC,EAAE,aAAa,MACnB,GAAG,OAAO,IAAI,YAAY;AAAA,IAC5B,QAAQ;AAAA,EACV;AAAA,EACA,kBAAkB;AAAA,IAChB,UAAU;AAAA,IACV,KAAK,CAAC,EAAE,aAAa,MACnB,GAAG,OAAO,IAAI,YAAY;AAAA,IAC5B,QAAQ;AAAA,EACV;AACF;AAEA,iBAAiB;AAAA,EACf,iBAAiB,gBAAgB;AAAA,EACjC;AACF;AAEA,iBAAiB;AAAA,EACf,iBAAiB,oBAAoB;AAAA,EACrC;AACF;AAEA,iBAAiB;AAAA,EACf,iBAAiB,cAAc;AAAA,EAC/B;AACF;AAEA,iBAAiB,KAAK,iBAAiB,cAAc,UAAU,+BAAa;AAC5E,iBAAiB;AAAA,EACf,iBAAiB,iBAAiB;AAAA,EAClC;AACF;AACA,iBAAiB;AAAA,EACf,iBAAiB,iBAAiB;AAAA,EAClC;AACF;AACA,iBAAiB;AAAA,EACf,iBAAiB,iBAAiB;AAAA,EAClC;AACF;","names":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var tags_routes_exports = {};
|
|
20
|
+
__export(tags_routes_exports, {
|
|
21
|
+
tagRouter: () => tagRouter,
|
|
22
|
+
tagRoutes: () => tagRoutes
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(tags_routes_exports);
|
|
25
|
+
var import_tag = require('./../controllers/tag.controller.cjs');
|
|
26
|
+
var import_express = require("express");
|
|
27
|
+
const tagRouter = (0, import_express.Router)();
|
|
28
|
+
const baseURL = `${process.env.BACKEND_URL}/api/tag`;
|
|
29
|
+
const tagRoutes = {
|
|
30
|
+
getTags: {
|
|
31
|
+
urlModel: "/",
|
|
32
|
+
url: baseURL,
|
|
33
|
+
method: "GET"
|
|
34
|
+
},
|
|
35
|
+
addTag: {
|
|
36
|
+
urlModel: "/",
|
|
37
|
+
url: baseURL,
|
|
38
|
+
method: "POST"
|
|
39
|
+
},
|
|
40
|
+
updateTag: {
|
|
41
|
+
urlModel: "/:tagId",
|
|
42
|
+
url: ({ tagId }) => `${baseURL}/${tagId}`,
|
|
43
|
+
method: "PUT"
|
|
44
|
+
},
|
|
45
|
+
deleteTag: {
|
|
46
|
+
urlModel: "/:tagId",
|
|
47
|
+
url: ({ tagId }) => `${baseURL}/${tagId}`,
|
|
48
|
+
method: "DELETE"
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
tagRouter.get(tagRoutes.getTags.urlModel, import_tag.getTags);
|
|
52
|
+
tagRouter.post(tagRoutes.addTag.urlModel, import_tag.addTag);
|
|
53
|
+
tagRouter.put(tagRoutes.updateTag.urlModel, import_tag.updateTag);
|
|
54
|
+
tagRouter.delete(tagRoutes.deleteTag.urlModel, import_tag.deleteTag);
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
tagRouter,
|
|
58
|
+
tagRoutes
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=tags.routes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/routes/tags.routes.ts"],"sourcesContent":["import {\n addTag,\n deleteTag,\n getTags,\n updateTag,\n} from '@controllers/tag.controller';\nimport { Router } from 'express';\nimport { Routes } from '@/types/Routes';\n\nexport const tagRouter: Router = Router();\n\nconst baseURL = `${process.env.BACKEND_URL}/api/tag`;\n\nexport const tagRoutes = {\n getTags: {\n urlModel: '/',\n url: baseURL,\n method: 'GET',\n },\n addTag: {\n urlModel: '/',\n url: baseURL,\n method: 'POST',\n },\n updateTag: {\n urlModel: '/:tagId',\n url: ({ tagId }: { tagId: string }) => `${baseURL}/${tagId}`,\n method: 'PUT',\n },\n deleteTag: {\n urlModel: '/:tagId',\n url: ({ tagId }: { tagId: string }) => `${baseURL}/${tagId}`,\n method: 'DELETE',\n },\n} satisfies Routes;\n\ntagRouter.get(tagRoutes.getTags.urlModel, getTags);\n\ntagRouter.post(tagRoutes.addTag.urlModel, addTag);\ntagRouter.put(tagRoutes.updateTag.urlModel, updateTag);\ntagRouter.delete(tagRoutes.deleteTag.urlModel, deleteTag);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAKO;AACP,qBAAuB;AAGhB,MAAM,gBAAoB,uBAAO;AAExC,MAAM,UAAU,GAAG,QAAQ,IAAI,WAAW;AAEnC,MAAM,YAAY;AAAA,EACvB,SAAS;AAAA,IACP,UAAU;AAAA,IACV,KAAK;AAAA,IACL,QAAQ;AAAA,EACV;AAAA,EACA,QAAQ;AAAA,IACN,UAAU;AAAA,IACV,KAAK;AAAA,IACL,QAAQ;AAAA,EACV;AAAA,EACA,WAAW;AAAA,IACT,UAAU;AAAA,IACV,KAAK,CAAC,EAAE,MAAM,MAAyB,GAAG,OAAO,IAAI,KAAK;AAAA,IAC1D,QAAQ;AAAA,EACV;AAAA,EACA,WAAW;AAAA,IACT,UAAU;AAAA,IACV,KAAK,CAAC,EAAE,MAAM,MAAyB,GAAG,OAAO,IAAI,KAAK;AAAA,IAC1D,QAAQ;AAAA,EACV;AACF;AAEA,UAAU,IAAI,UAAU,QAAQ,UAAU,kBAAO;AAEjD,UAAU,KAAK,UAAU,OAAO,UAAU,iBAAM;AAChD,UAAU,IAAI,UAAU,UAAU,UAAU,oBAAS;AACrD,UAAU,OAAO,UAAU,UAAU,UAAU,oBAAS;","names":[]}
|
|
@@ -22,6 +22,23 @@ __export(dictionary_schema_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(dictionary_schema_exports);
|
|
24
24
|
var import_mongoose = require("mongoose");
|
|
25
|
+
const versionedContentElSchema = new import_mongoose.Schema(
|
|
26
|
+
{
|
|
27
|
+
name: {
|
|
28
|
+
type: String
|
|
29
|
+
},
|
|
30
|
+
description: {
|
|
31
|
+
type: String
|
|
32
|
+
},
|
|
33
|
+
content: {
|
|
34
|
+
type: import_mongoose.Schema.Types.Mixed,
|
|
35
|
+
required: true
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
timestamps: true
|
|
40
|
+
}
|
|
41
|
+
);
|
|
25
42
|
const dictionarySchema = new import_mongoose.Schema(
|
|
26
43
|
{
|
|
27
44
|
projectIds: {
|
|
@@ -41,13 +58,15 @@ const dictionarySchema = new import_mongoose.Schema(
|
|
|
41
58
|
type: String,
|
|
42
59
|
default: ""
|
|
43
60
|
},
|
|
44
|
-
|
|
45
|
-
type:
|
|
46
|
-
default:
|
|
61
|
+
tags: {
|
|
62
|
+
type: [String],
|
|
63
|
+
default: []
|
|
47
64
|
},
|
|
48
65
|
content: {
|
|
49
|
-
type:
|
|
50
|
-
|
|
66
|
+
type: Map,
|
|
67
|
+
of: versionedContentElSchema,
|
|
68
|
+
required: true,
|
|
69
|
+
default: null
|
|
51
70
|
},
|
|
52
71
|
creatorId: {
|
|
53
72
|
type: import_mongoose.Schema.Types.ObjectId,
|
|
@@ -55,7 +74,13 @@ const dictionarySchema = new import_mongoose.Schema(
|
|
|
55
74
|
required: true
|
|
56
75
|
},
|
|
57
76
|
filePath: {
|
|
58
|
-
type:
|
|
77
|
+
type: Map,
|
|
78
|
+
of: String,
|
|
79
|
+
default: null
|
|
80
|
+
},
|
|
81
|
+
publishedVersion: {
|
|
82
|
+
type: String,
|
|
83
|
+
default: null
|
|
59
84
|
}
|
|
60
85
|
},
|
|
61
86
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/schemas/dictionary.schema.ts"],"sourcesContent":["import { Schema } from 'mongoose';\nimport type { Dictionary } from '@/types/dictionary.types';\n\nexport const dictionarySchema = new Schema<Dictionary>(\n {\n projectIds: {\n type: [Schema.Types.ObjectId],\n ref: 'Project',\n required: true,\n },\n key: {\n type: String,\n required: true,\n },\n title: {\n type: String,\n default: '',\n },\n description: {\n type: String,\n default: '',\n },\n
|
|
1
|
+
{"version":3,"sources":["../../../src/schemas/dictionary.schema.ts"],"sourcesContent":["import { Schema } from 'mongoose';\nimport type { Dictionary, VersionedContentEl } from '@/types/dictionary.types';\n\nconst versionedContentElSchema = new Schema<VersionedContentEl>(\n {\n name: {\n type: String,\n },\n description: {\n type: String,\n },\n content: {\n type: Schema.Types.Mixed,\n required: true,\n },\n },\n {\n timestamps: true,\n }\n);\n\nexport const dictionarySchema = new Schema<Dictionary>(\n {\n projectIds: {\n type: [Schema.Types.ObjectId],\n ref: 'Project',\n required: true,\n },\n key: {\n type: String,\n required: true,\n },\n title: {\n type: String,\n default: '',\n },\n description: {\n type: String,\n default: '',\n },\n tags: {\n type: [String],\n default: [],\n },\n content: {\n type: Map,\n of: versionedContentElSchema,\n required: true,\n default: null,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n filePath: {\n type: Map,\n of: String,\n default: null,\n },\n publishedVersion: {\n type: String,\n default: null,\n },\n },\n {\n timestamps: true,\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAuB;AAGvB,MAAM,2BAA2B,IAAI;AAAA,EACnC;AAAA,IACE,MAAM;AAAA,MACJ,MAAM;AAAA,IACR;AAAA,IACA,aAAa;AAAA,MACX,MAAM;AAAA,IACR;AAAA,IACA,SAAS;AAAA,MACP,MAAM,uBAAO,MAAM;AAAA,MACnB,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,EACd;AACF;AAEO,MAAM,mBAAmB,IAAI;AAAA,EAClC;AAAA,IACE,YAAY;AAAA,MACV,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA,MAAM;AAAA,MACJ,MAAM,CAAC,MAAM;AAAA,MACb,SAAS,CAAC;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,UAAU;AAAA,MACV,SAAS;AAAA,IACX;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,SAAS;AAAA,IACX;AAAA,IACA,kBAAkB;AAAA,MAChB,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,EACd;AACF;","names":[]}
|
|
@@ -23,6 +23,7 @@ __export(project_schema_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(project_schema_exports);
|
|
25
25
|
var import_validateProject = require('./../utils/validation/validateProject.cjs');
|
|
26
|
+
var import_intlayer = require("intlayer");
|
|
26
27
|
var import_mongoose = require("mongoose");
|
|
27
28
|
const RightsSchema = new import_mongoose.Schema({
|
|
28
29
|
read: { type: Boolean, required: true },
|
|
@@ -61,6 +62,10 @@ const projectSchema = new import_mongoose.Schema(
|
|
|
61
62
|
minlength: import_validateProject.NAME_MIN_LENGTH,
|
|
62
63
|
maxlength: import_validateProject.NAME_MAX_LENGTH
|
|
63
64
|
},
|
|
65
|
+
locales: {
|
|
66
|
+
type: [String],
|
|
67
|
+
enum: Object.values(import_intlayer.Locales)
|
|
68
|
+
},
|
|
64
69
|
oAuth2Access: [oAuth2AccessSchema],
|
|
65
70
|
membersIds: {
|
|
66
71
|
type: [import_mongoose.Schema.Types.ObjectId],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/schemas/project.schema.ts"],"sourcesContent":["import {\n NAME_MIN_LENGTH,\n NAME_MAX_LENGTH,\n MEMBERS_MIN_LENGTH,\n} from '@utils/validation/validateProject';\nimport { Schema } from 'mongoose';\nimport { Project, Rights, TokenRights } from '@/types/project.types';\n\nconst RightsSchema = new Schema<Rights>({\n read: { type: Boolean, required: true },\n write: { type: Boolean, required: true },\n admin: { type: Boolean, required: true },\n});\n\nexport const TokenRightsSchema = new Schema<TokenRights>({\n dictionary: { type: RightsSchema, required: true },\n project: { type: RightsSchema, required: true },\n organization: { type: RightsSchema, required: true },\n});\n\n// Define the oAuth2Access subdocument schema with timestamps\nconst oAuth2AccessSchema = new Schema(\n {\n clientId: { type: String, required: true, unique: true },\n clientSecret: { type: String, required: true },\n userId: { type: Schema.Types.ObjectId, ref: 'User', required: true },\n name: { type: String, required: true },\n expiresAt: { type: Date },\n accessToken: { type: [String], required: true },\n rights: { type: TokenRightsSchema, required: true },\n },\n {\n timestamps: true,\n }\n);\n\nexport const projectSchema = new Schema<Project>(\n {\n organizationId: {\n type: Schema.Types.ObjectId,\n ref: 'Organization',\n required: true,\n },\n name: {\n type: String,\n required: true,\n minlength: NAME_MIN_LENGTH,\n maxlength: NAME_MAX_LENGTH,\n },\n oAuth2Access: [oAuth2AccessSchema],\n membersIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n adminsIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n },\n {\n timestamps: true,\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAIO;AACP,sBAAuB;AAGvB,MAAM,eAAe,IAAI,uBAAe;AAAA,EACtC,MAAM,EAAE,MAAM,SAAS,UAAU,KAAK;AAAA,EACtC,OAAO,EAAE,MAAM,SAAS,UAAU,KAAK;AAAA,EACvC,OAAO,EAAE,MAAM,SAAS,UAAU,KAAK;AACzC,CAAC;AAEM,MAAM,oBAAoB,IAAI,uBAAoB;AAAA,EACvD,YAAY,EAAE,MAAM,cAAc,UAAU,KAAK;AAAA,EACjD,SAAS,EAAE,MAAM,cAAc,UAAU,KAAK;AAAA,EAC9C,cAAc,EAAE,MAAM,cAAc,UAAU,KAAK;AACrD,CAAC;AAGD,MAAM,qBAAqB,IAAI;AAAA,EAC7B;AAAA,IACE,UAAU,EAAE,MAAM,QAAQ,UAAU,MAAM,QAAQ,KAAK;AAAA,IACvD,cAAc,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IAC7C,QAAQ,EAAE,MAAM,uBAAO,MAAM,UAAU,KAAK,QAAQ,UAAU,KAAK;AAAA,IACnE,MAAM,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACrC,WAAW,EAAE,MAAM,KAAK;AAAA,IACxB,aAAa,EAAE,MAAM,CAAC,MAAM,GAAG,UAAU,KAAK;AAAA,IAC9C,QAAQ,EAAE,MAAM,mBAAmB,UAAU,KAAK;AAAA,EACpD;AAAA,EACA;AAAA,IACE,YAAY;AAAA,EACd;AACF;AAEO,MAAM,gBAAgB,IAAI;AAAA,EAC/B;AAAA,IACE,gBAAgB;AAAA,MACd,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,cAAc,CAAC,kBAAkB;AAAA,IACjC,YAAY;AAAA,MACV,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,EACd;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/schemas/project.schema.ts"],"sourcesContent":["import {\n NAME_MIN_LENGTH,\n NAME_MAX_LENGTH,\n MEMBERS_MIN_LENGTH,\n} from '@utils/validation/validateProject';\nimport { Locales } from 'intlayer';\nimport { Schema } from 'mongoose';\nimport { Project, Rights, TokenRights } from '@/types/project.types';\n\nconst RightsSchema = new Schema<Rights>({\n read: { type: Boolean, required: true },\n write: { type: Boolean, required: true },\n admin: { type: Boolean, required: true },\n});\n\nexport const TokenRightsSchema = new Schema<TokenRights>({\n dictionary: { type: RightsSchema, required: true },\n project: { type: RightsSchema, required: true },\n organization: { type: RightsSchema, required: true },\n});\n\n// Define the oAuth2Access subdocument schema with timestamps\nconst oAuth2AccessSchema = new Schema(\n {\n clientId: { type: String, required: true, unique: true },\n clientSecret: { type: String, required: true },\n userId: { type: Schema.Types.ObjectId, ref: 'User', required: true },\n name: { type: String, required: true },\n expiresAt: { type: Date },\n accessToken: { type: [String], required: true },\n rights: { type: TokenRightsSchema, required: true },\n },\n {\n timestamps: true,\n }\n);\n\nexport const projectSchema = new Schema<Project>(\n {\n organizationId: {\n type: Schema.Types.ObjectId,\n ref: 'Organization',\n required: true,\n },\n name: {\n type: String,\n required: true,\n minlength: NAME_MIN_LENGTH,\n maxlength: NAME_MAX_LENGTH,\n },\n locales: {\n type: [String],\n enum: Object.values(Locales),\n },\n oAuth2Access: [oAuth2AccessSchema],\n membersIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n adminsIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n },\n {\n timestamps: true,\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAIO;AACP,sBAAwB;AACxB,sBAAuB;AAGvB,MAAM,eAAe,IAAI,uBAAe;AAAA,EACtC,MAAM,EAAE,MAAM,SAAS,UAAU,KAAK;AAAA,EACtC,OAAO,EAAE,MAAM,SAAS,UAAU,KAAK;AAAA,EACvC,OAAO,EAAE,MAAM,SAAS,UAAU,KAAK;AACzC,CAAC;AAEM,MAAM,oBAAoB,IAAI,uBAAoB;AAAA,EACvD,YAAY,EAAE,MAAM,cAAc,UAAU,KAAK;AAAA,EACjD,SAAS,EAAE,MAAM,cAAc,UAAU,KAAK;AAAA,EAC9C,cAAc,EAAE,MAAM,cAAc,UAAU,KAAK;AACrD,CAAC;AAGD,MAAM,qBAAqB,IAAI;AAAA,EAC7B;AAAA,IACE,UAAU,EAAE,MAAM,QAAQ,UAAU,MAAM,QAAQ,KAAK;AAAA,IACvD,cAAc,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IAC7C,QAAQ,EAAE,MAAM,uBAAO,MAAM,UAAU,KAAK,QAAQ,UAAU,KAAK;AAAA,IACnE,MAAM,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACrC,WAAW,EAAE,MAAM,KAAK;AAAA,IACxB,aAAa,EAAE,MAAM,CAAC,MAAM,GAAG,UAAU,KAAK;AAAA,IAC9C,QAAQ,EAAE,MAAM,mBAAmB,UAAU,KAAK;AAAA,EACpD;AAAA,EACA;AAAA,IACE,YAAY;AAAA,EACd;AACF;AAEO,MAAM,gBAAgB,IAAI;AAAA,EAC/B;AAAA,IACE,gBAAgB;AAAA,MACd,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,SAAS;AAAA,MACP,MAAM,CAAC,MAAM;AAAA,MACb,MAAM,OAAO,OAAO,uBAAO;AAAA,IAC7B;AAAA,IACA,cAAc,CAAC,kBAAkB;AAAA,IACjC,YAAY;AAAA,MACV,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,EACd;AACF;","names":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var tag_schema_exports = {};
|
|
20
|
+
__export(tag_schema_exports, {
|
|
21
|
+
tagSchema: () => tagSchema
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(tag_schema_exports);
|
|
24
|
+
var import_validateTag = require('./../utils/validation/validateTag.cjs');
|
|
25
|
+
var import_mongoose = require("mongoose");
|
|
26
|
+
const tagSchema = new import_mongoose.Schema(
|
|
27
|
+
{
|
|
28
|
+
organizationId: {
|
|
29
|
+
type: import_mongoose.Schema.Types.ObjectId,
|
|
30
|
+
ref: "Organization",
|
|
31
|
+
required: true
|
|
32
|
+
},
|
|
33
|
+
key: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: true,
|
|
36
|
+
minlength: import_validateTag.KEY_MIN_LENGTH,
|
|
37
|
+
maxlength: import_validateTag.KEY_MAX_LENGTH
|
|
38
|
+
},
|
|
39
|
+
name: {
|
|
40
|
+
type: String,
|
|
41
|
+
minlength: import_validateTag.NAME_MIN_LENGTH,
|
|
42
|
+
maxlength: import_validateTag.NAME_MAX_LENGTH
|
|
43
|
+
},
|
|
44
|
+
description: {
|
|
45
|
+
type: String
|
|
46
|
+
},
|
|
47
|
+
instructions: {
|
|
48
|
+
type: String
|
|
49
|
+
},
|
|
50
|
+
creatorId: {
|
|
51
|
+
type: import_mongoose.Schema.Types.ObjectId,
|
|
52
|
+
ref: "User",
|
|
53
|
+
required: true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
timestamps: true
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
tagSchema
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=tag.schema.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/schemas/tag.schema.ts"],"sourcesContent":["import {\n NAME_MIN_LENGTH,\n NAME_MAX_LENGTH,\n KEY_MAX_LENGTH,\n KEY_MIN_LENGTH,\n} from '@utils/validation/validateTag';\nimport { Schema } from 'mongoose';\nimport { Tag } from '@/types/tag.types';\n\nexport const tagSchema = new Schema<Tag>(\n {\n organizationId: {\n type: Schema.Types.ObjectId,\n ref: 'Organization',\n required: true,\n },\n key: {\n type: String,\n required: true,\n minlength: KEY_MIN_LENGTH,\n maxlength: KEY_MAX_LENGTH,\n },\n name: {\n type: String,\n minlength: NAME_MIN_LENGTH,\n maxlength: NAME_MAX_LENGTH,\n },\n description: {\n type: String,\n },\n instructions: {\n type: String,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n },\n {\n timestamps: true,\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAKO;AACP,sBAAuB;AAGhB,MAAM,YAAY,IAAI;AAAA,EAC3B;AAAA,IACE,gBAAgB;AAAA,MACd,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,MACN,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,aAAa;AAAA,MACX,MAAM;AAAA,IACR;AAAA,IACA,cAAc;AAAA,MACZ,MAAM;AAAA,IACR;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,EACd;AACF;","names":[]}
|
|
@@ -23,43 +23,106 @@ __export(dictionary_service_exports, {
|
|
|
23
23
|
deleteDictionaryById: () => deleteDictionaryById,
|
|
24
24
|
findDictionaries: () => findDictionaries,
|
|
25
25
|
getDictionariesByKeys: () => getDictionariesByKeys,
|
|
26
|
+
getDictionariesByTags: () => getDictionariesByTags,
|
|
26
27
|
getDictionariesKeys: () => getDictionariesKeys,
|
|
27
28
|
getDictionaryById: () => getDictionaryById,
|
|
28
29
|
getDictionaryByKey: () => getDictionaryByKey,
|
|
29
30
|
getExistingDictionaryKey: () => getExistingDictionaryKey,
|
|
31
|
+
incrementVersion: () => incrementVersion,
|
|
30
32
|
updateDictionaryById: () => updateDictionaryById,
|
|
31
33
|
updateDictionaryByKey: () => updateDictionaryByKey
|
|
32
34
|
});
|
|
33
35
|
module.exports = __toCommonJS(dictionary_service_exports);
|
|
34
36
|
var import_dictionary = require('./../models/dictionary.model.cjs');
|
|
37
|
+
var import_ensureMongoDocumentToObject = require('./../utils/ensureMongoDocumentToObject.cjs');
|
|
35
38
|
var import_errors = require('./../utils/errors/index.cjs');
|
|
39
|
+
var import_removeObjectKeys = require('./../utils/removeObjectKeys.cjs');
|
|
36
40
|
var import_validateDictionary = require('./../utils/validation/validateDictionary.cjs');
|
|
37
|
-
const findDictionaries = async (filters, skip = 0, limit = 100) =>
|
|
41
|
+
const findDictionaries = async (filters, skip = 0, limit = 100) => {
|
|
42
|
+
try {
|
|
43
|
+
const dictionaries = await import_dictionary.DictionaryModel.aggregate([
|
|
44
|
+
// Stage 1: Match the filters
|
|
45
|
+
{ $match: filters },
|
|
46
|
+
// Stage 2: Skip for pagination
|
|
47
|
+
{ $skip: skip },
|
|
48
|
+
// Stage 3: Limit the number of documents
|
|
49
|
+
{ $limit: limit },
|
|
50
|
+
// Stage 4: Add the 'availableVersions' field
|
|
51
|
+
{
|
|
52
|
+
$addFields: {
|
|
53
|
+
availableVersions: {
|
|
54
|
+
$map: {
|
|
55
|
+
input: { $objectToArray: "$content" },
|
|
56
|
+
as: "version",
|
|
57
|
+
in: "$$version.k"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// (Optional) Stage 5: Project the fields you want to include/exclude
|
|
63
|
+
// For example, to exclude the entire 'content' field and keep only 'availableVersions'
|
|
64
|
+
// {
|
|
65
|
+
// $project: {
|
|
66
|
+
// content: 0 // Exclude the 'content' field
|
|
67
|
+
// }
|
|
68
|
+
// }
|
|
69
|
+
]);
|
|
70
|
+
return dictionaries;
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error("Error fetching dictionaries:", error);
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
38
76
|
const getDictionaryById = async (dictionaryId) => {
|
|
39
|
-
const dictionary = await import_dictionary.DictionaryModel.
|
|
40
|
-
|
|
77
|
+
const dictionary = await import_dictionary.DictionaryModel.aggregate([
|
|
78
|
+
// Stage 1: Match the document by ID
|
|
79
|
+
{ $match: { _id: dictionaryId } },
|
|
80
|
+
// Stage 2: Add the 'availableVersions' field
|
|
81
|
+
{
|
|
82
|
+
$addFields: {
|
|
83
|
+
availableVersions: {
|
|
84
|
+
$map: {
|
|
85
|
+
input: { $objectToArray: "$content" },
|
|
86
|
+
as: "version",
|
|
87
|
+
in: "$$version.k"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
]);
|
|
93
|
+
if (!dictionary.length) {
|
|
41
94
|
throw new import_errors.GenericError("DICTIONARY_NOT_FOUND", { dictionaryId });
|
|
42
95
|
}
|
|
43
|
-
return dictionary;
|
|
96
|
+
return dictionary[0];
|
|
44
97
|
};
|
|
45
98
|
const getDictionaryByKey = async (dictionaryKey, projectId) => {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
99
|
+
const dictionaries = await getDictionariesByKeys([dictionaryKey], projectId);
|
|
100
|
+
console.log("dictionaries", dictionaries);
|
|
101
|
+
return dictionaries[0];
|
|
102
|
+
};
|
|
103
|
+
const getDictionariesByKeys = async (dictionaryKeys, projectId) => {
|
|
104
|
+
const dictionaries = await import_dictionary.DictionaryModel.aggregate([
|
|
105
|
+
// Stage 1: Match the document by key
|
|
106
|
+
{ $match: { key: { $in: dictionaryKeys }, projectIds: projectId } },
|
|
107
|
+
// Stage 2: Add the 'availableVersions' field
|
|
108
|
+
{
|
|
109
|
+
$addFields: {
|
|
110
|
+
availableVersions: {
|
|
111
|
+
$map: {
|
|
112
|
+
input: { $objectToArray: "$content" },
|
|
113
|
+
as: "version",
|
|
114
|
+
in: "$$version.k"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
]);
|
|
120
|
+
if (!dictionaries) {
|
|
51
121
|
throw new import_errors.GenericError("DICTIONARY_NOT_FOUND", {
|
|
52
|
-
|
|
122
|
+
dictionaryKeys,
|
|
53
123
|
projectId
|
|
54
124
|
});
|
|
55
125
|
}
|
|
56
|
-
return dictionary;
|
|
57
|
-
};
|
|
58
|
-
const getDictionariesByKeys = async (dictionaryKey, projectId) => {
|
|
59
|
-
const dictionaries = await import_dictionary.DictionaryModel.find({
|
|
60
|
-
key: dictionaryKey,
|
|
61
|
-
projectIds: projectId
|
|
62
|
-
});
|
|
63
126
|
return dictionaries;
|
|
64
127
|
};
|
|
65
128
|
const getDictionariesKeys = async (projectId) => {
|
|
@@ -68,6 +131,30 @@ const getDictionariesKeys = async (projectId) => {
|
|
|
68
131
|
}).select("key");
|
|
69
132
|
return dictionaries.map((dictionary) => dictionary.key);
|
|
70
133
|
};
|
|
134
|
+
const getDictionariesByTags = async (tags, projectId) => {
|
|
135
|
+
const dictionaries = await import_dictionary.DictionaryModel.aggregate([
|
|
136
|
+
// Stage 1: Match the document by tags
|
|
137
|
+
{
|
|
138
|
+
$match: {
|
|
139
|
+
tags: { $in: tags },
|
|
140
|
+
projectIds: projectId
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
// Stage 2: Add the 'availableVersions' field
|
|
144
|
+
{
|
|
145
|
+
$addFields: {
|
|
146
|
+
availableVersions: {
|
|
147
|
+
$map: {
|
|
148
|
+
input: { $objectToArray: "$content" },
|
|
149
|
+
as: "version",
|
|
150
|
+
in: "$$version.k"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
]);
|
|
156
|
+
return dictionaries;
|
|
157
|
+
};
|
|
71
158
|
const countDictionaries = async (filters) => {
|
|
72
159
|
const result = await import_dictionary.DictionaryModel.countDocuments(filters);
|
|
73
160
|
if (typeof result === "undefined") {
|
|
@@ -104,27 +191,31 @@ const getExistingDictionaryKey = async (dictionariesKeys, projectId) => {
|
|
|
104
191
|
return { existingDictionariesKey, newDictionariesKey };
|
|
105
192
|
};
|
|
106
193
|
const updateDictionaryById = async (dictionaryId, dictionary) => {
|
|
107
|
-
const
|
|
108
|
-
const
|
|
194
|
+
const dictionaryObject = (0, import_ensureMongoDocumentToObject.ensureMongoDocumentToObject)(dictionary);
|
|
195
|
+
const dictionaryToUpdate = (0, import_removeObjectKeys.removeObjectKeys)(dictionaryObject, ["_id"]);
|
|
196
|
+
const updatedKeys = Object.keys(dictionaryToUpdate);
|
|
197
|
+
const errors = await (0, import_validateDictionary.validateDictionary)(dictionaryToUpdate, updatedKeys);
|
|
109
198
|
if (Object.keys(errors).length > 0) {
|
|
110
199
|
throw new import_errors.GenericError("DICTIONARY_INVALID_FIELDS", {
|
|
111
200
|
dictionaryId,
|
|
112
201
|
errors
|
|
113
202
|
});
|
|
114
203
|
}
|
|
115
|
-
const existingDictionary = await getDictionaryById(dictionaryId);
|
|
116
204
|
const result = await import_dictionary.DictionaryModel.updateOne(
|
|
117
205
|
{ _id: dictionaryId },
|
|
118
|
-
|
|
206
|
+
dictionaryToUpdate
|
|
119
207
|
);
|
|
120
208
|
if (result.matchedCount === 0) {
|
|
121
209
|
throw new import_errors.GenericError("DICTIONARY_UPDATE_FAILED", { dictionaryId });
|
|
122
210
|
}
|
|
123
|
-
|
|
211
|
+
const updatedDictionary = await getDictionaryById(dictionaryId);
|
|
212
|
+
return updatedDictionary;
|
|
124
213
|
};
|
|
125
214
|
const updateDictionaryByKey = async (dictionaryKey, dictionary, projectId) => {
|
|
126
|
-
const
|
|
127
|
-
const
|
|
215
|
+
const dictionaryObject = (0, import_ensureMongoDocumentToObject.ensureMongoDocumentToObject)(dictionary);
|
|
216
|
+
const dictionaryToUpdate = (0, import_removeObjectKeys.removeObjectKeys)(dictionaryObject, ["_id"]);
|
|
217
|
+
const updatedKeys = Object.keys(dictionaryToUpdate);
|
|
218
|
+
const errors = await (0, import_validateDictionary.validateDictionary)(dictionaryToUpdate, updatedKeys);
|
|
128
219
|
if (Object.keys(errors).length > 0) {
|
|
129
220
|
throw new import_errors.GenericError("DICTIONARY_INVALID_FIELDS", {
|
|
130
221
|
dictionaryKey,
|
|
@@ -132,15 +223,15 @@ const updateDictionaryByKey = async (dictionaryKey, dictionary, projectId) => {
|
|
|
132
223
|
errors
|
|
133
224
|
});
|
|
134
225
|
}
|
|
135
|
-
const existingDictionary = await getDictionaryByKey(dictionaryKey, projectId);
|
|
136
226
|
const result = await import_dictionary.DictionaryModel.updateOne(
|
|
137
227
|
{ key: dictionaryKey, projectIds: projectId },
|
|
138
|
-
|
|
228
|
+
dictionaryToUpdate
|
|
139
229
|
);
|
|
140
230
|
if (result.matchedCount === 0) {
|
|
141
231
|
throw new import_errors.GenericError("DICTIONARY_UPDATE_FAILED", { dictionaryKey });
|
|
142
232
|
}
|
|
143
|
-
|
|
233
|
+
const updatedDictionary = await getDictionaryByKey(dictionaryKey, projectId);
|
|
234
|
+
return updatedDictionary;
|
|
144
235
|
};
|
|
145
236
|
const deleteDictionaryById = async (dictionaryId) => {
|
|
146
237
|
const dictionary = await import_dictionary.DictionaryModel.findByIdAndDelete(dictionaryId);
|
|
@@ -149,6 +240,25 @@ const deleteDictionaryById = async (dictionaryId) => {
|
|
|
149
240
|
}
|
|
150
241
|
return dictionary;
|
|
151
242
|
};
|
|
243
|
+
const incrementVersion = (dictionary) => {
|
|
244
|
+
const VERSION_PREFIX = "v";
|
|
245
|
+
const availableVersions = dictionary.availableVersions ?? [];
|
|
246
|
+
const currentVersion = availableVersions.length > 0 ? availableVersions[availableVersions.length - 1] : "v1";
|
|
247
|
+
const getVersionNumber = (version) => {
|
|
248
|
+
const match = version.match(/^v(\d+)$/);
|
|
249
|
+
if (!match) {
|
|
250
|
+
throw new Error(`Invalid version format: ${version}`);
|
|
251
|
+
}
|
|
252
|
+
return parseInt(match[1], 10);
|
|
253
|
+
};
|
|
254
|
+
let newNumber = getVersionNumber(currentVersion) + 1;
|
|
255
|
+
let newVersion = `${VERSION_PREFIX}${newNumber}`;
|
|
256
|
+
while (availableVersions.includes(newVersion)) {
|
|
257
|
+
newNumber += 1;
|
|
258
|
+
newVersion = `${VERSION_PREFIX}${newNumber}`;
|
|
259
|
+
}
|
|
260
|
+
return newVersion;
|
|
261
|
+
};
|
|
152
262
|
// Annotate the CommonJS export names for ESM import in node:
|
|
153
263
|
0 && (module.exports = {
|
|
154
264
|
countDictionaries,
|
|
@@ -156,10 +266,12 @@ const deleteDictionaryById = async (dictionaryId) => {
|
|
|
156
266
|
deleteDictionaryById,
|
|
157
267
|
findDictionaries,
|
|
158
268
|
getDictionariesByKeys,
|
|
269
|
+
getDictionariesByTags,
|
|
159
270
|
getDictionariesKeys,
|
|
160
271
|
getDictionaryById,
|
|
161
272
|
getDictionaryByKey,
|
|
162
273
|
getExistingDictionaryKey,
|
|
274
|
+
incrementVersion,
|
|
163
275
|
updateDictionaryById,
|
|
164
276
|
updateDictionaryByKey
|
|
165
277
|
});
|