@strapi/core 0.0.0-experimental.a407f3bc8fb79a53cf7975140864526b6ddbac4b → 0.0.0-experimental.d23c1d5b0e45dd06ef09977f526c85468be05403

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 (741) hide show
  1. package/dist/Strapi.d.ts +49 -58
  2. package/dist/Strapi.d.ts.map +1 -1
  3. package/dist/Strapi.js +148 -208
  4. package/dist/Strapi.js.map +1 -1
  5. package/dist/Strapi.mjs +139 -200
  6. package/dist/Strapi.mjs.map +1 -1
  7. package/dist/configuration/config-loader.d.ts.map +1 -1
  8. package/dist/configuration/config-loader.js +9 -5
  9. package/dist/configuration/config-loader.js.map +1 -1
  10. package/dist/configuration/config-loader.mjs +9 -5
  11. package/dist/configuration/config-loader.mjs.map +1 -1
  12. package/dist/configuration/get-dirs.d.ts +10 -0
  13. package/dist/configuration/get-dirs.d.ts.map +1 -0
  14. package/dist/{utils → configuration}/get-dirs.js +3 -2
  15. package/dist/configuration/get-dirs.js.map +1 -0
  16. package/dist/{utils → configuration}/get-dirs.mjs +3 -2
  17. package/dist/configuration/get-dirs.mjs.map +1 -0
  18. package/dist/configuration/index.d.ts +4 -7
  19. package/dist/configuration/index.d.ts.map +1 -1
  20. package/dist/configuration/index.js +10 -8
  21. package/dist/configuration/index.js.map +1 -1
  22. package/dist/configuration/index.mjs +6 -5
  23. package/dist/configuration/index.mjs.map +1 -1
  24. package/dist/configuration/urls.d.ts +8 -0
  25. package/dist/configuration/urls.d.ts.map +1 -0
  26. package/dist/configuration/urls.js +68 -0
  27. package/dist/configuration/urls.js.map +1 -0
  28. package/dist/configuration/urls.mjs +66 -0
  29. package/dist/configuration/urls.mjs.map +1 -0
  30. package/dist/container.d.ts +2 -2
  31. package/dist/container.d.ts.map +1 -1
  32. package/dist/container.js.map +1 -1
  33. package/dist/container.mjs.map +1 -1
  34. package/dist/core-api/controller/collection-type.d.ts +3 -3
  35. package/dist/core-api/controller/collection-type.d.ts.map +1 -1
  36. package/dist/core-api/controller/collection-type.js +1 -0
  37. package/dist/core-api/controller/collection-type.js.map +1 -1
  38. package/dist/core-api/controller/collection-type.mjs +1 -0
  39. package/dist/core-api/controller/collection-type.mjs.map +1 -1
  40. package/dist/core-api/controller/index.d.ts +3 -3
  41. package/dist/core-api/controller/index.d.ts.map +1 -1
  42. package/dist/core-api/controller/index.js +11 -6
  43. package/dist/core-api/controller/index.js.map +1 -1
  44. package/dist/core-api/controller/index.mjs +12 -7
  45. package/dist/core-api/controller/index.mjs.map +1 -1
  46. package/dist/core-api/controller/single-type.d.ts +3 -3
  47. package/dist/core-api/controller/single-type.d.ts.map +1 -1
  48. package/dist/core-api/controller/single-type.js.map +1 -1
  49. package/dist/core-api/controller/single-type.mjs.map +1 -1
  50. package/dist/core-api/controller/transform.d.ts +10 -9
  51. package/dist/core-api/controller/transform.d.ts.map +1 -1
  52. package/dist/core-api/controller/transform.js +19 -13
  53. package/dist/core-api/controller/transform.js.map +1 -1
  54. package/dist/core-api/controller/transform.mjs +19 -13
  55. package/dist/core-api/controller/transform.mjs.map +1 -1
  56. package/dist/core-api/routes/index.d.ts.map +1 -1
  57. package/dist/core-api/service/collection-type.d.ts +10 -10
  58. package/dist/core-api/service/collection-type.d.ts.map +1 -1
  59. package/dist/core-api/service/collection-type.js +14 -5
  60. package/dist/core-api/service/collection-type.js.map +1 -1
  61. package/dist/core-api/service/collection-type.mjs +14 -5
  62. package/dist/core-api/service/collection-type.mjs.map +1 -1
  63. package/dist/core-api/service/index.d.ts +3 -3
  64. package/dist/core-api/service/index.d.ts.map +1 -1
  65. package/dist/core-api/service/index.js.map +1 -1
  66. package/dist/core-api/service/index.mjs.map +1 -1
  67. package/dist/core-api/service/single-type.d.ts +5 -5
  68. package/dist/core-api/service/single-type.d.ts.map +1 -1
  69. package/dist/core-api/service/single-type.js +11 -6
  70. package/dist/core-api/service/single-type.js.map +1 -1
  71. package/dist/core-api/service/single-type.mjs +11 -6
  72. package/dist/core-api/service/single-type.mjs.map +1 -1
  73. package/dist/domain/content-type/index.d.ts +1 -1
  74. package/dist/domain/content-type/index.d.ts.map +1 -1
  75. package/dist/domain/content-type/index.js +3 -0
  76. package/dist/domain/content-type/index.js.map +1 -1
  77. package/dist/domain/content-type/index.mjs +3 -0
  78. package/dist/domain/content-type/index.mjs.map +1 -1
  79. package/dist/domain/content-type/validator.d.ts.map +1 -1
  80. package/dist/domain/content-type/validator.js +1 -1
  81. package/dist/domain/content-type/validator.js.map +1 -1
  82. package/dist/domain/content-type/validator.mjs +2 -2
  83. package/dist/domain/content-type/validator.mjs.map +1 -1
  84. package/dist/domain/module/index.d.ts +24 -23
  85. package/dist/domain/module/index.d.ts.map +1 -1
  86. package/dist/domain/module/index.js +3 -3
  87. package/dist/domain/module/index.js.map +1 -1
  88. package/dist/domain/module/index.mjs +4 -4
  89. package/dist/domain/module/index.mjs.map +1 -1
  90. package/dist/ee/index.d.ts +4 -2
  91. package/dist/ee/index.d.ts.map +1 -1
  92. package/dist/ee/index.js.map +1 -1
  93. package/dist/ee/index.mjs.map +1 -1
  94. package/dist/ee/license.d.ts +2 -2
  95. package/dist/ee/license.d.ts.map +1 -1
  96. package/dist/ee/license.js +2 -1
  97. package/dist/ee/license.js.map +1 -1
  98. package/dist/ee/license.mjs +2 -1
  99. package/dist/ee/license.mjs.map +1 -1
  100. package/dist/factories.d.ts +10 -10
  101. package/dist/factories.d.ts.map +1 -1
  102. package/dist/factories.js +6 -2
  103. package/dist/factories.js.map +1 -1
  104. package/dist/factories.mjs +6 -2
  105. package/dist/factories.mjs.map +1 -1
  106. package/dist/index.d.ts +4 -2
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +25 -1
  109. package/dist/index.js.map +1 -1
  110. package/dist/index.mjs +27 -3
  111. package/dist/index.mjs.map +1 -1
  112. package/dist/loaders/admin.d.ts +2 -2
  113. package/dist/loaders/admin.d.ts.map +1 -1
  114. package/dist/loaders/admin.js +0 -1
  115. package/dist/loaders/admin.js.map +1 -1
  116. package/dist/loaders/admin.mjs +0 -1
  117. package/dist/loaders/admin.mjs.map +1 -1
  118. package/dist/loaders/apis.d.ts +2 -2
  119. package/dist/loaders/apis.d.ts.map +1 -1
  120. package/dist/loaders/apis.js +1 -1
  121. package/dist/loaders/apis.js.map +1 -1
  122. package/dist/loaders/apis.mjs +2 -2
  123. package/dist/loaders/apis.mjs.map +1 -1
  124. package/dist/loaders/components.d.ts +2 -2
  125. package/dist/loaders/components.d.ts.map +1 -1
  126. package/dist/loaders/components.js.map +1 -1
  127. package/dist/loaders/components.mjs.map +1 -1
  128. package/dist/loaders/index.d.ts +2 -2
  129. package/dist/loaders/index.d.ts.map +1 -1
  130. package/dist/loaders/index.js +0 -2
  131. package/dist/loaders/index.js.map +1 -1
  132. package/dist/loaders/index.mjs +0 -2
  133. package/dist/loaders/index.mjs.map +1 -1
  134. package/dist/loaders/middlewares.d.ts +2 -2
  135. package/dist/loaders/middlewares.d.ts.map +1 -1
  136. package/dist/loaders/middlewares.js.map +1 -1
  137. package/dist/loaders/middlewares.mjs.map +1 -1
  138. package/dist/loaders/plugins/get-enabled-plugins.d.ts +2 -2
  139. package/dist/loaders/plugins/get-enabled-plugins.d.ts.map +1 -1
  140. package/dist/loaders/plugins/get-enabled-plugins.js +4 -2
  141. package/dist/loaders/plugins/get-enabled-plugins.js.map +1 -1
  142. package/dist/loaders/plugins/get-enabled-plugins.mjs +5 -3
  143. package/dist/loaders/plugins/get-enabled-plugins.mjs.map +1 -1
  144. package/dist/loaders/plugins/index.d.ts +2 -2
  145. package/dist/loaders/plugins/index.d.ts.map +1 -1
  146. package/dist/loaders/plugins/index.js.map +1 -1
  147. package/dist/loaders/plugins/index.mjs.map +1 -1
  148. package/dist/loaders/policies.d.ts +2 -2
  149. package/dist/loaders/policies.d.ts.map +1 -1
  150. package/dist/loaders/policies.js.map +1 -1
  151. package/dist/loaders/policies.mjs.map +1 -1
  152. package/dist/loaders/sanitizers.d.ts +2 -2
  153. package/dist/loaders/sanitizers.d.ts.map +1 -1
  154. package/dist/loaders/sanitizers.js.map +1 -1
  155. package/dist/loaders/sanitizers.mjs.map +1 -1
  156. package/dist/loaders/src-index.d.ts +2 -2
  157. package/dist/loaders/src-index.d.ts.map +1 -1
  158. package/dist/loaders/src-index.js.map +1 -1
  159. package/dist/loaders/src-index.mjs.map +1 -1
  160. package/dist/loaders/validators.d.ts +2 -2
  161. package/dist/loaders/validators.d.ts.map +1 -1
  162. package/dist/loaders/validators.js.map +1 -1
  163. package/dist/loaders/validators.mjs.map +1 -1
  164. package/dist/middlewares/body.d.ts +4 -4
  165. package/dist/middlewares/body.d.ts.map +1 -1
  166. package/dist/middlewares/body.js +4 -4
  167. package/dist/middlewares/body.js.map +1 -1
  168. package/dist/middlewares/body.mjs +4 -4
  169. package/dist/middlewares/body.mjs.map +1 -1
  170. package/dist/middlewares/compression.d.ts +2 -2
  171. package/dist/middlewares/compression.d.ts.map +1 -1
  172. package/dist/middlewares/compression.js.map +1 -1
  173. package/dist/middlewares/compression.mjs.map +1 -1
  174. package/dist/middlewares/cors.d.ts +2 -2
  175. package/dist/middlewares/cors.d.ts.map +1 -1
  176. package/dist/middlewares/cors.js.map +1 -1
  177. package/dist/middlewares/cors.mjs.map +1 -1
  178. package/dist/middlewares/errors.d.ts +2 -2
  179. package/dist/middlewares/errors.d.ts.map +1 -1
  180. package/dist/middlewares/errors.js.map +1 -1
  181. package/dist/middlewares/errors.mjs.map +1 -1
  182. package/dist/middlewares/favicon.d.ts +2 -2
  183. package/dist/middlewares/favicon.d.ts.map +1 -1
  184. package/dist/middlewares/favicon.js.map +1 -1
  185. package/dist/middlewares/favicon.mjs.map +1 -1
  186. package/dist/middlewares/index.d.ts +2 -2
  187. package/dist/middlewares/index.d.ts.map +1 -1
  188. package/dist/middlewares/index.js.map +1 -1
  189. package/dist/middlewares/index.mjs.map +1 -1
  190. package/dist/middlewares/ip.d.ts +2 -2
  191. package/dist/middlewares/ip.d.ts.map +1 -1
  192. package/dist/middlewares/ip.js.map +1 -1
  193. package/dist/middlewares/ip.mjs.map +1 -1
  194. package/dist/middlewares/logger.d.ts +2 -2
  195. package/dist/middlewares/logger.d.ts.map +1 -1
  196. package/dist/middlewares/logger.js.map +1 -1
  197. package/dist/middlewares/logger.mjs.map +1 -1
  198. package/dist/middlewares/powered-by.d.ts +2 -2
  199. package/dist/middlewares/powered-by.d.ts.map +1 -1
  200. package/dist/middlewares/powered-by.js.map +1 -1
  201. package/dist/middlewares/powered-by.mjs.map +1 -1
  202. package/dist/middlewares/public.d.ts +2 -2
  203. package/dist/middlewares/public.d.ts.map +1 -1
  204. package/dist/middlewares/public.js +1 -1
  205. package/dist/middlewares/public.js.map +1 -1
  206. package/dist/middlewares/public.mjs +1 -1
  207. package/dist/middlewares/public.mjs.map +1 -1
  208. package/dist/middlewares/query.d.ts +2 -2
  209. package/dist/middlewares/query.d.ts.map +1 -1
  210. package/dist/middlewares/query.js.map +1 -1
  211. package/dist/middlewares/query.mjs.map +1 -1
  212. package/dist/middlewares/response-time.d.ts +2 -2
  213. package/dist/middlewares/response-time.d.ts.map +1 -1
  214. package/dist/middlewares/response-time.js.map +1 -1
  215. package/dist/middlewares/response-time.mjs.map +1 -1
  216. package/dist/middlewares/responses.d.ts +3 -3
  217. package/dist/middlewares/responses.d.ts.map +1 -1
  218. package/dist/middlewares/responses.js.map +1 -1
  219. package/dist/middlewares/responses.mjs.map +1 -1
  220. package/dist/middlewares/security.d.ts +2 -2
  221. package/dist/middlewares/security.d.ts.map +1 -1
  222. package/dist/middlewares/security.js +2 -2
  223. package/dist/middlewares/security.js.map +1 -1
  224. package/dist/middlewares/security.mjs +2 -2
  225. package/dist/middlewares/security.mjs.map +1 -1
  226. package/dist/middlewares/session.d.ts +2 -2
  227. package/dist/middlewares/session.d.ts.map +1 -1
  228. package/dist/middlewares/session.js.map +1 -1
  229. package/dist/middlewares/session.mjs.map +1 -1
  230. package/dist/migrations/draft-publish.d.ts +17 -0
  231. package/dist/migrations/draft-publish.d.ts.map +1 -0
  232. package/dist/migrations/draft-publish.js +59 -0
  233. package/dist/migrations/draft-publish.js.map +1 -0
  234. package/dist/migrations/draft-publish.mjs +59 -0
  235. package/dist/migrations/draft-publish.mjs.map +1 -0
  236. package/dist/providers/admin.d.ts +3 -0
  237. package/dist/providers/admin.d.ts.map +1 -0
  238. package/dist/providers/admin.js +20 -0
  239. package/dist/providers/admin.js.map +1 -0
  240. package/dist/providers/admin.mjs +21 -0
  241. package/dist/providers/admin.mjs.map +1 -0
  242. package/dist/providers/coreStore.d.ts +3 -0
  243. package/dist/providers/coreStore.d.ts.map +1 -0
  244. package/dist/providers/coreStore.js +11 -0
  245. package/dist/providers/coreStore.js.map +1 -0
  246. package/dist/providers/coreStore.mjs +12 -0
  247. package/dist/providers/coreStore.mjs.map +1 -0
  248. package/dist/providers/cron.d.ts +3 -0
  249. package/dist/providers/cron.d.ts.map +1 -0
  250. package/dist/providers/cron.js +20 -0
  251. package/dist/providers/cron.js.map +1 -0
  252. package/dist/providers/cron.mjs +21 -0
  253. package/dist/providers/cron.mjs.map +1 -0
  254. package/dist/providers/index.d.ts +3 -0
  255. package/dist/providers/index.d.ts.map +1 -0
  256. package/dist/providers/index.js +11 -0
  257. package/dist/providers/index.js.map +1 -0
  258. package/dist/providers/index.mjs +11 -0
  259. package/dist/providers/index.mjs.map +1 -0
  260. package/dist/providers/provider.d.ts +9 -0
  261. package/dist/providers/provider.d.ts.map +1 -0
  262. package/dist/providers/provider.js +5 -0
  263. package/dist/providers/provider.js.map +1 -0
  264. package/dist/providers/provider.mjs +5 -0
  265. package/dist/providers/provider.mjs.map +1 -0
  266. package/dist/providers/registries.d.ts +3 -0
  267. package/dist/providers/registries.d.ts.map +1 -0
  268. package/dist/providers/registries.js +33 -0
  269. package/dist/providers/registries.js.map +1 -0
  270. package/dist/providers/registries.mjs +34 -0
  271. package/dist/providers/registries.mjs.map +1 -0
  272. package/dist/providers/telemetry.d.ts +3 -0
  273. package/dist/providers/telemetry.d.ts.map +1 -0
  274. package/dist/providers/telemetry.js +19 -0
  275. package/dist/providers/telemetry.js.map +1 -0
  276. package/dist/providers/telemetry.mjs +20 -0
  277. package/dist/providers/telemetry.mjs.map +1 -0
  278. package/dist/providers/webhooks.d.ts +3 -0
  279. package/dist/providers/webhooks.d.ts.map +1 -0
  280. package/dist/providers/webhooks.js +30 -0
  281. package/dist/providers/webhooks.js.map +1 -0
  282. package/dist/providers/webhooks.mjs +31 -0
  283. package/dist/providers/webhooks.mjs.map +1 -0
  284. package/dist/registries/apis.d.ts +2 -2
  285. package/dist/registries/apis.d.ts.map +1 -1
  286. package/dist/registries/apis.js.map +1 -1
  287. package/dist/registries/apis.mjs.map +1 -1
  288. package/dist/registries/components.d.ts +6 -6
  289. package/dist/registries/components.d.ts.map +1 -1
  290. package/dist/registries/components.js.map +1 -1
  291. package/dist/registries/components.mjs.map +1 -1
  292. package/dist/registries/content-types.d.ts +5 -5
  293. package/dist/registries/content-types.d.ts.map +1 -1
  294. package/dist/registries/content-types.js.map +1 -1
  295. package/dist/registries/content-types.mjs.map +1 -1
  296. package/dist/registries/controllers.d.ts +10 -10
  297. package/dist/registries/controllers.d.ts.map +1 -1
  298. package/dist/registries/controllers.js.map +1 -1
  299. package/dist/registries/controllers.mjs.map +1 -1
  300. package/dist/registries/custom-fields.d.ts +3 -3
  301. package/dist/registries/custom-fields.d.ts.map +1 -1
  302. package/dist/registries/custom-fields.js.map +1 -1
  303. package/dist/registries/custom-fields.mjs.map +1 -1
  304. package/dist/registries/index.d.ts +0 -1
  305. package/dist/registries/index.d.ts.map +1 -1
  306. package/dist/registries/middlewares.d.ts +6 -6
  307. package/dist/registries/middlewares.d.ts.map +1 -1
  308. package/dist/registries/middlewares.js.map +1 -1
  309. package/dist/registries/middlewares.mjs.map +1 -1
  310. package/dist/registries/modules.d.ts +2 -2
  311. package/dist/registries/modules.d.ts.map +1 -1
  312. package/dist/registries/modules.js.map +1 -1
  313. package/dist/registries/modules.mjs.map +1 -1
  314. package/dist/registries/plugins.d.ts +5 -5
  315. package/dist/registries/plugins.d.ts.map +1 -1
  316. package/dist/registries/plugins.js.map +1 -1
  317. package/dist/registries/plugins.mjs.map +1 -1
  318. package/dist/registries/policies.d.ts +23 -11
  319. package/dist/registries/policies.d.ts.map +1 -1
  320. package/dist/registries/policies.js +64 -18
  321. package/dist/registries/policies.js.map +1 -1
  322. package/dist/registries/policies.mjs +65 -19
  323. package/dist/registries/policies.mjs.map +1 -1
  324. package/dist/registries/services.d.ts +8 -8
  325. package/dist/registries/services.d.ts.map +1 -1
  326. package/dist/registries/services.js.map +1 -1
  327. package/dist/registries/services.mjs.map +1 -1
  328. package/dist/services/auth/index.d.ts +4 -4
  329. package/dist/services/auth/index.d.ts.map +1 -1
  330. package/dist/services/auth/index.js.map +1 -1
  331. package/dist/services/auth/index.mjs.map +1 -1
  332. package/dist/services/config.d.ts +3 -0
  333. package/dist/services/config.d.ts.map +1 -0
  334. package/dist/services/config.js +47 -0
  335. package/dist/services/config.js.map +1 -0
  336. package/dist/services/config.mjs +47 -0
  337. package/dist/services/config.mjs.map +1 -0
  338. package/dist/services/content-api/index.d.ts +21 -3
  339. package/dist/services/content-api/index.d.ts.map +1 -1
  340. package/dist/services/content-api/index.js +28 -2
  341. package/dist/services/content-api/index.js.map +1 -1
  342. package/dist/services/content-api/index.mjs +28 -2
  343. package/dist/services/content-api/index.mjs.map +1 -1
  344. package/dist/services/content-api/permissions/index.d.ts +3 -3
  345. package/dist/services/content-api/permissions/index.d.ts.map +1 -1
  346. package/dist/services/content-api/permissions/index.js +1 -1
  347. package/dist/services/content-api/permissions/index.js.map +1 -1
  348. package/dist/services/content-api/permissions/index.mjs +1 -1
  349. package/dist/services/content-api/permissions/index.mjs.map +1 -1
  350. package/dist/services/core-store.d.ts.map +1 -1
  351. package/dist/services/cron.d.ts +2 -2
  352. package/dist/services/cron.d.ts.map +1 -1
  353. package/dist/services/cron.js.map +1 -1
  354. package/dist/services/cron.mjs.map +1 -1
  355. package/dist/services/custom-fields.d.ts +2 -2
  356. package/dist/services/custom-fields.d.ts.map +1 -1
  357. package/dist/services/custom-fields.js.map +1 -1
  358. package/dist/services/custom-fields.mjs.map +1 -1
  359. package/dist/services/document-service/attributes/index.d.ts +6 -0
  360. package/dist/services/document-service/attributes/index.d.ts.map +1 -0
  361. package/dist/services/{entity-service → document-service}/attributes/index.js +5 -5
  362. package/dist/services/document-service/attributes/index.js.map +1 -0
  363. package/dist/services/{entity-service → document-service}/attributes/index.mjs +5 -5
  364. package/dist/services/document-service/attributes/index.mjs.map +1 -0
  365. package/dist/services/document-service/attributes/transforms.d.ts +10 -0
  366. package/dist/services/document-service/attributes/transforms.d.ts.map +1 -0
  367. package/dist/services/document-service/attributes/transforms.js.map +1 -0
  368. package/dist/services/document-service/attributes/transforms.mjs.map +1 -0
  369. package/dist/services/document-service/common.d.ts +2 -2
  370. package/dist/services/document-service/common.d.ts.map +1 -1
  371. package/dist/services/document-service/common.js.map +1 -1
  372. package/dist/services/document-service/common.mjs.map +1 -1
  373. package/dist/services/document-service/components.d.ts +25 -1
  374. package/dist/services/document-service/components.d.ts.map +1 -1
  375. package/dist/services/{entity-service → document-service}/components.js +46 -142
  376. package/dist/services/document-service/components.js.map +1 -0
  377. package/dist/services/{entity-service → document-service}/components.mjs +48 -144
  378. package/dist/services/document-service/components.mjs.map +1 -0
  379. package/dist/services/document-service/document-engine.d.ts +0 -7
  380. package/dist/services/document-service/document-engine.d.ts.map +1 -1
  381. package/dist/services/document-service/draft-and-publish.d.ts +9 -23
  382. package/dist/services/document-service/draft-and-publish.d.ts.map +1 -1
  383. package/dist/services/document-service/draft-and-publish.js +37 -9
  384. package/dist/services/document-service/draft-and-publish.js.map +1 -1
  385. package/dist/services/document-service/draft-and-publish.mjs +38 -10
  386. package/dist/services/document-service/draft-and-publish.mjs.map +1 -1
  387. package/dist/services/document-service/entries.d.ts +10 -0
  388. package/dist/services/document-service/entries.d.ts.map +1 -0
  389. package/dist/services/document-service/entries.js +95 -0
  390. package/dist/services/document-service/entries.js.map +1 -0
  391. package/dist/services/document-service/entries.mjs +95 -0
  392. package/dist/services/document-service/entries.mjs.map +1 -0
  393. package/dist/services/document-service/index.d.ts +2 -4
  394. package/dist/services/document-service/index.d.ts.map +1 -1
  395. package/dist/services/document-service/index.js +21 -8
  396. package/dist/services/document-service/index.js.map +1 -1
  397. package/dist/services/document-service/index.mjs +17 -4
  398. package/dist/services/document-service/index.mjs.map +1 -1
  399. package/dist/services/document-service/internationalization.d.ts +5 -5
  400. package/dist/services/document-service/internationalization.d.ts.map +1 -1
  401. package/dist/services/document-service/internationalization.js.map +1 -1
  402. package/dist/services/document-service/internationalization.mjs.map +1 -1
  403. package/dist/services/document-service/middlewares/errors.d.ts +6 -0
  404. package/dist/services/document-service/middlewares/errors.d.ts.map +1 -0
  405. package/dist/services/document-service/middlewares/errors.js +25 -0
  406. package/dist/services/document-service/middlewares/errors.js.map +1 -0
  407. package/dist/services/document-service/middlewares/errors.mjs +25 -0
  408. package/dist/services/document-service/middlewares/errors.mjs.map +1 -0
  409. package/dist/services/document-service/middlewares/index.d.ts +3 -0
  410. package/dist/services/document-service/middlewares/index.d.ts.map +1 -0
  411. package/dist/services/document-service/middlewares/middleware-manager.d.ts +10 -0
  412. package/dist/services/document-service/middlewares/middleware-manager.d.ts.map +1 -0
  413. package/dist/services/document-service/{middlewares.js → middlewares/middleware-manager.js} +9 -6
  414. package/dist/services/document-service/middlewares/middleware-manager.js.map +1 -0
  415. package/dist/services/document-service/{middlewares.mjs → middlewares/middleware-manager.mjs} +9 -6
  416. package/dist/services/document-service/middlewares/middleware-manager.mjs.map +1 -0
  417. package/dist/services/document-service/params.d.ts +3 -1
  418. package/dist/services/document-service/params.d.ts.map +1 -1
  419. package/dist/services/{entity-service → document-service}/params.js +1 -1
  420. package/dist/services/document-service/params.js.map +1 -0
  421. package/dist/services/{entity-service → document-service}/params.mjs +1 -1
  422. package/dist/services/document-service/params.mjs.map +1 -0
  423. package/dist/services/document-service/repository.d.ts +3 -0
  424. package/dist/services/document-service/repository.d.ts.map +1 -0
  425. package/dist/services/document-service/repository.js +250 -0
  426. package/dist/services/document-service/repository.js.map +1 -0
  427. package/dist/services/document-service/repository.mjs +250 -0
  428. package/dist/services/document-service/repository.mjs.map +1 -0
  429. package/dist/services/document-service/transform/data.d.ts.map +1 -1
  430. package/dist/services/document-service/transform/data.js +4 -2
  431. package/dist/services/document-service/transform/data.js.map +1 -1
  432. package/dist/services/document-service/transform/data.mjs +4 -2
  433. package/dist/services/document-service/transform/data.mjs.map +1 -1
  434. package/dist/services/document-service/transform/fields.d.ts +2 -2
  435. package/dist/services/document-service/transform/fields.d.ts.map +1 -1
  436. package/dist/services/document-service/transform/fields.js.map +1 -1
  437. package/dist/services/document-service/transform/fields.mjs.map +1 -1
  438. package/dist/services/document-service/transform/id-map.d.ts +4 -4
  439. package/dist/services/document-service/transform/id-map.d.ts.map +1 -1
  440. package/dist/services/document-service/transform/id-map.js +15 -9
  441. package/dist/services/document-service/transform/id-map.js.map +1 -1
  442. package/dist/services/document-service/transform/id-map.mjs +16 -10
  443. package/dist/services/document-service/transform/id-map.mjs.map +1 -1
  444. package/dist/services/document-service/transform/id-transform.d.ts +4 -18
  445. package/dist/services/document-service/transform/id-transform.d.ts.map +1 -1
  446. package/dist/services/document-service/transform/id-transform.js +18 -12
  447. package/dist/services/document-service/transform/id-transform.js.map +1 -1
  448. package/dist/services/document-service/transform/id-transform.mjs +18 -12
  449. package/dist/services/document-service/transform/id-transform.mjs.map +1 -1
  450. package/dist/services/document-service/transform/populate.d.ts +5 -2
  451. package/dist/services/document-service/transform/populate.d.ts.map +1 -1
  452. package/dist/services/document-service/transform/populate.js +1 -1
  453. package/dist/services/document-service/transform/populate.js.map +1 -1
  454. package/dist/services/document-service/transform/populate.mjs +1 -1
  455. package/dist/services/document-service/transform/populate.mjs.map +1 -1
  456. package/dist/services/document-service/transform/query.d.ts +5 -0
  457. package/dist/services/document-service/transform/query.d.ts.map +1 -0
  458. package/dist/services/document-service/transform/query.js +9 -0
  459. package/dist/services/document-service/transform/query.js.map +1 -0
  460. package/dist/services/document-service/transform/query.mjs +9 -0
  461. package/dist/services/document-service/transform/query.mjs.map +1 -0
  462. package/dist/services/document-service/transform/relations/extract/data-ids.d.ts +8 -7
  463. package/dist/services/document-service/transform/relations/extract/data-ids.d.ts.map +1 -1
  464. package/dist/services/document-service/transform/relations/extract/data-ids.js +43 -68
  465. package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -1
  466. package/dist/services/document-service/transform/relations/extract/data-ids.mjs +43 -68
  467. package/dist/services/document-service/transform/relations/extract/data-ids.mjs.map +1 -1
  468. package/dist/services/document-service/transform/relations/transform/data-ids.d.ts +9 -5
  469. package/dist/services/document-service/transform/relations/transform/data-ids.d.ts.map +1 -1
  470. package/dist/services/document-service/transform/relations/transform/data-ids.js +61 -105
  471. package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
  472. package/dist/services/document-service/transform/relations/transform/data-ids.mjs +62 -106
  473. package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
  474. package/dist/services/document-service/transform/relations/transform/default-locale.d.ts +9 -0
  475. package/dist/services/document-service/transform/relations/transform/default-locale.d.ts.map +1 -0
  476. package/dist/services/document-service/transform/relations/transform/default-locale.js +32 -0
  477. package/dist/services/document-service/transform/relations/transform/default-locale.js.map +1 -0
  478. package/dist/services/document-service/transform/relations/transform/default-locale.mjs +32 -0
  479. package/dist/services/document-service/transform/relations/transform/default-locale.mjs.map +1 -0
  480. package/dist/services/document-service/transform/relations/utils/dp.d.ts +10 -0
  481. package/dist/services/document-service/transform/relations/utils/dp.d.ts.map +1 -0
  482. package/dist/services/document-service/transform/relations/utils/dp.js +30 -0
  483. package/dist/services/document-service/transform/relations/utils/dp.js.map +1 -0
  484. package/dist/services/document-service/transform/relations/utils/dp.mjs +30 -0
  485. package/dist/services/document-service/transform/relations/utils/dp.mjs.map +1 -0
  486. package/dist/services/document-service/transform/relations/utils/i18n.d.ts +6 -6
  487. package/dist/services/document-service/transform/relations/utils/i18n.d.ts.map +1 -1
  488. package/dist/services/document-service/transform/relations/utils/i18n.js +3 -9
  489. package/dist/services/document-service/transform/relations/utils/i18n.js.map +1 -1
  490. package/dist/services/document-service/transform/relations/utils/i18n.mjs +3 -9
  491. package/dist/services/document-service/transform/relations/utils/i18n.mjs.map +1 -1
  492. package/dist/services/document-service/transform/relations/utils/map-relation.d.ts +6 -0
  493. package/dist/services/document-service/transform/relations/utils/map-relation.d.ts.map +1 -0
  494. package/dist/services/document-service/transform/relations/utils/map-relation.js +87 -0
  495. package/dist/services/document-service/transform/relations/utils/map-relation.js.map +1 -0
  496. package/dist/services/document-service/transform/relations/utils/map-relation.mjs +87 -0
  497. package/dist/services/document-service/transform/relations/utils/map-relation.mjs.map +1 -0
  498. package/dist/services/document-service/transform/relations/utils/types.d.ts +10 -1
  499. package/dist/services/document-service/transform/relations/utils/types.d.ts.map +1 -1
  500. package/dist/services/document-service/transform/types.d.ts +4 -4
  501. package/dist/services/document-service/transform/types.d.ts.map +1 -1
  502. package/dist/services/document-service/utils/populate.d.ts +9 -2
  503. package/dist/services/document-service/utils/populate.d.ts.map +1 -1
  504. package/dist/services/document-service/utils/populate.js +5 -5
  505. package/dist/services/document-service/utils/populate.js.map +1 -1
  506. package/dist/services/document-service/utils/populate.mjs +5 -5
  507. package/dist/services/document-service/utils/populate.mjs.map +1 -1
  508. package/dist/services/entity-service/index.d.ts +4 -6
  509. package/dist/services/entity-service/index.d.ts.map +1 -1
  510. package/dist/services/entity-service/index.js +44 -203
  511. package/dist/services/entity-service/index.js.map +1 -1
  512. package/dist/services/entity-service/index.mjs +38 -197
  513. package/dist/services/entity-service/index.mjs.map +1 -1
  514. package/dist/services/entity-validator/index.d.ts +2 -2
  515. package/dist/services/entity-validator/index.d.ts.map +1 -1
  516. package/dist/services/entity-validator/index.js +101 -90
  517. package/dist/services/entity-validator/index.js.map +1 -1
  518. package/dist/services/entity-validator/index.mjs +101 -90
  519. package/dist/services/entity-validator/index.mjs.map +1 -1
  520. package/dist/services/entity-validator/validators.d.ts +18 -18
  521. package/dist/services/entity-validator/validators.d.ts.map +1 -1
  522. package/dist/services/entity-validator/validators.js +6 -1
  523. package/dist/services/entity-validator/validators.js.map +1 -1
  524. package/dist/services/entity-validator/validators.mjs +6 -1
  525. package/dist/services/entity-validator/validators.mjs.map +1 -1
  526. package/dist/services/features.d.ts +3 -3
  527. package/dist/services/features.d.ts.map +1 -1
  528. package/dist/services/features.js.map +1 -1
  529. package/dist/services/features.mjs.map +1 -1
  530. package/dist/services/fs.d.ts +2 -2
  531. package/dist/services/fs.d.ts.map +1 -1
  532. package/dist/services/fs.js.map +1 -1
  533. package/dist/services/fs.mjs.map +1 -1
  534. package/dist/services/metrics/admin-user-hash.d.ts +2 -2
  535. package/dist/services/metrics/admin-user-hash.d.ts.map +1 -1
  536. package/dist/services/metrics/admin-user-hash.js.map +1 -1
  537. package/dist/services/metrics/admin-user-hash.mjs.map +1 -1
  538. package/dist/services/metrics/index.d.ts +2 -2
  539. package/dist/services/metrics/index.d.ts.map +1 -1
  540. package/dist/services/metrics/index.js.map +1 -1
  541. package/dist/services/metrics/index.mjs.map +1 -1
  542. package/dist/services/metrics/middleware.d.ts +2 -2
  543. package/dist/services/metrics/middleware.d.ts.map +1 -1
  544. package/dist/services/metrics/middleware.js.map +1 -1
  545. package/dist/services/metrics/middleware.mjs.map +1 -1
  546. package/dist/services/metrics/rate-limiter.d.ts.map +1 -1
  547. package/dist/services/metrics/rate-limiter.js.map +1 -1
  548. package/dist/services/metrics/rate-limiter.mjs.map +1 -1
  549. package/dist/services/metrics/sender.d.ts +3 -3
  550. package/dist/services/metrics/sender.d.ts.map +1 -1
  551. package/dist/services/metrics/sender.js.map +1 -1
  552. package/dist/services/metrics/sender.mjs.map +1 -1
  553. package/dist/services/query-params.d.ts +7 -0
  554. package/dist/services/query-params.d.ts.map +1 -0
  555. package/dist/services/query-params.js +12 -0
  556. package/dist/services/query-params.js.map +1 -0
  557. package/dist/services/query-params.mjs +13 -0
  558. package/dist/services/query-params.mjs.map +1 -0
  559. package/dist/services/reloader.d.ts +7 -0
  560. package/dist/services/reloader.d.ts.map +1 -0
  561. package/dist/services/reloader.js +36 -0
  562. package/dist/services/reloader.js.map +1 -0
  563. package/dist/services/reloader.mjs +36 -0
  564. package/dist/services/reloader.mjs.map +1 -0
  565. package/dist/services/server/admin-api.d.ts +3 -3
  566. package/dist/services/server/admin-api.d.ts.map +1 -1
  567. package/dist/services/server/admin-api.js.map +1 -1
  568. package/dist/services/server/admin-api.mjs.map +1 -1
  569. package/dist/services/server/api.d.ts +3 -3
  570. package/dist/services/server/api.d.ts.map +1 -1
  571. package/dist/services/server/api.js.map +1 -1
  572. package/dist/services/server/api.mjs.map +1 -1
  573. package/dist/services/server/compose-endpoint.d.ts +2 -2
  574. package/dist/services/server/compose-endpoint.d.ts.map +1 -1
  575. package/dist/services/server/compose-endpoint.js +1 -2
  576. package/dist/services/server/compose-endpoint.js.map +1 -1
  577. package/dist/services/server/compose-endpoint.mjs +2 -3
  578. package/dist/services/server/compose-endpoint.mjs.map +1 -1
  579. package/dist/services/server/content-api.d.ts +3 -3
  580. package/dist/services/server/content-api.d.ts.map +1 -1
  581. package/dist/services/server/content-api.js.map +1 -1
  582. package/dist/services/server/content-api.mjs.map +1 -1
  583. package/dist/services/server/http-server.d.ts +2 -2
  584. package/dist/services/server/http-server.d.ts.map +1 -1
  585. package/dist/services/server/http-server.js.map +1 -1
  586. package/dist/services/server/http-server.mjs.map +1 -1
  587. package/dist/services/server/index.d.ts +2 -2
  588. package/dist/services/server/index.d.ts.map +1 -1
  589. package/dist/services/server/index.js +1 -2
  590. package/dist/services/server/index.js.map +1 -1
  591. package/dist/services/server/index.mjs +1 -2
  592. package/dist/services/server/index.mjs.map +1 -1
  593. package/dist/services/server/koa.d.ts.map +1 -1
  594. package/dist/services/server/middleware.d.ts +4 -4
  595. package/dist/services/server/middleware.d.ts.map +1 -1
  596. package/dist/services/server/middleware.js.map +1 -1
  597. package/dist/services/server/middleware.mjs.map +1 -1
  598. package/dist/services/server/policy.d.ts +3 -3
  599. package/dist/services/server/policy.d.ts.map +1 -1
  600. package/dist/services/server/policy.js +4 -4
  601. package/dist/services/server/policy.js.map +1 -1
  602. package/dist/services/server/policy.mjs +4 -4
  603. package/dist/services/server/policy.mjs.map +1 -1
  604. package/dist/services/server/register-middlewares.d.ts +2 -2
  605. package/dist/services/server/register-middlewares.d.ts.map +1 -1
  606. package/dist/services/server/register-middlewares.js.map +1 -1
  607. package/dist/services/server/register-middlewares.mjs.map +1 -1
  608. package/dist/services/server/register-routes.d.ts +2 -2
  609. package/dist/services/server/register-routes.d.ts.map +1 -1
  610. package/dist/services/server/register-routes.js +3 -3
  611. package/dist/services/server/register-routes.js.map +1 -1
  612. package/dist/services/server/register-routes.mjs +3 -3
  613. package/dist/services/server/register-routes.mjs.map +1 -1
  614. package/dist/services/server/routing.d.ts +5 -5
  615. package/dist/services/server/routing.d.ts.map +1 -1
  616. package/dist/services/server/routing.js.map +1 -1
  617. package/dist/services/server/routing.mjs.map +1 -1
  618. package/dist/services/utils/dynamic-zones.d.ts.map +1 -1
  619. package/dist/services/utils/dynamic-zones.js +2 -1
  620. package/dist/services/utils/dynamic-zones.js.map +1 -1
  621. package/dist/services/utils/dynamic-zones.mjs +2 -1
  622. package/dist/services/utils/dynamic-zones.mjs.map +1 -1
  623. package/dist/services/webhook-runner.js.map +1 -1
  624. package/dist/services/webhook-runner.mjs.map +1 -1
  625. package/dist/services/webhook-store.d.ts.map +1 -1
  626. package/dist/services/webhook-store.js +5 -6
  627. package/dist/services/webhook-store.js.map +1 -1
  628. package/dist/services/webhook-store.mjs +5 -6
  629. package/dist/services/webhook-store.mjs.map +1 -1
  630. package/dist/utils/convert-custom-field-type.d.ts +2 -2
  631. package/dist/utils/convert-custom-field-type.d.ts.map +1 -1
  632. package/dist/utils/convert-custom-field-type.js.map +1 -1
  633. package/dist/utils/convert-custom-field-type.mjs.map +1 -1
  634. package/dist/utils/fetch.d.ts +3 -3
  635. package/dist/utils/fetch.d.ts.map +1 -1
  636. package/dist/utils/fetch.js.map +1 -1
  637. package/dist/utils/fetch.mjs.map +1 -1
  638. package/dist/utils/index.d.ts +2 -1
  639. package/dist/utils/index.d.ts.map +1 -1
  640. package/dist/utils/is-initialized.d.ts +2 -2
  641. package/dist/utils/is-initialized.d.ts.map +1 -1
  642. package/dist/utils/is-initialized.js +1 -1
  643. package/dist/utils/is-initialized.js.map +1 -1
  644. package/dist/utils/is-initialized.mjs +1 -1
  645. package/dist/utils/is-initialized.mjs.map +1 -1
  646. package/dist/utils/load-config-file.js +1 -1
  647. package/dist/utils/load-config-file.js.map +1 -1
  648. package/dist/utils/load-config-file.mjs +2 -2
  649. package/dist/utils/load-config-file.mjs.map +1 -1
  650. package/dist/utils/load-files.d.ts.map +1 -1
  651. package/dist/utils/open-browser.d.ts +2 -2
  652. package/dist/utils/open-browser.d.ts.map +1 -1
  653. package/dist/utils/open-browser.js.map +1 -1
  654. package/dist/utils/open-browser.mjs.map +1 -1
  655. package/dist/utils/resolve-working-dirs.d.ts +19 -0
  656. package/dist/utils/resolve-working-dirs.d.ts.map +1 -0
  657. package/dist/utils/resolve-working-dirs.js +13 -0
  658. package/dist/utils/resolve-working-dirs.js.map +1 -0
  659. package/dist/utils/resolve-working-dirs.mjs +11 -0
  660. package/dist/utils/resolve-working-dirs.mjs.map +1 -0
  661. package/dist/utils/signals.d.ts +2 -2
  662. package/dist/utils/signals.d.ts.map +1 -1
  663. package/dist/utils/signals.js.map +1 -1
  664. package/dist/utils/signals.mjs.map +1 -1
  665. package/dist/utils/startup-logger.d.ts +2 -2
  666. package/dist/utils/startup-logger.d.ts.map +1 -1
  667. package/dist/utils/startup-logger.js.map +1 -1
  668. package/dist/utils/startup-logger.mjs.map +1 -1
  669. package/dist/utils/transform-content-types-to-models.d.ts +54 -99
  670. package/dist/utils/transform-content-types-to-models.d.ts.map +1 -1
  671. package/dist/utils/transform-content-types-to-models.js +95 -57
  672. package/dist/utils/transform-content-types-to-models.js.map +1 -1
  673. package/dist/utils/transform-content-types-to-models.mjs +95 -57
  674. package/dist/utils/transform-content-types-to-models.mjs.map +1 -1
  675. package/dist/utils/update-notifier/index.d.ts +2 -7
  676. package/dist/utils/update-notifier/index.d.ts.map +1 -1
  677. package/dist/utils/update-notifier/index.js +11 -14
  678. package/dist/utils/update-notifier/index.js.map +1 -1
  679. package/dist/utils/update-notifier/index.mjs +11 -14
  680. package/dist/utils/update-notifier/index.mjs.map +1 -1
  681. package/package.json +23 -23
  682. package/dist/registries/config.d.ts +0 -4
  683. package/dist/registries/config.d.ts.map +0 -1
  684. package/dist/registries/config.js +0 -23
  685. package/dist/registries/config.js.map +0 -1
  686. package/dist/registries/config.mjs +0 -22
  687. package/dist/registries/config.mjs.map +0 -1
  688. package/dist/services/document-service/document-engine.js +0 -241
  689. package/dist/services/document-service/document-engine.js.map +0 -1
  690. package/dist/services/document-service/document-engine.mjs +0 -242
  691. package/dist/services/document-service/document-engine.mjs.map +0 -1
  692. package/dist/services/document-service/middlewares.d.ts +0 -8
  693. package/dist/services/document-service/middlewares.d.ts.map +0 -1
  694. package/dist/services/document-service/middlewares.js.map +0 -1
  695. package/dist/services/document-service/middlewares.mjs.map +0 -1
  696. package/dist/services/document-service/repositories/content-type.d.ts +0 -3
  697. package/dist/services/document-service/repositories/content-type.d.ts.map +0 -1
  698. package/dist/services/document-service/repositories/content-type.js +0 -139
  699. package/dist/services/document-service/repositories/content-type.js.map +0 -1
  700. package/dist/services/document-service/repositories/content-type.mjs +0 -139
  701. package/dist/services/document-service/repositories/content-type.mjs.map +0 -1
  702. package/dist/services/document-service/transform/filters.d.ts +0 -3
  703. package/dist/services/document-service/transform/filters.d.ts.map +0 -1
  704. package/dist/services/document-service/transform/relations/transform/output-ids.d.ts +0 -4
  705. package/dist/services/document-service/transform/relations/transform/output-ids.d.ts.map +0 -1
  706. package/dist/services/document-service/transform/relations/utils/data.js +0 -12
  707. package/dist/services/document-service/transform/relations/utils/data.js.map +0 -1
  708. package/dist/services/document-service/transform/relations/utils/data.mjs +0 -12
  709. package/dist/services/document-service/transform/relations/utils/data.mjs.map +0 -1
  710. package/dist/services/document-service/transform/sort.d.ts +0 -5
  711. package/dist/services/document-service/transform/sort.d.ts.map +0 -1
  712. package/dist/services/document-service/transform/utils.d.ts +0 -9
  713. package/dist/services/document-service/transform/utils.d.ts.map +0 -1
  714. package/dist/services/entity-service/attributes/index.d.ts +0 -6
  715. package/dist/services/entity-service/attributes/index.d.ts.map +0 -1
  716. package/dist/services/entity-service/attributes/index.js.map +0 -1
  717. package/dist/services/entity-service/attributes/index.mjs.map +0 -1
  718. package/dist/services/entity-service/attributes/transforms.d.ts +0 -10
  719. package/dist/services/entity-service/attributes/transforms.d.ts.map +0 -1
  720. package/dist/services/entity-service/attributes/transforms.js.map +0 -1
  721. package/dist/services/entity-service/attributes/transforms.mjs.map +0 -1
  722. package/dist/services/entity-service/components.d.ts +0 -23
  723. package/dist/services/entity-service/components.d.ts.map +0 -1
  724. package/dist/services/entity-service/components.js.map +0 -1
  725. package/dist/services/entity-service/components.mjs.map +0 -1
  726. package/dist/services/entity-service/params.d.ts +0 -8
  727. package/dist/services/entity-service/params.d.ts.map +0 -1
  728. package/dist/services/entity-service/params.js.map +0 -1
  729. package/dist/services/entity-service/params.mjs.map +0 -1
  730. package/dist/services/utils/upload-files.d.ts +0 -8
  731. package/dist/services/utils/upload-files.d.ts.map +0 -1
  732. package/dist/services/utils/upload-files.js +0 -64
  733. package/dist/services/utils/upload-files.js.map +0 -1
  734. package/dist/services/utils/upload-files.mjs +0 -63
  735. package/dist/services/utils/upload-files.mjs.map +0 -1
  736. package/dist/utils/get-dirs.d.ts +0 -9
  737. package/dist/utils/get-dirs.d.ts.map +0 -1
  738. package/dist/utils/get-dirs.js.map +0 -1
  739. package/dist/utils/get-dirs.mjs.map +0 -1
  740. /package/dist/services/{entity-service → document-service}/attributes/transforms.js +0 -0
  741. /package/dist/services/{entity-service → document-service}/attributes/transforms.mjs +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.mjs","sources":["../../../src/services/document-service/components.ts"],"sourcesContent":["import _ from 'lodash';\nimport { has, omit, pipe, assign, curry } from 'lodash/fp';\nimport type { Utils, UID, Schema, Data, Modules } from '@strapi/types';\nimport { contentTypes as contentTypesUtils, async, errors } from '@strapi/utils';\n\n// type aliases for readability\ntype Input<T extends UID.Schema> = Modules.Documents.Params.Data.Input<T>;\n\ntype LoadedComponents<TUID extends UID.Schema> = Data.Entity<\n TUID,\n Schema.AttributeNamesByType<TUID, 'component' | 'dynamiczone'>\n>;\n\ntype SingleComponentValue = Schema.Attribute.ComponentValue<UID.Component, false>;\ntype RepeatableComponentValue = Schema.Attribute.ComponentValue<UID.Component, true>;\n\ntype ComponentValue = SingleComponentValue | RepeatableComponentValue;\n\ntype DynamicZoneValue = Schema.Attribute.DynamicZoneValue<UID.Component[]>;\n\ntype ComponentBody = {\n [key: string]: ComponentValue | DynamicZoneValue;\n};\n\nconst omitComponentData = curry(\n (schema: Schema.Schema, data: Input<UID.Schema>): Partial<Input<UID.Schema>> => {\n const { attributes } = schema;\n const componentAttributes = Object.keys(attributes).filter((attributeName) =>\n contentTypesUtils.isComponentAttribute(attributes[attributeName])\n );\n\n return omit(componentAttributes, data);\n }\n);\n\n// NOTE: we could generalize the logic to allow CRUD of relation directly in the DB layer\nconst createComponents = async <TUID extends UID.Schema, TData extends Input<TUID>>(\n uid: TUID,\n data: TData\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const componentBody: ComponentBody = {};\n\n const attributeNames = Object.keys(attributes);\n\n for (const attributeName of attributeNames) {\n const attribute = attributes[attributeName];\n\n if (!has(attributeName, data) || !contentTypesUtils.isComponentAttribute(attribute)) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID, repeatable = false } = attribute;\n\n const componentValue = data[attributeName as keyof TData];\n\n if (componentValue === null) {\n continue;\n }\n\n if (repeatable === true) {\n if (!Array.isArray(componentValue)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n const components: RepeatableComponentValue = await async.map(componentValue, (value: any) =>\n createComponent(componentUID, value)\n );\n\n componentBody[attributeName] = components.map(({ id }) => {\n return {\n id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n });\n } else {\n const component = await createComponent(\n componentUID,\n componentValue as Input<UID.Component>\n );\n\n componentBody[attributeName] = {\n id: component.id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n }\n\n continue;\n }\n\n if (attribute.type === 'dynamiczone') {\n const dynamiczoneValues = data[\n attributeName as keyof TData\n ] as Modules.EntityService.Params.Attribute.GetValue<Schema.Attribute.DynamicZone>;\n\n if (!Array.isArray(dynamiczoneValues)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n const createDynamicZoneComponents = async (\n value: Utils.Array.Values<typeof dynamiczoneValues>\n ) => {\n const { id } = await createComponent(value.__component, value);\n return {\n id,\n __component: value.__component,\n __pivot: {\n field: attributeName,\n },\n };\n };\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n componentBody[attributeName] = await async.map(\n dynamiczoneValues,\n createDynamicZoneComponents\n );\n\n continue;\n }\n }\n\n return componentBody;\n};\n\nconst getComponents = async <TUID extends UID.Schema>(\n uid: TUID,\n entity: { id: Modules.EntityService.Params.Attribute.ID }\n): Promise<LoadedComponents<TUID>> => {\n const componentAttributes = contentTypesUtils.getComponentAttributes(strapi.getModel(uid));\n\n if (_.isEmpty(componentAttributes)) {\n return {} as LoadedComponents<TUID>;\n }\n\n return strapi.db.query(uid).load(entity, componentAttributes) as Promise<LoadedComponents<TUID>>;\n};\n\n/*\n delete old components\n create or update\n*/\nconst updateComponents = async <TUID extends UID.Schema, TData extends Partial<Input<TUID>>>(\n uid: TUID,\n entityToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n data: TData\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const componentBody: ComponentBody = {};\n\n for (const attributeName of Object.keys(attributes)) {\n const attribute = attributes[attributeName];\n\n if (!has(attributeName, data)) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID, repeatable = false } = attribute;\n\n const componentValue = data[attributeName as keyof TData] as ComponentValue;\n\n await deleteOldComponents(uid, componentUID, entityToUpdate, attributeName, componentValue);\n\n if (repeatable === true) {\n if (!Array.isArray(componentValue)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n const components: RepeatableComponentValue = await async.map(componentValue, (value: any) =>\n updateOrCreateComponent(componentUID, value)\n );\n\n componentBody[attributeName] = components.filter(_.negate(_.isNil)).map(({ id }) => {\n return {\n id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n });\n } else {\n const component = await updateOrCreateComponent(componentUID, componentValue);\n componentBody[attributeName] = component && {\n id: component.id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n }\n } else if (attribute.type === 'dynamiczone') {\n const dynamiczoneValues = data[attributeName as keyof TData] as DynamicZoneValue;\n\n await deleteOldDZComponents(uid, entityToUpdate, attributeName, dynamiczoneValues);\n\n if (!Array.isArray(dynamiczoneValues)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n componentBody[attributeName] = await async.map(dynamiczoneValues, async (value: any) => {\n const { id } = await updateOrCreateComponent(value.__component, value);\n\n return {\n id,\n __component: value.__component,\n __pivot: {\n field: attributeName,\n },\n };\n });\n }\n }\n\n return componentBody;\n};\n\nconst pickStringifiedId = ({\n id,\n}: {\n id: Modules.EntityService.Params.Attribute.ID;\n}): Modules.EntityService.Params.Attribute.ID & string => {\n if (typeof id === 'string') {\n return id;\n }\n\n return `${id}`;\n};\n\nconst deleteOldComponents = async <TUID extends UID.Schema>(\n uid: TUID,\n componentUID: UID.Component,\n entityToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n attributeName: string,\n componentValue: ComponentValue\n) => {\n const previousValue = (await strapi.db\n .query(uid)\n .load(entityToUpdate, attributeName)) as ComponentValue;\n\n const idsToKeep = _.castArray(componentValue).filter(has('id')).map(pickStringifiedId);\n const allIds = _.castArray(previousValue).filter(has('id')).map(pickStringifiedId);\n\n idsToKeep.forEach((id) => {\n if (!allIds.includes(id)) {\n throw new errors.ApplicationError(\n `Some of the provided components in ${attributeName} are not related to the entity`\n );\n }\n });\n\n const idsToDelete = _.difference(allIds, idsToKeep);\n\n if (idsToDelete.length > 0) {\n for (const idToDelete of idsToDelete) {\n await deleteComponent(componentUID, { id: idToDelete });\n }\n }\n};\n\nconst deleteOldDZComponents = async <TUID extends UID.Schema>(\n uid: TUID,\n entityToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n attributeName: string,\n dynamiczoneValues: DynamicZoneValue\n) => {\n const previousValue = (await strapi.db\n .query(uid)\n .load(entityToUpdate, attributeName)) as DynamicZoneValue;\n\n const idsToKeep = _.castArray(dynamiczoneValues)\n .filter(has('id'))\n .map((v) => ({\n id: pickStringifiedId(v),\n __component: v.__component,\n }));\n\n const allIds = _.castArray(previousValue)\n .filter(has('id'))\n .map((v) => ({\n id: pickStringifiedId(v),\n __component: v.__component,\n }));\n\n idsToKeep.forEach(({ id, __component }) => {\n if (!allIds.find((el) => el.id === id && el.__component === __component)) {\n const err = new Error(\n `Some of the provided components in ${attributeName} are not related to the entity`\n );\n\n Object.assign(err, { status: 400 });\n throw err;\n }\n });\n\n type IdsToDelete = DynamicZoneValue;\n\n const idsToDelete = allIds.reduce((acc, { id, __component }) => {\n if (!idsToKeep.find((el) => el.id === id && el.__component === __component)) {\n acc.push({ id, __component });\n }\n\n return acc;\n }, [] as IdsToDelete);\n\n if (idsToDelete.length > 0) {\n for (const idToDelete of idsToDelete) {\n const { id, __component } = idToDelete;\n await deleteComponent(__component, { id });\n }\n }\n};\n\nconst deleteComponents = async <TUID extends UID.Schema, TEntity extends Data.Entity<TUID>>(\n uid: TUID,\n entityToDelete: TEntity,\n { loadComponents = true } = {}\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const attributeNames = Object.keys(attributes);\n\n for (const attributeName of attributeNames) {\n const attribute = attributes[attributeName];\n\n if (attribute.type === 'component' || attribute.type === 'dynamiczone') {\n let value;\n\n if (loadComponents) {\n value = await strapi.db.query(uid).load(entityToDelete, attributeName);\n } else {\n value = entityToDelete[attributeName as keyof TEntity];\n }\n\n if (!value) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID } = attribute;\n await async.map(_.castArray(value), (subValue: any) =>\n deleteComponent(componentUID, subValue)\n );\n } else {\n await async.map(_.castArray(value), (subValue: any) =>\n deleteComponent(subValue.__component, subValue)\n );\n }\n\n continue;\n }\n }\n};\n\n/** *************************\n Component queries\n************************** */\n\n// components can have nested compos so this must be recursive\nconst createComponent = async <TUID extends UID.Component>(uid: TUID, data: Input<TUID>) => {\n const schema = strapi.getModel(uid);\n\n const componentData = await createComponents(uid, data);\n\n const transform = pipe(\n // Make sure we don't save the component with a pre-defined ID\n omit('id'),\n assignComponentData(schema, componentData)\n );\n\n return strapi.db.query(uid).create({ data: transform(data) });\n};\n\n// components can have nested compos so this must be recursive\nconst updateComponent = async <TUID extends UID.Component>(\n uid: TUID,\n componentToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n data: Input<TUID>\n) => {\n const schema = strapi.getModel(uid);\n\n const componentData = await updateComponents(uid, componentToUpdate, data);\n\n return strapi.db.query(uid).update({\n where: {\n id: componentToUpdate.id,\n },\n data: assignComponentData(schema, componentData, data),\n });\n};\n\nconst updateOrCreateComponent = <TUID extends UID.Component>(\n componentUID: TUID,\n value: Input<TUID>\n) => {\n if (value === null) {\n return null;\n }\n\n // update\n if ('id' in value && typeof value.id !== 'undefined') {\n // TODO: verify the compo is associated with the entity\n return updateComponent(componentUID, { id: value.id }, value);\n }\n\n // create\n return createComponent(componentUID, value);\n};\n\nconst deleteComponent = async <TUID extends UID.Component>(\n uid: TUID,\n componentToDelete: Data.Component<TUID>\n) => {\n await deleteComponents(uid, componentToDelete);\n await strapi.db.query(uid).delete({ where: { id: componentToDelete.id } });\n};\n\nconst assignComponentData = curry(\n (schema: Schema.Schema, componentData: ComponentBody, data: Input<UID.Schema>) => {\n return pipe(omitComponentData(schema), assign(componentData))(data);\n }\n);\n\nexport {\n omitComponentData,\n assignComponentData,\n getComponents,\n createComponents,\n updateComponents,\n deleteComponents,\n deleteComponent,\n};\n"],"names":["contentTypesUtils"],"mappings":";;;AAwBA,MAAM,oBAAoB;AAAA,EACxB,CAAC,QAAuB,SAAwD;AACxE,UAAA,EAAE,WAAe,IAAA;AACvB,UAAM,sBAAsB,OAAO,KAAK,UAAU,EAAE;AAAA,MAAO,CAAC,kBAC1DA,aAAkB,qBAAqB,WAAW,aAAa,CAAC;AAAA,IAAA;AAG3D,WAAA,KAAK,qBAAqB,IAAI;AAAA,EACvC;AACF;AAGM,MAAA,mBAAmB,OACvB,KACA,SACG;AACH,QAAM,EAAE,aAAa,OAAO,OAAO,SAAS,GAAG;AAE/C,QAAM,gBAA+B,CAAA;AAE/B,QAAA,iBAAiB,OAAO,KAAK,UAAU;AAE7C,aAAW,iBAAiB,gBAAgB;AACpC,UAAA,YAAY,WAAW,aAAa;AAEtC,QAAA,CAAC,IAAI,eAAe,IAAI,KAAK,CAACA,aAAkB,qBAAqB,SAAS,GAAG;AACnF;AAAA,IACF;AAEI,QAAA,UAAU,SAAS,aAAa;AAClC,YAAM,EAAE,WAAW,cAAc,aAAa,UAAU;AAElD,YAAA,iBAAiB,KAAK,aAA4B;AAExD,UAAI,mBAAmB,MAAM;AAC3B;AAAA,MACF;AAEA,UAAI,eAAe,MAAM;AACvB,YAAI,CAAC,MAAM,QAAQ,cAAc,GAAG;AAC5B,gBAAA,IAAI,MAAM,kDAAkD;AAAA,QACpE;AAEM,cAAA,aAAuC,MAAM,MAAM;AAAA,UAAI;AAAA,U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AAGA,MAAI,QAAQ,SAAS,OAAO,MAAM,OAAO,aAAa;AAEpD,WAAO,gBAAgB,cAAc,EAAE,IAAI,MAAM,GAAA,GAAM,KAAK;AAAA,EAC9D;AAGO,SAAA,gBAAgB,cAAc,KAAK;AAC5C;AAEM,MAAA,kBAAkB,OACtB,KACA,sBACG;AACG,QAAA,iBAAiB,KAAK,iBAAiB;AAC7C,QAAM,OAAO,GAAG,MAAM,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,kBAAkB,GAAA,EAAM,CAAA;AAC3E;AAEA,MAAM,sBAAsB;AAAA,EAC1B,CAAC,QAAuB,eAA8B,SAA4B;AACzE,WAAA,KAAK,kBAAkB,MAAM,GAAG,OAAO,aAAa,CAAC,EAAE,IAAI;AAAA,EACpE;AACF;"}
