@strapi/core 5.0.0-beta.3 → 5.0.0-beta.5

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 (78) hide show
  1. package/dist/core-api/controller/collection-type.d.ts.map +1 -1
  2. package/dist/core-api/controller/collection-type.js +1 -0
  3. package/dist/core-api/controller/collection-type.js.map +1 -1
  4. package/dist/core-api/controller/collection-type.mjs +1 -0
  5. package/dist/core-api/controller/collection-type.mjs.map +1 -1
  6. package/dist/core-api/routes/index.d.ts.map +1 -1
  7. package/dist/ee/license.d.ts.map +1 -1
  8. package/dist/ee/license.js +2 -1
  9. package/dist/ee/license.js.map +1 -1
  10. package/dist/ee/license.mjs +2 -1
  11. package/dist/ee/license.mjs.map +1 -1
  12. package/dist/factories.d.ts +2 -2
  13. package/dist/factories.d.ts.map +1 -1
  14. package/dist/migrations/database/5.0.0-discard-drafts.d.ts +12 -0
  15. package/dist/migrations/database/5.0.0-discard-drafts.d.ts.map +1 -0
  16. package/dist/migrations/database/5.0.0-discard-drafts.js +49 -0
  17. package/dist/migrations/database/5.0.0-discard-drafts.js.map +1 -0
  18. package/dist/migrations/database/5.0.0-discard-drafts.mjs +49 -0
  19. package/dist/migrations/database/5.0.0-discard-drafts.mjs.map +1 -0
  20. package/dist/providers/registries.d.ts.map +1 -1
  21. package/dist/providers/registries.js +2 -0
  22. package/dist/providers/registries.js.map +1 -1
  23. package/dist/providers/registries.mjs +2 -0
  24. package/dist/providers/registries.mjs.map +1 -1
  25. package/dist/services/core-store.d.ts.map +1 -1
  26. package/dist/services/document-service/attributes/index.d.ts +4 -4
  27. package/dist/services/document-service/attributes/index.d.ts.map +1 -1
  28. package/dist/services/document-service/attributes/index.js +5 -5
  29. package/dist/services/document-service/attributes/index.js.map +1 -1
  30. package/dist/services/document-service/attributes/index.mjs +5 -5
  31. package/dist/services/document-service/attributes/index.mjs.map +1 -1
  32. package/dist/services/document-service/common.d.ts.map +1 -1
  33. package/dist/services/document-service/components.d.ts +8 -80
  34. package/dist/services/document-service/components.d.ts.map +1 -1
  35. package/dist/services/document-service/components.js +18 -19
  36. package/dist/services/document-service/components.js.map +1 -1
  37. package/dist/services/document-service/components.mjs +19 -20
  38. package/dist/services/document-service/components.mjs.map +1 -1
  39. package/dist/services/document-service/entries.d.ts +2 -0
  40. package/dist/services/document-service/entries.d.ts.map +1 -1
  41. package/dist/services/document-service/entries.js +47 -14
  42. package/dist/services/document-service/entries.js.map +1 -1
  43. package/dist/services/document-service/entries.mjs +42 -9
  44. package/dist/services/document-service/entries.mjs.map +1 -1
  45. package/dist/services/document-service/index.d.ts.map +1 -1
  46. package/dist/services/document-service/index.js +8 -10
  47. package/dist/services/document-service/index.js.map +1 -1
  48. package/dist/services/document-service/index.mjs +8 -10
  49. package/dist/services/document-service/index.mjs.map +1 -1
  50. package/dist/services/document-service/internationalization.d.ts.map +1 -1
  51. package/dist/services/document-service/internationalization.js.map +1 -1
  52. package/dist/services/document-service/internationalization.mjs.map +1 -1
  53. package/dist/services/document-service/middlewares/middleware-manager.d.ts +1 -1
  54. package/dist/services/document-service/middlewares/middleware-manager.d.ts.map +1 -1
  55. package/dist/services/document-service/middlewares/middleware-manager.js +1 -1
  56. package/dist/services/document-service/middlewares/middleware-manager.js.map +1 -1
  57. package/dist/services/document-service/middlewares/middleware-manager.mjs +1 -1
  58. package/dist/services/document-service/middlewares/middleware-manager.mjs.map +1 -1
  59. package/dist/services/document-service/params.d.ts +1 -5
  60. package/dist/services/document-service/params.d.ts.map +1 -1
  61. package/dist/services/document-service/repository.d.ts.map +1 -1
  62. package/dist/services/document-service/repository.js +13 -39
  63. package/dist/services/document-service/repository.js.map +1 -1
  64. package/dist/services/document-service/repository.mjs +6 -32
  65. package/dist/services/document-service/repository.mjs.map +1 -1
  66. package/dist/services/document-service/transform/id-map.d.ts.map +1 -1
  67. package/dist/services/entity-service/index.d.ts.map +1 -1
  68. package/dist/services/entity-validator/index.js.map +1 -1
  69. package/dist/services/entity-validator/index.mjs.map +1 -1
  70. package/dist/services/metrics/middleware.d.ts.map +1 -1
  71. package/dist/services/server/compose-endpoint.d.ts.map +1 -1
  72. package/dist/services/server/koa.d.ts.map +1 -1
  73. package/dist/services/webhook-store.d.ts.map +1 -1
  74. package/dist/utils/load-files.d.ts.map +1 -1
  75. package/dist/utils/startup-logger.d.ts.map +1 -1
  76. package/package.json +15 -15
  77. package/dist/services/document-service/document-engine.d.ts +0 -2
  78. package/dist/services/document-service/document-engine.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"collection-type.d.ts","sourceRoot":"","sources":["../../../src/core-api/controller/collection-type.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAO,MAAM,eAAe,CAAC;AAG9D,UAAU,OAAO;IACf,WAAW,EAAE,MAAM,CAAC,oBAAoB,CAAC;CAC1C;AAED;;;GAGG;AACH,QAAA,MAAM,8BAA8B,qBAEjC,OAAO,KAAG,MAAM,eAAe,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,cAAc,CA+FxE,CAAC;AAEF,OAAO,EAAE,8BAA8B,EAAE,CAAC"}
1
+ {"version":3,"file":"collection-type.d.ts","sourceRoot":"","sources":["../../../src/core-api/controller/collection-type.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAO,MAAM,eAAe,CAAC;AAG9D,UAAU,OAAO;IACf,WAAW,EAAE,MAAM,CAAC,oBAAoB,CAAC;CAC1C;AAED;;;GAGG;AACH,QAAA,MAAM,8BAA8B,qBAEjC,OAAO,KAAG,MAAM,eAAe,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,cAAc,CAgGxE,CAAC;AAEF,OAAO,EAAE,8BAA8B,EAAE,CAAC"}
@@ -44,6 +44,7 @@ const createCollectionTypeController = ({
44
44
  data: sanitizedInputData
45
45
  });
46
46
  const sanitizedEntity = await this.sanitizeOutput(entity, ctx);
47
+ ctx.status = 201;
47
48
  return this.transformResponse(sanitizedEntity);
48
49
  },
