@strapi/core 0.0.0-experimental.58c6b635911a7cb83cd165b4e5abd75b8ec30893 → 0.0.0-experimental.599b53360e581fdbd0afac055f1bf2d29816feec

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.

Potentially problematic release.


This version of @strapi/core might be problematic. Click here for more details.

Files changed (360) hide show
  1. package/dist/Strapi.d.ts +1 -1
  2. package/dist/Strapi.d.ts.map +1 -1
  3. package/dist/Strapi.js +54 -60
  4. package/dist/Strapi.js.map +1 -1
  5. package/dist/Strapi.mjs +34 -37
  6. package/dist/Strapi.mjs.map +1 -1
  7. package/dist/compile.js.map +1 -1
  8. package/dist/compile.mjs.map +1 -1
  9. package/dist/configuration/config-loader.js +1 -2
  10. package/dist/configuration/config-loader.js.map +1 -1
  11. package/dist/configuration/config-loader.mjs +1 -2
  12. package/dist/configuration/config-loader.mjs.map +1 -1
  13. package/dist/configuration/get-dirs.js.map +1 -1
  14. package/dist/configuration/get-dirs.mjs.map +1 -1
  15. package/dist/configuration/index.d.ts.map +1 -1
  16. package/dist/configuration/index.js +8 -3
  17. package/dist/configuration/index.js.map +1 -1
  18. package/dist/configuration/index.mjs +8 -3
  19. package/dist/configuration/index.mjs.map +1 -1
  20. package/dist/configuration/urls.js.map +1 -1
  21. package/dist/configuration/urls.mjs.map +1 -1
  22. package/dist/container.js.map +1 -1
  23. package/dist/container.mjs.map +1 -1
  24. package/dist/core-api/controller/collection-type.js.map +1 -1
  25. package/dist/core-api/controller/collection-type.mjs.map +1 -1
  26. package/dist/core-api/controller/index.js.map +1 -1
  27. package/dist/core-api/controller/index.mjs.map +1 -1
  28. package/dist/core-api/controller/single-type.js.map +1 -1
  29. package/dist/core-api/controller/single-type.mjs.map +1 -1
  30. package/dist/core-api/controller/transform.js.map +1 -1
  31. package/dist/core-api/controller/transform.mjs.map +1 -1
  32. package/dist/core-api/routes/index.js.map +1 -1
  33. package/dist/core-api/routes/index.mjs.map +1 -1
  34. package/dist/core-api/service/collection-type.js.map +1 -1
  35. package/dist/core-api/service/collection-type.mjs.map +1 -1
  36. package/dist/core-api/service/core-service.js.map +1 -1
  37. package/dist/core-api/service/core-service.mjs.map +1 -1
  38. package/dist/core-api/service/index.js.map +1 -1
  39. package/dist/core-api/service/index.mjs.map +1 -1
  40. package/dist/core-api/service/pagination.js.map +1 -1
  41. package/dist/core-api/service/pagination.mjs.map +1 -1
  42. package/dist/core-api/service/single-type.js +1 -2
  43. package/dist/core-api/service/single-type.js.map +1 -1
  44. package/dist/core-api/service/single-type.mjs +1 -2
  45. package/dist/core-api/service/single-type.mjs.map +1 -1
  46. package/dist/domain/content-type/index.js.map +1 -1
  47. package/dist/domain/content-type/index.mjs.map +1 -1
  48. package/dist/domain/content-type/validator.js.map +1 -1
  49. package/dist/domain/content-type/validator.mjs.map +1 -1
  50. package/dist/domain/module/index.js.map +1 -1
  51. package/dist/domain/module/index.mjs.map +1 -1
  52. package/dist/domain/module/validation.js.map +1 -1
  53. package/dist/domain/module/validation.mjs.map +1 -1
  54. package/dist/ee/index.js.map +1 -1
  55. package/dist/ee/index.mjs.map +1 -1
  56. package/dist/ee/license.js.map +1 -1
  57. package/dist/ee/license.mjs.map +1 -1
  58. package/dist/factories.js.map +1 -1
  59. package/dist/factories.mjs.map +1 -1
  60. package/dist/index.js.map +1 -1
  61. package/dist/loaders/admin.js.map +1 -1
  62. package/dist/loaders/admin.mjs.map +1 -1
  63. package/dist/loaders/apis.js.map +1 -1
  64. package/dist/loaders/apis.mjs.map +1 -1
  65. package/dist/loaders/components.js.map +1 -1
  66. package/dist/loaders/components.mjs.map +1 -1
  67. package/dist/loaders/middlewares.js.map +1 -1
  68. package/dist/loaders/middlewares.mjs.map +1 -1
  69. package/dist/loaders/plugins/get-enabled-plugins.js.map +1 -1
  70. package/dist/loaders/plugins/get-enabled-plugins.mjs.map +1 -1
  71. package/dist/loaders/plugins/get-user-plugins-config.js.map +1 -1
  72. package/dist/loaders/plugins/get-user-plugins-config.mjs.map +1 -1
  73. package/dist/loaders/plugins/index.js +1 -2
  74. package/dist/loaders/plugins/index.js.map +1 -1
  75. package/dist/loaders/plugins/index.mjs.map +1 -1
  76. package/dist/loaders/policies.js.map +1 -1
  77. package/dist/loaders/policies.mjs.map +1 -1
  78. package/dist/loaders/sanitizers.js.map +1 -1
  79. package/dist/loaders/sanitizers.mjs.map +1 -1
  80. package/dist/loaders/src-index.js.map +1 -1
  81. package/dist/loaders/src-index.mjs.map +1 -1
  82. package/dist/loaders/validators.js.map +1 -1
  83. package/dist/loaders/validators.mjs.map +1 -1
  84. package/dist/middlewares/body.js.map +1 -1
  85. package/dist/middlewares/body.mjs.map +1 -1
  86. package/dist/middlewares/cors.js.map +1 -1
  87. package/dist/middlewares/cors.mjs.map +1 -1
  88. package/dist/middlewares/errors.js.map +1 -1
  89. package/dist/middlewares/errors.mjs.map +1 -1
  90. package/dist/middlewares/favicon.js.map +1 -1
  91. package/dist/middlewares/favicon.mjs.map +1 -1
  92. package/dist/middlewares/index.js.map +1 -1
  93. package/dist/middlewares/logger.js.map +1 -1
  94. package/dist/middlewares/logger.mjs.map +1 -1
  95. package/dist/middlewares/powered-by.js.map +1 -1
  96. package/dist/middlewares/powered-by.mjs.map +1 -1
  97. package/dist/middlewares/public.js.map +1 -1
  98. package/dist/middlewares/public.mjs.map +1 -1
  99. package/dist/middlewares/query.js.map +1 -1
  100. package/dist/middlewares/query.mjs.map +1 -1
  101. package/dist/middlewares/response-time.js.map +1 -1
  102. package/dist/middlewares/response-time.mjs.map +1 -1
  103. package/dist/middlewares/responses.js.map +1 -1
  104. package/dist/middlewares/responses.mjs.map +1 -1
  105. package/dist/middlewares/security.js.map +1 -1
  106. package/dist/middlewares/security.mjs.map +1 -1
  107. package/dist/middlewares/session.js.map +1 -1
  108. package/dist/middlewares/session.mjs.map +1 -1
  109. package/dist/migrations/database/5.0.0-discard-drafts.d.ts +2 -2
  110. package/dist/migrations/database/5.0.0-discard-drafts.d.ts.map +1 -1
  111. package/dist/migrations/database/5.0.0-discard-drafts.js +5 -2
  112. package/dist/migrations/database/5.0.0-discard-drafts.js.map +1 -1
  113. package/dist/migrations/database/5.0.0-discard-drafts.mjs +5 -2
  114. package/dist/migrations/database/5.0.0-discard-drafts.mjs.map +1 -1
  115. package/dist/migrations/draft-publish.js.map +1 -1
  116. package/dist/migrations/draft-publish.mjs.map +1 -1
  117. package/dist/migrations/i18n.js.map +1 -1
  118. package/dist/migrations/i18n.mjs.map +1 -1
  119. package/dist/migrations/index.js.map +1 -1
  120. package/dist/migrations/index.mjs.map +1 -1
  121. package/dist/providers/admin.js.map +1 -1
  122. package/dist/providers/admin.mjs.map +1 -1
  123. package/dist/providers/coreStore.js.map +1 -1
  124. package/dist/providers/coreStore.mjs.map +1 -1
  125. package/dist/providers/cron.js.map +1 -1
  126. package/dist/providers/cron.mjs.map +1 -1
  127. package/dist/providers/registries.js.map +1 -1
  128. package/dist/providers/registries.mjs.map +1 -1
  129. package/dist/providers/telemetry.js.map +1 -1
  130. package/dist/providers/telemetry.mjs.map +1 -1
  131. package/dist/providers/webhooks.js.map +1 -1
  132. package/dist/providers/webhooks.mjs.map +1 -1
  133. package/dist/registries/apis.js.map +1 -1
  134. package/dist/registries/apis.mjs.map +1 -1
  135. package/dist/registries/components.js.map +1 -1
  136. package/dist/registries/components.mjs.map +1 -1
  137. package/dist/registries/content-types.js.map +1 -1
  138. package/dist/registries/content-types.mjs.map +1 -1
  139. package/dist/registries/controllers.js.map +1 -1
  140. package/dist/registries/controllers.mjs.map +1 -1
  141. package/dist/registries/custom-fields.js.map +1 -1
  142. package/dist/registries/custom-fields.mjs.map +1 -1
  143. package/dist/registries/hooks.js.map +1 -1
  144. package/dist/registries/hooks.mjs.map +1 -1
  145. package/dist/registries/middlewares.js.map +1 -1
  146. package/dist/registries/middlewares.mjs.map +1 -1
  147. package/dist/registries/models.js.map +1 -1
  148. package/dist/registries/models.mjs.map +1 -1
  149. package/dist/registries/modules.js.map +1 -1
  150. package/dist/registries/modules.mjs.map +1 -1
  151. package/dist/registries/namespace.js.map +1 -1
  152. package/dist/registries/namespace.mjs.map +1 -1
  153. package/dist/registries/plugins.js.map +1 -1
  154. package/dist/registries/plugins.mjs.map +1 -1
  155. package/dist/registries/policies.js.map +1 -1
  156. package/dist/registries/policies.mjs.map +1 -1
  157. package/dist/registries/sanitizers.js.map +1 -1
  158. package/dist/registries/sanitizers.mjs.map +1 -1
  159. package/dist/registries/services.js.map +1 -1
  160. package/dist/registries/services.mjs.map +1 -1
  161. package/dist/registries/validators.js.map +1 -1
  162. package/dist/registries/validators.mjs.map +1 -1
  163. package/dist/services/auth/index.js.map +1 -1
  164. package/dist/services/auth/index.mjs.map +1 -1
  165. package/dist/services/config.js.map +1 -1
  166. package/dist/services/config.mjs.map +1 -1
  167. package/dist/services/content-api/index.js.map +1 -1
  168. package/dist/services/content-api/index.mjs.map +1 -1
  169. package/dist/services/content-api/permissions/index.js.map +1 -1
  170. package/dist/services/content-api/permissions/index.mjs.map +1 -1
  171. package/dist/services/content-api/permissions/providers/action.js.map +1 -1
  172. package/dist/services/content-api/permissions/providers/action.mjs.map +1 -1
  173. package/dist/services/content-api/permissions/providers/condition.js.map +1 -1
  174. package/dist/services/content-api/permissions/providers/condition.mjs.map +1 -1
  175. package/dist/services/core-store.js.map +1 -1
  176. package/dist/services/core-store.mjs.map +1 -1
  177. package/dist/services/cron.js +1 -2
  178. package/dist/services/cron.js.map +1 -1
  179. package/dist/services/cron.mjs +1 -2
  180. package/dist/services/cron.mjs.map +1 -1
  181. package/dist/services/custom-fields.js.map +1 -1
  182. package/dist/services/custom-fields.mjs.map +1 -1
  183. package/dist/services/document-service/attributes/index.js.map +1 -1
  184. package/dist/services/document-service/attributes/index.mjs.map +1 -1
  185. package/dist/services/document-service/attributes/transforms.js.map +1 -1
  186. package/dist/services/document-service/attributes/transforms.mjs.map +1 -1
  187. package/dist/services/document-service/components.d.ts.map +1 -1
  188. package/dist/services/document-service/components.js.map +1 -1
  189. package/dist/services/document-service/components.mjs.map +1 -1
  190. package/dist/services/document-service/draft-and-publish.js.map +1 -1
  191. package/dist/services/document-service/draft-and-publish.mjs.map +1 -1
  192. package/dist/services/document-service/entries.js.map +1 -1
  193. package/dist/services/document-service/entries.mjs.map +1 -1
  194. package/dist/services/document-service/events.js.map +1 -1
  195. package/dist/services/document-service/events.mjs.map +1 -1
  196. package/dist/services/document-service/index.js.map +1 -1
  197. package/dist/services/document-service/index.mjs.map +1 -1
  198. package/dist/services/document-service/internationalization.js.map +1 -1
  199. package/dist/services/document-service/internationalization.mjs.map +1 -1
  200. package/dist/services/document-service/middlewares/errors.js.map +1 -1
  201. package/dist/services/document-service/middlewares/errors.mjs.map +1 -1
  202. package/dist/services/document-service/middlewares/middleware-manager.js.map +1 -1
  203. package/dist/services/document-service/middlewares/middleware-manager.mjs.map +1 -1
  204. package/dist/services/document-service/repository.d.ts.map +1 -1
  205. package/dist/services/document-service/repository.js +4 -1
  206. package/dist/services/document-service/repository.js.map +1 -1
  207. package/dist/services/document-service/repository.mjs +5 -2
  208. package/dist/services/document-service/repository.mjs.map +1 -1
  209. package/dist/services/document-service/transform/data.js.map +1 -1
  210. package/dist/services/document-service/transform/data.mjs.map +1 -1
  211. package/dist/services/document-service/transform/fields.js.map +1 -1
  212. package/dist/services/document-service/transform/fields.mjs.map +1 -1
  213. package/dist/services/document-service/transform/id-map.js +2 -4
  214. package/dist/services/document-service/transform/id-map.js.map +1 -1
  215. package/dist/services/document-service/transform/id-map.mjs +2 -4
  216. package/dist/services/document-service/transform/id-map.mjs.map +1 -1
  217. package/dist/services/document-service/transform/id-transform.js.map +1 -1
  218. package/dist/services/document-service/transform/id-transform.mjs.map +1 -1
  219. package/dist/services/document-service/transform/populate.js.map +1 -1
  220. package/dist/services/document-service/transform/populate.mjs.map +1 -1
  221. package/dist/services/document-service/transform/query.js.map +1 -1
  222. package/dist/services/document-service/transform/query.mjs.map +1 -1
  223. package/dist/services/document-service/transform/relations/extract/data-ids.d.ts.map +1 -1
  224. package/dist/services/document-service/transform/relations/extract/data-ids.js +13 -6
  225. package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -1
  226. package/dist/services/document-service/transform/relations/extract/data-ids.mjs +13 -6
  227. package/dist/services/document-service/transform/relations/extract/data-ids.mjs.map +1 -1
  228. package/dist/services/document-service/transform/relations/transform/data-ids.d.ts.map +1 -1
  229. package/dist/services/document-service/transform/relations/transform/data-ids.js +17 -8
  230. package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
  231. package/dist/services/document-service/transform/relations/transform/data-ids.mjs +18 -9
  232. package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
  233. package/dist/services/document-service/transform/relations/transform/default-locale.js.map +1 -1
  234. package/dist/services/document-service/transform/relations/transform/default-locale.mjs.map +1 -1
  235. package/dist/services/document-service/transform/relations/utils/dp.js.map +1 -1
  236. package/dist/services/document-service/transform/relations/utils/dp.mjs.map +1 -1
  237. package/dist/services/document-service/transform/relations/utils/i18n.js.map +1 -1
  238. package/dist/services/document-service/transform/relations/utils/i18n.mjs.map +1 -1
  239. package/dist/services/document-service/transform/relations/utils/map-relation.d.ts.map +1 -1
  240. package/dist/services/document-service/transform/relations/utils/map-relation.js +3 -10
  241. package/dist/services/document-service/transform/relations/utils/map-relation.js.map +1 -1
  242. package/dist/services/document-service/transform/relations/utils/map-relation.mjs +3 -10
  243. package/dist/services/document-service/transform/relations/utils/map-relation.mjs.map +1 -1
  244. package/dist/services/document-service/utils/populate.d.ts.map +1 -1
  245. package/dist/services/document-service/utils/populate.js +1 -1
  246. package/dist/services/document-service/utils/populate.js.map +1 -1
  247. package/dist/services/document-service/utils/populate.mjs +1 -1
  248. package/dist/services/document-service/utils/populate.mjs.map +1 -1
  249. package/dist/services/document-service/utils/unidirectional-relations.js +1 -2
  250. package/dist/services/document-service/utils/unidirectional-relations.js.map +1 -1
  251. package/dist/services/document-service/utils/unidirectional-relations.mjs +1 -2
  252. package/dist/services/document-service/utils/unidirectional-relations.mjs.map +1 -1
  253. package/dist/services/entity-service/index.js.map +1 -1
  254. package/dist/services/entity-service/index.mjs.map +1 -1
  255. package/dist/services/entity-validator/blocks-validator.js.map +1 -1
  256. package/dist/services/entity-validator/blocks-validator.mjs.map +1 -1
  257. package/dist/services/entity-validator/index.js.map +1 -1
  258. package/dist/services/entity-validator/index.mjs.map +1 -1
  259. package/dist/services/entity-validator/validators.js.map +1 -1
  260. package/dist/services/entity-validator/validators.mjs.map +1 -1
  261. package/dist/services/errors.js.map +1 -1
  262. package/dist/services/errors.mjs.map +1 -1
  263. package/dist/services/event-hub.js.map +1 -1
  264. package/dist/services/event-hub.mjs.map +1 -1
  265. package/dist/services/features.js.map +1 -1
  266. package/dist/services/features.mjs.map +1 -1
  267. package/dist/services/fs.js.map +1 -1
  268. package/dist/services/fs.mjs.map +1 -1
  269. package/dist/services/metrics/admin-user-hash.js.map +1 -1
  270. package/dist/services/metrics/admin-user-hash.mjs.map +1 -1
  271. package/dist/services/metrics/index.js +1 -2
  272. package/dist/services/metrics/index.js.map +1 -1
  273. package/dist/services/metrics/index.mjs +1 -2
  274. package/dist/services/metrics/index.mjs.map +1 -1
  275. package/dist/services/metrics/is-truthy.js.map +1 -1
  276. package/dist/services/metrics/middleware.d.ts.map +1 -1
  277. package/dist/services/metrics/middleware.js +6 -4
  278. package/dist/services/metrics/middleware.js.map +1 -1
  279. package/dist/services/metrics/middleware.mjs +6 -4
  280. package/dist/services/metrics/middleware.mjs.map +1 -1
  281. package/dist/services/metrics/rate-limiter.d.ts.map +1 -1
  282. package/dist/services/metrics/rate-limiter.js +6 -3
  283. package/dist/services/metrics/rate-limiter.js.map +1 -1
  284. package/dist/services/metrics/rate-limiter.mjs +6 -3
  285. package/dist/services/metrics/rate-limiter.mjs.map +1 -1
  286. package/dist/services/metrics/sender.js.map +1 -1
  287. package/dist/services/metrics/sender.mjs.map +1 -1
  288. package/dist/services/query-params.js.map +1 -1
  289. package/dist/services/query-params.mjs.map +1 -1
  290. package/dist/services/reloader.js.map +1 -1
  291. package/dist/services/reloader.mjs.map +1 -1
  292. package/dist/services/request-context.js.map +1 -1
  293. package/dist/services/request-context.mjs.map +1 -1
  294. package/dist/services/server/admin-api.js.map +1 -1
  295. package/dist/services/server/admin-api.mjs.map +1 -1
  296. package/dist/services/server/api.js.map +1 -1
  297. package/dist/services/server/api.mjs.map +1 -1
  298. package/dist/services/server/compose-endpoint.js.map +1 -1
  299. package/dist/services/server/compose-endpoint.mjs.map +1 -1
  300. package/dist/services/server/content-api.js.map +1 -1
  301. package/dist/services/server/content-api.mjs.map +1 -1
  302. package/dist/services/server/http-server.js.map +1 -1
  303. package/dist/services/server/http-server.mjs.map +1 -1
  304. package/dist/services/server/index.js.map +1 -1
  305. package/dist/services/server/index.mjs.map +1 -1
  306. package/dist/services/server/koa.js.map +1 -1
  307. package/dist/services/server/koa.mjs.map +1 -1
  308. package/dist/services/server/middleware.js.map +1 -1
  309. package/dist/services/server/middleware.mjs.map +1 -1
  310. package/dist/services/server/policy.js.map +1 -1
  311. package/dist/services/server/policy.mjs.map +1 -1
  312. package/dist/services/server/register-middlewares.js.map +1 -1
  313. package/dist/services/server/register-middlewares.mjs.map +1 -1
  314. package/dist/services/server/register-routes.js.map +1 -1
  315. package/dist/services/server/register-routes.mjs.map +1 -1
  316. package/dist/services/server/routing.js.map +1 -1
  317. package/dist/services/server/routing.mjs.map +1 -1
  318. package/dist/services/utils/dynamic-zones.js.map +1 -1
  319. package/dist/services/utils/dynamic-zones.mjs.map +1 -1
  320. package/dist/services/webhook-runner.js.map +1 -1
  321. package/dist/services/webhook-runner.mjs.map +1 -1
  322. package/dist/services/webhook-store.js.map +1 -1
  323. package/dist/services/webhook-store.mjs.map +1 -1
  324. package/dist/services/worker-queue.js.map +1 -1
  325. package/dist/services/worker-queue.mjs.map +1 -1
  326. package/dist/utils/convert-custom-field-type.js.map +1 -1
  327. package/dist/utils/convert-custom-field-type.mjs.map +1 -1
  328. package/dist/utils/cron.js.map +1 -1
  329. package/dist/utils/cron.mjs.map +1 -1
  330. package/dist/utils/fetch.js.map +1 -1
  331. package/dist/utils/fetch.mjs.map +1 -1
  332. package/dist/utils/filepath-to-prop-path.js.map +1 -1
  333. package/dist/utils/filepath-to-prop-path.mjs.map +1 -1
  334. package/dist/utils/is-initialized.js.map +1 -1
  335. package/dist/utils/is-initialized.mjs.map +1 -1
  336. package/dist/utils/load-config-file.js.map +1 -1
  337. package/dist/utils/load-config-file.mjs.map +1 -1
  338. package/dist/utils/load-files.js +1 -2
  339. package/dist/utils/load-files.js.map +1 -1
  340. package/dist/utils/load-files.mjs +1 -2
  341. package/dist/utils/load-files.mjs.map +1 -1
  342. package/dist/utils/resolve-working-dirs.js.map +1 -1
  343. package/dist/utils/resolve-working-dirs.mjs.map +1 -1
  344. package/dist/utils/signals.js.map +1 -1
  345. package/dist/utils/signals.mjs.map +1 -1
  346. package/dist/utils/startup-logger.d.ts.map +1 -1
  347. package/dist/utils/startup-logger.js +6 -1
  348. package/dist/utils/startup-logger.js.map +1 -1
  349. package/dist/utils/startup-logger.mjs +6 -1
  350. package/dist/utils/startup-logger.mjs.map +1 -1
  351. package/dist/utils/transform-content-types-to-models.d.ts +28 -0
  352. package/dist/utils/transform-content-types-to-models.d.ts.map +1 -1
  353. package/dist/utils/transform-content-types-to-models.js.map +1 -1
  354. package/dist/utils/transform-content-types-to-models.mjs.map +1 -1
  355. package/dist/utils/update-notifier/index.d.ts.map +1 -1
  356. package/dist/utils/update-notifier/index.js +3 -1
  357. package/dist/utils/update-notifier/index.js.map +1 -1
  358. package/dist/utils/update-notifier/index.mjs +2 -1
  359. package/dist/utils/update-notifier/index.mjs.map +1 -1
  360. package/package.json +14 -15