@@ -1,8 +1 @@
1
- import type { Database } from '@strapi/database';
2
- import type { Documents, Strapi } from '@strapi/types';
3
- declare const _default: (ctx: {
4
- strapi: Strapi;
5
- db: Database;
6
- }) => Documents.Engine;
7
- export default _default;
8
1
  //# sourceMappingURL=document-engine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"document-engine.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/document-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAU,MAAM,EAAE,MAAM,eAAe,CAAC;8BAkV1C;IAAE,QAAQ,MAAM,CAAC;IAAC,EAAE,EAAE,QAAQ,CAAA;CAAE,KAAG,UAAU,MAAM;AAAxE,wBAKE"}
1
+ {"version":3,"file":"document-engine.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/document-engine.ts"],"names":[],"mappings":""}
@@ -1,24 +1,10 @@
1
- import { Documents } from '@strapi/types';
2
- type ParamsTransform = (params: Documents.Params.All) => Documents.Params.All;
3
- /**
4
- * Sets status to draft only
5
- */
6
- export declare const setStatusToDraft: ParamsTransform;
7
- /**
8
- * Adds a default status of `draft` to the params
9
- */
10
- export declare const defaultToDraft: ParamsTransform;
11
- /**
12
- * In mutating actions we don't want user to set the publishedAt attribute.
13
- */
14
- export declare const filterDataPublishedAt: ParamsTransform;
15
- /**
16
- * Add status lookup query to the params
17
- */
18
- export declare const statusToLookup: ParamsTransform;
19
- /**
20
- * Translate publication status parameter into the data that will be saved
21
- */
22
- export declare const statusToData: ParamsTransform;
23
- export {};
1
+ /// <reference types="lodash" />
2
+ import { Modules, Struct } from '@strapi/types';
3
+ declare const setStatusToDraftCurry: import("lodash").CurriedFunction2<Struct.SingleTypeSchema | Struct.CollectionTypeSchema, Modules.Documents.Params.All, Modules.Documents.Params.All>;
4
+ declare const defaultToDraftCurry: import("lodash").CurriedFunction1<Modules.Documents.Params.All, Modules.Documents.Params.All>;
5
+ declare const defaultStatusCurry: import("lodash").CurriedFunction2<Struct.SingleTypeSchema | Struct.CollectionTypeSchema, Modules.Documents.Params.All, Modules.Documents.Params.All>;
6
+ declare const filterDataPublishedAtCurry: import("lodash").CurriedFunction1<Modules.Documents.Params.All, Modules.Documents.Params.All>;
7
+ declare const statusToLookupCurry: import("lodash").CurriedFunction2<Struct.SingleTypeSchema | Struct.CollectionTypeSchema, Modules.Documents.Params.All, Modules.Documents.Params.All>;
8
+ declare const statusToDataCurry: import("lodash").CurriedFunction2<Struct.SingleTypeSchema | Struct.CollectionTypeSchema, Modules.Documents.Params.All, Modules.Documents.Params.All>;
9
+ export { setStatusToDraftCurry as setStatusToDraft, defaultToDraftCurry as defaultToDraft, defaultStatusCurry as defaultStatus, filterDataPublishedAtCurry as filterDataPublishedAt, statusToLookupCurry as statusToLookup, statusToDataCurry as statusToData, };
24
10
  //# sourceMappingURL=draft-and-publish.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"draft-and-publish.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/draft-and-publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,KAAK,eAAe,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,KAAK,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,eAA0C,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,eAO5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,eAMnC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,eAa5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,eAW1B,CAAC"}