49
50
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"collection-type.js","sources":["../../../src/core-api/controller/collection-type.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Core, Struct, Utils, UID } from '@strapi/types';\nimport type Koa from 'koa';\n\ninterface Options {\n contentType: Struct.CollectionTypeSchema;\n}\n\n/**\n *\n * Returns a collection type controller to handle default core-api actions\n */\nconst createCollectionTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<Core.CoreAPI.Controller.CollectionType> => {\n const uid = contentType.uid as UID.Service;\n\n // TODO: transform into a class\n return {\n /**\n * Retrieve records.\n */\n async find(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const { results, pagination } = await strapi.service(uid).find(sanitizedQuery);\n const sanitizedResults = await this.sanitizeOutput(results, ctx);\n return this.transformResponse(sanitizedResults, { pagination });\n },\n\n /**\n * Retrieve a record\n */\n async findOne(ctx) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).findOne(id, sanitizedQuery);\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Create a record.\n */\n async create(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const { body = {} as any } = ctx.request;\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).create({\n ...sanitizedQuery,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Update a record.\n */\n async update(ctx: Koa.Context) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const { body = {} as any } = ctx.request;\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).update(id, {\n ...sanitizedQuery,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Destroy a record.\n */\n async delete(ctx) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n await strapi.service(uid).delete(id, sanitizedQuery);\n\n ctx.status = 204;\n },\n };\n};\n\nexport { createCollectionTypeController };\n"],"names":["isObject","errors"],"mappings":";;;;AAaA,MAAM,iCAAiC,CAAC;AAAA,EACtC;AACF,MAA8E;AAC5E,QAAM,MAAM,YAAY;AAGjB,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,MAAM,KAAK,KAAK;AACR,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAE7C,YAAA,EAAE,SAAS,WAAA,IAAe,MAAM,OAAO,QAAQ,GAAG,EAAE,KAAK,cAAc;AAC7E,YAAM,mBAAmB,MAAM,KAAK,eAAe,SAAS,GAAG;AAC/D,aAAO,KAAK,kBAAkB,kBAAkB,EAAE,WAAY,CAAA;AAAA,IAChE;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,QAAQ,KAAK;AACX,YAAA,EAAE,GAAG,IAAI,IAAI;AACb,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAE7C,YAAA,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,QAAQ,IAAI,cAAc;AACnE,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KA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I;AACb,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAEnD,YAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,IAAI,cAAc;AAEnD,UAAI,SAAS;AAAA,IACf;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"collection-type.js","sources":["../../../src/core-api/controller/collection-type.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Core, Struct, Utils, UID } from '@strapi/types';\nimport type Koa from 'koa';\n\ninterface Options {\n contentType: Struct.CollectionTypeSchema;\n}\n\n/**\n *\n * Returns a collection type controller to handle default core-api actions\n */\nconst createCollectionTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<Core.CoreAPI.Controller.CollectionType> => {\n const uid = contentType.uid as UID.Service;\n\n // TODO: transform into a class\n return {\n /**\n * Retrieve records.\n */\n async find(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const { results, pagination } = await strapi.service(uid).find(sanitizedQuery);\n const sanitizedResults = await this.sanitizeOutput(results, ctx);\n return this.transformResponse(sanitizedResults, { pagination });\n },\n\n /**\n * Retrieve a record\n */\n async findOne(ctx) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).findOne(id, sanitizedQuery);\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Create a record.\n */\n async create(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const { body = {} as any } = ctx.request;\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).create({\n ...sanitizedQuery,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n ctx.status = 201;\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Update a record.\n */\n async update(ctx: Koa.Context) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const { body = {} as any } = ctx.request;\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).update(id, {\n ...sanitizedQuery,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Destroy a record.\n */\n async delete(ctx) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n await strapi.service(uid).delete(id, sanitizedQuery);\n\n ctx.status = 204;\n },\n };\n};\n\nexport { createCollectionTypeController };\n"],"names":["isObject","errors"],"mappings":";;;;AAaA,MAAM,iCAAiC,CAAC;AAAA,EACtC;AACF,MAA8E;AAC5E,QAAM,MAAM,YAAY;AAGjB,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,MAAM,KAAK,KAAK;AACR,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAE7C,YAAA,EAAE,SAAS,WAAA,IAAe,MAAM,OAAO,QAAQ,GAAG,EAAE,KAAK,cAAc;AAC7E,YAAM,mBAAmB,MAAM,KAAK,eAAe,SAAS,GAAG;AAC/D,aAAO,KAAK,kBAAkB,kBAAkB,EAAE,WAAY,CAAA;AAAA,IAChE;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,QAAQ,KAAK;AACX,YAAA,EAAE,GAAG,IAAI,IAAI;AACb,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAE7C,YAAA,SAA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Q,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,OAAO,KAAK;AACV,YAAA,EAAE,GAAG,IAAI,IAAI;AACb,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAEnD,YAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,IAAI,cAAc;AAEnD,UAAI,SAAS;AAAA,IACf;AAAA,EAAA;AAEJ;;"}
@@ -42,6 +42,7 @@ const createCollectionTypeController = ({
42
42
  data: sanitizedInputData
43
43
  });
44
44
  const sanitizedEntity = await this.sanitizeOutput(entity, ctx);
45
+ ctx.status = 201;
45
46
  return this.transformResponse(sanitizedEntity);
46
47
  },
