@strapi/core 0.0.0-experimental.e60ec1829240dae21c1e1d29076681c322288813 → 0.0.0-experimental.f31889311d753b5f7d95198ae84d8fce1d156cd6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/LICENSE +18 -3
  2. package/dist/Strapi.d.ts +3 -1
  3. package/dist/Strapi.d.ts.map +1 -1
  4. package/dist/Strapi.js +59 -15
  5. package/dist/Strapi.js.map +1 -1
  6. package/dist/Strapi.mjs +38 -13
  7. package/dist/Strapi.mjs.map +1 -1
  8. package/dist/configuration/get-dirs.js +2 -2
  9. package/dist/configuration/get-dirs.js.map +1 -1
  10. package/dist/configuration/index.js +2 -2
  11. package/dist/configuration/index.js.map +1 -1
  12. package/dist/core-api/controller/collection-type.d.ts.map +1 -1
  13. package/dist/core-api/controller/collection-type.js +5 -3
  14. package/dist/core-api/controller/collection-type.js.map +1 -1
  15. package/dist/core-api/controller/collection-type.mjs +2 -0
  16. package/dist/core-api/controller/collection-type.mjs.map +1 -1
  17. package/dist/core-api/controller/index.js +2 -2
  18. package/dist/core-api/controller/index.js.map +1 -1
  19. package/dist/core-api/controller/single-type.d.ts.map +1 -1
  20. package/dist/core-api/controller/single-type.js +3 -2
  21. package/dist/core-api/controller/single-type.js.map +1 -1
  22. package/dist/core-api/controller/single-type.mjs +1 -0
  23. package/dist/core-api/controller/single-type.mjs.map +1 -1
  24. package/dist/core-api/controller/transform.js +8 -8
  25. package/dist/core-api/controller/transform.js.map +1 -1
  26. package/dist/core-api/service/collection-type.d.ts +1 -7
  27. package/dist/core-api/service/collection-type.d.ts.map +1 -1
  28. package/dist/core-api/service/collection-type.js +3 -2
  29. package/dist/core-api/service/collection-type.js.map +1 -1
  30. package/dist/core-api/service/collection-type.mjs +4 -3
  31. package/dist/core-api/service/collection-type.mjs.map +1 -1
  32. package/dist/core-api/service/pagination.d.ts +4 -11
  33. package/dist/core-api/service/pagination.d.ts.map +1 -1
  34. package/dist/core-api/service/pagination.js +18 -44
  35. package/dist/core-api/service/pagination.js.map +1 -1
  36. package/dist/core-api/service/pagination.mjs +16 -42
  37. package/dist/core-api/service/pagination.mjs.map +1 -1
  38. package/dist/domain/content-type/index.js +4 -4
  39. package/dist/domain/content-type/index.js.map +1 -1
  40. package/dist/ee/index.js +3 -3
  41. package/dist/ee/index.js.map +1 -1
  42. package/dist/factories.js +4 -4
  43. package/dist/factories.js.map +1 -1
  44. package/dist/index.d.ts +14 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/index.mjs.map +1 -1
  48. package/dist/loaders/apis.js +2 -2
  49. package/dist/loaders/apis.js.map +1 -1
  50. package/dist/loaders/plugins/get-enabled-plugins.d.ts.map +1 -1
  51. package/dist/loaders/plugins/get-enabled-plugins.js +34 -9
  52. package/dist/loaders/plugins/get-enabled-plugins.js.map +1 -1
  53. package/dist/loaders/plugins/get-enabled-plugins.mjs +4 -1
  54. package/dist/loaders/plugins/get-enabled-plugins.mjs.map +1 -1
  55. package/dist/loaders/plugins/get-user-plugins-config.js +2 -2
  56. package/dist/loaders/plugins/get-user-plugins-config.js.map +1 -1
  57. package/dist/loaders/plugins/index.js +6 -6
  58. package/dist/loaders/plugins/index.js.map +1 -1
  59. package/dist/middlewares/body.js +2 -2
  60. package/dist/middlewares/body.js.map +1 -1
  61. package/dist/middlewares/cors.d.ts.map +1 -1
  62. package/dist/middlewares/cors.js +9 -7
  63. package/dist/middlewares/cors.js.map +1 -1
  64. package/dist/middlewares/cors.mjs +9 -7
  65. package/dist/middlewares/cors.mjs.map +1 -1
  66. package/dist/middlewares/public.js +2 -2
  67. package/dist/middlewares/public.js.map +1 -1
  68. package/dist/middlewares/query.d.ts.map +1 -1
  69. package/dist/middlewares/query.js.map +1 -1
  70. package/dist/middlewares/query.mjs.map +1 -1
  71. package/dist/middlewares/responses.js +2 -2
  72. package/dist/middlewares/responses.js.map +1 -1
  73. package/dist/middlewares/security.d.ts.map +1 -1
  74. package/dist/middlewares/security.js +12 -5
  75. package/dist/middlewares/security.js.map +1 -1
  76. package/dist/middlewares/security.mjs +11 -4
  77. package/dist/middlewares/security.mjs.map +1 -1
  78. package/dist/middlewares/session.js +2 -2
  79. package/dist/middlewares/session.js.map +1 -1
  80. package/dist/migrations/database/5.0.0-discard-drafts.d.ts +19 -1
  81. package/dist/migrations/database/5.0.0-discard-drafts.d.ts.map +1 -1
  82. package/dist/migrations/database/5.0.0-discard-drafts.js +1 -0
  83. package/dist/migrations/database/5.0.0-discard-drafts.js.map +1 -1
  84. package/dist/migrations/database/5.0.0-discard-drafts.mjs +2 -1
  85. package/dist/migrations/database/5.0.0-discard-drafts.mjs.map +1 -1
  86. package/dist/migrations/draft-publish.d.ts.map +1 -1
  87. package/dist/migrations/draft-publish.js +14 -31
  88. package/dist/migrations/draft-publish.js.map +1 -1
  89. package/dist/migrations/draft-publish.mjs +15 -32
  90. package/dist/migrations/draft-publish.mjs.map +1 -1
  91. package/dist/registries/apis.js +2 -2
  92. package/dist/registries/apis.js.map +1 -1
  93. package/dist/registries/components.js +2 -2
  94. package/dist/registries/components.js.map +1 -1
  95. package/dist/registries/content-types.js +3 -3
  96. package/dist/registries/content-types.js.map +1 -1
  97. package/dist/registries/controllers.js +3 -3
  98. package/dist/registries/controllers.js.map +1 -1
  99. package/dist/registries/custom-fields.js +4 -4
  100. package/dist/registries/custom-fields.js.map +1 -1
  101. package/dist/registries/hooks.js +2 -2
  102. package/dist/registries/hooks.js.map +1 -1
  103. package/dist/registries/middlewares.js +3 -3
  104. package/dist/registries/middlewares.js.map +1 -1
  105. package/dist/registries/modules.js +3 -3
  106. package/dist/registries/modules.js.map +1 -1
  107. package/dist/registries/plugins.js +2 -2
  108. package/dist/registries/plugins.js.map +1 -1
  109. package/dist/registries/policies.js +4 -4
  110. package/dist/registries/policies.js.map +1 -1
  111. package/dist/registries/services.js +3 -3
  112. package/dist/registries/services.js.map +1 -1
  113. package/dist/services/auth/index.js +3 -3
  114. package/dist/services/auth/index.js.map +1 -1
  115. package/dist/services/core-store.js +3 -3
  116. package/dist/services/core-store.js.map +1 -1
  117. package/dist/services/cron.js +3 -3
  118. package/dist/services/cron.js.map +1 -1
  119. package/dist/services/document-service/attributes/index.js +2 -2
  120. package/dist/services/document-service/attributes/index.js.map +1 -1
  121. package/dist/services/document-service/attributes/transforms.js +3 -3
  122. package/dist/services/document-service/attributes/transforms.js.map +1 -1
  123. package/dist/services/document-service/components.js +15 -15
  124. package/dist/services/document-service/components.js.map +1 -1
  125. package/dist/services/document-service/draft-and-publish.js +16 -16
  126. package/dist/services/document-service/draft-and-publish.js.map +1 -1
  127. package/dist/services/document-service/entries.js +5 -5
  128. package/dist/services/document-service/entries.js.map +1 -1
  129. package/dist/services/document-service/internationalization.d.ts.map +1 -1
  130. package/dist/services/document-service/internationalization.js +21 -12
  131. package/dist/services/document-service/internationalization.js.map +1 -1
  132. package/dist/services/document-service/internationalization.mjs +14 -5
  133. package/dist/services/document-service/internationalization.mjs.map +1 -1
  134. package/dist/services/document-service/params.js +2 -2
  135. package/dist/services/document-service/params.js.map +1 -1
  136. package/dist/services/document-service/repository.js +10 -10
  137. package/dist/services/document-service/repository.js.map +1 -1
  138. package/dist/services/document-service/repository.mjs +2 -2
  139. package/dist/services/document-service/repository.mjs.map +1 -1
  140. package/dist/services/document-service/transform/id-transform.js +2 -2
  141. package/dist/services/document-service/transform/id-transform.js.map +1 -1
  142. package/dist/services/document-service/transform/query.js +3 -3
  143. package/dist/services/document-service/transform/query.js.map +1 -1
  144. package/dist/services/document-service/transform/relations/extract/data-ids.d.ts.map +1 -1
  145. package/dist/services/document-service/transform/relations/extract/data-ids.js +5 -2
  146. package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -1
  147. package/dist/services/document-service/transform/relations/extract/data-ids.mjs +3 -0
  148. package/dist/services/document-service/transform/relations/extract/data-ids.mjs.map +1 -1
  149. package/dist/services/document-service/transform/relations/transform/data-ids.d.ts.map +1 -1
  150. package/dist/services/document-service/transform/relations/transform/data-ids.js +5 -2
  151. package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
  152. package/dist/services/document-service/transform/relations/transform/data-ids.mjs +3 -0
  153. package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
  154. package/dist/services/document-service/transform/relations/utils/dp.js +2 -2
  155. package/dist/services/document-service/transform/relations/utils/dp.js.map +1 -1
  156. package/dist/services/document-service/transform/relations/utils/map-relation.d.ts.map +1 -1
  157. package/dist/services/document-service/transform/relations/utils/map-relation.js +13 -9
  158. package/dist/services/document-service/transform/relations/utils/map-relation.js.map +1 -1
  159. package/dist/services/document-service/transform/relations/utils/map-relation.mjs +7 -3
  160. package/dist/services/document-service/transform/relations/utils/map-relation.mjs.map +1 -1
  161. package/dist/services/document-service/utils/populate.d.ts.map +1 -1
  162. package/dist/services/document-service/utils/populate.js +4 -0
  163. package/dist/services/document-service/utils/populate.js.map +1 -1
  164. package/dist/services/document-service/utils/populate.mjs +4 -0
  165. package/dist/services/document-service/utils/populate.mjs.map +1 -1
  166. package/dist/services/entity-validator/index.d.ts +14 -1
  167. package/dist/services/entity-validator/index.d.ts.map +1 -1
  168. package/dist/services/entity-validator/index.js +106 -49
  169. package/dist/services/entity-validator/index.js.map +1 -1
  170. package/dist/services/entity-validator/index.mjs +87 -30
  171. package/dist/services/entity-validator/index.mjs.map +1 -1
  172. package/dist/services/entity-validator/validators.d.ts +10 -8
  173. package/dist/services/entity-validator/validators.d.ts.map +1 -1
  174. package/dist/services/entity-validator/validators.js +61 -19
  175. package/dist/services/entity-validator/validators.js.map +1 -1
  176. package/dist/services/entity-validator/validators.mjs +54 -11
  177. package/dist/services/entity-validator/validators.mjs.map +1 -1
  178. package/dist/services/server/compose-endpoint.js +7 -7
  179. package/dist/services/server/compose-endpoint.js.map +1 -1
  180. package/dist/services/server/index.js +1 -1
  181. package/dist/services/server/index.js.map +1 -1
  182. package/dist/services/server/index.mjs +1 -1
  183. package/dist/services/server/index.mjs.map +1 -1
  184. package/dist/services/server/koa.js +3 -3
  185. package/dist/services/server/koa.js.map +1 -1
  186. package/dist/services/server/middleware.js +3 -3
  187. package/dist/services/server/middleware.js.map +1 -1
  188. package/dist/services/server/routing.js +2 -2
  189. package/dist/services/server/routing.js.map +1 -1
  190. package/dist/services/utils/dynamic-zones.js +5 -5
  191. package/dist/services/utils/dynamic-zones.js.map +1 -1
  192. package/dist/services/webhook-runner.d.ts +2 -1
  193. package/dist/services/webhook-runner.d.ts.map +1 -1
  194. package/dist/services/webhook-runner.js.map +1 -1
  195. package/dist/services/webhook-runner.mjs.map +1 -1
  196. package/dist/services/webhook-store.d.ts +2 -8
  197. package/dist/services/webhook-store.d.ts.map +1 -1
  198. package/dist/services/webhook-store.js +1 -1
  199. package/dist/services/webhook-store.js.map +1 -1
  200. package/dist/services/webhook-store.mjs +1 -1
  201. package/dist/services/webhook-store.mjs.map +1 -1
  202. package/dist/utils/cron.js +3 -3
  203. package/dist/utils/cron.js.map +1 -1
  204. package/dist/utils/fetch.d.ts.map +1 -1
  205. package/dist/utils/fetch.js +4 -3
  206. package/dist/utils/fetch.js.map +1 -1
  207. package/dist/utils/fetch.mjs +4 -3
  208. package/dist/utils/fetch.mjs.map +1 -1
  209. package/dist/utils/filepath-to-prop-path.d.ts +1 -1
  210. package/dist/utils/filepath-to-prop-path.d.ts.map +1 -1
  211. package/dist/utils/filepath-to-prop-path.js +27 -6
  212. package/dist/utils/filepath-to-prop-path.js.map +1 -1
  213. package/dist/utils/filepath-to-prop-path.mjs +25 -5
  214. package/dist/utils/filepath-to-prop-path.mjs.map +1 -1
  215. package/dist/utils/is-initialized.js +3 -3
  216. package/dist/utils/is-initialized.js.map +1 -1
  217. package/dist/utils/startup-logger.js +4 -4
  218. package/dist/utils/startup-logger.js.map +1 -1
  219. package/dist/utils/startup-logger.mjs +3 -3
  220. package/dist/utils/startup-logger.mjs.map +1 -1
  221. package/dist/utils/transform-content-types-to-models.d.ts.map +1 -1
  222. package/dist/utils/transform-content-types-to-models.js +16 -4
  223. package/dist/utils/transform-content-types-to-models.js.map +1 -1
  224. package/dist/utils/transform-content-types-to-models.mjs +15 -3
  225. package/dist/utils/transform-content-types-to-models.mjs.map +1 -1
  226. package/package.json +16 -14