1
+ {"version":3,"file":"draft-and-publish.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/draft-and-publish.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAwGhD,QAAA,MAAM,qBAAqB,sJAA0B,CAAC;AACtD,QAAA,MAAM,mBAAmB,+FAAwB,CAAC;AAClD,QAAA,MAAM,kBAAkB,sJAAuB,CAAC;AAChD,QAAA,MAAM,0BAA0B,+FAA+B,CAAC;AAChE,QAAA,MAAM,mBAAmB,sJAAwB,CAAC;AAClD,QAAA,MAAM,iBAAiB,sJAAsB,CAAC;AAE9C,OAAO,EACL,qBAAqB,IAAI,gBAAgB,EACzC,mBAAmB,IAAI,cAAc,EACrC,kBAAkB,IAAI,aAAa,EACnC,0BAA0B,IAAI,qBAAqB,EACnD,mBAAmB,IAAI,cAAc,EACrC,iBAAiB,IAAI,YAAY,GAClC,CAAC"}
@@ -1,10 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const _ = require("lodash/fp");
4
- const setStatusToDraft = _.assoc("status", "draft");
4
+ const strapiUtils = require("@strapi/utils");
5
+ const setStatusToDraft = (contentType, params) => {
6
+ if (!strapiUtils.contentTypes.hasDraftAndPublish(contentType) && params.status) {
7
+ return params;
8
+ }
9
+ return _.assoc("status", "draft", params);
10
+ };
5
11
  const defaultToDraft = (params) => {
6
12
  if (!params.status || params.status !== "published") {
7
- return setStatusToDraft(params);
13
+ return _.assoc("status", "draft", params);
14
+ }
15
+ return params;
16
+ };
17
+ const defaultStatus = (contentType, params) => {
18
+ if (!strapiUtils.contentTypes.hasDraftAndPublish(contentType)) {
19
+ return params;
20
+ }
21
+ if (!params.status || params.status !== "published") {
22
+ return defaultToDraft(params);
8
23
  }
9
24
  return params;
10
25
  };