47
48
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"collection-type.mjs","sources":["../../../src/core-api/controller/collection-type.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Core, Struct, Utils, UID } from '@strapi/types';\nimport type Koa from 'koa';\n\ninterface Options {\n contentType: Struct.CollectionTypeSchema;\n}\n\n/**\n *\n * Returns a collection type controller to handle default core-api actions\n */\nconst createCollectionTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<Core.CoreAPI.Controller.CollectionType> => {\n const uid = contentType.uid as UID.Service;\n\n // TODO: transform into a class\n return {\n /**\n * Retrieve records.\n */\n async find(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const { results, pagination } = await strapi.service(uid).find(sanitizedQuery);\n const sanitizedResults = await this.sanitizeOutput(results, ctx);\n return this.transformResponse(sanitizedResults, { pagination });\n },\n\n /**\n * Retrieve a record\n */\n async findOne(ctx) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).findOne(id, sanitizedQuery);\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Create a record.\n */\n async create(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const { body = {} as any } = ctx.request;\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).create({\n ...sanitizedQuery,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Update a record.\n */\n async update(ctx: Koa.Context) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const { body = {} as any } = ctx.request;\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).update(id, {\n ...sanitizedQuery,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Destroy a record.\n */\n async delete(ctx) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n await strapi.service(uid).delete(id, sanitizedQuery);\n\n ctx.status = 204;\n },\n };\n};\n\nexport { createCollectionTypeController };\n"],"names":[],"mappings":";;AAaA,MAAM,iCAAiC,CAAC;AAAA,EACtC;AACF,MAA8E;AAC5E,QAAM,MAAM,YAAY;AAGjB,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,MAAM,KAAK,KAAK;AACR,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAE7C,YAAA,EAAE,SAAS,WAAA,IAAe,MAAM,OAAO,QAAQ,GAAG,EAAE,KAAK,c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A,IAAI,OAAO,gBAAgB,4CAA4C;AAAA,MAC/E;AAEA,YAAM,qBAAqB,MAAM,KAAK,cAAc,KAAK,MAAM,GAAG;AAElE,YAAM,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,IAAI;AAAA,QAClD,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACP;AAED,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,OAAO,KAAK;AACV,YAAA,EAAE,GAAG,IAAI,IAAI;AACb,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAEnD,YAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,IAAI,cAAc;AAEnD,UAAI,SAAS;AAAA,IACf;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"collection-type.mjs","sources":["../../../src/core-api/controller/collection-type.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Core, Struct, Utils, UID } from '@strapi/types';\nimport type Koa from 'koa';\n\ninterface Options {\n contentType: Struct.CollectionTypeSchema;\n}\n\n/**\n *\n * Returns a collection type controller to handle default core-api actions\n */\nconst createCollectionTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<Core.CoreAPI.Controller.CollectionType> => {\n const uid = contentType.uid as UID.Service;\n\n // TODO: transform into a class\n return {\n /**\n * Retrieve records.\n */\n async find(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const { results, pagination } = await strapi.service(uid).find(sanitizedQuery);\n const sanitizedResults = await this.sanitizeOutput(results, ctx);\n return this.transformResponse(sanitizedResults, { pagination });\n },\n\n /**\n * Retrieve a record\n */\n async findOne(ctx) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).findOne(id, sanitizedQuery);\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Create a record.\n */\n async create(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const { body = {} as any } = ctx.request;\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).create({\n ...sanitizedQuery,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n ctx.status = 201;\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Update a record.\n */\n async update(ctx: Koa.Context) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const { body = {} as any } = ctx.request;\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).update(id, {\n ...sanitizedQuery,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Destroy a record.\n */\n async delete(ctx) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n await strapi.service(uid).delete(id, sanitizedQuery);\n\n ctx.status = 204;\n },\n };\n};\n\nexport { createCollectionTypeController };\n"],"names":[],"mappings":";;AAaA,MAAM,iCAAiC,CAAC;AAAA,EACtC;AACF,MAA8E;AAC5E,QAAM,MAAM,YAAY;AAGjB,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,MAAM,KAAK,KAAK;AACR,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAA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AAG;AAEnD,YAAM,EAAE,OAAO,CAAA,MAAc,IAAI;AAEjC,UAAI,CAAC,SAAS,KAAK,IAAI,GAAG;AAClB,cAAA,IAAI,OAAO,gBAAgB,4CAA4C;AAAA,MAC/E;AAEA,YAAM,qBAAqB,MAAM,KAAK,cAAc,KAAK,MAAM,GAAG;AAElE,YAAM,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,IAAI;AAAA,QAClD,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACP;AAED,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,OAAO,KAAK;AACV,YAAA,EAAE,GAAG,IAAI,IAAI;AACb,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAEnD,YAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,IAAI,cAAc;AAEnD,UAAI,SAAS;AAAA,IACf;AAAA,EAAA;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core-api/routes/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,eAAO,MAAM,YAAY;iBAAoC,OAAO,WAAW;;;;;;;;;;;;;;;;;;;;CAM9E,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core-api/routes/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,eAAO,MAAM,YAAY,oBAAqB;IAAE,WAAW,EAAE,OAAO,WAAW,CAAA;CAAE;;;;;;;;;;;;;;;;;;;CAMhF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"license.d.ts","sourceRoot":"","sources":["../../src/ee/license.ts"],"names":[],"mappings":"A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E,cAAc,UAAQ;CAKpD;AAED,QAAA,MAAM,WAAW,cAAe,MAAM,uBASrC,CAAC;AAEF,QAAA,MAAM,aAAa,YAAa,MAAM,gBA2BrC,CAAC;AAMF,QAAA,MAAM,YAAY,eACJ;IAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CAAE,OAC9B,MAAM,aACA,MAAM,iBA4BlB,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
@@ -16,7 +16,8 @@ const DEFAULT_FEATURES = {
16
16
  // The default of 90 days is set in the audit logs service
17
17
  { name: "audit-logs", options: { retentionDays: null } },
18
18
  { name: "review-workflows" },
19
- { name: "cms-content-releases" }
19
+ { name: "cms-content-releases" },
20
+ { name: "cms-content-history", options: { retentionDays: 99999 } }
20
21
  ]
21
22
  };
22
23
  const publicKey = fs__default.default.readFileSync(path.resolve(__dirname, "../../resources/key.pub"));
