@intlayer/backend 3.5.5 → 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.
Files changed (244) hide show
  1. package/dist/cjs/controllers/ai.controller.cjs +159 -7
  2. package/dist/cjs/controllers/ai.controller.cjs.map +1 -1
  3. package/dist/cjs/controllers/dictionary.controller.cjs +50 -17
  4. package/dist/cjs/controllers/dictionary.controller.cjs.map +1 -1
  5. package/dist/cjs/controllers/project.controller.cjs +2 -6
  6. package/dist/cjs/controllers/project.controller.cjs.map +1 -1
  7. package/dist/cjs/controllers/tag.controller.cjs +235 -0
  8. package/dist/cjs/controllers/tag.controller.cjs.map +1 -0
  9. package/dist/cjs/controllers/user.controller.cjs +1 -0
  10. package/dist/cjs/controllers/user.controller.cjs.map +1 -1
  11. package/dist/cjs/export.cjs.map +1 -1
  12. package/dist/cjs/index.cjs +2 -0
  13. package/dist/cjs/index.cjs.map +1 -1
  14. package/dist/cjs/models/tag.model.cjs +31 -0
  15. package/dist/cjs/models/tag.model.cjs.map +1 -0
  16. package/dist/cjs/routes/ai.routes.cjs +31 -4
  17. package/dist/cjs/routes/ai.routes.cjs.map +1 -1
  18. package/dist/cjs/routes/dictionary.routes.cjs +4 -4
  19. package/dist/cjs/routes/dictionary.routes.cjs.map +1 -1
  20. package/dist/cjs/routes/tags.routes.cjs +60 -0
  21. package/dist/cjs/routes/tags.routes.cjs.map +1 -0
  22. package/dist/cjs/schemas/dictionary.schema.cjs +31 -6
  23. package/dist/cjs/schemas/dictionary.schema.cjs.map +1 -1
  24. package/dist/cjs/schemas/project.schema.cjs +5 -0
  25. package/dist/cjs/schemas/project.schema.cjs.map +1 -1
  26. package/dist/cjs/schemas/tag.schema.cjs +64 -0
  27. package/dist/cjs/schemas/tag.schema.cjs.map +1 -0
  28. package/dist/cjs/services/dictionary.service.cjs +139 -27
  29. package/dist/cjs/services/dictionary.service.cjs.map +1 -1
  30. package/dist/cjs/services/project.service.cjs +14 -5
  31. package/dist/cjs/services/project.service.cjs.map +1 -1
  32. package/dist/cjs/services/tag.service.cjs +91 -0
  33. package/dist/cjs/services/tag.service.cjs.map +1 -0
  34. package/dist/cjs/types/dictionary.types.cjs.map +1 -1
  35. package/dist/cjs/types/tag.types.cjs +17 -0
  36. package/dist/cjs/types/tag.types.cjs.map +1 -0
  37. package/dist/cjs/utils/{audit → auditDictionary}/PROMPT.md +6 -1
  38. package/dist/cjs/utils/{audit → auditDictionary}/index.cjs +10 -8
  39. package/dist/cjs/utils/auditDictionary/index.cjs.map +1 -0
  40. package/dist/cjs/utils/auditDictionaryField/PROMPT.md +115 -0
  41. package/dist/cjs/utils/auditDictionaryField/index.cjs +81 -0
  42. package/dist/cjs/utils/auditDictionaryField/index.cjs.map +1 -0
  43. package/dist/cjs/utils/auditDictionaryMetadata/PROMPT.md +76 -0
  44. package/dist/cjs/utils/auditDictionaryMetadata/index.cjs +78 -0
  45. package/dist/cjs/utils/auditDictionaryMetadata/index.cjs.map +1 -0
  46. package/dist/cjs/utils/auditTag/PROMPT.md +34 -0
  47. package/dist/cjs/utils/auditTag/index.cjs +74 -0
  48. package/dist/cjs/utils/auditTag/index.cjs.map +1 -0
  49. package/dist/cjs/utils/ensureArrayQueryFilter.cjs +39 -0
  50. package/dist/cjs/utils/ensureArrayQueryFilter.cjs.map +1 -0
  51. package/dist/cjs/utils/ensureMongoDocumentToObject.cjs +35 -0
  52. package/dist/cjs/utils/ensureMongoDocumentToObject.cjs.map +1 -0
  53. package/dist/cjs/utils/errors/errorCodes.cjs +91 -0
  54. package/dist/cjs/utils/errors/errorCodes.cjs.map +1 -1
  55. package/dist/cjs/utils/filtersAndPagination/getDictionaryFiltersAndPagination.cjs +10 -11
  56. package/dist/cjs/utils/filtersAndPagination/getDictionaryFiltersAndPagination.cjs.map +1 -1
  57. package/dist/cjs/utils/filtersAndPagination/getOrganizationFiltersAndPagination.cjs +6 -10
  58. package/dist/cjs/utils/filtersAndPagination/getOrganizationFiltersAndPagination.cjs.map +1 -1
  59. package/dist/cjs/utils/filtersAndPagination/getProjectFiltersAndPagination.cjs +6 -10
  60. package/dist/cjs/utils/filtersAndPagination/getProjectFiltersAndPagination.cjs.map +1 -1
  61. package/dist/cjs/utils/filtersAndPagination/getTagFiltersAndPagination.cjs +51 -0
  62. package/dist/cjs/utils/filtersAndPagination/getTagFiltersAndPagination.cjs.map +1 -0
  63. package/dist/cjs/utils/filtersAndPagination/getUserFiltersAndPagination.cjs +2 -9
  64. package/dist/cjs/utils/filtersAndPagination/getUserFiltersAndPagination.cjs.map +1 -1
  65. package/dist/cjs/utils/mapper/dictionary.cjs +8 -4
  66. package/dist/cjs/utils/mapper/dictionary.cjs.map +1 -1
  67. package/dist/cjs/utils/mapper/organization.cjs +2 -4
  68. package/dist/cjs/utils/mapper/organization.cjs.map +1 -1
  69. package/dist/cjs/utils/mapper/project.cjs +2 -4
  70. package/dist/cjs/utils/mapper/project.cjs.map +1 -1
  71. package/dist/cjs/utils/mapper/tag.cjs +37 -0
  72. package/dist/cjs/utils/mapper/tag.cjs.map +1 -0
  73. package/dist/cjs/utils/mapper/user.cjs +2 -4
  74. package/dist/cjs/utils/mapper/user.cjs.map +1 -1
  75. package/dist/cjs/utils/removeObjectKeys.cjs +35 -0
  76. package/dist/cjs/utils/removeObjectKeys.cjs.map +1 -0
  77. package/dist/cjs/utils/validation/validateProject.cjs +17 -10
  78. package/dist/cjs/utils/validation/validateProject.cjs.map +1 -1
  79. package/dist/cjs/utils/validation/validateTag.cjs +93 -0
  80. package/dist/cjs/utils/validation/validateTag.cjs.map +1 -0
  81. package/dist/esm/controllers/ai.controller.mjs +155 -6
  82. package/dist/esm/controllers/ai.controller.mjs.map +1 -1
  83. package/dist/esm/controllers/dictionary.controller.mjs +50 -17
  84. package/dist/esm/controllers/dictionary.controller.mjs.map +1 -1
  85. package/dist/esm/controllers/project.controller.mjs +2 -6
  86. package/dist/esm/controllers/project.controller.mjs.map +1 -1
  87. package/dist/esm/controllers/tag.controller.mjs +203 -0
  88. package/dist/esm/controllers/tag.controller.mjs.map +1 -0
  89. package/dist/esm/controllers/user.controller.mjs +1 -0
  90. package/dist/esm/controllers/user.controller.mjs.map +1 -1
  91. package/dist/esm/export.mjs.map +1 -1
  92. package/dist/esm/index.mjs +2 -0
  93. package/dist/esm/index.mjs.map +1 -1
  94. package/dist/esm/models/tag.model.mjs +7 -0
  95. package/dist/esm/models/tag.model.mjs.map +1 -0
  96. package/dist/esm/routes/ai.routes.mjs +37 -5
  97. package/dist/esm/routes/ai.routes.mjs.map +1 -1
  98. package/dist/esm/routes/dictionary.routes.mjs +4 -4
  99. package/dist/esm/routes/dictionary.routes.mjs.map +1 -1
  100. package/dist/esm/routes/tags.routes.mjs +40 -0
  101. package/dist/esm/routes/tags.routes.mjs.map +1 -0
  102. package/dist/esm/schemas/dictionary.schema.mjs +31 -6
  103. package/dist/esm/schemas/dictionary.schema.mjs.map +1 -1
  104. package/dist/esm/schemas/project.schema.mjs +5 -0
  105. package/dist/esm/schemas/project.schema.mjs.map +1 -1
  106. package/dist/esm/schemas/tag.schema.mjs +45 -0
  107. package/dist/esm/schemas/tag.schema.mjs.map +1 -0
  108. package/dist/esm/services/dictionary.service.mjs +137 -27
  109. package/dist/esm/services/dictionary.service.mjs.map +1 -1
  110. package/dist/esm/services/project.service.mjs +14 -5
  111. package/dist/esm/services/project.service.mjs.map +1 -1
  112. package/dist/esm/services/tag.service.mjs +61 -0
  113. package/dist/esm/services/tag.service.mjs.map +1 -0
  114. package/dist/esm/types/tag.types.mjs +1 -0
  115. package/dist/esm/types/tag.types.mjs.map +1 -0
  116. package/dist/esm/utils/{audit → auditDictionary}/PROMPT.md +6 -1
  117. package/dist/esm/utils/{audit → auditDictionary}/index.mjs +6 -4
  118. package/dist/esm/utils/auditDictionary/index.mjs.map +1 -0
  119. package/dist/esm/utils/auditDictionaryField/PROMPT.md +115 -0
  120. package/dist/esm/utils/auditDictionaryField/index.mjs +56 -0
  121. package/dist/esm/utils/auditDictionaryField/index.mjs.map +1 -0
  122. package/dist/esm/utils/auditDictionaryMetadata/PROMPT.md +76 -0
  123. package/dist/esm/utils/auditDictionaryMetadata/index.mjs +53 -0
  124. package/dist/esm/utils/auditDictionaryMetadata/index.mjs.map +1 -0
  125. package/dist/esm/utils/auditTag/PROMPT.md +34 -0
  126. package/dist/esm/utils/auditTag/index.mjs +49 -0
  127. package/dist/esm/utils/auditTag/index.mjs.map +1 -0
  128. package/dist/esm/utils/ensureArrayQueryFilter.mjs +15 -0
  129. package/dist/esm/utils/ensureArrayQueryFilter.mjs.map +1 -0
  130. package/dist/esm/utils/ensureMongoDocumentToObject.mjs +11 -0
  131. package/dist/esm/utils/ensureMongoDocumentToObject.mjs.map +1 -0
  132. package/dist/esm/utils/errors/errorCodes.mjs +91 -0
  133. package/dist/esm/utils/errors/errorCodes.mjs.map +1 -1
  134. package/dist/esm/utils/filtersAndPagination/getDictionaryFiltersAndPagination.mjs +10 -11
  135. package/dist/esm/utils/filtersAndPagination/getDictionaryFiltersAndPagination.mjs.map +1 -1
  136. package/dist/esm/utils/filtersAndPagination/getOrganizationFiltersAndPagination.mjs +6 -10
  137. package/dist/esm/utils/filtersAndPagination/getOrganizationFiltersAndPagination.mjs.map +1 -1
  138. package/dist/esm/utils/filtersAndPagination/getProjectFiltersAndPagination.mjs +6 -10
  139. package/dist/esm/utils/filtersAndPagination/getProjectFiltersAndPagination.mjs.map +1 -1
  140. package/dist/esm/utils/filtersAndPagination/getTagFiltersAndPagination.mjs +29 -0
  141. package/dist/esm/utils/filtersAndPagination/getTagFiltersAndPagination.mjs.map +1 -0
  142. package/dist/esm/utils/filtersAndPagination/getUserFiltersAndPagination.mjs +2 -9
  143. package/dist/esm/utils/filtersAndPagination/getUserFiltersAndPagination.mjs.map +1 -1
  144. package/dist/esm/utils/mapper/dictionary.mjs +8 -4
  145. package/dist/esm/utils/mapper/dictionary.mjs.map +1 -1
  146. package/dist/esm/utils/mapper/organization.mjs +2 -4
  147. package/dist/esm/utils/mapper/organization.mjs.map +1 -1
  148. package/dist/esm/utils/mapper/project.mjs +2 -4
  149. package/dist/esm/utils/mapper/project.mjs.map +1 -1
  150. package/dist/esm/utils/mapper/tag.mjs +12 -0
  151. package/dist/esm/utils/mapper/tag.mjs.map +1 -0
  152. package/dist/esm/utils/mapper/user.mjs +2 -4
  153. package/dist/esm/utils/mapper/user.mjs.map +1 -1
  154. package/dist/esm/utils/removeObjectKeys.mjs +11 -0
  155. package/dist/esm/utils/removeObjectKeys.mjs.map +1 -0
  156. package/dist/esm/utils/validation/validateProject.mjs +17 -10
  157. package/dist/esm/utils/validation/validateProject.mjs.map +1 -1
  158. package/dist/esm/utils/validation/validateTag.mjs +65 -0
  159. package/dist/esm/utils/validation/validateTag.mjs.map +1 -0
  160. package/dist/types/controllers/ai.controller.d.ts +45 -4
  161. package/dist/types/controllers/ai.controller.d.ts.map +1 -1
  162. package/dist/types/controllers/dictionary.controller.d.ts +6 -3
  163. package/dist/types/controllers/dictionary.controller.d.ts.map +1 -1
  164. package/dist/types/controllers/project.controller.d.ts +2 -4
  165. package/dist/types/controllers/project.controller.d.ts.map +1 -1
  166. package/dist/types/controllers/tag.controller.d.ts +39 -0
  167. package/dist/types/controllers/tag.controller.d.ts.map +1 -0
  168. package/dist/types/controllers/user.controller.d.ts.map +1 -1
  169. package/dist/types/export.d.ts +2 -0
  170. package/dist/types/export.d.ts.map +1 -1
  171. package/dist/types/index.d.ts.map +1 -1
  172. package/dist/types/models/dictionary.model.d.ts +1 -0
  173. package/dist/types/models/dictionary.model.d.ts.map +1 -1
  174. package/dist/types/models/tag.model.d.ts +3 -0
  175. package/dist/types/models/tag.model.d.ts.map +1 -0
  176. package/dist/types/routes/ai.routes.d.ts +16 -1
  177. package/dist/types/routes/ai.routes.d.ts.map +1 -1
  178. package/dist/types/routes/dictionary.routes.d.ts +6 -2
  179. package/dist/types/routes/dictionary.routes.d.ts.map +1 -1
  180. package/dist/types/routes/tags.routes.d.ts +29 -0
  181. package/dist/types/routes/tags.routes.d.ts.map +1 -0
  182. package/dist/types/schemas/dictionary.schema.d.ts +1 -0
  183. package/dist/types/schemas/dictionary.schema.d.ts.map +1 -1
  184. package/dist/types/schemas/project.schema.d.ts.map +1 -1
  185. package/dist/types/schemas/tag.schema.d.ts +16 -0
  186. package/dist/types/schemas/tag.schema.d.ts.map +1 -0
  187. package/dist/types/services/dictionary.service.d.ts +10 -2
  188. package/dist/types/services/dictionary.service.d.ts.map +1 -1
  189. package/dist/types/services/project.service.d.ts.map +1 -1
  190. package/dist/types/services/tag.service.d.ts +45 -0
  191. package/dist/types/services/tag.service.d.ts.map +1 -0
  192. package/dist/types/types/dictionary.types.d.ts +14 -4
  193. package/dist/types/types/dictionary.types.d.ts.map +1 -1
  194. package/dist/types/types/tag.types.d.ts +26 -0
  195. package/dist/types/types/tag.types.d.ts.map +1 -0
  196. package/dist/types/utils/auditDictionary/index.d.ts +24 -0
  197. package/dist/types/utils/auditDictionary/index.d.ts.map +1 -0
  198. package/dist/types/utils/auditDictionaryField/index.d.ts +24 -0
  199. package/dist/types/utils/auditDictionaryField/index.d.ts.map +1 -0
  200. package/dist/types/utils/auditDictionaryMetadata/index.d.ts +21 -0
  201. package/dist/types/utils/auditDictionaryMetadata/index.d.ts.map +1 -0
  202. package/dist/types/utils/auditTag/index.d.ts +27 -0
  203. package/dist/types/utils/auditTag/index.d.ts.map +1 -0
  204. package/dist/types/utils/ensureArrayQueryFilter.d.ts +2 -0
  205. package/dist/types/utils/ensureArrayQueryFilter.d.ts.map +1 -0
  206. package/dist/types/utils/ensureMongoDocumentToObject.d.ts +8 -0
  207. package/dist/types/utils/ensureMongoDocumentToObject.d.ts.map +1 -0
  208. package/dist/types/utils/errors/errorCodes.d.ts +91 -0
  209. package/dist/types/utils/errors/errorCodes.d.ts.map +1 -1
  210. package/dist/types/utils/filtersAndPagination/getDictionaryFiltersAndPagination.d.ts +2 -0
  211. package/dist/types/utils/filtersAndPagination/getDictionaryFiltersAndPagination.d.ts.map +1 -1
  212. package/dist/types/utils/filtersAndPagination/getOrganizationFiltersAndPagination.d.ts.map +1 -1
  213. package/dist/types/utils/filtersAndPagination/getProjectFiltersAndPagination.d.ts.map +1 -1
  214. package/dist/types/utils/filtersAndPagination/getTagFiltersAndPagination.d.ts +24 -0
  215. package/dist/types/utils/filtersAndPagination/getTagFiltersAndPagination.d.ts.map +1 -0
  216. package/dist/types/utils/filtersAndPagination/getUserFiltersAndPagination.d.ts.map +1 -1
  217. package/dist/types/utils/mapper/dictionary.d.ts +1 -1
  218. package/dist/types/utils/mapper/dictionary.d.ts.map +1 -1
  219. package/dist/types/utils/mapper/organization.d.ts.map +1 -1
  220. package/dist/types/utils/mapper/project.d.ts.map +1 -1
  221. package/dist/types/utils/mapper/tag.d.ts +16 -0
  222. package/dist/types/utils/mapper/tag.d.ts.map +1 -0
  223. package/dist/types/utils/mapper/user.d.ts +2 -2
  224. package/dist/types/utils/mapper/user.d.ts.map +1 -1
  225. package/dist/types/utils/removeObjectKeys.d.ts +2 -0
  226. package/dist/types/utils/removeObjectKeys.d.ts.map +1 -0
  227. package/dist/types/utils/validation/validateProject.d.ts.map +1 -1
  228. package/dist/types/utils/validation/validateTag.d.ts +16 -0
  229. package/dist/types/utils/validation/validateTag.d.ts.map +1 -0
  230. package/package.json +2 -3
  231. package/dist/cjs/utils/audit/index.cjs.map +0 -1
  232. package/dist/esm/utils/audit/index.mjs.map +0 -1
  233. /package/dist/cjs/utils/{audit → auditDictionary}/CJS_FORMAT.md +0 -0
  234. /package/dist/cjs/utils/{audit → auditDictionary}/JSON_FORMAT.md +0 -0
  235. /package/dist/cjs/utils/{audit → auditDictionary}/JSX_FORMAT.md +0 -0
  236. /package/dist/cjs/utils/{audit → auditDictionary}/MJS_FORMAT.md +0 -0
  237. /package/dist/cjs/utils/{audit → auditDictionary}/TSX_FORMAT.md +0 -0
  238. /package/dist/cjs/utils/{audit → auditDictionary}/TS_FORMAT.md +0 -0
  239. /package/dist/esm/utils/{audit → auditDictionary}/CJS_FORMAT.md +0 -0
  240. /package/dist/esm/utils/{audit → auditDictionary}/JSON_FORMAT.md +0 -0
  241. /package/dist/esm/utils/{audit → auditDictionary}/JSX_FORMAT.md +0 -0
  242. /package/dist/esm/utils/{audit → auditDictionary}/MJS_FORMAT.md +0 -0
  243. /package/dist/esm/utils/{audit → auditDictionary}/TSX_FORMAT.md +0 -0
  244. /package/dist/esm/utils/{audit → auditDictionary}/TS_FORMAT.md +0 -0
