@strapi/core 5.0.0-rc.2 → 5.0.0-rc.20

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 (196) hide show
  1. package/dist/Strapi.js +2 -2
  2. package/dist/Strapi.js.map +1 -1
  3. package/dist/configuration/get-dirs.js +2 -2
  4. package/dist/configuration/get-dirs.js.map +1 -1
  5. package/dist/configuration/index.js +2 -2
  6. package/dist/configuration/index.js.map +1 -1
  7. package/dist/core-api/controller/collection-type.js +3 -3
  8. package/dist/core-api/controller/collection-type.js.map +1 -1
  9. package/dist/core-api/controller/index.js +2 -2
  10. package/dist/core-api/controller/index.js.map +1 -1
  11. package/dist/core-api/controller/single-type.js +2 -2
  12. package/dist/core-api/controller/single-type.js.map +1 -1
  13. package/dist/core-api/controller/transform.js +8 -8
  14. package/dist/core-api/controller/transform.js.map +1 -1
  15. package/dist/core-api/service/collection-type.d.ts +2 -2
  16. package/dist/core-api/service/pagination.js +8 -8
  17. package/dist/core-api/service/pagination.js.map +1 -1
  18. package/dist/domain/content-type/index.js +4 -4
  19. package/dist/domain/content-type/index.js.map +1 -1
  20. package/dist/ee/index.js +3 -3
  21. package/dist/ee/index.js.map +1 -1
  22. package/dist/factories.js +4 -4
  23. package/dist/factories.js.map +1 -1
  24. package/dist/factories.mjs.map +1 -1
  25. package/dist/loaders/apis.js +2 -2
  26. package/dist/loaders/apis.js.map +1 -1
  27. package/dist/loaders/plugins/get-enabled-plugins.d.ts.map +1 -1
  28. package/dist/loaders/plugins/get-enabled-plugins.js +39 -11
  29. package/dist/loaders/plugins/get-enabled-plugins.js.map +1 -1
  30. package/dist/loaders/plugins/get-enabled-plugins.mjs +9 -3
  31. package/dist/loaders/plugins/get-enabled-plugins.mjs.map +1 -1
  32. package/dist/loaders/plugins/get-user-plugins-config.js +2 -2
  33. package/dist/loaders/plugins/get-user-plugins-config.js.map +1 -1
  34. package/dist/loaders/plugins/index.d.ts.map +1 -1
  35. package/dist/loaders/plugins/index.js +34 -7
  36. package/dist/loaders/plugins/index.js.map +1 -1
  37. package/dist/loaders/plugins/index.mjs +9 -1
  38. package/dist/loaders/plugins/index.mjs.map +1 -1
  39. package/dist/middlewares/body.js +2 -2
  40. package/dist/middlewares/body.js.map +1 -1
  41. package/dist/middlewares/public.js +2 -2
  42. package/dist/middlewares/public.js.map +1 -1
  43. package/dist/middlewares/query.js.map +1 -1
  44. package/dist/middlewares/query.mjs.map +1 -1
  45. package/dist/middlewares/responses.js +2 -2
  46. package/dist/middlewares/responses.js.map +1 -1
  47. package/dist/middlewares/security.d.ts.map +1 -1
  48. package/dist/middlewares/security.js +4 -4
  49. package/dist/middlewares/security.js.map +1 -1
  50. package/dist/middlewares/security.mjs +1 -1
  51. package/dist/middlewares/security.mjs.map +1 -1
  52. package/dist/middlewares/session.js +2 -2
  53. package/dist/middlewares/session.js.map +1 -1
  54. package/dist/migrations/database/5.0.0-discard-drafts.d.ts +12 -9
  55. package/dist/migrations/database/5.0.0-discard-drafts.d.ts.map +1 -1
  56. package/dist/migrations/database/5.0.0-discard-drafts.js +50 -11
  57. package/dist/migrations/database/5.0.0-discard-drafts.js.map +1 -1
  58. package/dist/migrations/database/5.0.0-discard-drafts.mjs +51 -12
  59. package/dist/migrations/database/5.0.0-discard-drafts.mjs.map +1 -1
  60. package/dist/providers/admin.d.ts.map +1 -1
  61. package/dist/providers/admin.js.map +1 -1
  62. package/dist/providers/admin.mjs.map +1 -1
  63. package/dist/registries/apis.js +2 -2
  64. package/dist/registries/apis.js.map +1 -1
  65. package/dist/registries/components.js +2 -2
  66. package/dist/registries/components.js.map +1 -1
  67. package/dist/registries/content-types.js +3 -3
  68. package/dist/registries/content-types.js.map +1 -1
  69. package/dist/registries/controllers.js +3 -3
  70. package/dist/registries/controllers.js.map +1 -1
  71. package/dist/registries/custom-fields.js +4 -4
  72. package/dist/registries/custom-fields.js.map +1 -1
  73. package/dist/registries/hooks.js +2 -2
  74. package/dist/registries/hooks.js.map +1 -1
  75. package/dist/registries/middlewares.js +3 -3
  76. package/dist/registries/middlewares.js.map +1 -1
  77. package/dist/registries/modules.js +3 -3
  78. package/dist/registries/modules.js.map +1 -1
  79. package/dist/registries/plugins.js +2 -2
  80. package/dist/registries/plugins.js.map +1 -1
  81. package/dist/registries/policies.d.ts +1 -1
  82. package/dist/registries/policies.d.ts.map +1 -1
  83. package/dist/registries/policies.js +5 -5
  84. package/dist/registries/policies.js.map +1 -1
  85. package/dist/registries/policies.mjs +1 -1
  86. package/dist/registries/policies.mjs.map +1 -1
  87. package/dist/registries/services.js +3 -3
  88. package/dist/registries/services.js.map +1 -1
  89. package/dist/services/auth/index.js +3 -3
  90. package/dist/services/auth/index.js.map +1 -1
  91. package/dist/services/content-api/index.d.ts +10 -12
  92. package/dist/services/content-api/index.d.ts.map +1 -1
  93. package/dist/services/content-api/permissions/index.d.ts +10 -12
  94. package/dist/services/content-api/permissions/index.d.ts.map +1 -1
  95. package/dist/services/content-api/permissions/providers/action.d.ts +5 -6
  96. package/dist/services/content-api/permissions/providers/action.d.ts.map +1 -1
  97. package/dist/services/content-api/permissions/providers/condition.d.ts +5 -6
  98. package/dist/services/content-api/permissions/providers/condition.d.ts.map +1 -1
  99. package/dist/services/core-store.js +3 -3
  100. package/dist/services/core-store.js.map +1 -1
  101. package/dist/services/cron.d.ts +3 -3
  102. package/dist/services/cron.d.ts.map +1 -1
  103. package/dist/services/cron.js +3 -3
  104. package/dist/services/cron.js.map +1 -1
  105. package/dist/services/cron.mjs.map +1 -1
  106. package/dist/services/document-service/attributes/index.js +2 -2
  107. package/dist/services/document-service/attributes/index.js.map +1 -1
  108. package/dist/services/document-service/attributes/transforms.js +3 -3
  109. package/dist/services/document-service/attributes/transforms.js.map +1 -1
  110. package/dist/services/document-service/components.js +15 -15
  111. package/dist/services/document-service/components.js.map +1 -1
  112. package/dist/services/document-service/draft-and-publish.js +16 -16
  113. package/dist/services/document-service/draft-and-publish.js.map +1 -1
  114. package/dist/services/document-service/entries.js +5 -5
  115. package/dist/services/document-service/entries.js.map +1 -1
  116. package/dist/services/document-service/internationalization.js +9 -9
  117. package/dist/services/document-service/internationalization.js.map +1 -1
  118. package/dist/services/document-service/params.js +2 -2
  119. package/dist/services/document-service/params.js.map +1 -1
  120. package/dist/services/document-service/repository.d.ts.map +1 -1
  121. package/dist/services/document-service/repository.js +51 -15
  122. package/dist/services/document-service/repository.js.map +1 -1
  123. package/dist/services/document-service/repository.mjs +43 -7
  124. package/dist/services/document-service/repository.mjs.map +1 -1
  125. package/dist/services/document-service/transform/id-transform.js +2 -2
  126. package/dist/services/document-service/transform/id-transform.js.map +1 -1
  127. package/dist/services/document-service/transform/query.js +3 -3
  128. package/dist/services/document-service/transform/query.js.map +1 -1
  129. package/dist/services/document-service/transform/relations/extract/data-ids.js +2 -2
  130. package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -1
  131. package/dist/services/document-service/transform/relations/transform/data-ids.js +2 -2
  132. package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
  133. package/dist/services/document-service/transform/relations/utils/dp.js +2 -2
  134. package/dist/services/document-service/transform/relations/utils/dp.js.map +1 -1
  135. package/dist/services/document-service/transform/relations/utils/map-relation.js +6 -6
  136. package/dist/services/document-service/transform/relations/utils/map-relation.js.map +1 -1
  137. package/dist/services/document-service/utils/populate.d.ts.map +1 -1
  138. package/dist/services/document-service/utils/populate.js +3 -1
  139. package/dist/services/document-service/utils/populate.js.map +1 -1
  140. package/dist/services/document-service/utils/populate.mjs +3 -1
  141. package/dist/services/document-service/utils/populate.mjs.map +1 -1
  142. package/dist/services/document-service/utils/unidirectional-relations.d.ts +33 -0
  143. package/dist/services/document-service/utils/unidirectional-relations.d.ts.map +1 -0
  144. package/dist/services/document-service/utils/unidirectional-relations.js +58 -0
  145. package/dist/services/document-service/utils/unidirectional-relations.js.map +1 -0
  146. package/dist/services/document-service/utils/unidirectional-relations.mjs +58 -0
  147. package/dist/services/document-service/utils/unidirectional-relations.mjs.map +1 -0
  148. package/dist/services/entity-validator/blocks-validator.d.ts +1 -2
  149. package/dist/services/entity-validator/blocks-validator.d.ts.map +1 -1
  150. package/dist/services/entity-validator/blocks-validator.js +4 -3
  151. package/dist/services/entity-validator/blocks-validator.js.map +1 -1
  152. package/dist/services/entity-validator/blocks-validator.mjs +3 -3
  153. package/dist/services/entity-validator/blocks-validator.mjs.map +1 -1
  154. package/dist/services/entity-validator/index.d.ts +2 -1
  155. package/dist/services/entity-validator/index.d.ts.map +1 -1
  156. package/dist/services/entity-validator/index.js +28 -33
  157. package/dist/services/entity-validator/index.js.map +1 -1
  158. package/dist/services/entity-validator/index.mjs +14 -19
  159. package/dist/services/entity-validator/index.mjs.map +1 -1
  160. package/dist/services/entity-validator/validators.d.ts +32 -23
  161. package/dist/services/entity-validator/validators.d.ts.map +1 -1
  162. package/dist/services/entity-validator/validators.js +136 -63
  163. package/dist/services/entity-validator/validators.js.map +1 -1
  164. package/dist/services/entity-validator/validators.mjs +135 -63
  165. package/dist/services/entity-validator/validators.mjs.map +1 -1
  166. package/dist/services/server/compose-endpoint.js +7 -7
  167. package/dist/services/server/compose-endpoint.js.map +1 -1
  168. package/dist/services/server/koa.js +3 -3
  169. package/dist/services/server/koa.js.map +1 -1
  170. package/dist/services/server/middleware.js +3 -3
  171. package/dist/services/server/middleware.js.map +1 -1
  172. package/dist/services/server/routing.js +2 -2
  173. package/dist/services/server/routing.js.map +1 -1
  174. package/dist/services/utils/dynamic-zones.js +5 -5
  175. package/dist/services/utils/dynamic-zones.js.map +1 -1
  176. package/dist/utils/cron.js +3 -3
  177. package/dist/utils/cron.js.map +1 -1
  178. package/dist/utils/filepath-to-prop-path.d.ts +1 -1
  179. package/dist/utils/filepath-to-prop-path.d.ts.map +1 -1
  180. package/dist/utils/filepath-to-prop-path.js +27 -6
  181. package/dist/utils/filepath-to-prop-path.js.map +1 -1
  182. package/dist/utils/filepath-to-prop-path.mjs +25 -5
  183. package/dist/utils/filepath-to-prop-path.mjs.map +1 -1
  184. package/dist/utils/is-initialized.js +3 -3
  185. package/dist/utils/is-initialized.js.map +1 -1
  186. package/dist/utils/startup-logger.js +4 -4
  187. package/dist/utils/startup-logger.js.map +1 -1
  188. package/dist/utils/startup-logger.mjs +3 -3
  189. package/dist/utils/startup-logger.mjs.map +1 -1
  190. package/dist/utils/transform-content-types-to-models.d.ts +2 -2
  191. package/dist/utils/transform-content-types-to-models.d.ts.map +1 -1
  192. package/dist/utils/transform-content-types-to-models.js +6 -5
  193. package/dist/utils/transform-content-types-to-models.js.map +1 -1
  194. package/dist/utils/transform-content-types-to-models.mjs +5 -4
  195. package/dist/utils/transform-content-types-to-models.mjs.map +1 -1
  196. package/package.json +15 -15