@@ -14,7 +29,10 @@ const filterDataPublishedAt = (params) => {
14
29
  }
15
30
  return params;
16
31
  };
17
- const statusToLookup = (params) => {
32
+ const statusToLookup = (contentType, params) => {
33
+ if (!strapiUtils.contentTypes.hasDraftAndPublish(contentType)) {
34
+ return params;
35
+ }
18
36
  const lookup = params.lookup || {};
19
37
  switch (params?.status) {
20
38
  case "published":
@@ -24,7 +42,10 @@ const statusToLookup = (params) => {
24
42
  }
25
43
  return _.assoc("lookup", lookup, params);
26
44
  };
27
- const statusToData = (params) => {
45
+ const statusToData = (contentType, params) => {
46
+ if (!strapiUtils.contentTypes.hasDraftAndPublish(contentType)) {
47
+ return _.assoc(["data", "publishedAt"], /* @__PURE__ */ new Date(), params);
48
+ }
28
49
  switch (params?.status) {
29
50
  case "published":
30
51
  return _.assoc(["data", "publishedAt"], /* @__PURE__ */ new Date(), params);
@@ -33,9 +54,16 @@ const statusToData = (params) => {
33
54
  }
34
55
  return params;
35
56
  };
36
- exports.defaultToDraft = defaultToDraft;
37
- exports.filterDataPublishedAt = filterDataPublishedAt;
38
- exports.setStatusToDraft = setStatusToDraft;
39
- exports.statusToData = statusToData;
40
- exports.statusToLookup = statusToLookup;
57
+ const setStatusToDraftCurry = _.curry(setStatusToDraft);
58
+ const defaultToDraftCurry = _.curry(defaultToDraft);
59
+ const defaultStatusCurry = _.curry(defaultStatus);
60
+ const filterDataPublishedAtCurry = _.curry(filterDataPublishedAt);
61
+ const statusToLookupCurry = _.curry(statusToLookup);
62
+ const statusToDataCurry = _.curry(statusToData);
63
+ exports.defaultStatus = defaultStatusCurry;
64
+ exports.defaultToDraft = defaultToDraftCurry;
65
+ exports.filterDataPublishedAt = filterDataPublishedAtCurry;
66
+ exports.setStatusToDraft = setStatusToDraftCurry;
67
+ exports.statusToData = statusToDataCurry;
68
+ exports.statusToLookup = statusToLookupCurry;
41
69
  //# sourceMappingURL=draft-and-publish.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"draft-and-publish.js","sources":["../../../src/services/document-service/draft-and-publish.ts"],"sourcesContent":["import { Documents } from '@strapi/types';\nimport { assoc } from 'lodash/fp';\n\ntype ParamsTransform = (params: Documents.Params.All) => Documents.Params.All;\n\n/**\n * Sets status to draft only\n */\nexport const setStatusToDraft: ParamsTransform = assoc('status', 'draft');\n\n/**\n * Adds a default status of `draft` to the params\n */\nexport const defaultToDraft: ParamsTransform = (params) => {\n // Default to draft if no status is provided or it's invalid\n if (!params.status || params.status !== 'published') {\n return setStatusToDraft(params);\n }\n\n return params;\n};\n\n/**\n * In mutating actions we don't want user to set the publishedAt attribute.\n */\nexport const filterDataPublishedAt: ParamsTransform = (params) => {\n if (params?.data?.publishedAt) {\n return assoc(['data', 'publishedAt'], null, params);\n }\n\n return params;\n};\n\n/**\n * Add status lookup query to the params\n */\nexport const statusToLookup: ParamsTransform = (params) => {\n const lookup = params.lookup || {};\n\n switch (params?.status) {\n case 'published':\n return assoc(['lookup', 'publishedAt'], { $notNull: true }, params);\n case 'draft':\n return assoc(['lookup', 'publishedAt'], { $null: true }, params);\n default:\n break;\n }\n\n return assoc('lookup', lookup, params);\n};\n\n/**\n * Translate publication status parameter into the data that will be saved\n */\nexport const statusToData: ParamsTransform = (params) => {\n switch (params?.status) {\n case 'published':\n return assoc(['data', 'publishedAt'], new Date(), params);\n case 'draft':\n return assoc(['data', 'publishedAt'], null, params);\n default:\n break;\n }\n\n return params;\n};\n"],"names":["assoc"],"mappings":";;;AAQa,MAAA,mBAAoCA,EAAAA,MAAM,UAAU,OAAO;AAK3D,MAAA,iBAAkC,CAAC,WAAW;AAEzD,MAAI,CAAC,OAAO,UAAU,OAAO,WAAW,aAAa;AACnD,WAAO,iBAAiB,MAAM;AAAA,EAChC;AAEO,SAAA;AACT;AAKa,MAAA,wBAAyC,CAAC,WAAW;AAC5D,MAAA,QAAQ,MAAM,aAAa;AAC7B,WAAOA,EAAAA,MAAM,CAAC,QAAQ,aAAa,GAAG,MAAM,MAAM;AAAA,EACpD;AAEO,SAAA;AACT;AAKa,MAAA,iBAAkC,CAAC,WAAW;AACnD,QAAA,SAAS,OAAO,UAAU;AAEhC,UAAQ,QAAQ,QAAQ;AAAA,IACtB,KAAK;AACI,aAAAA,EAAA,MAAM,CAAC,UAAU,aAAa,GAAG,EAAE,UAAU,QAAQ,MAAM;AAAA,IACpE,KAAK;AACI,aAAAA,EAAA,MAAM,CAAC,UAAU,aAAa,GAAG,EAAE,OAAO,QAAQ,MAAM;AAAA,EAGnE;AAEO,SAAAA,QAAM,UAAU,QAAQ,MAAM;AACvC;AAKa,MAAA,eAAgC,CAAC,WAAW;AACvD,UAAQ,QAAQ,QAAQ;AAAA,IACtB,KAAK;AACI,aAAAA,EAAAA,MAAM,CAAC,QAAQ,aAAa,GAAO,oBAAA,KAAA,GAAQ,MAAM;AAAA,IAC1D,KAAK;AACH,aAAOA,EAAAA,MAAM,CAAC,QAAQ,aAAa,GAAG,MAAM,MAAM;AAAA,EAGtD;AAEO,SAAA;AACT;;;;;;"}
1
+ {"version":3,"file":"draft-and-publish.js","sources":["../../../src/services/document-service/draft-and-publish.ts"],"sourcesContent":["import { assoc, curry } from 'lodash/fp';\n\nimport { Modules, Struct } from '@strapi/types';\nimport { contentTypes } from '@strapi/utils';\n\ntype ParamsTransform = (params: Modules.Documents.Params.All) => Modules.Documents.Params.All;\n\ntype TransformWithContentType = (\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema,\n params: Modules.Documents.Params.All\n) => Modules.Documents.Params.All;\n\n/**\n * DP enabled -> set status to draft\n * DP disabled -> Used mostly for parsing relations, so there is not a need for a default.\n */\nconst setStatusToDraft: TransformWithContentType = (contentType, params) => {\n if (!contentTypes.hasDraftAndPublish(contentType) && params.status) {\n return params;\n }\n\n return assoc('status', 'draft', params);\n};\n\n/**\n * Adds a default status of `draft` to the params\n */\nconst defaultToDraft: ParamsTransform = (params) => {\n // Default to draft if no status is provided or it's invalid\n if (!params.status || params.status !== 'published') {\n return assoc('status', 'draft', params);\n }\n\n return params;\n};\n\n/**\n * DP disabled -> ignore status\n * DP enabled -> set status to draft if no status is provided or it's invalid\n */\nconst defaultStatus: TransformWithContentType = (contentType, params) => {\n if (!contentTypes.hasDraftAndPublish(contentType)) {\n return params;\n }\n\n // Default to draft if no status is provided or it's invalid\n if (!params.status || params.status !== 'published') {\n return defaultToDraft(params);\n }\n\n return params;\n};\n\n/**\n * In mutating actions we don't want user to set the publishedAt attribute.\n */\nconst filterDataPublishedAt: ParamsTransform = (params) => {\n if (params?.data?.publishedAt) {\n return assoc(['data', 'publishedAt'], null, params);\n }\n\n return params;\n};\n\n/**\n * Add status lookup query to the params\n */\nconst statusToLookup: TransformWithContentType = (contentType, params) => {\n if (!contentTypes.hasDraftAndPublish(contentType)) {\n return params;\n }\n\n const lookup = params.lookup || {};\n\n switch (params?.status) {\n case 'published':\n return assoc(['lookup', 'publishedAt'], { $notNull: true }, params);\n case 'draft':\n return assoc(['lookup', 'publishedAt'], { $null: true }, params);\n default:\n break;\n }\n\n return assoc('lookup', lookup, params);\n};\n\n/**\n * Translate publication status parameter into the data that will be saved\n */\nconst statusToData: TransformWithContentType = (contentType, params) => {\n if (!contentTypes.hasDraftAndPublish(contentType)) {\n return assoc(['data', 'publishedAt'], new Date(), params);\n }\n\n switch (params?.status) {\n case 'published':\n return assoc(['data', 'publishedAt'], new Date(), params);\n case 'draft':\n return assoc(['data', 'publishedAt'], null, params);\n default:\n break;\n }\n\n return params;\n};\n\nconst setStatusToDraftCurry = curry(setStatusToDraft);\nconst defaultToDraftCurry = curry(defaultToDraft);\nconst defaultStatusCurry = curry(defaultStatus);\nconst filterDataPublishedAtCurry = curry(filterDataPublishedAt);\nconst statusToLookupCurry = curry(statusToLookup);\nconst statusToDataCurry = curry(statusToData);\n\nexport {\n setStatusToDraftCurry as setStatusToDraft,\n defaultToDraftCurry as defaultToDraft,\n defaultStatusCurry as defaultStatus,\n filterDataPublishedAtCurry as filterDataPublishedAt,\n statusToLookupCurry as statusToLookup,\n statusToDataCurry as statusToData,\n};\n"],"names":["contentTypes","assoc","curry"],"mappings":";;;;AAgBA,MAAM,mBAA6C,CAAC,aAAa,WAAW;AAC1E,MAAI,CAACA,YAAa,aAAA,mBAAmB,WAAW,KAAK,OAAO,QAAQ;AAC3D,WAAA;AAAA,EACT;AAEO,SAAAC,QAAM,UAAU,SAAS,MAAM;AACxC;AAKA,MAAM,iBAAkC,CAAC,WAAW;AAElD,MAAI,CAAC,OAAO,UAAU,OAAO,WAAW,aAAa;AAC5C,WAAAA,QAAM,UAAU,SAAS,MAAM;AAAA,EACxC;AAEO,SAAA;AACT;AAMA,MAAM,gBAA0C,CAAC,aAAa,WAAW;AACvE,MAAI,CAACD,YAAA,aAAa,mBAAmB,WAAW,GAAG;AAC1C,WAAA;AAAA,EACT;AAGA,MAAI,CAAC,OAAO,UAAU,OAAO,WAAW,aAAa;AACnD,WAAO,eAAe,MAAM;AAAA,EAC9B;AAEO,SAAA;AACT;AAKA,MAAM,wBAAyC,CAAC,WAAW;AACrD,MAAA,QAAQ,MAAM,aAAa;AAC7B,WAAOC,EAAAA,MAAM,CAAC,QAAQ,aAAa,GAAG,MAAM,MAAM;AAAA,EACpD;AAEO,SAAA;AACT;AAKA,MAAM,iBAA2C,CAAC,aAAa,WAAW;AACxE,MAAI,CAACD,YAAA,aAAa,mBAAmB,WAAW,GAAG;AAC1C,WAAA;AAAA,EACT;AAEM,QAAA,SAAS,OAAO,UAAU;AAEhC,UAAQ,QAAQ,QAAQ;AAAA,IACtB,KAAK;AACI,aAAAC,EAAA,MAAM,CAAC,UAAU,aAAa,GAAG,EAAE,UAAU,QAAQ,MAAM;AAAA,IACpE,KAAK;AACI,aAAAA,EAAA,MAAM,CAAC,UAAU,aAAa,GAAG,EAAE,OAAO,QAAQ,MAAM;AAAA,EAGnE;AAEO,SAAAA,QAAM,UAAU,QAAQ,MAAM;AACvC;AAKA,MAAM,eAAyC,CAAC,aAAa,WAAW;AACtE,MAAI,CAACD,YAAA,aAAa,mBAAmB,WAAW,GAAG;AAC1C,WAAAC,EAAAA,MAAM,CAAC,QAAQ,aAAa,GAAO,oBAAA,KAAA,GAAQ,MAAM;AAAA,EAC1D;AAEA,UAAQ,QAAQ,QAAQ;AAAA,IACtB,KAAK;AACI,aAAAA,EAAAA,MAAM,CAAC,QAAQ,aAAa,GAAO,oBAAA,KAAA,GAAQ,MAAM;AAAA,IAC1D,KAAK;AACH,aAAOA,EAAAA,MAAM,CAAC,QAAQ,aAAa,GAAG,MAAM,MAAM;AAAA,EAGtD;AAEO,SAAA;AACT;AAEM,MAAA,wBAAwBC,QAAM,gBAAgB;AAC9C,MAAA,sBAAsBA,QAAM,cAAc;AAC1C,MAAA,qBAAqBA,QAAM,aAAa;AACxC,MAAA,6BAA6BA,QAAM,qBAAqB;AACxD,MAAA,sBAAsBA,QAAM,cAAc;AAC1C,MAAA,oBAAoBA,QAAM,YAAY;;;;;;;"}
@@ -1,8 +1,23 @@
1
- import { assoc } from "lodash/fp";
2
- const setStatusToDraft = assoc("status", "draft");
1
+ import { curry, assoc } from "lodash/fp";
2
+ import { contentTypes } from "@strapi/utils";
3
+ const setStatusToDraft = (contentType, params) => {
4
+ if (!contentTypes.hasDraftAndPublish(contentType) && params.status) {
5
+ return params;
6
+ }
7
+ return assoc("status", "draft", params);
8
+ };
3
9
  const defaultToDraft = (params) => {
4
10
  if (!params.status || params.status !== "published") {
5
- return setStatusToDraft(params);
11
+ return assoc("status", "draft", params);
12
+ }
13
+ return params;
14
+ };
15
+ const defaultStatus = (contentType, params) => {
16
+ if (!contentTypes.hasDraftAndPublish(contentType)) {
17
+ return params;
18
+ }
19
+ if (!params.status || params.status !== "published") {
20
+ return defaultToDraft(params);
6
21
  }
7
22
  return params;
8
23
  };
@@ -12,7 +27,10 @@ const filterDataPublishedAt = (params) => {
12
27
  }
13
28
  return params;
14
29
  };
15
- const statusToLookup = (params) => {
30
+ const statusToLookup = (contentType, params) => {
31
+ if (!contentTypes.hasDraftAndPublish(contentType)) {
32
+ return params;
33
+ }
16
34
  const lookup = params.lookup || {};
17
35
  switch (params?.status) {
18
36
  case "published":
@@ -22,7 +40,10 @@ const statusToLookup = (params) => {
22
40
  }
23
41
  return assoc("lookup", lookup, params);
24
42
  };
25
- const statusToData = (params) => {
43
+ const statusToData = (contentType, params) => {
44
+ if (!contentTypes.hasDraftAndPublish(contentType)) {
45
+ return assoc(["data", "publishedAt"], /* @__PURE__ */ new Date(), params);
46
+ }
26
47
  switch (params?.status) {
27
48
  case "published":
28
49
  return assoc(["data", "publishedAt"], /* @__PURE__ */ new Date(), params);
@@ -31,11 +52,18 @@ const statusToData = (params) => {
31
52
  }
32
53
  return params;
33
54
  };
55
+ const setStatusToDraftCurry = curry(setStatusToDraft);
56
+ const defaultToDraftCurry = curry(defaultToDraft);
57
+ const defaultStatusCurry = curry(defaultStatus);
58
+ const filterDataPublishedAtCurry = curry(filterDataPublishedAt);
59
+ const statusToLookupCurry = curry(statusToLookup);
60
+ const statusToDataCurry = curry(statusToData);
34
61
  export {
35
- defaultToDraft,
36
- filterDataPublishedAt,
37
- setStatusToDraft,
38
- statusToData,
39
- statusToLookup
62
+ defaultStatusCurry as defaultStatus,
63
+ defaultToDraftCurry as defaultToDraft,
64
+ filterDataPublishedAtCurry as filterDataPublishedAt,
65
+ setStatusToDraftCurry as setStatusToDraft,
66
+ statusToDataCurry as statusToData,
67
+ statusToLookupCurry as statusToLookup
40
68
  };
41
69
  //# sourceMappingURL=draft-and-publish.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"draft-and-publish.mjs","sources":["../../../src/services/document-service/draft-and-publish.ts"],"sourcesContent":["import { Documents } from '@strapi/types';\nimport { assoc } from 'lodash/fp';\n\ntype ParamsTransform = (params: Documents.Params.All) => Documents.Params.All;\n\n/**\n * Sets status to draft only\n */\nexport const setStatusToDraft: ParamsTransform = assoc('status', 'draft');\n\n/**\n * Adds a default status of `draft` to the params\n */\nexport const defaultToDraft: ParamsTransform = (params) => {\n // Default to draft if no status is provided or it's invalid\n if (!params.status || params.status !== 'published') {\n return setStatusToDraft(params);\n }\n\n return params;\n};\n\n/**\n * In mutating actions we don't want user to set the publishedAt attribute.\n */\nexport const filterDataPublishedAt: ParamsTransform = (params) => {\n if (params?.data?.publishedAt) {\n return assoc(['data', 'publishedAt'], null, params);\n }\n\n return params;\n};\n\n/**\n * Add status lookup query to the params\n */\nexport const statusToLookup: ParamsTransform = (params) => {\n const lookup = params.lookup || {};\n\n switch (params?.status) {\n case 'published':\n return assoc(['lookup', 'publishedAt'], { $notNull: true }, params);\n case 'draft':\n return assoc(['lookup', 'publishedAt'], { $null: true }, params);\n default:\n break;\n }\n\n return assoc('lookup', lookup, params);\n};\n\n/**\n * Translate publication status parameter into the data that will be saved\n */\nexport const statusToData: ParamsTransform = (params) => {\n switch (params?.status) {\n case 'published':\n return assoc(['data', 'publishedAt'], new Date(), params);\n case 'draft':\n return assoc(['data', 'publishedAt'], null, params);\n default:\n break;\n }\n\n return params;\n};\n"],"names":[],"mappings":";AAQa,MAAA,mBAAoC,MAAM,UAAU,OAAO;AAK3D,MAAA,iBAAkC,CAAC,WAAW;AAEzD,MAAI,CAAC,OAAO,UAAU,OAAO,WAAW,aAAa;AACnD,WAAO,iBAAiB,MAAM;AAAA,EAChC;AAEO,SAAA;AACT;AAKa,MAAA,wBAAyC,CAAC,WAAW;AAC5D,MAAA,QAAQ,MAAM,aAAa;AAC7B,WAAO,MAAM,CAAC,QAAQ,aAAa,GAAG,MAAM,MAAM;AAAA,EACpD;AAEO,SAAA;AACT;AAKa,MAAA,iBAAkC,CAAC,WAAW;AACnD,QAAA,SAAS,OAAO,UAAU;AAEhC,UAAQ,QAAQ,QAAQ;AAAA,IACtB,KAAK;AACI,aAAA,MAAM,CAAC,UAAU,aAAa,GAAG,EAAE,UAAU,QAAQ,MAAM;AAAA,IACpE,KAAK;AACI,aAAA,MAAM,CAAC,UAAU,aAAa,GAAG,EAAE,OAAO,QAAQ,MAAM;AAAA,EAGnE;AAEO,SAAA,MAAM,UAAU,QAAQ,MAAM;AACvC;AAKa,MAAA,eAAgC,CAAC,WAAW;AACvD,UAAQ,QAAQ,QAAQ;AAAA,IACtB,KAAK;AACI,aAAA,MAAM,CAAC,QAAQ,aAAa,GAAO,oBAAA,KAAA,GAAQ,MAAM;AAAA,IAC1D,KAAK;AACH,aAAO,MAAM,CAAC,QAAQ,aAAa,GAAG,MAAM,MAAM;AAAA,EAGtD;AAEO,SAAA;AACT;"}
1
+ {"version":3,"file":"draft-and-publish.mjs","sources":["../../../src/services/document-service/draft-and-publish.ts"],"sourcesContent":["import { assoc, curry } from 'lodash/fp';\n\nimport { Modules, Struct } from '@strapi/types';\nimport { contentTypes } from '@strapi/utils';\n\ntype ParamsTransform = (params: Modules.Documents.Params.All) => Modules.Documents.Params.All;\n\ntype TransformWithContentType = (\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema,\n params: Modules.Documents.Params.All\n) => Modules.Documents.Params.All;\n\n/**\n * DP enabled -> set status to draft\n * DP disabled -> Used mostly for parsing relations, so there is not a need for a default.\n */\nconst setStatusToDraft: TransformWithContentType = (contentType, params) => {\n if (!contentTypes.hasDraftAndPublish(contentType) && params.status) {\n return params;\n }\n\n return assoc('status', 'draft', params);\n};\n\n/**\n * Adds a default status of `draft` to the params\n */\nconst defaultToDraft: ParamsTransform = (params) => {\n // Default to draft if no status is provided or it's invalid\n if (!params.status || params.status !== 'published') {\n return assoc('status', 'draft', params);\n }\n\n return params;\n};\n\n/**\n * DP disabled -> ignore status\n * DP enabled -> set status to draft if no status is provided or it's invalid\n */\nconst defaultStatus: TransformWithContentType = (contentType, params) => {\n if (!contentTypes.hasDraftAndPublish(contentType)) {\n return params;\n }\n\n // Default to draft if no status is provided or it's invalid\n if (!params.status || params.status !== 'published') {\n return defaultToDraft(params);\n }\n\n return params;\n};\n\n/**\n * In mutating actions we don't want user to set the publishedAt attribute.\n */\nconst filterDataPublishedAt: ParamsTransform = (params) => {\n if (params?.data?.publishedAt) {\n return assoc(['data', 'publishedAt'], null, params);\n }\n\n return params;\n};\n\n/**\n * Add status lookup query to the params\n */\nconst statusToLookup: TransformWithContentType = (contentType, params) => {\n if (!contentTypes.hasDraftAndPublish(contentType)) {\n return params;\n }\n\n const lookup = params.lookup || {};\n\n switch (params?.status) {\n case 'published':\n return assoc(['lookup', 'publishedAt'], { $notNull: true }, params);\n case 'draft':\n return assoc(['lookup', 'publishedAt'], { $null: true }, params);\n default:\n break;\n }\n\n return assoc('lookup', lookup, params);\n};\n\n/**\n * Translate publication status parameter into the data that will be saved\n */\nconst statusToData: TransformWithContentType = (contentType, params) => {\n if (!contentTypes.hasDraftAndPublish(contentType)) {\n return assoc(['data', 'publishedAt'], new Date(), params);\n }\n\n switch (params?.status) {\n case 'published':\n return assoc(['data', 'publishedAt'], new Date(), params);\n case 'draft':\n return assoc(['data', 'publishedAt'], null, params);\n default:\n break;\n }\n\n return params;\n};\n\nconst setStatusToDraftCurry = curry(setStatusToDraft);\nconst defaultToDraftCurry = curry(defaultToDraft);\nconst defaultStatusCurry = curry(defaultStatus);\nconst filterDataPublishedAtCurry = curry(filterDataPublishedAt);\nconst statusToLookupCurry = curry(statusToLookup);\nconst statusToDataCurry = curry(statusToData);\n\nexport {\n setStatusToDraftCurry as setStatusToDraft,\n defaultToDraftCurry as defaultToDraft,\n defaultStatusCurry as defaultStatus,\n filterDataPublishedAtCurry as filterDataPublishedAt,\n statusToLookupCurry as statusToLookup,\n statusToDataCurry as statusToData,\n};\n"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AA,EAC1D;AAEA,UAAQ,QAAQ,QAAQ;AAAA,IACtB,KAAK;AACI,aAAA,MAAM,CAAC,QAAQ,aAAa,GAAO,oBAAA,KAAA,GAAQ,MAAM;AAAA,IAC1D,KAAK;AACH,aAAO,MAAM,CAAC,QAAQ,aAAa,GAAG,MAAM,MAAM;AAAA,EAGtD;AAEO,SAAA;AACT;AAEM,MAAA,wBAAwB,MAAM,gBAAgB;AAC9C,MAAA,sBAAsB,MAAM,cAAc;AAC1C,MAAA,qBAAqB,MAAM,aAAa;AACxC,MAAA,6BAA6B,MAAM,qBAAqB;AACxD,MAAA,sBAAsB,MAAM,cAAc;AAC1C,MAAA,oBAAoB,MAAM,YAAY;"}
@@ -0,0 +1,10 @@
1
+ import type { UID } from '@strapi/types';
2
+ declare const createEntriesService: (uid: UID.ContentType) => {
3
+ create: (params?: any) => Promise<any>;
4
+ delete: (id: number) => Promise<void>;
5
+ update: (entryToUpdate: any, params?: any) => Promise<any>;
6
+ publish: (entry: any, params?: any) => Promise<object>;
7
+ discardDraft: (entry: any, params?: any) => Promise<object>;
8
+ };
9
+ export { createEntriesService };
10
+ //# sourceMappingURL=entries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAazC,QAAA,MAAM,oBAAoB,QAAS,IAAI,WAAW;;iBAkCjB,MAAM;4BAQK,GAAG;qBA4BV,GAAG;0BAaE,GAAG;CAoB5C,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const strapiUtils = require("@strapi/utils");
4
+ const _ = require("lodash/fp");
5
+ const components = require("./components.js");
6
+ const idTransform = require("./transform/id-transform.js");
7
+ const query = require("./transform/query.js");
8
+ const params = require("./params.js");
9
+ const index$1 = require("./attributes/index.js");
10
+ const data = require("./transform/data.js");
11
+ const index = require("../entity-validator/index.js");
12
+ const createEntriesService = (uid) => {
13
+ const contentType = strapi.contentType(uid);
14
+ async function createEntry(params$1 = {}) {
15
+ const { data: data2, ...restParams } = await idTransform.transformParamsDocumentId(uid, params$1);
16
+ const query$1 = query.transformParamsToQuery(uid, params.pickSelectionParams(restParams));
17
+ if (!data2) {
18
+ throw new Error("Create requires data attribute");
19
+ }
20
+ const validData = await index.validateEntityCreation(contentType, data2, {
21
+ // Note: publishedAt value will always be set when DP is disabled
22
+ isDraft: !params$1?.data?.publishedAt,
23
+ locale: params$1?.locale
24
+ });
25
+ const componentData = await components.createComponents(uid, validData);
26
+ const dataWithComponents = components.assignComponentData(
27
+ contentType,
28
+ componentData,
29
+ validData
30
+ );
31
+ const entryData = index$1.applyTransforms(contentType, dataWithComponents);
32
+ const doc = await strapi.db.query(uid).create({ ...query$1, data: entryData });
33
+ return doc;
34
+ }
35
+ async function deleteEntry(id) {
36
+ const componentsToDelete = await components.getComponents(uid, { id });
37
+ await strapi.db.query(uid).delete({ where: { id } });
38
+ await components.deleteComponents(uid, componentsToDelete, { loadComponents: false });
39
+ }
40
+ async function updateEntry(entryToUpdate, params$1 = {}) {
41
+ const { data: data2, ...restParams } = await idTransform.transformParamsDocumentId(uid, params$1);
42
+ const query$1 = query.transformParamsToQuery(uid, params.pickSelectionParams(restParams));
43
+ const validData = await index.validateEntityUpdate(
44
+ contentType,
45
+ data2,
46
+ {
47
+ isDraft: !params$1?.data?.publishedAt,
48
+ // Always update the draft version
49
+ locale: params$1?.locale
50
+ },
51
+ entryToUpdate
52
+ );
53
+ const componentData = await components.updateComponents(uid, entryToUpdate, validData);
54
+ const dataWithComponents = components.assignComponentData(
55
+ contentType,
56
+ componentData,
57
+ validData
58
+ );
59
+ const entryData = index$1.applyTransforms(contentType, dataWithComponents);
60
+ return strapi.db.query(uid).update({ ...query$1, where: { id: entryToUpdate.id }, data: entryData });
61
+ }
62
+ async function publishEntry(entry, params2 = {}) {
63
+ return strapiUtils.async.pipe(
64
+ _.omit("id"),
65
+ _.assoc("publishedAt", /* @__PURE__ */ new Date()),
66
+ (draft) => {
67
+ const opts = { uid, locale: draft.locale, status: "published", allowMissingId: true };
68
+ return data.transformData(draft, opts);
69
+ },
70
+ // Create the published entry
71
+ (draft) => createEntry({ ...params2, data: draft, locale: draft.locale, status: "published" })
72
+ )(entry);
73
+ }
74
+ async function discardDraftEntry(entry, params2 = {}) {
75
+ return strapiUtils.async.pipe(
76
+ _.omit("id"),
77
+ _.assoc("publishedAt", null),
78
+ (entry2) => {
79
+ const opts = { uid, locale: entry2.locale, status: "draft", allowMissingId: true };
80
+ return data.transformData(entry2, opts);
81
+ },
82
+ // Create the draft entry
83
+ (data2) => createEntry({ ...params2, locale: data2.locale, data: data2, status: "draft" })
84
+ )(entry);
85
+ }
86
+ return {
87
+ create: createEntry,
88
+ delete: deleteEntry,
89
+ update: updateEntry,
90
+ publish: publishEntry,
91
+ discardDraft: discardDraftEntry
92
+ };
93
+ };
94
+ exports.createEntriesService = createEntriesService;
95
+ //# sourceMappingURL=entries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries.js","sources":["../../../src/services/document-service/entries.ts"],"sourcesContent":["import type { UID } from '@strapi/types';\nimport { async } from '@strapi/utils';\nimport { assoc, omit } from 'lodash/fp';\n\nimport * as components from './components';\n\nimport { transformParamsDocumentId } from './transform/id-transform';\nimport { transformParamsToQuery } from './transform/query';\nimport { pickSelectionParams } from './params';\nimport { applyTransforms } from './attributes';\nimport { transformData } from './transform/data';\nimport entityValidator from '../entity-validator';\n\nconst createEntriesService = (uid: UID.ContentType) => {\n const contentType = strapi.contentType(uid);\n\n async function createEntry(params = {} as any) {\n const { data, ...restParams } = await transformParamsDocumentId(uid, params);\n\n const query = transformParamsToQuery(uid, pickSelectionParams(restParams) as any); // select / populate\n\n // Validation\n if (!data) {\n throw new Error('Create requires data attribute');\n }\n\n const validData = await entityValidator.validateEntityCreation(contentType, data, {\n // Note: publishedAt value will always be set when DP is disabled\n isDraft: !params?.data?.publishedAt,\n locale: params?.locale,\n });\n\n // Component handling\n const componentData = await components.createComponents(uid, validData);\n const dataWithComponents = components.assignComponentData(\n contentType,\n componentData,\n validData\n );\n\n const entryData = applyTransforms(contentType, dataWithComponents);\n\n const doc = await strapi.db.query(uid).create({ ...query, data: entryData });\n\n return doc;\n }\n\n async function deleteEntry(id: number) {\n const componentsToDelete = await components.getComponents(uid, { id });\n\n await strapi.db.query(uid).delete({ where: { id } });\n\n await components.deleteComponents(uid, componentsToDelete as any, { loadComponents: false });\n }\n\n async function updateEntry(entryToUpdate: any, params = {} as any) {\n const { data, ...restParams } = await transformParamsDocumentId(uid, params);\n const query = transformParamsToQuery(uid, pickSelectionParams(restParams) as any); // select / populate\n\n const validData = await entityValidator.validateEntityUpdate(\n contentType,\n data,\n {\n isDraft: !params?.data?.publishedAt, // Always update the draft version\n locale: params?.locale,\n },\n entryToUpdate\n );\n // Component handling\n const componentData = await components.updateComponents(uid, entryToUpdate, validData as any);\n const dataWithComponents = components.assignComponentData(\n contentType,\n componentData,\n validData\n );\n\n const entryData = applyTransforms(contentType, dataWithComponents);\n\n return strapi.db\n .query(uid)\n .update({ ...query, where: { id: entryToUpdate.id }, data: entryData });\n }\n\n async function publishEntry(entry: any, params = {} as any) {\n return async.pipe(\n omit('id'),\n assoc('publishedAt', new Date()),\n (draft) => {\n const opts = { uid, locale: draft.locale, status: 'published', allowMissingId: true };\n return transformData(draft, opts);\n },\n // Create the published entry\n (draft) => createEntry({ ...params, data: draft, locale: draft.locale, status: 'published' })\n )(entry);\n }\n\n async function discardDraftEntry(entry: any, params = {} as any) {\n return async.pipe(\n omit('id'),\n assoc('publishedAt', null),\n (entry) => {\n const opts = { uid, locale: entry.locale, status: 'draft', allowMissingId: true };\n return transformData(entry, opts);\n },\n // Create the draft entry\n (data) => createEntry({ ...params, locale: data.locale, data, status: 'draft' })\n )(entry);\n }\n\n return {\n create: createEntry,\n delete: deleteEntry,\n update: updateEntry,\n publish: publishEntry,\n discardDraft: discardDraftEntry,\n };\n};\n\nexport { createEntriesService };\n"],"names":["params","data","transformParamsDocumentId","query","transformParamsToQuery","pickSelectionParams","entityValidator","components.createComponents","components.assignComponentData","applyTransforms","components.getComponents","components.deleteComponents","components.updateComponents","async","omit","assoc","transformData","entry"],"mappings":";;;;;;;;;;;AAaM,MAAA,uBAAuB,CAAC,QAAyB;AAC/C,QAAA,cAAc,OAAO,YAAY,GAAG;AAE3B,iBAAA,YAAYA,WAAS,IAAW;AACvC,UAAA,EAAE,MAAAC,OAAM,GAAG,WAAA,IAAe,MAAMC,sCAA0B,KAAKF,QAAM;AAE3E,UAAMG,UAAQC,MAAAA,uBAAuB,KAAKC,OAAAA,oBAAoB,UAAU,CAAQ;AAGhF,QAAI,CAACJ,OAAM;AACH,YAAA,IAAI,MAAM,gCAAgC;AAAA,IAClD;AAEA,UAAM,YAAY,MAAMK,MAAgB,uBAAuB,aAAaL,OAAM;AAAA;AAAA,MAEhF,SAAS,CAACD,UAAQ,MAAM;AAAA,MACxB,QAAQA,UAAQ;AAAA,IAAA,CACjB;AAGD,UAAM,gBAAgB,MAAMO,WAAAA,iBAA4B,KAAK,SAAS;AACtE,UAAM,qBAAqBC,WAAW;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAGI,UAAA,YAAYC,QAAAA,gBAAgB,aAAa,kBAAkB;AAEjE,UAAM,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,EAAE,OAAO,EAAE,GAAGN,SAAO,MAAM,UAAW,CAAA;AAEpE,WAAA;AAAA,EACT;AAEA,iBAAe,YAAY,IAAY;AACrC,UAAM,qBAAqB,MAAMO,yBAAyB,KAAK,EAAE,GAAI,CAAA;AAE/D,UAAA,OAAO,GAAG,MAAM,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAA,CAAG;AAEnD,UAAMC,WAAAA,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AA,KAAK,IAAI;AAAA,MACTC,EAAA,MAAM,eAAe,IAAI;AAAA,MACzB,CAACE,WAAU;AACH,cAAA,OAAO,EAAE,KAAK,QAAQA,OAAM,QAAQ,QAAQ,SAAS,gBAAgB;AACpE,eAAAD,KAAA,cAAcC,QAAO,IAAI;AAAA,MAClC;AAAA;AAAA,MAEA,CAAChB,UAAS,YAAY,EAAE,GAAGD,SAAQ,QAAQC,MAAK,QAAQ,MAAAA,OAAM,QAAQ,QAAA,CAAS;AAAA,MAC/E,KAAK;AAAA,EACT;AAEO,SAAA;AAAA,IACL,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,cAAc;AAAA,EAAA;AAElB;;"}
@@ -0,0 +1,95 @@
1
+ import { async } from "@strapi/utils";
2
+ import { omit, assoc } from "lodash/fp";
3
+ import { createComponents, assignComponentData, getComponents, deleteComponents, updateComponents } from "./components.mjs";
4
+ import { transformParamsDocumentId as curriedTransformParamsDocumentId } from "./transform/id-transform.mjs";
5
+ import { transformParamsToQuery } from "./transform/query.mjs";
6
+ import { pickSelectionParams } from "./params.mjs";
7
+ import { applyTransforms } from "./attributes/index.mjs";
8
+ import { transformData } from "./transform/data.mjs";
9
+ import entityValidator from "../entity-validator/index.mjs";
10
+ const createEntriesService = (uid) => {
11
+ const contentType = strapi.contentType(uid);
12
+ async function createEntry(params = {}) {
13
+ const { data, ...restParams } = await curriedTransformParamsDocumentId(uid, params);
14
+ const query = transformParamsToQuery(uid, pickSelectionParams(restParams));
15
+ if (!data) {
16
+ throw new Error("Create requires data attribute");
17
+ }
18
+ const validData = await entityValidator.validateEntityCreation(contentType, data, {
19
+ // Note: publishedAt value will always be set when DP is disabled
20
+ isDraft: !params?.data?.publishedAt,
21
+ locale: params?.locale
22
+ });
23
+ const componentData = await createComponents(uid, validData);
24
+ const dataWithComponents = assignComponentData(
25
+ contentType,
26
+ componentData,
27
+ validData
28
+ );
29
+ const entryData = applyTransforms(contentType, dataWithComponents);
30
+ const doc = await strapi.db.query(uid).create({ ...query, data: entryData });
31
+ return doc;
32
+ }
33
+ async function deleteEntry(id) {
34
+ const componentsToDelete = await getComponents(uid, { id });
35
+ await strapi.db.query(uid).delete({ where: { id } });
36
+ await deleteComponents(uid, componentsToDelete, { loadComponents: false });
37
+ }
38
+ async function updateEntry(entryToUpdate, params = {}) {
39
+ const { data, ...restParams } = await curriedTransformParamsDocumentId(uid, params);
40
+ const query = transformParamsToQuery(uid, pickSelectionParams(restParams));
41
+ const validData = await entityValidator.validateEntityUpdate(
42
+ contentType,
43
+ data,
44
+ {
45
+ isDraft: !params?.data?.publishedAt,
46
+ // Always update the draft version
47
+ locale: params?.locale
48
+ },
49
+ entryToUpdate
50
+ );
51
+ const componentData = await updateComponents(uid, entryToUpdate, validData);
52
+ const dataWithComponents = assignComponentData(
53
+ contentType,
54
+ componentData,
55
+ validData
56
+ );
57
+ const entryData = applyTransforms(contentType, dataWithComponents);
58
+ return strapi.db.query(uid).update({ ...query, where: { id: entryToUpdate.id }, data: entryData });
59
+ }
60
+ async function publishEntry(entry, params = {}) {
61
+ return async.pipe(
62
+ omit("id"),
63
+ assoc("publishedAt", /* @__PURE__ */ new Date()),
64
+ (draft) => {
65
+ const opts = { uid, locale: draft.locale, status: "published", allowMissingId: true };
66
+ return transformData(draft, opts);
67
+ },
68
+ // Create the published entry
69
+ (draft) => createEntry({ ...params, data: draft, locale: draft.locale, status: "published" })
70
+ )(entry);
71
+ }
72
+ async function discardDraftEntry(entry, params = {}) {
73
+ return async.pipe(
74
+ omit("id"),
75
+ assoc("publishedAt", null),
76
+ (entry2) => {
77
+ const opts = { uid, locale: entry2.locale, status: "draft", allowMissingId: true };
78
+ return transformData(entry2, opts);
79
+ },
80
+ // Create the draft entry
81
+ (data) => createEntry({ ...params, locale: data.locale, data, status: "draft" })
82
+ )(entry);
83
+ }
84
+ return {
85
+ create: createEntry,
86
+ delete: deleteEntry,
87
+ update: updateEntry,
88
+ publish: publishEntry,
89
+ discardDraft: discardDraftEntry
90
+ };
91
+ };
92
+ export {
93
+ createEntriesService
94
+ };
95
+ //# sourceMappingURL=entries.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries.mjs","sources":["../../../src/services/document-service/entries.ts"],"sourcesContent":["import type { UID } from '@strapi/types';\nimport { async } from '@strapi/utils';\nimport { assoc, omit } from 'lodash/fp';\n\nimport * as components from './components';\n\nimport { transformParamsDocumentId } from './transform/id-transform';\nimport { transformParamsToQuery } from './transform/query';\nimport { pickSelectionParams } from './params';\nimport { applyTransforms } from './attributes';\nimport { transformData } from './transform/data';\nimport entityValidator from '../entity-validator';\n\nconst createEntriesService = (uid: UID.ContentType) => {\n const contentType = strapi.contentType(uid);\n\n async function createEntry(params = {} as any) {\n const { data, ...restParams } = await transformParamsDocumentId(uid, params);\n\n const query = transformParamsToQuery(uid, pickSelectionParams(restParams) as any); // select / populate\n\n // Validation\n if (!data) {\n throw new Error('Create requires data attribute');\n }\n\n const validData = await entityValidator.validateEntityCreation(contentType, data, {\n // Note: publishedAt value will always be set when DP is disabled\n isDraft: !params?.data?.publishedAt,\n locale: params?.locale,\n });\n\n // Component handling\n const componentData = await components.createComponents(uid, validData);\n const dataWithComponents = components.assignComponentData(\n contentType,\n componentData,\n validData\n );\n\n const entryData = applyTransforms(contentType, dataWithComponents);\n\n const doc = await strapi.db.query(uid).create({ ...query, data: entryData });\n\n return doc;\n }\n\n async function deleteEntry(id: number) {\n const componentsToDelete = await components.getComponents(uid, { id });\n\n await strapi.db.query(uid).delete({ where: { id } });\n\n await components.deleteComponents(uid, componentsToDelete as any, { loadComponents: false });\n }\n\n async function updateEntry(entryToUpdate: any, params = {} as any) {\n const { data, ...restParams } = await transformParamsDocumentId(uid, params);\n const query = transformParamsToQuery(uid, pickSelectionParams(restParams) as any); // select / populate\n\n const validData = await entityValidator.validateEntityUpdate(\n contentType,\n data,\n {\n isDraft: !params?.data?.publishedAt, // Always update the draft version\n locale: params?.locale,\n },\n entryToUpdate\n );\n // Component handling\n const componentData = await components.updateComponents(uid, entryToUpdate, validData as any);\n const dataWithComponents = components.assignComponentData(\n contentType,\n componentData,\n validData\n );\n\n const entryData = applyTransforms(contentType, dataWithComponents);\n\n return strapi.db\n .query(uid)\n .update({ ...query, where: { id: entryToUpdate.id }, data: entryData });\n }\n\n async function publishEntry(entry: any, params = {} as any) {\n return async.pipe(\n omit('id'),\n assoc('publishedAt', new Date()),\n (draft) => {\n const opts = { uid, locale: draft.locale, status: 'published', allowMissingId: true };\n return transformData(draft, opts);\n },\n // Create the published entry\n (draft) => createEntry({ ...params, data: draft, locale: draft.locale, status: 'published' })\n )(entry);\n }\n\n async function discardDraftEntry(entry: any, params = {} as any) {\n return async.pipe(\n omit('id'),\n assoc('publishedAt', null),\n (entry) => {\n const opts = { uid, locale: entry.locale, status: 'draft', allowMissingId: true };\n return transformData(entry, opts);\n },\n // Create the draft entry\n (data) => createEntry({ ...params, locale: data.locale, data, status: 'draft' })\n )(entry);\n }\n\n return {\n create: createEntry,\n delete: deleteEntry,\n update: updateEntry,\n publish: publishEntry,\n discardDraft: discardDraftEntry,\n };\n};\n\nexport { createEntriesService };\n"],"names":["transformParamsDocumentId","components.createComponents","components.assignComponentData","components.getComponents","components.deleteComponents","components.updateComponents","entry"],"mappings":";;;;;;;;;AAaM,MAAA,uBAAuB,CAAC,QAAyB;AAC/C,QAAA,cAAc,OAAO,YAAY,GAAG;AAE3B,iBAAA,YAAY,SAAS,IAAW;AACvC,UAAA,EAAE,MAAM,GAAG,WAAA,IAAe,MAAMA,iCAA0B,KAAK,MAAM;AAE3E,UAAM,QAAQ,uBAAuB,KAAK,oBAAoB,UAAU,CAAQ;AAGhF,QAAI,CAAC,MAAM;AACH,YAAA,IAAI,MAAM,gCAAgC;AAAA,IAClD;AAEA,UAAM,YAAY,MAAM,gBAAgB,uBAAuB,aAAa,MAAM;AAAA;AAAA,MAEhF,SAAS,CAAC,QAAQ,MAAM;AAAA,MACxB,QAAQ,Q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AAA,MACX,KAAK,IAAI;AAAA,MACT,MAAM,eAAmB,oBAAA,MAAM;AAAA,MAC/B,CAAC,UAAU;AACH,cAAA,OAAO,EAAE,KAAK,QAAQ,MAAM,QAAQ,QAAQ,aAAa,gBAAgB;AACxE,eAAA,cAAc,OAAO,IAAI;AAAA,MAClC;AAAA;AAAA,MAEA,CAAC,UAAU,YAAY,EAAE,GAAG,QAAQ,MAAM,OAAO,QAAQ,MAAM,QAAQ,QAAQ,aAAa;AAAA,MAC5F,KAAK;AAAA,EACT;AAEA,iBAAe,kBAAkB,OAAY,SAAS,IAAW;AAC/D,WAAO,MAAM;AAAA,MACX,KAAK,IAAI;AAAA,MACT,MAAM,eAAe,IAAI;AAAA,MACzB,CAACI,WAAU;AACH,cAAA,OAAO,EAAE,KAAK,QAAQA,OAAM,QAAQ,QAAQ,SAAS,gBAAgB;AACpE,eAAA,cAAcA,QAAO,IAAI;AAAA,MAClC;AAAA;AAAA,MAEA,CAAC,SAAS,YAAY,EAAE,GAAG,QAAQ,QAAQ,KAAK,QAAQ,MAAM,QAAQ,QAAA,CAAS;AAAA,MAC/E,KAAK;AAAA,EACT;AAEO,SAAA;AAAA,IACL,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,cAAc;AAAA,EAAA;AAElB;"}
@@ -1,4 +1,4 @@
1
- import { Strapi, Documents } from '@strapi/types';
1
+ import type { Core, Modules } from '@strapi/types';
2
2
  /**
3
3
  * Repository to :
4
4
  * - Access documents via actions (findMany, findOne, create, update, delete, ...)
@@ -6,8 +6,6 @@ import { Strapi, Documents } from '@strapi/types';
6
6
  * - Apply default parameters to document actions
7
7
  *
8
8
  * @param strapi
9
- * @param options.defaults - Default parameters to apply to all actions
10
- * @param options.parent - Parent repository, used when creating a new repository with .with()
11
9
  * @returns DocumentService
12
10
  *
13
11
  * @example Access documents
@@ -15,5 +13,5 @@ import { Strapi, Documents } from '@strapi/types';
15
13
  * const allArticles = strapi.documents('api::article.article').findMany(params)
16
14
  *
17
15
  */
18
- export declare const createDocumentService: (strapi: Strapi) => Documents.Service;
16
+ export declare const createDocumentService: (strapi: Core.Strapi) => Modules.Documents.Service;
19
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAKlD;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,qBAAqB,WAAY,MAAM,KAAG,UAAU,OAoBhE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAO,MAAM,eAAe,CAAC;AAMxD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,WAAY,KAAK,MAAM,KAAG,QAAQ,SAAS,CAAC,OAiC7E,CAAC"}
@@ -1,21 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const middlewares = require("./middlewares.js");
4
- const contentType = require("./repositories/content-type.js");
3
+ const errors = require("./middlewares/errors.js");
4
+ const middlewareManager = require("./middlewares/middleware-manager.js");
5
+ const repository = require("./repository.js");
6
+ const data = require("./transform/data.js");
5
7
  const createDocumentService = (strapi) => {
6
8
  const repositories = /* @__PURE__ */ new Map();
7
- const middlewares$1 = middlewares.createMiddlewareManager();
9
+ const middlewares = middlewareManager.createMiddlewareManager();
10
+ middlewares.use(errors.databaseErrorsMiddleware);
8
11
  const factory = function factory2(uid) {
9
12
  if (repositories.has(uid)) {
10
13
  return repositories.get(uid);
11
14
  }
12
- const contentType$1 = strapi.contentType(uid);
13
- const repository = contentType.createContentTypeRepository(uid);
14
- repositories.set(uid, middlewares$1.wrapObject(repository, { contentType: contentType$1 }));
15
- return repository;
15
+ const contentType = strapi.contentType(uid);
16
+ const repository$1 = repository.createContentTypeRepository(uid);
17
+ const instance = middlewares.wrapObject(
18
+ repository$1,
19
+ { uid, contentType },
20
+ {
21
+ exclude: ["updateComponents", "omitComponentData"]
22
+ }
23
+ );
24
+ repositories.set(uid, instance);
25
+ return instance;
16
26
  };
17
27
  return Object.assign(factory, {
18
- use: middlewares$1.use.bind(middlewares$1)
28
+ utils: {
29
+ transformData: data.transformData
30
+ },
31
+ use: middlewares.use.bind(middlewares)
19
32
  });
20
33
  };
21
34
  exports.createDocumentService = createDocumentService;