@@ -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: '/',\n url: baseURL,\n method: 'PUT',\n },\n deleteDictionary: {\n urlModel: '/',\n url: baseURL,\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;AAAA,IACL,QAAQ;AAAA,EACV;AAAA,EACA,kBAAkB;AAAA,IAChB,UAAU;AAAA,IACV,KAAK;AAAA,IACL,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":[]}
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
- version: {
45
- type: Number,
46
- default: 1
61
+ tags: {
62
+ type: [String],
63
+ default: []
47
64
  },
48
65
  content: {
49
- type: [import_mongoose.Schema.Types.Mixed],
50
- required: true
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: import_mongoose.Schema.Types.Mixed
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 version: {\n type: Number,\n default: 1,\n },\n content: {\n type: [Schema.Types.Mixed],\n required: true,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n filePath: {\n type: Schema.Types.Mixed,\n },\n },\n {\n timestamps: true,\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAuB;AAGhB,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,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA,SAAS;AAAA,MACP,MAAM,CAAC,uBAAO,MAAM,KAAK;AAAA,MACzB,UAAU;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,UAAU;AAAA,MACR,MAAM,uBAAO,MAAM;AAAA,IACrB;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,EACd;AACF;","names":[]}
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,IAC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 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) => await import_dictionary.DictionaryModel.find(filters).skip(skip).limit(limit);
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.findById(dictionaryId);
40
- if (!dictionary) {
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 dictionary = await import_dictionary.DictionaryModel.findOne({
47
- key: dictionaryKey,
48
- projectIds: projectId
49
- });
50
- if (!dictionary) {
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
- dictionaryKey,
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 updatedKeys = Object.keys(dictionary);
108
- const errors = (0, import_validateDictionary.validateDictionary)(dictionary, updatedKeys);
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
- { ...dictionary, content: [existingDictionary.content, dictionary.content] }
206
+ dictionaryToUpdate
119
207
  );
120
208
  if (result.matchedCount === 0) {
121
209
  throw new import_errors.GenericError("DICTIONARY_UPDATE_FAILED", { dictionaryId });
122
210
  }
123
- return await getDictionaryById(dictionaryId);
211
+ const updatedDictionary = await getDictionaryById(dictionaryId);
212
+ return updatedDictionary;
124
213
  };
125
214
  const updateDictionaryByKey = async (dictionaryKey, dictionary, projectId) => {
126
- const updatedKeys = Object.keys(dictionary);
127
- const errors = (0, import_validateDictionary.validateDictionary)(dictionary, updatedKeys);
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
- { ...dictionary, content: [existingDictionary.content, dictionary.content] }
228
+ dictionaryToUpdate
139
229
  );
140
230
  if (result.matchedCount === 0) {
141
231
  throw new import_errors.GenericError("DICTIONARY_UPDATE_FAILED", { dictionaryKey });
142
232
  }
143
- return await getDictionaryByKey(dictionaryKey, projectId);
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
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/services/dictionary.service.ts"],"sourcesContent":["import { DictionaryModel } from '@models/dictionary.model';\nimport { GenericError } from '@utils/errors';\nimport type { DictionaryFilters } from '@utils/filtersAndPagination/getDictionaryFiltersAndPagination';\nimport {\n type DictionaryFields,\n validateDictionary,\n} from '@utils/validation/validateDictionary';\nimport type { ObjectId } from 'mongoose';\nimport type {\n Dictionary,\n DictionaryData,\n DictionaryDocument,\n} from '@/types/dictionary.types';\n\n/**\n * Finds dictionaries based on filters and pagination options.\n * @param filters - MongoDB filter query.\n * @param skip - Number of documents to skip.\n * @param limit - Number of documents to limit.\n * @returns List of dictionaries matching the filters.\n */\nexport const findDictionaries = async (\n filters: DictionaryFilters,\n skip = 0,\n limit = 100\n): Promise<DictionaryDocument[]> =>\n await DictionaryModel.find(filters).skip(skip).limit(limit);\n\n/**\n * Finds a dictionary by its ID.\n * @param dictionaryId - The ID of the dictionary to find.\n * @returns The dictionary matching the ID.\n */\nexport const getDictionaryById = async (\n dictionaryId: string | ObjectId\n): Promise<DictionaryDocument> => {\n const dictionary = await DictionaryModel.findById(dictionaryId);\n\n if (!dictionary) {\n throw new GenericError('DICTIONARY_NOT_FOUND', { dictionaryId });\n }\n\n return dictionary;\n};\n\n/**\n * Finds a dictionary by its ID.\n * @param dictionaryKey - The ID of the dictionary to find.\n * @returns The dictionary matching the ID.\n */\nexport const getDictionaryByKey = async (\n dictionaryKey: string,\n projectId: string | ObjectId\n): Promise<DictionaryDocument> => {\n const dictionary = await DictionaryModel.findOne({\n key: dictionaryKey,\n projectIds: projectId,\n });\n\n if (!dictionary) {\n throw new GenericError('DICTIONARY_NOT_FOUND', {\n dictionaryKey,\n projectId,\n });\n }\n\n return dictionary;\n};\n\nexport const getDictionariesByKeys = async (\n dictionaryKey: string[],\n projectId: string | ObjectId\n): Promise<DictionaryDocument[]> => {\n const dictionaries = await DictionaryModel.find({\n key: dictionaryKey,\n projectIds: projectId,\n });\n\n return dictionaries;\n};\n\nexport const getDictionariesKeys = async (\n projectId: string | ObjectId\n): Promise<string[]> => {\n const dictionaries = await DictionaryModel.find({\n projectIds: projectId,\n }).select('key');\n\n return dictionaries.map((dictionary) => dictionary.key);\n};\n\n/**\n * Counts the total number of dictionaries that match the filters.\n * @param filters - MongoDB filter query.\n * @returns Total number of dictionaries.\n */\nexport const countDictionaries = async (\n filters: DictionaryFilters\n): Promise<number> => {\n const result = await DictionaryModel.countDocuments(filters);\n\n if (typeof result === 'undefined') {\n throw new GenericError('DICTIONARY_COUNT_FAILED', { filters });\n }\n\n return result;\n};\n\n/**\n * Creates a new dictionary in the database.\n * @param dictionary - The dictionary data to create.\n * @returns The created dictionary.\n */\nexport const createDictionary = async (\n dictionary: DictionaryData\n): Promise<DictionaryDocument> => {\n const errors = await validateDictionary(dictionary);\n\n if (Object.keys(errors).length > 0) {\n throw new GenericError('DICTIONARY_INVALID_FIELDS', {\n errors,\n });\n }\n\n return await DictionaryModel.create(dictionary);\n};\n\ntype GetExistingDictionaryResult = {\n existingDictionariesKey: string[];\n newDictionariesKey: string[];\n};\n\n/**\n * Gets the existing dictionaries from the provided list of keys.\n * @param dictionariesKeys - List of dictionary keys to check.\n * @param projectId - The ID of the project to check the dictionaries against.\n * @returns The existing dictionaries and the new dictionaries.\n */\nexport const getExistingDictionaryKey = async (\n dictionariesKeys: string[],\n projectId: string | ObjectId\n): Promise<GetExistingDictionaryResult> => {\n // Fetch dictionaries from the database where the key is in the provided list\n const existingDictionaries = await DictionaryModel.find({\n key: { $in: dictionariesKeys },\n projectIds: projectId,\n });\n\n // Map existing dictionaries to a LocalDictionary object\n const existingDictionariesKey: string[] = [];\n const newDictionariesKey: string[] = [];\n\n for (const key of dictionariesKeys) {\n const isDictionaryExist = existingDictionaries.some(\n (dictionary) => dictionary.key === key\n );\n\n if (isDictionaryExist) {\n existingDictionariesKey.push(key);\n } else {\n newDictionariesKey.push(key);\n }\n }\n\n return { existingDictionariesKey, newDictionariesKey };\n};\n\n/**\n * Updates an existing dictionary in the database by its ID.\n * @param dictionaryId - The ID of the dictionary to update.\n * @param dictionary - The updated dictionary data.\n * @returns The updated dictionary.\n */\nexport const updateDictionaryById = async (\n dictionaryId: string | ObjectId,\n dictionary: Partial<Dictionary>\n): Promise<DictionaryDocument> => {\n const updatedKeys = Object.keys(dictionary) as DictionaryFields;\n const errors = validateDictionary(dictionary, updatedKeys);\n\n if (Object.keys(errors).length > 0) {\n throw new GenericError('DICTIONARY_INVALID_FIELDS', {\n dictionaryId,\n errors,\n });\n }\n\n const existingDictionary = await getDictionaryById(dictionaryId);\n\n const result = await DictionaryModel.updateOne(\n { _id: dictionaryId },\n { ...dictionary, content: [existingDictionary.content, dictionary.content] }\n );\n\n if (result.matchedCount === 0) {\n throw new GenericError('DICTIONARY_UPDATE_FAILED', { dictionaryId });\n }\n\n return await getDictionaryById(dictionaryId);\n};\n\n/**\n * Updates an existing dictionary in the database by its key.\n * @param dictionaryKey - The ID of the dictionary to update.\n * @param dictionary - The updated dictionary data.\n * @returns The updated dictionary.\n */\nexport const updateDictionaryByKey = async (\n dictionaryKey: string,\n dictionary: Partial<Dictionary>,\n projectId: string | ObjectId\n): Promise<DictionaryDocument> => {\n const updatedKeys = Object.keys(dictionary) as DictionaryFields;\n const errors = validateDictionary(dictionary, updatedKeys);\n\n if (Object.keys(errors).length > 0) {\n throw new GenericError('DICTIONARY_INVALID_FIELDS', {\n dictionaryKey,\n projectId,\n errors,\n });\n }\n\n const existingDictionary = await getDictionaryByKey(dictionaryKey, projectId);\n\n const result = await DictionaryModel.updateOne(\n { key: dictionaryKey, projectIds: projectId },\n { ...dictionary, content: [existingDictionary.content, dictionary.content] }\n );\n\n if (result.matchedCount === 0) {\n throw new GenericError('DICTIONARY_UPDATE_FAILED', { dictionaryKey });\n }\n\n return await getDictionaryByKey(dictionaryKey, projectId);\n};\n\n/**\n * Deletes a dictionary from the database by its ID.\n * @param dictionaryId - The ID of the dictionary to delete.\n * @returns The result of the deletion operation.\n */\nexport const deleteDictionaryById = async (\n dictionaryId: string\n): Promise<DictionaryDocument> => {\n const dictionary = await DictionaryModel.findByIdAndDelete(dictionaryId);\n\n if (!dictionary) {\n throw new GenericError('DICTIONARY_NOT_FOUND', { dictionaryId });\n }\n\n return dictionary;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAgC;AAChC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C1C,QAAM,aAAS,8CAAmB,YAAY,WAAW;AAEzD,MAAI,OAAO,KAAK,MAAM,EAAE,SAAS,GAAG;AAClC,UAAM,IAAI,2BAAa,6BAA6B;AAAA,MAClD;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,qBAAqB,MAAM,mBAAmB,eAAe,SAAS;AAE5E,QAAM,SAAS,MAAM,kCAAgB;AAAA,IACnC,EAAE,KAAK,eAAe,YAAY,UAAU;AAAA,IAC5C,EAAE,GAAG,YAAY,SAAS,CAAC,mBAAmB,SAAS,WAAW,OAAO,EAAE;AAAA,EAC7E;AAEA,MAAI,OAAO,iBAAiB,GAAG;AAC7B,UAAM,IAAI,2BAAa,4BAA4B,EAAE,cAAc,CAAC;AAAA,EACtE;AAEA,SAAO,MAAM,mBAAmB,eAAe,SAAS;AAC1D;AAOO,MAAM,uBAAuB,OAClC,iBACgC;AAChC,QAAM,aAAa,MAAM,kCAAgB,kBAAkB,YAAY;AAEvE,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,2BAAa,wBAAwB,EAAE,aAAa,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/services/dictionary.service.ts"],"sourcesContent":["import { DictionaryModel } from '@models/dictionary.model';\nimport { ensureMongoDocumentToObject } from '@utils/ensureMongoDocumentToObject';\nimport { GenericError } from '@utils/errors';\nimport type { DictionaryFilters } from '@utils/filtersAndPagination/getDictionaryFiltersAndPagination';\nimport { removeObjectKeys } from '@utils/removeObjectKeys';\nimport {\n type DictionaryFields,\n validateDictionary,\n} from '@utils/validation/validateDictionary';\nimport { ObjectId } from 'mongoose';\nimport type {\n Dictionary,\n DictionaryData,\n DictionaryDocument,\n} from '@/types/dictionary.types';\nimport type { Project } from '@/types/project.types';\n\n/**\n * Finds dictionaries based on filters and pagination options.\n * @param filters - MongoDB filter query.\n * @param skip - Number of documents to skip.\n * @param limit - Number of documents to limit.\n * @returns List of dictionaries matching the filters.\n */\nexport const findDictionaries = async (\n filters: DictionaryFilters,\n skip = 0,\n limit = 100\n): Promise<DictionaryDocument[]> => {\n try {\n const dictionaries = await DictionaryModel.aggregate<DictionaryDocument>([\n // Stage 1: Match the filters\n { $match: filters },\n\n // Stage 2: Skip for pagination\n { $skip: skip },\n\n // Stage 3: Limit the number of documents\n { $limit: limit },\n\n // Stage 4: Add the 'availableVersions' field\n {\n $addFields: {\n availableVersions: {\n $map: {\n input: { $objectToArray: '$content' },\n as: 'version',\n in: '$$version.k',\n },\n },\n },\n },\n\n // (Optional) Stage 5: Project the fields you want to include/exclude\n // For example, to exclude the entire 'content' field and keep only 'availableVersions'\n // {\n // $project: {\n // content: 0 // Exclude the 'content' field\n // }\n // }\n ]);\n\n return dictionaries;\n } catch (error) {\n console.error('Error fetching dictionaries:', error);\n throw error;\n }\n};\n\n/**\n * Finds a dictionary by its ID.\n * @param dictionaryId - The ID of the dictionary to find.\n * @returns The dictionary matching the ID.\n */\n/**\n * Finds a dictionary by its ID and includes the 'availableVersions' field.\n * @param dictionaryId - The ID of the dictionary to find.\n * @returns The dictionary matching the ID with available versions.\n */\nexport const getDictionaryById = async (\n dictionaryId: string | ObjectId\n): Promise<DictionaryDocument> => {\n const dictionary = await DictionaryModel.aggregate<DictionaryDocument>([\n // Stage 1: Match the document by ID\n { $match: { _id: dictionaryId } },\n\n // Stage 2: Add the 'availableVersions' field\n {\n $addFields: {\n availableVersions: {\n $map: {\n input: { $objectToArray: '$content' },\n as: 'version',\n in: '$$version.k',\n },\n },\n },\n },\n ]);\n\n if (!dictionary.length) {\n throw new GenericError('DICTIONARY_NOT_FOUND', { dictionaryId });\n }\n\n return dictionary[0];\n};\n\n/**\n * Finds a dictionary by its ID.\n * @param dictionaryKey - The ID of the dictionary to find.\n * @returns The dictionary matching the ID.\n */\nexport const getDictionaryByKey = async (\n dictionaryKey: string,\n projectId: string | ObjectId\n): Promise<DictionaryDocument> => {\n const dictionaries = await getDictionariesByKeys([dictionaryKey], projectId);\n\n console.log('dictionaries', dictionaries);\n\n return dictionaries[0];\n};\n\nexport const getDictionariesByKeys = async (\n dictionaryKeys: string[],\n projectId: string | ObjectId\n): Promise<DictionaryDocument[]> => {\n const dictionaries = await DictionaryModel.aggregate<DictionaryDocument>([\n // Stage 1: Match the document by key\n { $match: { key: { $in: dictionaryKeys }, projectIds: projectId } },\n\n // Stage 2: Add the 'availableVersions' field\n {\n $addFields: {\n availableVersions: {\n $map: {\n input: { $objectToArray: '$content' },\n as: 'version',\n in: '$$version.k',\n },\n },\n },\n },\n ]);\n\n if (!dictionaries) {\n throw new GenericError('DICTIONARY_NOT_FOUND', {\n dictionaryKeys,\n projectId,\n });\n }\n\n return dictionaries;\n};\n\nexport const getDictionariesKeys = async (\n projectId: string | ObjectId\n): Promise<string[]> => {\n const dictionaries = await DictionaryModel.find({\n projectIds: projectId,\n }).select('key');\n\n return dictionaries.map((dictionary) => dictionary.key);\n};\n\nexport const getDictionariesByTags = async (\n tags: string[],\n projectId: string | Project['_id']\n): Promise<DictionaryDocument[]> => {\n const dictionaries = await DictionaryModel.aggregate<DictionaryDocument>([\n // Stage 1: Match the document by tags\n {\n $match: {\n tags: { $in: tags },\n projectIds: projectId,\n },\n },\n\n // Stage 2: Add the 'availableVersions' field\n {\n $addFields: {\n availableVersions: {\n $map: {\n input: { $objectToArray: '$content' },\n as: 'version',\n in: '$$version.k',\n },\n },\n },\n },\n ]);\n\n return dictionaries;\n};\n\n/**\n * Counts the total number of dictionaries that match the filters.\n * @param filters - MongoDB filter query.\n * @returns Total number of dictionaries.\n */\nexport const countDictionaries = async (\n filters: DictionaryFilters\n): Promise<number> => {\n const result = await DictionaryModel.countDocuments(filters);\n\n if (typeof result === 'undefined') {\n throw new GenericError('DICTIONARY_COUNT_FAILED', { filters });\n }\n\n return result;\n};\n\n/**\n * Creates a new dictionary in the database.\n * @param dictionary - The dictionary data to create.\n * @returns The created dictionary.\n */\nexport const createDictionary = async (\n dictionary: DictionaryData\n): Promise<DictionaryDocument> => {\n const errors = await validateDictionary(dictionary);\n\n if (Object.keys(errors).length > 0) {\n throw new GenericError('DICTIONARY_INVALID_FIELDS', {\n errors,\n });\n }\n\n return await DictionaryModel.create(dictionary);\n};\n\ntype GetExistingDictionaryResult = {\n existingDictionariesKey: string[];\n newDictionariesKey: string[];\n};\n\n/**\n * Gets the existing dictionaries from the provided list of keys.\n * @param dictionariesKeys - List of dictionary keys to check.\n * @param projectId - The ID of the project to check the dictionaries against.\n * @returns The existing dictionaries and the new dictionaries.\n */\nexport const getExistingDictionaryKey = async (\n dictionariesKeys: string[],\n projectId: string | ObjectId\n): Promise<GetExistingDictionaryResult> => {\n // Fetch dictionaries from the database where the key is in the provided list\n const existingDictionaries = await DictionaryModel.find({\n key: { $in: dictionariesKeys },\n projectIds: projectId,\n });\n\n // Map existing dictionaries to a LocalDictionary object\n const existingDictionariesKey: string[] = [];\n const newDictionariesKey: string[] = [];\n\n for (const key of dictionariesKeys) {\n const isDictionaryExist = existingDictionaries.some(\n (dictionary) => dictionary.key === key\n );\n\n if (isDictionaryExist) {\n existingDictionariesKey.push(key);\n } else {\n newDictionariesKey.push(key);\n }\n }\n\n return { existingDictionariesKey, newDictionariesKey };\n};\n\n/**\n * Updates an existing dictionary in the database by its ID.\n * @param dictionaryId - The ID of the dictionary to update.\n * @param dictionary - The updated dictionary data.\n * @returns The updated dictionary.\n */\nexport const updateDictionaryById = async (\n dictionaryId: string | ObjectId,\n dictionary: Partial<Dictionary>\n): Promise<DictionaryDocument> => {\n const dictionaryObject = ensureMongoDocumentToObject(dictionary);\n const dictionaryToUpdate = removeObjectKeys(dictionaryObject, ['_id']);\n\n const updatedKeys = Object.keys(dictionaryToUpdate) as DictionaryFields;\n const errors = await validateDictionary(dictionaryToUpdate, updatedKeys);\n\n if (Object.keys(errors).length > 0) {\n throw new GenericError('DICTIONARY_INVALID_FIELDS', {\n dictionaryId,\n errors,\n });\n }\n\n const result = await DictionaryModel.updateOne(\n { _id: dictionaryId },\n dictionaryToUpdate\n );\n\n if (result.matchedCount === 0) {\n throw new GenericError('DICTIONARY_UPDATE_FAILED', { dictionaryId });\n }\n\n const updatedDictionary = await getDictionaryById(dictionaryId);\n\n return updatedDictionary;\n};\n\n/**\n * Updates an existing dictionary in the database by its key.\n * @param dictionaryKey - The ID of the dictionary to update.\n * @param dictionary - The updated dictionary data.\n * @returns The updated dictionary.\n */\nexport const updateDictionaryByKey = async (\n dictionaryKey: string,\n dictionary: Partial<Dictionary>,\n projectId: string | ObjectId\n): Promise<DictionaryDocument> => {\n const dictionaryObject = ensureMongoDocumentToObject(dictionary);\n\n const dictionaryToUpdate = removeObjectKeys(dictionaryObject, ['_id']);\n\n const updatedKeys = Object.keys(dictionaryToUpdate) as DictionaryFields;\n const errors = await validateDictionary(dictionaryToUpdate, updatedKeys);\n\n if (Object.keys(errors).length > 0) {\n throw new GenericError('DICTIONARY_INVALID_FIELDS', {\n dictionaryKey,\n projectId,\n errors,\n });\n }\n\n const result = await DictionaryModel.updateOne(\n { key: dictionaryKey, projectIds: projectId },\n dictionaryToUpdate\n );\n\n if (result.matchedCount === 0) {\n throw new GenericError('DICTIONARY_UPDATE_FAILED', { dictionaryKey });\n }\n\n const updatedDictionary = await getDictionaryByKey(dictionaryKey, projectId);\n\n return updatedDictionary;\n};\n\n/**\n * Deletes a dictionary from the database by its ID.\n * @param dictionaryId - The ID of the dictionary to delete.\n * @returns The result of the deletion operation.\n */\nexport const deleteDictionaryById = async (\n dictionaryId: string\n): Promise<DictionaryDocument> => {\n const dictionary = await DictionaryModel.findByIdAndDelete(dictionaryId);\n\n if (!dictionary) {\n throw new GenericError('DICTIONARY_NOT_FOUND', { dictionaryId });\n }\n\n return dictionary;\n};\n\nexport const incrementVersion = (dictionary: Dictionary): string => {\n const VERSION_PREFIX = 'v';\n const availableVersions = dictionary.availableVersions ?? [];\n\n // Get the current version from the version list, default to 'v1' if not present\n const currentVersion =\n availableVersions.length > 0\n ? availableVersions[availableVersions.length - 1]\n : 'v1';\n\n // Function to extract the numeric part of the version\n const getVersionNumber = (version: string): number => {\n const match = version.match(/^v(\\d+)$/);\n if (!match) {\n throw new Error(`Invalid version format: ${version}`);\n }\n return parseInt(match[1], 10);\n };\n\n // Start with the next version number\n let newNumber = getVersionNumber(currentVersion) + 1;\n let newVersion = `${VERSION_PREFIX}${newNumber}`;\n\n // Loop until a unique version is found\n while (availableVersions.includes(newVersion)) {\n newNumber += 1;\n newVersion = `${VERSION_PREFIX}${newNumber}`;\n }\n\n return newVersion;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAgC;AAChC,yCAA4C;AAC5C,oBAA6B;AAE7B,8BAAiC;AACjC,gCAGO;AAgBA,MAAM,mBAAmB,OAC9B,SACA,OAAO,GACP,QAAQ,QAC0B;AAClC,MAAI;AACF,UAAM,eAAe,MAAM,kCAAgB,UAA8B;AAAA;AAAA,MAEvE,EAAE,QAAQ,QAAQ;AAAA;AAAA,MAGlB,EAAE,OAAO,KAAK;AAAA;AAAA,MAGd,EAAE,QAAQ,MAAM;AAAA;AAAA,MAGhB;AAAA,QACE,YAAY;AAAA,UACV,mBAAmB;AAAA,YACjB,MAAM;AAAA,cACJ,OAAO,EAAE,gBAAgB,WAAW;AAAA,cACpC,IAAI;AAAA,cACJ,IAAI;AAAA,YACN;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASF,CAAC;AAED,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,gCAAgC,KAAK;AACnD,UAAM;AAAA,EACR;AACF;AAYO,MAAM,oBAAoB,OAC/B,iBACgC;AAChC,QAAM,aAAa,MAAM,kCAAgB,UAA8B;AAAA;AAAA,IAErE,EAAE,QAAQ,EAAE,KAAK,aAAa,E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AACT;AAOO,MAAM,uBAAuB,OAClC,iBACgC;AAChC,QAAM,aAAa,MAAM,kCAAgB,kBAAkB,YAAY;AAEvE,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,2BAAa,wBAAwB,EAAE,aAAa,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;AAEO,MAAM,mBAAmB,CAAC,eAAmC;AAClE,QAAM,iBAAiB;AACvB,QAAM,oBAAoB,WAAW,qBAAqB,CAAC;AAG3D,QAAM,iBACJ,kBAAkB,SAAS,IACvB,kBAAkB,kBAAkB,SAAS,CAAC,IAC9C;AAGN,QAAM,mBAAmB,CAAC,YAA4B;AACpD,UAAM,QAAQ,QAAQ,MAAM,UAAU;AACtC,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,2BAA2B,OAAO,EAAE;AAAA,IACtD;AACA,WAAO,SAAS,MAAM,CAAC,GAAG,EAAE;AAAA,EAC9B;AAGA,MAAI,YAAY,iBAAiB,cAAc,IAAI;AACnD,MAAI,aAAa,GAAG,cAAc,GAAG,SAAS;AAG9C,SAAO,kBAAkB,SAAS,UAAU,GAAG;AAC7C,iBAAa;AACb,iBAAa,GAAG,cAAc,GAAG,SAAS;AAAA,EAC5C;AAEA,SAAO;AACT;","names":[]}
@@ -27,7 +27,9 @@ __export(project_service_exports, {
27
27
  });
28
28
  module.exports = __toCommonJS(project_service_exports);
29
29
  var import_project = require('./../models/project.model.cjs');
30
+ var import_ensureMongoDocumentToObject = require('./../utils/ensureMongoDocumentToObject.cjs');
30
31
  var import_errors = require('./../utils/errors/index.cjs');
32
+ var import_removeObjectKeys = require('./../utils/removeObjectKeys.cjs');
31
33
  var import_validateProject = require('./../utils/validation/validateProject.cjs');
32
34
  const findProjects = async (filters, skip = 0, limit = 100) => await import_project.ProjectModel.find(filters).skip(skip).limit(limit);
33
35
  const getProjectById = async (projectId) => {
@@ -55,10 +57,13 @@ const createProject = async (project) => {
55
57
  return await import_project.ProjectModel.create(project);
56
58
  };
57
59
  const updateProjectById = async (projectId, project) => {
58
- if (project.oAuth2Access) {
59
- delete project.oAuth2Access;
60
- }
61
- const updatedKeys = Object.keys(project);
60
+ const projectObject = (0, import_ensureMongoDocumentToObject.ensureMongoDocumentToObject)(project);
61
+ const projectToUpdate = (0, import_removeObjectKeys.removeObjectKeys)(projectObject, [
62
+ "_id",
63
+ "oAuth2Access",
64
+ "organizationId"
65
+ ]);
66
+ const updatedKeys = Object.keys(projectToUpdate);
62
67
  const errors = (0, import_validateProject.validateProject)(project, updatedKeys);
63
68
  if (Object.keys(errors).length > 0) {
64
69
  throw new import_errors.GenericError("PROJECT_INVALID_FIELDS", {
@@ -66,7 +71,11 @@ const updateProjectById = async (projectId, project) => {
66
71
  errors
67
72
  });
68
73
  }
69
- const result = await import_project.ProjectModel.updateOne({ _id: projectId }, project);
74
+ console.log("projectToUpdate", projectToUpdate);
75
+ const result = await import_project.ProjectModel.updateOne(
76
+ { _id: projectId },
77
+ projectToUpdate
78
+ );
70
79
  if (result.matchedCount === 0) {
71
80
  throw new import_errors.GenericError("PROJECT_UPDATE_FAILED", { projectId });
72
81
  }