@@ -1 +1 @@
1
- {"version":3,"file":"startup-logger.js","sources":["../../src/utils/startup-logger.ts"],"sourcesContent":["import chalk from 'chalk';\nimport CLITable from 'cli-table3';\nimport _ from 'lodash/fp';\n\nimport type { Core } from '@strapi/types';\n\nexport const createStartupLogger = (app: Core.Strapi) => {\n return {\n logStats() {\n const columns = Math.min(process.stderr.columns, 80) - 2;\n console.log();\n console.log(chalk.black.bgWhite(_.padEnd(columns, ' Project information')));\n console.log();\n\n const infoTable = new CLITable({\n colWidths: [20, 50],\n chars: { mid: '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' },\n });\n\n infoTable.push(\n [chalk.blue('Time'), `${new Date()}`],\n [chalk.blue('Launched in'), `${Date.now() - app.config.launchedAt} ms`],\n [chalk.blue('Environment'), app.config.environment],\n [chalk.blue('Process PID'), process.pid],\n [chalk.blue('Version'), `${app.config.info.strapi} (node ${process.version})`],\n [chalk.blue('Edition'), app.EE ? 'Enterprise' : 'Community'],\n [chalk.blue('Database'), app.db?.dialect.client]\n );\n\n console.log(infoTable.toString());\n console.log();\n console.log(chalk.black.bgWhite(_.padEnd(columns, ' Actions available')));\n console.log();\n },\n\n logFirstStartupMessage() {\n if (!strapi.config.get('server.logger.startup.enabled')) {\n return;\n }\n\n this.logStats();\n\n console.log(chalk.bold('One more thing...'));\n console.log(\n chalk.grey('Create your first administrator 💻 by going to the administration panel at:')\n );\n console.log();\n\n const addressTable = new CLITable();\n\n const adminUrl = strapi.config.get('admin.absoluteUrl');\n addressTable.push([chalk.bold(adminUrl)]);\n\n console.log(`${addressTable.toString()}`);\n console.log();\n },\n\n logDefaultStartupMessage() {\n if (!strapi.config.get('server.logger.startup.enabled')) {\n return;\n }\n this.logStats();\n\n console.log(chalk.bold('Welcome back!'));\n\n if (app.config.get('admin.serveAdminPanel') === true) {\n console.log(chalk.grey('To manage your project 🚀, go to the administration panel at:'));\n const adminUrl = strapi.config.get('admin.absoluteUrl');\n console.log(chalk.bold(adminUrl));\n console.log();\n }\n\n console.log(chalk.grey('To access the server ⚡️, go to:'));\n const serverUrl = strapi.config.get('server.absoluteUrl');\n console.log(chalk.bold(serverUrl));\n console.log();\n },\n\n logStartupMessage({ isInitialized }: { isInitialized: boolean }) {\n if (!strapi.config.get('server.logger.startup.enabled')) {\n return;\n }\n if (!isInitialized) {\n this.logFirstStartupMessage();\n } else {\n this.logDefaultStartupMessage();\n }\n },\n };\n};\n"],"names":["chalk","_","CLITable"],"mappings":";;;;;;;;;AAMa,MAAA,sBAAsB,CAAC,QAAqB;AAChD,SAAA;AAAA,IACL,WAAW;AACT,YAAM,UAAU,KAAK,IAAI,QAAQ,OAAO,SAAS,EAAE,IAAI;AACvD,cAAQ,IAAI;AACJ,cAAA,IAAIA,uBAAM,MAAM,QAAQC,mBAAE,OAAO,SAAS,sBAAsB,CAAC,CAAC;AAC1E,cAAQ,IAAI;AAEN,YAAA,YAAY,IAAIC,0BAAS;AAAA,QAC7B,WAAW,CAAC,IAAI,EAAE;AAAA,QAClB,OAAO,EAAE,KAAK,IAAI,YAAY,IAAI,WAAW,IAAI,aAAa,GAAG;AAAA,MAAA,CAClE;AAES,gBAAA;AAAA,QACR,CAACF,eAAAA,QAAM,KAAK,MAAM,GAAG,GAAG,oBAAI,KAAM,CAAA,EAAE;AAAA,QACpC,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AAAA,QAAM,KAAK,eAAe,CAAC;AAEvC,UAAI,IAAI,OAAO,IAAI,uBAAuB,MAAM,MAAM;AACpD,gBAAQ,IAAIA,eAAAA,QAAM,KAAK,+DAA+D,CAAC;AACvF,cAAM,WAAW,OAAO,OAAO,IAAI,mBAAmB;AACtD,gBAAQ,IAAIA,eAAAA,QAAM,KAAK,QAAQ,CAAC;AAChC,gBAAQ,IAAI;AAAA,MACd;AAEA,cAAQ,IAAIA,eAAAA,QAAM,KAAK,iCAAiC,CAAC;AACzD,YAAM,YAAY,OAAO,OAAO,IAAI,oBAAoB;AACxD,cAAQ,IAAIA,eAAAA,QAAM,KAAK,SAAS,CAAC;AACjC,cAAQ,IAAI;AAAA,IACd;AAAA,IAEA,kBAAkB,EAAE,iBAA6C;AAC/D,UAAI,CAAC,OAAO,OAAO,IAAI,+BAA+B,GAAG;AACvD;AAAA,MACF;AACA,UAAI,CAAC,eAAe;AAClB,aAAK,uBAAuB;AAAA,MAAA,OACvB;AACL,aAAK,yBAAyB;AAAA,MAChC;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"startup-logger.js","sources":["../../src/utils/startup-logger.ts"],"sourcesContent":["import chalk from 'chalk';\nimport CLITable from 'cli-table3';\nimport _ from 'lodash/fp';\n\nimport type { Core } from '@strapi/types';\n\nexport const createStartupLogger = (app: Core.Strapi) => {\n return {\n logStats() {\n const columns = Math.min(process.stderr.columns, 80) - 2;\n console.log();\n console.log(chalk.black.bgWhite(_.padEnd(columns, ' Project information')));\n console.log();\n\n const infoTable = new CLITable({\n colWidths: [20, 50],\n chars: { mid: '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' },\n });\n\n infoTable.push(\n [chalk.blue('Time'), `${new Date()}`],\n [chalk.blue('Launched in'), `${Date.now() - app.config.launchedAt} ms`],\n [chalk.blue('Environment'), app.config.environment],\n [chalk.blue('Process PID'), process.pid],\n [chalk.blue('Version'), `${app.config.info.strapi} (node ${process.version})`],\n [chalk.blue('Edition'), app.EE ? 'Enterprise' : 'Community'],\n [chalk.blue('Database'), app.db?.dialect.client]\n );\n\n console.log(infoTable.toString());\n console.log();\n console.log(chalk.black.bgWhite(_.padEnd(columns, ' Actions available')));\n console.log();\n },\n\n logFirstStartupMessage() {\n if (!strapi.config.get('server.logger.startup.enabled')) {\n return;\n }\n\n this.logStats();\n\n console.log(chalk.bold('One more thing...'));\n console.log(\n chalk.grey('Create your first administrator 💻 by going to the administration panel at:')\n );\n console.log();\n\n const addressTable = new CLITable();\n\n const adminUrl = strapi.config.get('admin.absoluteUrl');\n addressTable.push([chalk.bold(adminUrl)]);\n\n console.log(`${addressTable.toString()}`);\n console.log();\n },\n\n logDefaultStartupMessage() {\n if (!strapi.config.get('server.logger.startup.enabled')) {\n return;\n }\n this.logStats();\n\n console.log(chalk.bold('Welcome back!'));\n\n if (app.config.get('admin.serveAdminPanel') === true) {\n console.log(chalk.grey('To manage your project 🚀, go to the administration panel at:'));\n const adminUrl = strapi.config.get('admin.absoluteUrl');\n console.log(chalk.bold(adminUrl));\n console.log();\n }\n\n console.log(chalk.grey('To access the server ⚡️, go to:'));\n const serverUrl = strapi.config.get('server.absoluteUrl');\n console.log(chalk.bold(serverUrl));\n console.log();\n },\n\n logStartupMessage({ isInitialized }: { isInitialized: boolean }) {\n if (!strapi.config.get('server.logger.startup.enabled')) {\n return;\n }\n if (!isInitialized) {\n this.logFirstStartupMessage();\n } else {\n this.logDefaultStartupMessage();\n }\n },\n };\n};\n"],"names":["chalk","_","CLITable"],"mappings":";;;;;;;;;AAMa,MAAA,sBAAsB,CAAC,QAAqB;AAChD,SAAA;AAAA,IACL,WAAW;AACT,YAAM,UAAU,KAAK,IAAI,QAAQ,OAAO,SAAS,EAAE,IAAI;AACvD,cAAQ,IAAI;AACJ,cAAA,IAAIA,uBAAM,MAAM,QAAQC,oBAAE,OAAO,SAAS,sBAAsB,CAAC,CAAC;AAC1E,cAAQ,IAAI;AAEN,YAAA,YAAY,IAAIC,0BAAS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,KAAK,QAAQ,CAAC,CAAC;AAExC,cAAQ,IAAI,GAAG,aAAa,SAAA,CAAU,EAAE;AACxC,cAAQ,IAAI;AAAA,IACd;AAAA,IAEA,2BAA2B;AACzB,UAAI,CAAC,OAAO,OAAO,IAAI,+BAA+B,GAAG;AACvD;AAAA,MACF;AACA,WAAK,SAAS;AAEd,cAAQ,IAAIA,eAAAA,QAAM,KAAK,eAAe,CAAC;AAEvC,UAAI,IAAI,OAAO,IAAI,uBAAuB,MAAM,MAAM;AACpD,gBAAQ,IAAIA,eAAAA,QAAM,KAAK,+DAA+D,CAAC;AACvF,cAAM,WAAW,OAAO,OAAO,IAAI,mBAAmB;AACtD,gBAAQ,IAAIA,eAAAA,QAAM,KAAK,QAAQ,CAAC;AAChC,gBAAQ,IAAI;AAAA,MACd;AAEA,cAAQ,IAAIA,eAAAA,QAAM,KAAK,iCAAiC,CAAC;AACzD,YAAM,YAAY,OAAO,OAAO,IAAI,oBAAoB;AACxD,cAAQ,IAAIA,eAAAA,QAAM,KAAK,SAAS,CAAC;AACjC,cAAQ,IAAI;AAAA,IACd;AAAA,IAEA,kBAAkB,EAAE,iBAA6C;AAC/D,UAAI,CAAC,OAAO,OAAO,IAAI,+BAA+B,GAAG;AACvD;AAAA,MACF;AACA,UAAI,CAAC,eAAe;AAClB,aAAK,uBAAuB;AAAA,MAAA,OACvB;AACL,aAAK,yBAAyB;AAAA,MAChC;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
@@ -1,12 +1,12 @@
1
1
  import chalk from "chalk";
2
2
  import CLITable from "cli-table3";
3
- import _ from "lodash/fp";
3
+ import fp from "lodash/fp";
4
4
  const createStartupLogger = (app) => {
5
5
  return {
6
6
  logStats() {
7
7
  const columns = Math.min(process.stderr.columns, 80) - 2;
8
8
  console.log();
9
- console.log(chalk.black.bgWhite(_.padEnd(columns, " Project information")));
9
+ console.log(chalk.black.bgWhite(fp.padEnd(columns, " Project information")));
10
10
  console.log();
11
11
  const infoTable = new CLITable({
12
12
  colWidths: [20, 50],
@@ -23,7 +23,7 @@ const createStartupLogger = (app) => {
23
23
  );
24
24
  console.log(infoTable.toString());
25
25
  console.log();
26
- console.log(chalk.black.bgWhite(_.padEnd(columns, " Actions available")));
26
+ console.log(chalk.black.bgWhite(fp.padEnd(columns, " Actions available")));
27
27
  console.log();
28
28
  },
29
29
  logFirstStartupMessage() {
@@ -1 +1 @@
1
- {"version":3,"file":"startup-logger.mjs","sources":["../../src/utils/startup-logger.ts"],"sourcesContent":["import chalk from 'chalk';\nimport CLITable from 'cli-table3';\nimport _ from 'lodash/fp';\n\nimport type { Core } from '@strapi/types';\n\nexport const createStartupLogger = (app: Core.Strapi) => {\n return {\n logStats() {\n const columns = Math.min(process.stderr.columns, 80) - 2;\n console.log();\n console.log(chalk.black.bgWhite(_.padEnd(columns, ' Project information')));\n console.log();\n\n const infoTable = new CLITable({\n colWidths: [20, 50],\n chars: { mid: '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' },\n });\n\n infoTable.push(\n [chalk.blue('Time'), `${new Date()}`],\n [chalk.blue('Launched in'), `${Date.now() - app.config.launchedAt} ms`],\n [chalk.blue('Environment'), app.config.environment],\n [chalk.blue('Process PID'), process.pid],\n [chalk.blue('Version'), `${app.config.info.strapi} (node ${process.version})`],\n [chalk.blue('Edition'), app.EE ? 'Enterprise' : 'Community'],\n [chalk.blue('Database'), app.db?.dialect.client]\n );\n\n console.log(infoTable.toString());\n console.log();\n console.log(chalk.black.bgWhite(_.padEnd(columns, ' Actions available')));\n console.log();\n },\n\n logFirstStartupMessage() {\n if (!strapi.config.get('server.logger.startup.enabled')) {\n return;\n }\n\n this.logStats();\n\n console.log(chalk.bold('One more thing...'));\n console.log(\n chalk.grey('Create your first administrator 💻 by going to the administration panel at:')\n );\n console.log();\n\n const addressTable = new CLITable();\n\n const adminUrl = strapi.config.get('admin.absoluteUrl');\n addressTable.push([chalk.bold(adminUrl)]);\n\n console.log(`${addressTable.toString()}`);\n console.log();\n },\n\n logDefaultStartupMessage() {\n if (!strapi.config.get('server.logger.startup.enabled')) {\n return;\n }\n this.logStats();\n\n console.log(chalk.bold('Welcome back!'));\n\n if (app.config.get('admin.serveAdminPanel') === true) {\n console.log(chalk.grey('To manage your project 🚀, go to the administration panel at:'));\n const adminUrl = strapi.config.get('admin.absoluteUrl');\n console.log(chalk.bold(adminUrl));\n console.log();\n }\n\n console.log(chalk.grey('To access the server ⚡️, go to:'));\n const serverUrl = strapi.config.get('server.absoluteUrl');\n console.log(chalk.bold(serverUrl));\n console.log();\n },\n\n logStartupMessage({ isInitialized }: { isInitialized: boolean }) {\n if (!strapi.config.get('server.logger.startup.enabled')) {\n return;\n }\n if (!isInitialized) {\n this.logFirstStartupMessage();\n } else {\n this.logDefaultStartupMessage();\n }\n },\n };\n};\n"],"names":[],"mappings":";;;AAMa,MAAA,sBAAsB,CAAC,QAAqB;AAChD,SAAA;AAAA,IACL,WAAW;AACT,YAAM,UAAU,KAAK,IAAI,QAAQ,OAAO,SAAS,EAAE,IAAI;AACvD,cAAQ,IAAI;AACJ,cAAA,IAAI,MAAM,MAAM,QAAQ,EAAE,OAAO,SAAS,sBAAsB,CAAC,CAAC;AAC1E,cAAQ,IAAI;AAEN,YAAA,YAAY,IAAI,SAAS;AAAA,QAC7B,WAAW,CAAC,IAAI,EAAE;AAAA,QAClB,OAAO,EAAE,KAAK,IAAI,YAAY,IAAI,WAAW,IAAI,aAAa,GAAG;AAAA,MAAA,CAClE;AAES,gBAAA;AAAA,QACR,CAAC,MAAM,KAAK,MAAM,GAAG,GAAG,oBAAI,KAAM,CAAA,EAAE;AAAA,QACpC,CAAC,MAAM,KAAK,aAAa,GAAG,GAAG,KAAK,IAAA,IAAQ,IAAI,OAAO,UAAU,KAAK;AAAA,QACtE,CAAC,MAAM,KAAK,aAAa,GAAG,IAAI,OAAO,WAAW;AAAA,QAClD,CAAC,MAAM,KAAK,aAAa,GAAG,QAAQ,GAAG;AAAA,QACvC,CAAC,MAAM,KAAK,SAAS,G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AY,OAAO,OAAO,IAAI,oBAAoB;AACxD,cAAQ,IAAI,MAAM,KAAK,SAAS,CAAC;AACjC,cAAQ,IAAI;AAAA,IACd;AAAA,IAEA,kBAAkB,EAAE,iBAA6C;AAC/D,UAAI,CAAC,OAAO,OAAO,IAAI,+BAA+B,GAAG;AACvD;AAAA,MACF;AACA,UAAI,CAAC,eAAe;AAClB,aAAK,uBAAuB;AAAA,MAAA,OACvB;AACL,aAAK,yBAAyB;AAAA,MAChC;AAAA,IACF;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"startup-logger.mjs","sources":["../../src/utils/startup-logger.ts"],"sourcesContent":["import chalk from 'chalk';\nimport CLITable from 'cli-table3';\nimport _ from 'lodash/fp';\n\nimport type { Core } from '@strapi/types';\n\nexport const createStartupLogger = (app: Core.Strapi) => {\n return {\n logStats() {\n const columns = Math.min(process.stderr.columns, 80) - 2;\n console.log();\n console.log(chalk.black.bgWhite(_.padEnd(columns, ' Project information')));\n console.log();\n\n const infoTable = new CLITable({\n colWidths: [20, 50],\n chars: { mid: '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' },\n });\n\n infoTable.push(\n [chalk.blue('Time'), `${new Date()}`],\n [chalk.blue('Launched in'), `${Date.now() - app.config.launchedAt} ms`],\n [chalk.blue('Environment'), app.config.environment],\n [chalk.blue('Process PID'), process.pid],\n [chalk.blue('Version'), `${app.config.info.strapi} (node ${process.version})`],\n [chalk.blue('Edition'), app.EE ? 'Enterprise' : 'Community'],\n [chalk.blue('Database'), app.db?.dialect.client]\n );\n\n console.log(infoTable.toString());\n console.log();\n console.log(chalk.black.bgWhite(_.padEnd(columns, ' Actions available')));\n console.log();\n },\n\n logFirstStartupMessage() {\n if (!strapi.config.get('server.logger.startup.enabled')) {\n return;\n }\n\n this.logStats();\n\n console.log(chalk.bold('One more thing...'));\n console.log(\n chalk.grey('Create your first administrator 💻 by going to the administration panel at:')\n );\n console.log();\n\n const addressTable = new CLITable();\n\n const adminUrl = strapi.config.get('admin.absoluteUrl');\n addressTable.push([chalk.bold(adminUrl)]);\n\n console.log(`${addressTable.toString()}`);\n console.log();\n },\n\n logDefaultStartupMessage() {\n if (!strapi.config.get('server.logger.startup.enabled')) {\n return;\n }\n this.logStats();\n\n console.log(chalk.bold('Welcome back!'));\n\n if (app.config.get('admin.serveAdminPanel') === true) {\n console.log(chalk.grey('To manage your project 🚀, go to the administration panel at:'));\n const adminUrl = strapi.config.get('admin.absoluteUrl');\n console.log(chalk.bold(adminUrl));\n console.log();\n }\n\n console.log(chalk.grey('To access the server ⚡️, go to:'));\n const serverUrl = strapi.config.get('server.absoluteUrl');\n console.log(chalk.bold(serverUrl));\n console.log();\n },\n\n logStartupMessage({ isInitialized }: { isInitialized: boolean }) {\n if (!strapi.config.get('server.logger.startup.enabled')) {\n return;\n }\n if (!isInitialized) {\n this.logFirstStartupMessage();\n } else {\n this.logDefaultStartupMessage();\n }\n },\n };\n};\n"],"names":["_"],"mappings":";;;AAMa,MAAA,sBAAsB,CAAC,QAAqB;AAChD,SAAA;AAAA,IACL,WAAW;AACT,YAAM,UAAU,KAAK,IAAI,QAAQ,OAAO,SAAS,EAAE,IAAI;AACvD,cAAQ,IAAI;AACJ,cAAA,IAAI,MAAM,MAAM,QAAQA,GAAE,OAAO,SAAS,sBAAsB,CAAC,CAAC;AAC1E,cAAQ,IAAI;AAEN,YAAA,YAAY,IAAI,SAAS;AAAA,QAC7B,WAAW,CAAC,IAAI,EAAE;AAAA,QAClB,OAAO,EAAE,KAAK,IAAI,YAAY,IAAI,WAAW,IAAI,aAAa,GAAG;AAAA,MAAA,CAClE;AAES,gBAAA;AAAA,QACR,CAAC,MAAM,KAAK,MAAM,GAAG,GAAG,oBAAI,KAAM,CAAA,EAAE;AAAA,QACpC,CAAC,MAAM,KAAK,aAAa,GAAG,GAAG,KAAK,IAAA,IAAQ,IAAI,OAAO,UAAU,KAAK;AAAA,QACtE,CAAC,MAAM,KAAK,aAAa,GAAG,IAAI,OAAO,WAAW;AA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AChC,gBAAQ,IAAI;AAAA,MACd;AAEA,cAAQ,IAAI,MAAM,KAAK,iCAAiC,CAAC;AACzD,YAAM,YAAY,OAAO,OAAO,IAAI,oBAAoB;AACxD,cAAQ,IAAI,MAAM,KAAK,SAAS,CAAC;AACjC,cAAQ,IAAI;AAAA,IACd;AAAA,IAEA,kBAAkB,EAAE,iBAA6C;AAC/D,UAAI,CAAC,OAAO,OAAO,IAAI,+BAA+B,GAAG;AACvD;AAAA,MACF;AACA,UAAI,CAAC,eAAe;AAClB,aAAK,uBAAuB;AAAA,MAAA,OACvB;AACL,aAAK,yBAAyB;AAAA,MAChC;AAAA,IACF;AAAA,EAAA;AAEJ;"}
@@ -19,7 +19,7 @@ export declare const getComponentJoinColumnEntityName: (identifiers: Identifiers
19
19
  export declare const getComponentJoinColumnInverseName: (identifiers: Identifiers) => string;
20
20
  export declare const getComponentTypeColumn: (identifiers: Identifiers) => string;
21
21
  export declare const getComponentFkIndexName: (contentType: string, identifiers: Identifiers) => string;
22
- export type LoadedContentTypeModel = Struct.ContentTypeSchema & Required<Pick<Struct.ContentTypeSchema, 'collectionName' | 'uid' | 'modelName'>>;
22
+ export type LoadedContentTypeModel = Struct.ContentTypeSchema & Required<Pick<Struct.ContentTypeSchema, 'collectionName' | 'uid' | 'modelName'>> & Pick<Model, 'lifecycles'>;
23
23
  export declare const transformAttribute: (name: string, attribute: Schema.Attribute.AnyAttribute, contentType: LoadedContentTypeModel, identifiers: Identifiers) => (Schema.Attribute.OfType<"biginteger"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<string> & Schema.Attribute.MinMaxOption<string> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.UniqueOption) | (Schema.Attribute.OfType<"boolean"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<boolean> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"blocks"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"datetime"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<Schema.Attribute.DateTimeValue> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.UniqueOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"date"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<Schema.Attribute.DateValue> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.UniqueOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"decimal"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<number> & Schema.Attribute.MinMaxOption<number> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.UniqueOption) | (Schema.Attribute.OfType<"email"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<string> & Schema.Attribute.MinMaxLengthOption & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.UniqueOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"enumeration"> & Schema.Attribute.EnumerationProperties<string[]> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<string> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"float"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<number> & Schema.Attribute.MinMaxOption<number> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.UniqueOption) | (Schema.Attribute.OfType<"integer"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<number> & Schema.Attribute.MinMaxOption<number> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.UniqueOption) | (Schema.Attribute.OfType<"json"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.RequiredOption & Schema.Attribute.PrivateOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.DefaultOption<import("@strapi/types/dist/utils").JSONPrimitive>) | (Schema.Attribute.OfType<"password"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<string> & Schema.Attribute.MinMaxLengthOption & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"relation"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.PrivateOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.RequiredOption & {
24
24
  useJoinTable?: boolean | undefined;
25
25
  } & {
@@ -124,7 +124,7 @@ export declare const transformAttribute: (name: string, attribute: Schema.Attrib
124
124
  morphBy?: undefined;
125
125
  };
126
126
  export declare const transformAttributes: (contentType: LoadedContentTypeModel, identifiers: Identifiers) => {};
127
- export declare const hasComponentsOrDz: (contentType: LoadedContentTypeModel) => contentType is Struct.ContentTypeSchema & Required<Pick<Struct.ContentTypeSchema, "uid" | "collectionName" | "modelName">> & {
127
+ export declare const hasComponentsOrDz: (contentType: LoadedContentTypeModel) => contentType is Struct.ContentTypeSchema & Required<Pick<Struct.ContentTypeSchema, "uid" | "collectionName" | "modelName">> & Pick<Model, "lifecycles"> & {
128
128
  type: 'dynamiczone' | 'component';
129
129
  };
130
130
  export declare const createDocumentId: typeof createId;
@@ -1 +1 @@
1
- {"version":3,"file":"transform-content-types-to-models.d.ts","sourceRoot":"","sources":["../../src/utils/trans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EAAE,eACzB,WAAW,KACvB,KAAK,EAiEP,CAAC"}
1
+ {"version":3,"file":"transform-content-types-to-models.d.ts","sourceRoot":"","sources":["../../src/utils/transform-content-types-to-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,yBAAyB,mBAAoB,MAAM,eAAe,WAAW,WAKzF,CAAC;AAEF,eAAO,MAAM,kBAAkB,mBAAoB,MAAM,eAAe,WAAW,WAKlF,CAAC;AAEF,eAAO,MAAM,gCAAgC,gBAAiB,WAAW,WAKxE,CAAC;AAEF,eAAO,MAAM,iCAAiC,gBAAiB,WAAW,WAKzE,CAAC;AAEF,eAAO,MAAM,sBAAsB,gBAAiB,WAAW,WAE9D,CAAC;AAEF,eAAO,MAAM,uBAAuB,gBAAiB,MAAM,eAAe,WAAW,WAMpF,CAAC;AAIF,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,iBAAiB,GAC3D,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,gBAAgB,GAAG,KAAK,GAAG,WAAW,CAAC,CAAC,GAChF,IAAI,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAG5B,eAAO,MAAM,kBAAkB,SACvB,MAAM,aACD,OAAO,SAAS,CAAC,YAAY,eAC3B,sBAAsB,eACtB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+FzB,CAAC;AAEF,eAAO,MAAM,mBAAmB,gBACjB,sBAAsB,eACtB,WAAW,OAazB,CAAC;AAEF,eAAO,MAAM,iBAAiB,gBACf,sBAAsB;UACc,aAAa,GAAG,WAAW;CAI7E,CAAC;AAEF,eAAO,MAAM,gBAAgB,iBAAW,CAAC;AAgFzC,eAAO,MAAM,6BAA6B,iBAC1B,sBAAsB,EAAE,eACzB,WAAW,KACvB,KAAK,EAkEP,CAAC"}
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const cuid2 = require("@paralleldrive/cuid2");
4
4
  const assert = require("node:assert");
5
- const _ = require("lodash/fp");
5
+ const fp = require("lodash/fp");
6
6
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
7
7
  const assert__default = /* @__PURE__ */ _interopDefault(assert);
8
- const ___default = /* @__PURE__ */ _interopDefault(_);
8
+ const fp__default = /* @__PURE__ */ _interopDefault(fp);
9
9
  const getComponentJoinTableName = (collectionName, identifiers) => {
10
10
  return identifiers.getNameFromTokens([
11
11
  { name: collectionName, compressible: true },
@@ -233,7 +233,7 @@ const transformContentTypesToModels = (contentTypes, identifiers) => {
233
233
  const documentIdAttribute = contentType.modelType === "contentType" ? { documentId: { type: "string", default: createDocumentId } } : {};
234
234
  const reservedAttributeNames = ["document_id", identifiers.ID_COLUMN];
235
235
  Object.keys(contentType.attributes || {}).forEach((attributeName) => {
236
- const snakeCasedAttributeName = ___default.default.snakeCase(attributeName);
236
+ const snakeCasedAttributeName = fp__default.default.snakeCase(attributeName);
237
237
  if (reservedAttributeNames.includes(snakeCasedAttributeName)) {
238
238
  throw new Error(
239
239
  `The attribute "${attributeName}" is reserved and cannot be used in a model. Please rename "${contentType.modelName}" attribute "${attributeName}" to something else.`
@@ -257,7 +257,8 @@ const transformContentTypesToModels = (contentTypes, identifiers) => {
257
257
  ...transformAttributes(contentType, identifiers)
258
258
  },
259
259
  indexes: contentType.indexes,
260
- foreignKeys: contentType.foreignKeys
260
+ foreignKeys: contentType.foreignKeys,
261
+ lifecycles: contentType?.lifecycles ?? {}
261
262
  };
262
263
  if (contentType.modelType === "contentType") {
263
264
  model.indexes = [
@@ -265,7 +266,7 @@ const transformContentTypesToModels = (contentTypes, identifiers) => {
265
266
  {
266
267
  name: identifiers.getIndexName([contentType.collectionName, "documents"]),
267
268
  // Filter attributes that are not in the schema
268
- columns: ["documentId", "locale", "publishedAt"].filter((n) => model.attributes[n]).map((name) => identifiers.getColumnName(___default.default.snakeCase(name)))
269
+ columns: ["documentId", "locale", "publishedAt"].filter((n) => model.attributes[n]).map((name) => identifiers.getColumnName(fp__default.default.snakeCase(name)))
269
270
  }
270
271
  ];
271
272
  }
@@ -1 +1 @@
1
- {"version":3,"file":"transform-content-types-to-models.js","sources":["../../src/utils/transform-content-types-to-models.ts"],"sourcesContent":["import { type Model, type Identifiers } from '@strapi/database';\nimport type { Struct, Schema } from '@strapi/types';\nimport { createId } from '@paralleldrive/cuid2';\nimport assert from 'node:assert';\nimport _ from 'lodash/fp';\n\n/**\n * Because strapi/database models don't know about things like components or dynamic zones, we use this file to convert them\n * to a relations format that it recognizes\n *\n * Therefore we have to keep an additional set of helpers/extensions to the database naming methods\n *\n * IMPORTANT!\n * If we use short versions of anything, we MUST call getNameFromTokens directly; attempting to shorten them ourselves\n * prevents the unshortened name map from being filled properly, so for example it will think that the short name\n * 'collection4f3a_cmps' maps to the unshortened 'collectionname_cmps' rather than 'collectionname_components'\n * Therefore, we only use the identifiers helpers in cases where we do not do any of our own shortening\n */\n\nexport const getComponentJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getDzJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnEntityName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'entity', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnInverseName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'component', shortName: 'cmp', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentTypeColumn = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([{ name: 'component_type', compressible: false }]);\n};\n\nexport const getComponentFkIndexName = (contentType: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: contentType, compressible: true },\n { name: 'entity', compressible: false },\n { name: 'fk', compressible: false },\n ]);\n};\n\n// const { ID_COLUMN: id, FIELD_COLUMN: field, ORDER_COLUMN: order } = identifiers;\n\nexport type LoadedContentTypeModel = Struct.ContentTypeSchema &\n Required<Pick<Struct.ContentTypeSchema, 'collectionName' | 'uid' | 'modelName'>>;\n\n// Transforms an attribute (particularly for relation types) into the format that strapi/database accepts\nexport const transformAttribute = (\n name: string,\n attribute: Schema.Attribute.AnyAttribute,\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n switch (attribute.type) {\n case 'media': {\n return {\n type: 'relation',\n relation: attribute.multiple === true ? 'morphMany' : 'morphOne',\n target: 'plugin::upload.file',\n morphBy: 'related',\n };\n }\n case 'component': {\n const joinTableName = getComponentJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n return {\n type: 'relation',\n relation: attribute.repeatable === true ? 'oneToMany' : 'oneToOne',\n target: attribute.component,\n\n // We need the join table name to be deterministic,\n // We need to allow passing the join table name as an option\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n inverseJoinColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n on: {\n field: name,\n },\n orderColumnName: identifiers.ORDER_COLUMN,\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n case 'dynamiczone': {\n const joinTableName = getDzJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n\n return {\n type: 'relation',\n relation: 'morphToMany',\n // TODO: handle restrictions at some point\n // target: attribute.components,\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n morphColumn: {\n idColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n typeColumn: {\n name: compTypeColumn,\n },\n typeField: '__component',\n },\n on: {\n field: name,\n },\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n default: {\n return attribute;\n }\n }\n};\n\nexport const transformAttributes = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n return Object.keys(contentType.attributes! || {}).reduce((attrs, attrName) => {\n return {\n ...attrs,\n [attrName]: transformAttribute(\n attrName,\n contentType.attributes[attrName]!,\n contentType,\n identifiers\n ),\n };\n }, {});\n};\n\nexport const hasComponentsOrDz = (\n contentType: LoadedContentTypeModel\n): contentType is LoadedContentTypeModel & { type: 'dynamiczone' | 'component' } => {\n return Object.values(contentType.attributes || {}).some(\n (({ type }: { type: string }) => type === 'dynamiczone' || type === 'component') as any\n );\n};\n\nexport const createDocumentId = createId;\n\nconst createCompoLinkModel = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n): Model => {\n const name = getComponentJoinTableName(contentType.collectionName, identifiers);\n\n const entityId = getComponentJoinColumnEntityName(identifiers);\n const componentId = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n const fkIndex = getComponentFkIndexName(contentType.collectionName, identifiers);\n\n return {\n // TODO: make sure there can't be any conflicts with a prefix\n singularName: name,\n uid: name,\n tableName: name,\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n [entityId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [componentId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [compTypeColumn]: {\n type: 'string',\n },\n [identifiers.FIELD_COLUMN]: {\n type: 'string',\n },\n [identifiers.ORDER_COLUMN]: {\n type: 'float',\n column: {\n unsigned: true,\n defaultTo: null,\n },\n },\n },\n indexes: [\n {\n name: identifiers.getIndexName([contentType.collectionName, identifiers.FIELD_COLUMN]),\n columns: [identifiers.FIELD_COLUMN],\n },\n {\n name: identifiers.getIndexName([contentType.collectionName, compTypeColumn]),\n columns: [compTypeColumn],\n },\n {\n name: fkIndex,\n columns: [entityId],\n },\n {\n // NOTE: since we don't include attribute names, we need to be careful not to create another unique index\n name: identifiers.getUniqueIndexName([contentType.collectionName]),\n columns: [entityId, componentId, identifiers.FIELD_COLUMN, compTypeColumn],\n type: 'unique',\n },\n ],\n foreignKeys: [\n {\n name: fkIndex,\n columns: [entityId],\n referencedColumns: [identifiers.ID_COLUMN],\n referencedTable: identifiers.getTableName(contentType.collectionName),\n onDelete: 'CASCADE',\n },\n ],\n };\n};\n\nexport const transformContentTypesToModels = (\n contentTypes: LoadedContentTypeModel[],\n identifiers: Identifiers\n): Model[] => {\n const models: Model[] = [];\n\n contentTypes.forEach((contentType) => {\n assert(contentType.collectionName, 'Content type \"collectionName\" is required');\n assert(contentType.modelName, 'Content type \"modelName\" is required');\n assert(contentType.uid, 'Content type \"uid\" is required');\n\n // Add document id to content types\n // as it is not documented\n const documentIdAttribute: Record<string, Schema.Attribute.AnyAttribute> =\n contentType.modelType === 'contentType'\n ? { documentId: { type: 'string', default: createDocumentId } }\n : {};\n\n // TODO: this needs to be combined with getReservedNames, we should not be maintaining two lists\n // Prevent user from creating a documentId attribute\n const reservedAttributeNames = ['document_id', identifiers.ID_COLUMN];\n Object.keys(contentType.attributes || {}).forEach((attributeName) => {\n const snakeCasedAttributeName = _.snakeCase(attributeName);\n if (reservedAttributeNames.includes(snakeCasedAttributeName)) {\n throw new Error(\n `The attribute \"${attributeName}\" is reserved and cannot be used in a model. Please rename \"${contentType.modelName}\" attribute \"${attributeName}\" to something else.`\n );\n }\n });\n\n if (hasComponentsOrDz(contentType)) {\n const compoLinkModel = createCompoLinkModel(contentType, identifiers);\n models.push(compoLinkModel);\n }\n\n const model: Model = {\n uid: contentType.uid,\n singularName: contentType.modelName,\n tableName: contentType.collectionName, // This gets shortened in metadata.loadModels(), so we don't shorten here or it will happen twice\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n ...documentIdAttribute,\n ...transformAttributes(contentType, identifiers),\n },\n indexes: contentType.indexes as Model['indexes'],\n foreignKeys: contentType.foreignKeys as Model['foreignKeys'],\n };\n\n // Add indexes to model\n if (contentType.modelType === 'contentType') {\n model.indexes = [\n ...(model.indexes || []),\n {\n name: identifiers.getIndexName([contentType.collectionName, 'documents']),\n // Filter attributes that are not in the schema\n columns: ['documentId', 'locale', 'publishedAt']\n .filter((n) => model.attributes[n])\n .map((name) => identifiers.getColumnName(_.snakeCase(name))),\n },\n ];\n }\n\n models.push(model);\n });\n\n return models;\n};\n"],"names":["createId","assert","_"],"mappings":";;;;;;;;AAmBa,MAAA,4BAA4B,CAAC,gBAAwB,gBAA6B;AAC7F,SAAO,YAAY,kBAAkB;AAAA,IACnC,EAAE,MAAM,gBAAgB,cAAc,KAAK;AAAA,IAC3C,EAAE,MAAM,cAAc,WAAW,QAAQ,cAAc,MAAM;AAAA,EAAA,CAC9D;AACH;AAEa,MAAA,qBAAqB,CAAC,gBAAwB,gBAA6B;AACtF,SAAO,YAAY,kBAAkB;AAAA,IACnC,EAAE,MAAM,gBAAgB,cAAc,KAAK;AAAA,IAC3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Q,CAAC,kBAAkB;AAC7D,YAAA,0BAA0BC,WAAAA,QAAE,UAAU,aAAa;AACrD,UAAA,uBAAuB,SAAS,uBAAuB,GAAG;AAC5D,cAAM,IAAI;AAAA,UACR,kBAAkB,aAAa,+DAA+D,YAAY,SAAS,gBAAgB,aAAa;AAAA,QAAA;AAAA,MAEpJ;AAAA,IAAA,CACD;AAEG,QAAA,kBAAkB,WAAW,GAAG;AAC5B,YAAA,iBAAiB,qBAAqB,aAAa,WAAW;AACpE,aAAO,KAAK,cAAc;AAAA,IAC5B;AAEA,UAAM,QAAe;AAAA,MACnB,KAAK,YAAY;AAAA,MACjB,cAAc,YAAY;AAAA,MAC1B,WAAW,YAAY;AAAA;AAAA,MACvB,YAAY;AAAA,QACV,CAAC,YAAY,SAAS,GAAG;AAAA,UACvB,MAAM;AAAA,QACR;AAAA,QACA,GAAG;AAAA,QACH,GAAG,oBAAoB,aAAa,WAAW;AAAA,MACjD;AAAA,MACA,SAAS,YAAY;AAAA,MACrB,aAAa,YAAY;AAAA,IAAA;AAIvB,QAAA,YAAY,cAAc,eAAe;AAC3C,YAAM,UAAU;AAAA,QACd,GAAI,MAAM,WAAW,CAAC;AAAA,QACtB;AAAA,UACE,MAAM,YAAY,aAAa,CAAC,YAAY,gBAAgB,WAAW,CAAC;AAAA;AAAA,UAExE,SAAS,CAAC,cAAc,UAAU,aAAa,EAC5C,OAAO,CAAC,MAAM,MAAM,WAAW,CAAC,CAAC,EACjC,IAAI,CAAC,SAAS,YAAY,cAAcA,mBAAE,UAAU,IAAI,CAAC,CAAC;AAAA,QAC/D;AAAA,MAAA;AAAA,IAEJ;AAEA,WAAO,KAAK,KAAK;AAAA,EAAA,CAClB;AAEM,SAAA;AACT;;;;;;;;;;;;"}
1
+ {"version":3,"file":"transform-content-types-to-models.js","sources":["../../src/utils/transform-content-types-to-models.ts"],"sourcesContent":["import { type Model, type Identifiers } from '@strapi/database';\nimport type { Struct, Schema } from '@strapi/types';\nimport { createId } from '@paralleldrive/cuid2';\nimport assert from 'node:assert';\nimport _ from 'lodash/fp';\n\n/**\n * Because strapi/database models don't know about things like components or dynamic zones, we use this file to convert them\n * to a relations format that it recognizes\n *\n * Therefore we have to keep an additional set of helpers/extensions to the database naming methods\n *\n * IMPORTANT!\n * If we use short versions of anything, we MUST call getNameFromTokens directly; attempting to shorten them ourselves\n * prevents the unshortened name map from being filled properly, so for example it will think that the short name\n * 'collection4f3a_cmps' maps to the unshortened 'collectionname_cmps' rather than 'collectionname_components'\n * Therefore, we only use the identifiers helpers in cases where we do not do any of our own shortening\n */\n\nexport const getComponentJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getDzJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnEntityName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'entity', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnInverseName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'component', shortName: 'cmp', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentTypeColumn = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([{ name: 'component_type', compressible: false }]);\n};\n\nexport const getComponentFkIndexName = (contentType: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: contentType, compressible: true },\n { name: 'entity', compressible: false },\n { name: 'fk', compressible: false },\n ]);\n};\n\n// const { ID_COLUMN: id, FIELD_COLUMN: field, ORDER_COLUMN: order } = identifiers;\n\nexport type LoadedContentTypeModel = Struct.ContentTypeSchema &\n Required<Pick<Struct.ContentTypeSchema, 'collectionName' | 'uid' | 'modelName'>> &\n Pick<Model, 'lifecycles'>;\n\n// Transforms an attribute (particularly for relation types) into the format that strapi/database accepts\nexport const transformAttribute = (\n name: string,\n attribute: Schema.Attribute.AnyAttribute,\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n switch (attribute.type) {\n case 'media': {\n return {\n type: 'relation',\n relation: attribute.multiple === true ? 'morphMany' : 'morphOne',\n target: 'plugin::upload.file',\n morphBy: 'related',\n };\n }\n case 'component': {\n const joinTableName = getComponentJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n return {\n type: 'relation',\n relation: attribute.repeatable === true ? 'oneToMany' : 'oneToOne',\n target: attribute.component,\n\n // We need the join table name to be deterministic,\n // We need to allow passing the join table name as an option\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n inverseJoinColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n on: {\n field: name,\n },\n orderColumnName: identifiers.ORDER_COLUMN,\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n case 'dynamiczone': {\n const joinTableName = getDzJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n\n return {\n type: 'relation',\n relation: 'morphToMany',\n // TODO: handle restrictions at some point\n // target: attribute.components,\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n morphColumn: {\n idColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n typeColumn: {\n name: compTypeColumn,\n },\n typeField: '__component',\n },\n on: {\n field: name,\n },\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n default: {\n return attribute;\n }\n }\n};\n\nexport const transformAttributes = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n return Object.keys(contentType.attributes! || {}).reduce((attrs, attrName) => {\n return {\n ...attrs,\n [attrName]: transformAttribute(\n attrName,\n contentType.attributes[attrName]!,\n contentType,\n identifiers\n ),\n };\n }, {});\n};\n\nexport const hasComponentsOrDz = (\n contentType: LoadedContentTypeModel\n): contentType is LoadedContentTypeModel & { type: 'dynamiczone' | 'component' } => {\n return Object.values(contentType.attributes || {}).some(\n (({ type }: { type: string }) => type === 'dynamiczone' || type === 'component') as any\n );\n};\n\nexport const createDocumentId = createId;\n\nconst createCompoLinkModel = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n): Model => {\n const name = getComponentJoinTableName(contentType.collectionName, identifiers);\n\n const entityId = getComponentJoinColumnEntityName(identifiers);\n const componentId = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n const fkIndex = getComponentFkIndexName(contentType.collectionName, identifiers);\n\n return {\n // TODO: make sure there can't be any conflicts with a prefix\n singularName: name,\n uid: name,\n tableName: name,\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n [entityId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [componentId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [compTypeColumn]: {\n type: 'string',\n },\n [identifiers.FIELD_COLUMN]: {\n type: 'string',\n },\n [identifiers.ORDER_COLUMN]: {\n type: 'float',\n column: {\n unsigned: true,\n defaultTo: null,\n },\n },\n },\n indexes: [\n {\n name: identifiers.getIndexName([contentType.collectionName, identifiers.FIELD_COLUMN]),\n columns: [identifiers.FIELD_COLUMN],\n },\n {\n name: identifiers.getIndexName([contentType.collectionName, compTypeColumn]),\n columns: [compTypeColumn],\n },\n {\n name: fkIndex,\n columns: [entityId],\n },\n {\n // NOTE: since we don't include attribute names, we need to be careful not to create another unique index\n name: identifiers.getUniqueIndexName([contentType.collectionName]),\n columns: [entityId, componentId, identifiers.FIELD_COLUMN, compTypeColumn],\n type: 'unique',\n },\n ],\n foreignKeys: [\n {\n name: fkIndex,\n columns: [entityId],\n referencedColumns: [identifiers.ID_COLUMN],\n referencedTable: identifiers.getTableName(contentType.collectionName),\n onDelete: 'CASCADE',\n },\n ],\n };\n};\n\nexport const transformContentTypesToModels = (\n contentTypes: LoadedContentTypeModel[],\n identifiers: Identifiers\n): Model[] => {\n const models: Model[] = [];\n\n contentTypes.forEach((contentType) => {\n assert(contentType.collectionName, 'Content type \"collectionName\" is required');\n assert(contentType.modelName, 'Content type \"modelName\" is required');\n assert(contentType.uid, 'Content type \"uid\" is required');\n\n // Add document id to content types\n // as it is not documented\n const documentIdAttribute: Record<string, Schema.Attribute.AnyAttribute> =\n contentType.modelType === 'contentType'\n ? { documentId: { type: 'string', default: createDocumentId } }\n : {};\n\n // TODO: this needs to be combined with getReservedNames, we should not be maintaining two lists\n // Prevent user from creating a documentId attribute\n const reservedAttributeNames = ['document_id', identifiers.ID_COLUMN];\n Object.keys(contentType.attributes || {}).forEach((attributeName) => {\n const snakeCasedAttributeName = _.snakeCase(attributeName);\n if (reservedAttributeNames.includes(snakeCasedAttributeName)) {\n throw new Error(\n `The attribute \"${attributeName}\" is reserved and cannot be used in a model. Please rename \"${contentType.modelName}\" attribute \"${attributeName}\" to something else.`\n );\n }\n });\n\n if (hasComponentsOrDz(contentType)) {\n const compoLinkModel = createCompoLinkModel(contentType, identifiers);\n models.push(compoLinkModel);\n }\n\n const model: Model = {\n uid: contentType.uid,\n singularName: contentType.modelName,\n tableName: contentType.collectionName, // This gets shortened in metadata.loadModels(), so we don't shorten here or it will happen twice\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n ...documentIdAttribute,\n ...transformAttributes(contentType, identifiers),\n },\n indexes: contentType.indexes as Model['indexes'],\n foreignKeys: contentType.foreignKeys as Model['foreignKeys'],\n lifecycles: contentType?.lifecycles ?? {},\n };\n\n // Add indexes to model\n if (contentType.modelType === 'contentType') {\n model.indexes = [\n ...(model.indexes || []),\n {\n name: identifiers.getIndexName([contentType.collectionName, 'documents']),\n // Filter attributes that are not in the schema\n columns: ['documentId', 'locale', 'publishedAt']\n .filter((n) => model.attributes[n])\n .map((name) => identifiers.getColumnName(_.snakeCase(name))),\n },\n ];\n }\n\n models.push(model);\n });\n\n return models;\n};\n"],"names":["createId","assert","_"],"mappings":";;;;;;;;AAmBa,MAAA,4BAA4B,CAAC,gBAAwB,gBAA6B;AAC7F,SAAO,YAAY,kBAAkB;AAAA,IACnC,EAAE,MAAM,gBAAgB,cAAc,KAAK;AAAA,IAC3C,EAAE,MAAM,cAAc,WAAW,QAAQ,cAAc,MAAM;AAAA,EAAA,CAC9D;AACH;AAEa,MAAA,qBAAqB,CAAC,gBAAwB,gBAA6B;AACtF,SAAO,YAAY,kBAAkB;AAAA,IACnC,EAAE,MAAM,gBAAgB,cAAc,KAAK;AAAA,IAC3C,EAAE,MAAM,cAAc,WAAW,QAAQ,cAAc,MAAM;AAAA,EAAA,CAC9D;AACH;AAEa,MAAA,mCAAmC,CAAC,gBAA6B;AAC5E,SAAO,YAAY,kBAAkB;AAAA,IACnC,EAAE,MAAM,UAAU,cAAc,MAAM;AAAA,IACtC,EAAE,MAAM,MAAM,cAAc,MAAM;AAAA,EAAA,CACnC;AACH;AAEa,MAAA,oCAAoC,CAAC,gBAA6B;AAC7E,SAAO,YAAY,kBAAkB;AAAA,IACnC,EAAE,MAAM,aAAa,WAAW,OAAO,cAAc,MAAM;AAAA,IAC3D,EAAE,MAAM,MAAM,cAAc,MAAM;AAAA,EAAA,CACnC;AACH;AAEa,MAAA,yBAAyB,CAAC,gBAA6B;AAC3D,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V,CAAC,YAAY,SAAS,GAAG;AAAA,UACvB,MAAM;AAAA,QACR;AAAA,QACA,GAAG;AAAA,QACH,GAAG,oBAAoB,aAAa,WAAW;AAAA,MACjD;AAAA,MACA,SAAS,YAAY;AAAA,MACrB,aAAa,YAAY;AAAA,MACzB,YAAY,aAAa,cAAc,CAAC;AAAA,IAAA;AAItC,QAAA,YAAY,cAAc,eAAe;AAC3C,YAAM,UAAU;AAAA,QACd,GAAI,MAAM,WAAW,CAAC;AAAA,QACtB;AAAA,UACE,MAAM,YAAY,aAAa,CAAC,YAAY,gBAAgB,WAAW,CAAC;AAAA;AAAA,UAExE,SAAS,CAAC,cAAc,UAAU,aAAa,EAC5C,OAAO,CAAC,MAAM,MAAM,WAAW,CAAC,CAAC,EACjC,IAAI,CAAC,SAAS,YAAY,cAAcA,oBAAE,UAAU,IAAI,CAAC,CAAC;AAAA,QAC/D;AAAA,MAAA;AAAA,IAEJ;AAEA,WAAO,KAAK,KAAK;AAAA,EAAA,CAClB;AAEM,SAAA;AACT;;;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { createId } from "@paralleldrive/cuid2";
2
2
  import assert from "node:assert";
3
- import _ from "lodash/fp";
3
+ import fp from "lodash/fp";
4
4
  const getComponentJoinTableName = (collectionName, identifiers) => {
5
5
  return identifiers.getNameFromTokens([
6
6
  { name: collectionName, compressible: true },
@@ -228,7 +228,7 @@ const transformContentTypesToModels = (contentTypes, identifiers) => {
228
228
  const documentIdAttribute = contentType.modelType === "contentType" ? { documentId: { type: "string", default: createDocumentId } } : {};
229
229
  const reservedAttributeNames = ["document_id", identifiers.ID_COLUMN];
230
230
  Object.keys(contentType.attributes || {}).forEach((attributeName) => {
231
- const snakeCasedAttributeName = _.snakeCase(attributeName);
231
+ const snakeCasedAttributeName = fp.snakeCase(attributeName);
232
232
  if (reservedAttributeNames.includes(snakeCasedAttributeName)) {
233
233
  throw new Error(
234
234
  `The attribute "${attributeName}" is reserved and cannot be used in a model. Please rename "${contentType.modelName}" attribute "${attributeName}" to something else.`
@@ -252,7 +252,8 @@ const transformContentTypesToModels = (contentTypes, identifiers) => {
252
252
  ...transformAttributes(contentType, identifiers)
253
253
  },
254
254
  indexes: contentType.indexes,
255
- foreignKeys: contentType.foreignKeys
255
+ foreignKeys: contentType.foreignKeys,
256
+ lifecycles: contentType?.lifecycles ?? {}
256
257
  };
257
258
  if (contentType.modelType === "contentType") {
258
259
  model.indexes = [
@@ -260,7 +261,7 @@ const transformContentTypesToModels = (contentTypes, identifiers) => {
260
261
  {
261
262
  name: identifiers.getIndexName([contentType.collectionName, "documents"]),
262
263
  // Filter attributes that are not in the schema
263
- columns: ["documentId", "locale", "publishedAt"].filter((n) => model.attributes[n]).map((name) => identifiers.getColumnName(_.snakeCase(name)))
264
+ columns: ["documentId", "locale", "publishedAt"].filter((n) => model.attributes[n]).map((name) => identifiers.getColumnName(fp.snakeCase(name)))
264
265
  }
265
266
  ];
266
267
  }
@@ -1 +1 @@
1
- {"version":3,"file":"transform-content-types-to-models.mjs","sources":["../../src/utils/transform-content-types-to-models.ts"],"sourcesContent":["import { type Model, type Identifiers } from '@strapi/database';\nimport type { Struct, Schema } from '@strapi/types';\nimport { createId } from '@paralleldrive/cuid2';\nimport assert from 'node:assert';\nimport _ from 'lodash/fp';\n\n/**\n * Because strapi/database models don't know about things like components or dynamic zones, we use this file to convert them\n * to a relations format that it recognizes\n *\n * Therefore we have to keep an additional set of helpers/extensions to the database naming methods\n *\n * IMPORTANT!\n * If we use short versions of anything, we MUST call getNameFromTokens directly; attempting to shorten them ourselves\n * prevents the unshortened name map from being filled properly, so for example it will think that the short name\n * 'collection4f3a_cmps' maps to the unshortened 'collectionname_cmps' rather than 'collectionname_components'\n * Therefore, we only use the identifiers helpers in cases where we do not do any of our own shortening\n */\n\nexport const getComponentJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getDzJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnEntityName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'entity', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnInverseName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'component', shortName: 'cmp', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentTypeColumn = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([{ name: 'component_type', compressible: false }]);\n};\n\nexport const getComponentFkIndexName = (contentType: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: contentType, compressible: true },\n { name: 'entity', compressible: false },\n { name: 'fk', compressible: false },\n ]);\n};\n\n// const { ID_COLUMN: id, FIELD_COLUMN: field, ORDER_COLUMN: order } = identifiers;\n\nexport type LoadedContentTypeModel = Struct.ContentTypeSchema &\n Required<Pick<Struct.ContentTypeSchema, 'collectionName' | 'uid' | 'modelName'>>;\n\n// Transforms an attribute (particularly for relation types) into the format that strapi/database accepts\nexport const transformAttribute = (\n name: string,\n attribute: Schema.Attribute.AnyAttribute,\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n switch (attribute.type) {\n case 'media': {\n return {\n type: 'relation',\n relation: attribute.multiple === true ? 'morphMany' : 'morphOne',\n target: 'plugin::upload.file',\n morphBy: 'related',\n };\n }\n case 'component': {\n const joinTableName = getComponentJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n return {\n type: 'relation',\n relation: attribute.repeatable === true ? 'oneToMany' : 'oneToOne',\n target: attribute.component,\n\n // We need the join table name to be deterministic,\n // We need to allow passing the join table name as an option\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n inverseJoinColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n on: {\n field: name,\n },\n orderColumnName: identifiers.ORDER_COLUMN,\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n case 'dynamiczone': {\n const joinTableName = getDzJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n\n return {\n type: 'relation',\n relation: 'morphToMany',\n // TODO: handle restrictions at some point\n // target: attribute.components,\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n morphColumn: {\n idColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n typeColumn: {\n name: compTypeColumn,\n },\n typeField: '__component',\n },\n on: {\n field: name,\n },\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n default: {\n return attribute;\n }\n }\n};\n\nexport const transformAttributes = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n return Object.keys(contentType.attributes! || {}).reduce((attrs, attrName) => {\n return {\n ...attrs,\n [attrName]: transformAttribute(\n attrName,\n contentType.attributes[attrName]!,\n contentType,\n identifiers\n ),\n };\n }, {});\n};\n\nexport const hasComponentsOrDz = (\n contentType: LoadedContentTypeModel\n): contentType is LoadedContentTypeModel & { type: 'dynamiczone' | 'component' } => {\n return Object.values(contentType.attributes || {}).some(\n (({ type }: { type: string }) => type === 'dynamiczone' || type === 'component') as any\n );\n};\n\nexport const createDocumentId = createId;\n\nconst createCompoLinkModel = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n): Model => {\n const name = getComponentJoinTableName(contentType.collectionName, identifiers);\n\n const entityId = getComponentJoinColumnEntityName(identifiers);\n const componentId = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n const fkIndex = getComponentFkIndexName(contentType.collectionName, identifiers);\n\n return {\n // TODO: make sure there can't be any conflicts with a prefix\n singularName: name,\n uid: name,\n tableName: name,\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n [entityId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [componentId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [compTypeColumn]: {\n type: 'string',\n },\n [identifiers.FIELD_COLUMN]: {\n type: 'string',\n },\n [identifiers.ORDER_COLUMN]: {\n type: 'float',\n column: {\n unsigned: true,\n defaultTo: null,\n },\n },\n },\n indexes: [\n {\n name: identifiers.getIndexName([contentType.collectionName, identifiers.FIELD_COLUMN]),\n columns: [identifiers.FIELD_COLUMN],\n },\n {\n name: identifiers.getIndexName([contentType.collectionName, compTypeColumn]),\n columns: [compTypeColumn],\n },\n {\n name: fkIndex,\n columns: [entityId],\n },\n {\n // NOTE: since we don't include attribute names, we need to be careful not to create another unique index\n name: identifiers.getUniqueIndexName([contentType.collectionName]),\n columns: [entityId, componentId, identifiers.FIELD_COLUMN, compTypeColumn],\n type: 'unique',\n },\n ],\n foreignKeys: [\n {\n name: fkIndex,\n columns: [entityId],\n referencedColumns: [identifiers.ID_COLUMN],\n referencedTable: identifiers.getTableName(contentType.collectionName),\n onDelete: 'CASCADE',\n },\n ],\n };\n};\n\nexport const transformContentTypesToModels = (\n contentTypes: LoadedContentTypeModel[],\n identifiers: Identifiers\n): Model[] => {\n const models: Model[] = [];\n\n contentTypes.forEach((contentType) => {\n assert(contentType.collectionName, 'Content type \"collectionName\" is required');\n assert(contentType.modelName, 'Content type \"modelName\" is required');\n assert(contentType.uid, 'Content type \"uid\" is required');\n\n // Add document id to content types\n // as it is not documented\n const documentIdAttribute: Record<string, Schema.Attribute.AnyAttribute> =\n contentType.modelType === 'contentType'\n ? { documentId: { type: 'string', default: createDocumentId } }\n : {};\n\n // TODO: this needs to be combined with getReservedNames, we should not be maintaining two lists\n // Prevent user from creating a documentId attribute\n const reservedAttributeNames = ['document_id', identifiers.ID_COLUMN];\n Object.keys(contentType.attributes || {}).forEach((attributeName) => {\n const snakeCasedAttributeName = _.snakeCase(attributeName);\n if (reservedAttributeNames.includes(snakeCasedAttributeName)) {\n throw new Error(\n `The attribute \"${attributeName}\" is reserved and cannot be used in a model. Please rename \"${contentType.modelName}\" attribute \"${attributeName}\" to something else.`\n );\n }\n });\n\n if (hasComponentsOrDz(contentType)) {\n const compoLinkModel = createCompoLinkModel(contentType, identifiers);\n models.push(compoLinkModel);\n }\n\n const model: Model = {\n uid: contentType.uid,\n singularName: contentType.modelName,\n tableName: contentType.collectionName, // This gets shortened in metadata.loadModels(), so we don't shorten here or it will happen twice\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n ...documentIdAttribute,\n ...transformAttributes(contentType, identifiers),\n },\n indexes: contentType.indexes as Model['indexes'],\n foreignKeys: contentType.foreignKeys as Model['foreignKeys'],\n };\n\n // Add indexes to model\n if (contentType.modelType === 'contentType') {\n model.indexes = [\n ...(model.indexes || []),\n {\n name: identifiers.getIndexName([contentType.collectionName, 'documents']),\n // Filter attributes that are not in the schema\n columns: ['documentId', 'locale', 'publishedAt']\n .filter((n) => model.attributes[n])\n .map((name) => identifiers.getColumnName(_.snakeCase(name))),\n },\n ];\n }\n\n models.push(model);\n });\n\n return models;\n};\n"],"names":[],"mappings":";;;AAmBa,MAAA,4BAA4B,CAAC,gBAAwB,gBAA6B;AAC7F,SAAO,YAAY,kBAAkB;AAAA,IACnC,EAAE,MAAM,gBA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,SAAA;AACT;"}
1
+ {"version":3,"file":"transform-content-types-to-models.mjs","sources":["../../src/utils/transform-content-types-to-models.ts"],"sourcesContent":["import { type Model, type Identifiers } from '@strapi/database';\nimport type { Struct, Schema } from '@strapi/types';\nimport { createId } from '@paralleldrive/cuid2';\nimport assert from 'node:assert';\nimport _ from 'lodash/fp';\n\n/**\n * Because strapi/database models don't know about things like components or dynamic zones, we use this file to convert them\n * to a relations format that it recognizes\n *\n * Therefore we have to keep an additional set of helpers/extensions to the database naming methods\n *\n * IMPORTANT!\n * If we use short versions of anything, we MUST call getNameFromTokens directly; attempting to shorten them ourselves\n * prevents the unshortened name map from being filled properly, so for example it will think that the short name\n * 'collection4f3a_cmps' maps to the unshortened 'collectionname_cmps' rather than 'collectionname_components'\n * Therefore, we only use the identifiers helpers in cases where we do not do any of our own shortening\n */\n\nexport const getComponentJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getDzJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnEntityName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'entity', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnInverseName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'component', shortName: 'cmp', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentTypeColumn = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([{ name: 'component_type', compressible: false }]);\n};\n\nexport const getComponentFkIndexName = (contentType: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: contentType, compressible: true },\n { name: 'entity', compressible: false },\n { name: 'fk', compressible: false },\n ]);\n};\n\n// const { ID_COLUMN: id, FIELD_COLUMN: field, ORDER_COLUMN: order } = identifiers;\n\nexport type LoadedContentTypeModel = Struct.ContentTypeSchema &\n Required<Pick<Struct.ContentTypeSchema, 'collectionName' | 'uid' | 'modelName'>> &\n Pick<Model, 'lifecycles'>;\n\n// Transforms an attribute (particularly for relation types) into the format that strapi/database accepts\nexport const transformAttribute = (\n name: string,\n attribute: Schema.Attribute.AnyAttribute,\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n switch (attribute.type) {\n case 'media': {\n return {\n type: 'relation',\n relation: attribute.multiple === true ? 'morphMany' : 'morphOne',\n target: 'plugin::upload.file',\n morphBy: 'related',\n };\n }\n case 'component': {\n const joinTableName = getComponentJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n return {\n type: 'relation',\n relation: attribute.repeatable === true ? 'oneToMany' : 'oneToOne',\n target: attribute.component,\n\n // We need the join table name to be deterministic,\n // We need to allow passing the join table name as an option\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n inverseJoinColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n on: {\n field: name,\n },\n orderColumnName: identifiers.ORDER_COLUMN,\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n case 'dynamiczone': {\n const joinTableName = getDzJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n\n return {\n type: 'relation',\n relation: 'morphToMany',\n // TODO: handle restrictions at some point\n // target: attribute.components,\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n morphColumn: {\n idColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n typeColumn: {\n name: compTypeColumn,\n },\n typeField: '__component',\n },\n on: {\n field: name,\n },\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n default: {\n return attribute;\n }\n }\n};\n\nexport const transformAttributes = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n return Object.keys(contentType.attributes! || {}).reduce((attrs, attrName) => {\n return {\n ...attrs,\n [attrName]: transformAttribute(\n attrName,\n contentType.attributes[attrName]!,\n contentType,\n identifiers\n ),\n };\n }, {});\n};\n\nexport const hasComponentsOrDz = (\n contentType: LoadedContentTypeModel\n): contentType is LoadedContentTypeModel & { type: 'dynamiczone' | 'component' } => {\n return Object.values(contentType.attributes || {}).some(\n (({ type }: { type: string }) => type === 'dynamiczone' || type === 'component') as any\n );\n};\n\nexport const createDocumentId = createId;\n\nconst createCompoLinkModel = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n): Model => {\n const name = getComponentJoinTableName(contentType.collectionName, identifiers);\n\n const entityId = getComponentJoinColumnEntityName(identifiers);\n const componentId = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n const fkIndex = getComponentFkIndexName(contentType.collectionName, identifiers);\n\n return {\n // TODO: make sure there can't be any conflicts with a prefix\n singularName: name,\n uid: name,\n tableName: name,\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n [entityId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [componentId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [compTypeColumn]: {\n type: 'string',\n },\n [identifiers.FIELD_COLUMN]: {\n type: 'string',\n },\n [identifiers.ORDER_COLUMN]: {\n type: 'float',\n column: {\n unsigned: true,\n defaultTo: null,\n },\n },\n },\n indexes: [\n {\n name: identifiers.getIndexName([contentType.collectionName, identifiers.FIELD_COLUMN]),\n columns: [identifiers.FIELD_COLUMN],\n },\n {\n name: identifiers.getIndexName([contentType.collectionName, compTypeColumn]),\n columns: [compTypeColumn],\n },\n {\n name: fkIndex,\n columns: [entityId],\n },\n {\n // NOTE: since we don't include attribute names, we need to be careful not to create another unique index\n name: identifiers.getUniqueIndexName([contentType.collectionName]),\n columns: [entityId, componentId, identifiers.FIELD_COLUMN, compTypeColumn],\n type: 'unique',\n },\n ],\n foreignKeys: [\n {\n name: fkIndex,\n columns: [entityId],\n referencedColumns: [identifiers.ID_COLUMN],\n referencedTable: identifiers.getTableName(contentType.collectionName),\n onDelete: 'CASCADE',\n },\n ],\n };\n};\n\nexport const transformContentTypesToModels = (\n contentTypes: LoadedContentTypeModel[],\n identifiers: Identifiers\n): Model[] => {\n const models: Model[] = [];\n\n contentTypes.forEach((contentType) => {\n assert(contentType.collectionName, 'Content type \"collectionName\" is required');\n assert(contentType.modelName, 'Content type \"modelName\" is required');\n assert(contentType.uid, 'Content type \"uid\" is required');\n\n // Add document id to content types\n // as it is not documented\n const documentIdAttribute: Record<string, Schema.Attribute.AnyAttribute> =\n contentType.modelType === 'contentType'\n ? { documentId: { type: 'string', default: createDocumentId } }\n : {};\n\n // TODO: this needs to be combined with getReservedNames, we should not be maintaining two lists\n // Prevent user from creating a documentId attribute\n const reservedAttributeNames = ['document_id', identifiers.ID_COLUMN];\n Object.keys(contentType.attributes || {}).forEach((attributeName) => {\n const snakeCasedAttributeName = _.snakeCase(attributeName);\n if (reservedAttributeNames.includes(snakeCasedAttributeName)) {\n throw new Error(\n `The attribute \"${attributeName}\" is reserved and cannot be used in a model. Please rename \"${contentType.modelName}\" attribute \"${attributeName}\" to something else.`\n );\n }\n });\n\n if (hasComponentsOrDz(contentType)) {\n const compoLinkModel = createCompoLinkModel(contentType, identifiers);\n models.push(compoLinkModel);\n }\n\n const model: Model = {\n uid: contentType.uid,\n singularName: contentType.modelName,\n tableName: contentType.collectionName, // This gets shortened in metadata.loadModels(), so we don't shorten here or it will happen twice\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n ...documentIdAttribute,\n ...transformAttributes(contentType, identifiers),\n },\n indexes: contentType.indexes as Model['indexes'],\n foreignKeys: contentType.foreignKeys as Model['foreignKeys'],\n lifecycles: contentType?.lifecycles ?? {},\n };\n\n // Add indexes to model\n if (contentType.modelType === 'contentType') {\n model.indexes = [\n ...(model.indexes || []),\n {\n name: identifiers.getIndexName([contentType.collectionName, 'documents']),\n // Filter attributes that are not in the schema\n columns: ['documentId', 'locale', 'publishedAt']\n .filter((n) => model.attributes[n])\n .map((name) => identifiers.getColumnName(_.snakeCase(name))),\n },\n ];\n }\n\n models.push(model);\n });\n\n return models;\n};\n"],"names":["_"],"mappings":";;;AAmBa,MAAA,4BAA4B,CAAC,gBAAwB,gBAA6B;AAC7F,SAAO,YAAY,kBAAkB;AAAA,IACnC,EAAE,MAAM,gBAAgB,cAAc,KAAK;AAAA,IAC3C,EAAE,MAAM,cAAc,WAAW,QAAQ,cAAc,MAAM;AAAA,EAAA,CAC9D;AACH;AAEa,MAAA,qBAAqB,CAAC,gBAAwB,gBAA6B;AACtF,SAAO,YAAY,kBAAkB;AAAA,IACnC,EAAE,MAAM,gBAAgB,cAAc,KAAK;AAAA,IAC3C,EAAE,MAAM,cAAc,WAAW,QAAQ,cAAc,MAAM;AAAA,EAAA,CAC9D;AACH;AAEa,MAAA,mCAAmC,CAAC,gBAA6B;AAC5E,SAAO,YAAY,kBAAkB;AAAA,IACnC,EAAE,MAAM,UAAU,cAAc,MAAM;AAAA,IACtC,EAAE,MAAM,MAAM,cAAc,MAAM;AAAA,EAAA,CACnC;AACH;AAEa,MAAA,oCAAoC,CAAC,gBAA6B;AAC7E,SAAO,YAAY,kBAAkB;AAAA,IACnC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e;AAAA,MACnB,KAAK,YAAY;AAAA,MACjB,cAAc,YAAY;AAAA,MAC1B,WAAW,YAAY;AAAA;AAAA,MACvB,YAAY;AAAA,QACV,CAAC,YAAY,SAAS,GAAG;AAAA,UACvB,MAAM;AAAA,QACR;AAAA,QACA,GAAG;AAAA,QACH,GAAG,oBAAoB,aAAa,WAAW;AAAA,MACjD;AAAA,MACA,SAAS,YAAY;AAAA,MACrB,aAAa,YAAY;AAAA,MACzB,YAAY,aAAa,cAAc,CAAC;AAAA,IAAA;AAItC,QAAA,YAAY,cAAc,eAAe;AAC3C,YAAM,UAAU;AAAA,QACd,GAAI,MAAM,WAAW,CAAC;AAAA,QACtB;AAAA,UACE,MAAM,YAAY,aAAa,CAAC,YAAY,gBAAgB,WAAW,CAAC;AAAA;AAAA,UAExE,SAAS,CAAC,cAAc,UAAU,aAAa,EAC5C,OAAO,CAAC,MAAM,MAAM,WAAW,CAAC,CAAC,EACjC,IAAI,CAAC,SAAS,YAAY,cAAcA,GAAE,UAAU,IAAI,CAAC,CAAC;AAAA,QAC/D;AAAA,MAAA;AAAA,IAEJ;AAEA,WAAO,KAAK,KAAK;AAAA,EAAA,CAClB;AAEM,SAAA;AACT;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/core",
3
- "version": "5.0.0-rc.2",
3
+ "version": "5.0.0-rc.20",
4
4
  "description": "Core of Strapi",
5
5
  "homepage": "https://strapi.io",
6
6
  "bugs": {
@@ -55,16 +55,15 @@
55
55
  "@koa/cors": "5.0.0",
56
56
  "@koa/router": "12.0.1",
57
57
  "@paralleldrive/cuid2": "2.2.2",
58
- "@strapi/admin": "5.0.0-rc.2",
59
- "@strapi/database": "5.0.0-rc.2",
60
- "@strapi/generate-new": "5.0.0-rc.2",
61
- "@strapi/generators": "5.0.0-rc.2",
62
- "@strapi/logger": "5.0.0-rc.2",
58
+ "@strapi/admin": "5.0.0-rc.20",
59
+ "@strapi/database": "5.0.0-rc.20",
60
+ "@strapi/generators": "5.0.0-rc.20",
61
+ "@strapi/logger": "5.0.0-rc.20",
63
62
  "@strapi/pack-up": "5.0.0",
64
- "@strapi/permissions": "5.0.0-rc.2",
65
- "@strapi/types": "5.0.0-rc.2",
66
- "@strapi/typescript-utils": "5.0.0-rc.2",
67
- "@strapi/utils": "5.0.0-rc.2",
63
+ "@strapi/permissions": "5.0.0-rc.20",
64
+ "@strapi/types": "5.0.0-rc.20",
65
+ "@strapi/typescript-utils": "5.0.0-rc.20",
66
+ "@strapi/utils": "5.0.0-rc.20",
68
67
  "bcryptjs": "2.4.3",
69
68
  "boxen": "5.1.2",
70
69
  "chalk": "4.1.2",
@@ -94,12 +93,13 @@
94
93
  "koa-static": "5.0.0",
95
94
  "lodash": "4.17.21",
96
95
  "mime-types": "2.1.35",
97
- "node-schedule": "2.1.0",
96
+ "node-schedule": "2.1.1",
98
97
  "open": "8.4.0",
99
98
  "ora": "5.4.1",
100
99
  "package-json": "7.0.0",
101
100
  "pkg-up": "3.1.0",
102
101
  "qs": "6.11.1",
102
+ "resolve.exports": "2.0.2",
103
103
  "semver": "7.5.4",
104
104
  "statuses": "2.0.1",
105
105
  "typescript": "5.2.2",
@@ -124,15 +124,15 @@
124
124
  "@types/lodash": "^4.14.191",
125
125
  "@types/mime-types": "2.1.1",
126
126
  "@types/node": "18.19.24",
127
- "@types/node-schedule": "2.1.0",
127
+ "@types/node-schedule": "2.1.7",
128
128
  "@types/statuses": "2.0.1",
129
- "eslint-config-custom": "5.0.0-rc.2",
129
+ "eslint-config-custom": "5.0.0-rc.20",
130
130
  "supertest": "6.3.3",
131
- "tsconfig": "5.0.0-rc.2"
131
+ "tsconfig": "5.0.0-rc.20"
132
132
  },
133
133
  "engines": {
134
134
  "node": ">=18.0.0 <=20.x.x",
135
135
  "npm": ">=6.0.0"
136
136
  },
137
- "gitHead": "c3f078328f8506cd543f6635b992d8648cb8c501"
137
+ "gitHead": "e1f26c862f255e83fc7637a745fd54e39db1a839"
138
138
  }