@strapi/core 0.0.0-experimental.74c69aeafc770d59d5b3d5d37cd249934ef395ba → 0.0.0-experimental.7afdc9b682bc83a53ce599c4fb7c9e4506b31fff

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (157) hide show
  1. package/dist/core-api/controller/collection-type.d.ts.map +1 -1
  2. package/dist/core-api/controller/collection-type.js +3 -0
  3. package/dist/core-api/controller/collection-type.js.map +1 -1
  4. package/dist/core-api/controller/collection-type.mjs +3 -0
  5. package/dist/core-api/controller/collection-type.mjs.map +1 -1
  6. package/dist/core-api/controller/single-type.d.ts.map +1 -1
  7. package/dist/core-api/controller/single-type.js +1 -0
  8. package/dist/core-api/controller/single-type.js.map +1 -1
  9. package/dist/core-api/controller/single-type.mjs +1 -0
  10. package/dist/core-api/controller/single-type.mjs.map +1 -1
  11. package/dist/core-api/routes/index.d.ts.map +1 -1
  12. package/dist/core-api/service/collection-type.d.ts +1 -7
  13. package/dist/core-api/service/collection-type.d.ts.map +1 -1
  14. package/dist/core-api/service/collection-type.js +5 -3
  15. package/dist/core-api/service/collection-type.js.map +1 -1
  16. package/dist/core-api/service/collection-type.mjs +6 -4
  17. package/dist/core-api/service/collection-type.mjs.map +1 -1
  18. package/dist/core-api/service/pagination.d.ts +4 -11
  19. package/dist/core-api/service/pagination.d.ts.map +1 -1
  20. package/dist/core-api/service/pagination.js +14 -40
  21. package/dist/core-api/service/pagination.js.map +1 -1
  22. package/dist/core-api/service/pagination.mjs +16 -42
  23. package/dist/core-api/service/pagination.mjs.map +1 -1
  24. package/dist/core-api/service/single-type.d.ts.map +1 -1
  25. package/dist/core-api/service/single-type.js +2 -1
  26. package/dist/core-api/service/single-type.js.map +1 -1
  27. package/dist/core-api/service/single-type.mjs +2 -1
  28. package/dist/core-api/service/single-type.mjs.map +1 -1
  29. package/dist/ee/license.d.ts.map +1 -1
  30. package/dist/ee/license.js +2 -1
  31. package/dist/ee/license.js.map +1 -1
  32. package/dist/ee/license.mjs +2 -1
  33. package/dist/ee/license.mjs.map +1 -1
  34. package/dist/factories.d.ts +2 -2
  35. package/dist/factories.d.ts.map +1 -1
  36. package/dist/loaders/apis.d.ts.map +1 -1
  37. package/dist/loaders/apis.js +10 -10
  38. package/dist/loaders/apis.js.map +1 -1
  39. package/dist/loaders/apis.mjs +10 -10
  40. package/dist/loaders/apis.mjs.map +1 -1
  41. package/dist/loaders/plugins/get-enabled-plugins.d.ts.map +1 -1
  42. package/dist/loaders/plugins/get-enabled-plugins.js +5 -5
  43. package/dist/loaders/plugins/get-enabled-plugins.js.map +1 -1
  44. package/dist/loaders/plugins/get-enabled-plugins.mjs +5 -5
  45. package/dist/loaders/plugins/get-enabled-plugins.mjs.map +1 -1
  46. package/dist/migrations/database/5.0.0-discard-drafts.d.ts +30 -0
  47. package/dist/migrations/database/5.0.0-discard-drafts.d.ts.map +1 -0
  48. package/dist/migrations/database/5.0.0-discard-drafts.js +50 -0
  49. package/dist/migrations/database/5.0.0-discard-drafts.js.map +1 -0
  50. package/dist/migrations/database/5.0.0-discard-drafts.mjs +50 -0
  51. package/dist/migrations/database/5.0.0-discard-drafts.mjs.map +1 -0
  52. package/dist/migrations/draft-publish.d.ts.map +1 -1
  53. package/dist/migrations/draft-publish.js +14 -31
  54. package/dist/migrations/draft-publish.js.map +1 -1
  55. package/dist/migrations/draft-publish.mjs +15 -32
  56. package/dist/migrations/draft-publish.mjs.map +1 -1
  57. package/dist/providers/registries.d.ts.map +1 -1
  58. package/dist/providers/registries.js +2 -0
  59. package/dist/providers/registries.js.map +1 -1
  60. package/dist/providers/registries.mjs +2 -0
  61. package/dist/providers/registries.mjs.map +1 -1
  62. package/dist/services/core-store.d.ts.map +1 -1
  63. package/dist/services/document-service/attributes/index.d.ts +4 -4
  64. package/dist/services/document-service/attributes/index.d.ts.map +1 -1
  65. package/dist/services/document-service/attributes/index.js +5 -5
  66. package/dist/services/document-service/attributes/index.js.map +1 -1
  67. package/dist/services/document-service/attributes/index.mjs +5 -5
  68. package/dist/services/document-service/attributes/index.mjs.map +1 -1
  69. package/dist/services/document-service/common.d.ts.map +1 -1
  70. package/dist/services/document-service/components.d.ts +8 -80
  71. package/dist/services/document-service/components.d.ts.map +1 -1
  72. package/dist/services/document-service/components.js +18 -19
  73. package/dist/services/document-service/components.js.map +1 -1
  74. package/dist/services/document-service/components.mjs +19 -20
  75. package/dist/services/document-service/components.mjs.map +1 -1
  76. package/dist/services/document-service/entries.d.ts +3 -1
  77. package/dist/services/document-service/entries.d.ts.map +1 -1
  78. package/dist/services/document-service/entries.js +49 -15
  79. package/dist/services/document-service/entries.js.map +1 -1
  80. package/dist/services/document-service/entries.mjs +44 -10
  81. package/dist/services/document-service/entries.mjs.map +1 -1
  82. package/dist/services/document-service/events.d.ts +25 -0
  83. package/dist/services/document-service/events.d.ts.map +1 -0
  84. package/dist/services/document-service/events.js +47 -0
  85. package/dist/services/document-service/events.js.map +1 -0
  86. package/dist/services/document-service/events.mjs +47 -0
  87. package/dist/services/document-service/events.mjs.map +1 -0
  88. package/dist/services/document-service/index.d.ts.map +1 -1
  89. package/dist/services/document-service/index.js +9 -2
  90. package/dist/services/document-service/index.js.map +1 -1
  91. package/dist/services/document-service/index.mjs +9 -2
  92. package/dist/services/document-service/index.mjs.map +1 -1
  93. package/dist/services/document-service/internationalization.d.ts.map +1 -1
  94. package/dist/services/document-service/internationalization.js +14 -5
  95. package/dist/services/document-service/internationalization.js.map +1 -1
  96. package/dist/services/document-service/internationalization.mjs +14 -5
  97. package/dist/services/document-service/internationalization.mjs.map +1 -1
  98. package/dist/services/document-service/middlewares/middleware-manager.d.ts +5 -2
  99. package/dist/services/document-service/middlewares/middleware-manager.d.ts.map +1 -1
  100. package/dist/services/document-service/middlewares/middleware-manager.js +6 -3
  101. package/dist/services/document-service/middlewares/middleware-manager.js.map +1 -1
  102. package/dist/services/document-service/middlewares/middleware-manager.mjs +6 -3
  103. package/dist/services/document-service/middlewares/middleware-manager.mjs.map +1 -1
  104. package/dist/services/document-service/params.d.ts +1 -5
  105. package/dist/services/document-service/params.d.ts.map +1 -1
  106. package/dist/services/document-service/repository.d.ts.map +1 -1
  107. package/dist/services/document-service/repository.js +82 -80
  108. package/dist/services/document-service/repository.js.map +1 -1
  109. package/dist/services/document-service/repository.mjs +77 -75
  110. package/dist/services/document-service/repository.mjs.map +1 -1
  111. package/dist/services/document-service/transform/id-map.d.ts.map +1 -1
  112. package/dist/services/document-service/transform/relations/extract/data-ids.d.ts.map +1 -1
  113. package/dist/services/document-service/transform/relations/extract/data-ids.js +3 -0
  114. package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -1
  115. package/dist/services/document-service/transform/relations/extract/data-ids.mjs +3 -0
  116. package/dist/services/document-service/transform/relations/extract/data-ids.mjs.map +1 -1
  117. package/dist/services/document-service/transform/relations/transform/data-ids.d.ts.map +1 -1
  118. package/dist/services/document-service/transform/relations/transform/data-ids.js +3 -0
  119. package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
  120. package/dist/services/document-service/transform/relations/transform/data-ids.mjs +3 -0
  121. package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
  122. package/dist/services/document-service/transform/relations/utils/map-relation.d.ts.map +1 -1
  123. package/dist/services/document-service/transform/relations/utils/map-relation.js +7 -3
  124. package/dist/services/document-service/transform/relations/utils/map-relation.js.map +1 -1
  125. package/dist/services/document-service/transform/relations/utils/map-relation.mjs +7 -3
  126. package/dist/services/document-service/transform/relations/utils/map-relation.mjs.map +1 -1
  127. package/dist/services/entity-service/index.d.ts.map +1 -1
  128. package/dist/services/entity-validator/index.js.map +1 -1
  129. package/dist/services/entity-validator/index.mjs.map +1 -1
  130. package/dist/services/event-hub.d.ts +1 -0
  131. package/dist/services/event-hub.d.ts.map +1 -1
  132. package/dist/services/event-hub.js +9 -4
  133. package/dist/services/event-hub.js.map +1 -1
  134. package/dist/services/event-hub.mjs +9 -4
  135. package/dist/services/event-hub.mjs.map +1 -1
  136. package/dist/services/metrics/middleware.d.ts.map +1 -1
  137. package/dist/services/server/compose-endpoint.d.ts.map +1 -1
  138. package/dist/services/server/koa.d.ts.map +1 -1
  139. package/dist/services/server/koa.js +1 -1
  140. package/dist/services/server/koa.js.map +1 -1
  141. package/dist/services/server/koa.mjs +1 -1
  142. package/dist/services/server/koa.mjs.map +1 -1
  143. package/dist/services/webhook-runner.d.ts +2 -1
  144. package/dist/services/webhook-runner.d.ts.map +1 -1
  145. package/dist/services/webhook-runner.js.map +1 -1
  146. package/dist/services/webhook-runner.mjs.map +1 -1
  147. package/dist/services/webhook-store.d.ts +2 -8
  148. package/dist/services/webhook-store.d.ts.map +1 -1
  149. package/dist/services/webhook-store.js +9 -2
  150. package/dist/services/webhook-store.js.map +1 -1
  151. package/dist/services/webhook-store.mjs +9 -2
  152. package/dist/services/webhook-store.mjs.map +1 -1
  153. package/dist/utils/load-files.d.ts.map +1 -1
  154. package/dist/utils/startup-logger.d.ts.map +1 -1
  155. package/package.json +21 -19
  156. package/dist/services/document-service/document-engine.d.ts +0 -2
  157. package/dist/services/document-service/document-engine.d.ts.map +0 -1