@@ -1 +1 @@
1
- {"version":3,"file":"5.0.0-discard-drafts.js","sources":["../../../src/migrations/database/5.0.0-discard-drafts.ts"],"sourcesContent":["/* eslint-disable no-continue */\nimport type { UID } from '@strapi/types';\nimport type { Database, Migration } from '@strapi/database';\nimport { async, contentTypes } from '@strapi/utils';\n\ntype DocumentVersion = { documentId: string; locale: string };\ntype Knex = Parameters<Migration['up']>[0];\n\n/**\n * Load a batch of versions to discard.\n *\n * Versions with only a draft version will be ignored.\n * Only versions with a published version (which always have a draft version) will be discarded.\n */\nasync function* getBatchToDiscard({\n db,\n trx,\n uid,\n batchSize = 1000,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n batchSize?: number;\n}) {\n let offset = 0;\n let hasMore = true;\n\n while (hasMore) {\n // Look for the published entries to discard\n const batch: DocumentVersion[] = await db\n .queryBuilder(uid)\n .select(['id', 'documentId', 'locale'])\n .where({ publishedAt: { $ne: null } })\n .limit(batchSize)\n .offset(offset)\n .orderBy('id')\n .transacting(trx)\n .execute();\n\n if (batch.length < batchSize) {\n hasMore = false;\n }\n\n offset += batchSize;\n yield batch;\n }\n}\n\nconst migrateUp = async (trx: Knex, db: Database) => {\n for (const meta of db.metadata.values()) {\n const hasTable = await trx.schema.hasTable(meta.tableName);\n\n if (!hasTable) {\n continue;\n }\n\n const uid = meta.uid as UID.ContentType;\n const model = strapi.getModel(uid);\n const hasDP = contentTypes.hasDraftAndPublish(model);\n if (!hasDP) {\n continue;\n }\n\n const discardDraft = async (entry: DocumentVersion) =>\n strapi\n .documents(uid)\n // Discard draft by referencing the documentId and locale\n .discardDraft({ documentId: entry.documentId, locale: entry.locale });\n\n /**\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n */\n for await (const batch of getBatchToDiscard({ db, trx, uid: meta.uid })) {\n await async.map(batch, discardDraft, { concurrency: 10 });\n }\n }\n};\n\n/**\n * On V4 there was no concept of document, and an entry could be in a draft or published state.\n * But not both at the same time.\n *\n * On V5 we introduced the concept of document, and an entry can be in a draft or published state,\n * with the requirement that a document must always have a draft.\n *\n * This migration creates the document draft counterpart for all the entries that were in a published state.\n */\nexport const discardDocumentDrafts: Migration = {\n name: 'core::5.0.0-discard-drafts',\n async up(trx, db) {\n // TODO: Log to inform the user that the migration is running in the background\n await migrateUp(trx, db);\n },\n async down() {\n throw new Error('not implemented');\n },\n};\n"],"names":["contentTypes","async"],"mappings":";;;AAcA,gBAAgB,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AACd,GAKG;AACD,MAAI,SAAS;AACb,MAAI,UAAU;AAEd,SAAO,SAAS;AAEd,UAAM,QAA2B,MAAM,GACpC,aAAa,GAAG,EAChB,OAAO,CAAC,MAAM,cAAc,QAAQ,CAAC,EACrC,MAAM,EAAE,aAAa,EAAE,KAAK,KAAO,EAAA,CAAC,EACpC,MAAM,SAAS,EACf,OAAO,MAAM,EACb,QAAQ,IAAI,EACZ,YAAY,GAAG,EACf,QAAQ;AAEP,QAAA,MAAM,SAAS,WAAW;AAClB,gBAAA;AAAA,IACZ;AAEU,cAAA;AACJ,UAAA;AAAA,EACR;AACF;AAEA,MAAM,YAAY,OAAO,KAAW,OAAiB;AACnD,aAAW,QAAQ,GAAG,SAAS,OAAA,GAAU;AACvC,UAAM,WAAW,MAAM,IAAI,OAAO,SAAS,KAAK,SAAS;AAEzD,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AAEA,UAAM,MAAM,KAAK;AACX,UAAA,QAAQ,OAAO,SAAS,GAAG;AAC3B,UAAA,QAAQA,YAAAA,aAAa,mBAAmB,KAAK;AACnD,QAAI,CAAC,OAAO;AACV;AAAA,IACF;AAEA,UAAM,eAAe,OAAO,UAC1B,OACG,UAAU,GAAG,EAEb,aAAa,EAAE,YAAY,MAAM,YAAY,QAAQ,MAAM,QAAQ;AAMvD,qBAAA,SAAS,kBAAkB,EAAE,IAAI,KAAK,KAAK,KAAK,IAAI,CAAC,GAAG;AACvE,YAAMC,YAAAA,MAAM,IAAI,OAAO,cAAc,EAAE,aAAa,IAAI;AAAA,IAC1D;AAAA,EACF;AACF;AAWO,MAAM,wBAAmC;AAAA,EAC9C,MAAM;AAAA,EACN,MAAM,GAAG,KAAK,IAAI;AAEV,UAAA,UAAU,KAAK,EAAE;AAAA,EACzB;AAAA,EACA,MAAM,OAAO;AACL,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACnC;AACF;;"}
1
+ {"version":3,"file":"5.0.0-discard-drafts.js","sources":["../../../src/migrations/database/5.0.0-discard-drafts.ts"],"sourcesContent":["/* eslint-disable no-continue */\nimport type { UID } from '@strapi/types';\nimport type { Database, Migration } from '@strapi/database';\nimport { async, contentTypes } from '@strapi/utils';\n\ntype DocumentVersion = { documentId: string; locale: string };\ntype Knex = Parameters<Migration['up']>[0];\n\n/**\n * Load a batch of versions to discard.\n *\n * Versions with only a draft version will be ignored.\n * Only versions with a published version (which always have a draft version) will be discarded.\n */\nexport async function* getBatchToDiscard({\n db,\n trx,\n uid,\n batchSize = 1000,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n batchSize?: number;\n}) {\n let offset = 0;\n let hasMore = true;\n\n while (hasMore) {\n // Look for the published entries to discard\n const batch: DocumentVersion[] = await db\n .queryBuilder(uid)\n .select(['id', 'documentId', 'locale'])\n .where({ publishedAt: { $ne: null } })\n .limit(batchSize)\n .offset(offset)\n .orderBy('id')\n .transacting(trx)\n .execute();\n\n if (batch.length < batchSize) {\n hasMore = false;\n }\n\n offset += batchSize;\n yield batch;\n }\n}\n\nconst migrateUp = async (trx: Knex, db: Database) => {\n for (const meta of db.metadata.values()) {\n const hasTable = await trx.schema.hasTable(meta.tableName);\n\n if (!hasTable) {\n continue;\n }\n\n const uid = meta.uid as UID.ContentType;\n const model = strapi.getModel(uid);\n const hasDP = contentTypes.hasDraftAndPublish(model);\n if (!hasDP) {\n continue;\n }\n\n const discardDraft = async (entry: DocumentVersion) =>\n strapi\n .documents(uid)\n // Discard draft by referencing the documentId and locale\n .discardDraft({ documentId: entry.documentId, locale: entry.locale });\n\n /**\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n */\n for await (const batch of getBatchToDiscard({ db, trx, uid: meta.uid })) {\n await async.map(batch, discardDraft, { concurrency: 10 });\n }\n }\n};\n\n/**\n * On V4 there was no concept of document, and an entry could be in a draft or published state.\n * But not both at the same time.\n *\n * On V5 we introduced the concept of document, and an entry can be in a draft or published state,\n * with the requirement that a document must always have a draft.\n *\n * This migration creates the document draft counterpart for all the entries that were in a published state.\n */\nexport const discardDocumentDrafts: Migration = {\n name: 'core::5.0.0-discard-drafts',\n async up(trx, db) {\n // TODO: Log to inform the user that the migration is running in the background\n await migrateUp(trx, db);\n },\n async down() {\n throw new Error('not implemented');\n },\n};\n"],"names":["contentTypes","async"],"mappings":";;;AAcA,gBAAuB,kBAAkB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AACd,GAKG;AACD,MAAI,SAAS;AACb,MAAI,UAAU;AAEd,SAAO,SAAS;AAEd,UAAM,QAA2B,MAAM,GACpC,aAAa,GAAG,EAChB,OAAO,CAAC,MAAM,cAAc,QAAQ,CAAC,EACrC,MAAM,EAAE,aAAa,EAAE,KAAK,KAAO,EAAA,CAAC,EACpC,MAAM,SAAS,EACf,OAAO,MAAM,EACb,QAAQ,IAAI,EACZ,YAAY,GAAG,EACf,QAAQ;AAEP,QAAA,MAAM,SAAS,WAAW;AAClB,gBAAA;AAAA,IACZ;AAEU,cAAA;AACJ,UAAA;AAAA,EACR;AACF;AAEA,MAAM,YAAY,OAAO,KAAW,OAAiB;AACnD,aAAW,QAAQ,GAAG,SAAS,OAAA,GAAU;AACvC,UAAM,WAAW,MAAM,IAAI,OAAO,SAAS,KAAK,SAAS;AAEzD,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AAEA,UAAM,MAAM,KAAK;AACX,UAAA,QAAQ,OAAO,SAAS,GAAG;AAC3B,UAAA,QAAQA,YAAAA,aAAa,mBAAmB,KAAK;AACnD,QAAI,CAAC,OAAO;AACV;AAAA,IACF;AAEA,UAAM,eAAe,OAAO,UAC1B,OACG,UAAU,GAAG,EAEb,aAAa,EAAE,YAAY,MAAM,YAAY,QAAQ,MAAM,QAAQ;AAMvD,qBAAA,SAAS,kBAAkB,EAAE,IAAI,KAAK,KAAK,KAAK,IAAI,CAAC,GAAG;AACvE,YAAMC,YAAAA,MAAM,IAAI,OAAO,cAAc,EAAE,aAAa,IAAI;AAAA,IAC1D;AAAA,EACF;AACF;AAWO,MAAM,wBAAmC;AAAA,EAC9C,MAAM;AAAA,EACN,MAAM,GAAG,KAAK,IAAI;AAEV,UAAA,UAAU,KAAK,EAAE;AAAA,EACzB;AAAA,EACA,MAAM,OAAO;AACL,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACnC;AACF;;;"}
@@ -44,6 +44,7 @@ const discardDocumentDrafts = {
44
44
  }
45
45
  };
46
46
  export {
47
- discardDocumentDrafts
47
+ discardDocumentDrafts,
48
+ getBatchToDiscard
48
49
  };
49
50
  //# sourceMappingURL=5.0.0-discard-drafts.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"5.0.0-discard-drafts.mjs","sources":["../../../src/migrations/database/5.0.0-discard-drafts.ts"],"sourcesContent":["/* eslint-disable no-continue */\nimport type { UID } from '@strapi/types';\nimport type { Database, Migration } from '@strapi/database';\nimport { async, contentTypes } from '@strapi/utils';\n\ntype DocumentVersion = { documentId: string; locale: string };\ntype Knex = Parameters<Migration['up']>[0];\n\n/**\n * Load a batch of versions to discard.\n *\n * Versions with only a draft version will be ignored.\n * Only versions with a published version (which always have a draft version) will be discarded.\n */\nasync function* getBatchToDiscard({\n db,\n trx,\n uid,\n batchSize = 1000,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n batchSize?: number;\n}) {\n let offset = 0;\n let hasMore = true;\n\n while (hasMore) {\n // Look for the published entries to discard\n const batch: DocumentVersion[] = await db\n .queryBuilder(uid)\n .select(['id', 'documentId', 'locale'])\n .where({ publishedAt: { $ne: null } })\n .limit(batchSize)\n .offset(offset)\n .orderBy('id')\n .transacting(trx)\n .execute();\n\n if (batch.length < batchSize) {\n hasMore = false;\n }\n\n offset += batchSize;\n yield batch;\n }\n}\n\nconst migrateUp = async (trx: Knex, db: Database) => {\n for (const meta of db.metadata.values()) {\n const hasTable = await trx.schema.hasTable(meta.tableName);\n\n if (!hasTable) {\n continue;\n }\n\n const uid = meta.uid as UID.ContentType;\n const model = strapi.getModel(uid);\n const hasDP = contentTypes.hasDraftAndPublish(model);\n if (!hasDP) {\n continue;\n }\n\n const discardDraft = async (entry: DocumentVersion) =>\n strapi\n .documents(uid)\n // Discard draft by referencing the documentId and locale\n .discardDraft({ documentId: entry.documentId, locale: entry.locale });\n\n /**\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n */\n for await (const batch of getBatchToDiscard({ db, trx, uid: meta.uid })) {\n await async.map(batch, discardDraft, { concurrency: 10 });\n }\n }\n};\n\n/**\n * On V4 there was no concept of document, and an entry could be in a draft or published state.\n * But not both at the same time.\n *\n * On V5 we introduced the concept of document, and an entry can be in a draft or published state,\n * with the requirement that a document must always have a draft.\n *\n * This migration creates the document draft counterpart for all the entries that were in a published state.\n */\nexport const discardDocumentDrafts: Migration = {\n name: 'core::5.0.0-discard-drafts',\n async up(trx, db) {\n // TODO: Log to inform the user that the migration is running in the background\n await migrateUp(trx, db);\n },\n async down() {\n throw new Error('not implemented');\n },\n};\n"],"names":[],"mappings":";AAcA,gBAAgB,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AACd,GAKG;AACD,MAAI,SAAS;AACb,MAAI,UAAU;AAEd,SAAO,SAAS;AAEd,UAAM,QAA2B,MAAM,GACpC,aAAa,GAAG,EAChB,OAAO,CAAC,MAAM,cAAc,QAAQ,CAAC,EACrC,MAAM,EAAE,aAAa,EAAE,KAAK,KAAO,EAAA,CAAC,EACpC,MAAM,SAAS,EACf,OAAO,MAAM,EACb,QAAQ,IAAI,EACZ,YAAY,GAAG,EACf,QAAQ;AAEP,QAAA,MAAM,SAAS,WAAW;AAClB,gBAAA;AAAA,IACZ;AAEU,cAAA;AACJ,UAAA;AAAA,EACR;AACF;AAEA,MAAM,YAAY,OAAO,KAAW,OAAiB;AACnD,aAAW,QAAQ,GAAG,SAAS,OAAA,GAAU;AACvC,UAAM,WAAW,MAAM,IAAI,OAAO,SAAS,KAAK,SAAS;AAEzD,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AAEA,UAAM,MAAM,KAAK;AACX,UAAA,QAAQ,OAAO,SAAS,GAAG;AAC3B,UAAA,QAAQ,aAAa,mBAAmB,KAAK;AACnD,QAAI,CAAC,OAAO;AACV;AAAA,IACF;AAEA,UAAM,eAAe,OAAO,UAC1B,OACG,UAAU,GAAG,EAEb,aAAa,EAAE,YAAY,MAAM,YAAY,QAAQ,MAAM,QAAQ;AAMvD,qBAAA,SAAS,kBAAkB,EAAE,IAAI,KAAK,KAAK,KAAK,IAAI,CAAC,GAAG;AACvE,YAAM,MAAM,IAAI,OAAO,cAAc,EAAE,aAAa,IAAI;AAAA,IAC1D;AAAA,EACF;AACF;AAWO,MAAM,wBAAmC;AAAA,EAC9C,MAAM;AAAA,EACN,MAAM,GAAG,KAAK,IAAI;AAEV,UAAA,UAAU,KAAK,EAAE;AAAA,EACzB;AAAA,EACA,MAAM,OAAO;AACL,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACnC;AACF;"}
