@strapi/core 0.0.0-next.76a9dc5ca66301db734af3bc2111406c17ccb860 → 0.0.0-next.7c7ba817d00aeac2e9f750e6693dc8e51a8a2659

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 (696) hide show
  1. package/dist/Strapi.js +426 -408
  2. package/dist/Strapi.js.map +1 -1
  3. package/dist/Strapi.mjs +426 -408
  4. package/dist/Strapi.mjs.map +1 -1
  5. package/dist/compile.js +23 -14
  6. package/dist/compile.js.map +1 -1
  7. package/dist/compile.mjs +22 -14
  8. package/dist/compile.mjs.map +1 -1
  9. package/dist/configuration/config-loader.js +110 -96
  10. package/dist/configuration/config-loader.js.map +1 -1
  11. package/dist/configuration/config-loader.mjs +109 -95
  12. package/dist/configuration/config-loader.mjs.map +1 -1
  13. package/dist/configuration/get-dirs.js +31 -29
  14. package/dist/configuration/get-dirs.js.map +1 -1
  15. package/dist/configuration/get-dirs.mjs +30 -30
  16. package/dist/configuration/get-dirs.mjs.map +1 -1
  17. package/dist/configuration/index.d.ts.map +1 -1
  18. package/dist/configuration/index.js +84 -78
  19. package/dist/configuration/index.js.map +1 -1
  20. package/dist/configuration/index.mjs +83 -74
  21. package/dist/configuration/index.mjs.map +1 -1
  22. package/dist/configuration/urls.d.ts.map +1 -1
  23. package/dist/configuration/urls.js +74 -61
  24. package/dist/configuration/urls.js.map +1 -1
  25. package/dist/configuration/urls.mjs +73 -62
  26. package/dist/configuration/urls.mjs.map +1 -1
  27. package/dist/container.js +27 -23
  28. package/dist/container.js.map +1 -1
  29. package/dist/container.mjs +26 -24
  30. package/dist/container.mjs.map +1 -1
  31. package/dist/core-api/controller/collection-type.js +77 -76
  32. package/dist/core-api/controller/collection-type.js.map +1 -1
  33. package/dist/core-api/controller/collection-type.mjs +76 -77
  34. package/dist/core-api/controller/collection-type.mjs.map +1 -1
  35. package/dist/core-api/controller/index.js +63 -48
  36. package/dist/core-api/controller/index.js.map +1 -1
  37. package/dist/core-api/controller/index.mjs +62 -49
  38. package/dist/core-api/controller/index.mjs.map +1 -1
  39. package/dist/core-api/controller/single-type.js +41 -40
  40. package/dist/core-api/controller/single-type.js.map +1 -1
  41. package/dist/core-api/controller/single-type.mjs +40 -41
  42. package/dist/core-api/controller/single-type.mjs.map +1 -1
  43. package/dist/core-api/controller/transform.js +72 -63
  44. package/dist/core-api/controller/transform.js.map +1 -1
  45. package/dist/core-api/controller/transform.mjs +71 -64
  46. package/dist/core-api/controller/transform.mjs.map +1 -1
  47. package/dist/core-api/routes/index.js +64 -62
  48. package/dist/core-api/routes/index.js.map +1 -1
  49. package/dist/core-api/routes/index.mjs +62 -62
  50. package/dist/core-api/routes/index.mjs.map +1 -1
  51. package/dist/core-api/service/collection-type.js +73 -60
  52. package/dist/core-api/service/collection-type.js.map +1 -1
  53. package/dist/core-api/service/collection-type.mjs +72 -62
  54. package/dist/core-api/service/collection-type.mjs.map +1 -1
  55. package/dist/core-api/service/core-service.js +9 -8
  56. package/dist/core-api/service/core-service.js.map +1 -1
  57. package/dist/core-api/service/core-service.mjs +8 -9
  58. package/dist/core-api/service/core-service.mjs.map +1 -1
  59. package/dist/core-api/service/index.js +13 -13
  60. package/dist/core-api/service/index.js.map +1 -1
  61. package/dist/core-api/service/index.mjs +12 -14
  62. package/dist/core-api/service/index.mjs.map +1 -1
  63. package/dist/core-api/service/pagination.js +69 -43
  64. package/dist/core-api/service/pagination.js.map +1 -1
  65. package/dist/core-api/service/pagination.mjs +68 -47
  66. package/dist/core-api/service/pagination.mjs.map +1 -1
  67. package/dist/core-api/service/single-type.js +43 -38
  68. package/dist/core-api/service/single-type.js.map +1 -1
  69. package/dist/core-api/service/single-type.mjs +42 -40
  70. package/dist/core-api/service/single-type.mjs.map +1 -1
  71. package/dist/domain/content-type/index.js +95 -100
  72. package/dist/domain/content-type/index.js.map +1 -1
  73. package/dist/domain/content-type/index.mjs +94 -100
  74. package/dist/domain/content-type/index.mjs.map +1 -1
  75. package/dist/domain/content-type/validator.js +84 -69
  76. package/dist/domain/content-type/validator.js.map +1 -1
  77. package/dist/domain/content-type/validator.mjs +83 -68
  78. package/dist/domain/content-type/validator.mjs.map +1 -1
  79. package/dist/domain/module/index.js +109 -100
  80. package/dist/domain/module/index.js.map +1 -1
  81. package/dist/domain/module/index.mjs +108 -99
  82. package/dist/domain/module/index.mjs.map +1 -1
  83. package/dist/domain/module/validation.js +25 -20
  84. package/dist/domain/module/validation.js.map +1 -1
  85. package/dist/domain/module/validation.mjs +24 -21
  86. package/dist/domain/module/validation.mjs.map +1 -1
  87. package/dist/ee/index.d.ts +1 -0
  88. package/dist/ee/index.d.ts.map +1 -1
  89. package/dist/ee/index.js +171 -137
  90. package/dist/ee/index.js.map +1 -1
  91. package/dist/ee/index.mjs +170 -139
  92. package/dist/ee/index.mjs.map +1 -1
  93. package/dist/ee/license.d.ts.map +1 -1
  94. package/dist/ee/license.js +99 -75
  95. package/dist/ee/license.js.map +1 -1
  96. package/dist/ee/license.mjs +98 -76
  97. package/dist/ee/license.mjs.map +1 -1
  98. package/dist/factories.js +72 -67
  99. package/dist/factories.js.map +1 -1
  100. package/dist/factories.mjs +71 -71
  101. package/dist/factories.mjs.map +1 -1
  102. package/dist/index.js +29 -26
  103. package/dist/index.js.map +1 -1
  104. package/dist/index.mjs +29 -29
  105. package/dist/index.mjs.map +1 -1
  106. package/dist/loaders/admin.d.ts.map +1 -1
  107. package/dist/loaders/admin.js +21 -20
  108. package/dist/loaders/admin.js.map +1 -1
  109. package/dist/loaders/admin.mjs +20 -20
  110. package/dist/loaders/admin.mjs.map +1 -1
  111. package/dist/loaders/apis.js +143 -120
  112. package/dist/loaders/apis.js.map +1 -1
  113. package/dist/loaders/apis.mjs +142 -119
  114. package/dist/loaders/apis.mjs.map +1 -1
  115. package/dist/loaders/components.js +33 -34
  116. package/dist/loaders/components.js.map +1 -1
  117. package/dist/loaders/components.mjs +32 -34
  118. package/dist/loaders/components.mjs.map +1 -1
  119. package/dist/loaders/index.js +22 -20
  120. package/dist/loaders/index.js.map +1 -1
  121. package/dist/loaders/index.mjs +21 -21
  122. package/dist/loaders/index.mjs.map +1 -1
  123. package/dist/loaders/middlewares.js +29 -25
  124. package/dist/loaders/middlewares.js.map +1 -1
  125. package/dist/loaders/middlewares.mjs +28 -25
  126. package/dist/loaders/middlewares.mjs.map +1 -1
  127. package/dist/loaders/plugins/get-enabled-plugins.js +126 -131
  128. package/dist/loaders/plugins/get-enabled-plugins.js.map +1 -1
  129. package/dist/loaders/plugins/get-enabled-plugins.mjs +125 -108
  130. package/dist/loaders/plugins/get-enabled-plugins.mjs.map +1 -1
  131. package/dist/loaders/plugins/get-user-plugins-config.js +25 -24
  132. package/dist/loaders/plugins/get-user-plugins-config.js.map +1 -1
  133. package/dist/loaders/plugins/get-user-plugins-config.mjs +24 -23
  134. package/dist/loaders/plugins/get-user-plugins-config.mjs.map +1 -1
  135. package/dist/loaders/plugins/index.js +132 -121
  136. package/dist/loaders/plugins/index.js.map +1 -1
  137. package/dist/loaders/plugins/index.mjs +121 -112
  138. package/dist/loaders/plugins/index.mjs.map +1 -1
  139. package/dist/loaders/policies.js +24 -20
  140. package/dist/loaders/policies.js.map +1 -1
  141. package/dist/loaders/policies.mjs +23 -20
  142. package/dist/loaders/policies.mjs.map +1 -1
  143. package/dist/loaders/sanitizers.js +10 -4
  144. package/dist/loaders/sanitizers.js.map +1 -1
  145. package/dist/loaders/sanitizers.mjs +9 -6
  146. package/dist/loaders/sanitizers.mjs.map +1 -1
  147. package/dist/loaders/src-index.js +35 -27
  148. package/dist/loaders/src-index.js.map +1 -1
  149. package/dist/loaders/src-index.mjs +34 -29
  150. package/dist/loaders/src-index.mjs.map +1 -1
  151. package/dist/loaders/validators.js +9 -4
  152. package/dist/loaders/validators.js.map +1 -1
  153. package/dist/loaders/validators.mjs +8 -6
  154. package/dist/loaders/validators.mjs.map +1 -1
  155. package/dist/middlewares/body.d.ts.map +1 -1
  156. package/dist/middlewares/body.js +58 -54
  157. package/dist/middlewares/body.js.map +1 -1
  158. package/dist/middlewares/body.mjs +57 -51
  159. package/dist/middlewares/body.mjs.map +1 -1
  160. package/dist/middlewares/compression.js +6 -6
  161. package/dist/middlewares/compression.js.map +1 -1
  162. package/dist/middlewares/compression.mjs +5 -5
  163. package/dist/middlewares/compression.mjs.map +1 -1
  164. package/dist/middlewares/cors.js +59 -48
  165. package/dist/middlewares/cors.js.map +1 -1
  166. package/dist/middlewares/cors.mjs +58 -47
  167. package/dist/middlewares/cors.mjs.map +1 -1
  168. package/dist/middlewares/errors.js +32 -30
  169. package/dist/middlewares/errors.js.map +1 -1
  170. package/dist/middlewares/errors.mjs +31 -31
  171. package/dist/middlewares/errors.mjs.map +1 -1
  172. package/dist/middlewares/favicon.js +27 -17
  173. package/dist/middlewares/favicon.js.map +1 -1
  174. package/dist/middlewares/favicon.mjs +26 -16
  175. package/dist/middlewares/favicon.mjs.map +1 -1
  176. package/dist/middlewares/index.js +32 -30
  177. package/dist/middlewares/index.js.map +1 -1
  178. package/dist/middlewares/index.mjs +31 -31
  179. package/dist/middlewares/index.mjs.map +1 -1
  180. package/dist/middlewares/ip.js +6 -6
  181. package/dist/middlewares/ip.js.map +1 -1
  182. package/dist/middlewares/ip.mjs +5 -5
  183. package/dist/middlewares/ip.mjs.map +1 -1
  184. package/dist/middlewares/logger.js +10 -9
  185. package/dist/middlewares/logger.js.map +1 -1
  186. package/dist/middlewares/logger.mjs +9 -10
  187. package/dist/middlewares/logger.mjs.map +1 -1
  188. package/dist/middlewares/powered-by.js +13 -9
  189. package/dist/middlewares/powered-by.js.map +1 -1
  190. package/dist/middlewares/powered-by.mjs +12 -10
  191. package/dist/middlewares/powered-by.mjs.map +1 -1
  192. package/dist/middlewares/public.js +33 -29
  193. package/dist/middlewares/public.js.map +1 -1
  194. package/dist/middlewares/public.mjs +32 -28
  195. package/dist/middlewares/public.mjs.map +1 -1
  196. package/dist/middlewares/query.js +35 -32
  197. package/dist/middlewares/query.js.map +1 -1
  198. package/dist/middlewares/query.mjs +34 -31
  199. package/dist/middlewares/query.mjs.map +1 -1
  200. package/dist/middlewares/response-time.js +10 -9
  201. package/dist/middlewares/response-time.js.map +1 -1
  202. package/dist/middlewares/response-time.mjs +9 -10
  203. package/dist/middlewares/response-time.mjs.map +1 -1
  204. package/dist/middlewares/responses.js +14 -12
  205. package/dist/middlewares/responses.js.map +1 -1
  206. package/dist/middlewares/responses.mjs +13 -13
  207. package/dist/middlewares/responses.mjs.map +1 -1
  208. package/dist/middlewares/security.js +109 -71
  209. package/dist/middlewares/security.js.map +1 -1
  210. package/dist/middlewares/security.mjs +108 -70
  211. package/dist/middlewares/security.mjs.map +1 -1
  212. package/dist/middlewares/session.js +26 -25
  213. package/dist/middlewares/session.js.map +1 -1
  214. package/dist/middlewares/session.mjs +25 -24
  215. package/dist/middlewares/session.mjs.map +1 -1
  216. package/dist/migrations/database/5.0.0-discard-drafts.js +152 -93
  217. package/dist/migrations/database/5.0.0-discard-drafts.js.map +1 -1
  218. package/dist/migrations/database/5.0.0-discard-drafts.mjs +151 -95
  219. package/dist/migrations/database/5.0.0-discard-drafts.mjs.map +1 -1
  220. package/dist/migrations/draft-publish.d.ts +1 -1
  221. package/dist/migrations/draft-publish.d.ts.map +1 -1
  222. package/dist/migrations/draft-publish.js +61 -34
  223. package/dist/migrations/draft-publish.js.map +1 -1
  224. package/dist/migrations/draft-publish.mjs +60 -36
  225. package/dist/migrations/draft-publish.mjs.map +1 -1
  226. package/dist/migrations/i18n.js +62 -45
  227. package/dist/migrations/i18n.js.map +1 -1
  228. package/dist/migrations/i18n.mjs +61 -47
  229. package/dist/migrations/i18n.mjs.map +1 -1
  230. package/dist/migrations/index.js +24 -10
  231. package/dist/migrations/index.js.map +1 -1
  232. package/dist/migrations/index.mjs +23 -12
  233. package/dist/migrations/index.mjs.map +1 -1
  234. package/dist/package.json.js +182 -0
  235. package/dist/package.json.js.map +1 -0
  236. package/dist/package.json.mjs +159 -0
  237. package/dist/package.json.mjs.map +1 -0
  238. package/dist/providers/admin.js +27 -17
  239. package/dist/providers/admin.js.map +1 -1
  240. package/dist/providers/admin.mjs +26 -19
  241. package/dist/providers/admin.mjs.map +1 -1
  242. package/dist/providers/coreStore.js +13 -8
  243. package/dist/providers/coreStore.js.map +1 -1
  244. package/dist/providers/coreStore.mjs +12 -10
  245. package/dist/providers/coreStore.mjs.map +1 -1
  246. package/dist/providers/cron.js +19 -16
  247. package/dist/providers/cron.js.map +1 -1
  248. package/dist/providers/cron.mjs +18 -18
  249. package/dist/providers/cron.mjs.map +1 -1
  250. package/dist/providers/index.js +18 -9
  251. package/dist/providers/index.js.map +1 -1
  252. package/dist/providers/index.mjs +17 -10
  253. package/dist/providers/index.mjs.map +1 -1
  254. package/dist/providers/provider.js +4 -3
  255. package/dist/providers/provider.js.map +1 -1
  256. package/dist/providers/provider.mjs +3 -4
  257. package/dist/providers/provider.mjs.map +1 -1
  258. package/dist/providers/registries.js +37 -32
  259. package/dist/providers/registries.js.map +1 -1
  260. package/dist/providers/registries.mjs +36 -34
  261. package/dist/providers/registries.mjs.map +1 -1
  262. package/dist/providers/telemetry.js +19 -16
  263. package/dist/providers/telemetry.js.map +1 -1
  264. package/dist/providers/telemetry.mjs +18 -18
  265. package/dist/providers/telemetry.mjs.map +1 -1
  266. package/dist/providers/webhooks.js +28 -26
  267. package/dist/providers/webhooks.js.map +1 -1
  268. package/dist/providers/webhooks.mjs +27 -28
  269. package/dist/providers/webhooks.mjs.map +1 -1
  270. package/dist/registries/apis.js +23 -20
  271. package/dist/registries/apis.js.map +1 -1
  272. package/dist/registries/apis.mjs +22 -22
  273. package/dist/registries/apis.mjs.map +1 -1
  274. package/dist/registries/components.js +35 -37
  275. package/dist/registries/components.js.map +1 -1
  276. package/dist/registries/components.mjs +34 -39
  277. package/dist/registries/components.mjs.map +1 -1
  278. package/dist/registries/content-types.js +54 -59
  279. package/dist/registries/content-types.js.map +1 -1
  280. package/dist/registries/content-types.mjs +53 -61
  281. package/dist/registries/content-types.mjs.map +1 -1
  282. package/dist/registries/controllers.js +70 -71
  283. package/dist/registries/controllers.js.map +1 -1
  284. package/dist/registries/controllers.mjs +69 -73
  285. package/dist/registries/controllers.mjs.map +1 -1
  286. package/dist/registries/custom-fields.js +75 -65
  287. package/dist/registries/custom-fields.js.map +1 -1
  288. package/dist/registries/custom-fields.mjs +74 -67
  289. package/dist/registries/custom-fields.mjs.map +1 -1
  290. package/dist/registries/hooks.js +46 -49
  291. package/dist/registries/hooks.js.map +1 -1
  292. package/dist/registries/hooks.mjs +45 -51
  293. package/dist/registries/hooks.mjs.map +1 -1
  294. package/dist/registries/middlewares.js +49 -51
  295. package/dist/registries/middlewares.js.map +1 -1
  296. package/dist/registries/middlewares.mjs +48 -53
  297. package/dist/registries/middlewares.mjs.map +1 -1
  298. package/dist/registries/models.js +14 -13
  299. package/dist/registries/models.js.map +1 -1
  300. package/dist/registries/models.mjs +13 -14
  301. package/dist/registries/models.mjs.map +1 -1
  302. package/dist/registries/modules.js +39 -36
  303. package/dist/registries/modules.js.map +1 -1
  304. package/dist/registries/modules.mjs +38 -38
  305. package/dist/registries/modules.mjs.map +1 -1
  306. package/dist/registries/namespace.js +21 -20
  307. package/dist/registries/namespace.js.map +1 -1
  308. package/dist/registries/namespace.mjs +20 -23
  309. package/dist/registries/namespace.mjs.map +1 -1
  310. package/dist/registries/plugins.js +23 -20
  311. package/dist/registries/plugins.js.map +1 -1
  312. package/dist/registries/plugins.mjs +22 -22
  313. package/dist/registries/plugins.mjs.map +1 -1
  314. package/dist/registries/policies.js +103 -96
  315. package/dist/registries/policies.js.map +1 -1
  316. package/dist/registries/policies.mjs +102 -98
  317. package/dist/registries/policies.mjs.map +1 -1
  318. package/dist/registries/sanitizers.js +23 -22
  319. package/dist/registries/sanitizers.js.map +1 -1
  320. package/dist/registries/sanitizers.mjs +22 -22
  321. package/dist/registries/sanitizers.mjs.map +1 -1
  322. package/dist/registries/services.js +71 -71
  323. package/dist/registries/services.js.map +1 -1
  324. package/dist/registries/services.mjs +70 -73
  325. package/dist/registries/services.mjs.map +1 -1
  326. package/dist/registries/validators.js +23 -22
  327. package/dist/registries/validators.js.map +1 -1
  328. package/dist/registries/validators.mjs +22 -22
  329. package/dist/registries/validators.mjs.map +1 -1
  330. package/dist/services/auth/index.js +74 -74
  331. package/dist/services/auth/index.js.map +1 -1
  332. package/dist/services/auth/index.mjs +73 -74
  333. package/dist/services/auth/index.mjs.map +1 -1
  334. package/dist/services/config.js +47 -43
  335. package/dist/services/config.js.map +1 -1
  336. package/dist/services/config.mjs +46 -44
  337. package/dist/services/config.mjs.map +1 -1
  338. package/dist/services/content-api/index.js +80 -79
  339. package/dist/services/content-api/index.js.map +1 -1
  340. package/dist/services/content-api/index.mjs +79 -79
  341. package/dist/services/content-api/index.mjs.map +1 -1
  342. package/dist/services/content-api/permissions/engine.js +8 -5
  343. package/dist/services/content-api/permissions/engine.js.map +1 -1
  344. package/dist/services/content-api/permissions/engine.mjs +7 -5
  345. package/dist/services/content-api/permissions/engine.mjs.map +1 -1
  346. package/dist/services/content-api/permissions/index.js +101 -81
  347. package/dist/services/content-api/permissions/index.js.map +1 -1
  348. package/dist/services/content-api/permissions/index.mjs +100 -81
  349. package/dist/services/content-api/permissions/index.mjs.map +1 -1
  350. package/dist/services/content-api/permissions/providers/action.js +17 -14
  351. package/dist/services/content-api/permissions/providers/action.js.map +1 -1
  352. package/dist/services/content-api/permissions/providers/action.mjs +16 -16
  353. package/dist/services/content-api/permissions/providers/action.mjs.map +1 -1
  354. package/dist/services/content-api/permissions/providers/condition.js +17 -14
  355. package/dist/services/content-api/permissions/providers/condition.js.map +1 -1
  356. package/dist/services/content-api/permissions/providers/condition.mjs +16 -16
  357. package/dist/services/content-api/permissions/providers/condition.mjs.map +1 -1
  358. package/dist/services/core-store.js +115 -95
  359. package/dist/services/core-store.js.map +1 -1
  360. package/dist/services/core-store.mjs +114 -97
  361. package/dist/services/core-store.mjs.map +1 -1
  362. package/dist/services/cron.js +74 -64
  363. package/dist/services/cron.js.map +1 -1
  364. package/dist/services/cron.mjs +73 -66
  365. package/dist/services/cron.mjs.map +1 -1
  366. package/dist/services/custom-fields.js +9 -7
  367. package/dist/services/custom-fields.js.map +1 -1
  368. package/dist/services/custom-fields.mjs +8 -9
  369. package/dist/services/custom-fields.mjs.map +1 -1
  370. package/dist/services/document-service/attributes/index.js +23 -18
  371. package/dist/services/document-service/attributes/index.js.map +1 -1
  372. package/dist/services/document-service/attributes/index.mjs +22 -19
  373. package/dist/services/document-service/attributes/index.mjs.map +1 -1
  374. package/dist/services/document-service/attributes/transforms.js +16 -15
  375. package/dist/services/document-service/attributes/transforms.js.map +1 -1
  376. package/dist/services/document-service/attributes/transforms.mjs +15 -15
  377. package/dist/services/document-service/attributes/transforms.mjs.map +1 -1
  378. package/dist/services/document-service/common.js +5 -4
  379. package/dist/services/document-service/common.js.map +1 -1
  380. package/dist/services/document-service/common.mjs +4 -5
  381. package/dist/services/document-service/common.mjs.map +1 -1
  382. package/dist/services/document-service/components.js +255 -257
  383. package/dist/services/document-service/components.js.map +1 -1
  384. package/dist/services/document-service/components.mjs +254 -262
  385. package/dist/services/document-service/components.mjs.map +1 -1
  386. package/dist/services/document-service/draft-and-publish.d.ts +1 -1
  387. package/dist/services/document-service/draft-and-publish.d.ts.map +1 -1
  388. package/dist/services/document-service/draft-and-publish.js +88 -48
  389. package/dist/services/document-service/draft-and-publish.js.map +1 -1
  390. package/dist/services/document-service/draft-and-publish.mjs +87 -54
  391. package/dist/services/document-service/draft-and-publish.mjs.map +1 -1
  392. package/dist/services/document-service/entries.js +109 -91
  393. package/dist/services/document-service/entries.js.map +1 -1
  394. package/dist/services/document-service/entries.mjs +108 -92
  395. package/dist/services/document-service/entries.mjs.map +1 -1
  396. package/dist/services/document-service/events.d.ts +1 -1
  397. package/dist/services/document-service/events.d.ts.map +1 -1
  398. package/dist/services/document-service/events.js +52 -40
  399. package/dist/services/document-service/events.js.map +1 -1
  400. package/dist/services/document-service/events.mjs +51 -41
  401. package/dist/services/document-service/events.mjs.map +1 -1
  402. package/dist/services/document-service/index.js +53 -33
  403. package/dist/services/document-service/index.js.map +1 -1
  404. package/dist/services/document-service/index.mjs +52 -34
  405. package/dist/services/document-service/index.mjs.map +1 -1
  406. package/dist/services/document-service/internationalization.js +62 -46
  407. package/dist/services/document-service/internationalization.js.map +1 -1
  408. package/dist/services/document-service/internationalization.mjs +61 -50
  409. package/dist/services/document-service/internationalization.mjs.map +1 -1
  410. package/dist/services/document-service/middlewares/errors.js +23 -19
  411. package/dist/services/document-service/middlewares/errors.js.map +1 -1
  412. package/dist/services/document-service/middlewares/errors.mjs +22 -20
  413. package/dist/services/document-service/middlewares/errors.mjs.map +1 -1
  414. package/dist/services/document-service/middlewares/middleware-manager.js +46 -44
  415. package/dist/services/document-service/middlewares/middleware-manager.js.map +1 -1
  416. package/dist/services/document-service/middlewares/middleware-manager.mjs +45 -45
  417. package/dist/services/document-service/middlewares/middleware-manager.mjs.map +1 -1
  418. package/dist/services/document-service/params.js +11 -5
  419. package/dist/services/document-service/params.js.map +1 -1
  420. package/dist/services/document-service/params.mjs +10 -6
  421. package/dist/services/document-service/params.mjs.map +1 -1
  422. package/dist/services/document-service/repository.d.ts.map +1 -1
  423. package/dist/services/document-service/repository.js +353 -321
  424. package/dist/services/document-service/repository.js.map +1 -1
  425. package/dist/services/document-service/repository.mjs +352 -322
  426. package/dist/services/document-service/repository.mjs.map +1 -1
  427. package/dist/services/document-service/transform/data.js +22 -12
  428. package/dist/services/document-service/transform/data.js.map +1 -1
  429. package/dist/services/document-service/transform/data.mjs +21 -13
  430. package/dist/services/document-service/transform/data.mjs.map +1 -1
  431. package/dist/services/document-service/transform/fields.js +26 -17
  432. package/dist/services/document-service/transform/fields.js.map +1 -1
  433. package/dist/services/document-service/transform/fields.mjs +25 -18
  434. package/dist/services/document-service/transform/fields.mjs.map +1 -1
  435. package/dist/services/document-service/transform/id-map.d.ts +1 -1
  436. package/dist/services/document-service/transform/id-map.d.ts.map +1 -1
  437. package/dist/services/document-service/transform/id-map.js +115 -75
  438. package/dist/services/document-service/transform/id-map.js.map +1 -1
  439. package/dist/services/document-service/transform/id-map.mjs +114 -76
  440. package/dist/services/document-service/transform/id-map.mjs.map +1 -1
  441. package/dist/services/document-service/transform/id-transform.d.ts +1 -1
  442. package/dist/services/document-service/transform/id-transform.d.ts.map +1 -1
  443. package/dist/services/document-service/transform/id-transform.js +37 -29
  444. package/dist/services/document-service/transform/id-transform.js.map +1 -1
  445. package/dist/services/document-service/transform/id-transform.mjs +36 -30
  446. package/dist/services/document-service/transform/id-transform.mjs.map +1 -1
  447. package/dist/services/document-service/transform/populate.js +23 -18
  448. package/dist/services/document-service/transform/populate.js.map +1 -1
  449. package/dist/services/document-service/transform/populate.mjs +22 -19
  450. package/dist/services/document-service/transform/populate.mjs.map +1 -1
  451. package/dist/services/document-service/transform/query.js +11 -6
  452. package/dist/services/document-service/transform/query.js.map +1 -1
  453. package/dist/services/document-service/transform/query.mjs +10 -7
  454. package/dist/services/document-service/transform/query.mjs.map +1 -1
  455. package/dist/services/document-service/transform/relations/extract/data-ids.d.ts +1 -1
  456. package/dist/services/document-service/transform/relations/extract/data-ids.d.ts.map +1 -1
  457. package/dist/services/document-service/transform/relations/extract/data-ids.js +70 -54
  458. package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -1
  459. package/dist/services/document-service/transform/relations/extract/data-ids.mjs +69 -55
  460. package/dist/services/document-service/transform/relations/extract/data-ids.mjs.map +1 -1
  461. package/dist/services/document-service/transform/relations/transform/data-ids.js +96 -71
  462. package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
  463. package/dist/services/document-service/transform/relations/transform/data-ids.mjs +95 -72
  464. package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
  465. package/dist/services/document-service/transform/relations/transform/default-locale.js +47 -29
  466. package/dist/services/document-service/transform/relations/transform/default-locale.js.map +1 -1
  467. package/dist/services/document-service/transform/relations/transform/default-locale.mjs +46 -30
  468. package/dist/services/document-service/transform/relations/transform/default-locale.mjs.map +1 -1
  469. package/dist/services/document-service/transform/relations/utils/dp.d.ts +1 -1
  470. package/dist/services/document-service/transform/relations/utils/dp.d.ts.map +1 -1
  471. package/dist/services/document-service/transform/relations/utils/dp.js +52 -26
  472. package/dist/services/document-service/transform/relations/utils/dp.js.map +1 -1
  473. package/dist/services/document-service/transform/relations/utils/dp.mjs +51 -27
  474. package/dist/services/document-service/transform/relations/utils/dp.mjs.map +1 -1
  475. package/dist/services/document-service/transform/relations/utils/i18n.d.ts +1 -1
  476. package/dist/services/document-service/transform/relations/utils/i18n.d.ts.map +1 -1
  477. package/dist/services/document-service/transform/relations/utils/i18n.js +20 -18
  478. package/dist/services/document-service/transform/relations/utils/i18n.js.map +1 -1
  479. package/dist/services/document-service/transform/relations/utils/i18n.mjs +19 -21
  480. package/dist/services/document-service/transform/relations/utils/i18n.mjs.map +1 -1
  481. package/dist/services/document-service/transform/relations/utils/map-relation.js +116 -70
  482. package/dist/services/document-service/transform/relations/utils/map-relation.js.map +1 -1
  483. package/dist/services/document-service/transform/relations/utils/map-relation.mjs +115 -72
  484. package/dist/services/document-service/transform/relations/utils/map-relation.mjs.map +1 -1
  485. package/dist/services/document-service/utils/bidirectional-relations.d.ts +95 -0
  486. package/dist/services/document-service/utils/bidirectional-relations.d.ts.map +1 -0
  487. package/dist/services/document-service/utils/bidirectional-relations.js +148 -0
  488. package/dist/services/document-service/utils/bidirectional-relations.js.map +1 -0
  489. package/dist/services/document-service/utils/bidirectional-relations.mjs +145 -0
  490. package/dist/services/document-service/utils/bidirectional-relations.mjs.map +1 -0
  491. package/dist/services/document-service/utils/populate.d.ts +1 -1
  492. package/dist/services/document-service/utils/populate.d.ts.map +1 -1
  493. package/dist/services/document-service/utils/populate.js +66 -42
  494. package/dist/services/document-service/utils/populate.js.map +1 -1
  495. package/dist/services/document-service/utils/populate.mjs +65 -43
  496. package/dist/services/document-service/utils/populate.mjs.map +1 -1
  497. package/dist/services/document-service/utils/unidirectional-relations.d.ts +1 -1
  498. package/dist/services/document-service/utils/unidirectional-relations.d.ts.map +1 -1
  499. package/dist/services/document-service/utils/unidirectional-relations.js +110 -62
  500. package/dist/services/document-service/utils/unidirectional-relations.js.map +1 -1
  501. package/dist/services/document-service/utils/unidirectional-relations.mjs +109 -64
  502. package/dist/services/document-service/utils/unidirectional-relations.mjs.map +1 -1
  503. package/dist/services/entity-service/index.js +230 -161
  504. package/dist/services/entity-service/index.js.map +1 -1
  505. package/dist/services/entity-service/index.mjs +229 -160
  506. package/dist/services/entity-service/index.mjs.map +1 -1
  507. package/dist/services/entity-validator/blocks-validator.js +135 -103
  508. package/dist/services/entity-validator/blocks-validator.js.map +1 -1
  509. package/dist/services/entity-validator/blocks-validator.mjs +134 -104
  510. package/dist/services/entity-validator/blocks-validator.mjs.map +1 -1
  511. package/dist/services/entity-validator/index.d.ts +1 -1
  512. package/dist/services/entity-validator/index.d.ts.map +1 -1
  513. package/dist/services/entity-validator/index.js +362 -367
  514. package/dist/services/entity-validator/index.js.map +1 -1
  515. package/dist/services/entity-validator/index.mjs +358 -364
  516. package/dist/services/entity-validator/index.mjs.map +1 -1
  517. package/dist/services/entity-validator/validators.js +268 -210
  518. package/dist/services/entity-validator/validators.js.map +1 -1
  519. package/dist/services/entity-validator/validators.mjs +267 -216
  520. package/dist/services/entity-validator/validators.mjs.map +1 -1
  521. package/dist/services/errors.js +65 -65
  522. package/dist/services/errors.js.map +1 -1
  523. package/dist/services/errors.mjs +64 -66
  524. package/dist/services/errors.mjs.map +1 -1
  525. package/dist/services/event-hub.js +82 -69
  526. package/dist/services/event-hub.js.map +1 -1
  527. package/dist/services/event-hub.mjs +81 -71
  528. package/dist/services/event-hub.mjs.map +1 -1
  529. package/dist/services/features.js +19 -14
  530. package/dist/services/features.js.map +1 -1
  531. package/dist/services/features.mjs +18 -15
  532. package/dist/services/features.mjs.map +1 -1
  533. package/dist/services/fs.js +41 -40
  534. package/dist/services/fs.js.map +1 -1
  535. package/dist/services/fs.mjs +40 -39
  536. package/dist/services/fs.mjs.map +1 -1
  537. package/dist/services/metrics/admin-user-hash.js +13 -11
  538. package/dist/services/metrics/admin-user-hash.js.map +1 -1
  539. package/dist/services/metrics/admin-user-hash.mjs +12 -10
  540. package/dist/services/metrics/admin-user-hash.mjs.map +1 -1
  541. package/dist/services/metrics/index.js +46 -39
  542. package/dist/services/metrics/index.js.map +1 -1
  543. package/dist/services/metrics/index.mjs +45 -41
  544. package/dist/services/metrics/index.mjs.map +1 -1
  545. package/dist/services/metrics/is-truthy.js +13 -6
  546. package/dist/services/metrics/is-truthy.js.map +1 -1
  547. package/dist/services/metrics/is-truthy.mjs +12 -6
  548. package/dist/services/metrics/is-truthy.mjs.map +1 -1
  549. package/dist/services/metrics/middleware.d.ts.map +1 -1
  550. package/dist/services/metrics/middleware.js +37 -22
  551. package/dist/services/metrics/middleware.js.map +1 -1
  552. package/dist/services/metrics/middleware.mjs +36 -24
  553. package/dist/services/metrics/middleware.mjs.map +1 -1
  554. package/dist/services/metrics/rate-limiter.d.ts.map +1 -1
  555. package/dist/services/metrics/rate-limiter.js +24 -19
  556. package/dist/services/metrics/rate-limiter.js.map +1 -1
  557. package/dist/services/metrics/rate-limiter.mjs +23 -21
  558. package/dist/services/metrics/rate-limiter.mjs.map +1 -1
  559. package/dist/services/metrics/sender.js +78 -69
  560. package/dist/services/metrics/sender.js.map +1 -1
  561. package/dist/services/metrics/sender.mjs +77 -64
  562. package/dist/services/metrics/sender.mjs.map +1 -1
  563. package/dist/services/query-params.js +13 -10
  564. package/dist/services/query-params.js.map +1 -1
  565. package/dist/services/query-params.mjs +12 -12
  566. package/dist/services/query-params.mjs.map +1 -1
  567. package/dist/services/reloader.js +35 -32
  568. package/dist/services/reloader.js.map +1 -1
  569. package/dist/services/reloader.mjs +34 -33
  570. package/dist/services/reloader.mjs.map +1 -1
  571. package/dist/services/request-context.js +11 -8
  572. package/dist/services/request-context.js.map +1 -1
  573. package/dist/services/request-context.mjs +10 -10
  574. package/dist/services/request-context.mjs.map +1 -1
  575. package/dist/services/server/admin-api.js +11 -10
  576. package/dist/services/server/admin-api.js.map +1 -1
  577. package/dist/services/server/admin-api.mjs +10 -11
  578. package/dist/services/server/admin-api.mjs.map +1 -1
  579. package/dist/services/server/api.js +33 -27
  580. package/dist/services/server/api.js.map +1 -1
  581. package/dist/services/server/api.mjs +32 -26
  582. package/dist/services/server/api.mjs.map +1 -1
  583. package/dist/services/server/compose-endpoint.js +116 -105
  584. package/dist/services/server/compose-endpoint.js.map +1 -1
  585. package/dist/services/server/compose-endpoint.mjs +115 -105
  586. package/dist/services/server/compose-endpoint.mjs.map +1 -1
  587. package/dist/services/server/content-api.js +11 -9
  588. package/dist/services/server/content-api.js.map +1 -1
  589. package/dist/services/server/content-api.mjs +10 -10
  590. package/dist/services/server/content-api.mjs.map +1 -1
  591. package/dist/services/server/http-server.js +48 -44
  592. package/dist/services/server/http-server.js.map +1 -1
  593. package/dist/services/server/http-server.mjs +47 -43
  594. package/dist/services/server/http-server.mjs.map +1 -1
  595. package/dist/services/server/index.js +85 -82
  596. package/dist/services/server/index.js.map +1 -1
  597. package/dist/services/server/index.mjs +84 -81
  598. package/dist/services/server/index.mjs.map +1 -1
  599. package/dist/services/server/koa.js +49 -47
  600. package/dist/services/server/koa.js.map +1 -1
  601. package/dist/services/server/koa.mjs +48 -44
  602. package/dist/services/server/koa.mjs.map +1 -1
  603. package/dist/services/server/middleware.js +86 -82
  604. package/dist/services/server/middleware.js.map +1 -1
  605. package/dist/services/server/middleware.mjs +85 -82
  606. package/dist/services/server/middleware.mjs.map +1 -1
  607. package/dist/services/server/policy.js +24 -17
  608. package/dist/services/server/policy.js.map +1 -1
  609. package/dist/services/server/policy.mjs +23 -18
  610. package/dist/services/server/policy.mjs.map +1 -1
  611. package/dist/services/server/register-middlewares.js +68 -61
  612. package/dist/services/server/register-middlewares.js.map +1 -1
  613. package/dist/services/server/register-middlewares.mjs +67 -63
  614. package/dist/services/server/register-middlewares.mjs.map +1 -1
  615. package/dist/services/server/register-routes.js +90 -67
  616. package/dist/services/server/register-routes.js.map +1 -1
  617. package/dist/services/server/register-routes.mjs +89 -67
  618. package/dist/services/server/register-routes.mjs.map +1 -1
  619. package/dist/services/server/routing.js +94 -81
  620. package/dist/services/server/routing.js.map +1 -1
  621. package/dist/services/server/routing.mjs +93 -81
  622. package/dist/services/server/routing.mjs.map +1 -1
  623. package/dist/services/utils/dynamic-zones.js +13 -14
  624. package/dist/services/utils/dynamic-zones.js.map +1 -1
  625. package/dist/services/utils/dynamic-zones.mjs +12 -16
  626. package/dist/services/utils/dynamic-zones.mjs.map +1 -1
  627. package/dist/services/webhook-runner.js +124 -122
  628. package/dist/services/webhook-runner.js.map +1 -1
  629. package/dist/services/webhook-runner.mjs +123 -121
  630. package/dist/services/webhook-runner.mjs.map +1 -1
  631. package/dist/services/webhook-store.js +132 -99
  632. package/dist/services/webhook-store.js.map +1 -1
  633. package/dist/services/webhook-store.mjs +131 -101
  634. package/dist/services/webhook-store.mjs.map +1 -1
  635. package/dist/services/worker-queue.js +44 -49
  636. package/dist/services/worker-queue.js.map +1 -1
  637. package/dist/services/worker-queue.mjs +43 -49
  638. package/dist/services/worker-queue.mjs.map +1 -1
  639. package/dist/utils/convert-custom-field-type.js +17 -20
  640. package/dist/utils/convert-custom-field-type.js.map +1 -1
  641. package/dist/utils/convert-custom-field-type.mjs +16 -21
  642. package/dist/utils/convert-custom-field-type.mjs.map +1 -1
  643. package/dist/utils/cron.js +64 -30
  644. package/dist/utils/cron.js.map +1 -1
  645. package/dist/utils/cron.mjs +63 -31
  646. package/dist/utils/cron.mjs.map +1 -1
  647. package/dist/utils/fetch.js +24 -18
  648. package/dist/utils/fetch.js.map +1 -1
  649. package/dist/utils/fetch.mjs +23 -19
  650. package/dist/utils/fetch.mjs.map +1 -1
  651. package/dist/utils/filepath-to-prop-path.js +20 -28
  652. package/dist/utils/filepath-to-prop-path.js.map +1 -1
  653. package/dist/utils/filepath-to-prop-path.mjs +19 -26
  654. package/dist/utils/filepath-to-prop-path.mjs.map +1 -1
  655. package/dist/utils/is-initialized.js +21 -12
  656. package/dist/utils/is-initialized.js.map +1 -1
  657. package/dist/utils/is-initialized.mjs +20 -13
  658. package/dist/utils/is-initialized.mjs.map +1 -1
  659. package/dist/utils/lifecycles.js +6 -5
  660. package/dist/utils/lifecycles.js.map +1 -1
  661. package/dist/utils/lifecycles.mjs +5 -6
  662. package/dist/utils/lifecycles.mjs.map +1 -1
  663. package/dist/utils/load-config-file.js +40 -38
  664. package/dist/utils/load-config-file.js.map +1 -1
  665. package/dist/utils/load-config-file.mjs +39 -36
  666. package/dist/utils/load-config-file.mjs.map +1 -1
  667. package/dist/utils/load-files.js +40 -34
  668. package/dist/utils/load-files.js.map +1 -1
  669. package/dist/utils/load-files.mjs +39 -31
  670. package/dist/utils/load-files.mjs.map +1 -1
  671. package/dist/utils/open-browser.js +8 -8
  672. package/dist/utils/open-browser.js.map +1 -1
  673. package/dist/utils/open-browser.mjs +7 -7
  674. package/dist/utils/open-browser.mjs.map +1 -1
  675. package/dist/utils/resolve-working-dirs.js +23 -10
  676. package/dist/utils/resolve-working-dirs.js.map +1 -1
  677. package/dist/utils/resolve-working-dirs.mjs +22 -9
  678. package/dist/utils/resolve-working-dirs.mjs.map +1 -1
  679. package/dist/utils/signals.js +20 -14
  680. package/dist/utils/signals.js.map +1 -1
  681. package/dist/utils/signals.mjs +19 -15
  682. package/dist/utils/signals.mjs.map +1 -1
  683. package/dist/utils/startup-logger.js +107 -83
  684. package/dist/utils/startup-logger.js.map +1 -1
  685. package/dist/utils/startup-logger.mjs +106 -80
  686. package/dist/utils/startup-logger.mjs.map +1 -1
  687. package/dist/utils/transform-content-types-to-models.js +350 -261
  688. package/dist/utils/transform-content-types-to-models.js.map +1 -1
  689. package/dist/utils/transform-content-types-to-models.mjs +349 -269
  690. package/dist/utils/transform-content-types-to-models.mjs.map +1 -1
  691. package/dist/utils/update-notifier/index.d.ts.map +1 -1
  692. package/dist/utils/update-notifier/index.js +68 -73
  693. package/dist/utils/update-notifier/index.js.map +1 -1
  694. package/dist/utils/update-notifier/index.mjs +67 -67
  695. package/dist/utils/update-notifier/index.mjs.map +1 -1
  696. package/package.json +24 -24