@@ -0,0 +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 */\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;;;"}
@@ -0,0 +1,50 @@
1
+ import { contentTypes, async } from "@strapi/utils";
2
+ async function* getBatchToDiscard({
3
+ db,
4
+ trx,
5
+ uid,
6
+ batchSize = 1e3
7
+ }) {
8
+ let offset = 0;
9
+ let hasMore = true;
10
+ while (hasMore) {
11
+ const batch = await db.queryBuilder(uid).select(["id", "documentId", "locale"]).where({ publishedAt: { $ne: null } }).limit(batchSize).offset(offset).orderBy("id").transacting(trx).execute();
12
+ if (batch.length < batchSize) {
13
+ hasMore = false;
14
+ }
15
+ offset += batchSize;
16
+ yield batch;
17
+ }
18
+ }
19
+ const migrateUp = async (trx, db) => {
20
+ for (const meta of db.metadata.values()) {
21
+ const hasTable = await trx.schema.hasTable(meta.tableName);
22
+ if (!hasTable) {
23
+ continue;
24
+ }
25
+ const uid = meta.uid;
26
+ const model = strapi.getModel(uid);
27
+ const hasDP = contentTypes.hasDraftAndPublish(model);
28
+ if (!hasDP) {
29
+ continue;
30
+ }
31
+ const discardDraft = async (entry) => strapi.documents(uid).discardDraft({ documentId: entry.documentId, locale: entry.locale });
32
+ for await (const batch of getBatchToDiscard({ db, trx, uid: meta.uid })) {
33
+ await async.map(batch, discardDraft, { concurrency: 10 });
34
+ }
35
+ }
36
+ };
37
+ const discardDocumentDrafts = {
38
+ name: "core::5.0.0-discard-drafts",
39
+ async up(trx, db) {
40
+ await migrateUp(trx, db);
41
+ },
42
+ async down() {
43
+ throw new Error("not implemented");
44
+ }
45
+ };
46
+ export {
47
+ discardDocumentDrafts,
48
+ getBatchToDiscard
49
+ };
50
+ //# sourceMappingURL=5.0.0-discard-drafts.mjs.map
@@ -0,0 +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 */\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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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,iB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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 +1 @@
1
- {"version":3,"file":"registries.d.ts","sourceRoot":"","sources":["../../src/providers/registries.ts"],"names":[],"mappings":";AAOA,wBA2BG"}
1
+ {"version":3,"file":"registries.d.ts","sourceRoot":"","sources":["../../src/providers/registries.ts"],"names":[],"mappings":";AAQA,wBA+BG"}
@@ -17,6 +17,7 @@ const validators = require("../registries/validators.js");
17
17
  const models = require("../registries/models.js");
18
18
  const index = require("../loaders/index.js");
19
19
  const draftPublish = require("../migrations/draft-publish.js");