@@ -1 +1 @@
1
- {"version":3,"file":"license.js","sources":["../../src/ee/license.ts"],"sourcesContent":["import fs from 'fs';\nimport { join, resolve } from 'path';\nimport crypto from 'crypto';\nimport type { Core } from '@strapi/types';\n\nimport { machineID } from '@strapi/utils';\n\ninterface LicenseInfo {\n type: 'bronze' | 'silver' | 'gold';\n expireAt?: string;\n seats?: number;\n features?: Array<{ name: string; options?: Record<string, unknown> }>;\n}\n\nconst DEFAULT_FEATURES = {\n bronze: [],\n silver: [],\n gold: [\n { name: 'sso' },\n // Set a null retention duration to allow the user to override it\n // The default of 90 days is set in the audit logs service\n { name: 'audit-logs', options: { retentionDays: null } },\n { name: 'review-workflows' },\n { name: 'cms-content-releases' },\n ],\n};\n\nconst publicKey = fs.readFileSync(resolve(__dirname, '../../resources/key.pub'));\n\nclass LicenseCheckError extends Error {\n shouldFallback = false;\n\n constructor(message: string, shouldFallback = false) {\n super(message);\n\n this.shouldFallback = shouldFallback;\n }\n}\n\nconst readLicense = (directory: string) => {\n try {\n const path = join(directory, 'license.txt');\n return fs.readFileSync(path).toString();\n } catch (error) {\n if (typeof error === 'object' && error !== null && 'code' in error && error.code !== 'ENOENT') {\n throw Error('License file not readable, review its format and access rules.');\n }\n }\n};\n\nconst verifyLicense = (license: string) => {\n const [signature, base64Content] = Buffer.from(license, 'base64').toString().split('\\n');\n\n if (!signature || !base64Content) {\n throw new Error('Invalid license.');\n }\n\n const stringifiedContent = Buffer.from(base64Content, 'base64').toString();\n\n const verify = crypto.createVerify('RSA-SHA256');\n verify.update(stringifiedContent);\n verify.end();\n\n const verified = verify.verify(publicKey, signature, 'base64');\n\n if (!verified) {\n throw new Error('Invalid license.');\n }\n\n const licenseInfo: LicenseInfo = JSON.parse(stringifiedContent);\n\n if (!licenseInfo.features) {\n licenseInfo.features = DEFAULT_FEATURES[licenseInfo.type];\n }\n\n Object.freeze(licenseInfo.features);\n return licenseInfo;\n};\n\nconst throwError = () => {\n throw new LicenseCheckError('Could not proceed to the online validation of your license.', true);\n};\n\nconst fetchLicense = async (\n { strapi }: { strapi: Core.Strapi },\n key: string,\n projectId: string\n) => {\n const response = await strapi\n .fetch(`https://license.strapi.io/api/licenses/validate`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ key, projectId, deviceId: machineID() }),\n })\n .catch(throwError);\n\n const contentType = response.headers.get('Content-Type');\n\n if (contentType?.includes('application/json')) {\n const { data, error } = await response.json();\n\n switch (response.status) {\n case 200:\n return data.license;\n case 400:\n throw new LicenseCheckError(error.message);\n case 404:\n throw new LicenseCheckError('The license used does not exists.');\n default:\n throwError();\n }\n } else {\n throwError();\n }\n};\n\nexport { readLicense, verifyLicense, fetchLicense, LicenseCheckError };\n"],"names":["fs","resolve","path","join","crypto","machineID"],"mappings":";;;;;;;;;AAcA,MAAM,mBAAmB;AAAA,EACvB,QAAQ,CAAC;AAAA,EACT,QAAQ,CAAC;AAAA,EACT,MAAM;AAAA,IACJ,EAAE,MAAM,MAAM;AAAA;AAAA;AAAA,IAGd,EAAE,M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YAAY,QAAQ;AAC3B,SAAA;AACT;AAEA,MAAM,aAAa,MAAM;AACjB,QAAA,IAAI,kBAAkB,+DAA+D,IAAI;AACjG;AAEA,MAAM,eAAe,OACnB,EAAE,UACF,KACA,cACG;AACH,QAAM,WAAW,MAAM,OACpB,MAAM,mDAAmD;AAAA,IACxD,QAAQ;AAAA,IACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,IAC9C,MAAM,KAAK,UAAU,EAAE,KAAK,WAAW,UAAUC,YAAU,UAAA,GAAG;AAAA,EAAA,CAC/D,EACA,MAAM,UAAU;AAEnB,QAAM,cAAc,SAAS,QAAQ,IAAI,cAAc;AAEnD,MAAA,aAAa,SAAS,kBAAkB,GAAG;AAC7C,UAAM,EAAE,MAAM,MAAA,IAAU,MAAM,SAAS,KAAK;AAE5C,YAAQ,SAAS,QAAQ;AAAA,MACvB,KAAK;AACH,eAAO,KAAK;AAAA,MACd,KAAK;AACG,cAAA,IAAI,kBAAkB,MAAM,OAAO;AAAA,MAC3C,KAAK;AACG,cAAA,IAAI,kBAAkB,mCAAmC;AAAA,MACjE;AACa;IACf;AAAA,EAAA,OACK;AACM;EACb;AACF;;;;;"}
1
+ {"version":3,"file":"license.js","sources":["../../src/ee/license.ts"],"sourcesContent":["import fs from 'fs';\nimport { join, resolve } from 'path';\nimport crypto from 'crypto';\nimport type { Core } from '@strapi/types';\n\nimport { machineID } from '@strapi/utils';\n\ninterface LicenseInfo {\n type: 'bronze' | 'silver' | 'gold';\n expireAt?: string;\n seats?: number;\n features?: Array<{ name: string; options?: Record<string, unknown> }>;\n}\n\nconst DEFAULT_FEATURES = {\n bronze: [],\n silver: [],\n gold: [\n { name: 'sso' },\n // Set a null retention duration to allow the user to override it\n // The default of 90 days is set in the audit logs service\n { name: 'audit-logs', options: { retentionDays: null } },\n { name: 'review-workflows' },\n { name: 'cms-content-releases' },\n { name: 'cms-content-history', options: { retentionDays: 99999 } },\n ],\n};\n\nconst publicKey = fs.readFileSync(resolve(__dirname, '../../resources/key.pub'));\n\nclass LicenseCheckError extends Error {\n shouldFallback = false;\n\n constructor(message: string, shouldFallback = false) {\n super(message);\n\n this.shouldFallback = shouldFallback;\n }\n}\n\nconst readLicense = (directory: string) => {\n try {\n const path = join(directory, 'license.txt');\n return fs.readFileSync(path).toString();\n } catch (error) {\n if (typeof error === 'object' && error !== null && 'code' in error && error.code !== 'ENOENT') {\n throw Error('License file not readable, review its format and access rules.');\n }\n }\n};\n\nconst verifyLicense = (license: string) => {\n const [signature, base64Content] = Buffer.from(license, 'base64').toString().split('\\n');\n\n if (!signature || !base64Content) {\n throw new Error('Invalid license.');\n }\n\n const stringifiedContent = Buffer.from(base64Content, 'base64').toString();\n\n const verify = crypto.createVerify('RSA-SHA256');\n verify.update(stringifiedContent);\n verify.end();\n\n const verified = verify.verify(publicKey, signature, 'base64');\n\n if (!verified) {\n throw new Error('Invalid license.');\n }\n\n const licenseInfo: LicenseInfo = JSON.parse(stringifiedContent);\n\n if (!licenseInfo.features) {\n licenseInfo.features = DEFAULT_FEATURES[licenseInfo.type];\n }\n\n Object.freeze(licenseInfo.features);\n return licenseInfo;\n};\n\nconst throwError = () => {\n throw new LicenseCheckError('Could not proceed to the online validation of your license.', true);\n};\n\nconst fetchLicense = async (\n { strapi }: { strapi: Core.Strapi },\n key: string,\n projectId: string\n) => {\n const response = await strapi\n .fetch(`https://license.strapi.io/api/licenses/validate`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ key, projectId, deviceId: machineID() }),\n })\n .catch(throwError);\n\n const contentType = response.headers.get('Content-Type');\n\n if (contentType?.includes('application/json')) {\n const { data, error } = await response.json();\n\n switch (response.status) {\n case 200:\n return data.license;\n case 400:\n throw new LicenseCheckError(error.message);\n case 404:\n throw new LicenseCheckError('The license used does not exists.');\n default:\n throwError();\n }\n } else {\n throwError();\n }\n};\n\nexport { readLicense, verifyLicense, fetchLicense, LicenseCheckError };\n"],"names":["fs","resolve","path","join","crypto","machineID"],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,WAAW,QAAQ;AAE7D,MAAI,CAAC,UAAU;AACP,UAAA,IAAI,MAAM,kBAAkB;AAAA,EACpC;AAEM,QAAA,cAA2B,KAAK,MAAM,kBAAkB;AAE1D,MAAA,CAAC,YAAY,UAAU;AACb,gBAAA,WAAW,iBAAiB,YAAY,IAAI;AAAA,EAC1D;AAEO,SAAA,OAAO,YAAY,QAAQ;AAC3B,SAAA;AACT;AAEA,MAAM,aAAa,MAAM;AACjB,QAAA,IAAI,kBAAkB,+DAA+D,IAAI;AACjG;AAEA,MAAM,eAAe,OACnB,EAAE,UACF,KACA,cACG;AACH,QAAM,WAAW,MAAM,OACpB,MAAM,mDAAmD;AAAA,IACxD,QAAQ;AAAA,IACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,IAC9C,MAAM,KAAK,UAAU,EAAE,KAAK,WAAW,UAAUC,YAAU,UAAA,GAAG;AAAA,EAAA,CAC/D,EACA,MAAM,UAAU;AAEnB,QAAM,cAAc,SAAS,QAAQ,IAAI,cAAc;AAEnD,MAAA,aAAa,SAAS,kBAAkB,GAAG;AAC7C,UAAM,EAAE,MAAM,MAAA,IAAU,MAAM,SAAS,KAAK;AAE5C,YAAQ,SAAS,QAAQ;AAAA,MACvB,KAAK;AACH,eAAO,KAAK;AAAA,MACd,KAAK;AACG,cAAA,IAAI,kBAAkB,MAAM,OAAO;AAAA,MAC3C,KAAK;AACG,cAAA,IAAI,kBAAkB,mCAAmC;AAAA,MACjE;AACa;IACf;AAAA,EAAA,OACK;AACM;EACb;AACF;;;;;"}
@@ -11,7 +11,8 @@ const DEFAULT_FEATURES = {
11
11
  // The default of 90 days is set in the audit logs service
12
12
  { name: "audit-logs", options: { retentionDays: null } },
13
13
  { name: "review-workflows" },
14
- { name: "cms-content-releases" }
14
+ { name: "cms-content-releases" },
15
+ { name: "cms-content-history", options: { retentionDays: 99999 } }
15
16
  ]
16
17
  };