@@ -1 +1 @@
1
- {"version":3,"file":"license.mjs","sources":["../../src/ee/license.ts"],"sourcesContent":["import fs from 'fs';\nimport { join, resolve } from 'path';\nimport crypto from 'crypto';\nimport type { Core } from '@strapi/types';\n\nimport { machineID } from '@strapi/utils';\n\ninterface LicenseInfo {\n type: 'bronze' | 'silver' | 'gold';\n expireAt?: string;\n seats?: number;\n features?: Array<{ name: string; options?: Record<string, unknown> }>;\n}\n\nconst DEFAULT_FEATURES = {\n bronze: [],\n silver: [],\n gold: [\n { name: 'sso' },\n // Set a null retention duration to allow the user to override it\n // The default of 90 days is set in the audit logs service\n { name: 'audit-logs', options: { retentionDays: null } },\n { name: 'review-workflows' },\n { name: 'cms-content-releases' },\n { name: 'cms-content-history', options: { retentionDays: 99999 } },\n ],\n};\n\nconst publicKey = fs.readFileSync(resolve(__dirname, '../../resources/key.pub'));\n\nclass LicenseCheckError extends Error {\n shouldFallback = false;\n\n constructor(message: string, shouldFallback = false) {\n super(message);\n\n this.shouldFallback = shouldFallback;\n }\n}\n\nconst readLicense = (directory: string) => {\n try {\n const path = join(directory, 'license.txt');\n return fs.readFileSync(path).toString();\n } catch (error) {\n if (typeof error === 'object' && error !== null && 'code' in error && error.code !== 'ENOENT') {\n throw Error('License file not readable, review its format and access rules.');\n }\n }\n};\n\nconst verifyLicense = (license: string) => {\n const [signature, base64Content] = Buffer.from(license, 'base64').toString().split('\\n');\n\n if (!signature || !base64Content) {\n throw new Error('Invalid license.');\n }\n\n const stringifiedContent = Buffer.from(base64Content, 'base64').toString();\n\n const verify = crypto.createVerify('RSA-SHA256');\n verify.update(stringifiedContent);\n verify.end();\n\n const verified = verify.verify(publicKey, signature, 'base64');\n\n if (!verified) {\n throw new Error('Invalid license.');\n }\n\n const licenseInfo: LicenseInfo = JSON.parse(stringifiedContent);\n\n if (!licenseInfo.features) {\n licenseInfo.features = DEFAULT_FEATURES[licenseInfo.type];\n }\n\n Object.freeze(licenseInfo.features);\n return licenseInfo;\n};\n\nconst throwError = () => {\n throw new LicenseCheckError('Could not proceed to the online validation of your license.', true);\n};\n\nconst fetchLicense = async (\n { strapi }: { strapi: Core.Strapi },\n key: string,\n projectId: string\n) => {\n const response = await strapi\n .fetch(`https://license.strapi.io/api/licenses/validate`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ key, projectId, deviceId: machineID() }),\n })\n .catch(throwError);\n\n const contentType = response.headers.get('Content-Type');\n\n if (contentType?.includes('application/json')) {\n const { data, error } = await response.json();\n\n switch (response.status) {\n case 200:\n return data.license;\n case 400:\n throw new LicenseCheckError(error.message);\n case 404:\n throw new LicenseCheckError('The license used does not exists.');\n default:\n throwError();\n }\n } else {\n throwError();\n }\n};\n\nexport { readLicense, verifyLicense, fetchLicense, LicenseCheckError };\n"],"names":[],"mappings":";;;;AAcA,MAAM,mBAAmB;AAAA,EACvB,QAAQ,CAAC;AAAA,EACT,QAAQ,CAAC;AAAA,EACT,MAAM;AAAA,IACJ,EAAE,MAAM,MAAM;AAAA;AAAA;AAAA,IAGd,EAAE,MAAM,cAAc,SAAS,EAAE,eAAe,OAAO;AAAA,IACvD,EAAE,MAAM,mBAAmB;AAAA,IAC3B,EAAE,MAAM,uBAAuB;AAAA,IAC/B,EAAE,MAAM,uBAAuB,SAAS,EAAE,eAAe,QAAQ;AAAA,EACnE;AACF;AAEA,MAAM,YAAY,GAAG,aAAa,QAAQ,WAAW,yBAAyB,CAAC;AAE/E,MAAM,0BAA0B,MAAM;AAAA,EACpC,iBAAiB;AAAA,EAEjB,YAAY,SAAiB,iBAAiB,OAAO;AACnD,UAAM,OAAO;AAEb,SAAK,iBAAiB;AAAA,EACxB;AACF;AAEM,MAAA,cAAc,CAAC,cAAsB;AACrC,MAAA;AACI,UAAA,OAAO,KAAK,WAAW,aAAa;AAC1C,WAAO,GAAG,aAAa,IAAI,EAAE,SAAS;AAAA,WAC/B,OAAO;AACV,QAAA,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,MAAM,SAAS,UAAU;AAC7F,YAAM,MAAM,gEAAgE;AAAA,IAC9E;AAAA,EACF;AACF;AAEM,MAAA,gBAAgB,CAAC,YAAoB;AACzC,QAAM,CAAC,WAAW,aAAa,IAAI,OAAO,KAAK,SAAS,QAAQ,EAAE,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file":"license.mjs","sources":["../../src/ee/license.ts"],"sourcesContent":["import fs from 'fs';\nimport { join, resolve } from 'path';\nimport crypto from 'crypto';\nimport type { Core } from '@strapi/types';\n\nimport { machineID } from '@strapi/utils';\n\ninterface LicenseInfo {\n type: 'bronze' | 'silver' | 'gold';\n expireAt?: string;\n seats?: number;\n features?: Array<{ name: string; options?: Record<string, unknown> }>;\n}\n\nconst DEFAULT_FEATURES = {\n bronze: [],\n silver: [],\n gold: [\n { name: 'sso' },\n // Set a null retention duration to allow the user to override it\n // The default of 90 days is set in the audit logs service\n { name: 'audit-logs', options: { retentionDays: null } },\n { name: 'review-workflows' },\n { name: 'cms-content-releases' },\n { name: 'cms-content-history', options: { retentionDays: 99999 } },\n ],\n};\n\nconst publicKey = fs.readFileSync(resolve(__dirname, '../../resources/key.pub'));\n\nclass LicenseCheckError extends Error {\n shouldFallback = false;\n\n constructor(message: string, shouldFallback = false) {\n super(message);\n\n this.shouldFallback = shouldFallback;\n }\n}\n\nconst readLicense = (directory: string) => {\n try {\n const path = join(directory, 'license.txt');\n return fs.readFileSync(path).toString();\n } catch (error) {\n if (typeof error === 'object' && error !== null && 'code' in error && error.code !== 'ENOENT') {\n throw Error('License file not readable, review its format and access rules.');\n }\n }\n};\n\nconst verifyLicense = (license: string) => {\n const [signature, base64Content] = Buffer.from(license, 'base64').toString().split('\\n');\n\n if (!signature || !base64Content) {\n throw new Error('Invalid license.');\n }\n\n const stringifiedContent = Buffer.from(base64Content, 'base64').toString();\n\n const verify = crypto.createVerify('RSA-SHA256');\n verify.update(stringifiedContent);\n verify.end();\n\n const verified = verify.verify(publicKey, signature, 'base64');\n\n if (!verified) {\n throw new Error('Invalid license.');\n }\n\n const licenseInfo: LicenseInfo = JSON.parse(stringifiedContent);\n\n if (!licenseInfo.features) {\n licenseInfo.features = DEFAULT_FEATURES[licenseInfo.type];\n }\n\n Object.freeze(licenseInfo.features);\n return licenseInfo;\n};\n\nconst throwError = () => {\n throw new LicenseCheckError('Could not proceed to the online validation of your license.', true);\n};\n\nconst fetchLicense = async (\n { strapi }: { strapi: Core.Strapi },\n key: string,\n projectId: string\n) => {\n const response = await strapi\n .fetch(`https://license.strapi.io/api/licenses/validate`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ key, projectId, deviceId: machineID() }),\n })\n .catch(throwError);\n\n const contentType = response.headers.get('Content-Type');\n\n if (contentType?.includes('application/json')) {\n const { data, error } = await response.json();\n\n switch (response.status) {\n case 200:\n return data.license;\n case 400:\n throw new LicenseCheckError(error.message);\n case 404:\n throw new LicenseCheckError('The license used does not exists.');\n default:\n throwError();\n }\n } else {\n throwError();\n }\n};\n\nexport { readLicense, verifyLicense, fetchLicense, LicenseCheckError };\n"],"names":[],"mappings":";;;;AAcA,MAAM,mBAAmB;AAAA,EACvB,QAAQ,CAAC;AAAA,EACT,QAAQ,CAAC;AAAA,EACT,MAAM;AAAA,IACJ,EAAE,MAAM,MAAM;AAAA;AAAA;AAAA,IAGd,EAAE,MAAM,cAAc,SAAS,EAAE,eAAe,OAAO;AAAA,IACvD,EAAE,MAAM,mBAAmB;AAAA,IAC3B,EAAE,MAAM,uBAAuB;AAAA,IAC/B,EAAE,MAAM,uBAAuB,SAAS,EAAE,eAAe,MAAQ,EAAA;AAAA,EAAA;AAErE;AAEA,MAAM,YAAY,GAAG,aAAa,QAAQ,WAAW,yBAAyB,CAAC;AAE/E,MAAM,0BAA0B,MAAM;AAAA,EACpC,iBAAiB;AAAA,EAEjB,YAAY,SAAiB,iBAAiB,OAAO;AACnD,UAAM,OAAO;AAEb,SAAK,iBAAiB;AAAA,EAAA;AAE1B;AAEM,MAAA,cAAc,CAAC,cAAsB;AACrC,MAAA;AACI,UAAA,OAAO,KAAK,WAAW,aAAa;AAC1C,WAAO,GAAG,aAAa,IAAI,EAAE,SAAS;AAAA,WAC/B,OAAO;AACV,QAAA,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,MAAM,SAAS,UAAU;AAC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AACG,cAAA,IAAI,kBAAkB,MAAM,OAAO;AAAA,MAC3C,KAAK;AACG,cAAA,IAAI,kBAAkB,mCAAmC;AAAA,MACjE;AACa,mBAAA;AAAA,IAAA;AAAA,EACf,OACK;AACM,eAAA;AAAA,EAAA;AAEf;"}
@@ -1 +1 @@
1
- {"version":3,"file":"factories.js","sources":["../src/factories.ts"],"sourcesContent":["import { pipe, omit, pick } from 'lodash/fp';\nimport type { Core, UID, Utils } from '@strapi/types';\n\nimport { createController } from './core-api/controller';\nimport { createService } from './core-api/service';\nimport { createRoutes } from './core-api/routes';\n\nconst symbols = {\n CustomController: Symbol('StrapiCustomCoreController'),\n} as const;\n\ntype WithStrapiCallback<T> = T | (<S extends { strapi: Core.Strapi }>(params: S) => T);\n\nconst createCoreController = <\n TUID extends UID.ContentType,\n TController extends Core.CoreAPI.Controller.Extendable<TUID>,\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<\n Utils.PartialWithThis<Core.CoreAPI.Controller.Extendable<TUID> & TController>\n >\n) => {\n return ({\n strapi,\n }: {\n strapi: Core.Strapi;\n }): TController & Core.CoreAPI.Controller.ContentType<TUID> => {\n const baseController = createController({ contentType: strapi.contentType(uid) });\n\n const userCtrl = typeof cfg === 'function' ? cfg({ strapi }) : (cfg ?? ({} as any));\n\n for (const methodName of Object.keys(baseController) as Array<keyof typeof baseController>) {\n if (userCtrl[methodName] === undefined) {\n userCtrl[methodName] = baseController[methodName];\n }\n }\n\n Object.setPrototypeOf(userCtrl, baseController);\n\n const isCustom = typeof cfg !== 'undefined';\n if (isCustom) {\n Object.defineProperty(userCtrl, symbols.CustomController, {\n writable: false,\n configurable: false,\n enumerable: false,\n });\n }\n\n return userCtrl;\n };\n};\n\nfunction createCoreService<\n TUID extends UID.ContentType,\n TService extends Core.CoreAPI.Service.Extendable<TUID>,\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<Utils.PartialWithThis<Core.CoreAPI.Service.Extendable<TUID> & TService>>\n) {\n return ({\n strapi,\n }: {\n strapi: Core.Strapi;\n }): TService & Core.CoreAPI.Service.ContentType<TUID> => {\n const baseService = createService({ contentType: strapi.contentType(uid) });\n\n const userService = typeof cfg === 'function' ? cfg({ strapi }) : (cfg ?? ({} as any));\n\n for (const methodName of Object.keys(baseService) as Array<keyof typeof baseService>) {\n if (userService[methodName] === undefined) {\n userService[methodName] = baseService[methodName];\n }\n }\n\n Object.setPrototypeOf(userService, baseService);\n return userService;\n };\n}\n\nfunction createCoreRouter<T extends UID.ContentType>(\n uid: T,\n cfg?: Core.CoreAPI.Router.RouterConfig<T>\n): Core.CoreAPI.Router.Router {\n const { prefix, config = {}, only, except, type = 'content-api' } = cfg ?? {};\n let routes: Core.CoreAPI.Router.Route[];\n\n return {\n type,\n prefix,\n get routes() {\n if (!routes) {\n const contentType = strapi.contentType(uid);\n\n const defaultRoutes = createRoutes({ contentType });\n const keys = Object.keys(defaultRoutes) as Array<keyof typeof defaultRoutes>;\n\n keys.forEach((routeName) => {\n const defaultRoute = defaultRoutes[routeName];\n\n Object.assign(defaultRoute.config, config[routeName] || {});\n });\n\n const selectedRoutes = pipe(\n (routes) => (except ? omit(except, routes) : routes),\n (routes) => (only ? pick(only, routes) : routes)\n )(defaultRoutes);\n\n routes = Object.values(selectedRoutes);\n }\n\n return routes;\n },\n };\n}\n\nconst isCustomController = <T extends Core.Controller>(controller: T): boolean => {\n return symbols.CustomController in controller;\n};\n\nexport { createCoreController, createCoreService, createCoreRouter, isCustomController };\n"],"names":["strapi","createController","createService","createRoutes","pipe","routes","omit","pick"],"mappings":";;;;;;AAOA,MAAM,UAAU;AAAA,EACd,kBAAkB,OAAO,4BAA4B;AACvD;AAIM,MAAA,uBAAuB,CAI3B,KACA,QAGG;AACH,SAAO,CAAC;AAAA,IACN,QAAAA;AAAAA,EAAA,MAG6D;AACvD,UAAA,iBAAiBC,uBAAiB,EAAE,aAAaD,QAAO,YAAY,GAAG,GAAG;AAE1E,UAAA,WAAW,OAAO,QAAQ,aAAa,IAAI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SAAS;AAE5C,iBAAO,OAAO,aAAa,QAAQ,OAAO,SAAS,KAAK,CAAA,CAAE;AAAA,QAAA,CAC3D;AAED,cAAM,iBAAiBC,GAAA;AAAA,UACrB,CAACC,YAAY,SAASC,GAAAA,KAAK,QAAQD,OAAM,IAAIA;AAAAA,UAC7C,CAACA,YAAY,OAAOE,GAAAA,KAAK,MAAMF,OAAM,IAAIA;AAAAA,UACzC,aAAa;AAEN,iBAAA,OAAO,OAAO,cAAc;AAAA,MACvC;AAEO,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;AAEM,MAAA,qBAAqB,CAA4B,eAA2B;AAChF,SAAO,QAAQ,oBAAoB;AACrC;;;;;"}
1
+ {"version":3,"file":"factories.js","sources":["../src/factories.ts"],"sourcesContent":["import { pipe, omit, pick } from 'lodash/fp';\nimport type { Core, UID, Utils } from '@strapi/types';\n\nimport { createController } from './core-api/controller';\nimport { createService } from './core-api/service';\nimport { createRoutes } from './core-api/routes';\n\nconst symbols = {\n CustomController: Symbol('StrapiCustomCoreController'),\n} as const;\n\ntype WithStrapiCallback<T> = T | (<S extends { strapi: Core.Strapi }>(params: S) => T);\n\nconst createCoreController = <\n TUID extends UID.ContentType,\n TController extends Core.CoreAPI.Controller.Extendable<TUID>,\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<\n Utils.PartialWithThis<Core.CoreAPI.Controller.Extendable<TUID> & TController>\n >\n) => {\n return ({\n strapi,\n }: {\n strapi: Core.Strapi;\n }): TController & Core.CoreAPI.Controller.ContentType<TUID> => {\n const baseController = createController({ contentType: strapi.contentType(uid) });\n\n const userCtrl = typeof cfg === 'function' ? cfg({ strapi }) : (cfg ?? ({} as any));\n\n for (const methodName of Object.keys(baseController) as Array<keyof typeof baseController>) {\n if (userCtrl[methodName] === undefined) {\n userCtrl[methodName] = baseController[methodName];\n }\n }\n\n Object.setPrototypeOf(userCtrl, baseController);\n\n const isCustom = typeof cfg !== 'undefined';\n if (isCustom) {\n Object.defineProperty(userCtrl, symbols.CustomController, {\n writable: false,\n configurable: false,\n enumerable: false,\n });\n }\n\n return userCtrl;\n };\n};\n\nfunction createCoreService<\n TUID extends UID.ContentType,\n TService extends Core.CoreAPI.Service.Extendable<TUID>,\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<Utils.PartialWithThis<Core.CoreAPI.Service.Extendable<TUID> & TService>>\n) {\n return ({\n strapi,\n }: {\n strapi: Core.Strapi;\n }): TService & Core.CoreAPI.Service.ContentType<TUID> => {\n const baseService = createService({ contentType: strapi.contentType(uid) });\n\n const userService = typeof cfg === 'function' ? cfg({ strapi }) : (cfg ?? ({} as any));\n\n for (const methodName of Object.keys(baseService) as Array<keyof typeof baseService>) {\n if (userService[methodName] === undefined) {\n userService[methodName] = baseService[methodName];\n }\n }\n\n Object.setPrototypeOf(userService, baseService);\n return userService;\n };\n}\n\nfunction createCoreRouter<T extends UID.ContentType>(\n uid: T,\n cfg?: Core.CoreAPI.Router.RouterConfig<T>\n): Core.CoreAPI.Router.Router {\n const { prefix, config = {}, only, except, type = 'content-api' } = cfg ?? {};\n let routes: Core.CoreAPI.Router.Route[];\n\n return {\n type,\n prefix,\n get routes() {\n if (!routes) {\n const contentType = strapi.contentType(uid);\n\n const defaultRoutes = createRoutes({ contentType });\n const keys = Object.keys(defaultRoutes) as Array<keyof typeof defaultRoutes>;\n\n keys.forEach((routeName) => {\n const defaultRoute = defaultRoutes[routeName];\n\n Object.assign(defaultRoute.config, config[routeName] || {});\n });\n\n const selectedRoutes = pipe(\n (routes) => (except ? omit(except, routes) : routes),\n (routes) => (only ? pick(only, routes) : routes)\n )(defaultRoutes);\n\n routes = Object.values(selectedRoutes);\n }\n\n return routes;\n },\n };\n}\n\nconst isCustomController = <T extends Core.Controller>(controller: T): boolean => {\n return symbols.CustomController in controller;\n};\n\nexport { createCoreController, createCoreService, createCoreRouter, isCustomController };\n"],"names":["strapi","createController","createService","createRoutes","pipe","routes","omit","pick"],"mappings":";;;;;;AAOA,MAAM,UAAU;AAA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SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA,IAAI,SAAS;AACX,UAAI,CAAC,QAAQ;AACL,cAAA,cAAc,OAAO,YAAY,GAAG;AAE1C,cAAM,gBAAgBG,QAAAA,aAAa,EAAE,aAAa;AAC5C,cAAA,OAAO,OAAO,KAAK,aAAa;AAEjC,aAAA,QAAQ,CAAC,cAAc;AACpB,gBAAA,eAAe,cAAc,SAAS;AAE5C,iBAAO,OAAO,aAAa,QAAQ,OAAO,SAAS,KAAK,EAAE;AAAA,QAAA,CAC3D;AAED,cAAM,iBAAiBC,GAAA;AAAA,UACrB,CAACC,YAAY,SAASC,GAAAA,KAAK,QAAQD,OAAM,IAAIA;AAAAA,UAC7C,CAACA,YAAY,OAAOE,GAAK,KAAA,MAAMF,OAAM,IAAIA;AAAAA,UACzC,aAAa;AAEN,iBAAA,OAAO,OAAO,cAAc;AAAA,MAAA;AAGhC,aAAA;AAAA,IAAA;AAAA,EAEX;AACF;AAEM,MAAA,qBAAqB,CAA4B,eAA2B;AAChF,SAAO,QAAQ,oBAAoB;AACrC;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"factories.mjs","sources":["../src/factories.ts"],"sourcesContent":["import { pipe, omit, pick } from 'lodash/fp';\nimport type { Core, UID, Utils } from '@strapi/types';\n\nimport { createController } from './core-api/controller';\nimport { createService } from './core-api/service';\nimport { createRoutes } from './core-api/routes';\n\nconst symbols = {\n CustomController: Symbol('StrapiCustomCoreController'),\n} as const;\n\ntype WithStrapiCallback<T> = T | (<S extends { strapi: Core.Strapi }>(params: S) => T);\n\nconst createCoreController = <\n TUID extends UID.ContentType,\n TController extends Core.CoreAPI.Controller.Extendable<TUID>,\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<\n Utils.PartialWithThis<Core.CoreAPI.Controller.Extendable<TUID> & TController>\n >\n) => {\n return ({\n strapi,\n }: {\n strapi: Core.Strapi;\n }): TController & Core.CoreAPI.Controller.ContentType<TUID> => {\n const baseController = createController({ contentType: strapi.contentType(uid) });\n\n const userCtrl = typeof cfg === 'function' ? cfg({ strapi }) : (cfg ?? ({} as any));\n\n for (const methodName of Object.keys(baseController) as Array<keyof typeof baseController>) {\n if (userCtrl[methodName] === undefined) {\n userCtrl[methodName] = baseController[methodName];\n }\n }\n\n Object.setPrototypeOf(userCtrl, baseController);\n\n const isCustom = typeof cfg !== 'undefined';\n if (isCustom) {\n Object.defineProperty(userCtrl, symbols.CustomController, {\n writable: false,\n configurable: false,\n enumerable: false,\n });\n }\n\n return userCtrl;\n };\n};\n\nfunction createCoreService<\n TUID extends UID.ContentType,\n TService extends Core.CoreAPI.Service.Extendable<TUID>,\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<Utils.PartialWithThis<Core.CoreAPI.Service.Extendable<TUID> & TService>>\n) {\n return ({\n strapi,\n }: {\n strapi: Core.Strapi;\n }): TService & Core.CoreAPI.Service.ContentType<TUID> => {\n const baseService = createService({ contentType: strapi.contentType(uid) });\n\n const userService = typeof cfg === 'function' ? cfg({ strapi }) : (cfg ?? ({} as any));\n\n for (const methodName of Object.keys(baseService) as Array<keyof typeof baseService>) {\n if (userService[methodName] === undefined) {\n userService[methodName] = baseService[methodName];\n }\n }\n\n Object.setPrototypeOf(userService, baseService);\n return userService;\n };\n}\n\nfunction createCoreRouter<T extends UID.ContentType>(\n uid: T,\n cfg?: Core.CoreAPI.Router.RouterConfig<T>\n): Core.CoreAPI.Router.Router {\n const { prefix, config = {}, only, except, type = 'content-api' } = cfg ?? {};\n let routes: Core.CoreAPI.Router.Route[];\n\n return {\n type,\n prefix,\n get routes() {\n if (!routes) {\n const contentType = strapi.contentType(uid);\n\n const defaultRoutes = createRoutes({ contentType });\n const keys = Object.keys(defaultRoutes) as Array<keyof typeof defaultRoutes>;\n\n keys.forEach((routeName) => {\n const defaultRoute = defaultRoutes[routeName];\n\n Object.assign(defaultRoute.config, config[routeName] || {});\n });\n\n const selectedRoutes = pipe(\n (routes) => (except ? omit(except, routes) : routes),\n (routes) => (only ? pick(only, routes) : routes)\n )(defaultRoutes);\n\n routes = Object.values(selectedRoutes);\n }\n\n return routes;\n },\n };\n}\n\nconst isCustomController = <T extends Core.Controller>(controller: T): boolean => {\n return symbols.CustomController in controller;\n};\n\nexport { createCoreController, createCoreService, createCoreRouter, isCustomController };\n"],"names":["strapi","routes"],"mappings":";;;;AAOA,MAAM,UAAU;AAAA,EACd,kBAAkB,OAAO,4BAA4B;AACvD;AAIM,MAAA,uBAAuB,CAI3B,KACA,QAGG;AACH,SAAO,CAAC;AAAA,IACN,QAAAA;AAAAA,EAAA,MAG6D;AACvD,UAAA,iBAAiB,iBAAiB,EAAE,aAAaA,QAAO,YAAY,GAAG,GAAG;AAE1E,UAAA,WAAW,OAAO,QAAQ,aAAa,IAAI,EAAE,QAAAA,QAAQ,CAAA,IAAK,OAAQ;AAExE,eAAW,cAAc,OAAO,KAAK,cAAc,GAAyC;AACtF,UAAA,SAAS,UAAU,MAAM,QAAW;AAC7B,iBAAA,UAAU,IAAI,eAAe,UAAU;AAAA,MAClD;AAAA,IACF;AAEO,WAAA,eAAe,UAAU,cAAc;AAExC,UAAA,WAAW,OAAO,QAAQ;AAChC,QAAI,UAAU;AACL,aAAA,eAAe,UAAU,QAAQ,kBAAkB;AAAA,QACxD,UAAU;AAAA,QACV,cAAc;AAAA,QACd,YAAY;AAAA,MAAA,CACb;AAAA,IACH;AAEO,WAAA;AAAA,EAAA;AAEX;AAEA,SAAS,kBAIP,KACA,KACA;AACA,SAAO,CAAC;AAAA,IACN,QAAAA;AAAAA,EAAA,MAGuD;AACjD,UAAA,cAAc,cAAc,EAAE,aAAaA,QAAO,YAAY,GAAG,GAAG;AAEpE,UAAA,cAAc,OAAO,QAAQ,aAAa,IAAI,EAAE,QAAAA,QAAQ,CAAA,IAAK,OAAQ;AAE3E,eAAW,cAAc,OAAO,KAAK,WAAW,GAAsC;AAChF,UAAA,YAAY,UAAU,MAAM,QAAW;AAC7B,oBAAA,UAAU,IAAI,YAAY,UAAU;AAAA,MAClD;AAAA,IACF;AAEO,WAAA,eAAe,aAAa,WAAW;AACvC,WAAA;AAAA,EAAA;AAEX;AAEA,SAAS,iBACP,KACA,KAC4B;AACtB,QAAA,EAAE,QAAQ,SAAS,CAAA,GAAI,MAAM,QAAQ,OAAO,cAAA,IAAkB,OAAO;AACvE,MAAA;AAEG,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA,IAAI,SAAS;AACX,UAAI,CAAC,QAAQ;AACL,cAAA,cAAc,OAAO,YAAY,GAAG;AAE1C,cAAM,gBAAgB,aAAa,EAAE,YAAa,CAAA;AAC5C,cAAA,OAAO,OAAO,KAAK,aAAa;AAEjC,aAAA,QAAQ,CAAC,cAAc;AACpB,gBAAA,eAAe,cAAc,SAAS;AAE5C,iBAAO,OAAO,aAAa,QAAQ,OAAO,SAAS,KAAK,CAAA,CAAE;AAAA,QAAA,CAC3D;AAED,cAAM,iBAAiB;AAAA,UACrB,CAACC,YAAY,SAAS,KAAK,QAAQA,OAAM,IAAIA;AAAAA,UAC7C,CAACA,YAAY,OAAO,KAAK,MAAMA,OAAM,IAAIA;AAAAA,UACzC,aAAa;AAEN,iBAAA,OAAO,OAAO,cAAc;AAAA,MACvC;AAEO,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;AAEM,MAAA,qBAAqB,CAA4B,eAA2B;AAChF,SAAO,QAAQ,oBAAoB;AACrC;"}
1
+ {"version":3,"file":"factories.mjs","sources":["../src/factories.ts"],"sourcesContent":["import { pipe, omit, pick } from 'lodash/fp';\nimport type { Core, UID, Utils } from '@strapi/types';\n\nimport { createController } from './core-api/controller';\nimport { createService } from './core-api/service';\nimport { createRoutes } from './core-api/routes';\n\nconst symbols = {\n CustomController: Symbol('StrapiCustomCoreController'),\n} as const;\n\ntype WithStrapiCallback<T> = T | (<S extends { strapi: Core.Strapi }>(params: S) => T);\n\nconst createCoreController = <\n TUID extends UID.ContentType,\n TController extends Core.CoreAPI.Controller.Extendable<TUID>,\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<\n Utils.PartialWithThis<Core.CoreAPI.Controller.Extendable<TUID> & TController>\n >\n) => {\n return ({\n strapi,\n }: {\n strapi: Core.Strapi;\n }): TController & Core.CoreAPI.Controller.ContentType<TUID> => {\n const baseController = createController({ contentType: strapi.contentType(uid) });\n\n const userCtrl = typeof cfg === 'function' ? cfg({ strapi }) : (cfg ?? ({} as any));\n\n for (const methodName of Object.keys(baseController) as Array<keyof typeof baseController>) {\n if (userCtrl[methodName] === undefined) {\n userCtrl[methodName] = baseController[methodName];\n }\n }\n\n Object.setPrototypeOf(userCtrl, baseController);\n\n const isCustom = typeof cfg !== 'undefined';\n if (isCustom) {\n Object.defineProperty(userCtrl, symbols.CustomController, {\n writable: false,\n configurable: false,\n enumerable: false,\n });\n }\n\n return userCtrl;\n };\n};\n\nfunction createCoreService<\n TUID extends UID.ContentType,\n TService extends Core.CoreAPI.Service.Extendable<TUID>,\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<Utils.PartialWithThis<Core.CoreAPI.Service.Extendable<TUID> & TService>>\n) {\n return ({\n strapi,\n }: {\n strapi: Core.Strapi;\n }): TService & Core.CoreAPI.Service.ContentType<TUID> => {\n const baseService = createService({ contentType: strapi.contentType(uid) });\n\n const userService = typeof cfg === 'function' ? cfg({ strapi }) : (cfg ?? ({} as any));\n\n for (const methodName of Object.keys(baseService) as Array<keyof typeof baseService>) {\n if (userService[methodName] === undefined) {\n userService[methodName] = baseService[methodName];\n }\n }\n\n Object.setPrototypeOf(userService, baseService);\n return userService;\n };\n}\n\nfunction createCoreRouter<T extends UID.ContentType>(\n uid: T,\n cfg?: Core.CoreAPI.Router.RouterConfig<T>\n): Core.CoreAPI.Router.Router {\n const { prefix, config = {}, only, except, type = 'content-api' } = cfg ?? {};\n let routes: Core.CoreAPI.Router.Route[];\n\n return {\n type,\n prefix,\n get routes() {\n if (!routes) {\n const contentType = strapi.contentType(uid);\n\n const defaultRoutes = createRoutes({ contentType });\n const keys = Object.keys(defaultRoutes) as Array<keyof typeof defaultRoutes>;\n\n keys.forEach((routeName) => {\n const defaultRoute = defaultRoutes[routeName];\n\n Object.assign(defaultRoute.config, config[routeName] || {});\n });\n\n const selectedRoutes = pipe(\n (routes) => (except ? omit(except, routes) : routes),\n (routes) => (only ? pick(only, routes) : routes)\n )(defaultRoutes);\n\n routes = Object.values(selectedRoutes);\n }\n\n return routes;\n },\n };\n}\n\nconst isCustomController = <T extends Core.Controller>(controller: T): boolean => {\n return symbols.CustomController in controller;\n};\n\nexport { createCoreController, createCoreService, createCoreRouter, isCustomController };\n"],"names":["strapi","routes"],"mappings":";;;;AAOA,MAAM,UAAU;AAAA,EACd,kBAAkB,OAAO,4BAA4B;AACvD;AAIM,MAAA,uBAAuB,CAI3B,KACA,QAGG;AACH,SAAO,CAAC;AAAA,IACN,QAAAA;AAAAA,EAAA,MAG6D;AACvD,UAAA,iBAAiB,iBAAiB,EAAE,aAAaA,QAAO,YAAY,GAAG,GAAG;AAE1E,UAAA,WAAW,OAAO,QAAQ,aAAa,IAAI,EAAE,QAAAA,QAAO,CAAC,IAAK,OAAQ,CAAC;AAEzE,eAAW,cAAc,OAAO,KAAK,cAAc,GAAyC;AACtF,UAAA,SAAS,UAAU,MAAM,QAAW;AAC7B,iBAAA,UAAU,IAAI,eAAe,UAAU;AAAA,MAAA;AAAA,IAClD;AAGK,WAAA,eAAe,UAAU,cAAc;AAExC,UAAA,WAAW,OAAO,QAAQ;AAChC,QAAI,UAAU;AACL,aAAA,eAAe,UAAU,QAAQ,kBAAkB;AAAA,QACxD,UAAU;AAAA,QACV,cAAc;AAAA,QACd,YAAY;AAAA,MAAA,CACb;AAAA,IAAA;AAGI,WAAA;AAAA,EACT;AACF;AAEA,SAAS,kBAIP,KACA,KACA;AACA,SAAO,CAAC;AAAA,IACN,QAAAA;AAAAA,EAAA,MAGuD;AACjD,UAAA,cAAc,cAAc,EAAE,aAAaA,QAAO,YAAY,GAAG,GAAG;AAEpE,UAAA,cAAc,OAAO,QAAQ,aAAa,IAAI,EAAE,QAAAA,QAAO,CAAC,IAAK,OAAQ,CAAC;AAE5E,eAAW,cAAc,OAAO,KAAK,WAAW,GAAsC;AAChF,UAAA,YAAY,UAAU,MAAM,QAAW;AAC7B,oBAAA,UAAU,IAAI,YAAY,UAAU;AAAA,MAAA;AAAA,IAClD;AAGK,WAAA,eAAe,aAAa,WAAW;AACvC,WAAA;AAAA,EACT;AACF;AAEA,SAAS,iBACP,KACA,KAC4B;AACtB,QAAA,EAAE,QAAQ,SAAS,IAAI,MAAM,QAAQ,OAAO,kBAAkB,OAAO,CAAC;AACxE,MAAA;AAEG,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA,IAAI,SAAS;AACX,UAAI,CAAC,QAAQ;AACL,cAAA,cAAc,OAAO,YAAY,GAAG;AAE1C,cAAM,gBAAgB,aAAa,EAAE,aAAa;AAC5C,cAAA,OAAO,OAAO,KAAK,aAAa;AAEjC,aAAA,QAAQ,CAAC,cAAc;AACpB,gBAAA,eAAe,cAAc,SAAS;AAE5C,iBAAO,OAAO,aAAa,QAAQ,OAAO,SAAS,KAAK,EAAE;AAAA,QAAA,CAC3D;AAED,cAAM,iBAAiB;AAAA,UACrB,CAACC,YAAY,SAAS,KAAK,QAAQA,OAAM,IAAIA;AAAAA,UAC7C,CAACA,YAAY,OAAO,KAAK,MAAMA,OAAM,IAAIA;AAAAA,UACzC,aAAa;AAEN,iBAAA,OAAO,OAAO,cAAc;AAAA,MAAA;AAGhC,aAAA;AAAA,IAAA;AAAA,EAEX;AACF;AAEM,MAAA,qBAAqB,CAA4B,eAA2B;AAChF,SAAO,QAAQ,oBAAoB;AACrC;"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import * as qs from 'qs';\nimport type { Core } from '@strapi/types';\n\nimport Strapi, { type StrapiOptions } from './Strapi';\nimport { destroyOnSignal, resolveWorkingDirectories, createUpdateNotifier } from './utils';\n\nexport { default as compileStrapi } from './compile';\nexport * as factories from './factories';\n\nexport const createStrapi = (options: Partial<StrapiOptions> = {}): Core.Strapi => {\n const strapi = new Strapi({\n ...options,\n ...resolveWorkingDirectories(options),\n });\n\n destroyOnSignal(strapi);\n createUpdateNotifier(strapi);\n\n // TODO: deprecate and remove in next major\n global.strapi = strapi;\n\n return strapi;\n};\n\n// Augment Koa query type based on Strapi query middleware\n\ndeclare module 'koa' {\n type ParsedQuery = ReturnType<typeof qs.parse>;\n\n export interface BaseRequest {\n _querycache?: ParsedQuery;\n\n get query(): ParsedQuery;\n set query(obj: any);\n }\n\n export interface BaseContext {\n _querycache?: ParsedQuery;\n\n get query(): ParsedQuery;\n set query(obj: any);\n }\n}\n"],"names":["resolveWorkingDirectories","destroyOnSignal","createUpdateNotifier"],"mappings":";;;;;;;;;;;;;;;;;AASO,MAAM,eAAe,CAAC,UAAkC,OAAoB;AAC3E,QAAA,SAAS,IAAI,OAAO;AAAA,IACxB,GAAG;AAAA,IACH,GAAGA,mBAAAA,0BAA0B,OAAO;AAAA,EAAA,CACrC;AAEDC,UAAA,gBAAgB,MAAM;AACtBC,QAAA,qBAAqB,MAAM;AAG3B,SAAO,SAAS;AAET,SAAA;AACT;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import * as qs from 'qs';\nimport type { Core } from '@strapi/types';\n\nimport Strapi, { type StrapiOptions } from './Strapi';\nimport { destroyOnSignal, resolveWorkingDirectories, createUpdateNotifier } from './utils';\n\nexport { default as compileStrapi } from './compile';\nexport * as factories from './factories';\n\nexport const createStrapi = (options: Partial<StrapiOptions> = {}): Core.Strapi => {\n const strapi = new Strapi({\n ...options,\n ...resolveWorkingDirectories(options),\n });\n\n destroyOnSignal(strapi);\n createUpdateNotifier(strapi);\n\n // TODO: deprecate and remove in next major\n global.strapi = strapi;\n\n return strapi;\n};\n\n// Augment Koa query type based on Strapi query middleware\n\ndeclare module 'koa' {\n type ParsedQuery = ReturnType<typeof qs.parse>;\n\n export interface BaseRequest {\n _querycache?: ParsedQuery;\n\n get query(): ParsedQuery;\n set query(obj: any);\n }\n\n export interface BaseContext {\n _querycache?: ParsedQuery;\n\n get query(): ParsedQuery;\n set query(obj: any);\n }\n}\n"],"names":["resolveWorkingDirectories","destroyOnSignal","createUpdateNotifier"],"mappings":";;;;;;;;;;;;;;;;;AASO,MAAM,eAAe,CAAC,UAAkC,OAAoB;AAC3E,QAAA,SAAS,IAAI,OAAO;AAAA,IACxB,GAAG;AAAA,IACH,GAAGA,6CAA0B,OAAO;AAAA,EAAA,CACrC;AAEDC,UAAAA,gBAAgB,MAAM;AACtBC,QAAAA,qBAAqB,MAAM;AAG3B,SAAO,SAAS;AAET,SAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"admin.js","sources":["../../src/loaders/admin.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Core, Struct } from '@strapi/types';\nimport { getGlobalId } from '../domain/content-type';\n\nexport default async function loadAdmin(strapi: Core.Strapi) {\n // strapi.admin = require('@strapi/admin/strapi-server');\n\n strapi.get('services').add(`admin::`, strapi.admin?.services);\n strapi.get('controllers').add(`admin::`, strapi.admin?.controllers);\n strapi.get('content-types').add(`admin::`, formatContentTypes(strapi.admin?.contentTypes ?? {}));\n strapi.get('policies').add(`admin::`, strapi.admin?.policies);\n strapi.get('middlewares').add(`admin::`, strapi.admin?.middlewares);\n\n const userAdminConfig = strapi.config.get('admin');\n strapi.get('config').set('admin', _.merge(strapi.admin?.config, userAdminConfig));\n}\n\nconst formatContentTypes = (contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>) => {\n Object.values(contentTypes).forEach((definition) => {\n const { schema } = definition;\n\n Object.assign(schema, {\n plugin: 'admin',\n globalId: getGlobalId(schema, 'admin'),\n });\n });\n\n return contentTypes;\n};\n"],"names":["_","getGlobalId"],"mappings":";;;;;AAIA,eAA8B,UAAU,QAAqB;AAG3D,SAAO,IAAI,UAAU,EAAE,IAAI,WAAW,OAAO,OAAO,QAAQ;AAC5D,SAAO,IAAI,aAAa,EAAE,IAAI,WAAW,OAAO,OAAO,WAAW;AAC3D,SAAA,IAAI,eAAe,EAAE,IAAI,WAAW,mBAAmB,OAAO,OAAO,gBAAgB,CAAA,CAAE,CAAC;AAC/F,SAAO,IAAI,UAAU,EAAE,IAAI,WAAW,OAAO,OAAO,QAAQ;AAC5D,SAAO,IAAI,aAAa,EAAE,IAAI,WAAW,OAAO,OAAO,WAAW;AAElE,QAAM,kBAAkB,OAAO,OAAO,IAAI,OAAO;AAC1C,SAAA,IAAI,QAAQ,EAAE,IAAI,SAASA,WAAAA,QAAE,MAAM,OAAO,OAAO,QAAQ,eAAe,CAAC;AAClF;AAEA,MAAM,qBAAqB,CAAC,iBAAuE;AACjG,SAAO,OAAO,YAAY,EAAE,QAAQ,CAAC,eAAe;AAC5C,UAAA,EAAE,OAAW,IAAA;AAEnB,WAAO,OAAO,QAAQ;AAAA,MACpB,QAAQ;AAAA,MACR,UAAUC,MAAAA,YAAY,QAAQ,OAAO;AAAA,IAAA,CACtC;AAAA,EAAA,CACF;AAEM,SAAA;AACT;;"}
1
+ {"version":3,"file":"admin.js","sources":["../../src/loaders/admin.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Core, Struct } from '@strapi/types';\nimport { getGlobalId } from '../domain/content-type';\n\nexport default async function loadAdmin(strapi: Core.Strapi) {\n // strapi.admin = require('@strapi/admin/strapi-server');\n\n strapi.get('services').add(`admin::`, strapi.admin?.services);\n strapi.get('controllers').add(`admin::`, strapi.admin?.controllers);\n strapi.get('content-types').add(`admin::`, formatContentTypes(strapi.admin?.contentTypes ?? {}));\n strapi.get('policies').add(`admin::`, strapi.admin?.policies);\n strapi.get('middlewares').add(`admin::`, strapi.admin?.middlewares);\n\n const userAdminConfig = strapi.config.get('admin');\n strapi.get('config').set('admin', _.merge(strapi.admin?.config, userAdminConfig));\n}\n\nconst formatContentTypes = (contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>) => {\n Object.values(contentTypes).forEach((definition) => {\n const { schema } = definition;\n\n Object.assign(schema, {\n plugin: 'admin',\n globalId: getGlobalId(schema, 'admin'),\n });\n });\n\n return contentTypes;\n};\n"],"names":["_","getGlobalId"],"mappings":";;;;;AAIA,eAA8B,UAAU,QAAqB;AAG3D,SAAO,IAAI,UAAU,EAAE,IAAI,WAAW,OAAO,OAAO,QAAQ;AAC5D,SAAO,IAAI,aAAa,EAAE,IAAI,WAAW,OAAO,OAAO,WAAW;AAC3D,SAAA,IAAI,eAAe,EAAE,IAAI,WAAW,mBAAmB,OAAO,OAAO,gBAAgB,CAAE,CAAA,CAAC;AAC/F,SAAO,IAAI,UAAU,EAAE,IAAI,WAAW,OAAO,OAAO,QAAQ;AAC5D,SAAO,IAAI,aAAa,EAAE,IAAI,WAAW,OAAO,OAAO,WAAW;AAElE,QAAM,kBAAkB,OAAO,OAAO,IAAI,OAAO;AAC1C,SAAA,IAAI,QAAQ,EAAE,IAAI,SAASA,mBAAE,MAAM,OAAO,OAAO,QAAQ,eAAe,CAAC;AAClF;AAEA,MAAM,qBAAqB,CAAC,iBAAuE;AACjG,SAAO,OAAO,YAAY,EAAE,QAAQ,CAAC,eAAe;AAC5C,UAAA,EAAE,WAAW;AAEnB,WAAO,OAAO,QAAQ;AAAA,MACpB,QAAQ;AAAA,MACR,UAAUC,MAAAA,YAAY,QAAQ,OAAO;AAAA,IAAA,CACtC;AAAA,EAAA,CACF;AAEM,SAAA;AACT;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"admin.mjs","sources":["../../src/loaders/admin.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Core, Struct } from '@strapi/types';\nimport { getGlobalId } from '../domain/content-type';\n\nexport default async function loadAdmin(strapi: Core.Strapi) {\n // strapi.admin = require('@strapi/admin/strapi-server');\n\n strapi.get('services').add(`admin::`, strapi.admin?.services);\n strapi.get('controllers').add(`admin::`, strapi.admin?.controllers);\n strapi.get('content-types').add(`admin::`, formatContentTypes(strapi.admin?.contentTypes ?? {}));\n strapi.get('policies').add(`admin::`, strapi.admin?.policies);\n strapi.get('middlewares').add(`admin::`, strapi.admin?.middlewares);\n\n const userAdminConfig = strapi.config.get('admin');\n strapi.get('config').set('admin', _.merge(strapi.admin?.config, userAdminConfig));\n}\n\nconst formatContentTypes = (contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>) => {\n Object.values(contentTypes).forEach((definition) => {\n const { schema } = definition;\n\n Object.assign(schema, {\n plugin: 'admin',\n globalId: getGlobalId(schema, 'admin'),\n });\n });\n\n return contentTypes;\n};\n"],"names":[],"mappings":";;AAIA,eAA8B,UAAU,QAAqB;AAG3D,SAAO,IAAI,UAAU,EAAE,IAAI,WAAW,OAAO,OAAO,QAAQ;AAC5D,SAAO,IAAI,aAAa,EAAE,IAAI,WAAW,OAAO,OAAO,WAAW;AAC3D,SAAA,IAAI,eAAe,EAAE,IAAI,WAAW,mBAAmB,OAAO,OAAO,gBAAgB,CAAA,CAAE,CAAC;AAC/F,SAAO,IAAI,UAAU,EAAE,IAAI,WAAW,OAAO,OAAO,QAAQ;AAC5D,SAAO,IAAI,aAAa,EAAE,IAAI,WAAW,OAAO,OAAO,WAAW;AAElE,QAAM,kBAAkB,OAAO,OAAO,IAAI,OAAO;AAC1C,SAAA,IAAI,QAAQ,EAAE,IAAI,SAAS,EAAE,MAAM,OAAO,OAAO,QAAQ,eAAe,CAAC;AAClF;AAEA,MAAM,qBAAqB,CAAC,iBAAuE;AACjG,SAAO,OAAO,YAAY,EAAE,QAAQ,CAAC,eAAe;AAC5C,UAAA,EAAE,OAAW,IAAA;AAEnB,WAAO,OAAO,QAAQ;AAAA,MACpB,QAAQ;AAAA,MACR,UAAU,YAAY,QAAQ,OAAO;AAAA,IAAA,CACtC;AAAA,EAAA,CACF;AAEM,SAAA;AACT;"}
1
+ {"version":3,"file":"admin.mjs","sources":["../../src/loaders/admin.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Core, Struct } from '@strapi/types';\nimport { getGlobalId } from '../domain/content-type';\n\nexport default async function loadAdmin(strapi: Core.Strapi) {\n // strapi.admin = require('@strapi/admin/strapi-server');\n\n strapi.get('services').add(`admin::`, strapi.admin?.services);\n strapi.get('controllers').add(`admin::`, strapi.admin?.controllers);\n strapi.get('content-types').add(`admin::`, formatContentTypes(strapi.admin?.contentTypes ?? {}));\n strapi.get('policies').add(`admin::`, strapi.admin?.policies);\n strapi.get('middlewares').add(`admin::`, strapi.admin?.middlewares);\n\n const userAdminConfig = strapi.config.get('admin');\n strapi.get('config').set('admin', _.merge(strapi.admin?.config, userAdminConfig));\n}\n\nconst formatContentTypes = (contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>) => {\n Object.values(contentTypes).forEach((definition) => {\n const { schema } = definition;\n\n Object.assign(schema, {\n plugin: 'admin',\n globalId: getGlobalId(schema, 'admin'),\n });\n });\n\n return contentTypes;\n};\n"],"names":[],"mappings":";;AAIA,eAA8B,UAAU,QAAqB;AAG3D,SAAO,IAAI,UAAU,EAAE,IAAI,WAAW,OAAO,OAAO,QAAQ;AAC5D,SAAO,IAAI,aAAa,EAAE,IAAI,WAAW,OAAO,OAAO,WAAW;AAC3D,SAAA,IAAI,eAAe,EAAE,IAAI,WAAW,mBAAmB,OAAO,OAAO,gBAAgB,CAAE,CAAA,CAAC;AAC/F,SAAO,IAAI,UAAU,EAAE,IAAI,WAAW,OAAO,OAAO,QAAQ;AAC5D,SAAO,IAAI,aAAa,EAAE,IAAI,WAAW,OAAO,OAAO,WAAW;AAElE,QAAM,kBAAkB,OAAO,OAAO,IAAI,OAAO;AAC1C,SAAA,IAAI,QAAQ,EAAE,IAAI,SAAS,EAAE,MAAM,OAAO,OAAO,QAAQ,eAAe,CAAC;AAClF;AAEA,MAAM,qBAAqB,CAAC,iBAAuE;AACjG,SAAO,OAAO,YAAY,EAAE,QAAQ,CAAC,eAAe;AAC5C,UAAA,EAAE,WAAW;AAEnB,WAAO,OAAO,QAAQ;AAAA,MACpB,QAAQ;AAAA,MACR,UAAU,YAAY,QAAQ,OAAO;AAAA,IAAA,CACtC;AAAA,EAAA,CACF;AAEM,SAAA;AACT;"}
@@ -1 +1 @@
1
- {"version":3,"file":"apis.js","sources":["../../src/loaders/apis.ts"],"sourcesContent":["import { join, extname, basename } from 'path';\nimport fse, { existsSync } from 'fs-extra';\nimport _ from 'lodash';\nimport { strings, importDefault } from '@strapi/utils';\nimport { isEmpty } from 'lodash/fp';\nimport type { Core, Struct } from '@strapi/types';\nimport { getGlobalId, type ContentTypeDefinition } from '../domain/content-type';\n\ninterface API {\n bootstrap: () => void | Promise<void>;\n destroy: () => void | Promise<void>;\n register: () => void | Promise<void>;\n config: Record<string, unknown>;\n routes: Record<string, Core.Router>;\n controllers: Record<string, Core.Controller>;\n services: Record<string, Core.Service>;\n policies: Record<string, Core.Policy>;\n middlewares: Record<string, Core.Middleware>;\n contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>;\n}\n\ninterface APIs {\n [key: string]: API;\n}\n\nconst DEFAULT_CONTENT_TYPE = {\n schema: {},\n actions: {},\n lifecycles: {},\n};\n\n// to handle names with numbers in it we first check if it is already in kebabCase\nconst normalizeName = (name: string) => (strings.isKebabCase(name) ? name : _.kebabCase(name));\n\nconst isDirectory = (fd: fse.Dirent) => fd.isDirectory();\nconst isDotFile = (fd: fse.Dirent) => fd.name.startsWith('.');\n\nexport default async function loadAPIs(strapi: Core.Strapi) {\n if (!existsSync(strapi.dirs.dist.api)) {\n return;\n }\n\n const apisFDs = await (await fse.readdir(strapi.dirs.dist.api, { withFileTypes: true }))\n .filter(isDirectory)\n .filter(_.negate(isDotFile));\n\n const apis: APIs = {};\n\n // only load folders\n for (const apiFD of apisFDs) {\n const apiName = normalizeName(apiFD.name);\n const api = await loadAPI(apiName, join(strapi.dirs.dist.api, apiFD.name));\n\n // @ts-expect-error TODO verify that it's a valid api, not missing bootstrap, register, and destroy\n apis[apiName] = api;\n }\n\n validateContentTypesUnicity(apis);\n\n for (const apiName of Object.keys(apis)) {\n strapi.get('apis').add(apiName, apis[apiName]);\n }\n}\n\nconst validateContentTypesUnicity = (apis: APIs) => {\n const allApisSchemas = Object.values(apis).flatMap((api) => Object.values(api.contentTypes));\n\n const names: string[] = [];\n allApisSchemas.forEach(({ schema }) => {\n if (schema.info.singularName) {\n const singularName = _.kebabCase(schema.info.singularName);\n if (names.includes(singularName)) {\n throw new Error(`The singular name \"${schema.info.singularName}\" should be unique`);\n }\n names.push(singularName);\n }\n\n if (schema.info.pluralName) {\n const pluralName = _.kebabCase(schema.info.pluralName);\n if (names.includes(pluralName)) {\n throw new Error(`The plural name \"${schema.info.pluralName}\" should be unique`);\n }\n names.push(pluralName);\n }\n });\n};\n\nconst loadAPI = async (apiName: string, dir: string) => {\n const [index, config, routes, controllers, services, policies, middlewares, contentTypes] = (\n await Promise.all([\n loadIndex(dir),\n loadDir(join(dir, 'config')),\n loadDir(join(dir, 'routes')),\n loadDir(join(dir, 'controllers')),\n loadDir(join(dir, 'services')),\n loadDir(join(dir, 'policies')),\n loadDir(join(dir, 'middlewares')),\n loadContentTypes(apiName, join(dir, 'content-types')),\n ])\n ).map((result) => result?.result);\n\n return {\n ...(index || {}),\n config: config || {},\n routes: routes || [],\n controllers: controllers || {},\n services: services || {},\n policies: policies || {},\n middlewares: middlewares || {},\n contentTypes: contentTypes || {},\n };\n};\n\nconst loadIndex = async (dir: string) => {\n if (await fse.pathExists(join(dir, 'index.js'))) {\n return loadFile(join(dir, 'index.js'));\n }\n};\n\n// because this is async and its contents are dynamic, we must return it within an object to avoid a property called `then` being interpreted as a Promise\nconst loadContentTypes = async (apiName: string, dir: string) => {\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const fds = await fse.readdir(dir, { withFileTypes: true });\n const contentTypes: API['contentTypes'] = {};\n\n // only load folders\n for (const fd of fds) {\n if (fd.isFile()) {\n continue;\n }\n\n const contentTypeName = normalizeName(fd.name);\n const loadedContentType = (await loadDir(join(dir, fd.name)))?.result;\n\n if (isEmpty(loadedContentType) || isEmpty(loadedContentType.schema)) {\n throw new Error(`Could not load content type found at ${dir}`);\n }\n\n const contentType = {\n ...DEFAULT_CONTENT_TYPE,\n ...loadedContentType,\n } as ContentTypeDefinition;\n\n Object.assign(contentType.schema, {\n apiName,\n collectionName: contentType.schema.collectionName || contentType.schema.info.singularName,\n globalId: getGlobalId(contentType.schema),\n });\n\n contentTypes[normalizeName(contentTypeName)] = contentType;\n }\n\n return { result: contentTypes };\n};\n\n// because this is async and its contents are dynamic, we must return it within an object to avoid a property called `then` being interpreted as a Promise\nconst loadDir = async (dir: string) => {\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const fds = await fse.readdir(dir, { withFileTypes: true });\n\n const root: Record<string, unknown> = {};\n for (const fd of fds) {\n if (!fd.isFile() || extname(fd.name) === '.map') {\n continue;\n }\n\n const key = basename(fd.name, extname(fd.name));\n\n root[normalizeName(key)] = (await loadFile(join(dir, fd.name))).result;\n }\n\n return { result: root };\n};\n\n// because this is async and its contents are dynamic, we must return it as an array to avoid a property called `then` being interpreted as a Promise\nconst loadFile = async (file: string): Promise<{ result: unknown }> => {\n const ext = extname(file);\n\n switch (ext) {\n case '.js':\n return { result: importDefault(file) };\n case '.json':\n return { result: await fse.readJSON(file) };\n default:\n return { result: {} };\n }\n};\n"],"names":["strings","_","existsSync","fse","join","index","isEmpty","getGlobalId","extname","basename","importDefault"],"mappings":";;;;;;;;;;AAyBA,MAAM,uBAAuB;AAAA,EAC3B,QAAQ,CAAC;AAAA,EACT,SAAS,CAAC;AAAA,EACV,YAAY,CAAC;AACf;AAGA,MAAM,gBAAgB,CAAC,SAAkBA,YAAQ,QAAA,YAAY,IAAI,IAAI,OAAOC,WAAE,QAAA,UAAU,IAAI;AAE5F,MAAM,cAAc,CAAC,OAAmB,GAAG,YAAY;AACvD,MAAM,YAAY,CAAC,OAAmB,GAAG,KAAK,WAAW,GAAG;AAE5D,eAA8B,SAAS,QAAqB;AAC1D,MAAI,CAACC,IAAW,WAAA,OAAO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AAA,IACX,KAAK;AACH,aAAO,EAAE,QAAQE,0BAAc,IAAI,EAAE;AAAA,IACvC,KAAK;AACH,aAAO,EAAE,QAAQ,MAAMP,aAAAA,QAAI,SAAS,IAAI,EAAE;AAAA,IAC5C;AACS,aAAA,EAAE,QAAQ,CAAA;EACrB;AACF;;"}
1
+ {"version":3,"file":"apis.js","sources":["../../src/loaders/apis.ts"],"sourcesContent":["import { join, extname, basename } from 'path';\nimport fse, { existsSync } from 'fs-extra';\nimport _ from 'lodash';\nimport { strings, importDefault } from '@strapi/utils';\nimport { isEmpty } from 'lodash/fp';\nimport type { Core, Struct } from '@strapi/types';\nimport { getGlobalId, type ContentTypeDefinition } from '../domain/content-type';\n\ninterface API {\n bootstrap: () => void | Promise<void>;\n destroy: () => void | Promise<void>;\n register: () => void | Promise<void>;\n config: Record<string, unknown>;\n routes: Record<string, Core.Router>;\n controllers: Record<string, Core.Controller>;\n services: Record<string, Core.Service>;\n policies: Record<string, Core.Policy>;\n middlewares: Record<string, Core.Middleware>;\n contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>;\n}\n\ninterface APIs {\n [key: string]: API;\n}\n\nconst DEFAULT_CONTENT_TYPE = {\n schema: {},\n actions: {},\n lifecycles: {},\n};\n\n// to handle names with numbers in it we first check if it is already in kebabCase\nconst normalizeName = (name: string) => (strings.isKebabCase(name) ? name : _.kebabCase(name));\n\nconst isDirectory = (fd: fse.Dirent) => fd.isDirectory();\nconst isDotFile = (fd: fse.Dirent) => fd.name.startsWith('.');\n\nexport default async function loadAPIs(strapi: Core.Strapi) {\n if (!existsSync(strapi.dirs.dist.api)) {\n return;\n }\n\n const apisFDs = await (await fse.readdir(strapi.dirs.dist.api, { withFileTypes: true }))\n .filter(isDirectory)\n .filter(_.negate(isDotFile));\n\n const apis: APIs = {};\n\n // only load folders\n for (const apiFD of apisFDs) {\n const apiName = normalizeName(apiFD.name);\n const api = await loadAPI(apiName, join(strapi.dirs.dist.api, apiFD.name));\n\n // @ts-expect-error TODO verify that it's a valid api, not missing bootstrap, register, and destroy\n apis[apiName] = api;\n }\n\n validateContentTypesUnicity(apis);\n\n for (const apiName of Object.keys(apis)) {\n strapi.get('apis').add(apiName, apis[apiName]);\n }\n}\n\nconst validateContentTypesUnicity = (apis: APIs) => {\n const allApisSchemas = Object.values(apis).flatMap((api) => Object.values(api.contentTypes));\n\n const names: string[] = [];\n allApisSchemas.forEach(({ schema }) => {\n if (schema.info.singularName) {\n const singularName = _.kebabCase(schema.info.singularName);\n if (names.includes(singularName)) {\n throw new Error(`The singular name \"${schema.info.singularName}\" should be unique`);\n }\n names.push(singularName);\n }\n\n if (schema.info.pluralName) {\n const pluralName = _.kebabCase(schema.info.pluralName);\n if (names.includes(pluralName)) {\n throw new Error(`The plural name \"${schema.info.pluralName}\" should be unique`);\n }\n names.push(pluralName);\n }\n });\n};\n\nconst loadAPI = async (apiName: string, dir: string) => {\n const [index, config, routes, controllers, services, policies, middlewares, contentTypes] = (\n await Promise.all([\n loadIndex(dir),\n loadDir(join(dir, 'config')),\n loadDir(join(dir, 'routes')),\n loadDir(join(dir, 'controllers')),\n loadDir(join(dir, 'services')),\n loadDir(join(dir, 'policies')),\n loadDir(join(dir, 'middlewares')),\n loadContentTypes(apiName, join(dir, 'content-types')),\n ])\n ).map((result) => result?.result);\n\n return {\n ...(index || {}),\n config: config || {},\n routes: routes || [],\n controllers: controllers || {},\n services: services || {},\n policies: policies || {},\n middlewares: middlewares || {},\n contentTypes: contentTypes || {},\n };\n};\n\nconst loadIndex = async (dir: string) => {\n if (await fse.pathExists(join(dir, 'index.js'))) {\n return loadFile(join(dir, 'index.js'));\n }\n};\n\n// because this is async and its contents are dynamic, we must return it within an object to avoid a property called `then` being interpreted as a Promise\nconst loadContentTypes = async (apiName: string, dir: string) => {\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const fds = await fse.readdir(dir, { withFileTypes: true });\n const contentTypes: API['contentTypes'] = {};\n\n // only load folders\n for (const fd of fds) {\n if (fd.isFile()) {\n continue;\n }\n\n const contentTypeName = normalizeName(fd.name);\n const loadedContentType = (await loadDir(join(dir, fd.name)))?.result;\n\n if (isEmpty(loadedContentType) || isEmpty(loadedContentType.schema)) {\n throw new Error(`Could not load content type found at ${dir}`);\n }\n\n const contentType = {\n ...DEFAULT_CONTENT_TYPE,\n ...loadedContentType,\n } as ContentTypeDefinition;\n\n Object.assign(contentType.schema, {\n apiName,\n collectionName: contentType.schema.collectionName || contentType.schema.info.singularName,\n globalId: getGlobalId(contentType.schema),\n });\n\n contentTypes[normalizeName(contentTypeName)] = contentType;\n }\n\n return { result: contentTypes };\n};\n\n// because this is async and its contents are dynamic, we must return it within an object to avoid a property called `then` being interpreted as a Promise\nconst loadDir = async (dir: string) => {\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const fds = await fse.readdir(dir, { withFileTypes: true });\n\n const root: Record<string, unknown> = {};\n for (const fd of fds) {\n if (!fd.isFile() || extname(fd.name) === '.map') {\n continue;\n }\n\n const key = basename(fd.name, extname(fd.name));\n\n root[normalizeName(key)] = (await loadFile(join(dir, fd.name))).result;\n }\n\n return { result: root };\n};\n\n// because this is async and its contents are dynamic, we must return it as an array to avoid a property called `then` being interpreted as a Promise\nconst loadFile = async (file: string): Promise<{ result: unknown }> => {\n const ext = extname(file);\n\n switch (ext) {\n case '.js':\n return { result: importDefault(file) };\n case '.json':\n return { result: await fse.readJSON(file) };\n default:\n return { result: {} };\n }\n};\n"],"names":["strings","_","existsSync","fse","join","index","isEmpty","getGlobalId","extname","basename","importDefault"],"mappings":";;;;;;;;;;AAyBA,MAAM,uBAAuB;AAAA,EAC3B,QAAQ,CAAC;AAAA,EACT,SAAS,CAAC;AAAA,EACV,YAAY,CAAA;AACd;AAGA,MAAM,gBAAgB,CAAC,SAAkBA,YAAAA,QAAQ,YAAY,IAAI,IAAI,OAAOC,WAAAA,QAAE,UAAU,IAAI;AAE5F,MAAM,cAAc,CAAC,OAAmB,GAAG,YAAY;AACvD,MAAM,YAAY,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EAAE,QAAQ,KAAK;AACxB;AAGA,MAAM,WAAW,OAAO,SAA+C;AAC/D,QAAA,MAAMI,aAAQ,IAAI;AAExB,UAAQ,KAAK;AAAA,IACX,KAAK;AACH,aAAO,EAAE,QAAQE,0BAAc,IAAI,EAAE;AAAA,IACvC,KAAK;AACH,aAAO,EAAE,QAAQ,MAAMP,aAAI,QAAA,SAAS,IAAI,EAAE;AAAA,IAC5C;AACS,aAAA,EAAE,QAAQ,GAAG;AAAA,EAAA;AAE1B;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"apis.mjs","sources":["../../src/loaders/apis.ts"],"sourcesContent":["import { join, extname, basename } from 'path';\nimport fse, { existsSync } from 'fs-extra';\nimport _ from 'lodash';\nimport { strings, importDefault } from '@strapi/utils';\nimport { isEmpty } from 'lodash/fp';\nimport type { Core, Struct } from '@strapi/types';\nimport { getGlobalId, type ContentTypeDefinition } from '../domain/content-type';\n\ninterface API {\n bootstrap: () => void | Promise<void>;\n destroy: () => void | Promise<void>;\n register: () => void | Promise<void>;\n config: Record<string, unknown>;\n routes: Record<string, Core.Router>;\n controllers: Record<string, Core.Controller>;\n services: Record<string, Core.Service>;\n policies: Record<string, Core.Policy>;\n middlewares: Record<string, Core.Middleware>;\n contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>;\n}\n\ninterface APIs {\n [key: string]: API;\n}\n\nconst DEFAULT_CONTENT_TYPE = {\n schema: {},\n actions: {},\n lifecycles: {},\n};\n\n// to handle names with numbers in it we first check if it is already in kebabCase\nconst normalizeName = (name: string) => (strings.isKebabCase(name) ? name : _.kebabCase(name));\n\nconst isDirectory = (fd: fse.Dirent) => fd.isDirectory();\nconst isDotFile = (fd: fse.Dirent) => fd.name.startsWith('.');\n\nexport default async function loadAPIs(strapi: Core.Strapi) {\n if (!existsSync(strapi.dirs.dist.api)) {\n return;\n }\n\n const apisFDs = await (await fse.readdir(strapi.dirs.dist.api, { withFileTypes: true }))\n .filter(isDirectory)\n .filter(_.negate(isDotFile));\n\n const apis: APIs = {};\n\n // only load folders\n for (const apiFD of apisFDs) {\n const apiName = normalizeName(apiFD.name);\n const api = await loadAPI(apiName, join(strapi.dirs.dist.api, apiFD.name));\n\n // @ts-expect-error TODO verify that it's a valid api, not missing bootstrap, register, and destroy\n apis[apiName] = api;\n }\n\n validateContentTypesUnicity(apis);\n\n for (const apiName of Object.keys(apis)) {\n strapi.get('apis').add(apiName, apis[apiName]);\n }\n}\n\nconst validateContentTypesUnicity = (apis: APIs) => {\n const allApisSchemas = Object.values(apis).flatMap((api) => Object.values(api.contentTypes));\n\n const names: string[] = [];\n allApisSchemas.forEach(({ schema }) => {\n if (schema.info.singularName) {\n const singularName = _.kebabCase(schema.info.singularName);\n if (names.includes(singularName)) {\n throw new Error(`The singular name \"${schema.info.singularName}\" should be unique`);\n }\n names.push(singularName);\n }\n\n if (schema.info.pluralName) {\n const pluralName = _.kebabCase(schema.info.pluralName);\n if (names.includes(pluralName)) {\n throw new Error(`The plural name \"${schema.info.pluralName}\" should be unique`);\n }\n names.push(pluralName);\n }\n });\n};\n\nconst loadAPI = async (apiName: string, dir: string) => {\n const [index, config, routes, controllers, services, policies, middlewares, contentTypes] = (\n await Promise.all([\n loadIndex(dir),\n loadDir(join(dir, 'config')),\n loadDir(join(dir, 'routes')),\n loadDir(join(dir, 'controllers')),\n loadDir(join(dir, 'services')),\n loadDir(join(dir, 'policies')),\n loadDir(join(dir, 'middlewares')),\n loadContentTypes(apiName, join(dir, 'content-types')),\n ])\n ).map((result) => result?.result);\n\n return {\n ...(index || {}),\n config: config || {},\n routes: routes || [],\n controllers: controllers || {},\n services: services || {},\n policies: policies || {},\n middlewares: middlewares || {},\n contentTypes: contentTypes || {},\n };\n};\n\nconst loadIndex = async (dir: string) => {\n if (await fse.pathExists(join(dir, 'index.js'))) {\n return loadFile(join(dir, 'index.js'));\n }\n};\n\n// because this is async and its contents are dynamic, we must return it within an object to avoid a property called `then` being interpreted as a Promise\nconst loadContentTypes = async (apiName: string, dir: string) => {\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const fds = await fse.readdir(dir, { withFileTypes: true });\n const contentTypes: API['contentTypes'] = {};\n\n // only load folders\n for (const fd of fds) {\n if (fd.isFile()) {\n continue;\n }\n\n const contentTypeName = normalizeName(fd.name);\n const loadedContentType = (await loadDir(join(dir, fd.name)))?.result;\n\n if (isEmpty(loadedContentType) || isEmpty(loadedContentType.schema)) {\n throw new Error(`Could not load content type found at ${dir}`);\n }\n\n const contentType = {\n ...DEFAULT_CONTENT_TYPE,\n ...loadedContentType,\n } as ContentTypeDefinition;\n\n Object.assign(contentType.schema, {\n apiName,\n collectionName: contentType.schema.collectionName || contentType.schema.info.singularName,\n globalId: getGlobalId(contentType.schema),\n });\n\n contentTypes[normalizeName(contentTypeName)] = contentType;\n }\n\n return { result: contentTypes };\n};\n\n// because this is async and its contents are dynamic, we must return it within an object to avoid a property called `then` being interpreted as a Promise\nconst loadDir = async (dir: string) => {\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const fds = await fse.readdir(dir, { withFileTypes: true });\n\n const root: Record<string, unknown> = {};\n for (const fd of fds) {\n if (!fd.isFile() || extname(fd.name) === '.map') {\n continue;\n }\n\n const key = basename(fd.name, extname(fd.name));\n\n root[normalizeName(key)] = (await loadFile(join(dir, fd.name))).result;\n }\n\n return { result: root };\n};\n\n// because this is async and its contents are dynamic, we must return it as an array to avoid a property called `then` being interpreted as a Promise\nconst loadFile = async (file: string): Promise<{ result: unknown }> => {\n const ext = extname(file);\n\n switch (ext) {\n case '.js':\n return { result: importDefault(file) };\n case '.json':\n return { result: await fse.readJSON(file) };\n default:\n return { result: {} };\n }\n};\n"],"names":[],"mappings":";;;;;;AAyBA,MAAM,uBAAuB;AAAA,EAC3B,QAAQ,CAAC;AAAA,EACT,SAAS,CAAC;AAAA,EACV,YAAY,CAAC;AACf;AAGA,MAAM,gBAAgB,CAAC,SAAkB,QAAQ,YAAY,IAAI,IAAI,OAAO,EAAE,UAAU,IAAI;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,EAAE,QAAQ,cAAc,IAAI,EAAE;AAAA,IACvC,KAAK;AACH,aAAO,EAAE,QAAQ,MAAM,IAAI,SAAS,IAAI,EAAE;AAAA,IAC5C;AACS,aAAA,EAAE,QAAQ,CAAA;EACrB;AACF;"}
1
+ {"version":3,"file":"apis.mjs","sources":["../../src/loaders/apis.ts"],"sourcesContent":["import { join, extname, basename } from 'path';\nimport fse, { existsSync } from 'fs-extra';\nimport _ from 'lodash';\nimport { strings, importDefault } from '@strapi/utils';\nimport { isEmpty } from 'lodash/fp';\nimport type { Core, Struct } from '@strapi/types';\nimport { getGlobalId, type ContentTypeDefinition } from '../domain/content-type';\n\ninterface API {\n bootstrap: () => void | Promise<void>;\n destroy: () => void | Promise<void>;\n register: () => void | Promise<void>;\n config: Record<string, unknown>;\n routes: Record<string, Core.Router>;\n controllers: Record<string, Core.Controller>;\n services: Record<string, Core.Service>;\n policies: Record<string, Core.Policy>;\n middlewares: Record<string, Core.Middleware>;\n contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>;\n}\n\ninterface APIs {\n [key: string]: API;\n}\n\nconst DEFAULT_CONTENT_TYPE = {\n schema: {},\n actions: {},\n lifecycles: {},\n};\n\n// to handle names with numbers in it we first check if it is already in kebabCase\nconst normalizeName = (name: string) => (strings.isKebabCase(name) ? name : _.kebabCase(name));\n\nconst isDirectory = (fd: fse.Dirent) => fd.isDirectory();\nconst isDotFile = (fd: fse.Dirent) => fd.name.startsWith('.');\n\nexport default async function loadAPIs(strapi: Core.Strapi) {\n if (!existsSync(strapi.dirs.dist.api)) {\n return;\n }\n\n const apisFDs = await (await fse.readdir(strapi.dirs.dist.api, { withFileTypes: true }))\n .filter(isDirectory)\n .filter(_.negate(isDotFile));\n\n const apis: APIs = {};\n\n // only load folders\n for (const apiFD of apisFDs) {\n const apiName = normalizeName(apiFD.name);\n const api = await loadAPI(apiName, join(strapi.dirs.dist.api, apiFD.name));\n\n // @ts-expect-error TODO verify that it's a valid api, not missing bootstrap, register, and destroy\n apis[apiName] = api;\n }\n\n validateContentTypesUnicity(apis);\n\n for (const apiName of Object.keys(apis)) {\n strapi.get('apis').add(apiName, apis[apiName]);\n }\n}\n\nconst validateContentTypesUnicity = (apis: APIs) => {\n const allApisSchemas = Object.values(apis).flatMap((api) => Object.values(api.contentTypes));\n\n const names: string[] = [];\n allApisSchemas.forEach(({ schema }) => {\n if (schema.info.singularName) {\n const singularName = _.kebabCase(schema.info.singularName);\n if (names.includes(singularName)) {\n throw new Error(`The singular name \"${schema.info.singularName}\" should be unique`);\n }\n names.push(singularName);\n }\n\n if (schema.info.pluralName) {\n const pluralName = _.kebabCase(schema.info.pluralName);\n if (names.includes(pluralName)) {\n throw new Error(`The plural name \"${schema.info.pluralName}\" should be unique`);\n }\n names.push(pluralName);\n }\n });\n};\n\nconst loadAPI = async (apiName: string, dir: string) => {\n const [index, config, routes, controllers, services, policies, middlewares, contentTypes] = (\n await Promise.all([\n loadIndex(dir),\n loadDir(join(dir, 'config')),\n loadDir(join(dir, 'routes')),\n loadDir(join(dir, 'controllers')),\n loadDir(join(dir, 'services')),\n loadDir(join(dir, 'policies')),\n loadDir(join(dir, 'middlewares')),\n loadContentTypes(apiName, join(dir, 'content-types')),\n ])\n ).map((result) => result?.result);\n\n return {\n ...(index || {}),\n config: config || {},\n routes: routes || [],\n controllers: controllers || {},\n services: services || {},\n policies: policies || {},\n middlewares: middlewares || {},\n contentTypes: contentTypes || {},\n };\n};\n\nconst loadIndex = async (dir: string) => {\n if (await fse.pathExists(join(dir, 'index.js'))) {\n return loadFile(join(dir, 'index.js'));\n }\n};\n\n// because this is async and its contents are dynamic, we must return it within an object to avoid a property called `then` being interpreted as a Promise\nconst loadContentTypes = async (apiName: string, dir: string) => {\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const fds = await fse.readdir(dir, { withFileTypes: true });\n const contentTypes: API['contentTypes'] = {};\n\n // only load folders\n for (const fd of fds) {\n if (fd.isFile()) {\n continue;\n }\n\n const contentTypeName = normalizeName(fd.name);\n const loadedContentType = (await loadDir(join(dir, fd.name)))?.result;\n\n if (isEmpty(loadedContentType) || isEmpty(loadedContentType.schema)) {\n throw new Error(`Could not load content type found at ${dir}`);\n }\n\n const contentType = {\n ...DEFAULT_CONTENT_TYPE,\n ...loadedContentType,\n } as ContentTypeDefinition;\n\n Object.assign(contentType.schema, {\n apiName,\n collectionName: contentType.schema.collectionName || contentType.schema.info.singularName,\n globalId: getGlobalId(contentType.schema),\n });\n\n contentTypes[normalizeName(contentTypeName)] = contentType;\n }\n\n return { result: contentTypes };\n};\n\n// because this is async and its contents are dynamic, we must return it within an object to avoid a property called `then` being interpreted as a Promise\nconst loadDir = async (dir: string) => {\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const fds = await fse.readdir(dir, { withFileTypes: true });\n\n const root: Record<string, unknown> = {};\n for (const fd of fds) {\n if (!fd.isFile() || extname(fd.name) === '.map') {\n continue;\n }\n\n const key = basename(fd.name, extname(fd.name));\n\n root[normalizeName(key)] = (await loadFile(join(dir, fd.name))).result;\n }\n\n return { result: root };\n};\n\n// because this is async and its contents are dynamic, we must return it as an array to avoid a property called `then` being interpreted as a Promise\nconst loadFile = async (file: string): Promise<{ result: unknown }> => {\n const ext = extname(file);\n\n switch (ext) {\n case '.js':\n return { result: importDefault(file) };\n case '.json':\n return { result: await fse.readJSON(file) };\n default:\n return { result: {} };\n }\n};\n"],"names":[],"mappings":";;;;;;AAyBA,MAAM,uBAAuB;AAAA,EAC3B,QAAQ,CAAC;AAAA,EACT,SAAS,CAAC;AAAA,EACV,YAAY,CAAA;AACd;AAGA,MAAM,gBAAgB,CAAC,SAAkB,QAAQ,YAAY,IAAI,IAAI,OAAO,EAAE,UAAU,IAAI;AAE5F,MAAM,cAAc,CAAC,OAAmB,GAAG,YAAY;AACvD,MAAM,YAAY,CAAC,OAAmB,GAAG,KAAK,WAAW,GAAG;AAE5D,eAA8B,SAAS,QAAqB;AAC1D,MAAI,CAAC,WAAW,OAAO,KAAK,KA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,GAAG;AAAA,EAAA;AAE1B;"}
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sources":["../../src/loaders/components.ts"],"sourcesContent":["import { join } from 'path';\nimport _ from 'lodash';\nimport { pathExists } from 'fs-extra';\nimport type { Core, Struct, UID } from '@strapi/types';\nimport { loadFiles } from '../utils/load-files';\n\ntype LoadedComponent = {\n collectionName: string;\n __filename__: string;\n __schema__: LoadedComponent;\n uid: string;\n category: string;\n modelName: string;\n globalId: string;\n info: any;\n attributes: any;\n};\n\ntype LoadedComponents = {\n [category: string]: {\n [key: string]: LoadedComponent;\n };\n};\n\ntype ComponentMap = {\n [uid in UID.Component]: Struct.ComponentSchema;\n};\n\nexport default async function loadComponents(strapi: Core.Strapi) {\n if (!(await pathExists(strapi.dirs.dist.components))) {\n return {};\n }\n\n const map = await loadFiles<LoadedComponents>(strapi.dirs.dist.components, '*/*.*(js|json)');\n\n const components = Object.keys(map).reduce((acc, category) => {\n Object.keys(map[category]).forEach((key) => {\n const schema = map[category][key];\n\n if (!schema.collectionName) {\n // NOTE: We're using the filepath from the app directory instead of the dist for information purpose\n const filePath = join(strapi.dirs.app.components, category, schema.__filename__);\n\n return strapi.stopWithError(\n `Component ${key} is missing a \"collectionName\" property.\\nVerify file ${filePath}.`\n );\n }\n\n const uid: UID.Component = `${category}.${key}`;\n\n acc[uid] = Object.assign(schema, {\n __schema__: _.cloneDeep(schema),\n uid,\n category,\n modelType: 'component' as const,\n modelName: key,\n globalId: schema.globalId || _.upperFirst(_.camelCase(`component_${uid}`)),\n });\n });\n\n return acc;\n }, {} as ComponentMap);\n\n strapi.get('components').add(components);\n}\n"],"names":["pathExists","loadFiles","join","_"],"mappings":";;;;;;;AA4BA,eAA8B,eAAe,QAAqB;AAChE,MAAI,CAAE,MAAMA,IAAAA,WAAW,OAAO,KAAK,KAAK,UAAU,GAAI;AACpD,WAAO;EACT;AAEA,QAAM,MAAM,MAAMC,UAAAA,UAA4B,OAAO,KAAK,KAAK,YAAY,gBAAgB;AAErF,QAAA,aAAa,OAAO,KAAK,GAAG,EAAE,OAAO,CAAC,KAAK,aAAa;AAC5D,WAAO,KAAK,IAAI,QAAQ,CAAC,EAAE,QAAQ,CAAC,QAAQ;AAC1C,YAAM,SAAS,IAAI,QAAQ,EAAE,GAAG;AAE5B,UAAA,CAAC,OAAO,gBAAgB;AAEpB,cAAA,WAAWC,UAAK,OAAO,KAAK,IAAI,YAAY,UAAU,OAAO,YAAY;AAE/E,eAAO,OAAO;AAAA,UACZ,aAAa,GAAG;AAAA,cAAyD,QAAQ;AAAA,QAAA;AAAA,MAErF;AAEA,YAAM,MAAqB,GAAG,QAAQ,IAAI,GAAG;AAE7C,UAAI,GAAG,IAAI,OAAO,OAAO,QAAQ;AAAA,QAC/B,YAAYC,WAAAA,QAAE,UAAU,MAAM;AAAA,QAC9B;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX,WAAW;AAAA,QACX,UAAU,OAAO,YAAYA,WAAAA,QAAE,WAAWA,mBAAE,UAAU,aAAa,GAAG,EAAE,CAAC;AAAA,MAAA,CAC1E;AAAA,IAAA,CACF;AAEM,WAAA;AAAA,EACT,GAAG,CAAkB,CAAA;AAErB,SAAO,IAAI,YAAY,EAAE,IAAI,UAAU;AACzC;;"}
1
+ {"version":3,"file":"components.js","sources":["../../src/loaders/components.ts"],"sourcesContent":["import { join } from 'path';\nimport _ from 'lodash';\nimport { pathExists } from 'fs-extra';\nimport type { Core, Struct, UID } from '@strapi/types';\nimport { loadFiles } from '../utils/load-files';\n\ntype LoadedComponent = {\n collectionName: string;\n __filename__: string;\n __schema__: LoadedComponent;\n uid: string;\n category: string;\n modelName: string;\n globalId: string;\n info: any;\n attributes: any;\n};\n\ntype LoadedComponents = {\n [category: string]: {\n [key: string]: LoadedComponent;\n };\n};\n\ntype ComponentMap = {\n [uid in UID.Component]: Struct.ComponentSchema;\n};\n\nexport default async function loadComponents(strapi: Core.Strapi) {\n if (!(await pathExists(strapi.dirs.dist.components))) {\n return {};\n }\n\n const map = await loadFiles<LoadedComponents>(strapi.dirs.dist.components, '*/*.*(js|json)');\n\n const components = Object.keys(map).reduce((acc, category) => {\n Object.keys(map[category]).forEach((key) => {\n const schema = map[category][key];\n\n if (!schema.collectionName) {\n // NOTE: We're using the filepath from the app directory instead of the dist for information purpose\n const filePath = join(strapi.dirs.app.components, category, schema.__filename__);\n\n return strapi.stopWithError(\n `Component ${key} is missing a \"collectionName\" property.\\nVerify file ${filePath}.`\n );\n }\n\n const uid: UID.Component = `${category}.${key}`;\n\n acc[uid] = Object.assign(schema, {\n __schema__: _.cloneDeep(schema),\n uid,\n category,\n modelType: 'component' as const,\n modelName: key,\n globalId: schema.globalId || _.upperFirst(_.camelCase(`component_${uid}`)),\n });\n });\n\n return acc;\n }, {} as ComponentMap);\n\n strapi.get('components').add(components);\n}\n"],"names":["pathExists","loadFiles","join","_"],"mappings":";;;;;;;AA4BA,eAA8B,eAAe,QAAqB;AAChE,MAAI,CAAE,MAAMA,IAAAA,WAAW,OAAO,KAAK,KAAK,UAAU,GAAI;AACpD,WAAO,CAAC;AAAA,EAAA;AAGV,QAAM,MAAM,MAAMC,oBAA4B,OAAO,KAAK,KAAK,YAAY,gBAAgB;AAErF,QAAA,aAAa,OAAO,KAAK,GAAG,EAAE,OAAO,CAAC,KAAK,aAAa;AAC5D,WAAO,KAAK,IAAI,QAAQ,CAAC,EAAE,QAAQ,CAAC,QAAQ;AAC1C,YAAM,SAAS,IAAI,QAAQ,EAAE,GAAG;AAE5B,UAAA,CAAC,OAAO,gBAAgB;AAEpB,cAAA,WAAWC,UAAK,OAAO,KAAK,IAAI,YAAY,UAAU,OAAO,YAAY;AAE/E,eAAO,OAAO;AAAA,UACZ,aAAa,GAAG;AAAA,cAAyD,QAAQ;AAAA,QACnF;AAAA,MAAA;AAGF,YAAM,MAAqB,GAAG,QAAQ,IAAI,GAAG;AAE7C,UAAI,GAAG,IAAI,OAAO,OAAO,QAAQ;AAAA,QAC/B,YAAYC,WAAAA,QAAE,UAAU,MAAM;AAAA,QAC9B;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX,WAAW;AAAA,QACX,UAAU,OAAO,YAAYA,WAAAA,QAAE,WAAWA,mBAAE,UAAU,aAAa,GAAG,EAAE,CAAC;AAAA,MAAA,CAC1E;AAAA,IAAA,CACF;AAEM,WAAA;AAAA,EACT,GAAG,EAAkB;AAErB,SAAO,IAAI,YAAY,EAAE,IAAI,UAAU;AACzC;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"components.mjs","sources":["../../src/loaders/components.ts"],"sourcesContent":["import { join } from 'path';\nimport _ from 'lodash';\nimport { pathExists } from 'fs-extra';\nimport type { Core, Struct, UID } from '@strapi/types';\nimport { loadFiles } from '../utils/load-files';\n\ntype LoadedComponent = {\n collectionName: string;\n __filename__: string;\n __schema__: LoadedComponent;\n uid: string;\n category: string;\n modelName: string;\n globalId: string;\n info: any;\n attributes: any;\n};\n\ntype LoadedComponents = {\n [category: string]: {\n [key: string]: LoadedComponent;\n };\n};\n\ntype ComponentMap = {\n [uid in UID.Component]: Struct.ComponentSchema;\n};\n\nexport default async function loadComponents(strapi: Core.Strapi) {\n if (!(await pathExists(strapi.dirs.dist.components))) {\n return {};\n }\n\n const map = await loadFiles<LoadedComponents>(strapi.dirs.dist.components, '*/*.*(js|json)');\n\n const components = Object.keys(map).reduce((acc, category) => {\n Object.keys(map[category]).forEach((key) => {\n const schema = map[category][key];\n\n if (!schema.collectionName) {\n // NOTE: We're using the filepath from the app directory instead of the dist for information purpose\n const filePath = join(strapi.dirs.app.components, category, schema.__filename__);\n\n return strapi.stopWithError(\n `Component ${key} is missing a \"collectionName\" property.\\nVerify file ${filePath}.`\n );\n }\n\n const uid: UID.Component = `${category}.${key}`;\n\n acc[uid] = Object.assign(schema, {\n __schema__: _.cloneDeep(schema),\n uid,\n category,\n modelType: 'component' as const,\n modelName: key,\n globalId: schema.globalId || _.upperFirst(_.camelCase(`component_${uid}`)),\n });\n });\n\n return acc;\n }, {} as ComponentMap);\n\n strapi.get('components').add(components);\n}\n"],"names":[],"mappings":";;;;AA4BA,eAA8B,eAAe,QAAqB;AAChE,MAAI,CAAE,MAAM,WAAW,OAAO,KAAK,KAAK,UAAU,GAAI;AACpD,WAAO;EACT;AAEA,QAAM,MAAM,MAAM,UAA4B,OAAO,KAAK,KAAK,YAAY,gBAAgB;AAErF,QAAA,aAAa,OAAO,KAAK,GAAG,EAAE,OAAO,CAAC,KAAK,aAAa;AAC5D,WAAO,KAAK,IAAI,QAAQ,CAAC,EAAE,QAAQ,CAAC,QAAQ;AAC1C,YAAM,SAAS,IAAI,QAAQ,EAAE,GAAG;AAE5B,UAAA,CAAC,OAAO,gBAAgB;AAEpB,cAAA,WAAW,KAAK,OAAO,KAAK,IAAI,YAAY,UAAU,OAAO,YAAY;AAE/E,eAAO,OAAO;AAAA,UACZ,aAAa,GAAG;AAAA,cAAyD,QAAQ;AAAA,QAAA;AAAA,MAErF;AAEA,YAAM,MAAqB,GAAG,QAAQ,IAAI,GAAG;AAE7C,UAAI,GAAG,IAAI,OAAO,OAAO,QAAQ;AAAA,QAC/B,YAAY,EAAE,UAAU,MAAM;AAAA,QAC9B;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX,WAAW;AAAA,QACX,UAAU,OAAO,YAAY,EAAE,WAAW,EAAE,UAAU,aAAa,GAAG,EAAE,CAAC;AAAA,MAAA,CAC1E;AAAA,IAAA,CACF;AAEM,WAAA;AAAA,EACT,GAAG,CAAkB,CAAA;AAErB,SAAO,IAAI,YAAY,EAAE,IAAI,UAAU;AACzC;"}
1
+ {"version":3,"file":"components.mjs","sources":["../../src/loaders/components.ts"],"sourcesContent":["import { join } from 'path';\nimport _ from 'lodash';\nimport { pathExists } from 'fs-extra';\nimport type { Core, Struct, UID } from '@strapi/types';\nimport { loadFiles } from '../utils/load-files';\n\ntype LoadedComponent = {\n collectionName: string;\n __filename__: string;\n __schema__: LoadedComponent;\n uid: string;\n category: string;\n modelName: string;\n globalId: string;\n info: any;\n attributes: any;\n};\n\ntype LoadedComponents = {\n [category: string]: {\n [key: string]: LoadedComponent;\n };\n};\n\ntype ComponentMap = {\n [uid in UID.Component]: Struct.ComponentSchema;\n};\n\nexport default async function loadComponents(strapi: Core.Strapi) {\n if (!(await pathExists(strapi.dirs.dist.components))) {\n return {};\n }\n\n const map = await loadFiles<LoadedComponents>(strapi.dirs.dist.components, '*/*.*(js|json)');\n\n const components = Object.keys(map).reduce((acc, category) => {\n Object.keys(map[category]).forEach((key) => {\n const schema = map[category][key];\n\n if (!schema.collectionName) {\n // NOTE: We're using the filepath from the app directory instead of the dist for information purpose\n const filePath = join(strapi.dirs.app.components, category, schema.__filename__);\n\n return strapi.stopWithError(\n `Component ${key} is missing a \"collectionName\" property.\\nVerify file ${filePath}.`\n );\n }\n\n const uid: UID.Component = `${category}.${key}`;\n\n acc[uid] = Object.assign(schema, {\n __schema__: _.cloneDeep(schema),\n uid,\n category,\n modelType: 'component' as const,\n modelName: key,\n globalId: schema.globalId || _.upperFirst(_.camelCase(`component_${uid}`)),\n });\n });\n\n return acc;\n }, {} as ComponentMap);\n\n strapi.get('components').add(components);\n}\n"],"names":[],"mappings":";;;;AA4BA,eAA8B,eAAe,QAAqB;AAChE,MAAI,CAAE,MAAM,WAAW,OAAO,KAAK,KAAK,UAAU,GAAI;AACpD,WAAO,CAAC;AAAA,EAAA;AAGV,QAAM,MAAM,MAAM,UAA4B,OAAO,KAAK,KAAK,YAAY,gBAAgB;AAErF,QAAA,aAAa,OAAO,KAAK,GAAG,EAAE,OAAO,CAAC,KAAK,aAAa;AAC5D,WAAO,KAAK,IAAI,QAAQ,CAAC,EAAE,QAAQ,CAAC,QAAQ;AAC1C,YAAM,SAAS,IAAI,QAAQ,EAAE,GAAG;AAE5B,UAAA,CAAC,OAAO,gBAAgB;AAEpB,cAAA,WAAW,KAAK,OAAO,KAAK,IAAI,YAAY,UAAU,OAAO,YAAY;AAE/E,eAAO,OAAO;AAAA,UACZ,aAAa,GAAG;AAAA,cAAyD,QAAQ;AAAA,QACnF;AAAA,MAAA;AAGF,YAAM,MAAqB,GAAG,QAAQ,IAAI,GAAG;AAE7C,UAAI,GAAG,IAAI,OAAO,OAAO,QAAQ;AAAA,QAC/B,YAAY,EAAE,UAAU,MAAM;AAAA,QAC9B;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX,WAAW;AAAA,QACX,UAAU,OAAO,YAAY,EAAE,WAAW,EAAE,UAAU,aAAa,GAAG,EAAE,CAAC;AAAA,MAAA,CAC1E;AAAA,IAAA,CACF;AAEM,WAAA;AAAA,EACT,GAAG,EAAkB;AAErB,SAAO,IAAI,YAAY,EAAE,IAAI,UAAU;AACzC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"middlewares.js","sources":["../../src/loaders/middlewares.ts"],"sourcesContent":["import { join, extname, basename } from 'path';\nimport fse from 'fs-extra';\nimport { importDefault } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\nimport { middlewares as internalMiddlewares } from '../middlewares';\n\n// TODO:: allow folders with index.js inside for bigger policies\nexport default async function loadMiddlewares(strapi: Core.Strapi) {\n const localMiddlewares = await loadLocalMiddlewares(strapi);\n\n strapi.get('middlewares').add(`global::`, localMiddlewares);\n strapi.get('middlewares').add(`strapi::`, internalMiddlewares);\n}\n\nconst loadLocalMiddlewares = async (strapi: Core.Strapi) => {\n const dir = strapi.dirs.dist.middlewares;\n\n if (!(await fse.pathExists(dir))) {\n return {};\n }\n\n const middlewares: Record<string, Core.MiddlewareFactory> = {};\n const paths = await fse.readdir(dir, { withFileTypes: true });\n\n for (const fd of paths) {\n const { name } = fd;\n const fullPath = join(dir, name);\n\n if (fd.isFile() && extname(name) === '.js') {\n const key = basename(name, '.js');\n middlewares[key] = importDefault(fullPath);\n }\n }\n\n return middlewares;\n};\n"],"names":["internalMiddlewares","fse","join","extname","basename","importDefault"],"mappings":";;;;;;;AAOA,eAA8B,gBAAgB,QAAqB;AAC3D,QAAA,mBAAmB,MAAM,qBAAqB,MAAM;AAE1D,SAAO,IAAI,aAAa,EAAE,IAAI,YAAY,gBAAgB;AAC1D,SAAO,IAAI,aAAa,EAAE,IAAI,YAAYA,MAAAA,WAAmB;AAC/D;AAEA,MAAM,uBAAuB,OAAO,WAAwB;AACpD,QAAA,MAAM,OAAO,KAAK,KAAK;AAE7B,MAAI,CAAE,MAAMC,aAAAA,QAAI,WAAW,GAAG,GAAI;AAChC,WAAO;EACT;AAEA,QAAM,cAAsD,CAAA;AACtD,QAAA,QAAQ,MAAMA,aAAAA,QAAI,QAAQ,KAAK,EAAE,eAAe,MAAM;AAE5D,aAAW,MAAM,OAAO;AAChB,UAAA,EAAE,KAAS,IAAA;AACX,UAAA,WAAWC,KAAAA,KAAK,KAAK,IAAI;AAE/B,QAAI,GAAG,OAAO,KAAKC,KAAQ,QAAA,IAAI,MAAM,OAAO;AACpC,YAAA,MAAMC,KAAAA,SAAS,MAAM,KAAK;AACpB,kBAAA,GAAG,IAAIC,YAAA,cAAc,QAAQ;AAAA,IAC3C;AAAA,EACF;AAEO,SAAA;AACT;;"}
1
+ {"version":3,"file":"middlewares.js","sources":["../../src/loaders/middlewares.ts"],"sourcesContent":["import { join, extname, basename } from 'path';\nimport fse from 'fs-extra';\nimport { importDefault } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\nimport { middlewares as internalMiddlewares } from '../middlewares';\n\n// TODO:: allow folders with index.js inside for bigger policies\nexport default async function loadMiddlewares(strapi: Core.Strapi) {\n const localMiddlewares = await loadLocalMiddlewares(strapi);\n\n strapi.get('middlewares').add(`global::`, localMiddlewares);\n strapi.get('middlewares').add(`strapi::`, internalMiddlewares);\n}\n\nconst loadLocalMiddlewares = async (strapi: Core.Strapi) => {\n const dir = strapi.dirs.dist.middlewares;\n\n if (!(await fse.pathExists(dir))) {\n return {};\n }\n\n const middlewares: Record<string, Core.MiddlewareFactory> = {};\n const paths = await fse.readdir(dir, { withFileTypes: true });\n\n for (const fd of paths) {\n const { name } = fd;\n const fullPath = join(dir, name);\n\n if (fd.isFile() && extname(name) === '.js') {\n const key = basename(name, '.js');\n middlewares[key] = importDefault(fullPath);\n }\n }\n\n return middlewares;\n};\n"],"names":["internalMiddlewares","fse","join","extname","basename","importDefault"],"mappings":";;;;;;;AAOA,eAA8B,gBAAgB,QAAqB;AAC3D,QAAA,mBAAmB,MAAM,qBAAqB,MAAM;AAE1D,SAAO,IAAI,aAAa,EAAE,IAAI,YAAY,gBAAgB;AAC1D,SAAO,IAAI,aAAa,EAAE,IAAI,YAAYA,iBAAmB;AAC/D;AAEA,MAAM,uBAAuB,OAAO,WAAwB;AACpD,QAAA,MAAM,OAAO,KAAK,KAAK;AAE7B,MAAI,CAAE,MAAMC,aAAAA,QAAI,WAAW,GAAG,GAAI;AAChC,WAAO,CAAC;AAAA,EAAA;AAGV,QAAM,cAAsD,CAAC;AACvD,QAAA,QAAQ,MAAMA,qBAAI,QAAQ,KAAK,EAAE,eAAe,MAAM;AAE5D,aAAW,MAAM,OAAO;AAChB,UAAA,EAAE,SAAS;AACX,UAAA,WAAWC,KAAAA,KAAK,KAAK,IAAI;AAE/B,QAAI,GAAG,OAAO,KAAKC,KAAQ,QAAA,IAAI,MAAM,OAAO;AACpC,YAAA,MAAMC,KAAAA,SAAS,MAAM,KAAK;AACpB,kBAAA,GAAG,IAAIC,YAAA,cAAc,QAAQ;AAAA,IAAA;AAAA,EAC3C;AAGK,SAAA;AACT;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"middlewares.mjs","sources":["../../src/loaders/middlewares.ts"],"sourcesContent":["import { join, extname, basename } from 'path';\nimport fse from 'fs-extra';\nimport { importDefault } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\nimport { middlewares as internalMiddlewares } from '../middlewares';\n\n// TODO:: allow folders with index.js inside for bigger policies\nexport default async function loadMiddlewares(strapi: Core.Strapi) {\n const localMiddlewares = await loadLocalMiddlewares(strapi);\n\n strapi.get('middlewares').add(`global::`, localMiddlewares);\n strapi.get('middlewares').add(`strapi::`, internalMiddlewares);\n}\n\nconst loadLocalMiddlewares = async (strapi: Core.Strapi) => {\n const dir = strapi.dirs.dist.middlewares;\n\n if (!(await fse.pathExists(dir))) {\n return {};\n }\n\n const middlewares: Record<string, Core.MiddlewareFactory> = {};\n const paths = await fse.readdir(dir, { withFileTypes: true });\n\n for (const fd of paths) {\n const { name } = fd;\n const fullPath = join(dir, name);\n\n if (fd.isFile() && extname(name) === '.js') {\n const key = basename(name, '.js');\n middlewares[key] = importDefault(fullPath);\n }\n }\n\n return middlewares;\n};\n"],"names":["internalMiddlewares","middlewares"],"mappings":";;;;AAOA,eAA8B,gBAAgB,QAAqB;AAC3D,QAAA,mBAAmB,MAAM,qBAAqB,MAAM;AAE1D,SAAO,IAAI,aAAa,EAAE,IAAI,YAAY,gBAAgB;AAC1D,SAAO,IAAI,aAAa,EAAE,IAAI,YAAYA,WAAmB;AAC/D;AAEA,MAAM,uBAAuB,OAAO,WAAwB;AACpD,QAAA,MAAM,OAAO,KAAK,KAAK;AAE7B,MAAI,CAAE,MAAM,IAAI,WAAW,GAAG,GAAI;AAChC,WAAO;EACT;AAEA,QAAMC,eAAsD,CAAA;AACtD,QAAA,QAAQ,MAAM,IAAI,QAAQ,KAAK,EAAE,eAAe,MAAM;AAE5D,aAAW,MAAM,OAAO;AAChB,UAAA,EAAE,KAAS,IAAA;AACX,UAAA,WAAW,KAAK,KAAK,IAAI;AAE/B,QAAI,GAAG,OAAO,KAAK,QAAQ,IAAI,MAAM,OAAO;AACpC,YAAA,MAAM,SAAS,MAAM,KAAK;AACpB,MAAAA,aAAA,GAAG,IAAI,cAAc,QAAQ;AAAA,IAC3C;AAAA,EACF;AAEO,SAAAA;AACT;"}
1
+ {"version":3,"file":"middlewares.mjs","sources":["../../src/loaders/middlewares.ts"],"sourcesContent":["import { join, extname, basename } from 'path';\nimport fse from 'fs-extra';\nimport { importDefault } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\nimport { middlewares as internalMiddlewares } from '../middlewares';\n\n// TODO:: allow folders with index.js inside for bigger policies\nexport default async function loadMiddlewares(strapi: Core.Strapi) {\n const localMiddlewares = await loadLocalMiddlewares(strapi);\n\n strapi.get('middlewares').add(`global::`, localMiddlewares);\n strapi.get('middlewares').add(`strapi::`, internalMiddlewares);\n}\n\nconst loadLocalMiddlewares = async (strapi: Core.Strapi) => {\n const dir = strapi.dirs.dist.middlewares;\n\n if (!(await fse.pathExists(dir))) {\n return {};\n }\n\n const middlewares: Record<string, Core.MiddlewareFactory> = {};\n const paths = await fse.readdir(dir, { withFileTypes: true });\n\n for (const fd of paths) {\n const { name } = fd;\n const fullPath = join(dir, name);\n\n if (fd.isFile() && extname(name) === '.js') {\n const key = basename(name, '.js');\n middlewares[key] = importDefault(fullPath);\n }\n }\n\n return middlewares;\n};\n"],"names":["internalMiddlewares","middlewares"],"mappings":";;;;AAOA,eAA8B,gBAAgB,QAAqB;AAC3D,QAAA,mBAAmB,MAAM,qBAAqB,MAAM;AAE1D,SAAO,IAAI,aAAa,EAAE,IAAI,YAAY,gBAAgB;AAC1D,SAAO,IAAI,aAAa,EAAE,IAAI,YAAYA,WAAmB;AAC/D;AAEA,MAAM,uBAAuB,OAAO,WAAwB;AACpD,QAAA,MAAM,OAAO,KAAK,KAAK;AAE7B,MAAI,CAAE,MAAM,IAAI,WAAW,GAAG,GAAI;AAChC,WAAO,CAAC;AAAA,EAAA;AAGV,QAAMC,eAAsD,CAAC;AACvD,QAAA,QAAQ,MAAM,IAAI,QAAQ,KAAK,EAAE,eAAe,MAAM;AAE5D,aAAW,MAAM,OAAO;AAChB,UAAA,EAAE,SAAS;AACX,UAAA,WAAW,KAAK,KAAK,IAAI;AAE/B,QAAI,GAAG,OAAO,KAAK,QAAQ,IAAI,MAAM,OAAO;AACpC,YAAA,MAAM,SAAS,MAAM,KAAK;AACpB,MAAAA,aAAA,GAAG,IAAI,cAAc,QAAQ;AAAA,IAAA;AAAA,EAC3C;AAGK,SAAAA;AACT;"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-enabled-plugins.js","sources":["../../../src/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport { strings } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface PluginMeta {\n enabled: boolean;\n pathToPlugin?: string;\n info: Record<string, unknown>;\n packageInfo?: Record<string, unknown>;\n}\n\ntype PluginMetas = Record<string, PluginMeta>;\n\ninterface PluginInfo {\n name: string;\n kind: string;\n}\n\ninterface PluginDeclaration {\n enabled: boolean;\n resolve: string;\n isModule: boolean;\n}\n\n/**\n * otherwise known as \"core features\"\n *\n * NOTE: These are excluded from the content manager plugin list, as they are always enabled.\n * See admin.ts server controller on the content-manager plugin for more details.\n */\nconst INTERNAL_PLUGINS = [\n '@strapi/content-manager',\n '@strapi/content-type-builder',\n '@strapi/email',\n '@strapi/upload',\n '@strapi/i18n',\n '@strapi/content-releases',\n '@strapi/review-workflows',\n];\n\nconst isStrapiPlugin = (info: PluginInfo) => get('strapi.kind', info) === 'plugin';\n\nconst validatePluginName = (pluginName: string) => {\n if (!strings.isKebabCase(pluginName)) {\n throw new Error(`Plugin name \"${pluginName}\" is not in kebab (an-example-of-kebab-case)`);\n }\n};\n\nconst toDetailedDeclaration = (declaration: boolean | PluginDeclaration) => {\n if (typeof declaration === 'boolean') {\n return { enabled: declaration };\n }\n\n const detailedDeclaration: { enabled: boolean; pathToPlugin?: string } = {\n enabled: declaration.enabled,\n };\n\n if (declaration?.resolve) {\n let pathToPlugin = '';\n\n if (declaration.isModule) {\n /**\n * we only want the node_module here, not the package.json\n */\n pathToPlugin = join(declaration.resolve, '..');\n } else {\n try {\n pathToPlugin = dirname(require.resolve(declaration.resolve));\n } catch (e) {\n pathToPlugin = resolve(strapi.dirs.app.root, declaration.resolve);\n\n if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {\n throw new Error(`${declaration.resolve} couldn't be resolved`);\n }\n }\n }\n\n detailedDeclaration.pathToPlugin = pathToPlugin;\n }\n\n return detailedDeclaration;\n};\n\nexport const getEnabledPlugins = async (strapi: Core.Strapi, { client } = { client: false }) => {\n const internalPlugins: PluginMetas = {};\n\n for (const dep of INTERNAL_PLUGINS) {\n const packagePath = join(dep, 'package.json');\n\n // NOTE: internal plugins should be resolved from the strapi package\n const packageModulePath = require.resolve(packagePath, {\n paths: [require.resolve('@strapi/strapi/package.json'), process.cwd()],\n });\n\n const packageInfo = require(packageModulePath);\n\n validatePluginName(packageInfo.strapi.name);\n internalPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packageModulePath, isModule: client }),\n info: packageInfo.strapi,\n packageInfo,\n };\n }\n\n const installedPlugins: PluginMetas = {};\n const dependencies = strapi.config.get('info.dependencies', {});\n\n for (const dep of Object.keys(dependencies)) {\n const packagePath = join(dep, 'package.json');\n let packageInfo;\n try {\n packageInfo = require(packagePath);\n } catch {\n continue;\n }\n\n if (isStrapiPlugin(packageInfo)) {\n validatePluginName(packageInfo.strapi.name);\n installedPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: {\n ...packageInfo.strapi,\n packageName: packageInfo.name,\n },\n packageInfo,\n };\n }\n }\n\n const declaredPlugins: PluginMetas = {};\n const userPluginsConfig = await getUserPluginsConfig();\n\n _.forEach(userPluginsConfig, (declaration, pluginName) => {\n validatePluginName(pluginName);\n\n declaredPlugins[pluginName] = {\n ...toDetailedDeclaration(declaration),\n info: {},\n };\n\n const { pathToPlugin } = declaredPlugins[pluginName];\n\n // for manually resolved plugins\n if (pathToPlugin) {\n const packagePath = join(pathToPlugin, 'package.json');\n const packageInfo = require(packagePath);\n\n if (isStrapiPlugin(packageInfo)) {\n declaredPlugins[pluginName].info = packageInfo.strapi || {};\n declaredPlugins[pluginName].packageInfo = packageInfo;\n }\n }\n });\n\n const declaredPluginsResolves = map(prop('pathToPlugin'), declaredPlugins);\n const installedPluginsNotAlreadyUsed = pickBy(\n (p) => !declaredPluginsResolves.includes(p.pathToPlugin),\n installedPlugins\n );\n\n const enabledPlugins = pipe(\n defaultsDeep(declaredPlugins),\n defaultsDeep(installedPluginsNotAlreadyUsed),\n pickBy((p: PluginMeta) => p.enabled)\n )(internalPlugins);\n\n return enabledPlugins;\n};\n"],"names":["get","strings","join","dirname","resolve","existsSync","statSync","strapi","getUserPluginsConfig","_","map","prop","pickBy","pipe","defaultsDeep"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,iBAAiB,CAAC,SAAqBA,GAAAA,IAAI,eAAe,IAAI,MAAM;AAE1E,MAAM,qBAAqB,CAAC,eAAuB;AACjD,MAAI,CAACC,YAAA,QAAQ,YAAY,UAAU,GAAG;AACpC,UAAM,IAAI,MAAM,gBAAgB,UAAU,8CAA8C;AAAA,EAC1F;AACF;AAEA,MAAM,wBAAwB,CAAC,gBAA6C;AACtE,MAAA,OAAO,gBAAgB,WAAW;AAC7B,WAAA,EAAE,SAAS;EACpB;AAEA,QAAM,sBAAmE;AAAA,IACvE,SAAS,YAAY;AAAA,EAAA;AAGvB,MAAI,aAAa,SAAS;AACxB,QAAI,eAAe;AAEnB,QAAI,YAAY,UAAU;AAIT,qBAAAC,KAAAA,KAAK,YAAY,SAAS,IAAI;AAAA,IAAA,OACxC;AACD,UAAA;AACF,uBAAeC,KAAQ,QAAA,QAAQ,QAAQ,YAAY,OAAO,CAAC;AAAA,eACpD,GAAG;AACV,uBAAeC,KAAAA,QAAQ,OAAO,KAAK,IAAI,MAAM,YAAY,OAAO;AAE5D,YAAA,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AAA,QACA;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AAEA,QAAM,kBAA+B,CAAA;AAC/B,QAAA,oBAAoB,MAAMM,qBAAAA;AAEhCC,aAAAA,QAAE,QAAQ,mBAAmB,CAAC,aAAa,eAAe;AACxD,uBAAmB,UAAU;AAE7B,oBAAgB,UAAU,IAAI;AAAA,MAC5B,GAAG,sBAAsB,WAAW;AAAA,MACpC,MAAM,CAAC;AAAA,IAAA;AAGT,UAAM,EAAE,aAAA,IAAiB,gBAAgB,UAAU;AAGnD,QAAI,cAAc;AACV,YAAA,cAAcP,KAAAA,KAAK,cAAc,cAAc;AAC/C,YAAA,cAAc,QAAQ,WAAW;AAEnC,UAAA,eAAe,WAAW,GAAG;AAC/B,wBAAgB,UAAU,EAAE,OAAO,YAAY,UAAU,CAAA;AACzC,wBAAA,UAAU,EAAE,cAAc;AAAA,MAC5C;AAAA,IACF;AAAA,EAAA,CACD;AAED,QAAM,0BAA0BQ,GAAAA,IAAIC,GAAAA,KAAK,cAAc,GAAG,eAAe;AACzE,QAAM,iCAAiCC,GAAA;AAAA,IACrC,CAAC,MAAM,CAAC,wBAAwB,SAAS,EAAE,YAAY;AAAA,IACvD;AAAA,EAAA;AAGF,QAAM,iBAAiBC,GAAA;AAAA,IACrBC,GAAAA,aAAa,eAAe;AAAA,IAC5BA,GAAAA,aAAa,8BAA8B;AAAA,IAC3CF,GAAAA,OAAO,CAAC,MAAkB,EAAE,OAAO;AAAA,IACnC,eAAe;AAEV,SAAA;AACT;;"}
1
+ {"version":3,"file":"get-enabled-plugins.js","sources":["../../../src/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport { strings } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface PluginMeta {\n enabled: boolean;\n pathToPlugin?: string;\n info: Record<string, unknown>;\n packageInfo?: Record<string, unknown>;\n}\n\ntype PluginMetas = Record<string, PluginMeta>;\n\ninterface PluginInfo {\n name: string;\n kind: string;\n}\n\ninterface PluginDeclaration {\n enabled: boolean;\n resolve: string;\n isModule: boolean;\n}\n\n/**\n * otherwise known as \"core features\"\n *\n * NOTE: These are excluded from the content manager plugin list, as they are always enabled.\n * See admin.ts server controller on the content-manager plugin for more details.\n */\nconst INTERNAL_PLUGINS = [\n '@strapi/content-manager',\n '@strapi/content-type-builder',\n '@strapi/email',\n '@strapi/upload',\n '@strapi/i18n',\n '@strapi/content-releases',\n '@strapi/review-workflows',\n];\n\nconst isStrapiPlugin = (info: PluginInfo) => get('strapi.kind', info) === 'plugin';\n\nconst validatePluginName = (pluginName: string) => {\n if (!strings.isKebabCase(pluginName)) {\n throw new Error(`Plugin name \"${pluginName}\" is not in kebab (an-example-of-kebab-case)`);\n }\n};\n\nconst toDetailedDeclaration = (declaration: boolean | PluginDeclaration) => {\n if (typeof declaration === 'boolean') {\n return { enabled: declaration };\n }\n\n const detailedDeclaration: { enabled: boolean; pathToPlugin?: string } = {\n enabled: declaration.enabled,\n };\n\n if (declaration?.resolve) {\n let pathToPlugin = '';\n\n if (declaration.isModule) {\n /**\n * we only want the node_module here, not the package.json\n */\n pathToPlugin = join(declaration.resolve, '..');\n } else {\n try {\n pathToPlugin = dirname(require.resolve(declaration.resolve));\n } catch (e) {\n pathToPlugin = resolve(strapi.dirs.app.root, declaration.resolve);\n\n if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {\n throw new Error(`${declaration.resolve} couldn't be resolved`);\n }\n }\n }\n\n detailedDeclaration.pathToPlugin = pathToPlugin;\n }\n\n return detailedDeclaration;\n};\n\nexport const getEnabledPlugins = async (strapi: Core.Strapi, { client } = { client: false }) => {\n const internalPlugins: PluginMetas = {};\n\n for (const dep of INTERNAL_PLUGINS) {\n const packagePath = join(dep, 'package.json');\n\n // NOTE: internal plugins should be resolved from the strapi package\n const packageModulePath = require.resolve(packagePath, {\n paths: [require.resolve('@strapi/strapi/package.json'), process.cwd()],\n });\n\n const packageInfo = require(packageModulePath);\n\n validatePluginName(packageInfo.strapi.name);\n internalPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packageModulePath, isModule: client }),\n info: packageInfo.strapi,\n packageInfo,\n };\n }\n\n const installedPlugins: PluginMetas = {};\n const dependencies = strapi.config.get('info.dependencies', {});\n\n for (const dep of Object.keys(dependencies)) {\n const packagePath = join(dep, 'package.json');\n let packageInfo;\n try {\n packageInfo = require(packagePath);\n } catch {\n continue;\n }\n\n if (isStrapiPlugin(packageInfo)) {\n validatePluginName(packageInfo.strapi.name);\n installedPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: {\n ...packageInfo.strapi,\n packageName: packageInfo.name,\n },\n packageInfo,\n };\n }\n }\n\n const declaredPlugins: PluginMetas = {};\n const userPluginsConfig = await getUserPluginsConfig();\n\n _.forEach(userPluginsConfig, (declaration, pluginName) => {\n validatePluginName(pluginName);\n\n declaredPlugins[pluginName] = {\n ...toDetailedDeclaration(declaration),\n info: {},\n };\n\n const { pathToPlugin } = declaredPlugins[pluginName];\n\n // for manually resolved plugins\n if (pathToPlugin) {\n const packagePath = join(pathToPlugin, 'package.json');\n const packageInfo = require(packagePath);\n\n if (isStrapiPlugin(packageInfo)) {\n declaredPlugins[pluginName].info = packageInfo.strapi || {};\n declaredPlugins[pluginName].packageInfo = packageInfo;\n }\n }\n });\n\n const declaredPluginsResolves = map(prop('pathToPlugin'), declaredPlugins);\n const installedPluginsNotAlreadyUsed = pickBy(\n (p) => !declaredPluginsResolves.includes(p.pathToPlugin),\n installedPlugins\n );\n\n const enabledPlugins = pipe(\n defaultsDeep(declaredPlugins),\n defaultsDeep(installedPluginsNotAlreadyUsed),\n pickBy((p: PluginMeta) => p.enabled)\n )(internalPlugins);\n\n return enabledPlugins;\n};\n"],"names":["get","strings","join","dirname","resolve","existsSync","statSync","strapi","getUserPluginsConfig","_","map","prop","pickBy","pipe","defaultsDeep"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,iBAAiB,CAAC,SAAqBA,GAAAA,IAAI,eAAe,IAAI,MAAM;AAE1E,MAAM,qBAAqB,CAAC,eAAuB;AACjD,MAAI,CAACC,YAAA,QAAQ,YAAY,UAAU,GAAG;AACpC,UAAM,IAAI,MAAM,gBAAgB,UAAU,8CAA8C;AAAA,EAAA;AAE5F;AAEA,MAAM,wBAAwB,CAAC,gBAA6C;AACtE,MAAA,OAAO,gBAAgB,WAAW;AAC7B,WAAA,EAAE,SAAS,YAAY;AAAA,EAAA;AAGhC,QAAM,sBAAmE;AAAA,IACvE,SAAS,YAAY;AAAA,EACvB;AAEA,MAAI,aAAa,SAAS;AACxB,QAAI,eAAe;AAEnB,QAAI,YAAY,UAAU;AAIT,qBAAAC,KAAA,KAAK,YAAY,SAAS,IAAI;AAAA,IAAA,OACxC;AACD,UAAA;AACF,uBAAeC,KAAQ,QAAA,QAAQ,QAAQ,YAAY,OAAO,CAAC;AAAA,eACpD,GAAG;AACV,uBAAeC,aAAQ,OAAO,KAAK,IAAI,MAAM,YAAY,OAAO;AAE5D,YAAA,CAACC,cAAW,YAAY,KAAK,CAACC,GAAAA,SAAS,YAAY,EAAE,eAAe;AACtE,gBAAM,IAAI,MAAM,GAAG,YAAY,OAAO,uBAAuB;AAAA,QAAA;AAAA,MAC/D;AAAA,IACF;AAGF,wBAAoB,eAAe;AAAA,EAAA;AAG9B,SAAA;AACT;AAEa,MAAA,oBAAoB,OAAOC,SAAqB,EAAE,OAAW,IAAA,EAAE,QAAQ,YAAY;AA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AAAA,IACR;AAEA,UAAM,EAAE,aAAA,IAAiB,gBAAgB,UAAU;AAGnD,QAAI,cAAc;AACV,YAAA,cAAcP,KAAAA,KAAK,cAAc,cAAc;AAC/C,YAAA,cAAc,QAAQ,WAAW;AAEnC,UAAA,eAAe,WAAW,GAAG;AAC/B,wBAAgB,UAAU,EAAE,OAAO,YAAY,UAAU,CAAC;AAC1C,wBAAA,UAAU,EAAE,cAAc;AAAA,MAAA;AAAA,IAC5C;AAAA,EACF,CACD;AAED,QAAM,0BAA0BQ,GAAA,IAAIC,GAAK,KAAA,cAAc,GAAG,eAAe;AACzE,QAAM,iCAAiCC,GAAA;AAAA,IACrC,CAAC,MAAM,CAAC,wBAAwB,SAAS,EAAE,YAAY;AAAA,IACvD;AAAA,EACF;AAEA,QAAM,iBAAiBC,GAAA;AAAA,IACrBC,GAAAA,aAAa,eAAe;AAAA,IAC5BA,GAAAA,aAAa,8BAA8B;AAAA,IAC3CF,UAAO,CAAC,MAAkB,EAAE,OAAO;AAAA,IACnC,eAAe;AAEV,SAAA;AACT;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-enabled-plugins.mjs","sources":["../../../src/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport { strings } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface PluginMeta {\n enabled: boolean;\n pathToPlugin?: string;\n info: Record<string, unknown>;\n packageInfo?: Record<string, unknown>;\n}\n\ntype PluginMetas = Record<string, PluginMeta>;\n\ninterface PluginInfo {\n name: string;\n kind: string;\n}\n\ninterface PluginDeclaration {\n enabled: boolean;\n resolve: string;\n isModule: boolean;\n}\n\n/**\n * otherwise known as \"core features\"\n *\n * NOTE: These are excluded from the content manager plugin list, as they are always enabled.\n * See admin.ts server controller on the content-manager plugin for more details.\n */\nconst INTERNAL_PLUGINS = [\n '@strapi/content-manager',\n '@strapi/content-type-builder',\n '@strapi/email',\n '@strapi/upload',\n '@strapi/i18n',\n '@strapi/content-releases',\n '@strapi/review-workflows',\n];\n\nconst isStrapiPlugin = (info: PluginInfo) => get('strapi.kind', info) === 'plugin';\n\nconst validatePluginName = (pluginName: string) => {\n if (!strings.isKebabCase(pluginName)) {\n throw new Error(`Plugin name \"${pluginName}\" is not in kebab (an-example-of-kebab-case)`);\n }\n};\n\nconst toDetailedDeclaration = (declaration: boolean | PluginDeclaration) => {\n if (typeof declaration === 'boolean') {\n return { enabled: declaration };\n }\n\n const detailedDeclaration: { enabled: boolean; pathToPlugin?: string } = {\n enabled: declaration.enabled,\n };\n\n if (declaration?.resolve) {\n let pathToPlugin = '';\n\n if (declaration.isModule) {\n /**\n * we only want the node_module here, not the package.json\n */\n pathToPlugin = join(declaration.resolve, '..');\n } else {\n try {\n pathToPlugin = dirname(require.resolve(declaration.resolve));\n } catch (e) {\n pathToPlugin = resolve(strapi.dirs.app.root, declaration.resolve);\n\n if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {\n throw new Error(`${declaration.resolve} couldn't be resolved`);\n }\n }\n }\n\n detailedDeclaration.pathToPlugin = pathToPlugin;\n }\n\n return detailedDeclaration;\n};\n\nexport const getEnabledPlugins = async (strapi: Core.Strapi, { client } = { client: false }) => {\n const internalPlugins: PluginMetas = {};\n\n for (const dep of INTERNAL_PLUGINS) {\n const packagePath = join(dep, 'package.json');\n\n // NOTE: internal plugins should be resolved from the strapi package\n const packageModulePath = require.resolve(packagePath, {\n paths: [require.resolve('@strapi/strapi/package.json'), process.cwd()],\n });\n\n const packageInfo = require(packageModulePath);\n\n validatePluginName(packageInfo.strapi.name);\n internalPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packageModulePath, isModule: client }),\n info: packageInfo.strapi,\n packageInfo,\n };\n }\n\n const installedPlugins: PluginMetas = {};\n const dependencies = strapi.config.get('info.dependencies', {});\n\n for (const dep of Object.keys(dependencies)) {\n const packagePath = join(dep, 'package.json');\n let packageInfo;\n try {\n packageInfo = require(packagePath);\n } catch {\n continue;\n }\n\n if (isStrapiPlugin(packageInfo)) {\n validatePluginName(packageInfo.strapi.name);\n installedPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: {\n ...packageInfo.strapi,\n packageName: packageInfo.name,\n },\n packageInfo,\n };\n }\n }\n\n const declaredPlugins: PluginMetas = {};\n const userPluginsConfig = await getUserPluginsConfig();\n\n _.forEach(userPluginsConfig, (declaration, pluginName) => {\n validatePluginName(pluginName);\n\n declaredPlugins[pluginName] = {\n ...toDetailedDeclaration(declaration),\n info: {},\n };\n\n const { pathToPlugin } = declaredPlugins[pluginName];\n\n // for manually resolved plugins\n if (pathToPlugin) {\n const packagePath = join(pathToPlugin, 'package.json');\n const packageInfo = require(packagePath);\n\n if (isStrapiPlugin(packageInfo)) {\n declaredPlugins[pluginName].info = packageInfo.strapi || {};\n declaredPlugins[pluginName].packageInfo = packageInfo;\n }\n }\n });\n\n const declaredPluginsResolves = map(prop('pathToPlugin'), declaredPlugins);\n const installedPluginsNotAlreadyUsed = pickBy(\n (p) => !declaredPluginsResolves.includes(p.pathToPlugin),\n installedPlugins\n );\n\n const enabledPlugins = pipe(\n defaultsDeep(declaredPlugins),\n defaultsDeep(installedPluginsNotAlreadyUsed),\n pickBy((p: PluginMeta) => p.enabled)\n )(internalPlugins);\n\n return enabledPlugins;\n};\n"],"names":["strapi"],"mappings":";;;;;;AAmCA,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,iBAAiB,CAAC,SAAqB,IAAI,eAAe,IAAI,MAAM;AAE1E,MAAM,qBAAqB,CAA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AAM,iBAAiB;AAAA,IACrB,aAAa,eAAe;AAAA,IAC5B,aAAa,8BAA8B;AAAA,IAC3C,OAAO,CAAC,MAAkB,EAAE,OAAO;AAAA,IACnC,eAAe;AAEV,SAAA;AACT;"}
1
+ {"version":3,"file":"get-enabled-plugins.mjs","sources":["../../../src/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport { strings } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface PluginMeta {\n enabled: boolean;\n pathToPlugin?: string;\n info: Record<string, unknown>;\n packageInfo?: Record<string, unknown>;\n}\n\ntype PluginMetas = Record<string, PluginMeta>;\n\ninterface PluginInfo {\n name: string;\n kind: string;\n}\n\ninterface PluginDeclaration {\n enabled: boolean;\n resolve: string;\n isModule: boolean;\n}\n\n/**\n * otherwise known as \"core features\"\n *\n * NOTE: These are excluded from the content manager plugin list, as they are always enabled.\n * See admin.ts server controller on the content-manager plugin for more details.\n */\nconst INTERNAL_PLUGINS = [\n '@strapi/content-manager',\n '@strapi/content-type-builder',\n '@strapi/email',\n '@strapi/upload',\n '@strapi/i18n',\n '@strapi/content-releases',\n '@strapi/review-workflows',\n];\n\nconst isStrapiPlugin = (info: PluginInfo) => get('strapi.kind', info) === 'plugin';\n\nconst validatePluginName = (pluginName: string) => {\n if (!strings.isKebabCase(pluginName)) {\n throw new Error(`Plugin name \"${pluginName}\" is not in kebab (an-example-of-kebab-case)`);\n }\n};\n\nconst toDetailedDeclaration = (declaration: boolean | PluginDeclaration) => {\n if (typeof declaration === 'boolean') {\n return { enabled: declaration };\n }\n\n const detailedDeclaration: { enabled: boolean; pathToPlugin?: string } = {\n enabled: declaration.enabled,\n };\n\n if (declaration?.resolve) {\n let pathToPlugin = '';\n\n if (declaration.isModule) {\n /**\n * we only want the node_module here, not the package.json\n */\n pathToPlugin = join(declaration.resolve, '..');\n } else {\n try {\n pathToPlugin = dirname(require.resolve(declaration.resolve));\n } catch (e) {\n pathToPlugin = resolve(strapi.dirs.app.root, declaration.resolve);\n\n if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {\n throw new Error(`${declaration.resolve} couldn't be resolved`);\n }\n }\n }\n\n detailedDeclaration.pathToPlugin = pathToPlugin;\n }\n\n return detailedDeclaration;\n};\n\nexport const getEnabledPlugins = async (strapi: Core.Strapi, { client } = { client: false }) => {\n const internalPlugins: PluginMetas = {};\n\n for (const dep of INTERNAL_PLUGINS) {\n const packagePath = join(dep, 'package.json');\n\n // NOTE: internal plugins should be resolved from the strapi package\n const packageModulePath = require.resolve(packagePath, {\n paths: [require.resolve('@strapi/strapi/package.json'), process.cwd()],\n });\n\n const packageInfo = require(packageModulePath);\n\n validatePluginName(packageInfo.strapi.name);\n internalPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packageModulePath, isModule: client }),\n info: packageInfo.strapi,\n packageInfo,\n };\n }\n\n const installedPlugins: PluginMetas = {};\n const dependencies = strapi.config.get('info.dependencies', {});\n\n for (const dep of Object.keys(dependencies)) {\n const packagePath = join(dep, 'package.json');\n let packageInfo;\n try {\n packageInfo = require(packagePath);\n } catch {\n continue;\n }\n\n if (isStrapiPlugin(packageInfo)) {\n validatePluginName(packageInfo.strapi.name);\n installedPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: {\n ...packageInfo.strapi,\n packageName: packageInfo.name,\n },\n packageInfo,\n };\n }\n }\n\n const declaredPlugins: PluginMetas = {};\n const userPluginsConfig = await getUserPluginsConfig();\n\n _.forEach(userPluginsConfig, (declaration, pluginName) => {\n validatePluginName(pluginName);\n\n declaredPlugins[pluginName] = {\n ...toDetailedDeclaration(declaration),\n info: {},\n };\n\n const { pathToPlugin } = declaredPlugins[pluginName];\n\n // for manually resolved plugins\n if (pathToPlugin) {\n const packagePath = join(pathToPlugin, 'package.json');\n const packageInfo = require(packagePath);\n\n if (isStrapiPlugin(packageInfo)) {\n declaredPlugins[pluginName].info = packageInfo.strapi || {};\n declaredPlugins[pluginName].packageInfo = packageInfo;\n }\n }\n });\n\n const declaredPluginsResolves = map(prop('pathToPlugin'), declaredPlugins);\n const installedPluginsNotAlreadyUsed = pickBy(\n (p) => !declaredPluginsResolves.includes(p.pathToPlugin),\n installedPlugins\n );\n\n const enabledPlugins = pipe(\n defaultsDeep(declaredPlugins),\n defaultsDeep(installedPluginsNotAlreadyUsed),\n pickBy((p: PluginMeta) => p.enabled)\n )(internalPlugins);\n\n return enabledPlugins;\n};\n"],"names":["strapi"],"mappings":";;;;;;AAmCA,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,iBAAiB,CAAC,SAAqB,IAAI,eAAe,IAAI,MAAM;AAE1E,MAAM,qBAAqB,CAAC,eAAuB;AACjD,MAAI,CAAC,QAAQ,YAAY,UAAU,GAAG;AACpC,UAAM,IAAI,MAAM,gBAAgB,UAAU,8CAA8C;AAAA,EAAA;AAE5F;AAEA,MAAM,wBAAwB,CAAC,gBAA6C;AACtE,MAAA,OAAO,gBAAgB,WAAW;AAC7B,WAAA,EAAE,SAAS,YAAY;AAAA,EAAA;AAGhC,QAAM,sBAAmE;AAAA,IACvE,SAAS,YAAY;AAAA,EACvB;AAEA,MAAI,aAAa,SAAS;AACxB,QAAI,eAAe;AAEnB,QAAI,YAAY,UAAU;AAIT,qBAAA,KAAK,YAAY,SAAS,IAAI;AAAA,IAAA,OACxC;AACD,UAAA;AACF,uBAAe,QAAQ,QAAQ,QAAQ,YAAY,OAAO,CAAC;AAAA,eACpD,GAAG;AACV,uBAAe,QAAQ,OAAO,KAAK,IAAI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Y;AAAA,QAC3B;AAAA,QACA;AAAA,MACF;AAAA,IAAA;AAAA,EACF;AAGF,QAAM,kBAA+B,CAAC;AAChC,QAAA,oBAAoB,MAAM,qBAAqB;AAErD,IAAE,QAAQ,mBAAmB,CAAC,aAAa,eAAe;AACxD,uBAAmB,UAAU;AAE7B,oBAAgB,UAAU,IAAI;AAAA,MAC5B,GAAG,sBAAsB,WAAW;AAAA,MACpC,MAAM,CAAA;AAAA,IACR;AAEA,UAAM,EAAE,aAAA,IAAiB,gBAAgB,UAAU;AAGnD,QAAI,cAAc;AACV,YAAA,cAAc,KAAK,cAAc,cAAc;AAC/C,YAAA,cAAc,QAAQ,WAAW;AAEnC,UAAA,eAAe,WAAW,GAAG;AAC/B,wBAAgB,UAAU,EAAE,OAAO,YAAY,UAAU,CAAC;AAC1C,wBAAA,UAAU,EAAE,cAAc;AAAA,MAAA;AAAA,IAC5C;AAAA,EACF,CACD;AAED,QAAM,0BAA0B,IAAI,KAAK,cAAc,GAAG,eAAe;AACzE,QAAM,iCAAiC;AAAA,IACrC,CAAC,MAAM,CAAC,wBAAwB,SAAS,EAAE,YAAY;AAAA,IACvD;AAAA,EACF;AAEA,QAAM,iBAAiB;AAAA,IACrB,aAAa,eAAe;AAAA,IAC5B,aAAa,8BAA8B;AAAA,IAC3C,OAAO,CAAC,MAAkB,EAAE,OAAO;AAAA,IACnC,eAAe;AAEV,SAAA;AACT;"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-user-plugins-config.js","sources":["../../../src/loaders/plugins/get-user-plugins-config.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { merge } from 'lodash/fp';\nimport { loadConfigFile } from '../../utils/load-config-file';\n\n/**\n * Return user defined plugins' config\n * first load config from `config/plugins.js`\n * and then merge config from `config/env/{env}/plugins.js`\n */\nexport const getUserPluginsConfig = async () => {\n const globalUserConfigPath = join(strapi.dirs.dist.config, 'plugins.js');\n const currentEnvUserConfigPath = join(\n strapi.dirs.dist.config,\n 'env',\n process.env.NODE_ENV as string,\n 'plugins.js'\n );\n let config = {};\n\n // assign global user config if exists\n if (await fse.pathExists(globalUserConfigPath)) {\n config = loadConfigFile(globalUserConfigPath);\n }\n\n // and merge user config by environment if exists\n if (await fse.pathExists(currentEnvUserConfigPath)) {\n config = merge(config, loadConfigFile(currentEnvUserConfigPath));\n }\n\n return config;\n};\n"],"names":["join","fse","loadConfigFile","merge"],"mappings":";;;;;;;;AAUO,MAAM,uBAAuB,YAAY;AAC9C,QAAM,uBAAuBA,KAAAA,KAAK,OAAO,KAAK,KAAK,QAAQ,YAAY;AACvE,QAAM,2BAA2BA,KAAA;AAAA,IAC/B,OAAO,KAAK,KAAK;AAAA,IACjB;AAAA,IACA,QAAQ,IAAI;AAAA,IACZ;AAAA,EAAA;AAEF,MAAI,SAAS,CAAA;AAGb,MAAI,MAAMC,aAAA,QAAI,WAAW,oBAAoB,GAAG;AAC9C,aAASC,eAAAA,eAAe,oBAAoB;AAAA,EAC9C;AAGA,MAAI,MAAMD,aAAA,QAAI,WAAW,wBAAwB,GAAG;AAClD,aAASE,GAAAA,MAAM,QAAQD,eAAAA,eAAe,wBAAwB,CAAC;AAAA,EACjE;AAEO,SAAA;AACT;;"}
1
+ {"version":3,"file":"get-user-plugins-config.js","sources":["../../../src/loaders/plugins/get-user-plugins-config.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { merge } from 'lodash/fp';\nimport { loadConfigFile } from '../../utils/load-config-file';\n\n/**\n * Return user defined plugins' config\n * first load config from `config/plugins.js`\n * and then merge config from `config/env/{env}/plugins.js`\n */\nexport const getUserPluginsConfig = async () => {\n const globalUserConfigPath = join(strapi.dirs.dist.config, 'plugins.js');\n const currentEnvUserConfigPath = join(\n strapi.dirs.dist.config,\n 'env',\n process.env.NODE_ENV as string,\n 'plugins.js'\n );\n let config = {};\n\n // assign global user config if exists\n if (await fse.pathExists(globalUserConfigPath)) {\n config = loadConfigFile(globalUserConfigPath);\n }\n\n // and merge user config by environment if exists\n if (await fse.pathExists(currentEnvUserConfigPath)) {\n config = merge(config, loadConfigFile(currentEnvUserConfigPath));\n }\n\n return config;\n};\n"],"names":["join","fse","loadConfigFile","merge"],"mappings":";;;;;;;;AAUO,MAAM,uBAAuB,YAAY;AAC9C,QAAM,uBAAuBA,KAAAA,KAAK,OAAO,KAAK,KAAK,QAAQ,YAAY;AACvE,QAAM,2BAA2BA,KAAA;AAAA,IAC/B,OAAO,KAAK,KAAK;AAAA,IACjB;AAAA,IACA,QAAQ,IAAI;AAAA,IACZ;AAAA,EACF;AACA,MAAI,SAAS,CAAC;AAGd,MAAI,MAAMC,aAAA,QAAI,WAAW,oBAAoB,GAAG;AAC9C,aAASC,8BAAe,oBAAoB;AAAA,EAAA;AAI9C,MAAI,MAAMD,aAAA,QAAI,WAAW,wBAAwB,GAAG;AAClD,aAASE,GAAAA,MAAM,QAAQD,eAAe,eAAA,wBAAwB,CAAC;AAAA,EAAA;AAG1D,SAAA;AACT;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-user-plugins-config.mjs","sources":["../../../src/loaders/plugins/get-user-plugins-config.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { merge } from 'lodash/fp';\nimport { loadConfigFile } from '../../utils/load-config-file';\n\n/**\n * Return user defined plugins' config\n * first load config from `config/plugins.js`\n * and then merge config from `config/env/{env}/plugins.js`\n */\nexport const getUserPluginsConfig = async () => {\n const globalUserConfigPath = join(strapi.dirs.dist.config, 'plugins.js');\n const currentEnvUserConfigPath = join(\n strapi.dirs.dist.config,\n 'env',\n process.env.NODE_ENV as string,\n 'plugins.js'\n );\n let config = {};\n\n // assign global user config if exists\n if (await fse.pathExists(globalUserConfigPath)) {\n config = loadConfigFile(globalUserConfigPath);\n }\n\n // and merge user config by environment if exists\n if (await fse.pathExists(currentEnvUserConfigPath)) {\n config = merge(config, loadConfigFile(currentEnvUserConfigPath));\n }\n\n return config;\n};\n"],"names":[],"mappings":";;;;AAUO,MAAM,uBAAuB,YAAY;AAC9C,QAAM,uBAAuB,KAAK,OAAO,KAAK,KAAK,QAAQ,YAAY;AACvE,QAAM,2BAA2B;AAAA,IAC/B,OAAO,KAAK,KAAK;AAAA,IACjB;AAAA,IACA,QAAQ,IAAI;AAAA,IACZ;AAAA,EAAA;AAEF,MAAI,SAAS,CAAA;AAGb,MAAI,MAAM,IAAI,WAAW,oBAAoB,GAAG;AAC9C,aAAS,eAAe,oBAAoB;AAAA,EAC9C;AAGA,MAAI,MAAM,IAAI,WAAW,wBAAwB,GAAG;AAClD,aAAS,MAAM,QAAQ,eAAe,wBAAwB,CAAC;AAAA,EACjE;AAEO,SAAA;AACT;"}
1
+ {"version":3,"file":"get-user-plugins-config.mjs","sources":["../../../src/loaders/plugins/get-user-plugins-config.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { merge } from 'lodash/fp';\nimport { loadConfigFile } from '../../utils/load-config-file';\n\n/**\n * Return user defined plugins' config\n * first load config from `config/plugins.js`\n * and then merge config from `config/env/{env}/plugins.js`\n */\nexport const getUserPluginsConfig = async () => {\n const globalUserConfigPath = join(strapi.dirs.dist.config, 'plugins.js');\n const currentEnvUserConfigPath = join(\n strapi.dirs.dist.config,\n 'env',\n process.env.NODE_ENV as string,\n 'plugins.js'\n );\n let config = {};\n\n // assign global user config if exists\n if (await fse.pathExists(globalUserConfigPath)) {\n config = loadConfigFile(globalUserConfigPath);\n }\n\n // and merge user config by environment if exists\n if (await fse.pathExists(currentEnvUserConfigPath)) {\n config = merge(config, loadConfigFile(currentEnvUserConfigPath));\n }\n\n return config;\n};\n"],"names":[],"mappings":";;;;AAUO,MAAM,uBAAuB,YAAY;AAC9C,QAAM,uBAAuB,KAAK,OAAO,KAAK,KAAK,QAAQ,YAAY;AACvE,QAAM,2BAA2B;AAAA,IAC/B,OAAO,KAAK,KAAK;AAAA,IACjB;AAAA,IACA,QAAQ,IAAI;AAAA,IACZ;AAAA,EACF;AACA,MAAI,SAAS,CAAC;AAGd,MAAI,MAAM,IAAI,WAAW,oBAAoB,GAAG;AAC9C,aAAS,eAAe,oBAAoB;AAAA,EAAA;AAI9C,MAAI,MAAM,IAAI,WAAW,wBAAwB,GAAG;AAClD,aAAS,MAAM,QAAQ,eAAe,wBAAwB,CAAC;AAAA,EAAA;AAG1D,SAAA;AACT;"}
@@ -11,8 +11,7 @@ const getUserPluginsConfig = require("./get-user-plugins-config.js");
11
11
  const index = require("../../domain/content-type/index.js");
12
12
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
13
13
  function _interopNamespace(e) {
14
- if (e && e.__esModule)
15
- return e;
14
+ if (e && e.__esModule) return e;
16
15
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
17
16
  if (e) {
18
17
  for (const k in e) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/loaders/plugins/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { defaultsDeep, defaults, getOr, get } from 'lodash/fp';\nimport * as resolve from 'resolve.exports';\n\nimport { env } from '@strapi/utils';\nimport type { Core, Plugin, Struct } from '@strapi/types';\nimport { loadConfigFile } from '../../utils/load-config-file';\nimport { loadFiles } from '../../utils/load-files';\nimport { getEnabledPlugins } from './get-enabled-plugins';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\nimport { getGlobalId } from '../../domain/content-type';\n\ninterface Plugins {\n [key: string]: Plugin.LoadedPlugin;\n}\n\nconst defaultPlugin = {\n bootstrap() {},\n destroy() {},\n register() {},\n config: {\n default: {},\n validator() {},\n },\n routes: [],\n controllers: {},\n services: {},\n policies: {},\n middlewares: {},\n contentTypes: {},\n};\n\nconst applyUserExtension = async (plugins: Plugins) => {\n const extensionsDir = strapi.dirs.dist.extensions;\n if (!(await fse.pathExists(extensionsDir))) {\n return;\n }\n\n const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');\n const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n // first: load json schema\n for (const ctName of Object.keys(plugin.contentTypes)) {\n const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);\n if (extendedSchema) {\n plugin.contentTypes[ctName].schema = {\n ...plugin.contentTypes[ctName].schema,\n ...extendedSchema,\n };\n }\n }\n // second: execute strapi-server extension\n const strapiServer = get([pluginName, 'strapi-server'], strapiServers);\n if (strapiServer) {\n plugins[pluginName] = await strapiServer(plugin);\n }\n }\n};\n\nconst applyUserConfig = async (plugins: Plugins) => {\n const userPluginsConfig = await getUserPluginsConfig();\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);\n const defaultConfig =\n typeof plugin.config.default === 'function'\n ? plugin.config.default({ env })\n : plugin.config.default;\n\n const config = defaultsDeep(defaultConfig, userPluginConfig);\n try {\n plugin.config.validator(config);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error regarding ${pluginName} config: ${e.message}`);\n }\n\n throw e;\n }\n plugin.config = config;\n }\n};\n\nexport default async function loadPlugins(strapi: Core.Strapi) {\n const plugins: Plugins = {};\n\n const enabledPlugins = await getEnabledPlugins(strapi);\n\n strapi.config.set('enabledPlugins', enabledPlugins);\n\n for (const pluginName of Object.keys(enabledPlugins)) {\n const enabledPlugin = enabledPlugins[pluginName];\n\n let serverEntrypointPath;\n let resolvedExport = './strapi-server.js';\n\n try {\n resolvedExport = (\n resolve.exports(enabledPlugin.packageInfo, 'strapi-server', {\n require: true,\n }) ?? './strapi-server.js'\n ).toString();\n } catch (e) {\n // no export map or missing strapi-server export => fallback to default\n }\n\n try {\n serverEntrypointPath = join(enabledPlugin.pathToPlugin, resolvedExport);\n } catch (e) {\n throw new Error(\n `Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove it's configuration.`\n );\n }\n\n // only load plugins with a server entrypoint\n if (!(await fse.pathExists(serverEntrypointPath))) {\n continue;\n }\n\n const pluginServer = loadConfigFile(serverEntrypointPath);\n plugins[pluginName] = {\n ...defaultPlugin,\n ...pluginServer,\n contentTypes: formatContentTypes(pluginName, pluginServer.contentTypes ?? {}),\n config: defaults(defaultPlugin.config, pluginServer.config),\n routes: pluginServer.routes ?? defaultPlugin.routes,\n };\n }\n\n // TODO: validate plugin format\n await applyUserConfig(plugins);\n await applyUserExtension(plugins);\n\n for (const pluginName of Object.keys(plugins)) {\n strapi.get('plugins').add(pluginName, plugins[pluginName]);\n }\n}\n\nconst formatContentTypes = (\n pluginName: string,\n contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>\n) => {\n Object.values(contentTypes).forEach((definition) => {\n const { schema } = definition;\n\n Object.assign(schema, {\n plugin: pluginName,\n collectionName:\n schema.collectionName || `${pluginName}_${schema.info.singularName}`.toLowerCase(),\n globalId: getGlobalId(schema, pluginName),\n });\n });\n\n return contentTypes;\n};\n"],"names":["fse","loadFiles","get","getUserPluginsConfig","getOr","env","defaultsDeep","strapi","getEnabledPlugins","resolve","join","loadConfigFile","defaults","getGlobalId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAM,gBAAgB;AAAA,EACpB,YAAY;AAAA,EAAC;AAAA,EACb,UAAU;AAAA,EAAC;AAAA,EACX,WAAW;AAAA,EAAC;AAAA,EACZ,QAAQ;AAAA,IACN,SAAS,CAAC;AAAA,IACV,YAAY;AAAA,IAAC;AAAA,EACf;AAAA,EACA,QAAQ,CAAC;AAAA,EACT,aAAa,CAAC;AAAA,EACd,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,aAAa,CAAC;AAAA,EACd,cAAc,CAAC;AACjB;AAEA,MAAM,qBAAqB,OAAO,YAAqB;AAC/C,QAAA,gBAAgB,OAAO,KAAK,KAAK;AACvC,MAAI,CAAE,MAAMA,aAAAA,QAAI,WAAW,aAAa,GAAI;AAC1C;AAAA,EACF;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BAAkB,GAAG,UAAU,IAAI,OAAO,KAAK,YAAY,GAAG,YAAY;AAAA,MACnF,UAAUM,MAAAA,YAAY,QAAQ,UAAU;AAAA,IAAA,CACzC;AAAA,EAAA,CACF;AAEM,SAAA;AACT;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/loaders/plugins/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { defaultsDeep, defaults, getOr, get } from 'lodash/fp';\nimport * as resolve from 'resolve.exports';\n\nimport { env } from '@strapi/utils';\nimport type { Core, Plugin, Struct } from '@strapi/types';\nimport { loadConfigFile } from '../../utils/load-config-file';\nimport { loadFiles } from '../../utils/load-files';\nimport { getEnabledPlugins } from './get-enabled-plugins';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\nimport { getGlobalId } from '../../domain/content-type';\n\ninterface Plugins {\n [key: string]: Plugin.LoadedPlugin;\n}\n\nconst defaultPlugin = {\n bootstrap() {},\n destroy() {},\n register() {},\n config: {\n default: {},\n validator() {},\n },\n routes: [],\n controllers: {},\n services: {},\n policies: {},\n middlewares: {},\n contentTypes: {},\n};\n\nconst applyUserExtension = async (plugins: Plugins) => {\n const extensionsDir = strapi.dirs.dist.extensions;\n if (!(await fse.pathExists(extensionsDir))) {\n return;\n }\n\n const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');\n const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n // first: load json schema\n for (const ctName of Object.keys(plugin.contentTypes)) {\n const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);\n if (extendedSchema) {\n plugin.contentTypes[ctName].schema = {\n ...plugin.contentTypes[ctName].schema,\n ...extendedSchema,\n };\n }\n }\n // second: execute strapi-server extension\n const strapiServer = get([pluginName, 'strapi-server'], strapiServers);\n if (strapiServer) {\n plugins[pluginName] = await strapiServer(plugin);\n }\n }\n};\n\nconst applyUserConfig = async (plugins: Plugins) => {\n const userPluginsConfig = await getUserPluginsConfig();\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);\n const defaultConfig =\n typeof plugin.config.default === 'function'\n ? plugin.config.default({ env })\n : plugin.config.default;\n\n const config = defaultsDeep(defaultConfig, userPluginConfig);\n try {\n plugin.config.validator(config);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error regarding ${pluginName} config: ${e.message}`);\n }\n\n throw e;\n }\n plugin.config = config;\n }\n};\n\nexport default async function loadPlugins(strapi: Core.Strapi) {\n const plugins: Plugins = {};\n\n const enabledPlugins = await getEnabledPlugins(strapi);\n\n strapi.config.set('enabledPlugins', enabledPlugins);\n\n for (const pluginName of Object.keys(enabledPlugins)) {\n const enabledPlugin = enabledPlugins[pluginName];\n\n let serverEntrypointPath;\n let resolvedExport = './strapi-server.js';\n\n try {\n resolvedExport = (\n resolve.exports(enabledPlugin.packageInfo, 'strapi-server', {\n require: true,\n }) ?? './strapi-server.js'\n ).toString();\n } catch (e) {\n // no export map or missing strapi-server export => fallback to default\n }\n\n try {\n serverEntrypointPath = join(enabledPlugin.pathToPlugin, resolvedExport);\n } catch (e) {\n throw new Error(\n `Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove it's configuration.`\n );\n }\n\n // only load plugins with a server entrypoint\n if (!(await fse.pathExists(serverEntrypointPath))) {\n continue;\n }\n\n const pluginServer = loadConfigFile(serverEntrypointPath);\n plugins[pluginName] = {\n ...defaultPlugin,\n ...pluginServer,\n contentTypes: formatContentTypes(pluginName, pluginServer.contentTypes ?? {}),\n config: defaults(defaultPlugin.config, pluginServer.config),\n routes: pluginServer.routes ?? defaultPlugin.routes,\n };\n }\n\n // TODO: validate plugin format\n await applyUserConfig(plugins);\n await applyUserExtension(plugins);\n\n for (const pluginName of Object.keys(plugins)) {\n strapi.get('plugins').add(pluginName, plugins[pluginName]);\n }\n}\n\nconst formatContentTypes = (\n pluginName: string,\n contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>\n) => {\n Object.values(contentTypes).forEach((definition) => {\n const { schema } = definition;\n\n Object.assign(schema, {\n plugin: pluginName,\n collectionName:\n schema.collectionName || `${pluginName}_${schema.info.singularName}`.toLowerCase(),\n globalId: getGlobalId(schema, pluginName),\n });\n });\n\n return contentTypes;\n};\n"],"names":["fse","loadFiles","get","getUserPluginsConfig","getOr","env","defaultsDeep","strapi","getEnabledPlugins","resolve","join","loadConfigFile","defaults","getGlobalId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAM,gBAAgB;AAAA,EACpB,YAAY;AAAA,EAAC;AAAA,EACb,UAAU;AAAA,EAAC;AAAA,EACX,WAAW;AAAA,EAAC;AAAA,EACZ,QAAQ;AAAA,IACN,SAAS,CAAC;AAAA,IACV,YAAY;AAAA,IAAA;AAAA,EACd;AAAA,EACA,QAAQ,CAAC;AAAA,EACT,aAAa,CAAC;AAAA,EACd,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,aAAa,CAAC;AAAA,EACd,cAAc,CAAA;AAChB;AAEA,MAAM,qBAAqB,OAAO,YAAqB;AAC/C,QAAA,gBAAgB,OAAO,KAAK,KAAK;AACvC,MAAI,CAAE,MAAMA,aAAAA,QAAI,WAAW,aAAa,GAAI;AAC1C;AAAA,EAAA;AAGF,QAAM,kBAAkB,MAAMC,oBAAU,eAAe,iCAAiC;AACxF,QAAM,gBAAgB,MAAMA,oBAAU,eAAe,qBAAqB;AAE1E,aAAW,cAAc,OAAO,KAAK,OAAO,GAAG;AACvC,UAAA,SAAS,QAAQ,UAAU;AAEjC,eAAW,UAAU,OAAO,KAAK,OAAO,YAAY,GAAG;AAC/C,YAAA,iBAAiBC,OAAI,CAAC,YAAY,iBAAiB,QAAQ,QAAQ,GAAG,eAAe;AAC3F,UAAI,gBAAgB;AACX,eAAA,aAAa,MAAM,EAAE,SAA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GAAG;AAAA,IAAA;AAIR,QAAA;AACqB,6BAAAC,KAAA,KAAK,cAAc,cAAc,cAAc;AAAA,aAC/D,GAAG;AACV,YAAM,IAAI;AAAA,QACR,4BAA4B,UAAU,YAAY,UAAU;AAAA,MAC9D;AAAA,IAAA;AAIF,QAAI,CAAE,MAAMV,aAAAA,QAAI,WAAW,oBAAoB,GAAI;AACjD;AAAA,IAAA;AAGI,UAAA,eAAeW,8BAAe,oBAAoB;AACxD,YAAQ,UAAU,IAAI;AAAA,MACpB,GAAG;AAAA,MACH,GAAG;AAAA,MACH,cAAc,mBAAmB,YAAY,aAAa,gBAAgB,CAAA,CAAE;AAAA,MAC5E,QAAQC,GAAAA,SAAS,cAAc,QAAQ,aAAa,MAAM;AAAA,MAC1D,QAAQ,aAAa,UAAU,cAAc;AAAA,IAC/C;AAAA,EAAA;AAIF,QAAM,gBAAgB,OAAO;AAC7B,QAAM,mBAAmB,OAAO;AAEhC,aAAW,cAAc,OAAO,KAAK,OAAO,GAAG;AAC7CL,YAAO,IAAI,SAAS,EAAE,IAAI,YAAY,QAAQ,UAAU,CAAC;AAAA,EAAA;AAE7D;AAEA,MAAM,qBAAqB,CACzB,YACA,iBACG;AACH,SAAO,OAAO,YAAY,EAAE,QAAQ,CAAC,eAAe;AAC5C,UAAA,EAAE,WAAW;AAEnB,WAAO,OAAO,QAAQ;AAAA,MACpB,QAAQ;AAAA,MACR,gBACE,OAAO,kBAAkB,GAAG,UAAU,IAAI,OAAO,KAAK,YAAY,GAAG,YAAY;AAAA,MACnF,UAAUM,MAAAA,YAAY,QAAQ,UAAU;AAAA,IAAA,CACzC;AAAA,EAAA,CACF;AAEM,SAAA;AACT;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../src/loaders/plugins/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { defaultsDeep, defaults, getOr, get } from 'lodash/fp';\nimport * as resolve from 'resolve.exports';\n\nimport { env } from '@strapi/utils';\nimport type { Core, Plugin, Struct } from '@strapi/types';\nimport { loadConfigFile } from '../../utils/load-config-file';\nimport { loadFiles } from '../../utils/load-files';\nimport { getEnabledPlugins } from './get-enabled-plugins';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\nimport { getGlobalId } from '../../domain/content-type';\n\ninterface Plugins {\n [key: string]: Plugin.LoadedPlugin;\n}\n\nconst defaultPlugin = {\n bootstrap() {},\n destroy() {},\n register() {},\n config: {\n default: {},\n validator() {},\n },\n routes: [],\n controllers: {},\n services: {},\n policies: {},\n middlewares: {},\n contentTypes: {},\n};\n\nconst applyUserExtension = async (plugins: Plugins) => {\n const extensionsDir = strapi.dirs.dist.extensions;\n if (!(await fse.pathExists(extensionsDir))) {\n return;\n }\n\n const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');\n const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n // first: load json schema\n for (const ctName of Object.keys(plugin.contentTypes)) {\n const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);\n if (extendedSchema) {\n plugin.contentTypes[ctName].schema = {\n ...plugin.contentTypes[ctName].schema,\n ...extendedSchema,\n };\n }\n }\n // second: execute strapi-server extension\n const strapiServer = get([pluginName, 'strapi-server'], strapiServers);\n if (strapiServer) {\n plugins[pluginName] = await strapiServer(plugin);\n }\n }\n};\n\nconst applyUserConfig = async (plugins: Plugins) => {\n const userPluginsConfig = await getUserPluginsConfig();\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);\n const defaultConfig =\n typeof plugin.config.default === 'function'\n ? plugin.config.default({ env })\n : plugin.config.default;\n\n const config = defaultsDeep(defaultConfig, userPluginConfig);\n try {\n plugin.config.validator(config);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error regarding ${pluginName} config: ${e.message}`);\n }\n\n throw e;\n }\n plugin.config = config;\n }\n};\n\nexport default async function loadPlugins(strapi: Core.Strapi) {\n const plugins: Plugins = {};\n\n const enabledPlugins = await getEnabledPlugins(strapi);\n\n strapi.config.set('enabledPlugins', enabledPlugins);\n\n for (const pluginName of Object.keys(enabledPlugins)) {\n const enabledPlugin = enabledPlugins[pluginName];\n\n let serverEntrypointPath;\n let resolvedExport = './strapi-server.js';\n\n try {\n resolvedExport = (\n resolve.exports(enabledPlugin.packageInfo, 'strapi-server', {\n require: true,\n }) ?? './strapi-server.js'\n ).toString();\n } catch (e) {\n // no export map or missing strapi-server export => fallback to default\n }\n\n try {\n serverEntrypointPath = join(enabledPlugin.pathToPlugin, resolvedExport);\n } catch (e) {\n throw new Error(\n `Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove it's configuration.`\n );\n }\n\n // only load plugins with a server entrypoint\n if (!(await fse.pathExists(serverEntrypointPath))) {\n continue;\n }\n\n const pluginServer = loadConfigFile(serverEntrypointPath);\n plugins[pluginName] = {\n ...defaultPlugin,\n ...pluginServer,\n contentTypes: formatContentTypes(pluginName, pluginServer.contentTypes ?? {}),\n config: defaults(defaultPlugin.config, pluginServer.config),\n routes: pluginServer.routes ?? defaultPlugin.routes,\n };\n }\n\n // TODO: validate plugin format\n await applyUserConfig(plugins);\n await applyUserExtension(plugins);\n\n for (const pluginName of Object.keys(plugins)) {\n strapi.get('plugins').add(pluginName, plugins[pluginName]);\n }\n}\n\nconst formatContentTypes = (\n pluginName: string,\n contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>\n) => {\n Object.values(contentTypes).forEach((definition) => {\n const { schema } = definition;\n\n Object.assign(schema, {\n plugin: pluginName,\n collectionName:\n schema.collectionName || `${pluginName}_${schema.info.singularName}`.toLowerCase(),\n globalId: getGlobalId(schema, pluginName),\n });\n });\n\n return contentTypes;\n};\n"],"names":["strapi"],"mappings":";;;;;;;;;;AAiBA,MAAM,gBAAgB;AAAA,EACpB,YAAY;AAAA,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,QAAM,mBAAmB,OAAO;AAEhC,aAAW,cAAc,OAAO,KAAK,OAAO,GAAG;AAC7CA,YAAO,IAAI,SAAS,EAAE,IAAI,YAAY,QAAQ,UAAU,CAAC;AAAA,EAC3D;AACF;AAEA,MAAM,qBAAqB,CACzB,YACA,iBACG;AACH,SAAO,OAAO,YAAY,EAAE,QAAQ,CAAC,eAAe;AAC5C,UAAA,EAAE,OAAW,IAAA;AAEnB,WAAO,OAAO,QAAQ;AAAA,MACpB,QAAQ;AAAA,MACR,gBACE,OAAO,kBAAkB,GAAG,UAAU,IAAI,OAAO,KAAK,YAAY,GAAG,YAAY;AAAA,MACnF,UAAU,YAAY,QAAQ,UAAU;AAAA,IAAA,CACzC;AAAA,EAAA,CACF;AAEM,SAAA;AACT;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../src/loaders/plugins/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { defaultsDeep, defaults, getOr, get } from 'lodash/fp';\nimport * as resolve from 'resolve.exports';\n\nimport { env } from '@strapi/utils';\nimport type { Core, Plugin, Struct } from '@strapi/types';\nimport { loadConfigFile } from '../../utils/load-config-file';\nimport { loadFiles } from '../../utils/load-files';\nimport { getEnabledPlugins } from './get-enabled-plugins';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\nimport { getGlobalId } from '../../domain/content-type';\n\ninterface Plugins {\n [key: string]: Plugin.LoadedPlugin;\n}\n\nconst defaultPlugin = {\n bootstrap() {},\n destroy() {},\n register() {},\n config: {\n default: {},\n validator() {},\n },\n routes: [],\n controllers: {},\n services: {},\n policies: {},\n middlewares: {},\n contentTypes: {},\n};\n\nconst applyUserExtension = async (plugins: Plugins) => {\n const extensionsDir = strapi.dirs.dist.extensions;\n if (!(await fse.pathExists(extensionsDir))) {\n return;\n }\n\n const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');\n const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n // first: load json schema\n for (const ctName of Object.keys(plugin.contentTypes)) {\n const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);\n if (extendedSchema) {\n plugin.contentTypes[ctName].schema = {\n ...plugin.contentTypes[ctName].schema,\n ...extendedSchema,\n };\n }\n }\n // second: execute strapi-server extension\n const strapiServer = get([pluginName, 'strapi-server'], strapiServers);\n if (strapiServer) {\n plugins[pluginName] = await strapiServer(plugin);\n }\n }\n};\n\nconst applyUserConfig = async (plugins: Plugins) => {\n const userPluginsConfig = await getUserPluginsConfig();\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);\n const defaultConfig =\n typeof plugin.config.default === 'function'\n ? plugin.config.default({ env })\n : plugin.config.default;\n\n const config = defaultsDeep(defaultConfig, userPluginConfig);\n try {\n plugin.config.validator(config);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error regarding ${pluginName} config: ${e.message}`);\n }\n\n throw e;\n }\n plugin.config = config;\n }\n};\n\nexport default async function loadPlugins(strapi: Core.Strapi) {\n const plugins: Plugins = {};\n\n const enabledPlugins = await getEnabledPlugins(strapi);\n\n strapi.config.set('enabledPlugins', enabledPlugins);\n\n for (const pluginName of Object.keys(enabledPlugins)) {\n const enabledPlugin = enabledPlugins[pluginName];\n\n let serverEntrypointPath;\n let resolvedExport = './strapi-server.js';\n\n try {\n resolvedExport = (\n resolve.exports(enabledPlugin.packageInfo, 'strapi-server', {\n require: true,\n }) ?? './strapi-server.js'\n ).toString();\n } catch (e) {\n // no export map or missing strapi-server export => fallback to default\n }\n\n try {\n serverEntrypointPath = join(enabledPlugin.pathToPlugin, resolvedExport);\n } catch (e) {\n throw new Error(\n `Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove it's configuration.`\n );\n }\n\n // only load plugins with a server entrypoint\n if (!(await fse.pathExists(serverEntrypointPath))) {\n continue;\n }\n\n const pluginServer = loadConfigFile(serverEntrypointPath);\n plugins[pluginName] = {\n ...defaultPlugin,\n ...pluginServer,\n contentTypes: formatContentTypes(pluginName, pluginServer.contentTypes ?? {}),\n config: defaults(defaultPlugin.config, pluginServer.config),\n routes: pluginServer.routes ?? defaultPlugin.routes,\n };\n }\n\n // TODO: validate plugin format\n await applyUserConfig(plugins);\n await applyUserExtension(plugins);\n\n for (const pluginName of Object.keys(plugins)) {\n strapi.get('plugins').add(pluginName, plugins[pluginName]);\n }\n}\n\nconst formatContentTypes = (\n pluginName: string,\n contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>\n) => {\n Object.values(contentTypes).forEach((definition) => {\n const { schema } = definition;\n\n Object.assign(schema, {\n plugin: pluginName,\n collectionName:\n schema.collectionName || `${pluginName}_${schema.info.singularName}`.toLowerCase(),\n globalId: getGlobalId(schema, pluginName),\n });\n });\n\n return contentTypes;\n};\n"],"names":["strapi"],"mappings":";;;;;;;;;;AAiBA,MAAM,gBAAgB;AAAA,EACpB,YAAY;AAAA,EAAC;AAAA,EACb,UAAU;AAAA,EAAC;AAAA,EACX,WAAW;AAAA,EAAC;AAAA,EACZ,QAAQ;AAAA,IACN,SAAS,CAAC;AAAA,IACV,YAAY;AAAA,IAAA;AAAA,EACd;AAAA,EACA,QAAQ,CAAC;AAAA,EACT,aAAa,CAAC;AAAA,EACd,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,aAAa,CAAC;AAAA,EACd,cAAc,CAAA;AAChB;AAEA,MAAM,qBAAqB,OAAO,YAAqB;AAC/C,QAAA,gBAAgB,OAAO,KAAK,KAAK;AACvC,MAAI,CAAE,MAAM,IAAI,WAAW,aAAa,GAAI;AAC1C;AAAA,EAAA;AAGF,QAAM,kBAAkB,MAAM,UAAU,eAAe,iCAAiC;AACxF,QAAM,gBAAgB,MAAM,UAAU,eAAe,qBAAqB;AAE1E,aAAW,cAAc,OAAO,KAAK,OAAO,GAAG;AACvC,UA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{ join, extname, basename } from 'path';\nimport fse from 'fs-extra';\nimport { importDefault } from '@strapi/utils';\n\nimport type { Core } from '@strapi/types';\n\n// TODO:: allow folders with index.js inside for bigger policies\nexport default async function loadPolicies(strapi: Core.Strapi) {\n const dir = strapi.dirs.dist.policies;\n\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const policies: Record<string, Core.Policy> = {};\n const paths = await fse.readdir(dir, { withFileTypes: true });\n\n for (const fd of paths) {\n const { name } = fd;\n const fullPath = join(dir, name);\n\n if (fd.isFile() && extname(name) === '.js') {\n const key = basename(name, '.js');\n policies[key] = importDefault(fullPath);\n }\n }\n\n strapi.get('policies').add(`global::`, policies);\n}\n"],"names":["fse","join","extname","basename","importDefault"],"mappings":";;;;;;AAOA,eAA8B,aAAa,QAAqB;AACxD,QAAA,MAAM,OAAO,KAAK,KAAK;AAE7B,MAAI,CAAE,MAAMA,aAAAA,QAAI,WAAW,GAAG,GAAI;AAChC;AAAA,EACF;AAEA,QAAM,WAAwC,CAAA;AACxC,QAAA,QAAQ,MAAMA,aAAAA,QAAI,QAAQ,KAAK,EAAE,eAAe,MAAM;AAE5D,aAAW,MAAM,OAAO;AAChB,UAAA,EAAE,KAAS,IAAA;AACX,UAAA,WAAWC,KAAAA,KAAK,KAAK,IAAI;AAE/B,QAAI,GAAG,OAAO,KAAKC,KAAQ,QAAA,IAAI,MAAM,OAAO;AACpC,YAAA,MAAMC,KAAAA,SAAS,MAAM,KAAK;AACvB,eAAA,GAAG,IAAIC,YAAA,cAAc,QAAQ;AAAA,IACxC;AAAA,EACF;AAEA,SAAO,IAAI,UAAU,EAAE,IAAI,YAAY,QAAQ;AACjD;;"}
1
+ {"version":3,"file":"policies.js","sources":["../../src/loaders/policies.ts"],"sourcesContent":["import { join, extname, basename } from 'path';\nimport fse from 'fs-extra';\nimport { importDefault } from '@strapi/utils';\n\nimport type { Core } from '@strapi/types';\n\n// TODO:: allow folders with index.js inside for bigger policies\nexport default async function loadPolicies(strapi: Core.Strapi) {\n const dir = strapi.dirs.dist.policies;\n\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const policies: Record<string, Core.Policy> = {};\n const paths = await fse.readdir(dir, { withFileTypes: true });\n\n for (const fd of paths) {\n const { name } = fd;\n const fullPath = join(dir, name);\n\n if (fd.isFile() && extname(name) === '.js') {\n const key = basename(name, '.js');\n policies[key] = importDefault(fullPath);\n }\n }\n\n strapi.get('policies').add(`global::`, policies);\n}\n"],"names":["fse","join","extname","basename","importDefault"],"mappings":";;;;;;AAOA,eAA8B,aAAa,QAAqB;AACxD,QAAA,MAAM,OAAO,KAAK,KAAK;AAE7B,MAAI,CAAE,MAAMA,aAAAA,QAAI,WAAW,GAAG,GAAI;AAChC;AAAA,EAAA;AAGF,QAAM,WAAwC,CAAC;AACzC,QAAA,QAAQ,MAAMA,qBAAI,QAAQ,KAAK,EAAE,eAAe,MAAM;AAE5D,aAAW,MAAM,OAAO;AAChB,UAAA,EAAE,SAAS;AACX,UAAA,WAAWC,KAAAA,KAAK,KAAK,IAAI;AAE/B,QAAI,GAAG,OAAO,KAAKC,KAAQ,QAAA,IAAI,MAAM,OAAO;AACpC,YAAA,MAAMC,KAAAA,SAAS,MAAM,KAAK;AACvB,eAAA,GAAG,IAAIC,YAAA,cAAc,QAAQ;AAAA,IAAA;AAAA,EACxC;AAGF,SAAO,IAAI,UAAU,EAAE,IAAI,YAAY,QAAQ;AACjD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"policies.mjs","sources":["../../src/loaders/policies.ts"],"sourcesContent":["import { join, extname, basename } from 'path';\nimport fse from 'fs-extra';\nimport { importDefault } from '@strapi/utils';\n\nimport type { Core } from '@strapi/types';\n\n// TODO:: allow folders with index.js inside for bigger policies\nexport default async function loadPolicies(strapi: Core.Strapi) {\n const dir = strapi.dirs.dist.policies;\n\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const policies: Record<string, Core.Policy> = {};\n const paths = await fse.readdir(dir, { withFileTypes: true });\n\n for (const fd of paths) {\n const { name } = fd;\n const fullPath = join(dir, name);\n\n if (fd.isFile() && extname(name) === '.js') {\n const key = basename(name, '.js');\n policies[key] = importDefault(fullPath);\n }\n }\n\n strapi.get('policies').add(`global::`, policies);\n}\n"],"names":[],"mappings":";;;AAOA,eAA8B,aAAa,QAAqB;AACxD,QAAA,MAAM,OAAO,KAAK,KAAK;AAE7B,MAAI,CAAE,MAAM,IAAI,WAAW,GAAG,GAAI;AAChC;AAAA,EACF;AAEA,QAAM,WAAwC,CAAA;AACxC,QAAA,QAAQ,MAAM,IAAI,QAAQ,KAAK,EAAE,eAAe,MAAM;AAE5D,aAAW,MAAM,OAAO;AAChB,UAAA,EAAE,KAAS,IAAA;AACX,UAAA,WAAW,KAAK,KAAK,IAAI;AAE/B,QAAI,GAAG,OAAO,KAAK,QAAQ,IAAI,MAAM,OAAO;AACpC,YAAA,MAAM,SAAS,MAAM,KAAK;AACvB,eAAA,GAAG,IAAI,cAAc,QAAQ;AAAA,IACxC;AAAA,EACF;AAEA,SAAO,IAAI,UAAU,EAAE,IAAI,YAAY,QAAQ;AACjD;"}
1
+ {"version":3,"file":"policies.mjs","sources":["../../src/loaders/policies.ts"],"sourcesContent":["import { join, extname, basename } from 'path';\nimport fse from 'fs-extra';\nimport { importDefault } from '@strapi/utils';\n\nimport type { Core } from '@strapi/types';\n\n// TODO:: allow folders with index.js inside for bigger policies\nexport default async function loadPolicies(strapi: Core.Strapi) {\n const dir = strapi.dirs.dist.policies;\n\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const policies: Record<string, Core.Policy> = {};\n const paths = await fse.readdir(dir, { withFileTypes: true });\n\n for (const fd of paths) {\n const { name } = fd;\n const fullPath = join(dir, name);\n\n if (fd.isFile() && extname(name) === '.js') {\n const key = basename(name, '.js');\n policies[key] = importDefault(fullPath);\n }\n }\n\n strapi.get('policies').add(`global::`, policies);\n}\n"],"names":[],"mappings":";;;AAOA,eAA8B,aAAa,QAAqB;AACxD,QAAA,MAAM,OAAO,KAAK,KAAK;AAE7B,MAAI,CAAE,MAAM,IAAI,WAAW,GAAG,GAAI;AAChC;AAAA,EAAA;AAGF,QAAM,WAAwC,CAAC;AACzC,QAAA,QAAQ,MAAM,IAAI,QAAQ,KAAK,EAAE,eAAe,MAAM;AAE5D,aAAW,MAAM,OAAO;AAChB,UAAA,EAAE,SAAS;AACX,UAAA,WAAW,KAAK,KAAK,IAAI;AAE/B,QAAI,GAAG,OAAO,KAAK,QAAQ,IAAI,MAAM,OAAO;AACpC,YAAA,MAAM,SAAS,MAAM,KAAK;AACvB,eAAA,GAAG,IAAI,cAAc,QAAQ;AAAA,IAAA;AAAA,EACxC;AAGF,SAAO,IAAI,UAAU,EAAE,IAAI,YAAY,QAAQ;AACjD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizers.js","sources":["../../src/loaders/sanitizers.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nexport default (strapi: Core.Strapi) => {\n strapi.get('sanitizers').set('content-api', { input: [], output: [], query: [] });\n};\n"],"names":[],"mappings":";AAEA,MAAe,iBAAA,CAAC,WAAwB;AACtC,SAAO,IAAI,YAAY,EAAE,IAAI,eAAe,EAAE,OAAO,CAAA,GAAI,QAAQ,CAAA,GAAI,OAAO,CAAA,EAAI,CAAA;AAClF;;"}
1
+ {"version":3,"file":"sanitizers.js","sources":["../../src/loaders/sanitizers.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nexport default (strapi: Core.Strapi) => {\n strapi.get('sanitizers').set('content-api', { input: [], output: [], query: [] });\n};\n"],"names":[],"mappings":";AAEA,MAAe,iBAAA,CAAC,WAAwB;AACtC,SAAO,IAAI,YAAY,EAAE,IAAI,eAAe,EAAE,OAAO,CAAA,GAAI,QAAQ,CAAA,GAAI,OAAO,IAAI;AAClF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizers.mjs","sources":["../../src/loaders/sanitizers.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nexport default (strapi: Core.Strapi) => {\n strapi.get('sanitizers').set('content-api', { input: [], output: [], query: [] });\n};\n"],"names":[],"mappings":"AAEA,MAAe,iBAAA,CAAC,WAAwB;AACtC,SAAO,IAAI,YAAY,EAAE,IAAI,eAAe,EAAE,OAAO,CAAA,GAAI,QAAQ,CAAA,GAAI,OAAO,CAAA,EAAI,CAAA;AAClF;"}
1
+ {"version":3,"file":"sanitizers.mjs","sources":["../../src/loaders/sanitizers.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nexport default (strapi: Core.Strapi) => {\n strapi.get('sanitizers').set('content-api', { input: [], output: [], query: [] });\n};\n"],"names":[],"mappings":"AAEA,MAAe,iBAAA,CAAC,WAAwB;AACtC,SAAO,IAAI,YAAY,EAAE,IAAI,eAAe,EAAE,OAAO,CAAA,GAAI,QAAQ,CAAA,GAAI,OAAO,IAAI;AAClF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"src-index.js","sources":["../../src/loaders/src-index.ts"],"sourcesContent":["import { resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport { yup, importDefault } from '@strapi/utils';\n\nimport type { Core } from '@strapi/types';\n\nconst srcSchema = yup\n .object()\n .shape({\n bootstrap: yup.mixed().isFunction(),\n register: yup.mixed().isFunction(),\n destroy: yup.mixed().isFunction(),\n })\n .noUnknown();\n\nconst validateSrcIndex = (srcIndex: unknown) => {\n return srcSchema.validateSync(srcIndex, { strict: true, abortEarly: false });\n};\n\nexport default (strapi: Core.Strapi) => {\n if (!existsSync(strapi.dirs.dist.src)) {\n return;\n }\n\n const pathToSrcIndex = resolve(strapi.dirs.dist.src, 'index.js');\n if (!existsSync(pathToSrcIndex) || statSync(pathToSrcIndex).isDirectory()) {\n return {};\n }\n\n const srcIndex = importDefault(pathToSrcIndex);\n\n try {\n validateSrcIndex(srcIndex);\n } catch (e) {\n if (e instanceof yup.ValidationError) {\n strapi.stopWithError({ message: `Invalid file \\`./src/index.js\\`: ${e.message}` });\n }\n\n throw e;\n }\n\n strapi.app = srcIndex;\n};\n"],"names":["yup","existsSync","resolve","statSync","importDefault"],"mappings":";;;;AAMA,MAAM,YAAYA,YAAA,IACf,OAAO,EACP,MAAM;AAAA,EACL,WAAWA,YAAA,IAAI,MAAM,EAAE,WAAW;AAAA,EAClC,UAAUA,YAAA,IAAI,MAAM,EAAE,WAAW;AAAA,EACjC,SAASA,YAAA,IAAI,MAAM,EAAE,WAAW;AAClC,CAAC,EACA,UAAU;AAEb,MAAM,mBAAmB,CAAC,aAAsB;AACvC,SAAA,UAAU,aAAa,UAAU,EAAE,QAAQ,MAAM,YAAY,OAAO;AAC7E;AAEA,MAAe,eAAA,CAAC,WAAwB;AACtC,MAAI,CAACC,GAAW,WAAA,OAAO,KAAK,KAAK,GAAG,GAAG;AACrC;AAAA,EACF;AAEA,QAAM,iBAAiBC,KAAAA,QAAQ,OAAO,KAAK,KAAK,KAAK,UAAU;AAC3D,MAAA,CAACD,cAAW,cAAc,KAAKE,YAAS,cAAc,EAAE,eAAe;AACzE,WAAO;EACT;AAEM,QAAA,WAAWC,0BAAc,cAAc;AAEzC,MAAA;AACF,qBAAiB,QAAQ;AAAA,WAClB,GAAG;AACN,QAAA,aAAaJ,gBAAI,iBAAiB;AACpC,aAAO,cAAc,EAAE,SAAS,oCAAoC,EAAE,OAAO,IAAI;AAAA,IACnF;AAEM,UAAA;AAAA,EACR;AAEA,SAAO,MAAM;AACf;;"}
1
+ {"version":3,"file":"src-index.js","sources":["../../src/loaders/src-index.ts"],"sourcesContent":["import { resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport { yup, importDefault } from '@strapi/utils';\n\nimport type { Core } from '@strapi/types';\n\nconst srcSchema = yup\n .object()\n .shape({\n bootstrap: yup.mixed().isFunction(),\n register: yup.mixed().isFunction(),\n destroy: yup.mixed().isFunction(),\n })\n .noUnknown();\n\nconst validateSrcIndex = (srcIndex: unknown) => {\n return srcSchema.validateSync(srcIndex, { strict: true, abortEarly: false });\n};\n\nexport default (strapi: Core.Strapi) => {\n if (!existsSync(strapi.dirs.dist.src)) {\n return;\n }\n\n const pathToSrcIndex = resolve(strapi.dirs.dist.src, 'index.js');\n if (!existsSync(pathToSrcIndex) || statSync(pathToSrcIndex).isDirectory()) {\n return {};\n }\n\n const srcIndex = importDefault(pathToSrcIndex);\n\n try {\n validateSrcIndex(srcIndex);\n } catch (e) {\n if (e instanceof yup.ValidationError) {\n strapi.stopWithError({ message: `Invalid file \\`./src/index.js\\`: ${e.message}` });\n }\n\n throw e;\n }\n\n strapi.app = srcIndex;\n};\n"],"names":["yup","existsSync","resolve","statSync","importDefault"],"mappings":";;;;AAMA,MAAM,YAAYA,YAAA,IACf,OAAO,EACP,MAAM;AAAA,EACL,WAAWA,YAAA,IAAI,MAAM,EAAE,WAAW;AAAA,EAClC,UAAUA,YAAA,IAAI,MAAM,EAAE,WAAW;AAAA,EACjC,SAASA,YAAAA,IAAI,MAAM,EAAE,WAAW;AAClC,CAAC,EACA,UAAU;AAEb,MAAM,mBAAmB,CAAC,aAAsB;AACvC,SAAA,UAAU,aAAa,UAAU,EAAE,QAAQ,MAAM,YAAY,OAAO;AAC7E;AAEA,MAAe,eAAA,CAAC,WAAwB;AACtC,MAAI,CAACC,GAAW,WAAA,OAAO,KAAK,KAAK,GAAG,GAAG;AACrC;AAAA,EAAA;AAGF,QAAM,iBAAiBC,KAAAA,QAAQ,OAAO,KAAK,KAAK,KAAK,UAAU;AAC3D,MAAA,CAACD,cAAW,cAAc,KAAKE,YAAS,cAAc,EAAE,eAAe;AACzE,WAAO,CAAC;AAAA,EAAA;AAGJ,QAAA,WAAWC,0BAAc,cAAc;AAEzC,MAAA;AACF,qBAAiB,QAAQ;AAAA,WAClB,GAAG;AACN,QAAA,aAAaJ,gBAAI,iBAAiB;AACpC,aAAO,cAAc,EAAE,SAAS,oCAAoC,EAAE,OAAO,IAAI;AAAA,IAAA;AAG7E,UAAA;AAAA,EAAA;AAGR,SAAO,MAAM;AACf;;"}