1
+ {"version":3,"file":"5.0.0-discard-drafts.mjs","sources":["../../../src/migrations/database/5.0.0-discard-drafts.ts"],"sourcesContent":["/* eslint-disable no-continue */\nimport type { UID } from '@strapi/types';\nimport type { Database, Migration } from '@strapi/database';\nimport { async, contentTypes } from '@strapi/utils';\n\ntype DocumentVersion = { documentId: string; locale: string };\ntype Knex = Parameters<Migration['up']>[0];\n\n/**\n * Load a batch of versions to discard.\n *\n * Versions with only a draft version will be ignored.\n * Only versions with a published version (which always have a draft version) will be discarded.\n */\nexport async function* getBatchToDiscard({\n db,\n trx,\n uid,\n batchSize = 1000,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n batchSize?: number;\n}) {\n let offset = 0;\n let hasMore = true;\n\n while (hasMore) {\n // Look for the published entries to discard\n const batch: DocumentVersion[] = await db\n .queryBuilder(uid)\n .select(['id', 'documentId', 'locale'])\n .where({ publishedAt: { $ne: null } })\n .limit(batchSize)\n .offset(offset)\n .orderBy('id')\n .transacting(trx)\n .execute();\n\n if (batch.length < batchSize) {\n hasMore = false;\n }\n\n offset += batchSize;\n yield batch;\n }\n}\n\nconst migrateUp = async (trx: Knex, db: Database) => {\n for (const meta of db.metadata.values()) {\n const hasTable = await trx.schema.hasTable(meta.tableName);\n\n if (!hasTable) {\n continue;\n }\n\n const uid = meta.uid as UID.ContentType;\n const model = strapi.getModel(uid);\n const hasDP = contentTypes.hasDraftAndPublish(model);\n if (!hasDP) {\n continue;\n }\n\n const discardDraft = async (entry: DocumentVersion) =>\n strapi\n .documents(uid)\n // Discard draft by referencing the documentId and locale\n .discardDraft({ documentId: entry.documentId, locale: entry.locale });\n\n /**\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n */\n for await (const batch of getBatchToDiscard({ db, trx, uid: meta.uid })) {\n await async.map(batch, discardDraft, { concurrency: 10 });\n }\n }\n};\n\n/**\n * On V4 there was no concept of document, and an entry could be in a draft or published state.\n * But not both at the same time.\n *\n * On V5 we introduced the concept of document, and an entry can be in a draft or published state,\n * with the requirement that a document must always have a draft.\n *\n * This migration creates the document draft counterpart for all the entries that were in a published state.\n */\nexport const discardDocumentDrafts: Migration = {\n name: 'core::5.0.0-discard-drafts',\n async up(trx, db) {\n // TODO: Log to inform the user that the migration is running in the background\n await migrateUp(trx, db);\n },\n async down() {\n throw new Error('not implemented');\n },\n};\n"],"names":[],"mappings":";AAcA,gBAAuB,kBAAkB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AACd,GAKG;AACD,MAAI,SAAS;AACb,MAAI,UAAU;AAEd,SAAO,SAAS;AAEd,UAAM,QAA2B,MAAM,GACpC,aAAa,GAAG,EAChB,OAAO,CAAC,MAAM,cAAc,QAAQ,CAAC,EACrC,MAAM,EAAE,aAAa,EAAE,KAAK,KAAO,EAAA,CAAC,EACpC,MAAM,SAAS,EACf,OAAO,MAAM,EACb,QAAQ,IAAI,EACZ,YAAY,GAAG,EACf,QAAQ;AAEP,QAAA,MAAM,SAAS,WAAW;AAClB,gBAAA;AAAA,IACZ;AAEU,cAAA;AACJ,UAAA;AAAA,EACR;AACF;AAEA,MAAM,YAAY,OAAO,KAAW,OAAiB;AACnD,aAAW,QAAQ,GAAG,SAAS,OAAA,GAAU;AACvC,UAAM,WAAW,MAAM,IAAI,OAAO,SAAS,KAAK,SAAS;AAEzD,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AAEA,UAAM,MAAM,KAAK;AACX,UAAA,QAAQ,OAAO,SAAS,GAAG;AAC3B,UAAA,QAAQ,aAAa,mBAAmB,KAAK;AACnD,QAAI,CAAC,OAAO;AACV;AAAA,IACF;AAEA,UAAM,eAAe,OAAO,UAC1B,OACG,UAAU,GAAG,EAEb,aAAa,EAAE,YAAY,MAAM,YAAY,QAAQ,MAAM,QAAQ;AAMvD,qBAAA,SAAS,kBAAkB,EAAE,IAAI,KAAK,KAAK,KAAK,IAAI,CAAC,GAAG;AACvE,YAAM,MAAM,IAAI,OAAO,cAAc,EAAE,aAAa,IAAI;AAAA,IAC1D;AAAA,EACF;AACF;AAWO,MAAM,wBAAmC;AAAA,EAC9C,MAAM;AAAA,EACN,MAAM,GAAG,KAAK,IAAI;AAEV,UAAA,UAAU,KAAK,EAAE;AAAA,EACzB;AAAA,EACA,MAAM,OAAO;AACL,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACnC;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"draft-publish.d.ts","sourceRoot":"","sources":["../../src/migrations/draft-publish.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,UAAU,KAAK;IACb,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACpD,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;CAClD;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,qBAAqB,sCAA6C,KAAK,kBAkE5E,CAAC;AAEF,QAAA,MAAM,sBAAsB,sCAA6C,KAAK,kBAqB7E,CAAC;AAEF,OAAO,EAAE,qBAAqB,IAAI,MAAM,EAAE,sBAAsB,IAAI,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"draft-publish.d.ts","sourceRoot":"","sources":["../../src/migrations/draft-publish.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIvC,UAAU,KAAK;IACb,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACpD,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;CAClD;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,qBAAqB,sCAA6C,KAAK,kBAoC5E,CAAC;AAEF,QAAA,MAAM,sBAAsB,sCAA6C,KAAK,kBAqB7E,CAAC;AAEF,OAAO,EAAE,qBAAqB,IAAI,MAAM,EAAE,sBAAsB,IAAI,OAAO,EAAE,CAAC"}
@@ -1,43 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const strapiUtils = require("@strapi/utils");
4
+ const _5_0_0DiscardDrafts = require("./database/5.0.0-discard-drafts.js");
4
5
  const enableDraftAndPublish = async ({ oldContentTypes, contentTypes }) => {
5
6
  if (!oldContentTypes) {
6
7
  return;
7
8
  }
8
- for (const uid in contentTypes) {
9
- if (!oldContentTypes[uid]) {
10
- continue;
11
- }
12
- const oldContentType = oldContentTypes[uid];
13
- const contentType = contentTypes[uid];
14
- if (!strapiUtils.contentTypes.hasDraftAndPublish(oldContentType) && strapiUtils.contentTypes.hasDraftAndPublish(contentType)) {
15
- const metadata = strapi.db.metadata.get(uid);
16
- const attributes = Object.values(metadata.attributes).reduce((acc, attribute) => {
17
- if (["id"].includes(attribute.columnName)) {
18
- return acc;
9
+ return strapi.db.transaction(async (trx) => {
10
+ for (const uid in contentTypes) {
11
+ if (!oldContentTypes[uid]) {
12
+ continue;
13
+ }
14
+ const oldContentType = oldContentTypes[uid];
15
+ const contentType = contentTypes[uid];
16
+ if (!strapiUtils.contentTypes.hasDraftAndPublish(oldContentType) && strapiUtils.contentTypes.hasDraftAndPublish(contentType)) {
17
+ const discardDraft = async (entry) => strapi.documents(uid).discardDraft({ documentId: entry.documentId, locale: entry.locale });
18
+ for await (const batch of _5_0_0DiscardDrafts.getBatchToDiscard({ db: strapi.db, trx, uid })) {
19
+ await strapiUtils.async.map(batch, discardDraft, { concurrency: 10 });
19
20
  }
20
- if (strapiUtils.contentTypes.isScalarAttribute(attribute)) {
21
- acc.push(attribute.columnName);
22
- }
23
- return acc;
24
- }, []);
25
- const qb = strapi.db?.getConnection();
26
- await qb.into(qb.raw(`${metadata.tableName} (${attributes.join(", ")})`)).insert((subQb) => {
27
- subQb.select(
28
- ...attributes.map((att) => {
29
- if (att === "published_at") {
30
- return qb.raw("NULL as published_at");
31
- }
32
- if (att === "updated_at") {
33
- return qb.raw(`? as updated_at`, [/* @__PURE__ */ new Date()]);
34
- }
35
- return att;
36
- })
37
- ).from(metadata.tableName).whereNotNull("published_at");
38
- });
21
+ }
39
22
  }
40
- }
23
+ });
41
24
  };
42
25
  const disableDraftAndPublish = async ({ oldContentTypes, contentTypes }) => {
43
26
  if (!oldContentTypes) {
@@ -1 +1 @@
1
- {"version":3,"file":"draft-publish.js","sources":["../../src/migrations/draft-publish.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils } from '@strapi/utils';\nimport { Schema } from '@strapi/types';\n\ninterface Input {\n oldContentTypes: Record<string, Schema.ContentType>;\n contentTypes: Record<string, Schema.ContentType>;\n}\n\n/**\n * Enable draft and publish for content types.\n *\n * Draft and publish disabled content types will have their entries published,\n * this migration clones those entries as drafts.\n *\n * TODO: Clone components, dynamic zones and relations\n */\nconst enableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n // run the after content types migrations\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was enabled set publishedAt to eq createdAt\n if (\n !contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n const metadata = strapi.db.metadata.get(uid);\n\n // Extract all scalar attributes to use in the insert query\n const attributes = Object.values(metadata.attributes).reduce((acc, attribute: any) => {\n if (['id'].includes(attribute.columnName)) {\n return acc;\n }\n\n if (contentTypesUtils.isScalarAttribute(attribute)) {\n acc.push(attribute.columnName);\n }\n\n return acc;\n }, [] as string[]);\n\n /**\n * INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n * SELECT columnName1, columnName2, columnName3, ...\n * FROM tableName\n */\n const qb = strapi.db?.getConnection();\n await qb\n // INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n .into(qb.raw(`${metadata.tableName} (${attributes.join(', ')})`))\n .insert((subQb: typeof qb) => {\n // SELECT columnName1, columnName2, columnName3, ...\n subQb\n .select(\n ...attributes.map((att) => {\n // Override 'publishedAt' and 'updatedAt' attributes\n if (att === 'published_at') {\n return qb.raw('NULL as published_at');\n }\n\n if (att === 'updated_at') {\n return qb.raw(`? as updated_at`, [new Date()]);\n }\n\n return att;\n })\n )\n .from(metadata.tableName)\n .whereNotNull('published_at');\n });\n }\n }\n};\n\nconst disableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was disabled remove unpublish content before sync\n if (\n contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n !contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n await strapi.db?.queryBuilder(uid).delete().where({ published_at: null }).execute();\n }\n }\n};\n\nexport { enableDraftAndPublish as enable, disableDraftAndPublish as disable };\n"],"names":["contentTypesUtils"],"mappings":";;;AAgBA,MAAM,wBAAwB,OAAO,EAAE,iBAAiB,mBAA0B;AAChF,MAAI,CAAC,iBAAiB;AACpB;AAAA,EACF;AAIA,aAAW,OAAO,cAAc;AAC1B,QAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,IACF;AAEM,UAAA,iBAAiB,gBAAgB,GAAG;AACpC,UAAA,cAAc,aAAa,GAAG;AAIlC,QAAA,CAACA,yBAAkB,mBAAmB,cAAc,KACpDA,yBAAkB,mBAAmB,WAAW,GAChD;AACA,YAAM,WAAW,OAAO,GAAG,SAAS,IAAI,GAAG;AAGrC,YAAA,aAAa,OAAO,OAAO,SAAS,UAAU,EAAE,OAAO,CAAC,KAAK,cAAmB;AACpF,YAAI,CAAC,IAAI,EAAE,SAAS,UAAU,UAAU,GAAG;AAClC,iBAAA;AAAA,QACT;AAEI,YAAAA,YAAA,aAAkB,kBAAkB,SAAS,GAAG;AAC9C,cAAA,KAAK,UAAU,UAAU;AAAA,QAC/B;AAEO,eAAA;AAAA,MACT,GAAG,CAAc,CAAA;AAOX,YAAA,KAAK,OAAO,IAAI,cAAc;AACpC,YAAM,GAEH,KAAK,GAAG,IAAI,GAAG,SAAS,SAAS,KAAK,WAAW,KAAK,IAAI,CAAC,GAAG,CAAC,EAC/D,OAAO,CAAC,UAAqB;AAGzB,cAAA;AAAA,UACC,GAAG,WAAW,IAAI,CAAC,QAAQ;AAEzB,gBAAI,QAAQ,gBAAgB;AACnB,qBAAA,GAAG,IAAI,sBAAsB;AAAA,YACtC;AAEA,gBAAI,QAAQ,cAAc;AACxB,qBAAO,GAAG,IAAI,mBAAmB,CAAK,oBAAA,KAAM,CAAA,CAAC;AAAA,YAC/C;AAEO,mBAAA;AAAA,UAAA,CACR;AAAA,QAAA,EAEF,KAAK,SAAS,SAAS,EACvB,aAAa,cAAc;AAAA,MAAA,CAC/B;AAAA,IACL;AAAA,EACF;AACF;AAEA,MAAM,yBAAyB,OAAO,EAAE,iBAAiB,mBAA0B;AACjF,MAAI,CAAC,iBAAiB;AACpB;AAAA,EACF;AAEA,aAAW,OAAO,cAAc;AAC1B,QAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,IACF;AAEM,UAAA,iBAAiB,gBAAgB,GAAG;AACpC,UAAA,cAAc,aAAa,GAAG;AAIlC,QAAAA,YAAAA,aAAkB,mBAAmB,cAAc,KACnD,CAACA,yBAAkB,mBAAmB,WAAW,GACjD;AACA,YAAM,OAAO,IAAI,aAAa,GAAG,EAAE,OAAA,EAAS,MAAM,EAAE,cAAc,MAAM,EAAE,QAAQ;AAAA,IACpF;AAAA,EACF;AACF;;;"}
1
+ {"version":3,"file":"draft-publish.js","sources":["../../src/migrations/draft-publish.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils, async } from '@strapi/utils';\nimport { Schema } from '@strapi/types';\n\nimport { getBatchToDiscard } from './database/5.0.0-discard-drafts';\n\ninterface Input {\n oldContentTypes: Record<string, Schema.ContentType>;\n contentTypes: Record<string, Schema.ContentType>;\n}\n\n/**\n * Enable draft and publish for content types.\n *\n * Draft and publish disabled content types will have their entries published,\n * this migration clones those entries as drafts.\n *\n * TODO: Clone components, dynamic zones and relations\n */\nconst enableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n // run the after content types migrations\n return strapi.db.transaction(async (trx) => {\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was enabled set publishedAt to eq createdAt\n if (\n !contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n const discardDraft = async (entry: { documentId: string; locale: string }) =>\n strapi\n .documents(uid as any)\n // Discard draft by referencing the documentId and locale\n .discardDraft({ documentId: entry.documentId, locale: entry.locale });\n\n /**\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n */\n for await (const batch of getBatchToDiscard({ db: strapi.db, trx, uid })) {\n await async.map(batch, discardDraft, { concurrency: 10 });\n }\n }\n }\n });\n};\n\nconst disableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was disabled remove unpublish content before sync\n if (\n contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n !contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n await strapi.db?.queryBuilder(uid).delete().where({ published_at: null }).execute();\n }\n }\n};\n\nexport { enableDraftAndPublish as enable, disableDraftAndPublish as disable };\n"],"names":["contentTypesUtils","getBatchToDiscard","async"],"mappings":";;;;AAkBA,MAAM,wBAAwB,OAAO,EAAE,iBAAiB,mBAA0B;AAChF,MAAI,CAAC,iBAAiB;AACpB;AAAA,EACF;AAGA,SAAO,OAAO,GAAG,YAAY,OAAO,QAAQ;AAC1C,eAAW,OAAO,cAAc;AAC1B,UAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,MACF;AAEM,YAAA,iBAAiB,gBAAgB,GAAG;AACpC,YAAA,cAAc,aAAa,GAAG;AAIlC,UAAA,CAACA,yBAAkB,mBAAmB,cAAc,KACpDA,yBAAkB,mBAAmB,WAAW,GAChD;AACA,cAAM,eAAe,OAAO,UAC1B,OACG,UAAU,GAAU,EAEpB,aAAa,EAAE,YAAY,MAAM,YAAY,QAAQ,MAAM,QAAQ;AAMvD,yBAAA,SAASC,sCAAkB,EAAE,IAAI,OAAO,IAAI,KAAK,IAAI,CAAC,GAAG;AACxE,gBAAMC,YAAAA,MAAM,IAAI,OAAO,cAAc,EAAE,aAAa,IAAI;AAAA,QAC1D;AAAA,MACF;AAAA,IACF;AAAA,EAAA,CACD;AACH;AAEA,MAAM,yBAAyB,OAAO,EAAE,iBAAiB,mBAA0B;AACjF,MAAI,CAAC,iBAAiB;AACpB;AAAA,EACF;AAEA,aAAW,OAAO,cAAc;AAC1B,QAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,IACF;AAEM,UAAA,iBAAiB,gBAAgB,GAAG;AACpC,UAAA,cAAc,aAAa,GAAG;AAIlC,QAAAF,YAAAA,aAAkB,mBAAmB,cAAc,KACnD,CAACA,yBAAkB,mBAAmB,WAAW,GACjD;AACA,YAAM,OAAO,IAAI,aAAa,GAAG,EAAE,OAAA,EAAS,MAAM,EAAE,cAAc,MAAM,EAAE,QAAQ;AAAA,IACpF;AAAA,EACF;AACF;;;"}
@@ -1,41 +1,24 @@
1
- import { contentTypes } from "@strapi/utils";
1
+ import { contentTypes, async } from "@strapi/utils";
2
+ import { getBatchToDiscard } from "./database/5.0.0-discard-drafts.mjs";
2
3
  const enableDraftAndPublish = async ({ oldContentTypes, contentTypes: contentTypes$1 }) => {
3
4
  if (!oldContentTypes) {
4
5
  return;
5
6
  }
6
- for (const uid in contentTypes$1) {
7
- if (!oldContentTypes[uid]) {
8
- continue;
9
- }
10
- const oldContentType = oldContentTypes[uid];
11
- const contentType = contentTypes$1[uid];
12
- if (!contentTypes.hasDraftAndPublish(oldContentType) && contentTypes.hasDraftAndPublish(contentType)) {
13
- const metadata = strapi.db.metadata.get(uid);
14
- const attributes = Object.values(metadata.attributes).reduce((acc, attribute) => {
15
- if (["id"].includes(attribute.columnName)) {
16
- return acc;
7
+ return strapi.db.transaction(async (trx) => {
8
+ for (const uid in contentTypes$1) {
9
+ if (!oldContentTypes[uid]) {
10
+ continue;
11
+ }
12
+ const oldContentType = oldContentTypes[uid];
13
+ const contentType = contentTypes$1[uid];
14
+ if (!contentTypes.hasDraftAndPublish(oldContentType) && contentTypes.hasDraftAndPublish(contentType)) {
15
+ const discardDraft = async (entry) => strapi.documents(uid).discardDraft({ documentId: entry.documentId, locale: entry.locale });
16
+ for await (const batch of getBatchToDiscard({ db: strapi.db, trx, uid })) {
17
+ await async.map(batch, discardDraft, { concurrency: 10 });
17
18
  }
18
- if (contentTypes.isScalarAttribute(attribute)) {
19
- acc.push(attribute.columnName);
20
- }
21
- return acc;
22
- }, []);
23
- const qb = strapi.db?.getConnection();
24
- await qb.into(qb.raw(`${metadata.tableName} (${attributes.join(", ")})`)).insert((subQb) => {
25
- subQb.select(
26
- ...attributes.map((att) => {
27
- if (att === "published_at") {
28
- return qb.raw("NULL as published_at");
29
- }
30
- if (att === "updated_at") {
31
- return qb.raw(`? as updated_at`, [/* @__PURE__ */ new Date()]);
32
- }
33
- return att;
34
- })
35
- ).from(metadata.tableName).whereNotNull("published_at");
36
- });
19
+ }
37
20
  }
38
- }
21
+ });
39
22
  };
40
23
  const disableDraftAndPublish = async ({ oldContentTypes, contentTypes: contentTypes$1 }) => {
41
24
  if (!oldContentTypes) {
@@ -1 +1 @@
1
- {"version":3,"file":"draft-publish.mjs","sources":["../../src/migrations/draft-publish.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils } from '@strapi/utils';\nimport { Schema } from '@strapi/types';\n\ninterface Input {\n oldContentTypes: Record<string, Schema.ContentType>;\n contentTypes: Record<string, Schema.ContentType>;\n}\n\n/**\n * Enable draft and publish for content types.\n *\n * Draft and publish disabled content types will have their entries published,\n * this migration clones those entries as drafts.\n *\n * TODO: Clone components, dynamic zones and relations\n */\nconst enableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n // run the after content types migrations\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was enabled set publishedAt to eq createdAt\n if (\n !contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n const metadata = strapi.db.metadata.get(uid);\n\n // Extract all scalar attributes to use in the insert query\n const attributes = Object.values(metadata.attributes).reduce((acc, attribute: any) => {\n if (['id'].includes(attribute.columnName)) {\n return acc;\n }\n\n if (contentTypesUtils.isScalarAttribute(attribute)) {\n acc.push(attribute.columnName);\n }\n\n return acc;\n }, [] as string[]);\n\n /**\n * INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n * SELECT columnName1, columnName2, columnName3, ...\n * FROM tableName\n */\n const qb = strapi.db?.getConnection();\n await qb\n // INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n .into(qb.raw(`${metadata.tableName} (${attributes.join(', ')})`))\n .insert((subQb: typeof qb) => {\n // SELECT columnName1, columnName2, columnName3, ...\n subQb\n .select(\n ...attributes.map((att) => {\n // Override 'publishedAt' and 'updatedAt' attributes\n if (att === 'published_at') {\n return qb.raw('NULL as published_at');\n }\n\n if (att === 'updated_at') {\n return qb.raw(`? as updated_at`, [new Date()]);\n }\n\n return att;\n })\n )\n .from(metadata.tableName)\n .whereNotNull('published_at');\n });\n }\n }\n};\n\nconst disableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was disabled remove unpublish content before sync\n if (\n contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n !contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n await strapi.db?.queryBuilder(uid).delete().where({ published_at: null }).execute();\n }\n }\n};\n\nexport { enableDraftAndPublish as enable, disableDraftAndPublish as disable };\n"],"names":["contentTypes","contentTypesUtils"],"mappings":";AAgBA,MAAM,wBAAwB,OAAO,EAAE,iBAAiBA,cAAAA,qBAA0B;AAChF,MAAI,CAAC,iBAAiB;AACpB;AAAA,EACF;AAIA,aAAW,OAAOA,gBAAc;AAC1B,QAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,IACF;AAEM,UAAA,iBAAiB,gBAAgB,GAAG;AACpC,UAAA,cAAcA,eAAa,GAAG;AAIlC,QAAA,CAACC,aAAkB,mBAAmB,cAAc,KACpDA,aAAkB,mBAAmB,WAAW,GAChD;AACA,YAAM,WAAW,OAAO,GAAG,SAAS,IAAI,GAAG;AAGrC,YAAA,aAAa,OAAO,OAAO,SAAS,UAAU,EAAE,OAAO,CAAC,KAAK,cAAmB;AACpF,YAAI,CAAC,IAAI,EAAE,SAAS,UAAU,UAAU,GAAG;AAClC,iBAAA;AAAA,QACT;AAEI,YAAAA,aAAkB,kBAAkB,SAAS,GAAG;AAC9C,cAAA,KAAK,UAAU,UAAU;AAAA,QAC/B;AAEO,eAAA;AAAA,MACT,GAAG,CAAc,CAAA;AAOX,YAAA,KAAK,OAAO,IAAI,cAAc;AACpC,YAAM,GAEH,KAAK,GAAG,IAAI,GAAG,SAAS,SAAS,KAAK,WAAW,KAAK,IAAI,CAAC,GAAG,CAAC,EAC/D,OAAO,CAAC,UAAqB;AAGzB,cAAA;AAAA,UACC,GAAG,WAAW,IAAI,CAAC,QAAQ;AAEzB,gBAAI,QAAQ,gBAAgB;AACnB,qBAAA,GAAG,IAAI,sBAAsB;AAAA,YACtC;AAEA,gBAAI,QAAQ,cAAc;AACxB,qBAAO,GAAG,IAAI,mBAAmB,CAAK,oBAAA,KAAM,CAAA,CAAC;AAAA,YAC/C;AAEO,mBAAA;AAAA,UAAA,CACR;AAAA,QAAA,EAEF,KAAK,SAAS,SAAS,EACvB,aAAa,cAAc;AAAA,MAAA,CAC/B;AAAA,IACL;AAAA,EACF;AACF;AAEA,MAAM,yBAAyB,OAAO,EAAE,iBAAiBD,cAAAA,qBAA0B;AACjF,MAAI,CAAC,iBAAiB;AACpB;AAAA,EACF;AAEA,aAAW,OAAOA,gBAAc;AAC1B,QAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,IACF;AAEM,UAAA,iBAAiB,gBAAgB,GAAG;AACpC,UAAA,cAAcA,eAAa,GAAG;AAIlC,QAAAC,aAAkB,mBAAmB,cAAc,KACnD,CAACA,aAAkB,mBAAmB,WAAW,GACjD;AACA,YAAM,OAAO,IAAI,aAAa,GAAG,EAAE,OAAA,EAAS,MAAM,EAAE,cAAc,MAAM,EAAE,QAAQ;AAAA,IACpF;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"draft-publish.mjs","sources":["../../src/migrations/draft-publish.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils, async } from '@strapi/utils';\nimport { Schema } from '@strapi/types';\n\nimport { getBatchToDiscard } from './database/5.0.0-discard-drafts';\n\ninterface Input {\n oldContentTypes: Record<string, Schema.ContentType>;\n contentTypes: Record<string, Schema.ContentType>;\n}\n\n/**\n * Enable draft and publish for content types.\n *\n * Draft and publish disabled content types will have their entries published,\n * this migration clones those entries as drafts.\n *\n * TODO: Clone components, dynamic zones and relations\n */\nconst enableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n // run the after content types migrations\n return strapi.db.transaction(async (trx) => {\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was enabled set publishedAt to eq createdAt\n if (\n !contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n const discardDraft = async (entry: { documentId: string; locale: string }) =>\n strapi\n .documents(uid as any)\n // Discard draft by referencing the documentId and locale\n .discardDraft({ documentId: entry.documentId, locale: entry.locale });\n\n /**\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n */\n for await (const batch of getBatchToDiscard({ db: strapi.db, trx, uid })) {\n await async.map(batch, discardDraft, { concurrency: 10 });\n }\n }\n }\n });\n};\n\nconst disableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was disabled remove unpublish content before sync\n if (\n contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n !contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n await strapi.db?.queryBuilder(uid).delete().where({ published_at: null }).execute();\n }\n }\n};\n\nexport { enableDraftAndPublish as enable, disableDraftAndPublish as disable };\n"],"names":["contentTypes","contentTypesUtils"],"mappings":";;AAkBA,MAAM,wBAAwB,OAAO,EAAE,iBAAiBA,cAAAA,qBAA0B;AAChF,MAAI,CAAC,iBAAiB;AACpB;AAAA,EACF;AAGA,SAAO,OAAO,GAAG,YAAY,OAAO,QAAQ;AAC1C,eAAW,OAAOA,gBAAc;AAC1B,UAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,MACF;AAEM,YAAA,iBAAiB,gBAAgB,GAAG;AACpC,YAAA,cAAcA,eAAa,GAAG;AAIlC,UAAA,CAACC,aAAkB,mBAAmB,cAAc,KACpDA,aAAkB,mBAAmB,WAAW,GAChD;AACA,cAAM,eAAe,OAAO,UAC1B,OACG,UAAU,GAAU,EAEpB,aAAa,EAAE,YAAY,MAAM,YAAY,QAAQ,MAAM,QAAQ;AAMvD,yBAAA,SAAS,kBAAkB,EAAE,IAAI,OAAO,IAAI,KAAK,IAAI,CAAC,GAAG;AACxE,gBAAM,MAAM,IAAI,OAAO,cAAc,EAAE,aAAa,IAAI;AAAA,QAC1D;AAAA,MACF;AAAA,IACF;AAAA,EAAA,CACD;AACH;AAEA,MAAM,yBAAyB,OAAO,EAAE,iBAAiBD,cAAAA,qBAA0B;AACjF,MAAI,CAAC,iBAAiB;AACpB;AAAA,EACF;AAEA,aAAW,OAAOA,gBAAc;AAC1B,QAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,IACF;AAEM,UAAA,iBAAiB,gBAAgB,GAAG;AACpC,UAAA,cAAcA,eAAa,GAAG;AAIlC,QAAAC,aAAkB,mBAAmB,cAAc,KACnD,CAACA,aAAkB,mBAAmB,WAAW,GACjD;AACA,YAAM,OAAO,IAAI,aAAa,GAAG,EAAE,OAAA,EAAS,MAAM,EAAE,cAAc,MAAM,EAAE,QAAQ;AAAA,IACpF;AAAA,EACF;AACF;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const apisRegistry = (strapi) => {
4
4
  const apis = {};
5
5
  return {
@@ -10,7 +10,7 @@ const apisRegistry = (strapi) => {
10
10
  return apis;
11
11
  },
12
12
  add(apiName, apiConfig) {
13
- if (_.has(apiName, apis)) {
13
+ if (fp.has(apiName, apis)) {
14
14
  throw new Error(`API ${apiName} has already been registered.`);
15
15
  }
16
16
  const api = strapi.get("modules").add(`api::${apiName}`, apiConfig);
@@ -1 +1 @@
1
- {"version":3,"file":"apis.js","sources":["../../src/registries/apis.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\nconst apisRegistry = (strapi: Core.Strapi) => {\n const apis: Record<string, unknown> = {};\n\n return {\n get(name: string) {\n return apis[name];\n },\n getAll() {\n return apis;\n },\n add(apiName: string, apiConfig: unknown) {\n if (has(apiName, apis)) {\n throw new Error(`API ${apiName} has already been registered.`);\n }\n\n const api = strapi.get('modules').add(`api::${apiName}`, apiConfig);\n\n apis[apiName] = api;\n\n return apis[apiName];\n },\n };\n};\n\nexport default apisRegistry;\n"],"names":["has"],"mappings":";;AAGM,MAAA,eAAe,CAAC,WAAwB;AAC5C,QAAM,OAAgC,CAAA;AAE/B,SAAA;AAAA,IACL,IAAI,MAAc;AAChB,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,IACA,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,SAAiB,WAAoB;AACnC,UAAAA,EAAA,IAAI,SAAS,IAAI,GAAG;AACtB,cAAM,IAAI,MAAM,OAAO,OAAO,+BAA+B;AAAA,MAC/D;AAEM,YAAA,MAAM,OAAO,IAAI,SAAS,EAAE,IAAI,QAAQ,OAAO,IAAI,SAAS;AAElE,WAAK,OAAO,IAAI;AAEhB,aAAO,KAAK,OAAO;AAAA,IACrB;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"apis.js","sources":["../../src/registries/apis.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\nconst apisRegistry = (strapi: Core.Strapi) => {\n const apis: Record<string, unknown> = {};\n\n return {\n get(name: string) {\n return apis[name];\n },\n getAll() {\n return apis;\n },\n add(apiName: string, apiConfig: unknown) {\n if (has(apiName, apis)) {\n throw new Error(`API ${apiName} has already been registered.`);\n }\n\n const api = strapi.get('modules').add(`api::${apiName}`, apiConfig);\n\n apis[apiName] = api;\n\n return apis[apiName];\n },\n };\n};\n\nexport default apisRegistry;\n"],"names":["has"],"mappings":";;AAGM,MAAA,eAAe,CAAC,WAAwB;AAC5C,QAAM,OAAgC,CAAA;AAE/B,SAAA;AAAA,IACL,IAAI,MAAc;AAChB,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,IACA,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,SAAiB,WAAoB;AACnC,UAAAA,GAAA,IAAI,SAAS,IAAI,GAAG;AACtB,cAAM,IAAI,MAAM,OAAO,OAAO,+BAA+B;AAAA,MAC/D;AAEM,YAAA,MAAM,OAAO,IAAI,SAAS,EAAE,IAAI,QAAQ,OAAO,IAAI,SAAS;AAElE,WAAK,OAAO,IAAI;AAEhB,aAAO,KAAK,OAAO;AAAA,IACrB;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const componentsRegistry = () => {
4
4
  const components = {};
5
5
  return {
@@ -25,7 +25,7 @@ const componentsRegistry = () => {
25
25
  * Registers a component
26
26
  */
27
27
  set(uid, component) {
28
- if (_.has(uid, components)) {
28
+ if (fp.has(uid, components)) {
29
29
  throw new Error(`Component ${uid} has already been registered.`);
30
30
  }
31
31
  components[uid] = component;
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sources":["../../src/registries/components.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Struct, UID } from '@strapi/types';\n\nconst componentsRegistry = () => {\n const components: Record<UID.Component, Struct.ComponentSchema> = {};\n\n return {\n /**\n * Returns this list of registered components uids\n */\n keys(): UID.Component[] {\n return Object.keys(components) as UID.Component[];\n },\n\n /**\n * Returns the instance of a component. Instantiate the component if not already done\n */\n get(uid: UID.Component) {\n return components[uid];\n },\n\n /**\n * Returns a map with all the components in a namespace\n */\n getAll() {\n return components;\n },\n\n /**\n * Registers a component\n */\n set(uid: UID.Component, component: Struct.ComponentSchema) {\n if (has(uid, components)) {\n throw new Error(`Component ${uid} has already been registered.`);\n }\n\n components[uid] = component;\n\n return this;\n },\n\n /**\n * Registers a map of components for a specific namespace\n */\n add(newComponents: Record<UID.Component, Struct.ComponentSchema>) {\n for (const uid of Object.keys(newComponents) as UID.Component[]) {\n this.set(uid, newComponents[uid]);\n }\n },\n };\n};\n\nexport default componentsRegistry;\n"],"names":["has"],"mappings":";;AAGA,MAAM,qBAAqB,MAAM;AAC/B,QAAM,aAA4D,CAAA;AAE3D,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAwB;AACf,aAAA,OAAO,KAAK,UAAU;AAAA,IAC/B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAoB;AACtB,aAAO,WAAW,GAAG;AAAA,IACvB;AAAA;AAAA;AAAA;AAAA,IAKA,SAAS;AACA,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAoB,WAAmC;AACrD,UAAAA,EAAA,IAAI,KAAK,UAAU,GAAG;AACxB,cAAM,IAAI,MAAM,aAAa,GAAG,+BAA+B;AAAA,MACjE;AAEA,iBAAW,GAAG,IAAI;AAEX,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,eAA8D;AAChE,iBAAW,OAAO,OAAO,KAAK,aAAa,GAAsB;AAC/D,aAAK,IAAI,KAAK,cAAc,GAAG,CAAC;AAAA,MAClC;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"components.js","sources":["../../src/registries/components.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Struct, UID } from '@strapi/types';\n\nconst componentsRegistry = () => {\n const components: Record<UID.Component, Struct.ComponentSchema> = {};\n\n return {\n /**\n * Returns this list of registered components uids\n */\n keys(): UID.Component[] {\n return Object.keys(components) as UID.Component[];\n },\n\n /**\n * Returns the instance of a component. Instantiate the component if not already done\n */\n get(uid: UID.Component) {\n return components[uid];\n },\n\n /**\n * Returns a map with all the components in a namespace\n */\n getAll() {\n return components;\n },\n\n /**\n * Registers a component\n */\n set(uid: UID.Component, component: Struct.ComponentSchema) {\n if (has(uid, components)) {\n throw new Error(`Component ${uid} has already been registered.`);\n }\n\n components[uid] = component;\n\n return this;\n },\n\n /**\n * Registers a map of components for a specific namespace\n */\n add(newComponents: Record<UID.Component, Struct.ComponentSchema>) {\n for (const uid of Object.keys(newComponents) as UID.Component[]) {\n this.set(uid, newComponents[uid]);\n }\n },\n };\n};\n\nexport default componentsRegistry;\n"],"names":["has"],"mappings":";;AAGA,MAAM,qBAAqB,MAAM;AAC/B,QAAM,aAA4D,CAAA;AAE3D,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAwB;AACf,aAAA,OAAO,KAAK,UAAU;AAAA,IAC/B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAoB;AACtB,aAAO,WAAW,GAAG;AAAA,IACvB;AAAA;AAAA;AAAA;AAAA,IAKA,SAAS;AACA,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAoB,WAAmC;AACrD,UAAAA,GAAA,IAAI,KAAK,UAAU,GAAG;AACxB,cAAM,IAAI,MAAM,aAAa,GAAG,+BAA+B;AAAA,MACjE;AAEA,iBAAW,GAAG,IAAI;AAEX,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,eAA8D;AAChE,iBAAW,OAAO,OAAO,KAAK,aAAa,GAAsB;AAC/D,aAAK,IAAI,KAAK,cAAc,GAAG,CAAC;AAAA,MAClC;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const index = require("../domain/content-type/index.js");
4
4
  const namespace = require("./namespace.js");
5
5
  const validateKeySameToSingularName = (contentTypes) => {
@@ -31,7 +31,7 @@ const contentTypesRegistry = () => {
31
31
  * Returns a map with all the contentTypes in a namespace
32
32
  */
33
33
  getAll(namespace$1) {
34
- return _.pickBy((_2, uid) => namespace.hasNamespace(uid, namespace$1))(contentTypes);
34
+ return fp.pickBy((_, uid) => namespace.hasNamespace(uid, namespace$1))(contentTypes);
35
35
  },
36
36
  /**
37
37
  * Registers a contentType
@@ -47,7 +47,7 @@ const contentTypesRegistry = () => {
47
47
  validateKeySameToSingularName(newContentTypes);
48
48
  for (const rawCtName of Object.keys(newContentTypes)) {
49
49
  const uid = namespace.addNamespace(rawCtName, namespace$1);
50
- if (_.has(uid, contentTypes)) {
50
+ if (fp.has(uid, contentTypes)) {
51
51
  throw new Error(`Content-type ${uid} has already been registered.`);
52
52
  }
53
53
  contentTypes[uid] = index.createContentType(uid, newContentTypes[rawCtName]);
@@ -1 +1 @@
1
- {"version":3,"file":"content-types.js","sources":["../../src/registries/content-types.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { UID, Struct } from '@strapi/types';\nimport { createContentType, ContentTypeDefinition } from '../domain/content-type';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype ContentTypesInput = Record<string, ContentTypeDefinition>;\ntype ContentTypeExtendFn = (contentType: Struct.ContentTypeSchema) => Struct.ContentTypeSchema;\n\nconst validateKeySameToSingularName = (contentTypes: ContentTypesInput) => {\n for (const ctName of Object.keys(contentTypes)) {\n const contentType = contentTypes[ctName];\n\n if (ctName !== contentType.schema.info.singularName) {\n throw new Error(\n `The key of the content-type should be the same as its singularName. Found ${ctName} and ${contentType.schema.info.singularName}.`\n );\n }\n }\n};\n\nconst contentTypesRegistry = () => {\n const contentTypes: Record<string, Struct.ContentTypeSchema> = {};\n\n return {\n /**\n * Returns this list of registered contentTypes uids\n */\n keys() {\n return Object.keys(contentTypes);\n },\n\n /**\n * Returns the instance of a contentType. Instantiate the contentType if not already done\n */\n get(uid: UID.ContentType) {\n return contentTypes[uid];\n },\n\n /**\n * Returns a map with all the contentTypes in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(contentTypes);\n },\n\n /**\n * Registers a contentType\n */\n set(uid: UID.ContentType, contentType: Struct.ContentTypeSchema) {\n contentTypes[uid] = contentType;\n return this;\n },\n\n /**\n * Registers a map of contentTypes for a specific namespace\n */\n add(namespace: string, newContentTypes: ContentTypesInput) {\n validateKeySameToSingularName(newContentTypes);\n\n for (const rawCtName of Object.keys(newContentTypes)) {\n const uid = addNamespace(rawCtName, namespace);\n\n if (has(uid, contentTypes)) {\n throw new Error(`Content-type ${uid} has already been registered.`);\n }\n\n contentTypes[uid] = createContentType(uid, newContentTypes[rawCtName]);\n }\n },\n\n /**\n * Wraps a contentType to extend it\n */\n extend(ctUID: UID.ContentType, extendFn: ContentTypeExtendFn) {\n const currentContentType = this.get(ctUID);\n\n if (!currentContentType) {\n throw new Error(`Content-Type ${ctUID} doesn't exist`);\n }\n\n extendFn(currentContentType);\n\n return this;\n },\n };\n};\n\nexport default contentTypesRegistry;\n"],"names":["namespace","pickBy","_","hasNamespace","addNamespace","has","createContentType"],"mappings":";;;;AAQA,MAAM,gCAAgC,CAAC,iBAAoC;AACzE,aAAW,UAAU,OAAO,KAAK,YAAY,GAAG;AACxC,UAAA,cAAc,aAAa,MAAM;AAEvC,QAAI,WAAW,YAAY,OAAO,KAAK,cAAc;AACnD,YAAM,IAAI;AAAA,QACR,6EAA6E,MAAM,QAAQ,YAAY,OAAO,KAAK,YAAY;AAAA,MAAA;AAAA,IAEnI;AAAA,EACF;AACF;AAEA,MAAM,uBAAuB,MAAM;AACjC,QAAM,eAAyD,CAAA;AAExD,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,YAAY;AAAA,IACjC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAsB;AACxB,aAAO,aAAa,GAAG;AAAA,IACzB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AACjB,aAAAC,EAAA,OAAO,CAACC,IAAG,QAAQC,UAAAA,aAAa,KAAKH,WAAS,CAAC,EAAE,YAAY;AAAA,IACtE;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAsB,aAAuC;AAC/D,mBAAa,GAAG,IAAI;AACb,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmB,iBAAoC;AACzD,oCAA8B,eAAe;AAE7C,iBAAW,aAAa,OAAO,KAAK,eAAe,GAAG;AAC9C,cAAA,MAAMI,UAAAA,aAAa,WAAWJ,WAAS;AAEzC,YAAAK,EAAA,IAAI,KAAK,YAAY,GAAG;AAC1B,gBAAM,IAAI,MAAM,gBAAgB,GAAG,+BAA+B;AAAA,QACpE;AAEA,qBAAa,GAAG,IAAIC,MAAA,kBAAkB,KAAK,gBAAgB,SAAS,CAAC;AAAA,MACvE;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,OAAwB,UAA+B;AACtD,YAAA,qBAAqB,KAAK,IAAI,KAAK;AAEzC,UAAI,CAAC,oBAAoB;AACvB,cAAM,IAAI,MAAM,gBAAgB,KAAK,gBAAgB;AAAA,MACvD;AAEA,eAAS,kBAAkB;AAEpB,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"content-types.js","sources":["../../src/registries/content-types.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { UID, Struct } from '@strapi/types';\nimport { createContentType, ContentTypeDefinition } from '../domain/content-type';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype ContentTypesInput = Record<string, ContentTypeDefinition>;\ntype ContentTypeExtendFn = (contentType: Struct.ContentTypeSchema) => Struct.ContentTypeSchema;\n\nconst validateKeySameToSingularName = (contentTypes: ContentTypesInput) => {\n for (const ctName of Object.keys(contentTypes)) {\n const contentType = contentTypes[ctName];\n\n if (ctName !== contentType.schema.info.singularName) {\n throw new Error(\n `The key of the content-type should be the same as its singularName. Found ${ctName} and ${contentType.schema.info.singularName}.`\n );\n }\n }\n};\n\nconst contentTypesRegistry = () => {\n const contentTypes: Record<string, Struct.ContentTypeSchema> = {};\n\n return {\n /**\n * Returns this list of registered contentTypes uids\n */\n keys() {\n return Object.keys(contentTypes);\n },\n\n /**\n * Returns the instance of a contentType. Instantiate the contentType if not already done\n */\n get(uid: UID.ContentType) {\n return contentTypes[uid];\n },\n\n /**\n * Returns a map with all the contentTypes in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(contentTypes);\n },\n\n /**\n * Registers a contentType\n */\n set(uid: UID.ContentType, contentType: Struct.ContentTypeSchema) {\n contentTypes[uid] = contentType;\n return this;\n },\n\n /**\n * Registers a map of contentTypes for a specific namespace\n */\n add(namespace: string, newContentTypes: ContentTypesInput) {\n validateKeySameToSingularName(newContentTypes);\n\n for (const rawCtName of Object.keys(newContentTypes)) {\n const uid = addNamespace(rawCtName, namespace);\n\n if (has(uid, contentTypes)) {\n throw new Error(`Content-type ${uid} has already been registered.`);\n }\n\n contentTypes[uid] = createContentType(uid, newContentTypes[rawCtName]);\n }\n },\n\n /**\n * Wraps a contentType to extend it\n */\n extend(ctUID: UID.ContentType, extendFn: ContentTypeExtendFn) {\n const currentContentType = this.get(ctUID);\n\n if (!currentContentType) {\n throw new Error(`Content-Type ${ctUID} doesn't exist`);\n }\n\n extendFn(currentContentType);\n\n return this;\n },\n };\n};\n\nexport default contentTypesRegistry;\n"],"names":["namespace","pickBy","hasNamespace","addNamespace","has","createContentType"],"mappings":";;;;AAQA,MAAM,gCAAgC,CAAC,iBAAoC;AACzE,aAAW,UAAU,OAAO,KAAK,YAAY,GAAG;AACxC,UAAA,cAAc,aAAa,MAAM;AAEvC,QAAI,WAAW,YAAY,OAAO,KAAK,cAAc;AACnD,YAAM,IAAI;AAAA,QACR,6EAA6E,MAAM,QAAQ,YAAY,OAAO,KAAK,YAAY;AAAA,MAAA;AAAA,IAEnI;AAAA,EACF;AACF;AAEA,MAAM,uBAAuB,MAAM;AACjC,QAAM,eAAyD,CAAA;AAExD,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,YAAY;AAAA,IACjC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAsB;AACxB,aAAO,aAAa,GAAG;AAAA,IACzB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AACjB,aAAAC,GAAA,OAAO,CAAC,GAAG,QAAQC,UAAAA,aAAa,KAAKF,WAAS,CAAC,EAAE,YAAY;AAAA,IACtE;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAsB,aAAuC;AAC/D,mBAAa,GAAG,IAAI;AACb,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmB,iBAAoC;AACzD,oCAA8B,eAAe;AAE7C,iBAAW,aAAa,OAAO,KAAK,eAAe,GAAG;AAC9C,cAAA,MAAMG,UAAAA,aAAa,WAAWH,WAAS;AAEzC,YAAAI,GAAA,IAAI,KAAK,YAAY,GAAG;AAC1B,gBAAM,IAAI,MAAM,gBAAgB,GAAG,+BAA+B;AAAA,QACpE;AAEA,qBAAa,GAAG,IAAIC,MAAA,kBAAkB,KAAK,gBAAgB,SAAS,CAAC;AAAA,MACvE;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,OAAwB,UAA+B;AACtD,YAAA,qBAAqB,KAAK,IAAI,KAAK;AAEzC,UAAI,CAAC,oBAAoB;AACvB,cAAM,IAAI,MAAM,gBAAgB,KAAK,gBAAgB;AAAA,MACvD;AAEA,eAAS,kBAAkB;AAEpB,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const namespace = require("./namespace.js");
4
4
  const controllersRegistry = (strapi) => {
5
5
  const controllers = {};
@@ -28,7 +28,7 @@ const controllersRegistry = (strapi) => {
28
28
  * Returns a map with all the controller in a namespace
29
29
  */
30
30
  getAll(namespace$1) {
31
- const filteredControllers = _.pickBy((_2, uid) => namespace.hasNamespace(uid, namespace$1))(controllers);
31
+ const filteredControllers = fp.pickBy((_, uid) => namespace.hasNamespace(uid, namespace$1))(controllers);
32
32
  const map = {};
33
33
  for (const uid of Object.keys(filteredControllers)) {
34
34
  Object.defineProperty(map, uid, {
@@ -55,7 +55,7 @@ const controllersRegistry = (strapi) => {
55
55
  for (const controllerName of Object.keys(newControllers)) {
56
56
  const controller = newControllers[controllerName];
57
57
  const uid = namespace.addNamespace(controllerName, namespace$1);
58
- if (_.has(uid, controllers)) {
58
+ if (fp.has(uid, controllers)) {
59
59
  throw new Error(`Controller ${uid} has already been registered.`);
60
60
  }
61
61
  controllers[uid] = controller;
@@ -1 +1 @@
1
- {"version":3,"file":"controllers.js","sources":["../../src/registries/controllers.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core, UID } from '@strapi/types';\nimport { addNamespace, hasNamespace } from './namespace';\n\nexport type ControllerFactory =\n | ((params: { strapi: Core.Strapi }) => Core.Controller)\n | Core.Controller;\nexport type ControllerFactoryMap = Record<UID.Controller, ControllerFactory>;\nexport type ControllerMap = Record<UID.Controller, Core.Controller>;\nexport type ControllerExtendFn = (service: Core.Controller) => Core.Controller;\n\nconst controllersRegistry = (strapi: Core.Strapi) => {\n const controllers: ControllerFactoryMap = {};\n const instances: ControllerMap = {};\n\n return {\n /**\n * Returns this list of registered controllers uids\n */\n keys() {\n return Object.keys(controllers);\n },\n\n /**\n * Returns the instance of a controller. Instantiate the controller if not already done\n */\n get(uid: UID.Controller) {\n if (instances[uid]) {\n return instances[uid];\n }\n\n const controller = controllers[uid];\n\n if (controller) {\n instances[uid] = typeof controller === 'function' ? controller({ strapi }) : controller;\n return instances[uid];\n }\n },\n\n /**\n * Returns a map with all the controller in a namespace\n */\n getAll(namespace: string) {\n const filteredControllers = pickBy((_, uid) => hasNamespace(uid, namespace))(controllers);\n\n const map = {};\n for (const uid of Object.keys(filteredControllers) as UID.Controller[]) {\n Object.defineProperty(map, uid, {\n enumerable: true,\n get: () => {\n return this.get(uid);\n },\n });\n }\n\n return map;\n },\n\n /**\n * Registers a controller\n */\n set(uid: UID.Controller, value: ControllerFactory) {\n controllers[uid] = value;\n delete instances[uid];\n return this;\n },\n\n /**\n * Registers a map of controllers for a specific namespace\n */\n add(namespace: string, newControllers: ControllerFactoryMap) {\n for (const controllerName of Object.keys(newControllers) as UID.Controller[]) {\n const controller = newControllers[controllerName];\n const uid = addNamespace(controllerName, namespace) as UID.Controller;\n\n if (has(uid, controllers)) {\n throw new Error(`Controller ${uid} has already been registered.`);\n }\n\n controllers[uid] = controller;\n }\n\n return this;\n },\n\n /**\n * Wraps a controller to extend it\n */\n extend(controllerUID: UID.Controller, extendFn: ControllerExtendFn) {\n const currentController = this.get(controllerUID);\n\n if (!currentController) {\n throw new Error(`Controller ${controllerUID} doesn't exist`);\n }\n\n const newController = extendFn(currentController);\n instances[controllerUID] = newController;\n\n return this;\n },\n };\n};\n\nexport default controllersRegistry;\n"],"names":["namespace","pickBy","_","hasNamespace","addNamespace","has"],"mappings":";;;AAWM,MAAA,sBAAsB,CAAC,WAAwB;AACnD,QAAM,cAAoC,CAAA;AAC1C,QAAM,YAA2B,CAAA;AAE1B,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,WAAW;AAAA,IAChC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB;AACnB,UAAA,UAAU,GAAG,GAAG;AAClB,eAAO,UAAU,GAAG;AAAA,MACtB;AAEM,YAAA,aAAa,YAAY,GAAG;AAElC,UAAI,YAAY;AACJ,kBAAA,GAAG,IAAI,OAAO,eAAe,aAAa,WAAW,EAAE,QAAQ,IAAI;AAC7E,eAAO,UAAU,GAAG;AAAA,MACtB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AAClB,YAAA,sBAAsBC,EAAAA,OAAO,CAACC,IAAG,QAAQC,uBAAa,KAAKH,WAAS,CAAC,EAAE,WAAW;AAExF,YAAM,MAAM,CAAA;AACZ,iBAAW,OAAO,OAAO,KAAK,mBAAmB,GAAuB;AAC/D,eAAA,eAAe,KAAK,KAAK;AAAA,UAC9B,YAAY;AAAA,UACZ,KAAK,MAAM;AACF,mBAAA,KAAK,IAAI,GAAG;AAAA,UACrB;AAAA,QAAA,CACD;AAAA,MACH;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB,OAA0B;AACjD,kBAAY,GAAG,IAAI;AACnB,aAAO,UAAU,GAAG;AACb,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmB,gBAAsC;AAC3D,iBAAW,kBAAkB,OAAO,KAAK,cAAc,GAAuB;AACtE,cAAA,aAAa,eAAe,cAAc;AAC1C,cAAA,MAAMI,UAAAA,aAAa,gBAAgBJ,WAAS;AAE9C,YAAAK,EAAA,IAAI,KAAK,WAAW,GAAG;AACzB,gBAAM,IAAI,MAAM,cAAc,GAAG,+BAA+B;AAAA,QAClE;AAEA,oBAAY,GAAG,IAAI;AAAA,MACrB;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,eAA+B,UAA8B;AAC5D,YAAA,oBAAoB,KAAK,IAAI,aAAa;AAEhD,UAAI,CAAC,mBAAmB;AACtB,cAAM,IAAI,MAAM,cAAc,aAAa,gBAAgB;AAAA,MAC7D;AAEM,YAAA,gBAAgB,SAAS,iBAAiB;AAChD,gBAAU,aAAa,IAAI;AAEpB,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"controllers.js","sources":["../../src/registries/controllers.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core, UID } from '@strapi/types';\nimport { addNamespace, hasNamespace } from './namespace';\n\nexport type ControllerFactory =\n | ((params: { strapi: Core.Strapi }) => Core.Controller)\n | Core.Controller;\nexport type ControllerFactoryMap = Record<UID.Controller, ControllerFactory>;\nexport type ControllerMap = Record<UID.Controller, Core.Controller>;\nexport type ControllerExtendFn = (service: Core.Controller) => Core.Controller;\n\nconst controllersRegistry = (strapi: Core.Strapi) => {\n const controllers: ControllerFactoryMap = {};\n const instances: ControllerMap = {};\n\n return {\n /**\n * Returns this list of registered controllers uids\n */\n keys() {\n return Object.keys(controllers);\n },\n\n /**\n * Returns the instance of a controller. Instantiate the controller if not already done\n */\n get(uid: UID.Controller) {\n if (instances[uid]) {\n return instances[uid];\n }\n\n const controller = controllers[uid];\n\n if (controller) {\n instances[uid] = typeof controller === 'function' ? controller({ strapi }) : controller;\n return instances[uid];\n }\n },\n\n /**\n * Returns a map with all the controller in a namespace\n */\n getAll(namespace: string) {\n const filteredControllers = pickBy((_, uid) => hasNamespace(uid, namespace))(controllers);\n\n const map = {};\n for (const uid of Object.keys(filteredControllers) as UID.Controller[]) {\n Object.defineProperty(map, uid, {\n enumerable: true,\n get: () => {\n return this.get(uid);\n },\n });\n }\n\n return map;\n },\n\n /**\n * Registers a controller\n */\n set(uid: UID.Controller, value: ControllerFactory) {\n controllers[uid] = value;\n delete instances[uid];\n return this;\n },\n\n /**\n * Registers a map of controllers for a specific namespace\n */\n add(namespace: string, newControllers: ControllerFactoryMap) {\n for (const controllerName of Object.keys(newControllers) as UID.Controller[]) {\n const controller = newControllers[controllerName];\n const uid = addNamespace(controllerName, namespace) as UID.Controller;\n\n if (has(uid, controllers)) {\n throw new Error(`Controller ${uid} has already been registered.`);\n }\n\n controllers[uid] = controller;\n }\n\n return this;\n },\n\n /**\n * Wraps a controller to extend it\n */\n extend(controllerUID: UID.Controller, extendFn: ControllerExtendFn) {\n const currentController = this.get(controllerUID);\n\n if (!currentController) {\n throw new Error(`Controller ${controllerUID} doesn't exist`);\n }\n\n const newController = extendFn(currentController);\n instances[controllerUID] = newController;\n\n return this;\n },\n };\n};\n\nexport default controllersRegistry;\n"],"names":["namespace","pickBy","hasNamespace","addNamespace","has"],"mappings":";;;AAWM,MAAA,sBAAsB,CAAC,WAAwB;AACnD,QAAM,cAAoC,CAAA;AAC1C,QAAM,YAA2B,CAAA;AAE1B,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,WAAW;AAAA,IAChC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB;AACnB,UAAA,UAAU,GAAG,GAAG;AAClB,eAAO,UAAU,GAAG;AAAA,MACtB;AAEM,YAAA,aAAa,YAAY,GAAG;AAElC,UAAI,YAAY;AACJ,kBAAA,GAAG,IAAI,OAAO,eAAe,aAAa,WAAW,EAAE,QAAQ,IAAI;AAC7E,eAAO,UAAU,GAAG;AAAA,MACtB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AAClB,YAAA,sBAAsBC,GAAAA,OAAO,CAAC,GAAG,QAAQC,uBAAa,KAAKF,WAAS,CAAC,EAAE,WAAW;AAExF,YAAM,MAAM,CAAA;AACZ,iBAAW,OAAO,OAAO,KAAK,mBAAmB,GAAuB;AAC/D,eAAA,eAAe,KAAK,KAAK;AAAA,UAC9B,YAAY;AAAA,UACZ,KAAK,MAAM;AACF,mBAAA,KAAK,IAAI,GAAG;AAAA,UACrB;AAAA,QAAA,CACD;AAAA,MACH;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB,OAA0B;AACjD,kBAAY,GAAG,IAAI;AACnB,aAAO,UAAU,GAAG;AACb,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmB,gBAAsC;AAC3D,iBAAW,kBAAkB,OAAO,KAAK,cAAc,GAAuB;AACtE,cAAA,aAAa,eAAe,cAAc;AAC1C,cAAA,MAAMG,UAAAA,aAAa,gBAAgBH,WAAS;AAE9C,YAAAI,GAAA,IAAI,KAAK,WAAW,GAAG;AACzB,gBAAM,IAAI,MAAM,cAAc,GAAG,+BAA+B;AAAA,QAClE;AAEA,oBAAY,GAAG,IAAI;AAAA,MACrB;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,eAA+B,UAA8B;AAC5D,YAAA,oBAAoB,KAAK,IAAI,aAAa;AAEhD,UAAI,CAAC,mBAAmB;AACtB,cAAM,IAAI,MAAM,cAAc,aAAa,gBAAgB;AAAA,MAC7D;AAEM,YAAA,gBAAgB,SAAS,iBAAiB;AAChD,gBAAU,aAAa,IAAI;AAEpB,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const ALLOWED_TYPES = [
4
4
  "biginteger",
5
5
  "boolean",
@@ -34,7 +34,7 @@ const customFieldsRegistry = (strapi) => {
34
34
  add(customField) {
35
35
  const customFieldList = Array.isArray(customField) ? customField : [customField];
36
36
  for (const cf of customFieldList) {
37
- if (!_.has("name", cf) || !_.has("type", cf)) {
37
+ if (!fp.has("name", cf) || !fp.has("type", cf)) {
38
38
  throw new Error(`Custom fields require a 'name' and 'type' key`);
39
39
  }
40
40
  const { name, plugin, type, inputSize } = cf;
@@ -48,7 +48,7 @@ const customFieldsRegistry = (strapi) => {
48
48
  throw new Error(`Custom field name: '${name}' is not a valid object key`);
49
49
  }
50
50
  if (inputSize) {
51
- if (!_.isPlainObject(inputSize) || !_.has("default", inputSize) || !_.has("isResizable", inputSize)) {
51
+ if (!fp.isPlainObject(inputSize) || !fp.has("default", inputSize) || !fp.has("isResizable", inputSize)) {
52
52
  throw new Error(`inputSize should be an object with 'default' and 'isResizable' keys`);
53
53
  }
54
54
  if (![4, 6, 8, 12].includes(inputSize.default)) {
@@ -59,7 +59,7 @@ const customFieldsRegistry = (strapi) => {
59
59
  }
60
60
  }
61
61
  const uid = plugin && strapi.plugin(plugin) ? `plugin::${plugin}.${name}` : `global::${name}`;
62
- if (_.has(uid, customFields)) {
62
+ if (fp.has(uid, customFields)) {
63
63
  throw new Error(`Custom field: '${uid}' has already been registered`);
64
64
  }
65
65
  customFields[uid] = cf;
@@ -1 +1 @@
1
- {"version":3,"file":"custom-fields.js","sources":["../../src/registries/custom-fields.ts"],"sourcesContent":["import { has, isPlainObject } from 'lodash/fp';\n\nimport type { Core, Modules } from '@strapi/types';\n\nconst ALLOWED_TYPES = [\n 'biginteger',\n 'boolean',\n 'date',\n 'datetime',\n 'decimal',\n 'email',\n 'enumeration',\n 'float',\n 'integer',\n 'json',\n 'password',\n 'richtext',\n 'string',\n 'text',\n 'time',\n 'uid',\n] as const;\n\nconst customFieldsRegistry = (strapi: Core.Strapi) => {\n const customFields: Record<string, unknown> = {};\n\n return {\n getAll() {\n return customFields;\n },\n get(customField: string) {\n const registeredCustomField = customFields[customField];\n if (!registeredCustomField) {\n throw new Error(`Could not find Custom Field: ${customField}`);\n }\n\n return registeredCustomField;\n },\n add(\n customField:\n | Modules.CustomFields.CustomFieldServerOptions\n | Modules.CustomFields.CustomFieldServerOptions[]\n ) {\n const customFieldList = Array.isArray(customField) ? customField : [customField];\n\n for (const cf of customFieldList) {\n if (!has('name', cf) || !has('type', cf)) {\n throw new Error(`Custom fields require a 'name' and 'type' key`);\n }\n\n const { name, plugin, type, inputSize } = cf;\n if (!ALLOWED_TYPES.includes(type)) {\n throw new Error(\n `Custom field type: '${type}' is not a valid Strapi type or it can't be used with a Custom Field`\n );\n }\n\n const isValidObjectKey = /^(?![0-9])[a-zA-Z0-9$_-]+$/g;\n if (!isValidObjectKey.test(name)) {\n throw new Error(`Custom field name: '${name}' is not a valid object key`);\n }\n\n // Validate inputSize when provided\n if (inputSize) {\n if (\n !isPlainObject(inputSize) ||\n !has('default', inputSize) ||\n !has('isResizable', inputSize)\n ) {\n throw new Error(`inputSize should be an object with 'default' and 'isResizable' keys`);\n }\n if (![4, 6, 8, 12].includes(inputSize.default)) {\n throw new Error('Custom fields require a valid default input size');\n }\n if (typeof inputSize.isResizable !== 'boolean') {\n throw new Error('Custom fields should specify if their input is resizable');\n }\n }\n\n // When no plugin is specified, or it isn't found in Strapi, default to global\n const uid =\n plugin && strapi.plugin(plugin) ? `plugin::${plugin}.${name}` : `global::${name}`;\n\n if (has(uid, customFields)) {\n throw new Error(`Custom field: '${uid}' has already been registered`);\n }\n\n customFields[uid] = cf;\n }\n },\n };\n};\n\nexport default customFieldsRegistry;\n"],"names":["has","isPlainObject"],"mappings":";;AAIA,MAAM,gBAAgB;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEM,MAAA,uBAAuB,CAAC,WAAwB;AACpD,QAAM,eAAwC,CAAA;AAEvC,SAAA;AAAA,IACL,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,aAAqB;AACjB,YAAA,wBAAwB,aAAa,WAAW;AACtD,UAAI,CAAC,uBAAuB;AAC1B,cAAM,IAAI,MAAM,gCAAgC,WAAW,EAAE;AAAA,MAC/D;AAEO,aAAA;AAAA,IACT;AAAA,IACA,IACE,aAGA;AACA,YAAM,kBAAkB,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW;AAE/E,iBAAW,MAAM,iBAAiB;AAC5B,YAAA,CAACA,EAAAA,IAAI,QAAQ,EAAE,KAAK,CAACA,MAAI,QAAQ,EAAE,GAAG;AAClC,gBAAA,IAAI,MAAM,+CAA+C;AAAA,QACjE;AAEA,cAAM,EAAE,MAAM,QAAQ,MAAM,cAAc;AAC1C,YAAI,CAAC,cAAc,SAAS,IAAI,GAAG;AACjC,gBAAM,IAAI;AAAA,YACR,uBAAuB,IAAI;AAAA,UAAA;AAAA,QAE/B;AAEA,cAAM,mBAAmB;AACzB,YAAI,CAAC,iBAAiB,KAAK,IAAI,GAAG;AAChC,gBAAM,IAAI,MAAM,uBAAuB,IAAI,6BAA6B;AAAA,QAC1E;AAGA,YAAI,WAAW;AACb,cACE,CAACC,EAAA,cAAc,SAAS,KACxB,CAACD,EAAAA,IAAI,WAAW,SAAS,KACzB,CAACA,EAAAA,IAAI,eAAe,SAAS,GAC7B;AACM,kBAAA,IAAI,MAAM,qEAAqE;AAAA,UACvF;AACI,cAAA,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,EAAE,SAAS,UAAU,OAAO,GAAG;AACxC,kBAAA,IAAI,MAAM,kDAAkD;AAAA,UACpE;AACI,cAAA,OAAO,UAAU,gBAAgB,WAAW;AACxC,kBAAA,IAAI,MAAM,0DAA0D;AAAA,UAC5E;AAAA,QACF;AAGA,cAAM,MACJ,UAAU,OAAO,OAAO,MAAM,IAAI,WAAW,MAAM,IAAI,IAAI,KAAK,WAAW,IAAI;AAE7E,YAAAA,EAAA,IAAI,KAAK,YAAY,GAAG;AAC1B,gBAAM,IAAI,MAAM,kBAAkB,GAAG,+BAA+B;AAAA,QACtE;AAEA,qBAAa,GAAG,IAAI;AAAA,MACtB;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"custom-fields.js","sources":["../../src/registries/custom-fields.ts"],"sourcesContent":["import { has, isPlainObject } from 'lodash/fp';\n\nimport type { Core, Modules } from '@strapi/types';\n\nconst ALLOWED_TYPES = [\n 'biginteger',\n 'boolean',\n 'date',\n 'datetime',\n 'decimal',\n 'email',\n 'enumeration',\n 'float',\n 'integer',\n 'json',\n 'password',\n 'richtext',\n 'string',\n 'text',\n 'time',\n 'uid',\n] as const;\n\nconst customFieldsRegistry = (strapi: Core.Strapi) => {\n const customFields: Record<string, unknown> = {};\n\n return {\n getAll() {\n return customFields;\n },\n get(customField: string) {\n const registeredCustomField = customFields[customField];\n if (!registeredCustomField) {\n throw new Error(`Could not find Custom Field: ${customField}`);\n }\n\n return registeredCustomField;\n },\n add(\n customField:\n | Modules.CustomFields.CustomFieldServerOptions\n | Modules.CustomFields.CustomFieldServerOptions[]\n ) {\n const customFieldList = Array.isArray(customField) ? customField : [customField];\n\n for (const cf of customFieldList) {\n if (!has('name', cf) || !has('type', cf)) {\n throw new Error(`Custom fields require a 'name' and 'type' key`);\n }\n\n const { name, plugin, type, inputSize } = cf;\n if (!ALLOWED_TYPES.includes(type)) {\n throw new Error(\n `Custom field type: '${type}' is not a valid Strapi type or it can't be used with a Custom Field`\n );\n }\n\n const isValidObjectKey = /^(?![0-9])[a-zA-Z0-9$_-]+$/g;\n if (!isValidObjectKey.test(name)) {\n throw new Error(`Custom field name: '${name}' is not a valid object key`);\n }\n\n // Validate inputSize when provided\n if (inputSize) {\n if (\n !isPlainObject(inputSize) ||\n !has('default', inputSize) ||\n !has('isResizable', inputSize)\n ) {\n throw new Error(`inputSize should be an object with 'default' and 'isResizable' keys`);\n }\n if (![4, 6, 8, 12].includes(inputSize.default)) {\n throw new Error('Custom fields require a valid default input size');\n }\n if (typeof inputSize.isResizable !== 'boolean') {\n throw new Error('Custom fields should specify if their input is resizable');\n }\n }\n\n // When no plugin is specified, or it isn't found in Strapi, default to global\n const uid =\n plugin && strapi.plugin(plugin) ? `plugin::${plugin}.${name}` : `global::${name}`;\n\n if (has(uid, customFields)) {\n throw new Error(`Custom field: '${uid}' has already been registered`);\n }\n\n customFields[uid] = cf;\n }\n },\n };\n};\n\nexport default customFieldsRegistry;\n"],"names":["has","isPlainObject"],"mappings":";;AAIA,MAAM,gBAAgB;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEM,MAAA,uBAAuB,CAAC,WAAwB;AACpD,QAAM,eAAwC,CAAA;AAEvC,SAAA;AAAA,IACL,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,aAAqB;AACjB,YAAA,wBAAwB,aAAa,WAAW;AACtD,UAAI,CAAC,uBAAuB;AAC1B,cAAM,IAAI,MAAM,gCAAgC,WAAW,EAAE;AAAA,MAC/D;AAEO,aAAA;AAAA,IACT;AAAA,IACA,IACE,aAGA;AACA,YAAM,kBAAkB,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW;AAE/E,iBAAW,MAAM,iBAAiB;AAC5B,YAAA,CAACA,GAAAA,IAAI,QAAQ,EAAE,KAAK,CAACA,OAAI,QAAQ,EAAE,GAAG;AAClC,gBAAA,IAAI,MAAM,+CAA+C;AAAA,QACjE;AAEA,cAAM,EAAE,MAAM,QAAQ,MAAM,cAAc;AAC1C,YAAI,CAAC,cAAc,SAAS,IAAI,GAAG;AACjC,gBAAM,IAAI;AAAA,YACR,uBAAuB,IAAI;AAAA,UAAA;AAAA,QAE/B;AAEA,cAAM,mBAAmB;AACzB,YAAI,CAAC,iBAAiB,KAAK,IAAI,GAAG;AAChC,gBAAM,IAAI,MAAM,uBAAuB,IAAI,6BAA6B;AAAA,QAC1E;AAGA,YAAI,WAAW;AACb,cACE,CAACC,GAAA,cAAc,SAAS,KACxB,CAACD,GAAAA,IAAI,WAAW,SAAS,KACzB,CAACA,GAAAA,IAAI,eAAe,SAAS,GAC7B;AACM,kBAAA,IAAI,MAAM,qEAAqE;AAAA,UACvF;AACI,cAAA,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,EAAE,SAAS,UAAU,OAAO,GAAG;AACxC,kBAAA,IAAI,MAAM,kDAAkD;AAAA,UACpE;AACI,cAAA,OAAO,UAAU,gBAAgB,WAAW;AACxC,kBAAA,IAAI,MAAM,0DAA0D;AAAA,UAC5E;AAAA,QACF;AAGA,cAAM,MACJ,UAAU,OAAO,OAAO,MAAM,IAAI,WAAW,MAAM,IAAI,IAAI,KAAK,WAAW,IAAI;AAE7E,YAAAA,GAAA,IAAI,KAAK,YAAY,GAAG;AAC1B,gBAAM,IAAI,MAAM,kBAAkB,GAAG,+BAA+B;AAAA,QACtE;AAEA,qBAAa,GAAG,IAAI;AAAA,MACtB;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const namespace = require("./namespace.js");
4
4
  const hooksRegistry = () => {
5
5
  const hooks = {};
@@ -20,7 +20,7 @@ const hooksRegistry = () => {
20
20
  * Returns a map with all the hooks in a namespace
21
21
  */
22
22
  getAll(namespace$1) {
23
- return _.pickBy((_2, uid) => namespace.hasNamespace(uid, namespace$1))(hooks);
23
+ return fp.pickBy((_, uid) => namespace.hasNamespace(uid, namespace$1))(hooks);
24
24
  },
25
25
  /**
26
26
  * Registers a hook
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sources":["../../src/registries/hooks.ts"],"sourcesContent":["import { pickBy } from 'lodash/fp';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype Handler = (context: any) => any;\n\ntype AsyncHook = {\n handlers: Handler[];\n register(handler: Handler): AsyncHook;\n delete(handler: Handler): AsyncHook;\n call(): Promise<void>;\n};\n\ntype SyncHook = {\n get handlers(): Handler[];\n register(handler: Handler): SyncHook;\n delete(handler: Handler): SyncHook;\n call(): void;\n};\n\nexport type Hook = AsyncHook | SyncHook;\n\ntype HookExtendFn = (hook: Hook) => Hook;\n\nconst hooksRegistry = () => {\n const hooks: Record<string, Hook> = {};\n\n return {\n /**\n * Returns this list of registered hooks uids\n */\n keys() {\n return Object.keys(hooks);\n },\n\n /**\n * Returns the instance of a hook.\n */\n get(uid: string) {\n return hooks[uid];\n },\n\n /**\n * Returns a map with all the hooks in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(hooks);\n },\n\n /**\n * Registers a hook\n */\n set(uid: string, hook: Hook) {\n hooks[uid] = hook;\n return this;\n },\n\n /**\n * Registers a map of hooks for a specific namespace\n */\n add(namespace: string, hooks: Record<string, Hook>) {\n for (const hookName of Object.keys(hooks)) {\n const hook = hooks[hookName];\n const uid = addNamespace(hookName, namespace);\n\n this.set(uid, hook);\n }\n\n return this;\n },\n\n /**\n * Wraps a hook to extend it\n */\n extend(uid: string, extendFn: HookExtendFn) {\n const currentHook = this.get(uid);\n\n if (!currentHook) {\n throw new Error(`Hook ${uid} doesn't exist`);\n }\n\n const newHook = extendFn(currentHook);\n hooks[uid] = newHook;\n\n return this;\n },\n };\n};\n\nexport default hooksRegistry;\n"],"names":["namespace","pickBy","_","hasNamespace","hooks","addNamespace"],"mappings":";;;AAuBA,MAAM,gBAAgB,MAAM;AAC1B,QAAM,QAA8B,CAAA;AAE7B,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,KAAK;AAAA,IAC1B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa;AACf,aAAO,MAAM,GAAG;AAAA,IAClB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AACjB,aAAAC,EAAA,OAAO,CAACC,IAAG,QAAQC,UAAAA,aAAa,KAAKH,WAAS,CAAC,EAAE,KAAK;AAAA,IAC/D;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa,MAAY;AAC3B,YAAM,GAAG,IAAI;AACN,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmBI,QAA6B;AAClD,iBAAW,YAAY,OAAO,KAAKA,MAAK,GAAG;AACnC,cAAA,OAAOA,OAAM,QAAQ;AACrB,cAAA,MAAMC,UAAAA,aAAa,UAAUL,WAAS;AAEvC,aAAA,IAAI,KAAK,IAAI;AAAA,MACpB;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,KAAa,UAAwB;AACpC,YAAA,cAAc,KAAK,IAAI,GAAG;AAEhC,UAAI,CAAC,aAAa;AAChB,cAAM,IAAI,MAAM,QAAQ,GAAG,gBAAgB;AAAA,MAC7C;AAEM,YAAA,UAAU,SAAS,WAAW;AACpC,YAAM,GAAG,IAAI;AAEN,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"hooks.js","sources":["../../src/registries/hooks.ts"],"sourcesContent":["import { pickBy } from 'lodash/fp';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype Handler = (context: any) => any;\n\ntype AsyncHook = {\n handlers: Handler[];\n register(handler: Handler): AsyncHook;\n delete(handler: Handler): AsyncHook;\n call(): Promise<void>;\n};\n\ntype SyncHook = {\n get handlers(): Handler[];\n register(handler: Handler): SyncHook;\n delete(handler: Handler): SyncHook;\n call(): void;\n};\n\nexport type Hook = AsyncHook | SyncHook;\n\ntype HookExtendFn = (hook: Hook) => Hook;\n\nconst hooksRegistry = () => {\n const hooks: Record<string, Hook> = {};\n\n return {\n /**\n * Returns this list of registered hooks uids\n */\n keys() {\n return Object.keys(hooks);\n },\n\n /**\n * Returns the instance of a hook.\n */\n get(uid: string) {\n return hooks[uid];\n },\n\n /**\n * Returns a map with all the hooks in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(hooks);\n },\n\n /**\n * Registers a hook\n */\n set(uid: string, hook: Hook) {\n hooks[uid] = hook;\n return this;\n },\n\n /**\n * Registers a map of hooks for a specific namespace\n */\n add(namespace: string, hooks: Record<string, Hook>) {\n for (const hookName of Object.keys(hooks)) {\n const hook = hooks[hookName];\n const uid = addNamespace(hookName, namespace);\n\n this.set(uid, hook);\n }\n\n return this;\n },\n\n /**\n * Wraps a hook to extend it\n */\n extend(uid: string, extendFn: HookExtendFn) {\n const currentHook = this.get(uid);\n\n if (!currentHook) {\n throw new Error(`Hook ${uid} doesn't exist`);\n }\n\n const newHook = extendFn(currentHook);\n hooks[uid] = newHook;\n\n return this;\n },\n };\n};\n\nexport default hooksRegistry;\n"],"names":["namespace","pickBy","hasNamespace","hooks","addNamespace"],"mappings":";;;AAuBA,MAAM,gBAAgB,MAAM;AAC1B,QAAM,QAA8B,CAAA;AAE7B,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,KAAK;AAAA,IAC1B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa;AACf,aAAO,MAAM,GAAG;AAAA,IAClB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AACjB,aAAAC,GAAA,OAAO,CAAC,GAAG,QAAQC,UAAAA,aAAa,KAAKF,WAAS,CAAC,EAAE,KAAK;AAAA,IAC/D;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa,MAAY;AAC3B,YAAM,GAAG,IAAI;AACN,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmBG,QAA6B;AAClD,iBAAW,YAAY,OAAO,KAAKA,MAAK,GAAG;AACnC,cAAA,OAAOA,OAAM,QAAQ;AACrB,cAAA,MAAMC,UAAAA,aAAa,UAAUJ,WAAS;AAEvC,aAAA,IAAI,KAAK,IAAI;AAAA,MACpB;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,KAAa,UAAwB;AACpC,YAAA,cAAc,KAAK,IAAI,GAAG;AAEhC,UAAI,CAAC,aAAa;AAChB,cAAM,IAAI,MAAM,QAAQ,GAAG,gBAAgB;AAAA,MAC7C;AAEM,YAAA,UAAU,SAAS,WAAW;AACpC,YAAM,GAAG,IAAI;AAEN,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const namespace = require("./namespace.js");
4
4
  const middlewaresRegistry = () => {
5
5
  const middlewares = {};
@@ -20,7 +20,7 @@ const middlewaresRegistry = () => {
20
20
  * Returns a map with all the middlewares in a namespace
21
21
  */
22
22
  getAll(namespace$1) {
23
- return _.pickBy((_2, uid) => namespace.hasNamespace(uid, namespace$1))(middlewares);
23
+ return fp.pickBy((_, uid) => namespace.hasNamespace(uid, namespace$1))(middlewares);
24
24
  },
25
25
  /**
26
26
  * Registers a middleware
@@ -36,7 +36,7 @@ const middlewaresRegistry = () => {
36
36
  for (const middlewareName of Object.keys(rawMiddlewares)) {
37
37
  const middleware = rawMiddlewares[middlewareName];
38
38
  const uid = namespace.addNamespace(middlewareName, namespace$1);
39
- if (_.has(uid, middlewares)) {
39
+ if (fp.has(uid, middlewares)) {
40
40
  throw new Error(`Middleware ${uid} has already been registered.`);
41
41
  }
42
42
  middlewares[uid] = middleware;
@@ -1 +1 @@
1
- {"version":3,"file":"middlewares.js","sources":["../../src/registries/middlewares.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core, UID } from '@strapi/types';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype MiddlewareExtendFn = (middleware: Core.Middleware) => Core.Middleware;\n\n// TODO: move instantiation part here instead of in the server service\nconst middlewaresRegistry = () => {\n const middlewares: Record<UID.Middleware, Core.Middleware> = {};\n\n return {\n /**\n * Returns this list of registered middlewares uids\n */\n keys() {\n return Object.keys(middlewares);\n },\n\n /**\n * Returns the instance of a middleware. Instantiate the middleware if not already done\n */\n get(uid: UID.Middleware) {\n return middlewares[uid];\n },\n\n /**\n * Returns a map with all the middlewares in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(middlewares);\n },\n\n /**\n * Registers a middleware\n */\n set(uid: UID.Middleware, middleware: Core.Middleware) {\n middlewares[uid] = middleware;\n return this;\n },\n\n /**\n * Registers a map of middlewares for a specific namespace\n */\n add(namespace: string, rawMiddlewares: Record<string, Core.Middleware> = {}) {\n for (const middlewareName of Object.keys(rawMiddlewares)) {\n const middleware = rawMiddlewares[middlewareName];\n const uid = addNamespace(middlewareName, namespace) as UID.Middleware;\n\n if (has(uid, middlewares)) {\n throw new Error(`Middleware ${uid} has already been registered.`);\n }\n middlewares[uid] = middleware;\n }\n },\n\n /**\n * Wraps a middleware to extend it\n */\n extend(uid: UID.Middleware, extendFn: MiddlewareExtendFn) {\n const currentMiddleware = this.get(uid);\n\n if (!currentMiddleware) {\n throw new Error(`Middleware ${uid} doesn't exist`);\n }\n\n const newMiddleware = extendFn(currentMiddleware);\n middlewares[uid] = newMiddleware;\n\n return this;\n },\n };\n};\n\nexport default middlewaresRegistry;\n"],"names":["namespace","pickBy","_","hasNamespace","addNamespace","has"],"mappings":";;;AAOA,MAAM,sBAAsB,MAAM;AAChC,QAAM,cAAuD,CAAA;AAEtD,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,WAAW;AAAA,IAChC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB;AACvB,aAAO,YAAY,GAAG;AAAA,IACxB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AACjB,aAAAC,EAAA,OAAO,CAACC,IAAG,QAAQC,UAAAA,aAAa,KAAKH,WAAS,CAAC,EAAE,WAAW;AAAA,IACrE;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB,YAA6B;AACpD,kBAAY,GAAG,IAAI;AACZ,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmB,iBAAkD,IAAI;AAC3E,iBAAW,kBAAkB,OAAO,KAAK,cAAc,GAAG;AAClD,cAAA,aAAa,eAAe,cAAc;AAC1C,cAAA,MAAMI,UAAAA,aAAa,gBAAgBJ,WAAS;AAE9C,YAAAK,EAAA,IAAI,KAAK,WAAW,GAAG;AACzB,gBAAM,IAAI,MAAM,cAAc,GAAG,+BAA+B;AAAA,QAClE;AACA,oBAAY,GAAG,IAAI;AAAA,MACrB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,KAAqB,UAA8B;AAClD,YAAA,oBAAoB,KAAK,IAAI,GAAG;AAEtC,UAAI,CAAC,mBAAmB;AACtB,cAAM,IAAI,MAAM,cAAc,GAAG,gBAAgB;AAAA,MACnD;AAEM,YAAA,gBAAgB,SAAS,iBAAiB;AAChD,kBAAY,GAAG,IAAI;AAEZ,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"middlewares.js","sources":["../../src/registries/middlewares.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core, UID } from '@strapi/types';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype MiddlewareExtendFn = (middleware: Core.Middleware) => Core.Middleware;\n\n// TODO: move instantiation part here instead of in the server service\nconst middlewaresRegistry = () => {\n const middlewares: Record<UID.Middleware, Core.Middleware> = {};\n\n return {\n /**\n * Returns this list of registered middlewares uids\n */\n keys() {\n return Object.keys(middlewares);\n },\n\n /**\n * Returns the instance of a middleware. Instantiate the middleware if not already done\n */\n get(uid: UID.Middleware) {\n return middlewares[uid];\n },\n\n /**\n * Returns a map with all the middlewares in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(middlewares);\n },\n\n /**\n * Registers a middleware\n */\n set(uid: UID.Middleware, middleware: Core.Middleware) {\n middlewares[uid] = middleware;\n return this;\n },\n\n /**\n * Registers a map of middlewares for a specific namespace\n */\n add(namespace: string, rawMiddlewares: Record<string, Core.Middleware> = {}) {\n for (const middlewareName of Object.keys(rawMiddlewares)) {\n const middleware = rawMiddlewares[middlewareName];\n const uid = addNamespace(middlewareName, namespace) as UID.Middleware;\n\n if (has(uid, middlewares)) {\n throw new Error(`Middleware ${uid} has already been registered.`);\n }\n middlewares[uid] = middleware;\n }\n },\n\n /**\n * Wraps a middleware to extend it\n */\n extend(uid: UID.Middleware, extendFn: MiddlewareExtendFn) {\n const currentMiddleware = this.get(uid);\n\n if (!currentMiddleware) {\n throw new Error(`Middleware ${uid} doesn't exist`);\n }\n\n const newMiddleware = extendFn(currentMiddleware);\n middlewares[uid] = newMiddleware;\n\n return this;\n },\n };\n};\n\nexport default middlewaresRegistry;\n"],"names":["namespace","pickBy","hasNamespace","addNamespace","has"],"mappings":";;;AAOA,MAAM,sBAAsB,MAAM;AAChC,QAAM,cAAuD,CAAA;AAEtD,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,WAAW;AAAA,IAChC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB;AACvB,aAAO,YAAY,GAAG;AAAA,IACxB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AACjB,aAAAC,GAAA,OAAO,CAAC,GAAG,QAAQC,UAAAA,aAAa,KAAKF,WAAS,CAAC,EAAE,WAAW;AAAA,IACrE;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB,YAA6B;AACpD,kBAAY,GAAG,IAAI;AACZ,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmB,iBAAkD,IAAI;AAC3E,iBAAW,kBAAkB,OAAO,KAAK,cAAc,GAAG;AAClD,cAAA,aAAa,eAAe,cAAc;AAC1C,cAAA,MAAMG,UAAAA,aAAa,gBAAgBH,WAAS;AAE9C,YAAAI,GAAA,IAAI,KAAK,WAAW,GAAG;AACzB,gBAAM,IAAI,MAAM,cAAc,GAAG,+BAA+B;AAAA,QAClE;AACA,oBAAY,GAAG,IAAI;AAAA,MACrB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,KAAqB,UAA8B;AAClD,YAAA,oBAAoB,KAAK,IAAI,GAAG;AAEtC,UAAI,CAAC,mBAAmB;AACtB,cAAM,IAAI,MAAM,cAAc,GAAG,gBAAgB;AAAA,MACnD;AAEM,YAAA,gBAAgB,SAAS,iBAAiB;AAChD,kBAAY,GAAG,IAAI;AAEZ,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const index = require("../domain/module/index.js");
4
4
  const modulesRegistry = (strapi) => {
5
5
  const modules = {};
@@ -8,10 +8,10 @@ const modulesRegistry = (strapi) => {
8
8
  return modules[namespace];
9
9
  },
10
10
  getAll(prefix = "") {
11
- return _.pickBy((mod, namespace) => namespace.startsWith(prefix))(modules);
11
+ return fp.pickBy((mod, namespace) => namespace.startsWith(prefix))(modules);
12
12
  },
13
13
  add(namespace, rawModule) {
14
- if (_.has(namespace, modules)) {
14
+ if (fp.has(namespace, modules)) {
15
15
  throw new Error(`Module ${namespace} has already been registered.`);
16
16
  }
17
17
  modules[namespace] = index.createModule(namespace, rawModule, strapi);
@@ -1 +1 @@
1
- {"version":3,"file":"modules.js","sources":["../../src/registries/modules.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\nimport { createModule, RawModule, Module } from '../domain/module';\n\ntype ModuleMap = { [namespace: string]: Module };\n\nconst modulesRegistry = (strapi: Core.Strapi) => {\n const modules: ModuleMap = {};\n\n return {\n get(namespace: string) {\n return modules[namespace];\n },\n getAll(prefix = '') {\n return pickBy<ModuleMap>((mod, namespace) => namespace.startsWith(prefix))(modules);\n },\n add(namespace: string, rawModule: RawModule) {\n if (has(namespace, modules)) {\n throw new Error(`Module ${namespace} has already been registered.`);\n }\n\n modules[namespace] = createModule(namespace, rawModule, strapi);\n modules[namespace].load();\n\n return modules[namespace];\n },\n async bootstrap() {\n for (const mod of Object.values(modules)) {\n await mod.bootstrap();\n }\n },\n async register() {\n for (const mod of Object.values(modules)) {\n await mod.register();\n }\n },\n async destroy() {\n for (const mod of Object.values(modules)) {\n await mod.destroy();\n }\n },\n };\n};\n\nexport default modulesRegistry;\n"],"names":["pickBy","has","createModule"],"mappings":";;;AAMM,MAAA,kBAAkB,CAAC,WAAwB;AAC/C,QAAM,UAAqB,CAAA;AAEpB,SAAA;AAAA,IACL,IAAI,WAAmB;AACrB,aAAO,QAAQ,SAAS;AAAA,IAC1B;AAAA,IACA,OAAO,SAAS,IAAI;AACX,aAAAA,EAAA,OAAkB,CAAC,KAAK,cAAc,UAAU,WAAW,MAAM,CAAC,EAAE,OAAO;AAAA,IACpF;AAAA,IACA,IAAI,WAAmB,WAAsB;AACvC,UAAAC,EAAA,IAAI,WAAW,OAAO,GAAG;AAC3B,cAAM,IAAI,MAAM,UAAU,SAAS,+BAA+B;AAAA,MACpE;AAEA,cAAQ,SAAS,IAAIC,MAAAA,aAAa,WAAW,WAAW,MAAM;AACtD,cAAA,SAAS,EAAE;AAEnB,aAAO,QAAQ,SAAS;AAAA,IAC1B;AAAA,IACA,MAAM,YAAY;AAChB,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,IACA,MAAM,WAAW;AACf,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,IACA,MAAM,UAAU;AACd,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"modules.js","sources":["../../src/registries/modules.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\nimport { createModule, RawModule, Module } from '../domain/module';\n\ntype ModuleMap = { [namespace: string]: Module };\n\nconst modulesRegistry = (strapi: Core.Strapi) => {\n const modules: ModuleMap = {};\n\n return {\n get(namespace: string) {\n return modules[namespace];\n },\n getAll(prefix = '') {\n return pickBy<ModuleMap>((mod, namespace) => namespace.startsWith(prefix))(modules);\n },\n add(namespace: string, rawModule: RawModule) {\n if (has(namespace, modules)) {\n throw new Error(`Module ${namespace} has already been registered.`);\n }\n\n modules[namespace] = createModule(namespace, rawModule, strapi);\n modules[namespace].load();\n\n return modules[namespace];\n },\n async bootstrap() {\n for (const mod of Object.values(modules)) {\n await mod.bootstrap();\n }\n },\n async register() {\n for (const mod of Object.values(modules)) {\n await mod.register();\n }\n },\n async destroy() {\n for (const mod of Object.values(modules)) {\n await mod.destroy();\n }\n },\n };\n};\n\nexport default modulesRegistry;\n"],"names":["pickBy","has","createModule"],"mappings":";;;AAMM,MAAA,kBAAkB,CAAC,WAAwB;AAC/C,QAAM,UAAqB,CAAA;AAEpB,SAAA;AAAA,IACL,IAAI,WAAmB;AACrB,aAAO,QAAQ,SAAS;AAAA,IAC1B;AAAA,IACA,OAAO,SAAS,IAAI;AACX,aAAAA,GAAA,OAAkB,CAAC,KAAK,cAAc,UAAU,WAAW,MAAM,CAAC,EAAE,OAAO;AAAA,IACpF;AAAA,IACA,IAAI,WAAmB,WAAsB;AACvC,UAAAC,GAAA,IAAI,WAAW,OAAO,GAAG;AAC3B,cAAM,IAAI,MAAM,UAAU,SAAS,+BAA+B;AAAA,MACpE;AAEA,cAAQ,SAAS,IAAIC,MAAAA,aAAa,WAAW,WAAW,MAAM;AACtD,cAAA,SAAS,EAAE;AAEnB,aAAO,QAAQ,SAAS;AAAA,IAC1B;AAAA,IACA,MAAM,YAAY;AAChB,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,IACA,MAAM,WAAW;AACf,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,IACA,MAAM,UAAU;AACd,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const pluginsRegistry = (strapi) => {
4
4
  const plugins = {};
5
5
  return {
@@ -10,7 +10,7 @@ const pluginsRegistry = (strapi) => {
10
10
  return plugins;
11
11
  },
12
12
  add(name, pluginConfig) {
13
- if (_.has(name, plugins)) {
13
+ if (fp.has(name, plugins)) {
14
14
  throw new Error(`Plugin ${name} has already been registered.`);
15
15
  }
16
16
  const pluginModule = strapi.get("modules").add(`plugin::${name}`, pluginConfig);
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.js","sources":["../../src/registries/plugins.ts"],"sourcesContent":["import { has } from 'lodash/fp';\n\nimport type { Core } from '@strapi/types';\n\ntype PluginMap = Record<string, Core.Plugin>;\n\nconst pluginsRegistry = (strapi: Core.Strapi) => {\n const plugins: PluginMap = {};\n\n return {\n get(name: string) {\n return plugins[name];\n },\n getAll() {\n return plugins;\n },\n add(name: string, pluginConfig: Core.Plugin) {\n if (has(name, plugins)) {\n throw new Error(`Plugin ${name} has already been registered.`);\n }\n\n const pluginModule = strapi.get('modules').add(`plugin::${name}`, pluginConfig);\n plugins[name] = pluginModule;\n\n return plugins[name];\n },\n };\n};\n\nexport default pluginsRegistry;\n"],"names":["has"],"mappings":";;AAMM,MAAA,kBAAkB,CAAC,WAAwB;AAC/C,QAAM,UAAqB,CAAA;AAEpB,SAAA;AAAA,IACL,IAAI,MAAc;AAChB,aAAO,QAAQ,IAAI;AAAA,IACrB;AAAA,IACA,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,MAAc,cAA2B;AACvC,UAAAA,EAAA,IAAI,MAAM,OAAO,GAAG;AACtB,cAAM,IAAI,MAAM,UAAU,IAAI,+BAA+B;AAAA,MAC/D;AAEM,YAAA,eAAe,OAAO,IAAI,SAAS,EAAE,IAAI,WAAW,IAAI,IAAI,YAAY;AAC9E,cAAQ,IAAI,IAAI;AAEhB,aAAO,QAAQ,IAAI;AAAA,IACrB;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"plugins.js","sources":["../../src/registries/plugins.ts"],"sourcesContent":["import { has } from 'lodash/fp';\n\nimport type { Core } from '@strapi/types';\n\ntype PluginMap = Record<string, Core.Plugin>;\n\nconst pluginsRegistry = (strapi: Core.Strapi) => {\n const plugins: PluginMap = {};\n\n return {\n get(name: string) {\n return plugins[name];\n },\n getAll() {\n return plugins;\n },\n add(name: string, pluginConfig: Core.Plugin) {\n if (has(name, plugins)) {\n throw new Error(`Plugin ${name} has already been registered.`);\n }\n\n const pluginModule = strapi.get('modules').add(`plugin::${name}`, pluginConfig);\n plugins[name] = pluginModule;\n\n return plugins[name];\n },\n };\n};\n\nexport default pluginsRegistry;\n"],"names":["has"],"mappings":";;AAMM,MAAA,kBAAkB,CAAC,WAAwB;AAC/C,QAAM,UAAqB,CAAA;AAEpB,SAAA;AAAA,IACL,IAAI,MAAc;AAChB,aAAO,QAAQ,IAAI;AAAA,IACrB;AAAA,IACA,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,MAAc,cAA2B;AACvC,UAAAA,GAAA,IAAI,MAAM,OAAO,GAAG;AACtB,cAAM,IAAI,MAAM,UAAU,IAAI,+BAA+B;AAAA,MAC/D;AAEM,YAAA,eAAe,OAAO,IAAI,SAAS,EAAE,IAAI,WAAW,IAAI,IAAI,YAAY;AAC9E,cAAQ,IAAI,IAAI;AAEhB,aAAO,QAAQ,IAAI;AAAA,IACrB;AAAA,EAAA;AAEJ;;"}