17
18
  const publicKey = fs.readFileSync(resolve(__dirname, "../../resources/key.pub"));
@@ -1 +1 @@
1
- {"version":3,"file":"license.mjs","sources":["../../src/ee/license.ts"],"sourcesContent":["import fs from 'fs';\nimport { join, resolve } from 'path';\nimport crypto from 'crypto';\nimport type { Core } from '@strapi/types';\n\nimport { machineID } from '@strapi/utils';\n\ninterface LicenseInfo {\n type: 'bronze' | 'silver' | 'gold';\n expireAt?: string;\n seats?: number;\n features?: Array<{ name: string; options?: Record<string, unknown> }>;\n}\n\nconst DEFAULT_FEATURES = {\n bronze: [],\n silver: [],\n gold: [\n { name: 'sso' },\n // Set a null retention duration to allow the user to override it\n // The default of 90 days is set in the audit logs service\n { name: 'audit-logs', options: { retentionDays: null } },\n { name: 'review-workflows' },\n { name: 'cms-content-releases' },\n ],\n};\n\nconst publicKey = fs.readFileSync(resolve(__dirname, '../../resources/key.pub'));\n\nclass LicenseCheckError extends Error {\n shouldFallback = false;\n\n constructor(message: string, shouldFallback = false) {\n super(message);\n\n this.shouldFallback = shouldFallback;\n }\n}\n\nconst readLicense = (directory: string) => {\n try {\n const path = join(directory, 'license.txt');\n return fs.readFileSync(path).toString();\n } catch (error) {\n if (typeof error === 'object' && error !== null && 'code' in error && error.code !== 'ENOENT') {\n throw Error('License file not readable, review its format and access rules.');\n }\n }\n};\n\nconst verifyLicense = (license: string) => {\n const [signature, base64Content] = Buffer.from(license, 'base64').toString().split('\\n');\n\n if (!signature || !base64Content) {\n throw new Error('Invalid license.');\n }\n\n const stringifiedContent = Buffer.from(base64Content, 'base64').toString();\n\n const verify = crypto.createVerify('RSA-SHA256');\n verify.update(stringifiedContent);\n verify.end();\n\n const verified = verify.verify(publicKey, signature, 'base64');\n\n if (!verified) {\n throw new Error('Invalid license.');\n }\n\n const licenseInfo: LicenseInfo = JSON.parse(stringifiedContent);\n\n if (!licenseInfo.features) {\n licenseInfo.features = DEFAULT_FEATURES[licenseInfo.type];\n }\n\n Object.freeze(licenseInfo.features);\n return licenseInfo;\n};\n\nconst throwError = () => {\n throw new LicenseCheckError('Could not proceed to the online validation of your license.', true);\n};\n\nconst fetchLicense = async (\n { strapi }: { strapi: Core.Strapi },\n key: string,\n projectId: string\n) => {\n const response = await strapi\n .fetch(`https://license.strapi.io/api/licenses/validate`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ key, projectId, deviceId: machineID() }),\n })\n .catch(throwError);\n\n const contentType = response.headers.get('Content-Type');\n\n if (contentType?.includes('application/json')) {\n const { data, error } = await response.json();\n\n switch (response.status) {\n case 200:\n return data.license;\n case 400:\n throw new LicenseCheckError(error.message);\n case 404:\n throw new LicenseCheckError('The license used does not exists.');\n default:\n throwError();\n }\n } else {\n throwError();\n }\n};\n\nexport { readLicense, verifyLicense, fetchLicense, LicenseCheckError };\n"],"names":[],"mappings":";;;;AAcA,MAAM,mBAAmB;AAAA,EACvB,QAAQ,CAAC;AAAA,EACT,QAAQ,CAAC;AAAA,EACT,MAAM;AAAA,IACJ,EAAE,MAAM,MAAM;AAAA;AAAA;AAAA,IAGd,EAAE,MAAM,cAAc,SAAS,EAAE,eAAe,OAAO;AAAA,IACvD,EAAE,MAAM,mBAAmB;AAAA,IAC3B,EAAE,MAAM,uBAAuB;AAAA,EACjC;AACF;AAEA,MAAM,YAAY,GAAG,aAAa,QAAQ,WAAW,yBAAyB,CAAC;AAE/E,MAAM,0BAA0B,MAAM;AAAA,EACpC,iBAAiB;AAAA,EAEjB,YAAY,SAAiB,iBAAiB,OAAO;AACnD,UAAM,OAAO;AAEb,SAAK,iBAAiB;AAAA,EACxB;AACF;AAEM,MAAA,cAAc,CAAC,cAAsB;AACrC,MAAA;AACI,UAAA,OAAO,KAAK,WAAW,aAAa;AAC1C,WAAO,GAAG,aAAa,IAAI,EAAE,SAAS;AAAA,WAC/B,OAAO;AACV,QAAA,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,MAAM,SAAS,UAAU;AAC7F,YAAM,MAAM,gEAAgE;AAAA,IAC9E;AAAA,EACF;AACF;AAEM,MAAA,gBAAgB,CAAC,YAAoB;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AA,MACjE;AACa;IACf;AAAA,EAAA,OACK;AACM;EACb;AACF;"}
1
+ {"version":3,"file":"license.mjs","sources":["../../src/ee/license.ts"],"sourcesContent":["import fs from 'fs';\nimport { join, resolve } from 'path';\nimport crypto from 'crypto';\nimport type { Core } from '@strapi/types';\n\nimport { machineID } from '@strapi/utils';\n\ninterface LicenseInfo {\n type: 'bronze' | 'silver' | 'gold';\n expireAt?: string;\n seats?: number;\n features?: Array<{ name: string; options?: Record<string, unknown> }>;\n}\n\nconst DEFAULT_FEATURES = {\n bronze: [],\n silver: [],\n gold: [\n { name: 'sso' },\n // Set a null retention duration to allow the user to override it\n // The default of 90 days is set in the audit logs service\n { name: 'audit-logs', options: { retentionDays: null } },\n { name: 'review-workflows' },\n { name: 'cms-content-releases' },\n { name: 'cms-content-history', options: { retentionDays: 99999 } },\n ],\n};\n\nconst publicKey = fs.readFileSync(resolve(__dirname, '../../resources/key.pub'));\n\nclass LicenseCheckError extends Error {\n shouldFallback = false;\n\n constructor(message: string, shouldFallback = false) {\n super(message);\n\n this.shouldFallback = shouldFallback;\n }\n}\n\nconst readLicense = (directory: string) => {\n try {\n const path = join(directory, 'license.txt');\n return fs.readFileSync(path).toString();\n } catch (error) {\n if (typeof error === 'object' && error !== null && 'code' in error && error.code !== 'ENOENT') {\n throw Error('License file not readable, review its format and access rules.');\n }\n }\n};\n\nconst verifyLicense = (license: string) => {\n const [signature, base64Content] = Buffer.from(license, 'base64').toString().split('\\n');\n\n if (!signature || !base64Content) {\n throw new Error('Invalid license.');\n }\n\n const stringifiedContent = Buffer.from(base64Content, 'base64').toString();\n\n const verify = crypto.createVerify('RSA-SHA256');\n verify.update(stringifiedContent);\n verify.end();\n\n const verified = verify.verify(publicKey, signature, 'base64');\n\n if (!verified) {\n throw new Error('Invalid license.');\n }\n\n const licenseInfo: LicenseInfo = JSON.parse(stringifiedContent);\n\n if (!licenseInfo.features) {\n licenseInfo.features = DEFAULT_FEATURES[licenseInfo.type];\n }\n\n Object.freeze(licenseInfo.features);\n return licenseInfo;\n};\n\nconst throwError = () => {\n throw new LicenseCheckError('Could not proceed to the online validation of your license.', true);\n};\n\nconst fetchLicense = async (\n { strapi }: { strapi: Core.Strapi },\n key: string,\n projectId: string\n) => {\n const response = await strapi\n .fetch(`https://license.strapi.io/api/licenses/validate`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ key, projectId, deviceId: machineID() }),\n })\n .catch(throwError);\n\n const contentType = response.headers.get('Content-Type');\n\n if (contentType?.includes('application/json')) {\n const { data, error } = await response.json();\n\n switch (response.status) {\n case 200:\n return data.license;\n case 400:\n throw new LicenseCheckError(error.message);\n case 404:\n throw new LicenseCheckError('The license used does not exists.');\n default:\n throwError();\n }\n } else {\n throwError();\n }\n};\n\nexport { readLicense, verifyLicense, fetchLicense, LicenseCheckError };\n"],"names":[],"mappings":";;;;AAcA,MAAM,mBAAmB;AAAA,EACvB,QAAQ,CAAC;AAAA,EACT,QAAQ,CAAC;AAAA,EACT,MAAM;AAAA,IACJ,EAAE,MAAM,MAAM;AAAA;AAAA;AAAA,IAGd,EAAE,MAAM,cAAc,SAAS,EAAE,eAAe,OAAO;AAAA,IACvD,EAAE,MAAM,mBAAmB;AAAA,IAC3B,EAAE,MAAM,uBAAuB;AAAA,IAC/B,EAAE,MAAM,uBAAuB,SAAS,EAAE,eAAe,QAAQ;AAAA,EACnE;AACF;AAEA,MAAM,YAAY,GAAG,aAAa,QAAQ,WAAW,yBAAyB,CAAC;AAE/E,MAAM,0BAA0B,MAAM;AAAA,EACpC,iBAAiB;AAAA,EAEjB,YAAY,SAAiB,iBAAiB,OAAO;AACnD,UAAM,OAAO;AAEb,SAAK,iBAAiB;AAAA,EACxB;AACF;AAEM,MAAA,cAAc,CAAC,cAAsB;AACrC,MAAA;AACI,UAAA,OAAO,KAAK,WAAW,aAAa;AAC1C,WAAO,GAAG,aAAa,IAAI,EAAE,SAAS;AAAA,WAC/B,OAAO;AACV,QAAA,OAAO,U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AAAA,MACvB,KAAK;AACH,eAAO,KAAK;AAAA,MACd,KAAK;AACG,cAAA,IAAI,kBAAkB,MAAM,OAAO;AAAA,MAC3C,KAAK;AACG,cAAA,IAAI,kBAAkB,mCAAmC;AAAA,MACjE;AACa;IACf;AAAA,EAAA,OACK;AACM;EACb;AACF;"}
@@ -2,9 +2,9 @@ import type { Core, UID, Utils } from '@strapi/types';
2
2
  type WithStrapiCallback<T> = T | (<S extends {
3
3
  strapi: Core.Strapi;
4
4
  }>(params: S) => T);
