@strapi/core 5.0.0-beta.3 → 5.0.0-beta.4
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.
- package/dist/core-api/controller/collection-type.d.ts.map +1 -1
- package/dist/core-api/controller/collection-type.js +1 -0
- package/dist/core-api/controller/collection-type.js.map +1 -1
- package/dist/core-api/controller/collection-type.mjs +1 -0
- package/dist/core-api/controller/collection-type.mjs.map +1 -1
- package/dist/core-api/routes/index.d.ts.map +1 -1
- package/dist/ee/license.d.ts.map +1 -1
- package/dist/ee/license.js +2 -1
- package/dist/ee/license.js.map +1 -1
- package/dist/ee/license.mjs +2 -1
- package/dist/ee/license.mjs.map +1 -1
- package/dist/factories.d.ts +2 -2
- package/dist/factories.d.ts.map +1 -1
- package/dist/services/core-store.d.ts.map +1 -1
- package/dist/services/document-service/attributes/index.d.ts +4 -4
- package/dist/services/document-service/attributes/index.d.ts.map +1 -1
- package/dist/services/document-service/attributes/index.js +5 -5
- package/dist/services/document-service/attributes/index.js.map +1 -1
- package/dist/services/document-service/attributes/index.mjs +5 -5
- package/dist/services/document-service/attributes/index.mjs.map +1 -1
- package/dist/services/document-service/common.d.ts.map +1 -1
- package/dist/services/document-service/components.d.ts +8 -80
- package/dist/services/document-service/components.d.ts.map +1 -1
- package/dist/services/document-service/components.js +18 -19
- package/dist/services/document-service/components.js.map +1 -1
- package/dist/services/document-service/components.mjs +19 -20
- package/dist/services/document-service/components.mjs.map +1 -1
- package/dist/services/document-service/document-engine.d.ts +0 -1
- package/dist/services/document-service/entries.d.ts +2 -0
- package/dist/services/document-service/entries.d.ts.map +1 -1
- package/dist/services/document-service/entries.js +47 -14
- package/dist/services/document-service/entries.js.map +1 -1
- package/dist/services/document-service/entries.mjs +42 -9
- package/dist/services/document-service/entries.mjs.map +1 -1
- package/dist/services/document-service/index.d.ts.map +1 -1
- package/dist/services/document-service/index.js +8 -10
- package/dist/services/document-service/index.js.map +1 -1
- package/dist/services/document-service/index.mjs +8 -10
- package/dist/services/document-service/index.mjs.map +1 -1
- package/dist/services/document-service/internationalization.d.ts.map +1 -1
- package/dist/services/document-service/internationalization.js.map +1 -1
- package/dist/services/document-service/internationalization.mjs.map +1 -1
- package/dist/services/document-service/middlewares/middleware-manager.d.ts +1 -1
- package/dist/services/document-service/middlewares/middleware-manager.d.ts.map +1 -1
- package/dist/services/document-service/middlewares/middleware-manager.js +1 -1
- package/dist/services/document-service/middlewares/middleware-manager.js.map +1 -1
- package/dist/services/document-service/middlewares/middleware-manager.mjs +1 -1
- package/dist/services/document-service/middlewares/middleware-manager.mjs.map +1 -1
- package/dist/services/document-service/params.d.ts +1 -5
- package/dist/services/document-service/params.d.ts.map +1 -1
- package/dist/services/document-service/repository.d.ts.map +1 -1
- package/dist/services/document-service/repository.js +13 -39
- package/dist/services/document-service/repository.js.map +1 -1
- package/dist/services/document-service/repository.mjs +6 -32
- package/dist/services/document-service/repository.mjs.map +1 -1
- package/dist/services/document-service/transform/id-map.d.ts.map +1 -1
- package/dist/services/entity-service/index.d.ts.map +1 -1
- package/dist/services/entity-validator/index.js.map +1 -1
- package/dist/services/entity-validator/index.mjs.map +1 -1
- package/dist/services/metrics/middleware.d.ts.map +1 -1
- package/dist/services/server/compose-endpoint.d.ts.map +1 -1
- package/dist/services/server/koa.d.ts.map +1 -1
- package/dist/services/webhook-store.d.ts.map +1 -1
- package/dist/utils/load-files.d.ts.map +1 -1
- package/dist/utils/startup-logger.d.ts.map +1 -1
- package/package.json +15 -15
@@ -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,
|
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"}
|
@@ -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,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,OAAO,KAAK;AACV,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAEnD,YAAM,EAAE,OAAO,CAAA,MAAc,IAAI;AAEjC,UAAI,CAACA,EAAA,SAAS,KAAK,IAAI,GAAG;AAClB,cAAA,IAAIC,YAAO,OAAA,gBAAgB,4CAA4C;AAAA,MAC/E;AAEA,YAAM,qBAAqB,MAAM,KAAK,cAAc,KAAK,MAAM,GAAG;AAElE,YAAM,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,OAAO;AAAA,QAC9C,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACP;AAED,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;
|
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,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,QAAQ,IAAI,cAAc;AACnE,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,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAEnD,YAAM,EAAE,OAAO,CAAA,MAAc,IAAI;AAEjC,UAAI,CAACA,EAAA,SAAS,KAAK,IAAI,GAAG;AAClB,cAAA,IAAIC,YAAO,OAAA,gBAAgB,4CAA4C;AAAA,MAC/E;AAEA,YAAM,qBAAqB,MAAM,KAAK,cAAc,KAAK,MAAM,GAAG;AAElE,YAAM,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,OAAO;AAAA,QAC9C,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACP;AAED,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAE7D,UAAI,SAAS;AACN,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,OAAO,KAAkB;AACvB,YAAA,EAAE,GAAG,IAAI,IAAI;AACb,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAEnD,YAAM,EAAE,OAAO,CAAA,MAAc,IAAI;AAEjC,UAAI,CAACD,EAAA,SAAS,KAAK,IAAI,GAAG;AAClB,cAAA,IAAIC,YAAO,OAAA,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":"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,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,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,OAAO,KAAK;AACV,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;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;AAAA,QAC9C,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACP;AAED,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;
|
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,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,GAA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AAG;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;
|
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"}
|
package/dist/ee/license.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"license.d.ts","sourceRoot":"","sources":["../../src/ee/license.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAI1C,UAAU,WAAW;IACnB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;CACvE;
|
1
|
+
{"version":3,"file":"license.d.ts","sourceRoot":"","sources":["../../src/ee/license.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAI1C,UAAU,WAAW;IACnB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;CACvE;AAkBD,cAAM,iBAAkB,SAAQ,KAAK;IACnC,cAAc,UAAS;gBAEX,OAAO,EAAE,MAAM,EAAE,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"}
|
package/dist/ee/license.js
CHANGED
@@ -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"));
|
package/dist/ee/license.js.map
CHANGED
@@ -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,MAAM,cAAc,SAAS,EAAE,eAAe,OAAO;AAAA,IACvD,EAAE,MAAM,mBAAmB;AAAA,IAC3B,EAAE,MAAM,uBAAuB;AAAA,
|
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();\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;AAC/C,SAAO,OAAO,kBAAkB;AAChC,SAAO,IAAI;AAEX,QAAM,WAAW,OAAO,OAAO,WAAW,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;;;;;"}
|
package/dist/ee/license.mjs
CHANGED
@@ -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"));
|
package/dist/ee/license.mjs.map
CHANGED
@@ -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,
|
1
|
+
{"version":3,"file":"license.mjs","sources":["../../src/ee/license.ts"],"sourcesContent":["import fs from 'fs';\nimport { join, resolve } from 'path';\nimport crypto from 'crypto';\nimport type { Core } from '@strapi/types';\n\nimport { machineID } from '@strapi/utils';\n\ninterface LicenseInfo {\n type: 'bronze' | 'silver' | 'gold';\n expireAt?: string;\n seats?: number;\n features?: Array<{ name: string; options?: Record<string, unknown> }>;\n}\n\nconst DEFAULT_FEATURES = {\n bronze: [],\n silver: [],\n gold: [\n { name: 'sso' },\n // Set a null retention duration to allow the user to override it\n // The default of 90 days is set in the audit logs service\n { name: 'audit-logs', options: { retentionDays: null } },\n { name: 'review-workflows' },\n { name: 'cms-content-releases' },\n { name: 'cms-content-history', options: { retentionDays: 99999 } },\n ],\n};\n\nconst publicKey = fs.readFileSync(resolve(__dirname, '../../resources/key.pub'));\n\nclass LicenseCheckError extends Error {\n shouldFallback = false;\n\n constructor(message: string, shouldFallback = false) {\n super(message);\n\n this.shouldFallback = shouldFallback;\n }\n}\n\nconst readLicense = (directory: string) => {\n try {\n const path = join(directory, 'license.txt');\n return fs.readFileSync(path).toString();\n } catch (error) {\n if (typeof error === 'object' && error !== null && 'code' in error && error.code !== 'ENOENT') {\n throw Error('License file not readable, review its format and access rules.');\n }\n }\n};\n\nconst verifyLicense = (license: string) => {\n const [signature, base64Content] = Buffer.from(license, 'base64').toString().split('\\n');\n\n if (!signature || !base64Content) {\n throw new Error('Invalid license.');\n }\n\n const stringifiedContent = Buffer.from(base64Content, 'base64').toString();\n\n const verify = crypto.createVerify('RSA-SHA256');\n verify.update(stringifiedContent);\n verify.end();\n\n const verified = verify.verify(publicKey, signature, 'base64');\n\n if (!verified) {\n throw new Error('Invalid license.');\n }\n\n const licenseInfo: LicenseInfo = JSON.parse(stringifiedContent);\n\n if (!licenseInfo.features) {\n licenseInfo.features = DEFAULT_FEATURES[licenseInfo.type];\n }\n\n Object.freeze(licenseInfo.features);\n return licenseInfo;\n};\n\nconst throwError = () => {\n throw new LicenseCheckError('Could not proceed to the online validation of your license.', true);\n};\n\nconst fetchLicense = async (\n { strapi }: { strapi: Core.Strapi },\n key: string,\n projectId: string\n) => {\n const response = await strapi\n .fetch(`https://license.strapi.io/api/licenses/validate`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ key, projectId, deviceId: machineID() }),\n })\n .catch(throwError);\n\n const contentType = response.headers.get('Content-Type');\n\n if (contentType?.includes('application/json')) {\n const { data, error } = await response.json();\n\n switch (response.status) {\n case 200:\n return data.license;\n case 400:\n throw new LicenseCheckError(error.message);\n case 404:\n throw new LicenseCheckError('The license used does not exists.');\n default:\n throwError();\n }\n } else {\n throwError();\n }\n};\n\nexport { readLicense, verifyLicense, fetchLicense, LicenseCheckError };\n"],"names":[],"mappings":";;;;AAcA,MAAM,mBAAmB;AAAA,EACvB,QAAQ,CAAC;AAAA,EACT,QAAQ,CAAC;AAAA,EACT,MAAM;AAAA,IACJ,EAAE,MAAM,MAAM;AAAA;AAAA;AAAA,IAGd,EAAE,MAAM,cAAc,SAAS,EAAE,eAAe,OAAO;AAAA,IACvD,EAAE,MAAM,mBAAmB;AAAA,IAC3B,EAAE,MAAM,uBAAuB;AAAA,IAC/B,EAAE,MAAM,uBAAuB,SAAS,EAAE,eAAe,QAAQ;AAAA,EACnE;AACF;AAEA,MAAM,YAAY,GAAG,aAAa,QAAQ,WAAW,yBAAyB,CAAC;AAE/E,MAAM,0BAA0B,MAAM;AAAA,EACpC,iBAAiB;AAAA,EAEjB,YAAY,SAAiB,iBAAiB,OAAO;AACnD,UAAM,OAAO;AAEb,SAAK,iBAAiB;AAAA,EACxB;AACF;AAEM,MAAA,cAAc,CAAC,cAAsB;AACrC,MAAA;AACI,UAAA,OAAO,KAAK,WAAW,aAAa;AAC1C,WAAO,GAAG,aAAa,IAAI,EAAE,SAAS;AAAA,WAC/B,OAAO;AACV,QAAA,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,MAAM,SAAS,UAAU;AAC7F,YAAM,MAAM,gEAAgE;AAAA,IAC9E;AAAA,EACF;AACF;AAEM,MAAA,gBAAgB,CAAC,YAAoB;AACzC,QAAM,CAAC,WAAW,aAAa,IAAI,OAAO,KAAK,SAAS,QAAQ,EAAE,SAAA,EAAW,MAAM,IAAI;AAEnF,MAAA,CAAC,aAAa,CAAC,eAAe;AAC1B,UAAA,IAAI,MAAM,kBAAkB;AAAA,EACpC;AAEA,QAAM,qBAAqB,OAAO,KAAK,eAAe,QAAQ,EAAE;AAE1D,QAAA,SAAS,OAAO,aAAa,YAAY;AAC/C,SAAO,OAAO,kBAAkB;AAChC,SAAO,IAAI;AAEX,QAAM,WAAW,OAAO,OAAO,WAAW,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,UAAU,UAAU,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;"}
|
package/dist/factories.d.ts
CHANGED
@@ -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<
|
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 &
|
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>;
|
package/dist/factories.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../src/factories.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAUtD,KAAK,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AAEvF,QAAA,MAAM,oBAAoB;
|
1
|
+
{"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../src/factories.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAUtD,KAAK,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;IAAE,MAAM,EAAE,IAAI,CAAC,MA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AC;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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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":"
|
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 = (
|
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 =
|
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 = {
|
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\
|
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 = (
|
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 =
|
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 = {
|
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\
|
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,
|
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
|
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
|
11
|
-
declare
|
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<
|
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
|
-
|
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","sourceRoot":"","sources":["../../../src/services/document-service/components.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/components.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAEvB,OAAO,KAAK,EAAS,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAIvE,KAAK,KAAK,CAAC,CAAC,SAAS,GAAG,CAAC,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAE1E,KAAK,gBAAgB,CAAC,IAAI,SAAS,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAC1D,IAAI,EACJ,MAAM,CAAC,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,aAAa,CAAC,CAC/D,CAAC;AAEF,KAAK,oBAAoB,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAClF,KAAK,wBAAwB,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAErF,KAAK,cAAc,GAAG,oBAAoB,GAAG,wBAAwB,CAAC;AAEtE,KAAK,gBAAgB,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;AAE3E,KAAK,aAAa,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,gBAAgB,CAAC;CAClD,CAAC;AAEF,QAAA,MAAM,iBAAiB,gLAStB,CAAC;AAGF,QAAA,MAAM,gBAAgB,4DACf,IAAI,QACH,KAAK,2BA6FZ,CAAC;AAEF,QAAA,MAAM,aAAa,iCACZ,IAAI,UACD;IAAE,EAAE,EAAE,QAAQ,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAA;CAAE,KACxD,QAAQ,iBAAiB,IAAI,CAAC,CAQhC,CAAC;AAMF,QAAA,MAAM,gBAAgB,qEACf,IAAI,kBACO;IAAE,EAAE,EAAE,QAAQ,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAA;CAAE,QAC3D,KAAK,2BA0EZ,CAAC;AAkGF,QAAA,MAAM,gBAAgB,oHACf,IAAI,kBACO,OAAO;;mBAqCxB,CAAC;AAyDF,QAAA,MAAM,eAAe,4CACd,IAAI,qBACU,KAAK,SAAS,CAAC,IAAI,CAAC,kBAIxC,CAAC;AAEF,QAAA,MAAM,mBAAmB,+MAIxB,CAAC;AAEF,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAChB,CAAC"}
|
@@ -5,13 +5,15 @@ const _ = require("lodash/fp");
|
|
5
5
|
const strapiUtils = require("@strapi/utils");
|
6
6
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
7
7
|
const ___default = /* @__PURE__ */ _interopDefault(_$1);
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
const omitComponentData = _.curry(
|
9
|
+
(schema, data) => {
|
10
|
+
const { attributes } = schema;
|
11
|
+
const componentAttributes = Object.keys(attributes).filter(
|
12
|
+
(attributeName) => strapiUtils.contentTypes.isComponentAttribute(attributes[attributeName])
|
13
|
+
);
|
14
|
+
return _.omit(componentAttributes, data);
|
15
|
+
}
|
16
|
+
);
|
15
17
|
const createComponents = async (uid, data) => {
|
16
18
|
const { attributes = {} } = strapi.getModel(uid);
|
17
19
|
const componentBody = {};
|
@@ -239,26 +241,23 @@ const deleteComponents = async (uid, entityToDelete, { loadComponents = true } =
|
|
239
241
|
}
|
240
242
|
};
|
241
243
|
const createComponent = async (uid, data) => {
|
242
|
-
const
|
244
|
+
const schema = strapi.getModel(uid);
|
243
245
|
const componentData = await createComponents(uid, data);
|
244
246
|
const transform = _.pipe(
|
245
247
|
// Make sure we don't save the component with a pre-defined ID
|
246
248
|
_.omit("id"),
|
247
|
-
|
248
|
-
(payload) => omitComponentData(model, payload),
|
249
|
-
// ... and assign the newly created component instead
|
250
|
-
_.assign(componentData)
|
249
|
+
assignComponentData(schema, componentData)
|
251
250
|
);
|
252
251
|
return strapi.db.query(uid).create({ data: transform(data) });
|
253
252
|
};
|
254
253
|
const updateComponent = async (uid, componentToUpdate, data) => {
|
255
|
-
const
|
254
|
+
const schema = strapi.getModel(uid);
|
256
255
|
const componentData = await updateComponents(uid, componentToUpdate, data);
|
257
256
|
return strapi.db.query(uid).update({
|
258
257
|
where: {
|
259
258
|
id: componentToUpdate.id
|
260
259
|
},
|
261
|
-
data:
|
260
|
+
data: assignComponentData(schema, componentData, data)
|
262
261
|
});
|
263
262
|
};
|
264
263
|
const updateOrCreateComponent = (componentUID, value) => {
|
@@ -274,11 +273,11 @@ const deleteComponent = async (uid, componentToDelete) => {
|
|
274
273
|
await deleteComponents(uid, componentToDelete);
|
275
274
|
await strapi.db.query(uid).delete({ where: { id: componentToDelete.id } });
|
276
275
|
};
|
277
|
-
const assignComponentData = (
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
276
|
+
const assignComponentData = _.curry(
|
277
|
+
(schema, componentData, data) => {
|
278
|
+
return _.pipe(omitComponentData(schema), _.assign(componentData))(data);
|
279
|
+
}
|
280
|
+
);
|
282
281
|
exports.assignComponentData = assignComponentData;
|
283
282
|
exports.createComponents = createComponents;
|
284
283
|
exports.deleteComponent = deleteComponent;
|