@@ -1,52 +1,67 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fp = require("lodash/fp");
4
- const strapiUtils = require("@strapi/utils");
5
- const transform = require("./transform.js");
6
- const singleType = require("./single-type.js");
7
- const collectionType = require("./collection-type.js");
8
- const requestContext = require("../../services/request-context.js");
9
- const isSingleType = (contentType) => strapiUtils.contentTypes.isSingleType(contentType);
10
- const getAuthFromKoaContext = (ctx) => fp.prop("state.auth", ctx) ?? {};
11
- function createController({
12
- contentType
13
- }) {
14
- const proto = {
15
- transformResponse(data, meta) {
16
- const ctx = requestContext.get();
17
- return transform.transformResponse(data, meta, {
18
- contentType,
19
- useJsonAPIFormat: ctx?.headers?.["strapi-response-format"] === "v4"
20
- });
21
- },
22
- async sanitizeOutput(data, ctx) {
23
- const auth = getAuthFromKoaContext(ctx);
24
- return strapi.contentAPI.sanitize.output(data, contentType, { auth });
25
- },
26
- async sanitizeInput(data, ctx) {
27
- const auth = getAuthFromKoaContext(ctx);
28
- return strapi.contentAPI.sanitize.input(data, contentType, { auth });
29
- },
30
- async sanitizeQuery(ctx) {
31
- const auth = getAuthFromKoaContext(ctx);
32
- return strapi.contentAPI.sanitize.query(ctx.query, contentType, { auth });
33
- },
34
- async validateQuery(ctx) {
35
- const auth = getAuthFromKoaContext(ctx);
36
- return strapi.contentAPI.validate.query(ctx.query, contentType, { auth });
37
- },
38
- async validateInput(data, ctx) {
39
- const auth = getAuthFromKoaContext(ctx);
40
- return strapi.contentAPI.validate.input(data, contentType, { auth });
1
+ 'use strict';
2
+
3
+ var fp = require('lodash/fp');
4
+ var strapiUtils = require('@strapi/utils');
5
+ var transform = require('./transform.js');
6
+ var singleType = require('./single-type.js');
7
+ var collectionType = require('./collection-type.js');
8
+ var requestContext = require('../../services/request-context.js');
9
+
10
+ const isSingleType = (contentType)=>strapiUtils.contentTypes.isSingleType(contentType);
11
+ const getAuthFromKoaContext = (ctx)=>fp.prop('state.auth', ctx) ?? {};
12
+ function createController({ contentType }) {
13
+ // TODO: replace with Base class + SingleType and CollectionType classes
14
+ const proto = {
15
+ transformResponse (data, meta) {
16
+ const ctx = requestContext.get();
17
+ return transform.transformResponse(data, meta, {
18
+ contentType,
19
+ useJsonAPIFormat: ctx?.headers?.['strapi-response-format'] === 'v4'
20
+ });
21
+ },
22
+ async sanitizeOutput (data, ctx) {
23
+ const auth = getAuthFromKoaContext(ctx);
24
+ return strapi.contentAPI.sanitize.output(data, contentType, {
25
+ auth
26
+ });
27
+ },
28
+ async sanitizeInput (data, ctx) {
29
+ const auth = getAuthFromKoaContext(ctx);
30
+ return strapi.contentAPI.sanitize.input(data, contentType, {
31
+ auth
32
+ });
33
+ },
34
+ async sanitizeQuery (ctx) {
35
+ const auth = getAuthFromKoaContext(ctx);
36
+ return strapi.contentAPI.sanitize.query(ctx.query, contentType, {
37
+ auth
38
+ });
39
+ },
40
+ async validateQuery (ctx) {
41
+ const auth = getAuthFromKoaContext(ctx);
42
+ return strapi.contentAPI.validate.query(ctx.query, contentType, {
43
+ auth
44
+ });
45
+ },
46
+ async validateInput (data, ctx) {
47
+ const auth = getAuthFromKoaContext(ctx);
48
+ return strapi.contentAPI.validate.input(data, contentType, {
49
+ auth
50
+ });
51
+ }
52
+ };
53
+ let ctrl;
54
+ if (isSingleType(contentType)) {
55
+ ctrl = singleType.createSingleTypeController({
56
+ contentType
57
+ });
58
+ } else {
59
+ ctrl = collectionType.createCollectionTypeController({
60
+ contentType
61
+ });
41
62
  }
42
- };
43
- let ctrl;
44
- if (isSingleType(contentType)) {
45
- ctrl = singleType.createSingleTypeController({ contentType });
46
- } else {
47
- ctrl = collectionType.createCollectionTypeController({ contentType });
48
- }
49
- return Object.assign(Object.create(proto), ctrl);
63
+ return Object.assign(Object.create(proto), ctrl);
50
64
  }
65
+
51
66
  exports.createController = createController;
52
67
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/core-api/controller/index.ts"],"sourcesContent":["import { prop } from 'lodash/fp';\nimport type Koa from 'koa';\nimport { contentTypes as contentTypeUtils } from '@strapi/utils';\nimport type { Core, Struct } from '@strapi/types';\n\nimport { transformResponse } from './transform';\nimport { createSingleTypeController } from './single-type';\nimport { createCollectionTypeController } from './collection-type';\nimport requestCtx from '../../services/request-context';\n\nconst isSingleType = (\n contentType: Struct.ContentTypeSchema\n): contentType is Struct.SingleTypeSchema => contentTypeUtils.isSingleType(contentType);\n\nconst getAuthFromKoaContext = (ctx: Koa.Context) => prop('state.auth', ctx) ?? {};\n\nfunction createController<T extends Struct.SingleTypeSchema | Struct.CollectionTypeSchema>(opts: {\n contentType: T;\n}): T extends Struct.SingleTypeSchema\n ? Core.CoreAPI.Controller.SingleType\n : Core.CoreAPI.Controller.CollectionType;\nfunction createController({\n contentType,\n}: {\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema;\n}) {\n // TODO: replace with Base class + SingleType and CollectionType classes\n\n const proto: Core.CoreAPI.Controller.Base = {\n transformResponse(data, meta) {\n const ctx = requestCtx.get();\n return transformResponse(data, meta, {\n contentType,\n useJsonAPIFormat: ctx?.headers?.['strapi-response-format'] === 'v4',\n });\n },\n\n async sanitizeOutput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.sanitize.output(data, contentType, { auth });\n },\n\n async sanitizeInput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.sanitize.input(data, contentType, { auth });\n },\n\n async sanitizeQuery(ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.sanitize.query(ctx.query, contentType, { auth });\n },\n\n async validateQuery(ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.validate.query(ctx.query, contentType, { auth });\n },\n\n async validateInput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.validate.input(data, contentType, { auth });\n },\n };\n\n let ctrl;\n\n if (isSingleType(contentType)) {\n ctrl = createSingleTypeController({ contentType });\n } else {\n ctrl = createCollectionTypeController({ contentType });\n }\n\n return Object.assign(Object.create(proto), ctrl);\n}\n\nexport { createController };\n"],"names":["contentTypeUtils","prop","requestCtx","transformResponse","createSingleTypeController","createCollectionTypeController"],"mappings":";;;;;;;;AAUA,MAAM,eAAe,CACnB,gBAC2CA,yBAAiB,aAAa,WAAW;AAEtF,MAAM,wBAAwB,CAAC,QAAqBC,GAAAA,KAAK,cAAc,GAAG,KAAK,CAAC;AAOhF,SAAS,iBAAiB;AAAA,EACxB;AACF,GAEG;AAGD,QAAM,QAAsC;AAAA,IAC1C,kBAAkB,MAAM,MAAM;AACtB,YAAA,MAAMC,eAAW,IAAI;AACpB,aAAAC,UAAA,kBAAkB,MAAM,MAAM;AAAA,QACnC;AAAA,QACA,kBAAkB,KAAK,UAAU,wBAAwB,MAAM;AAAA,MAAA,CAChE;AAAA,IACH;AAAA,IAEA,MAAM,eAAe,MAAM,KAAK;AACxB,YAAA,OAAO,sBAAsB,GAAG;AAE/B,aAAA,OAAO,WAAW,SAAS,OAAO,MAAM,aAAa,EAAE,MAAM;AAAA,IACtE;AAAA,IAEA,MAAM,cAAc,MAAM,KAAK;AACvB,YAAA,OAAO,sBAAsB,GAAG;AAE/B,aAAA,OAAO,WAAW,SAAS,MAAM,MAAM,aAAa,EAAE,MAAM;AAAA,IACrE;AAAA,IAEA,MAAM,cAAc,KAAK;AACjB,YAAA,OAAO,sBAAsB,GAAG;AAE/B,aAAA,OAAO,WAAW,SAAS,MAAM,IAAI,OAAO,aAAa,EAAE,MAAM;AAAA,IAC1E;AAAA,IAEA,MAAM,cAAc,KAAK;AACjB,YAAA,OAAO,sBAAsB,GAAG;AAE/B,aAAA,OAAO,WAAW,SAAS,MAAM,IAAI,OAAO,aAAa,EAAE,MAAM;AAAA,IAC1E;AAAA,IAEA,MAAM,cAAc,MAAM,KAAK;AACvB,YAAA,OAAO,sBAAsB,GAAG;AAE/B,aAAA,OAAO,WAAW,SAAS,MAAM,MAAM,aAAa,EAAE,MAAM;AAAA,IAAA;AAAA,EAEvE;AAEI,MAAA;AAEA,MAAA,aAAa,WAAW,GAAG;AACtB,WAAAC,WAAAA,2BAA2B,EAAE,aAAa;AAAA,EAAA,OAC5C;AACE,WAAAC,eAAAA,+BAA+B,EAAE,aAAa;AAAA,EAAA;AAGvD,SAAO,OAAO,OAAO,OAAO,OAAO,KAAK,GAAG,IAAI;AACjD;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/core-api/controller/index.ts"],"sourcesContent":["import { prop } from 'lodash/fp';\nimport type Koa from 'koa';\nimport { contentTypes as contentTypeUtils } from '@strapi/utils';\nimport type { Core, Struct } from '@strapi/types';\n\nimport { transformResponse } from './transform';\nimport { createSingleTypeController } from './single-type';\nimport { createCollectionTypeController } from './collection-type';\nimport requestCtx from '../../services/request-context';\n\nconst isSingleType = (\n contentType: Struct.ContentTypeSchema\n): contentType is Struct.SingleTypeSchema => contentTypeUtils.isSingleType(contentType);\n\nconst getAuthFromKoaContext = (ctx: Koa.Context) => prop('state.auth', ctx) ?? {};\n\nfunction createController<T extends Struct.SingleTypeSchema | Struct.CollectionTypeSchema>(opts: {\n contentType: T;\n}): T extends Struct.SingleTypeSchema\n ? Core.CoreAPI.Controller.SingleType\n : Core.CoreAPI.Controller.CollectionType;\nfunction createController({\n contentType,\n}: {\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema;\n}) {\n // TODO: replace with Base class + SingleType and CollectionType classes\n\n const proto: Core.CoreAPI.Controller.Base = {\n transformResponse(data, meta) {\n const ctx = requestCtx.get();\n return transformResponse(data, meta, {\n contentType,\n useJsonAPIFormat: ctx?.headers?.['strapi-response-format'] === 'v4',\n });\n },\n\n async sanitizeOutput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.sanitize.output(data, contentType, { auth });\n },\n\n async sanitizeInput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.sanitize.input(data, contentType, { auth });\n },\n\n async sanitizeQuery(ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.sanitize.query(ctx.query, contentType, { auth });\n },\n\n async validateQuery(ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.validate.query(ctx.query, contentType, { auth });\n },\n\n async validateInput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.validate.input(data, contentType, { auth });\n },\n };\n\n let ctrl;\n\n if (isSingleType(contentType)) {\n ctrl = createSingleTypeController({ contentType });\n } else {\n ctrl = createCollectionTypeController({ contentType });\n }\n\n return Object.assign(Object.create(proto), ctrl);\n}\n\nexport { createController };\n"],"names":["isSingleType","contentType","contentTypeUtils","getAuthFromKoaContext","ctx","prop","createController","proto","transformResponse","data","meta","requestCtx","get","useJsonAPIFormat","headers","sanitizeOutput","auth","strapi","contentAPI","sanitize","output","sanitizeInput","input","sanitizeQuery","query","validateQuery","validate","validateInput","ctrl","createSingleTypeController","createCollectionTypeController","Object","assign","create"],"mappings":";;;;;;;;;AAUA,MAAMA,YAAe,GAAA,CACnBC,WAC2CC,GAAAA,wBAAAA,CAAiBF,YAAY,CAACC,WAAAA,CAAAA;AAE3E,MAAME,wBAAwB,CAACC,GAAAA,GAAqBC,OAAK,CAAA,YAAA,EAAcD,QAAQ,EAAC;AAOhF,SAASE,gBAAAA,CAAiB,EACxBL,WAAW,EAGZ,EAAA;;AAGC,IAAA,MAAMM,KAAsC,GAAA;QAC1CC,iBAAkBC,CAAAA,CAAAA,IAAI,EAAEC,IAAI,EAAA;YAC1B,MAAMN,GAAAA,GAAMO,eAAWC,GAAG,EAAA;YAC1B,OAAOJ,2BAAAA,CAAkBC,MAAMC,IAAM,EAAA;AACnCT,gBAAAA,WAAAA;AACAY,gBAAAA,gBAAAA,EAAkBT,GAAKU,EAAAA,OAAAA,GAAU,wBAAA,CAAyB,KAAK;AACjE,aAAA,CAAA;AACF,SAAA;QAEA,MAAMC,cAAAA,CAAAA,CAAeN,IAAI,EAAEL,GAAG,EAAA;AAC5B,YAAA,MAAMY,OAAOb,qBAAsBC,CAAAA,GAAAA,CAAAA;YAEnC,OAAOa,MAAAA,CAAOC,UAAU,CAACC,QAAQ,CAACC,MAAM,CAACX,MAAMR,WAAa,EAAA;AAAEe,gBAAAA;AAAK,aAAA,CAAA;AACrE,SAAA;QAEA,MAAMK,aAAAA,CAAAA,CAAcZ,IAAI,EAAEL,GAAG,EAAA;AAC3B,YAAA,MAAMY,OAAOb,qBAAsBC,CAAAA,GAAAA,CAAAA;YAEnC,OAAOa,MAAAA,CAAOC,UAAU,CAACC,QAAQ,CAACG,KAAK,CAACb,MAAMR,WAAa,EAAA;AAAEe,gBAAAA;AAAK,aAAA,CAAA;AACpE,SAAA;AAEA,QAAA,MAAMO,eAAcnB,GAAG,EAAA;AACrB,YAAA,MAAMY,OAAOb,qBAAsBC,CAAAA,GAAAA,CAAAA;YAEnC,OAAOa,MAAAA,CAAOC,UAAU,CAACC,QAAQ,CAACK,KAAK,CAACpB,GAAAA,CAAIoB,KAAK,EAAEvB,WAAa,EAAA;AAAEe,gBAAAA;AAAK,aAAA,CAAA;AACzE,SAAA;AAEA,QAAA,MAAMS,eAAcrB,GAAG,EAAA;AACrB,YAAA,MAAMY,OAAOb,qBAAsBC,CAAAA,GAAAA,CAAAA;YAEnC,OAAOa,MAAAA,CAAOC,UAAU,CAACQ,QAAQ,CAACF,KAAK,CAACpB,GAAAA,CAAIoB,KAAK,EAAEvB,WAAa,EAAA;AAAEe,gBAAAA;AAAK,aAAA,CAAA;AACzE,SAAA;QAEA,MAAMW,aAAAA,CAAAA,CAAclB,IAAI,EAAEL,GAAG,EAAA;AAC3B,YAAA,MAAMY,OAAOb,qBAAsBC,CAAAA,GAAAA,CAAAA;YAEnC,OAAOa,MAAAA,CAAOC,UAAU,CAACQ,QAAQ,CAACJ,KAAK,CAACb,MAAMR,WAAa,EAAA;AAAEe,gBAAAA;AAAK,aAAA,CAAA;AACpE;AACF,KAAA;IAEA,IAAIY,IAAAA;AAEJ,IAAA,IAAI5B,aAAaC,WAAc,CAAA,EAAA;AAC7B2B,QAAAA,IAAAA,GAAOC,qCAA2B,CAAA;AAAE5B,YAAAA;AAAY,SAAA,CAAA;KAC3C,MAAA;AACL2B,QAAAA,IAAAA,GAAOE,6CAA+B,CAAA;AAAE7B,YAAAA;AAAY,SAAA,CAAA;AACtD;AAEA,IAAA,OAAO8B,OAAOC,MAAM,CAACD,MAAOE,CAAAA,MAAM,CAAC1B,KAAQqB,CAAAA,EAAAA,IAAAA,CAAAA;AAC7C;;;;"}
@@ -1,52 +1,65 @@
1
- import { prop } from "lodash/fp";
2
- import { contentTypes } from "@strapi/utils";
3
- import { transformResponse } from "./transform.mjs";
4
- import { createSingleTypeController } from "./single-type.mjs";
5
- import { createCollectionTypeController } from "./collection-type.mjs";
6
- import requestCtx from "../../services/request-context.mjs";
7
- const isSingleType = (contentType) => contentTypes.isSingleType(contentType);
8
- const getAuthFromKoaContext = (ctx) => prop("state.auth", ctx) ?? {};
9
- function createController({
10
- contentType
11
- }) {
12
- const proto = {
13
- transformResponse(data, meta) {
14
- const ctx = requestCtx.get();
15
- return transformResponse(data, meta, {
16
- contentType,
17
- useJsonAPIFormat: ctx?.headers?.["strapi-response-format"] === "v4"
18
- });
19
- },
20
- async sanitizeOutput(data, ctx) {
21
- const auth = getAuthFromKoaContext(ctx);
22
- return strapi.contentAPI.sanitize.output(data, contentType, { auth });
23
- },
24
- async sanitizeInput(data, ctx) {
25
- const auth = getAuthFromKoaContext(ctx);
26
- return strapi.contentAPI.sanitize.input(data, contentType, { auth });
27
- },
28
- async sanitizeQuery(ctx) {
29
- const auth = getAuthFromKoaContext(ctx);
30
- return strapi.contentAPI.sanitize.query(ctx.query, contentType, { auth });
31
- },
32
- async validateQuery(ctx) {
33
- const auth = getAuthFromKoaContext(ctx);
34
- return strapi.contentAPI.validate.query(ctx.query, contentType, { auth });
35
- },
36
- async validateInput(data, ctx) {
37
- const auth = getAuthFromKoaContext(ctx);
38
- return strapi.contentAPI.validate.input(data, contentType, { auth });
1
+ import { prop } from 'lodash/fp';
2
+ import { contentTypes } from '@strapi/utils';
3
+ import { transformResponse } from './transform.mjs';
4
+ import { createSingleTypeController } from './single-type.mjs';
5
+ import { createCollectionTypeController } from './collection-type.mjs';
6
+ import requestCtx from '../../services/request-context.mjs';
7
+
8
+ const isSingleType = (contentType)=>contentTypes.isSingleType(contentType);
9
+ const getAuthFromKoaContext = (ctx)=>prop('state.auth', ctx) ?? {};
10
+ function createController({ contentType }) {
11
+ // TODO: replace with Base class + SingleType and CollectionType classes
12
+ const proto = {
13
+ transformResponse (data, meta) {
14
+ const ctx = requestCtx.get();
15
+ return transformResponse(data, meta, {
16
+ contentType,
17
+ useJsonAPIFormat: ctx?.headers?.['strapi-response-format'] === 'v4'
18
+ });
19
+ },
20
+ async sanitizeOutput (data, ctx) {
21
+ const auth = getAuthFromKoaContext(ctx);
22
+ return strapi.contentAPI.sanitize.output(data, contentType, {
23
+ auth
24
+ });
25
+ },
26
+ async sanitizeInput (data, ctx) {
27
+ const auth = getAuthFromKoaContext(ctx);
28
+ return strapi.contentAPI.sanitize.input(data, contentType, {
29
+ auth
30
+ });
31
+ },
32
+ async sanitizeQuery (ctx) {
33
+ const auth = getAuthFromKoaContext(ctx);
34
+ return strapi.contentAPI.sanitize.query(ctx.query, contentType, {
35
+ auth
36
+ });
37
+ },
38
+ async validateQuery (ctx) {
39
+ const auth = getAuthFromKoaContext(ctx);
40
+ return strapi.contentAPI.validate.query(ctx.query, contentType, {
41
+ auth
42
+ });
43
+ },
44
+ async validateInput (data, ctx) {
45
+ const auth = getAuthFromKoaContext(ctx);
46
+ return strapi.contentAPI.validate.input(data, contentType, {
47
+ auth
48
+ });
49
+ }
50
+ };
51
+ let ctrl;
52
+ if (isSingleType(contentType)) {
53
+ ctrl = createSingleTypeController({
54
+ contentType
55
+ });
56
+ } else {
57
+ ctrl = createCollectionTypeController({
58
+ contentType
59
+ });
39
60
  }
40
- };
41
- let ctrl;
42
- if (isSingleType(contentType)) {
43
- ctrl = createSingleTypeController({ contentType });
44
- } else {
45
- ctrl = createCollectionTypeController({ contentType });
46
- }
47
- return Object.assign(Object.create(proto), ctrl);
61
+ return Object.assign(Object.create(proto), ctrl);
48
62
  }
49
- export {
50
- createController
51
- };
63
+
64
+ export { createController };
52
65
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../src/core-api/controller/index.ts"],"sourcesContent":["import { prop } from 'lodash/fp';\nimport type Koa from 'koa';\nimport { contentTypes as contentTypeUtils } from '@strapi/utils';\nimport type { Core, Struct } from '@strapi/types';\n\nimport { transformResponse } from './transform';\nimport { createSingleTypeController } from './single-type';\nimport { createCollectionTypeController } from './collection-type';\nimport requestCtx from '../../services/request-context';\n\nconst isSingleType = (\n contentType: Struct.ContentTypeSchema\n): contentType is Struct.SingleTypeSchema => contentTypeUtils.isSingleType(contentType);\n\nconst getAuthFromKoaContext = (ctx: Koa.Context) => prop('state.auth', ctx) ?? {};\n\nfunction createController<T extends Struct.SingleTypeSchema | Struct.CollectionTypeSchema>(opts: {\n contentType: T;\n}): T extends Struct.SingleTypeSchema\n ? Core.CoreAPI.Controller.SingleType\n : Core.CoreAPI.Controller.CollectionType;\nfunction createController({\n contentType,\n}: {\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema;\n}) {\n // TODO: replace with Base class + SingleType and CollectionType classes\n\n const proto: Core.CoreAPI.Controller.Base = {\n transformResponse(data, meta) {\n const ctx = requestCtx.get();\n return transformResponse(data, meta, {\n contentType,\n useJsonAPIFormat: ctx?.headers?.['strapi-response-format'] === 'v4',\n });\n },\n\n async sanitizeOutput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.sanitize.output(data, contentType, { auth });\n },\n\n async sanitizeInput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.sanitize.input(data, contentType, { auth });\n },\n\n async sanitizeQuery(ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.sanitize.query(ctx.query, contentType, { auth });\n },\n\n async validateQuery(ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.validate.query(ctx.query, contentType, { auth });\n },\n\n async validateInput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.validate.input(data, contentType, { auth });\n },\n };\n\n let ctrl;\n\n if (isSingleType(contentType)) {\n ctrl = createSingleTypeController({ contentType });\n } else {\n ctrl = createCollectionTypeController({ contentType });\n }\n\n return Object.assign(Object.create(proto), ctrl);\n}\n\nexport { createController };\n"],"names":["contentTypeUtils"],"mappings":";;;;;;AAUA,MAAM,eAAe,CACnB,gBAC2CA,aAAiB,aAAa,WAAW;AAEtF,MAAM,wBAAwB,CAAC,QAAqB,KAAK,cAAc,GAAG,KAAK,CAAC;AAOhF,SAAS,iBAAiB;AAAA,EACxB;AACF,GAEG;AAGD,QAAM,QAAsC;AAAA,IAC1C,kBAAkB,MAAM,MAAM;AACtB,YAAA,MAAM,WAAW,IAAI;AACpB,aAAA,kBAAkB,MAAM,MAAM;AAAA,QACnC;AAAA,QACA,kBAAkB,KAAK,UAAU,wBAAwB,MAAM;AAAA,MAAA,CAChE;AAAA,IACH;AAAA,IAEA,MAAM,eAAe,MAAM,KAAK;AACxB,YAAA,OAAO,sBAAsB,GAAG;AAE/B,aAAA,OAAO,WAAW,SAAS,OAAO,MAAM,aAAa,EAAE,MAAM;AAAA,IACtE;AAAA,IAEA,MAAM,cAAc,MAAM,KAAK;AACvB,YAAA,OAAO,sBAAsB,GAAG;AAE/B,aAAA,OAAO,WAAW,SAAS,MAAM,MAAM,aAAa,EAAE,MAAM;AAAA,IACrE;AAAA,IAEA,MAAM,cAAc,KAAK;AACjB,YAAA,OAAO,sBAAsB,GAAG;AAE/B,aAAA,OAAO,WAAW,SAAS,MAAM,IAAI,OAAO,aAAa,EAAE,MAAM;AAAA,IAC1E;AAAA,IAEA,MAAM,cAAc,KAAK;AACjB,YAAA,OAAO,sBAAsB,GAAG;AAE/B,aAAA,OAAO,WAAW,SAAS,MAAM,IAAI,OAAO,aAAa,EAAE,MAAM;AAAA,IAC1E;AAAA,IAEA,MAAM,cAAc,MAAM,KAAK;AACvB,YAAA,OAAO,sBAAsB,GAAG;AAE/B,aAAA,OAAO,WAAW,SAAS,MAAM,MAAM,aAAa,EAAE,MAAM;AAAA,IAAA;AAAA,EAEvE;AAEI,MAAA;AAEA,MAAA,aAAa,WAAW,GAAG;AACtB,WAAA,2BAA2B,EAAE,aAAa;AAAA,EAAA,OAC5C;AACE,WAAA,+BAA+B,EAAE,aAAa;AAAA,EAAA;AAGvD,SAAO,OAAO,OAAO,OAAO,OAAO,KAAK,GAAG,IAAI;AACjD;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../src/core-api/controller/index.ts"],"sourcesContent":["import { prop } from 'lodash/fp';\nimport type Koa from 'koa';\nimport { contentTypes as contentTypeUtils } from '@strapi/utils';\nimport type { Core, Struct } from '@strapi/types';\n\nimport { transformResponse } from './transform';\nimport { createSingleTypeController } from './single-type';\nimport { createCollectionTypeController } from './collection-type';\nimport requestCtx from '../../services/request-context';\n\nconst isSingleType = (\n contentType: Struct.ContentTypeSchema\n): contentType is Struct.SingleTypeSchema => contentTypeUtils.isSingleType(contentType);\n\nconst getAuthFromKoaContext = (ctx: Koa.Context) => prop('state.auth', ctx) ?? {};\n\nfunction createController<T extends Struct.SingleTypeSchema | Struct.CollectionTypeSchema>(opts: {\n contentType: T;\n}): T extends Struct.SingleTypeSchema\n ? Core.CoreAPI.Controller.SingleType\n : Core.CoreAPI.Controller.CollectionType;\nfunction createController({\n contentType,\n}: {\n contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema;\n}) {\n // TODO: replace with Base class + SingleType and CollectionType classes\n\n const proto: Core.CoreAPI.Controller.Base = {\n transformResponse(data, meta) {\n const ctx = requestCtx.get();\n return transformResponse(data, meta, {\n contentType,\n useJsonAPIFormat: ctx?.headers?.['strapi-response-format'] === 'v4',\n });\n },\n\n async sanitizeOutput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.sanitize.output(data, contentType, { auth });\n },\n\n async sanitizeInput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.sanitize.input(data, contentType, { auth });\n },\n\n async sanitizeQuery(ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.sanitize.query(ctx.query, contentType, { auth });\n },\n\n async validateQuery(ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.validate.query(ctx.query, contentType, { auth });\n },\n\n async validateInput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return strapi.contentAPI.validate.input(data, contentType, { auth });\n },\n };\n\n let ctrl;\n\n if (isSingleType(contentType)) {\n ctrl = createSingleTypeController({ contentType });\n } else {\n ctrl = createCollectionTypeController({ contentType });\n }\n\n return Object.assign(Object.create(proto), ctrl);\n}\n\nexport { createController };\n"],"names":["isSingleType","contentType","contentTypeUtils","getAuthFromKoaContext","ctx","prop","createController","proto","transformResponse","data","meta","requestCtx","get","useJsonAPIFormat","headers","sanitizeOutput","auth","strapi","contentAPI","sanitize","output","sanitizeInput","input","sanitizeQuery","query","validateQuery","validate","validateInput","ctrl","createSingleTypeController","createCollectionTypeController","Object","assign","create"],"mappings":";;;;;;;AAUA,MAAMA,YAAe,GAAA,CACnBC,WAC2CC,GAAAA,YAAAA,CAAiBF,YAAY,CAACC,WAAAA,CAAAA;AAE3E,MAAME,wBAAwB,CAACC,GAAAA,GAAqBC,IAAK,CAAA,YAAA,EAAcD,QAAQ,EAAC;AAOhF,SAASE,gBAAAA,CAAiB,EACxBL,WAAW,EAGZ,EAAA;;AAGC,IAAA,MAAMM,KAAsC,GAAA;QAC1CC,iBAAkBC,CAAAA,CAAAA,IAAI,EAAEC,IAAI,EAAA;YAC1B,MAAMN,GAAAA,GAAMO,WAAWC,GAAG,EAAA;YAC1B,OAAOJ,iBAAAA,CAAkBC,MAAMC,IAAM,EAAA;AACnCT,gBAAAA,WAAAA;AACAY,gBAAAA,gBAAAA,EAAkBT,GAAKU,EAAAA,OAAAA,GAAU,wBAAA,CAAyB,KAAK;AACjE,aAAA,CAAA;AACF,SAAA;QAEA,MAAMC,cAAAA,CAAAA,CAAeN,IAAI,EAAEL,GAAG,EAAA;AAC5B,YAAA,MAAMY,OAAOb,qBAAsBC,CAAAA,GAAAA,CAAAA;YAEnC,OAAOa,MAAAA,CAAOC,UAAU,CAACC,QAAQ,CAACC,MAAM,CAACX,MAAMR,WAAa,EAAA;AAAEe,gBAAAA;AAAK,aAAA,CAAA;AACrE,SAAA;QAEA,MAAMK,aAAAA,CAAAA,CAAcZ,IAAI,EAAEL,GAAG,EAAA;AAC3B,YAAA,MAAMY,OAAOb,qBAAsBC,CAAAA,GAAAA,CAAAA;YAEnC,OAAOa,MAAAA,CAAOC,UAAU,CAACC,QAAQ,CAACG,KAAK,CAACb,MAAMR,WAAa,EAAA;AAAEe,gBAAAA;AAAK,aAAA,CAAA;AACpE,SAAA;AAEA,QAAA,MAAMO,eAAcnB,GAAG,EAAA;AACrB,YAAA,MAAMY,OAAOb,qBAAsBC,CAAAA,GAAAA,CAAAA;YAEnC,OAAOa,MAAAA,CAAOC,UAAU,CAACC,QAAQ,CAACK,KAAK,CAACpB,GAAAA,CAAIoB,KAAK,EAAEvB,WAAa,EAAA;AAAEe,gBAAAA;AAAK,aAAA,CAAA;AACzE,SAAA;AAEA,QAAA,MAAMS,eAAcrB,GAAG,EAAA;AACrB,YAAA,MAAMY,OAAOb,qBAAsBC,CAAAA,GAAAA,CAAAA;YAEnC,OAAOa,MAAAA,CAAOC,UAAU,CAACQ,QAAQ,CAACF,KAAK,CAACpB,GAAAA,CAAIoB,KAAK,EAAEvB,WAAa,EAAA;AAAEe,gBAAAA;AAAK,aAAA,CAAA;AACzE,SAAA;QAEA,MAAMW,aAAAA,CAAAA,CAAclB,IAAI,EAAEL,GAAG,EAAA;AAC3B,YAAA,MAAMY,OAAOb,qBAAsBC,CAAAA,GAAAA,CAAAA;YAEnC,OAAOa,MAAAA,CAAOC,UAAU,CAACQ,QAAQ,CAACJ,KAAK,CAACb,MAAMR,WAAa,EAAA;AAAEe,gBAAAA;AAAK,aAAA,CAAA;AACpE;AACF,KAAA;IAEA,IAAIY,IAAAA;AAEJ,IAAA,IAAI5B,aAAaC,WAAc,CAAA,EAAA;AAC7B2B,QAAAA,IAAAA,GAAOC,0BAA2B,CAAA;AAAE5B,YAAAA;AAAY,SAAA,CAAA;KAC3C,MAAA;AACL2B,QAAAA,IAAAA,GAAOE,8BAA+B,CAAA;AAAE7B,YAAAA;AAAY,SAAA,CAAA;AACtD;AAEA,IAAA,OAAO8B,OAAOC,MAAM,CAACD,MAAOE,CAAAA,MAAM,CAAC1B,KAAQqB,CAAAA,EAAAA,IAAAA,CAAAA;AAC7C;;;;"}
@@ -1,46 +1,47 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fp = require("lodash/fp");
4
- const strapiUtils = require("@strapi/utils");
5
- const createSingleTypeController = ({
6
- contentType
7
- }) => {
8
- const uid = contentType.uid;
9
- return {
10
- /**
1
+ 'use strict';
2
+
3
+ var fp = require('lodash/fp');
4
+ var strapiUtils = require('@strapi/utils');
5
+
6
+ /**
7
+ * Returns a single type controller to handle default core-api actions
8
+ */ const createSingleTypeController = ({ contentType })=>{
9
+ const uid = contentType.uid;
10
+ // TODO: transform into a class
11
+ return {
12
+ /**
11
13
  * Retrieve single type content
12
14
  *
13
- */
14
- async find(ctx) {
15
- await this.validateQuery(ctx);
16
- const sanitizedQuery = await this.sanitizeQuery(ctx);
17
- const entity = await strapi.service(uid).find(sanitizedQuery);
18
- const sanitizedEntity = await this.sanitizeOutput(entity, ctx);
19
- return this.transformResponse(sanitizedEntity);
20
- },
21
- /**
15
+ */ async find (ctx) {
16
+ await this.validateQuery(ctx);
17
+ const sanitizedQuery = await this.sanitizeQuery(ctx);
18
+ const entity = await strapi.service(uid).find(sanitizedQuery);
19
+ const sanitizedEntity = await this.sanitizeOutput(entity, ctx);
20
+ return this.transformResponse(sanitizedEntity);
21
+ },
22
+ /**
22
23
  * create or update single type content.
23
- */
24
- async update(ctx) {
25
- const { query, body = {} } = ctx.request;
26
- if (!fp.isObject(body.data)) {
27
- throw new strapiUtils.errors.ValidationError('Missing "data" payload in the request body');
28
- }
29
- await this.validateInput(body.data, ctx);
30
- const sanitizedInputData = await this.sanitizeInput(body.data, ctx);
31
- const entity = await strapi.service(uid).createOrUpdate({
32
- ...query,
33
- data: sanitizedInputData
34
- });
35
- const sanitizedEntity = await this.sanitizeOutput(entity, ctx);
36
- return this.transformResponse(sanitizedEntity);
37
- },
38
- async delete(ctx) {
39
- const { query } = ctx;
40
- await strapi.service(uid).delete(query);
41
- ctx.status = 204;
42
- }
43
- };
24
+ */ async update (ctx) {
25
+ const { query, body = {} } = ctx.request;
26
+ if (!fp.isObject(body.data)) {
27
+ throw new strapiUtils.errors.ValidationError('Missing "data" payload in the request body');
28
+ }
29
+ await this.validateInput(body.data, ctx);
30
+ const sanitizedInputData = await this.sanitizeInput(body.data, ctx);
31
+ const entity = await strapi.service(uid).createOrUpdate({
32
+ ...query,
33
+ data: sanitizedInputData
34
+ });
35
+ const sanitizedEntity = await this.sanitizeOutput(entity, ctx);
36
+ return this.transformResponse(sanitizedEntity);
37
+ },
38
+ async delete (ctx) {
39
+ const { query } = ctx;
40
+ await strapi.service(uid).delete(query);
41
+ ctx.status = 204;
42
+ }
43
+ };
44
44
  };
45
+
45
46
  exports.createSingleTypeController = createSingleTypeController;
46
47
  //# sourceMappingURL=single-type.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"single-type.js","sources":["../../../src/core-api/controller/single-type.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Struct, Core, Utils, UID } from '@strapi/types';\n\ninterface Options {\n contentType: Struct.SingleTypeSchema;\n}\n\n/**\n * Returns a single type controller to handle default core-api actions\n */\nconst createSingleTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<Core.CoreAPI.Controller.SingleType> => {\n const uid = contentType.uid as UID.Service;\n\n // TODO: transform into a class\n return {\n /**\n * Retrieve single type content\n *\n */\n async find(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).find(sanitizedQuery);\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * create or update single type content.\n */\n async update(ctx) {\n const { query, body = {} as any } = ctx.request;\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n await this.validateInput(body.data, ctx);\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).createOrUpdate({\n ...query,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n async delete(ctx) {\n const { query } = ctx;\n\n await strapi.service(uid).delete(query);\n\n ctx.status = 204;\n },\n };\n};\n\nexport { createSingleTypeController };\n"],"names":["isObject","errors"],"mappings":";;;;AAWA,MAAM,6BAA6B,CAAC;AAAA,EAClC;AACF,MAA0E;AACxE,QAAM,MAAM,YAAY;AAGjB,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL,MAAM,KAAK,KAAK;AACR,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAEnD,YAAM,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,KAAK,cAAc;AAE5D,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,OAAO,KAAK;AAChB,YAAM,EAAE,OAAO,OAAO,CAAA,MAAc,IAAI;AAExC,UAAI,CAACA,GAAA,SAAS,KAAK,IAAI,GAAG;AAClB,cAAA,IAAIC,YAAAA,OAAO,gBAAgB,4CAA4C;AAAA,MAAA;AAG/E,YAAM,KAAK,cAAc,KAAK,MAAM,GAAG;AAEvC,YAAM,qBAAqB,MAAM,KAAK,cAAc,KAAK,MAAM,GAAG;AAElE,YAAM,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,eAAe;AAAA,QACtD,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACP;AAED,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA,IAEA,MAAM,OAAO,KAAK;AACV,YAAA,EAAE,UAAU;AAElB,YAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,KAAK;AAEtC,UAAI,SAAS;AAAA,IAAA;AAAA,EAEjB;AACF;;"}
1
+ {"version":3,"file":"single-type.js","sources":["../../../src/core-api/controller/single-type.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Struct, Core, Utils, UID } from '@strapi/types';\n\ninterface Options {\n contentType: Struct.SingleTypeSchema;\n}\n\n/**\n * Returns a single type controller to handle default core-api actions\n */\nconst createSingleTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<Core.CoreAPI.Controller.SingleType> => {\n const uid = contentType.uid as UID.Service;\n\n // TODO: transform into a class\n return {\n /**\n * Retrieve single type content\n *\n */\n async find(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).find(sanitizedQuery);\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * create or update single type content.\n */\n async update(ctx) {\n const { query, body = {} as any } = ctx.request;\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n await this.validateInput(body.data, ctx);\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).createOrUpdate({\n ...query,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n async delete(ctx) {\n const { query } = ctx;\n\n await strapi.service(uid).delete(query);\n\n ctx.status = 204;\n },\n };\n};\n\nexport { createSingleTypeController };\n"],"names":["createSingleTypeController","contentType","uid","find","ctx","validateQuery","sanitizedQuery","sanitizeQuery","entity","strapi","service","sanitizedEntity","sanitizeOutput","transformResponse","update","query","body","request","isObject","data","errors","ValidationError","validateInput","sanitizedInputData","sanitizeInput","createOrUpdate","delete","status"],"mappings":";;;;;AAQA;;AAEC,IACKA,MAAAA,0BAAAA,GAA6B,CAAC,EAClCC,WAAW,EACH,GAAA;IACR,MAAMC,GAAAA,GAAMD,YAAYC,GAAG;;IAG3B,OAAO;AACL;;;QAIA,MAAMC,MAAKC,GAAG,EAAA;YACZ,MAAM,IAAI,CAACC,aAAa,CAACD,GAAAA,CAAAA;AACzB,YAAA,MAAME,cAAiB,GAAA,MAAM,IAAI,CAACC,aAAa,CAACH,GAAAA,CAAAA;AAEhD,YAAA,MAAMI,SAAS,MAAMC,MAAAA,CAAOC,OAAO,CAACR,GAAAA,CAAAA,CAAKC,IAAI,CAACG,cAAAA,CAAAA;AAE9C,YAAA,MAAMK,kBAAkB,MAAM,IAAI,CAACC,cAAc,CAACJ,MAAQJ,EAAAA,GAAAA,CAAAA;YAE1D,OAAO,IAAI,CAACS,iBAAiB,CAACF,eAAAA,CAAAA;AAChC,SAAA;AAEA;;QAGA,MAAMG,QAAOV,GAAG,EAAA;YACd,MAAM,EAAEW,KAAK,EAAEC,IAAAA,GAAO,EAAS,EAAE,GAAGZ,GAAAA,CAAIa,OAAO;AAE/C,YAAA,IAAI,CAACC,WAAAA,CAASF,IAAKG,CAAAA,IAAI,CAAG,EAAA;gBACxB,MAAM,IAAIC,kBAAOC,CAAAA,eAAe,CAAC,4CAAA,CAAA;AACnC;AAEA,YAAA,MAAM,IAAI,CAACC,aAAa,CAACN,IAAAA,CAAKG,IAAI,EAAEf,GAAAA,CAAAA;YAEpC,MAAMmB,kBAAAA,GAAqB,MAAM,IAAI,CAACC,aAAa,CAACR,IAAAA,CAAKG,IAAI,EAAEf,GAAAA,CAAAA;AAE/D,YAAA,MAAMI,SAAS,MAAMC,MAAAA,CAAOC,OAAO,CAACR,GAAAA,CAAAA,CAAKuB,cAAc,CAAC;AACtD,gBAAA,GAAGV,KAAK;gBACRI,IAAMI,EAAAA;AACR,aAAA,CAAA;AAEA,YAAA,MAAMZ,kBAAkB,MAAM,IAAI,CAACC,cAAc,CAACJ,MAAQJ,EAAAA,GAAAA,CAAAA;YAE1D,OAAO,IAAI,CAACS,iBAAiB,CAACF,eAAAA,CAAAA;AAChC,SAAA;AAEA,QAAA,MAAMe,QAAOtB,GAAG,EAAA;YACd,MAAM,EAAEW,KAAK,EAAE,GAAGX,GAAAA;AAElB,YAAA,MAAMK,MAAOC,CAAAA,OAAO,CAACR,GAAAA,CAAAA,CAAKwB,MAAM,CAACX,KAAAA,CAAAA;AAEjCX,YAAAA,GAAAA,CAAIuB,MAAM,GAAG,GAAA;AACf;AACF,KAAA;AACF;;;;"}
@@ -1,46 +1,45 @@
1
- import { isObject } from "lodash/fp";
2
- import { errors } from "@strapi/utils";
3
- const createSingleTypeController = ({
4
- contentType
5
- }) => {
6
- const uid = contentType.uid;
7
- return {
8
- /**
1
+ import { isObject } from 'lodash/fp';
2
+ import { errors } from '@strapi/utils';
3
+
4
+ /**
5
+ * Returns a single type controller to handle default core-api actions
6
+ */ const createSingleTypeController = ({ contentType })=>{
7
+ const uid = contentType.uid;
8
+ // TODO: transform into a class
9
+ return {
10
+ /**
9
11
  * Retrieve single type content
10
12
  *
11
- */
12
- async find(ctx) {
13
- await this.validateQuery(ctx);
14
- const sanitizedQuery = await this.sanitizeQuery(ctx);
15
- const entity = await strapi.service(uid).find(sanitizedQuery);
16
- const sanitizedEntity = await this.sanitizeOutput(entity, ctx);
17
- return this.transformResponse(sanitizedEntity);
18
- },
19
- /**
13
+ */ async find (ctx) {
14
+ await this.validateQuery(ctx);
15
+ const sanitizedQuery = await this.sanitizeQuery(ctx);
16
+ const entity = await strapi.service(uid).find(sanitizedQuery);
17
+ const sanitizedEntity = await this.sanitizeOutput(entity, ctx);
18
+ return this.transformResponse(sanitizedEntity);
19
+ },
20
+ /**
20
21
  * create or update single type content.
21
- */
22
- async update(ctx) {
23
- const { query, body = {} } = ctx.request;
24
- if (!isObject(body.data)) {
25
- throw new errors.ValidationError('Missing "data" payload in the request body');
26
- }
27
- await this.validateInput(body.data, ctx);
28
- const sanitizedInputData = await this.sanitizeInput(body.data, ctx);
29
- const entity = await strapi.service(uid).createOrUpdate({
30
- ...query,
31
- data: sanitizedInputData
32
- });
33
- const sanitizedEntity = await this.sanitizeOutput(entity, ctx);
34
- return this.transformResponse(sanitizedEntity);
35
- },
36
- async delete(ctx) {
37
- const { query } = ctx;
38
- await strapi.service(uid).delete(query);
39
- ctx.status = 204;
40
- }
41
- };
42
- };
43
- export {
44
- createSingleTypeController
22
+ */ async update (ctx) {
23
+ const { query, body = {} } = ctx.request;
24
+ if (!isObject(body.data)) {
25
+ throw new errors.ValidationError('Missing "data" payload in the request body');
26
+ }
27
+ await this.validateInput(body.data, ctx);
28
+ const sanitizedInputData = await this.sanitizeInput(body.data, ctx);
29
+ const entity = await strapi.service(uid).createOrUpdate({
30
+ ...query,
31
+ data: sanitizedInputData
32
+ });
33
+ const sanitizedEntity = await this.sanitizeOutput(entity, ctx);
34
+ return this.transformResponse(sanitizedEntity);
35
+ },
36
+ async delete (ctx) {
37
+ const { query } = ctx;
38
+ await strapi.service(uid).delete(query);
39
+ ctx.status = 204;
40
+ }
41
+ };
45
42
  };
43
+
44
+ export { createSingleTypeController };
46
45
  //# sourceMappingURL=single-type.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"single-type.mjs","sources":["../../../src/core-api/controller/single-type.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Struct, Core, Utils, UID } from '@strapi/types';\n\ninterface Options {\n contentType: Struct.SingleTypeSchema;\n}\n\n/**\n * Returns a single type controller to handle default core-api actions\n */\nconst createSingleTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<Core.CoreAPI.Controller.SingleType> => {\n const uid = contentType.uid as UID.Service;\n\n // TODO: transform into a class\n return {\n /**\n * Retrieve single type content\n *\n */\n async find(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).find(sanitizedQuery);\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * create or update single type content.\n */\n async update(ctx) {\n const { query, body = {} as any } = ctx.request;\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n await this.validateInput(body.data, ctx);\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).createOrUpdate({\n ...query,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n async delete(ctx) {\n const { query } = ctx;\n\n await strapi.service(uid).delete(query);\n\n ctx.status = 204;\n },\n };\n};\n\nexport { createSingleTypeController };\n"],"names":[],"mappings":";;AAWA,MAAM,6BAA6B,CAAC;AAAA,EAClC;AACF,MAA0E;AACxE,QAAM,MAAM,YAAY;AAGjB,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL,MAAM,KAAK,KAAK;AACR,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAEnD,YAAM,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,KAAK,cAAc;AAE5D,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,OAAO,KAAK;AAChB,YAAM,EAAE,OAAO,OAAO,CAAA,MAAc,IAAI;AAExC,UAAI,CAAC,SAAS,KAAK,IAAI,GAAG;AAClB,cAAA,IAAI,OAAO,gBAAgB,4CAA4C;AAAA,MAAA;AAG/E,YAAM,KAAK,cAAc,KAAK,MAAM,GAAG;AAEvC,YAAM,qBAAqB,MAAM,KAAK,cAAc,KAAK,MAAM,GAAG;AAElE,YAAM,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,eAAe;AAAA,QACtD,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACP;AAED,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA,IAEA,MAAM,OAAO,KAAK;AACV,YAAA,EAAE,UAAU;AAElB,YAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,KAAK;AAEtC,UAAI,SAAS;AAAA,IAAA;AAAA,EAEjB;AACF;"}
1
+ {"version":3,"file":"single-type.mjs","sources":["../../../src/core-api/controller/single-type.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Struct, Core, Utils, UID } from '@strapi/types';\n\ninterface Options {\n contentType: Struct.SingleTypeSchema;\n}\n\n/**\n * Returns a single type controller to handle default core-api actions\n */\nconst createSingleTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<Core.CoreAPI.Controller.SingleType> => {\n const uid = contentType.uid as UID.Service;\n\n // TODO: transform into a class\n return {\n /**\n * Retrieve single type content\n *\n */\n async find(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).find(sanitizedQuery);\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * create or update single type content.\n */\n async update(ctx) {\n const { query, body = {} as any } = ctx.request;\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n await this.validateInput(body.data, ctx);\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).createOrUpdate({\n ...query,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n async delete(ctx) {\n const { query } = ctx;\n\n await strapi.service(uid).delete(query);\n\n ctx.status = 204;\n },\n };\n};\n\nexport { createSingleTypeController };\n"],"names":["createSingleTypeController","contentType","uid","find","ctx","validateQuery","sanitizedQuery","sanitizeQuery","entity","strapi","service","sanitizedEntity","sanitizeOutput","transformResponse","update","query","body","request","isObject","data","errors","ValidationError","validateInput","sanitizedInputData","sanitizeInput","createOrUpdate","delete","status"],"mappings":";;;AAQA;;AAEC,IACKA,MAAAA,0BAAAA,GAA6B,CAAC,EAClCC,WAAW,EACH,GAAA;IACR,MAAMC,GAAAA,GAAMD,YAAYC,GAAG;;IAG3B,OAAO;AACL;;;QAIA,MAAMC,MAAKC,GAAG,EAAA;YACZ,MAAM,IAAI,CAACC,aAAa,CAACD,GAAAA,CAAAA;AACzB,YAAA,MAAME,cAAiB,GAAA,MAAM,IAAI,CAACC,aAAa,CAACH,GAAAA,CAAAA;AAEhD,YAAA,MAAMI,SAAS,MAAMC,MAAAA,CAAOC,OAAO,CAACR,GAAAA,CAAAA,CAAKC,IAAI,CAACG,cAAAA,CAAAA;AAE9C,YAAA,MAAMK,kBAAkB,MAAM,IAAI,CAACC,cAAc,CAACJ,MAAQJ,EAAAA,GAAAA,CAAAA;YAE1D,OAAO,IAAI,CAACS,iBAAiB,CAACF,eAAAA,CAAAA;AAChC,SAAA;AAEA;;QAGA,MAAMG,QAAOV,GAAG,EAAA;YACd,MAAM,EAAEW,KAAK,EAAEC,IAAAA,GAAO,EAAS,EAAE,GAAGZ,GAAAA,CAAIa,OAAO;AAE/C,YAAA,IAAI,CAACC,QAAAA,CAASF,IAAKG,CAAAA,IAAI,CAAG,EAAA;gBACxB,MAAM,IAAIC,MAAOC,CAAAA,eAAe,CAAC,4CAAA,CAAA;AACnC;AAEA,YAAA,MAAM,IAAI,CAACC,aAAa,CAACN,IAAAA,CAAKG,IAAI,EAAEf,GAAAA,CAAAA;YAEpC,MAAMmB,kBAAAA,GAAqB,MAAM,IAAI,CAACC,aAAa,CAACR,IAAAA,CAAKG,IAAI,EAAEf,GAAAA,CAAAA;AAE/D,YAAA,MAAMI,SAAS,MAAMC,MAAAA,CAAOC,OAAO,CAACR,GAAAA,CAAAA,CAAKuB,cAAc,CAAC;AACtD,gBAAA,GAAGV,KAAK;gBACRI,IAAMI,EAAAA;AACR,aAAA,CAAA;AAEA,YAAA,MAAMZ,kBAAkB,MAAM,IAAI,CAACC,cAAc,CAACJ,MAAQJ,EAAAA,GAAAA,CAAAA;YAE1D,OAAO,IAAI,CAACS,iBAAiB,CAACF,eAAAA,CAAAA;AAChC,SAAA;AAEA,QAAA,MAAMe,QAAOtB,GAAG,EAAA;YACd,MAAM,EAAEW,KAAK,EAAE,GAAGX,GAAAA;AAElB,YAAA,MAAMK,MAAOC,CAAAA,OAAO,CAACR,GAAAA,CAAAA,CAAKwB,MAAM,CAACX,KAAAA,CAAAA;AAEjCX,YAAAA,GAAAA,CAAIuB,MAAM,GAAG,GAAA;AACf;AACF,KAAA;AACF;;;;"}