5
- declare const createCoreController: <TUID extends UID.ContentType, TController extends Core.CoreAPI.Controller.Extendable<TUID>>(uid: TUID, cfg?: WithStrapiCallback<Utils.PartialWithThis<Partial<Utils.If<UID.IsCollectionType<TUID>, Core.CoreAPI.Controller.CollectionType, Utils.If<UID.IsSingleType<TUID>, Core.CoreAPI.Controller.SingleType, Core.CoreAPI.Controller.Base>>> & Core.CoreAPI.Controller.Generic & TController>> | undefined) => ({ strapi, }: {
5
+ declare const createCoreController: <TUID extends UID.ContentType, TController extends Core.CoreAPI.Controller.Extendable<TUID>>(uid: TUID, cfg?: WithStrapiCallback<Utils.PartialWithThis<Core.CoreAPI.Controller.Extendable<TUID> & TController>>) => ({ strapi, }: {
6
6
  strapi: Core.Strapi;
7
- }) => TController & Utils.If<UID.IsCollectionType<TUID>, Core.CoreAPI.Controller.CollectionType, Utils.If<UID.IsSingleType<TUID>, Core.CoreAPI.Controller.SingleType, Core.CoreAPI.Controller.Base>>;
7
+ }) => TController & Core.CoreAPI.Controller.ContentType<TUID>;
8
8
  declare function createCoreService<TUID extends UID.ContentType, TService extends Core.CoreAPI.Service.Extendable<TUID>>(uid: TUID, cfg?: WithStrapiCallback<Utils.PartialWithThis<Core.CoreAPI.Service.Extendable<TUID> & TService>>): ({ strapi, }: {
9
9
  strapi: Core.Strapi;
10
10
  }) => TService & Core.CoreAPI.Service.ContentType<TUID>;