20
+ const _5_0_0DiscardDrafts = require("../migrations/database/5.0.0-discard-drafts.js");
20
21
  const registries = provider.defineProvider({
21
22
  init(strapi) {
22
23
  strapi.add("content-types", () => contentTypes()).add("components", () => components()).add("services", () => services(strapi)).add("policies", () => policies()).add("middlewares", () => middlewares()).add("hooks", () => hooks()).add("controllers", () => controllers(strapi)).add("modules", () => modules(strapi)).add("plugins", () => plugins(strapi)).add("custom-fields", () => customFields(strapi)).add("apis", () => apis(strapi)).add("models", () => models.registry()).add("sanitizers", sanitizers()).add("validators", validators());
@@ -27,6 +28,7 @@ const registries = provider.defineProvider({
27
28
  strapi.get("hooks").set("strapi::content-types.afterSync", strapiUtils.hooks.createAsyncParallelHook());
28
29
  strapi.hook("strapi::content-types.beforeSync").register(draftPublish.disable);
29
30
  strapi.hook("strapi::content-types.afterSync").register(draftPublish.enable);
31
+ strapi.db.migrations.providers.internal.register(_5_0_0DiscardDrafts.discardDocumentDrafts);
30
32
  }
31
33
  });
32
34
  module.exports = registries;
@@ -1 +1 @@
1
- {"version":3,"file":"registries.js","sources":["../../src/providers/registries.ts"],"sourcesContent":["import { hooks } from '@strapi/utils';\n\nimport { defineProvider } from './provider';\nimport * as registries from '../registries';\nimport { loadApplicationContext } from '../loaders';\nimport * as draftAndPublishSync from '../migrations/draft-publish';\n\nexport default defineProvider({\n init(strapi) {\n strapi\n .add('content-types', () => registries.contentTypes())\n .add('components', () => registries.components())\n .add('services', () => registries.services(strapi))\n .add('policies', () => registries.policies())\n .add('middlewares', () => registries.middlewares())\n .add('hooks', () => registries.hooks())\n .add('controllers', () => registries.controllers(strapi))\n .add('modules', () => registries.modules(strapi))\n .add('plugins', () => registries.plugins(strapi))\n .add('custom-fields', () => registries.customFields(strapi))\n .add('apis', () => registries.apis(strapi))\n .add('models', () => registries.models())\n .add('sanitizers', registries.sanitizers())\n .add('validators', registries.validators());\n },\n async register(strapi) {\n await loadApplicationContext(strapi);\n\n strapi.get('hooks').set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n strapi.get('hooks').set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n\n strapi.hook('strapi::content-types.beforeSync').register(draftAndPublishSync.disable);\n strapi.hook('strapi::content-types.afterSync').register(draftAndPublishSync.enable);\n },\n});\n"],"names":["defineProvider","registries.contentTypes","registries.components","registries.services","registries.policies","registries.middlewares","registries.hooks","registries.controllers","registries.modules","registries.plugins","registries.customFields","registries.apis","registries.models","registries.sanitizers","registries.validators","loadApplicationContext","hooks","draftAndPublishSync.disable","draftAndPublishSync.enable"],"mappings":";;;;;;;;;;;;;;;;;;;AAOA,MAAA,aAAeA,wBAAe;AAAA,EAC5B,KAAK,QAAQ;AAER,WAAA,IAAI,iBAAiB,MAAMC,aAAyB,CAAA,EACpD,IAAI,cAAc,MAAMC,WAAuB,CAAA,EAC/C,IAAI,YAAY,MAAMC,SAAoB,MAAM,CAAC,EACjD,IAAI,YAAY,MAAMC,SAAqB,CAAA,EAC3C,IAAI,eAAe,MAAMC,YAAuB,CAAC,EACjD,IAAI,SAAS,MAAMC,OAAkB,EACrC,IAAI,eAAe,MAAMC,YAAuB,MAAM,CAAC,EACvD,IAAI,WAAW,MAAMC,QAAmB,MAAM,CAAC,EAC/C,IAAI,WAAW,MAAMC,QAAmB,MAAM,CAAC,EAC/C,IAAI,iBAAiB,MAAMC,aAAwB,MAAM,CAAC,EAC1D,IAAI,QAAQ,MAAMC,KAAgB,MAAM,CAAC,EACzC,IAAI,UAAU,MAAMC,gBAAmB,CAAA,EACvC,IAAI,cAAcC,YAAuB,EACzC,IAAI,cAAcC,WAAW,CAAY;AAAA,EAC9C;AAAA,EACA,MAAM,SAAS,QAAQ;AACrB,UAAMC,MAAAA,uBAAuB,MAAM;AAEnC,WAAO,IAAI,OAAO,EAAE,IAAI,oCAAoCC,YAAA,MAAM,yBAAyB;AAC3F,WAAO,IAAI,OAAO,EAAE,IAAI,mCAAmCA,YAAA,MAAM,yBAAyB;AAE1F,WAAO,KAAK,kCAAkC,EAAE,SAASC,aAA2B,OAAA;AACpF,WAAO,KAAK,iCAAiC,EAAE,SAASC,aAA0B,MAAA;AAAA,EACpF;AACF,CAAC;;"}
1
+ {"version":3,"file":"registries.js","sources":["../../src/providers/registries.ts"],"sourcesContent":["import { hooks } from '@strapi/utils';\n\nimport { defineProvider } from './provider';\nimport * as registries from '../registries';\nimport { loadApplicationContext } from '../loaders';\nimport * as draftAndPublishSync from '../migrations/draft-publish';\nimport { discardDocumentDrafts } from '../migrations/database/5.0.0-discard-drafts';\n\nexport default defineProvider({\n init(strapi) {\n strapi\n .add('content-types', () => registries.contentTypes())\n .add('components', () => registries.components())\n .add('services', () => registries.services(strapi))\n .add('policies', () => registries.policies())\n .add('middlewares', () => registries.middlewares())\n .add('hooks', () => registries.hooks())\n .add('controllers', () => registries.controllers(strapi))\n .add('modules', () => registries.modules(strapi))\n .add('plugins', () => registries.plugins(strapi))\n .add('custom-fields', () => registries.customFields(strapi))\n .add('apis', () => registries.apis(strapi))\n .add('models', () => registries.models())\n .add('sanitizers', registries.sanitizers())\n .add('validators', registries.validators());\n },\n async register(strapi) {\n await loadApplicationContext(strapi);\n\n strapi.get('hooks').set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n strapi.get('hooks').set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n\n // Content migration to enable draft and publish\n strapi.hook('strapi::content-types.beforeSync').register(draftAndPublishSync.disable);\n strapi.hook('strapi::content-types.afterSync').register(draftAndPublishSync.enable);\n\n // Database migrations\n strapi.db.migrations.providers.internal.register(discardDocumentDrafts);\n },\n});\n"],"names":["defineProvider","registries.contentTypes","registries.components","registries.services","registries.policies","registries.middlewares","registries.hooks","registries.controllers","registries.modules","registries.plugins","registries.customFields","registries.apis","registries.models","registries.sanitizers","registries.validators","loadApplicationContext","hooks","draftAndPublishSync.disable","draftAndPublishSync.enable","discardDocumentDrafts"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQA,MAAA,aAAeA,wBAAe;AAAA,EAC5B,KAAK,QAAQ;AAER,WAAA,IAAI,iBAAiB,MAAMC,aAAyB,CAAA,EACpD,IAAI,cAAc,MAAMC,WAAuB,CAAA,EAC/C,IAAI,YAAY,MAAMC,SAAoB,MAAM,CAAC,EACjD,IAAI,YAAY,MAAMC,SAAqB,CAAA,EAC3C,IAAI,eAAe,MAAMC,YAAuB,CAAC,EACjD,IAAI,SAAS,MAAMC,OAAkB,EACrC,IAAI,eAAe,MAAMC,YAAuB,MAAM,CAAC,EACvD,IAAI,WAAW,MAAMC,QAAmB,MAAM,CAAC,EAC/C,IAAI,WAAW,MAAMC,QAAmB,MAAM,CAAC,EAC/C,IAAI,iBAAiB,MAAMC,aAAwB,MAAM,CAAC,EAC1D,IAAI,QAAQ,MAAMC,KAAgB,MAAM,CAAC,EACzC,IAAI,UAAU,MAAMC,gBAAmB,CAAA,EACvC,IAAI,cAAcC,YAAuB,EACzC,IAAI,cAAcC,WAAW,CAAY;AAAA,EAC9C;AAAA,EACA,MAAM,SAAS,QAAQ;AACrB,UAAMC,MAAAA,uBAAuB,MAAM;AAEnC,WAAO,IAAI,OAAO,EAAE,IAAI,oCAAoCC,YAAA,MAAM,yBAAyB;AAC3F,WAAO,IAAI,OAAO,EAAE,IAAI,mCAAmCA,YAAA,MAAM,yBAAyB;AAG1F,WAAO,KAAK,kCAAkC,EAAE,SAASC,aAA2B,OAAA;AACpF,WAAO,KAAK,iCAAiC,EAAE,SAASC,aAA0B,MAAA;AAGlF,WAAO,GAAG,WAAW,UAAU,SAAS,SAASC,oBAAAA,qBAAqB;AAAA,EACxE;AACF,CAAC;;"}
@@ -16,6 +16,7 @@ import validatorsRegistry from "../registries/validators.mjs";
16
16
  import { registry } from "../registries/models.mjs";
17
17
  import { loadApplicationContext } from "../loaders/index.mjs";
18
18
  import { disable as disableDraftAndPublish, enable as enableDraftAndPublish } from "../migrations/draft-publish.mjs";
19
+ import { discardDocumentDrafts } from "../migrations/database/5.0.0-discard-drafts.mjs";
19
20
  const registries = defineProvider({
20
21
  init(strapi) {
21
22
  strapi.add("content-types", () => contentTypesRegistry()).add("components", () => componentsRegistry()).add("services", () => servicesRegistry(strapi)).add("policies", () => policiesRegistry()).add("middlewares", () => middlewaresRegistry()).add("hooks", () => hooksRegistry()).add("controllers", () => controllersRegistry(strapi)).add("modules", () => modulesRegistry(strapi)).add("plugins", () => pluginsRegistry(strapi)).add("custom-fields", () => customFieldsRegistry(strapi)).add("apis", () => apisRegistry(strapi)).add("models", () => registry()).add("sanitizers", sanitizersRegistry()).add("validators", validatorsRegistry());
@@ -26,6 +27,7 @@ const registries = defineProvider({
26
27
  strapi.get("hooks").set("strapi::content-types.afterSync", hooks.createAsyncParallelHook());
27
28
  strapi.hook("strapi::content-types.beforeSync").register(disableDraftAndPublish);
28
29
  strapi.hook("strapi::content-types.afterSync").register(enableDraftAndPublish);
30
+ strapi.db.migrations.providers.internal.register(discardDocumentDrafts);
29
31
  }
30
32
  });
31
33
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"registries.mjs","sources":["../../src/providers/registries.ts"],"sourcesContent":["import { hooks } from '@strapi/utils';\n\nimport { defineProvider } from './provider';\nimport * as registries from '../registries';\nimport { loadApplicationContext } from '../loaders';\nimport * as draftAndPublishSync from '../migrations/draft-publish';\n\nexport default defineProvider({\n init(strapi) {\n strapi\n .add('content-types', () => registries.contentTypes())\n .add('components', () => registries.components())\n .add('services', () => registries.services(strapi))\n .add('policies', () => registries.policies())\n .add('middlewares', () => registries.middlewares())\n .add('hooks', () => registries.hooks())\n .add('controllers', () => registries.controllers(strapi))\n .add('modules', () => registries.modules(strapi))\n .add('plugins', () => registries.plugins(strapi))\n .add('custom-fields', () => registries.customFields(strapi))\n .add('apis', () => registries.apis(strapi))\n .add('models', () => registries.models())\n .add('sanitizers', registries.sanitizers())\n .add('validators', registries.validators());\n },\n async register(strapi) {\n await loadApplicationContext(strapi);\n\n strapi.get('hooks').set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n strapi.get('hooks').set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n\n strapi.hook('strapi::content-types.beforeSync').register(draftAndPublishSync.disable);\n strapi.hook('strapi::content-types.afterSync').register(draftAndPublishSync.enable);\n },\n});\n"],"names":["registries.contentTypes","registries.components","registries.services","registries.policies","registries.middlewares","registries.hooks","registries.controllers","registries.modules","registries.plugins","registries.customFields","registries.apis","registries.models","registries.sanitizers","registries.validators","draftAndPublishSync.disable","draftAndPublishSync.enable"],"mappings":";;;;;;;;;;;;;;;;;;AAOA,MAAA,aAAe,eAAe;AAAA,EAC5B,KAAK,QAAQ;AAER,WAAA,IAAI,iBAAiB,MAAMA,qBAAyB,CAAA,EACpD,IAAI,cAAc,MAAMC,mBAAuB,CAAA,EAC/C,IAAI,YAAY,MAAMC,iBAAoB,MAAM,CAAC,EACjD,IAAI,YAAY,MAAMC,iBAAqB,CAAA,EAC3C,IAAI,eAAe,MAAMC,oBAAuB,CAAC,EACjD,IAAI,SAAS,MAAMC,eAAkB,EACrC,IAAI,eAAe,MAAMC,oBAAuB,MAAM,CAAC,EACvD,IAAI,WAAW,MAAMC,gBAAmB,MAAM,CAAC,EAC/C,IAAI,WAAW,MAAMC,gBAAmB,MAAM,CAAC,EAC/C,IAAI,iBAAiB,MAAMC,qBAAwB,MAAM,CAAC,EAC1D,IAAI,QAAQ,MAAMC,aAAgB,MAAM,CAAC,EACzC,IAAI,UAAU,MAAMC,SAAmB,CAAA,EACvC,IAAI,cAAcC,oBAAuB,EACzC,IAAI,cAAcC,mBAAW,CAAY;AAAA,EAC9C;AAAA,EACA,MAAM,SAAS,QAAQ;AACrB,UAAM,uBAAuB,MAAM;AAEnC,WAAO,IAAI,OAAO,EAAE,IAAI,oCAAoC,MAAM,yBAAyB;AAC3F,WAAO,IAAI,OAAO,EAAE,IAAI,mCAAmC,MAAM,yBAAyB;AAE1F,WAAO,KAAK,kCAAkC,EAAE,SAASC,sBAA2B;AACpF,WAAO,KAAK,iCAAiC,EAAE,SAASC,qBAA0B;AAAA,EACpF;AACF,CAAC;"}
1
+ {"version":3,"file":"registries.mjs","sources":["../../src/providers/registries.ts"],"sourcesContent":["import { hooks } from '@strapi/utils';\n\nimport { defineProvider } from './provider';\nimport * as registries from '../registries';\nimport { loadApplicationContext } from '../loaders';\nimport * as draftAndPublishSync from '../migrations/draft-publish';\nimport { discardDocumentDrafts } from '../migrations/database/5.0.0-discard-drafts';\n\nexport default defineProvider({\n init(strapi) {\n strapi\n .add('content-types', () => registries.contentTypes())\n .add('components', () => registries.components())\n .add('services', () => registries.services(strapi))\n .add('policies', () => registries.policies())\n .add('middlewares', () => registries.middlewares())\n .add('hooks', () => registries.hooks())\n .add('controllers', () => registries.controllers(strapi))\n .add('modules', () => registries.modules(strapi))\n .add('plugins', () => registries.plugins(strapi))\n .add('custom-fields', () => registries.customFields(strapi))\n .add('apis', () => registries.apis(strapi))\n .add('models', () => registries.models())\n .add('sanitizers', registries.sanitizers())\n .add('validators', registries.validators());\n },\n async register(strapi) {\n await loadApplicationContext(strapi);\n\n strapi.get('hooks').set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n strapi.get('hooks').set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n\n // Content migration to enable draft and publish\n strapi.hook('strapi::content-types.beforeSync').register(draftAndPublishSync.disable);\n strapi.hook('strapi::content-types.afterSync').register(draftAndPublishSync.enable);\n\n // Database migrations\n strapi.db.migrations.providers.internal.register(discardDocumentDrafts);\n },\n});\n"],"names":["registries.contentTypes","registries.components","registries.services","registries.policies","registries.middlewares","registries.hooks","registries.controllers","registries.modules","registries.plugins","registries.customFields","registries.apis","registries.models","registries.sanitizers","registries.validators","draftAndPublishSync.disable","draftAndPublishSync.enable"],"mappings":";;;;;;;;;;;;;;;;;;;AAQA,MAAA,aAAe,eAAe;AAAA,EAC5B,KAAK,QAAQ;AAER,WAAA,IAAI,iBAAiB,MAAMA,qBAAyB,CAAA,EACpD,IAAI,cAAc,MAAMC,mBAAuB,CAAA,EAC/C,IAAI,YAAY,MAAMC,iBAAoB,MAAM,CAAC,EACjD,IAAI,YAAY,MAAMC,iBAAqB,CAAA,EAC3C,IAAI,eAAe,MAAMC,oBAAuB,CAAC,EACjD,IAAI,SAAS,MAAMC,eAAkB,EACrC,IAAI,eAAe,MAAMC,oBAAuB,MAAM,CAAC,EACvD,IAAI,WAAW,MAAMC,gBAAmB,MAAM,CAAC,EAC/C,IAAI,WAAW,MAAMC,gBAAmB,MAAM,CAAC,EAC/C,IAAI,iBAAiB,MAAMC,qBAAwB,MAAM,CAAC,EAC1D,IAAI,QAAQ,MAAMC,aAAgB,MAAM,CAAC,EACzC,IAAI,UAAU,MAAMC,SAAmB,CAAA,EACvC,IAAI,cAAcC,oBAAuB,EACzC,IAAI,cAAcC,mBAAW,CAAY;AAAA,EAC9C;AAAA,EACA,MAAM,SAAS,QAAQ;AACrB,UAAM,uBAAuB,MAAM;AAEnC,WAAO,IAAI,OAAO,EA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AAC,CAAC;QAClD,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACnD,CAAC;IACF,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED,QAAA,MAAM,eAAe,WAAY;IAAE,EAAE,EAAE,QAAQ,CAAA;CAAE,cA+GhD,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC"}
@@ -1,6 +1,6 @@
1
- import type { UID, Modules, Schema } from '@strapi/types';
2
- declare const applyTransforms: <TUID extends UID.ContentType>(data: Modules.EntityService.Params.Data.Input<TUID>, context: {
3
- contentType: Schema.ContentType<TUID>;
4
- }) => Modules.EntityService.Params.Data.Input<TUID>;
1
+ /// <reference types="lodash" />
2
+ import type { UID, Modules } from '@strapi/types';
3
+ type Data = Modules.Documents.Params.Data.Input<UID.Schema>;
4
+ declare const applyTransforms: import("lodash").CurriedFunction2<import("@strapi/types/dist/struct").ComponentSchema | import("@strapi/types/dist/struct").ContentTypeSchema, Data, Data>;
5
5
  export { applyTransforms };
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/document-service/attributes/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG1D,QAAA,MAAM,eAAe;;mDA6BpB,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/document-service/attributes/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAU,MAAM,eAAe,CAAC;AAK1D,KAAK,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAE5D,QAAA,MAAM,eAAe,4JAsBnB,CAAC;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const _ = require("lodash/fp");
3
4
  const transforms = require("./transforms.js");
4
- const applyTransforms = (data, context) => {
5
- const { contentType } = context;
5
+ const applyTransforms = _.curry((schema, data) => {
6
6
  const attributeNames = Object.keys(data);
7
7
  for (const attributeName of attributeNames) {
8
8
  const value = data[attributeName];
9
- const attribute = contentType.attributes[attributeName];
9
+ const attribute = schema.attributes[attributeName];
10
10
  if (!attribute) {
11
11
  continue;
12
12
  }
13
13
  const transform = transforms[attribute.type];
14
14
  if (transform) {
15
- const attributeContext = { ...context, attributeName, attribute };
15
+ const attributeContext = { attributeName, attribute };
16
16
  data[attributeName] = transform(value, attributeContext);
17
17
  }
18
18
  }
19
19
  return data;
20
- };
20
+ });
21
21
  exports.applyTransforms = applyTransforms;
22
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/services/document-service/attributes/index.ts"],"sourcesContent":["import type { UID, Modules, Schema } from '@strapi/types';\nimport transforms from './transforms';\n\nconst applyTransforms = <TUID extends UID.ContentType>(\n data: Modules.EntityService.Params.Data.Input<TUID>,\n context: {\n contentType: Schema.ContentType<TUID>;\n }\n) => {\n const { contentType } = context;\n\n const attributeNames = Object.keys(data) as Array<keyof typeof data & string>;\n\n for (const attributeName of attributeNames) {\n const value = data[attributeName];\n\n const attribute = contentType.attributes[attributeName];\n\n if (!attribute) {\n continue;\n }\n\n const transform = transforms[attribute.type];\n\n if (transform) {\n const attributeContext = { ...context, attributeName, attribute };\n\n data[attributeName] = transform(value, attributeContext);\n }\n }\n\n return data;\n};\n\nexport { applyTransforms };\n"],"names":[],"mappings":";;;AAGM,MAAA,kBAAkB,CACtB,MACA,YAGG;AACG,QAAA,EAAE,YAAgB,IAAA;AAElB,QAAA,iBAAiB,OAAO,KAAK,IAAI;AAEvC,aAAW,iBAAiB,gBAAgB;AACpC,UAAA,QAAQ,KAAK,aAAa;AAE1B,UAAA,YAAY,YAAY,WAAW,aAAa;AAEtD,QAAI,CAAC,WAAW;AACd;AAAA,IACF;AAEM,UAAA,YAAY,WAAW,UAAU,IAAI;AAE3C,QAAI,WAAW;AACb,YAAM,mBAAmB,EAAE,GAAG,SAAS,eAAe,UAAU;AAEhE,WAAK,aAAa,IAAI,UAAU,OAAO,gBAAgB;AAAA,IACzD;AAAA,EACF;AAEO,SAAA;AACT;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/services/document-service/attributes/index.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport type { UID, Modules, Schema } from '@strapi/types';\n\nimport transforms from './transforms';\n\n// aliasing the type to make it easier to read\ntype Data = Modules.Documents.Params.Data.Input<UID.Schema>;\n\nconst applyTransforms = curry((schema: Schema.Schema, data: Data) => {\n const attributeNames = Object.keys(data) as Array<keyof typeof data & string>;\n\n for (const attributeName of attributeNames) {\n const value = data[attributeName];\n\n const attribute = schema.attributes[attributeName];\n\n if (!attribute) {\n continue;\n }\n\n const transform = transforms[attribute.type];\n\n if (transform) {\n const attributeContext = { attributeName, attribute };\n\n data[attributeName] = transform(value, attributeContext);\n }\n }\n\n return data;\n});\n\nexport { applyTransforms };\n"],"names":["curry"],"mappings":";;;;AASA,MAAM,kBAAkBA,EAAA,MAAM,CAAC,QAAuB,SAAe;AAC7D,QAAA,iBAAiB,OAAO,KAAK,IAAI;AAEvC,aAAW,iBAAiB,gBAAgB;AACpC,UAAA,QAAQ,KAAK,aAAa;AAE1B,UAAA,YAAY,OAAO,WAAW,aAAa;AAEjD,QAAI,CAAC,WAAW;AACd;AAAA,IACF;AAEM,UAAA,YAAY,WAAW,UAAU,IAAI;AAE3C,QAAI,WAAW;AACP,YAAA,mBAAmB,EAAE,eAAe;AAE1C,WAAK,aAAa,IAAI,UAAU,OAAO,gBAAgB;AAAA,IACzD;AAAA,EACF;AAEO,SAAA;AACT,CAAC;;"}
@@ -1,21 +1,21 @@
1
+ import { curry } from "lodash/fp";
1
2
  import transforms from "./transforms.mjs";
2
- const applyTransforms = (data, context) => {
3
- const { contentType } = context;
3
+ const applyTransforms = curry((schema, data) => {
4
4
  const attributeNames = Object.keys(data);
5
5
  for (const attributeName of attributeNames) {
6
6
  const value = data[attributeName];
7
- const attribute = contentType.attributes[attributeName];
7
+ const attribute = schema.attributes[attributeName];
8
8
  if (!attribute) {
9
9
  continue;
10
10
  }
11
11
  const transform = transforms[attribute.type];
12
12
  if (transform) {
13
- const attributeContext = { ...context, attributeName, attribute };
13
+ const attributeContext = { attributeName, attribute };
14
14
  data[attributeName] = transform(value, attributeContext);
15
15
  }
16
16
  }
17
17
  return data;
18
- };
18
+ });
19
19
  export {
20
20
  applyTransforms
21
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../../src/services/document-service/attributes/index.ts"],"sourcesContent":["import type { UID, Modules, Schema } from '@strapi/types';\nimport transforms from './transforms';\n\nconst applyTransforms = <TUID extends UID.ContentType>(\n data: Modules.EntityService.Params.Data.Input<TUID>,\n context: {\n contentType: Schema.ContentType<TUID>;\n }\n) => {\n const { contentType } = context;\n\n const attributeNames = Object.keys(data) as Array<keyof typeof data & string>;\n\n for (const attributeName of attributeNames) {\n const value = data[attributeName];\n\n const attribute = contentType.attributes[attributeName];\n\n if (!attribute) {\n continue;\n }\n\n const transform = transforms[attribute.type];\n\n if (transform) {\n const attributeContext = { ...context, attributeName, attribute };\n\n data[attributeName] = transform(value, attributeContext);\n }\n }\n\n return data;\n};\n\nexport { applyTransforms };\n"],"names":[],"mappings":";AAGM,MAAA,kBAAkB,CACtB,MACA,YAGG;AACG,QAAA,EAAE,YAAgB,IAAA;AAElB,QAAA,iBAAiB,OAAO,KAAK,IAAI;AAEvC,aAAW,iBAAiB,gBAAgB;AACpC,UAAA,QAAQ,KAAK,aAAa;AAE1B,UAAA,YAAY,YAAY,WAAW,aAAa;AAEtD,QAAI,CAAC,WAAW;AACd;AAAA,IACF;AAEM,UAAA,YAAY,WAAW,UAAU,IAAI;AAE3C,QAAI,WAAW;AACb,YAAM,mBAAmB,EAAE,GAAG,SAAS,eAAe,UAAU;AAEhE,WAAK,aAAa,IAAI,UAAU,OAAO,gBAAgB;AAAA,IACzD;AAAA,EACF;AAEO,SAAA;AACT;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../../src/services/document-service/attributes/index.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport type { UID, Modules, Schema } from '@strapi/types';\n\nimport transforms from './transforms';\n\n// aliasing the type to make it easier to read\ntype Data = Modules.Documents.Params.Data.Input<UID.Schema>;\n\nconst applyTransforms = curry((schema: Schema.Schema, data: Data) => {\n const attributeNames = Object.keys(data) as Array<keyof typeof data & string>;\n\n for (const attributeName of attributeNames) {\n const value = data[attributeName];\n\n const attribute = schema.attributes[attributeName];\n\n if (!attribute) {\n continue;\n }\n\n const transform = transforms[attribute.type];\n\n if (transform) {\n const attributeContext = { attributeName, attribute };\n\n data[attributeName] = transform(value, attributeContext);\n }\n }\n\n return data;\n});\n\nexport { applyTransforms };\n"],"names":[],"mappings":";;AASA,MAAM,kBAAkB,MAAM,CAAC,QAAuB,SAAe;AAC7D,QAAA,iBAAiB,OAAO,KAAK,IAAI;AAEvC,aAAW,iBAAiB,gBAAgB;AACpC,UAAA,QAAQ,KAAK,aAAa;AAE1B,UAAA,YAAY,OAAO,WAAW,aAAa;AAEjD,QAAI,CAAC,WAAW;AACd;AAAA,IACF;AAEM,UAAA,YAAY,WAAW,UAAU,IAAI;AAE3C,QAAI,WAAW;AACP,YAAA,mBAAmB,EAAE,eAAe;AAE1C,WAAK,aAAa,IAAI,UAAU,OAAO,gBAAgB;AAAA,IACzD;AAAA,EACF;AAEO,SAAA;AACT,CAAC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,MAAM,uBAAuB,GAAG,CAAC,eAAe,SAAS,GAAG,CAAC,WAAW,EAC5E,GAAG,EAAE,eAAe,KACjB,OAAO,CAAC,SAAS,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,iBAAiB,iBAAkB,GAAG,KAAK,GAAG,eACxC,GAAG,EAAE,iBACvB,CAAC"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,MAAM,uBAAuB,GAAG,CAAC,eAAe,SAAS,GAAG,CAAC,WAAW,EAC5E,GAAG,EAAE,eAAe,KACjB,OAAO,CAAC,SAAS,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,iBAAiB,OAAQ,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,eACxC,GAAG,EAAE,iBACvB,CAAC"}
@@ -1,4 +1,6 @@
1
- import type { Struct, Utils, UID, Schema, Data, Modules } from '@strapi/types';
1
+ import _ from 'lodash';
2
+ import type { UID, Schema, Data, Modules } from '@strapi/types';
3
+ type Input<T extends UID.Schema> = Modules.Documents.Params.Data.Input<T>;
2
4
  type LoadedComponents<TUID extends UID.Schema> = Data.Entity<TUID, Schema.AttributeNamesByType<TUID, 'component' | 'dynamiczone'>>;
3
5
  type SingleComponentValue = Schema.Attribute.ComponentValue<UID.Component, false>;
4
6
  type RepeatableComponentValue = Schema.Attribute.ComponentValue<UID.Component, true>;
@@ -7,92 +9,18 @@ type DynamicZoneValue = Schema.Attribute.DynamicZoneValue<UID.Component[]>;
7
9
  type ComponentBody = {
8
10
  [key: string]: ComponentValue | DynamicZoneValue;
9
11
  };
10
- declare function omitComponentData(contentType: Struct.ContentTypeSchema, data: Modules.EntityService.Params.Data.Input<Struct.ContentTypeSchema['uid']>): Partial<Modules.EntityService.Params.Data.Input<Struct.ContentTypeSchema['uid']>>;
11
- declare function omitComponentData(contentType: Struct.ComponentSchema, data: Modules.EntityService.Params.Data.Input<Struct.ComponentSchema['uid']>): Partial<Modules.EntityService.Params.Data.Input<Struct.ComponentSchema['uid']>>;
12
- declare const createComponents: <TUID extends UID.Schema, TData extends Modules.EntityService.Params.Data.Input<TUID>>(uid: TUID, data: TData) => Promise<ComponentBody>;
12
+ declare const omitComponentData: _.CurriedFunction2<import("@strapi/types/dist/struct").ComponentSchema | import("@strapi/types/dist/struct").ContentTypeSchema, Input<UID.Schema>, Partial<Input<UID.Schema>>>;
13
+ declare const createComponents: <TUID extends UID.Schema, TData extends Input<TUID>>(uid: TUID, data: TData) => Promise<ComponentBody>;
13
14
  declare const getComponents: <TUID extends UID.Schema>(uid: TUID, entity: {
14
15
  id: Modules.EntityService.Params.Attribute.ID;
15
16
  }) => Promise<LoadedComponents<TUID>>;
16
- declare const updateComponents: <TUID extends UID.Schema, TData extends Partial<Modules.EntityService.Params.Data.Input<TUID>>>(uid: TUID, entityToUpdate: {
17
+ declare const updateComponents: <TUID extends UID.Schema, TData extends Partial<Input<TUID>>>(uid: TUID, entityToUpdate: {
17
18
  id: Modules.EntityService.Params.Attribute.ID;
18
19
  }, data: TData) => Promise<ComponentBody>;
19
20
  declare const deleteComponents: <TUID extends UID.Schema, TEntity extends Data.Entity<TUID, Extract<keyof Schema.Attributes<TUID>, string>>>(uid: TUID, entityToDelete: TEntity, { loadComponents }?: {
20
21
  loadComponents?: boolean | undefined;
21
22
  }) => Promise<void>;
22
- declare const deleteComponent: <TUID extends `${string}.${string}`>(uid: TUID, componentToDelete: {
23
- id: Data.ID;
24
- } & Pick<{ [TAttributeName in Extract<keyof Schema.Attributes<TUID>, string>]?: Utils.If<Utils.IsTrue<Utils.IsTrue<Utils.Extends<{
25
- biginteger: Schema.Attribute.GetBigIntegerValue<Schema.AttributeByName<TUID, TAttributeName>>;
26
- boolean: Schema.Attribute.GetBooleanValue<Schema.AttributeByName<TUID, TAttributeName>>;
27
- blocks: Schema.Attribute.GetBlocksValue<Schema.AttributeByName<TUID, TAttributeName>>;
28
- decimal: Schema.Attribute.GetDecimalValue<Schema.AttributeByName<TUID, TAttributeName>>;
29
- enumeration: Schema.Attribute.GetEnumerationValue<Schema.AttributeByName<TUID, TAttributeName>>;
30
- email: Schema.Attribute.GetEmailValue<Schema.AttributeByName<TUID, TAttributeName>>;
31
- float: Schema.Attribute.GetFloatValue<Schema.AttributeByName<TUID, TAttributeName>>;
32
- integer: Schema.Attribute.GetIntegerValue<Schema.AttributeByName<TUID, TAttributeName>>;
33
- json: Schema.Attribute.GetJsonValue<Schema.AttributeByName<TUID, TAttributeName>>;
34
- password: Schema.Attribute.GetPasswordValue<Schema.AttributeByName<TUID, TAttributeName>>;
35
- richtext: Schema.Attribute.GetRichTextValue<Schema.AttributeByName<TUID, TAttributeName>>;
36
- string: Schema.Attribute.GetStringValue<Schema.AttributeByName<TUID, TAttributeName>>;
37
- text: Schema.Attribute.GetTextValue<Schema.AttributeByName<TUID, TAttributeName>>;
38
- uid: Schema.Attribute.GetUIDValue<Schema.AttributeByName<TUID, TAttributeName>>;
39
- date: Schema.Attribute.GetDateValue<Schema.AttributeByName<TUID, TAttributeName>>;
40
- datetime: Schema.Attribute.GetDateTimeValue<Schema.AttributeByName<TUID, TAttributeName>>;
41
- time: Schema.Attribute.GetTimeValue<Schema.AttributeByName<TUID, TAttributeName>>;
42
- timestamp: Schema.Attribute.GetTimestampValue<Schema.AttributeByName<TUID, TAttributeName>>;
43
- component: Schema.Attribute.GetComponentValue<Schema.AttributeByName<TUID, TAttributeName>>;
44
- dynamiczone: Schema.Attribute.GetDynamicZoneValue<Schema.AttributeByName<TUID, TAttributeName>>;
45
- media: Schema.Attribute.GetMediaValue<Schema.AttributeByName<TUID, TAttributeName>>;
46
- relation: Schema.Attribute.GetRelationValue<Schema.AttributeByName<TUID, TAttributeName>>;
47
- }[Schema.Attribute.TypeOf<Schema.AttributeByName<TUID, TAttributeName>>], never>> | Utils.IsTrue<Utils.Extends<never, {
48
- biginteger: Schema.Attribute.GetBigIntegerValue<Schema.AttributeByName<TUID, TAttributeName>>;
49
- boolean: Schema.Attribute.GetBooleanValue<Schema.AttributeByName<TUID, TAttributeName>>;
50
- blocks: Schema.Attribute.GetBlocksValue<Schema.AttributeByName<TUID, TAttributeName>>;
51
- decimal: Schema.Attribute.GetDecimalValue<Schema.AttributeByName<TUID, TAttributeName>>;
52
- enumeration: Schema.Attribute.GetEnumerationValue<Schema.AttributeByName<TUID, TAttributeName>>;
53
- email: Schema.Attribute.GetEmailValue<Schema.AttributeByName<TUID, TAttributeName>>;
54
- float: Schema.Attribute.GetFloatValue<Schema.AttributeByName<TUID, TAttributeName>>;
55
- integer: Schema.Attribute.GetIntegerValue<Schema.AttributeByName<TUID, TAttributeName>>;
56
- json: Schema.Attribute.GetJsonValue<Schema.AttributeByName<TUID, TAttributeName>>;
57
- password: Schema.Attribute.GetPasswordValue<Schema.AttributeByName<TUID, TAttributeName>>;
58
- richtext: Schema.Attribute.GetRichTextValue<Schema.AttributeByName<TUID, TAttributeName>>;
59
- string: Schema.Attribute.GetStringValue<Schema.AttributeByName<TUID, TAttributeName>>;
60
- text: Schema.Attribute.GetTextValue<Schema.AttributeByName<TUID, TAttributeName>>;
61
- uid: Schema.Attribute.GetUIDValue<Schema.AttributeByName<TUID, TAttributeName>>;
62
- date: Schema.Attribute.GetDateValue<Schema.AttributeByName<TUID, TAttributeName>>;
63
- datetime: Schema.Attribute.GetDateTimeValue<Schema.AttributeByName<TUID, TAttributeName>>;
64
- time: Schema.Attribute.GetTimeValue<Schema.AttributeByName<TUID, TAttributeName>>;
65
- timestamp: Schema.Attribute.GetTimestampValue<Schema.AttributeByName<TUID, TAttributeName>>;
66
- component: Schema.Attribute.GetComponentValue<Schema.AttributeByName<TUID, TAttributeName>>;
67
- dynamiczone: Schema.Attribute.GetDynamicZoneValue<Schema.AttributeByName<TUID, TAttributeName>>;
68
- media: Schema.Attribute.GetMediaValue<Schema.AttributeByName<TUID, TAttributeName>>;
69
- relation: Schema.Attribute.GetRelationValue<Schema.AttributeByName<TUID, TAttributeName>>;
70
- }[Schema.Attribute.TypeOf<Schema.AttributeByName<TUID, TAttributeName>>]>>>, unknown, {
71
- biginteger: Schema.Attribute.GetBigIntegerValue<Schema.AttributeByName<TUID, TAttributeName>>;
72
- boolean: Schema.Attribute.GetBooleanValue<Schema.AttributeByName<TUID, TAttributeName>>;
73
- blocks: Schema.Attribute.GetBlocksValue<Schema.AttributeByName<TUID, TAttributeName>>;
74
- decimal: Schema.Attribute.GetDecimalValue<Schema.AttributeByName<TUID, TAttributeName>>;
75
- enumeration: Schema.Attribute.GetEnumerationValue<Schema.AttributeByName<TUID, TAttributeName>>;
76
- email: Schema.Attribute.GetEmailValue<Schema.AttributeByName<TUID, TAttributeName>>;
77
- float: Schema.Attribute.GetFloatValue<Schema.AttributeByName<TUID, TAttributeName>>;
78
- integer: Schema.Attribute.GetIntegerValue<Schema.AttributeByName<TUID, TAttributeName>>;
79
- json: Schema.Attribute.GetJsonValue<Schema.AttributeByName<TUID, TAttributeName>>;
80
- password: Schema.Attribute.GetPasswordValue<Schema.AttributeByName<TUID, TAttributeName>>;
81
- richtext: Schema.Attribute.GetRichTextValue<Schema.AttributeByName<TUID, TAttributeName>>;
82
- string: Schema.Attribute.GetStringValue<Schema.AttributeByName<TUID, TAttributeName>>;
83
- text: Schema.Attribute.GetTextValue<Schema.AttributeByName<TUID, TAttributeName>>;
84
- uid: Schema.Attribute.GetUIDValue<Schema.AttributeByName<TUID, TAttributeName>>;
85
- date: Schema.Attribute.GetDateValue<Schema.AttributeByName<TUID, TAttributeName>>;
86
- datetime: Schema.Attribute.GetDateTimeValue<Schema.AttributeByName<TUID, TAttributeName>>;
87
- time: Schema.Attribute.GetTimeValue<Schema.AttributeByName<TUID, TAttributeName>>;
88
- timestamp: Schema.Attribute.GetTimestampValue<Schema.AttributeByName<TUID, TAttributeName>>;
89
- component: Schema.Attribute.GetComponentValue<Schema.AttributeByName<TUID, TAttributeName>>;
90
- dynamiczone: Schema.Attribute.GetDynamicZoneValue<Schema.AttributeByName<TUID, TAttributeName>>;
91
- media: Schema.Attribute.GetMediaValue<Schema.AttributeByName<TUID, TAttributeName>>;
92
- relation: Schema.Attribute.GetRelationValue<Schema.AttributeByName<TUID, TAttributeName>>;
93
- }[Schema.Attribute.TypeOf<Schema.AttributeByName<TUID, TAttributeName>>]> | null | undefined; }, Extract<keyof Schema.Attributes<TUID>, string>>) => Promise<void>;
94
- declare const assignComponentData: <TUID extends UID.ContentType>(data: Modules.EntityService.Params.Data.Input<TUID>, componentData: ComponentBody, { contentType, }: {
95
- contentType: Schema.ContentType<TUID>;
96
- }) => Partial<Modules.EntityService.Params.Data.Input<UID.ContentType>> & ComponentBody;
23
+ declare const deleteComponent: <TUID extends `${string}.${string}`>(uid: TUID, componentToDelete: Data.Component<TUID>) => Promise<void>;
24
+ declare const assignComponentData: _.CurriedFunction3<import("@strapi/types/dist/struct").ComponentSchema | import("@strapi/types/dist/struct").ContentTypeSchema, ComponentBody, Input<UID.Schema>, ComponentBody & Partial<Input<UID.Schema>>>;
97
25
  export { omitComponentData, assignComponentData, getComponents, createComponents, updateComponents, deleteComponents, deleteComponent, };
98
26
  //# sourceMappingURL=components.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","source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