@@ -1 +1 @@
1
- {"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../src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E,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Migration } from '@strapi/database';
2
+ /**
3
+ * On V4 there was no concept of document, and an entry could be in a draft or published state.
4
+ * But not both at the same time.
5
+ *
6
+ * On V5 we introduced the concept of document, and an entry can be in a draft or published state,
7
+ * with the requirement that a document must always have a draft.
8
+ *
9
+ * This migration creates the document draft counterpart for all the entries that were in a published state.
10
+ */
11
+ export declare const discardDocumentDrafts: Migration;
12
+ //# sourceMappingURL=5.0.0-discard-drafts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"5.0.0-discard-drafts.d.ts","sourceRoot":"","sources":["../../../src/migrations/database/5.0.0-discard-drafts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAY,SAAS,EAAE,MAAM,kBAAkB,CAAC;AA8E5D;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,SASnC,CAAC"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const strapiUtils = require("@strapi/utils");
4
+ async function* getBatchToDiscard({
5
+ db,
6
+ trx,
7
+ uid,
8
+ batchSize = 1e3
9
+ }) {
10
+ let offset = 0;
11
+ let hasMore = true;
12
+ while (hasMore) {
13
+ const batch = await db.queryBuilder(uid).select(["id", "documentId", "locale"]).where({ publishedAt: { $ne: null } }).limit(batchSize).offset(offset).orderBy("id").transacting(trx).execute();
14
+ if (batch.length < batchSize) {
15
+ hasMore = false;
16
+ }
17
+ offset += batchSize;
18
+ yield batch;
19
+ }
20
+ }
21
+ const migrateUp = async (trx, db) => {
22
+ for (const meta of db.metadata.values()) {
23
+ const hasTable = await trx.schema.hasTable(meta.tableName);
24
+ if (!hasTable) {
25
+ continue;
26
+ }
27
+ const uid = meta.uid;
28
+ const model = strapi.getModel(uid);
29
+ const hasDP = strapiUtils.contentTypes.hasDraftAndPublish(model);
30
+ if (!hasDP) {
31
+ continue;
32
+ }
33
+ const discardDraft = async (entry) => strapi.documents(uid).discardDraft({ documentId: entry.documentId, locale: entry.locale });
34
+ for await (const batch of getBatchToDiscard({ db, trx, uid: meta.uid })) {
35
+ await strapiUtils.async.map(batch, discardDraft, { concurrency: 10 });
36
+ }
37
+ }
38
+ };
39
+ const discardDocumentDrafts = {
40
+ name: "core::5.0.0-discard-drafts",
41
+ async up(trx, db) {
42
+ await migrateUp(trx, db);
43
+ },
44
+ async down() {
45
+ throw new Error("not implemented");
46
+ }
47
+ };
48
+ exports.discardDocumentDrafts = discardDocumentDrafts;
49
+ //# sourceMappingURL=5.0.0-discard-drafts.js.map
@@ -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 */\nasync function* getBatchToDiscard({\n db,\n trx,\n uid,\n batchSize = 1000,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n batchSize?: number;\n}) {\n let offset = 0;\n let hasMore = true;\n\n while (hasMore) {\n // Look for the published entries to discard\n const batch: DocumentVersion[] = await db\n .queryBuilder(uid)\n .select(['id', 'documentId', 'locale'])\n .where({ publishedAt: { $ne: null } })\n .limit(batchSize)\n .offset(offset)\n .orderBy('id')\n .transacting(trx)\n .execute();\n\n if (batch.length < batchSize) {\n hasMore = false;\n }\n\n offset += batchSize;\n yield batch;\n }\n}\n\nconst migrateUp = async (trx: Knex, db: Database) => {\n for (const meta of db.metadata.values()) {\n const hasTable = await trx.schema.hasTable(meta.tableName);\n\n if (!hasTable) {\n continue;\n }\n\n const uid = meta.uid as UID.ContentType;\n const model = strapi.getModel(uid);\n const hasDP = contentTypes.hasDraftAndPublish(model);\n if (!hasDP) {\n continue;\n }\n\n const discardDraft = async (entry: DocumentVersion) =>\n strapi\n .documents(uid)\n // Discard draft by referencing the documentId and locale\n .discardDraft({ documentId: entry.documentId, locale: entry.locale });\n\n /**\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n */\n for await (const batch of getBatchToDiscard({ db, trx, uid: meta.uid })) {\n await async.map(batch, discardDraft, { concurrency: 10 });\n }\n }\n};\n\n/**\n * On V4 there was no concept of document, and an entry could be in a draft or published state.\n * But not both at the same time.\n *\n * On V5 we introduced the concept of document, and an entry can be in a draft or published state,\n * with the requirement that a document must always have a draft.\n *\n * This migration creates the document draft counterpart for all the entries that were in a published state.\n */\nexport const discardDocumentDrafts: Migration = {\n name: 'core::5.0.0-discard-drafts',\n async up(trx, db) {\n // TODO: Log to inform the user that the migration is running in the background\n await migrateUp(trx, db);\n },\n async down() {\n throw new Error('not implemented');\n },\n};\n"],"names":["contentTypes","async"],"mappings":";;;AAcA,gBAAgB,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AACd,GAKG;AACD,MAAI,SAAS;AACb,MAAI,UAAU;AAEd,SAAO,SAAS;AAEd,UAAM,QAA2B,MAAM,GACpC,aAAa,GAAG,EAChB,OAAO,CAAC,MAAM,cAAc,QAAQ,CAAC,EACrC,MAAM,EAAE,aAAa,EAAE,KAAK,KAAO,EAAA,CAAC,EACpC,MAAM,SAAS,EACf,OAAO,MAAM,EACb,QAAQ,IAAI,EACZ,YAAY,GAAG,EACf,QAAQ;AAEP,QAAA,MAAM,SAAS,WAAW;AAClB,gBAAA;AAAA,IACZ;AAEU,cAAA;AACJ,UAAA;AAAA,EACR;AACF;AAEA,MAAM,YAAY,OAAO,KAAW,OAAiB;AACnD,aAAW,QAAQ,GAAG,SAAS,OAAA,GAAU;AACvC,UAAM,WAAW,MAAM,IAAI,OAAO,SAAS,KAAK,SAAS;AAEzD,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AAEA,UAAM,MAAM,KAAK;AACX,UAAA,QAAQ,OAAO,SAAS,GAAG;AAC3B,UAAA,QAAQA,YAAAA,aAAa,mBAAmB,KAAK;AACnD,QAAI,CAAC,OAAO;AACV;AAAA,IACF;AAEA,UAAM,eAAe,OAAO,UAC1B,OACG,UAAU,GAAG,EAEb,aAAa,EAAE,YAAY,MAAM,YAAY,QAAQ,MAAM,QAAQ;AAMvD,qBAAA,SAAS,kBAAkB,EAAE,IAAI,KAAK,KAAK,KAAK,IAAI,CAAC,GAAG;AACvE,YAAMC,YAAAA,MAAM,IAAI,OAAO,cAAc,EAAE,aAAa,IAAI;AAAA,IAC1D;AAAA,EACF;AACF;AAWO,MAAM,wBAAmC;AAAA,EAC9C,MAAM;AAAA,EACN,MAAM,GAAG,KAAK,IAAI;AAEV,UAAA,UAAU,KAAK,EAAE;AAAA,EACzB;AAAA,EACA,MAAM,OAAO;AACL,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACnC;AACF;;"}
@@ -0,0 +1,49 @@
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
+ };
49
+ //# 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 */\nasync function* getBatchToDiscard({\n db,\n trx,\n uid,\n batchSize = 1000,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n batchSize?: number;\n}) {\n let offset = 0;\n let hasMore = true;\n\n while (hasMore) {\n // Look for the published entries to discard\n const batch: DocumentVersion[] = await db\n .queryBuilder(uid)\n .select(['id', 'documentId', 'locale'])\n .where({ publishedAt: { $ne: null } })\n .limit(batchSize)\n .offset(offset)\n .orderBy('id')\n .transacting(trx)\n .execute();\n\n if (batch.length < batchSize) {\n hasMore = false;\n }\n\n offset += batchSize;\n yield batch;\n }\n}\n\nconst migrateUp = async (trx: Knex, db: Database) => {\n for (const meta of db.metadata.values()) {\n const hasTable = await trx.schema.hasTable(meta.tableName);\n\n if (!hasTable) {\n continue;\n }\n\n const uid = meta.uid as UID.ContentType;\n const model = strapi.getModel(uid);\n const hasDP = contentTypes.hasDraftAndPublish(model);\n if (!hasDP) {\n continue;\n }\n\n const discardDraft = async (entry: DocumentVersion) =>\n strapi\n .documents(uid)\n // Discard draft by referencing the documentId and locale\n .discardDraft({ documentId: entry.documentId, locale: entry.locale });\n\n /**\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n */\n for await (const batch of getBatchToDiscard({ db, trx, uid: meta.uid })) {\n await async.map(batch, discardDraft, { concurrency: 10 });\n }\n }\n};\n\n/**\n * On V4 there was no concept of document, and an entry could be in a draft or published state.\n * But not both at the same time.\n *\n * On V5 we introduced the concept of document, and an entry can be in a draft or published state,\n * with the requirement that a document must always have a draft.\n *\n * This migration creates the document draft counterpart for all the entries that were in a published state.\n */\nexport const discardDocumentDrafts: Migration = {\n name: 'core::5.0.0-discard-drafts',\n async up(trx, db) {\n // TODO: Log to inform the user that the migration is running in the background\n await migrateUp(trx, db);\n },\n async down() {\n throw new Error('not implemented');\n },\n};\n"],"names":[],"mappings":";AAcA,gBAAgB,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AACd,GAKG;AACD,MAAI,SAAS;AACb,MAAI,UAAU;AAEd,SAAO,SAAS;AAEd,UAAM,QAA2B,MAAM,GACpC,aAAa,GAAG,EAChB,OAAO,CAAC,MAAM,cAAc,QAAQ,CAAC,EACrC,MAAM,EAAE,aAAa,EAAE,KAAK,KAAO,EAAA,CAAC,EACpC,MAAM,SAAS,EACf,OAAO,MAAM,EACb,QAAQ,IAAI,EACZ,YAAY,GAAG,EACf,QAAQ;AAEP,QAAA,MAAM,SAAS,WAAW;AAClB,gBAAA;AAAA,IACZ;AAEU,cAAA;AACJ,UAAA;AAAA,EACR;AACF;AAEA,MAAM,YAAY,OAAO,KAAW,OAAiB;AACnD,aAAW,QAAQ,GAAG,SAAS,OAAA,GAAU;AACvC,UAAM,WAAW,MAAM,IAAI,OAAO,SAAS,KAAK,SAAS;AAEzD,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AAEA,UAAM,MAAM,KAAK;AACX,UAAA,QAAQ,OAAO,SAAS,GAAG;AAC3B,UAAA,QAAQ,aAAa,mBAAmB,KAAK;AACnD,QAAI,CAAC,OAAO;AACV;AAAA,IACF;AAEA,UAAM,eAAe,OAAO,UAC1B,OACG,UAAU,GAAG,EAEb,aAAa,EAAE,YAAY,MAAM,YAAY,QAAQ,MAAM,QAAQ;AAMvD,qBAAA,SAAS,kBAAkB,EAAE,IAAI,KAAK,KAAK,KAAK,IAAI,CAAC,GAAG;AACvE,YAAM,MAAM,IAAI,OAAO,cAAc,EAAE,aAAa,IAAI;AAAA,IAC1D;AAAA,EACF;AACF;AAWO,MAAM,wBAAmC;AAAA,EAC9C,MAAM;AAAA,EACN,MAAM,GAAG,KAAK,IAAI;AAEV,UAAA,UAAU,KAAK,EAAE;AAAA,EACzB;AAAA,EACA,MAAM,OAAO;AACL,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACnC;AACF;"}
@@ -1 +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,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AC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AAEpC,UAAU,SAAS;IACjB,CAAC,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG;QAChC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,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"}