@strapi/core 0.0.0-experimental.76447298a89499e415c97916c03f4f90c25ff336 → 0.0.0-experimental.779667bd163026468f566293decf331a0246fff9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @strapi/core might be problematic. Click here for more details.
- package/dist/Strapi.d.ts +3 -1
- package/dist/Strapi.d.ts.map +1 -1
- package/dist/Strapi.js +57 -13
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs +38 -13
- package/dist/Strapi.mjs.map +1 -1
- package/dist/core-api/controller/collection-type.d.ts.map +1 -1
- package/dist/core-api/controller/collection-type.js +2 -0
- package/dist/core-api/controller/collection-type.js.map +1 -1
- package/dist/core-api/controller/collection-type.mjs +2 -0
- package/dist/core-api/controller/collection-type.mjs.map +1 -1
- package/dist/core-api/controller/single-type.d.ts.map +1 -1
- package/dist/core-api/controller/single-type.js +1 -0
- package/dist/core-api/controller/single-type.js.map +1 -1
- package/dist/core-api/controller/single-type.mjs +1 -0
- package/dist/core-api/controller/single-type.mjs.map +1 -1
- package/dist/core-api/service/collection-type.d.ts +1 -7
- package/dist/core-api/service/collection-type.d.ts.map +1 -1
- package/dist/core-api/service/collection-type.js +5 -3
- package/dist/core-api/service/collection-type.js.map +1 -1
- package/dist/core-api/service/collection-type.mjs +6 -4
- package/dist/core-api/service/collection-type.mjs.map +1 -1
- package/dist/core-api/service/pagination.d.ts +4 -11
- package/dist/core-api/service/pagination.d.ts.map +1 -1
- package/dist/core-api/service/pagination.js +14 -40
- package/dist/core-api/service/pagination.js.map +1 -1
- package/dist/core-api/service/pagination.mjs +16 -42
- package/dist/core-api/service/pagination.mjs.map +1 -1
- package/dist/core-api/service/single-type.d.ts.map +1 -1
- package/dist/core-api/service/single-type.js +2 -1
- package/dist/core-api/service/single-type.js.map +1 -1
- package/dist/core-api/service/single-type.mjs +2 -1
- package/dist/core-api/service/single-type.mjs.map +1 -1
- package/dist/loaders/apis.d.ts.map +1 -1
- package/dist/loaders/apis.js +10 -10
- package/dist/loaders/apis.js.map +1 -1
- package/dist/loaders/apis.mjs +10 -10
- package/dist/loaders/apis.mjs.map +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.d.ts.map +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.js +5 -5
- package/dist/loaders/plugins/get-enabled-plugins.js.map +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.mjs +5 -5
- package/dist/loaders/plugins/get-enabled-plugins.mjs.map +1 -1
- package/dist/middlewares/cors.d.ts.map +1 -1
- package/dist/middlewares/cors.js +6 -8
- package/dist/middlewares/cors.js.map +1 -1
- package/dist/middlewares/cors.mjs +6 -8
- package/dist/middlewares/cors.mjs.map +1 -1
- package/dist/middlewares/security.d.ts.map +1 -1
- package/dist/middlewares/security.js +10 -3
- package/dist/middlewares/security.js.map +1 -1
- package/dist/middlewares/security.mjs +11 -4
- package/dist/middlewares/security.mjs.map +1 -1
- package/dist/migrations/database/5.0.0-discard-drafts.d.ts +19 -1
- package/dist/migrations/database/5.0.0-discard-drafts.d.ts.map +1 -1
- package/dist/migrations/database/5.0.0-discard-drafts.js +1 -0
- package/dist/migrations/database/5.0.0-discard-drafts.js.map +1 -1
- package/dist/migrations/database/5.0.0-discard-drafts.mjs +2 -1
- package/dist/migrations/database/5.0.0-discard-drafts.mjs.map +1 -1
- package/dist/migrations/draft-publish.d.ts.map +1 -1
- package/dist/migrations/draft-publish.js +14 -31
- package/dist/migrations/draft-publish.js.map +1 -1
- package/dist/migrations/draft-publish.mjs +15 -32
- package/dist/migrations/draft-publish.mjs.map +1 -1
- package/dist/services/document-service/entries.d.ts +1 -1
- package/dist/services/document-service/entries.d.ts.map +1 -1
- package/dist/services/document-service/entries.js +2 -1
- package/dist/services/document-service/entries.js.map +1 -1
- package/dist/services/document-service/entries.mjs +2 -1
- package/dist/services/document-service/entries.mjs.map +1 -1
- package/dist/services/document-service/events.d.ts +25 -0
- package/dist/services/document-service/events.d.ts.map +1 -0
- package/dist/services/document-service/events.js +47 -0
- package/dist/services/document-service/events.js.map +1 -0
- package/dist/services/document-service/events.mjs +47 -0
- package/dist/services/document-service/events.mjs.map +1 -0
- package/dist/services/document-service/index.d.ts.map +1 -1
- package/dist/services/document-service/index.js.map +1 -1
- 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 +14 -5
- package/dist/services/document-service/internationalization.js.map +1 -1
- package/dist/services/document-service/internationalization.mjs +14 -5
- package/dist/services/document-service/internationalization.mjs.map +1 -1
- package/dist/services/document-service/repository.d.ts.map +1 -1
- package/dist/services/document-service/repository.js +73 -45
- package/dist/services/document-service/repository.js.map +1 -1
- package/dist/services/document-service/repository.mjs +75 -47
- package/dist/services/document-service/repository.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.d.ts.map +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.js +3 -0
- package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.mjs +3 -0
- package/dist/services/document-service/transform/relations/extract/data-ids.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.d.ts.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.js +3 -0
- package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs +3 -0
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/utils/map-relation.d.ts.map +1 -1
- package/dist/services/document-service/transform/relations/utils/map-relation.js +7 -3
- package/dist/services/document-service/transform/relations/utils/map-relation.js.map +1 -1
- package/dist/services/document-service/transform/relations/utils/map-relation.mjs +7 -3
- package/dist/services/document-service/transform/relations/utils/map-relation.mjs.map +1 -1
- package/dist/services/document-service/utils/populate.d.ts.map +1 -1
- package/dist/services/document-service/utils/populate.js +4 -0
- package/dist/services/document-service/utils/populate.js.map +1 -1
- package/dist/services/document-service/utils/populate.mjs +4 -0
- package/dist/services/document-service/utils/populate.mjs.map +1 -1
- package/dist/services/entity-validator/index.d.ts +14 -1
- package/dist/services/entity-validator/index.d.ts.map +1 -1
- package/dist/services/entity-validator/index.js +87 -30
- package/dist/services/entity-validator/index.js.map +1 -1
- package/dist/services/entity-validator/index.mjs +87 -30
- package/dist/services/entity-validator/index.mjs.map +1 -1
- package/dist/services/entity-validator/validators.d.ts +10 -8
- package/dist/services/entity-validator/validators.d.ts.map +1 -1
- package/dist/services/entity-validator/validators.js +60 -19
- package/dist/services/entity-validator/validators.js.map +1 -1
- package/dist/services/entity-validator/validators.mjs +53 -11
- package/dist/services/entity-validator/validators.mjs.map +1 -1
- package/dist/services/event-hub.d.ts +1 -0
- package/dist/services/event-hub.d.ts.map +1 -1
- package/dist/services/event-hub.js +9 -4
- package/dist/services/event-hub.js.map +1 -1
- package/dist/services/event-hub.mjs +9 -4
- package/dist/services/event-hub.mjs.map +1 -1
- package/dist/services/server/index.js +1 -1
- package/dist/services/server/index.js.map +1 -1
- package/dist/services/server/index.mjs +1 -1
- package/dist/services/server/index.mjs.map +1 -1
- package/dist/services/server/koa.d.ts.map +1 -1
- package/dist/services/server/koa.js +1 -1
- package/dist/services/server/koa.js.map +1 -1
- package/dist/services/server/koa.mjs +1 -1
- package/dist/services/server/koa.mjs.map +1 -1
- package/dist/services/webhook-runner.d.ts +2 -1
- package/dist/services/webhook-runner.d.ts.map +1 -1
- package/dist/services/webhook-runner.js.map +1 -1
- package/dist/services/webhook-runner.mjs.map +1 -1
- package/dist/services/webhook-store.d.ts +2 -8
- package/dist/services/webhook-store.d.ts.map +1 -1
- package/dist/services/webhook-store.js +9 -2
- package/dist/services/webhook-store.js.map +1 -1
- package/dist/services/webhook-store.mjs +9 -2
- package/dist/services/webhook-store.mjs.map +1 -1
- package/dist/utils/fetch.d.ts.map +1 -1
- package/dist/utils/fetch.js +4 -3
- package/dist/utils/fetch.js.map +1 -1
- package/dist/utils/fetch.mjs +4 -3
- package/dist/utils/fetch.mjs.map +1 -1
- package/dist/utils/transform-content-types-to-models.d.ts.map +1 -1
- package/dist/utils/transform-content-types-to-models.js +13 -1
- package/dist/utils/transform-content-types-to-models.js.map +1 -1
- package/dist/utils/transform-content-types-to-models.mjs +13 -1
- package/dist/utils/transform-content-types-to-models.mjs.map +1 -1
- package/package.json +22 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-type.js","sources":["../../../src/core-api/controller/single-type.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Struct, Core, Utils, UID } from '@strapi/types';\n\ninterface Options {\n contentType: Struct.SingleTypeSchema;\n}\n\n/**\n * Returns a single type controller to handle default core-api actions\n */\nconst createSingleTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<Core.CoreAPI.Controller.SingleType> => {\n const uid = contentType.uid as UID.Service;\n\n // TODO: transform into a class\n return {\n /**\n * Retrieve single type content\n *\n */\n async find(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).find(sanitizedQuery);\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * create or update single type content.\n */\n async update(ctx) {\n const { query, 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).createOrUpdate({\n ...query,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n async delete(ctx) {\n const { query } = ctx;\n\n await strapi.service(uid).delete(query);\n\n ctx.status = 204;\n },\n };\n};\n\nexport { createSingleTypeController };\n"],"names":["isObject","errors"],"mappings":";;;;AAWA,MAAM,6BAA6B,CAAC;AAAA,EAClC;AACF,MAA0E;AACxE,QAAM,MAAM,YAAY;AAGjB,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL,MAAM,KAAK,KAAK;AACR,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAEnD,YAAM,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,KAAK,cAAc;AAE5D,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,OAAO,KAAK;AAChB,YAAM,EAAE,OAAO,OAAO,CAAC,EAAA,IAAa,IAAI;AAExC,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,eAAe;AAAA,QACtD,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACP;AAED,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA,IAEA,MAAM,OAAO,KAAK;AACV,YAAA,EAAE,MAAU,IAAA;AAElB,YAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,KAAK;AAEtC,UAAI,SAAS;AAAA,IACf;AAAA,EAAA;AAEJ;;"}
|
|
1
|
+
{"version":3,"file":"single-type.js","sources":["../../../src/core-api/controller/single-type.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Struct, Core, Utils, UID } from '@strapi/types';\n\ninterface Options {\n contentType: Struct.SingleTypeSchema;\n}\n\n/**\n * Returns a single type controller to handle default core-api actions\n */\nconst createSingleTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<Core.CoreAPI.Controller.SingleType> => {\n const uid = contentType.uid as UID.Service;\n\n // TODO: transform into a class\n return {\n /**\n * Retrieve single type content\n *\n */\n async find(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).find(sanitizedQuery);\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * create or update single type content.\n */\n async update(ctx) {\n const { query, 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 await this.validateInput(body.data, ctx);\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).createOrUpdate({\n ...query,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n async delete(ctx) {\n const { query } = ctx;\n\n await strapi.service(uid).delete(query);\n\n ctx.status = 204;\n },\n };\n};\n\nexport { createSingleTypeController };\n"],"names":["isObject","errors"],"mappings":";;;;AAWA,MAAM,6BAA6B,CAAC;AAAA,EAClC;AACF,MAA0E;AACxE,QAAM,MAAM,YAAY;AAGjB,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL,MAAM,KAAK,KAAK;AACR,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAEnD,YAAM,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,KAAK,cAAc;AAE5D,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,OAAO,KAAK;AAChB,YAAM,EAAE,OAAO,OAAO,CAAC,EAAA,IAAa,IAAI;AAExC,UAAI,CAACA,EAAA,SAAS,KAAK,IAAI,GAAG;AAClB,cAAA,IAAIC,YAAO,OAAA,gBAAgB,4CAA4C;AAAA,MAC/E;AAEA,YAAM,KAAK,cAAc,KAAK,MAAM,GAAG;AAEvC,YAAM,qBAAqB,MAAM,KAAK,cAAc,KAAK,MAAM,GAAG;AAElE,YAAM,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,eAAe;AAAA,QACtD,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACP;AAED,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA,IAEA,MAAM,OAAO,KAAK;AACV,YAAA,EAAE,MAAU,IAAA;AAElB,YAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,KAAK;AAEtC,UAAI,SAAS;AAAA,IACf;AAAA,EAAA;AAEJ;;"}
|
|
@@ -24,6 +24,7 @@ const createSingleTypeController = ({
|
|
|
24
24
|
if (!isObject(body.data)) {
|
|
25
25
|
throw new errors.ValidationError('Missing "data" payload in the request body');
|
|
26
26
|
}
|
|
27
|
+
await this.validateInput(body.data, ctx);
|
|
27
28
|
const sanitizedInputData = await this.sanitizeInput(body.data, ctx);
|
|
28
29
|
const entity = await strapi.service(uid).createOrUpdate({
|
|
29
30
|
...query,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-type.mjs","sources":["../../../src/core-api/controller/single-type.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Struct, Core, Utils, UID } from '@strapi/types';\n\ninterface Options {\n contentType: Struct.SingleTypeSchema;\n}\n\n/**\n * Returns a single type controller to handle default core-api actions\n */\nconst createSingleTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<Core.CoreAPI.Controller.SingleType> => {\n const uid = contentType.uid as UID.Service;\n\n // TODO: transform into a class\n return {\n /**\n * Retrieve single type content\n *\n */\n async find(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).find(sanitizedQuery);\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * create or update single type content.\n */\n async update(ctx) {\n const { query, 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).createOrUpdate({\n ...query,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n async delete(ctx) {\n const { query } = ctx;\n\n await strapi.service(uid).delete(query);\n\n ctx.status = 204;\n },\n };\n};\n\nexport { createSingleTypeController };\n"],"names":[],"mappings":";;AAWA,MAAM,6BAA6B,CAAC;AAAA,EAClC;AACF,MAA0E;AACxE,QAAM,MAAM,YAAY;AAGjB,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL,MAAM,KAAK,KAAK;AACR,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAEnD,YAAM,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,KAAK,cAAc;AAE5D,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,OAAO,KAAK;AAChB,YAAM,EAAE,OAAO,OAAO,CAAC,EAAA,IAAa,IAAI;AAExC,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,eAAe;AAAA,QACtD,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACP;AAED,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA,IAEA,MAAM,OAAO,KAAK;AACV,YAAA,EAAE,MAAU,IAAA;AAElB,YAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,KAAK;AAEtC,UAAI,SAAS;AAAA,IACf;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"single-type.mjs","sources":["../../../src/core-api/controller/single-type.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { Struct, Core, Utils, UID } from '@strapi/types';\n\ninterface Options {\n contentType: Struct.SingleTypeSchema;\n}\n\n/**\n * Returns a single type controller to handle default core-api actions\n */\nconst createSingleTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<Core.CoreAPI.Controller.SingleType> => {\n const uid = contentType.uid as UID.Service;\n\n // TODO: transform into a class\n return {\n /**\n * Retrieve single type content\n *\n */\n async find(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).find(sanitizedQuery);\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * create or update single type content.\n */\n async update(ctx) {\n const { query, 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 await this.validateInput(body.data, ctx);\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).createOrUpdate({\n ...query,\n data: sanitizedInputData,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n async delete(ctx) {\n const { query } = ctx;\n\n await strapi.service(uid).delete(query);\n\n ctx.status = 204;\n },\n };\n};\n\nexport { createSingleTypeController };\n"],"names":[],"mappings":";;AAWA,MAAM,6BAA6B,CAAC;AAAA,EAClC;AACF,MAA0E;AACxE,QAAM,MAAM,YAAY;AAGjB,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL,MAAM,KAAK,KAAK;AACR,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAEnD,YAAM,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,KAAK,cAAc;AAE5D,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,OAAO,KAAK;AAChB,YAAM,EAAE,OAAO,OAAO,CAAC,EAAA,IAAa,IAAI;AAExC,UAAI,CAAC,SAAS,KAAK,IAAI,GAAG;AAClB,cAAA,IAAI,OAAO,gBAAgB,4CAA4C;AAAA,MAC/E;AAEA,YAAM,KAAK,cAAc,KAAK,MAAM,GAAG;AAEvC,YAAM,qBAAqB,MAAM,KAAK,cAAc,KAAK,MAAM,GAAG;AAElE,YAAM,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,eAAe;AAAA,QACtD,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACP;AAED,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA,IAEA,MAAM,OAAO,KAAK;AACV,YAAA,EAAE,MAAU,IAAA;AAElB,YAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,KAAK;AAEtC,UAAI,SAAS;AAAA,IACf;AAAA,EAAA;AAEJ;"}
|
|
@@ -5,13 +5,7 @@ export declare class CollectionTypeService extends CoreService implements Core.C
|
|
|
5
5
|
constructor(contentType: Struct.CollectionTypeSchema);
|
|
6
6
|
find(params?: {}): Promise<{
|
|
7
7
|
results: Modules.Documents.AnyDocument[];
|
|
8
|
-
pagination:
|
|
9
|
-
page: number;
|
|
10
|
-
pageSize: number;
|
|
11
|
-
} | {
|
|
12
|
-
start: number;
|
|
13
|
-
limit: number;
|
|
14
|
-
};
|
|
8
|
+
pagination: import("@strapi/utils/dist/pagination").PagePatinationInformation | import("@strapi/utils/dist/pagination").OffsetPaginationInformation;
|
|
15
9
|
}>;
|
|
16
10
|
findOne(documentId: Modules.Documents.ID, params?: {}): import("@strapi/types/dist/modules/documents/result/document-engine").FindOne<import("@strapi/types/dist/uid").ContentType, import("@strapi/types/dist/modules/documents/params/document-engine").FindOne<import("@strapi/types/dist/uid").ContentType>>;
|
|
17
11
|
create(params?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-type.d.ts","sourceRoot":"","sources":["../../../src/core-api/service/collection-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"collection-type.d.ts","sourceRoot":"","sources":["../../../src/core-api/service/collection-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAS3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAAa,qBACX,SAAQ,WACR,YAAW,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc;IAE9C,OAAO,CAAC,WAAW,CAA8B;gBAErC,WAAW,EAAE,MAAM,CAAC,oBAAoB;IAM9C,IAAI,CAAC,MAAM,KAAK;;;;IAgCtB,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,KAAK;IAS/C,MAAM,CAAC,MAAM;;KAAe;IAMlC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM;;KAAe;IASxD,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,KAAK;;;CAU3D;AAED;;;GAGG;AAEH,QAAA,MAAM,2BAA2B,gBAClB,OAAO,oBAAoB,KACvC,KAAK,OAAO,CAAC,OAAO,CAAC,cAEvB,CAAC;AAEF,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
|
|
@@ -12,6 +12,7 @@ class CollectionTypeService extends coreService.CoreService {
|
|
|
12
12
|
const { uid } = this.contentType;
|
|
13
13
|
const fetchParams = this.getFetchParams(params);
|
|
14
14
|
const paginationInfo = pagination.getPaginationInfo(fetchParams);
|
|
15
|
+
const isPaged = pagination.isPagedPagination(fetchParams.pagination);
|
|
15
16
|
const results = await strapi.documents(uid).findMany({
|
|
16
17
|
...fetchParams,
|
|
17
18
|
...paginationInfo
|
|
@@ -23,12 +24,12 @@ class CollectionTypeService extends coreService.CoreService {
|
|
|
23
24
|
}
|
|
24
25
|
return {
|
|
25
26
|
results,
|
|
26
|
-
pagination: pagination.transformPaginationResponse(paginationInfo, count)
|
|
27
|
+
pagination: pagination.transformPaginationResponse(paginationInfo, count, isPaged)
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
return {
|
|
30
31
|
results,
|
|
31
|
-
pagination: paginationInfo
|
|
32
|
+
pagination: pagination.transformPaginationResponse(paginationInfo, void 0, isPaged)
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
findOne(documentId, params = {}) {
|
|
@@ -51,10 +52,11 @@ class CollectionTypeService extends coreService.CoreService {
|
|
|
51
52
|
}
|
|
52
53
|
async delete(documentId, params = {}) {
|
|
53
54
|
const { uid } = this.contentType;
|
|
54
|
-
|
|
55
|
+
const { entries } = await strapi.documents(uid).delete({
|
|
55
56
|
...this.getFetchParams(params),
|
|
56
57
|
documentId
|
|
57
58
|
});
|
|
59
|
+
return { deletedEntries: entries.length };
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
const createCollectionTypeService = (contentType) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-type.js","sources":["../../../src/core-api/service/collection-type.ts"],"sourcesContent":["import type { Core, Struct, Modules } from '@strapi/types';\n\nimport {
|
|
1
|
+
{"version":3,"file":"collection-type.js","sources":["../../../src/core-api/service/collection-type.ts"],"sourcesContent":["import type { Core, Struct, Modules } from '@strapi/types';\n\nimport {\n getPaginationInfo,\n shouldCount,\n isPagedPagination,\n transformPaginationResponse,\n} from './pagination';\n\nimport { CoreService } from './core-service';\n\nexport class CollectionTypeService\n extends CoreService\n implements Core.CoreAPI.Service.CollectionType\n{\n private contentType: Struct.CollectionTypeSchema;\n\n constructor(contentType: Struct.CollectionTypeSchema) {\n super();\n\n this.contentType = contentType;\n }\n\n async find(params = {}) {\n const { uid } = this.contentType;\n\n const fetchParams = this.getFetchParams(params);\n\n const paginationInfo = getPaginationInfo(fetchParams);\n const isPaged = isPagedPagination(fetchParams.pagination);\n\n const results = await strapi.documents(uid).findMany({\n ...fetchParams,\n ...paginationInfo,\n });\n\n if (shouldCount(fetchParams)) {\n const count = await strapi.documents(uid).count({ ...fetchParams, ...paginationInfo });\n\n if (typeof count !== 'number') {\n throw new Error('Count should be a number');\n }\n\n return {\n results,\n pagination: transformPaginationResponse(paginationInfo, count, isPaged),\n };\n }\n\n return {\n results,\n pagination: transformPaginationResponse(paginationInfo, undefined, isPaged),\n };\n }\n\n findOne(documentId: Modules.Documents.ID, params = {}) {\n const { uid } = this.contentType;\n\n return strapi.documents(uid).findOne({\n ...this.getFetchParams(params),\n documentId,\n });\n }\n\n async create(params = { data: {} }) {\n const { uid } = this.contentType;\n\n return strapi.documents(uid).create(this.getFetchParams(params));\n }\n\n update(documentId: Modules.Documents.ID, params = { data: {} }) {\n const { uid } = this.contentType;\n\n return strapi.documents(uid).update({\n ...this.getFetchParams(params),\n documentId,\n });\n }\n\n async delete(documentId: Modules.Documents.ID, params = {}) {\n const { uid } = this.contentType;\n\n const { entries } = await strapi.documents(uid).delete({\n ...this.getFetchParams(params),\n documentId,\n });\n\n return { deletedEntries: entries.length };\n }\n}\n\n/**\n *\n * Returns a collection type service to handle default core-api actions\n */\n\nconst createCollectionTypeService = (\n contentType: Struct.CollectionTypeSchema\n): Core.CoreAPI.Service.CollectionType => {\n return new CollectionTypeService(contentType);\n};\n\nexport { createCollectionTypeService };\n"],"names":["CoreService","getPaginationInfo","isPagedPagination","shouldCount","transformPaginationResponse"],"mappings":";;;;AAWO,MAAM,8BACHA,YAAAA,YAEV;AAAA,EACU;AAAA,EAER,YAAY,aAA0C;AAC9C;AAEN,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,MAAM,KAAK,SAAS,IAAI;AAChB,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,cAAc,KAAK,eAAe,MAAM;AAExC,UAAA,iBAAiBC,6BAAkB,WAAW;AAC9C,UAAA,UAAUC,WAAAA,kBAAkB,YAAY,UAAU;AAExD,UAAM,UAAU,MAAM,OAAO,UAAU,GAAG,EAAE,SAAS;AAAA,MACnD,GAAG;AAAA,MACH,GAAG;AAAA,IAAA,CACJ;AAEG,QAAAC,WAAAA,YAAY,WAAW,GAAG;AAC5B,YAAM,QAAQ,MAAM,OAAO,UAAU,GAAG,EAAE,MAAM,EAAE,GAAG,aAAa,GAAG,eAAgB,CAAA;AAEjF,UAAA,OAAO,UAAU,UAAU;AACvB,cAAA,IAAI,MAAM,0BAA0B;AAAA,MAC5C;AAEO,aAAA;AAAA,QACL;AAAA,QACA,YAAYC,WAAA,4BAA4B,gBAAgB,OAAO,OAAO;AAAA,MAAA;AAAA,IAE1E;AAEO,WAAA;AAAA,MACL;AAAA,MACA,YAAYA,WAAAA,4BAA4B,gBAAgB,QAAW,OAAO;AAAA,IAAA;AAAA,EAE9E;AAAA,EAEA,QAAQ,YAAkC,SAAS,IAAI;AAC/C,UAAA,EAAE,IAAI,IAAI,KAAK;AAErB,WAAO,OAAO,UAAU,GAAG,EAAE,QAAQ;AAAA,MACnC,GAAG,KAAK,eAAe,MAAM;AAAA,MAC7B;AAAA,IAAA,CACD;AAAA,EACH;AAAA,EAEA,MAAM,OAAO,SAAS,EAAE,MAAM,MAAM;AAC5B,UAAA,EAAE,IAAI,IAAI,KAAK;AAEd,WAAA,OAAO,UAAU,GAAG,EAAE,OAAO,KAAK,eAAe,MAAM,CAAC;AAAA,EACjE;AAAA,EAEA,OAAO,YAAkC,SAAS,EAAE,MAAM,MAAM;AACxD,UAAA,EAAE,IAAI,IAAI,KAAK;AAErB,WAAO,OAAO,UAAU,GAAG,EAAE,OAAO;AAAA,MAClC,GAAG,KAAK,eAAe,MAAM;AAAA,MAC7B;AAAA,IAAA,CACD;AAAA,EACH;AAAA,EAEA,MAAM,OAAO,YAAkC,SAAS,IAAI;AACpD,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,EAAE,YAAY,MAAM,OAAO,UAAU,GAAG,EAAE,OAAO;AAAA,MACrD,GAAG,KAAK,eAAe,MAAM;AAAA,MAC7B;AAAA,IAAA,CACD;AAEM,WAAA,EAAE,gBAAgB,QAAQ;EACnC;AACF;AAOM,MAAA,8BAA8B,CAClC,gBACwC;AACjC,SAAA,IAAI,sBAAsB,WAAW;AAC9C;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getPaginationInfo, shouldCount, transformPaginationResponse } from "./pagination.mjs";
|
|
1
|
+
import { getPaginationInfo, isPagedPagination, shouldCount, transformPaginationResponse } from "./pagination.mjs";
|
|
2
2
|
import { CoreService } from "./core-service.mjs";
|
|
3
3
|
class CollectionTypeService extends CoreService {
|
|
4
4
|
contentType;
|
|
@@ -10,6 +10,7 @@ class CollectionTypeService extends CoreService {
|
|
|
10
10
|
const { uid } = this.contentType;
|
|
11
11
|
const fetchParams = this.getFetchParams(params);
|
|
12
12
|
const paginationInfo = getPaginationInfo(fetchParams);
|
|
13
|
+
const isPaged = isPagedPagination(fetchParams.pagination);
|
|
13
14
|
const results = await strapi.documents(uid).findMany({
|
|
14
15
|
...fetchParams,
|
|
15
16
|
...paginationInfo
|
|
@@ -21,12 +22,12 @@ class CollectionTypeService extends CoreService {
|
|
|
21
22
|
}
|
|
22
23
|
return {
|
|
23
24
|
results,
|
|
24
|
-
pagination: transformPaginationResponse(paginationInfo, count)
|
|
25
|
+
pagination: transformPaginationResponse(paginationInfo, count, isPaged)
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
return {
|
|
28
29
|
results,
|
|
29
|
-
pagination: paginationInfo
|
|
30
|
+
pagination: transformPaginationResponse(paginationInfo, void 0, isPaged)
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
33
|
findOne(documentId, params = {}) {
|
|
@@ -49,10 +50,11 @@ class CollectionTypeService extends CoreService {
|
|
|
49
50
|
}
|
|
50
51
|
async delete(documentId, params = {}) {
|
|
51
52
|
const { uid } = this.contentType;
|
|
52
|
-
|
|
53
|
+
const { entries } = await strapi.documents(uid).delete({
|
|
53
54
|
...this.getFetchParams(params),
|
|
54
55
|
documentId
|
|
55
56
|
});
|
|
57
|
+
return { deletedEntries: entries.length };
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
const createCollectionTypeService = (contentType) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-type.mjs","sources":["../../../src/core-api/service/collection-type.ts"],"sourcesContent":["import type { Core, Struct, Modules } from '@strapi/types';\n\nimport {
|
|
1
|
+
{"version":3,"file":"collection-type.mjs","sources":["../../../src/core-api/service/collection-type.ts"],"sourcesContent":["import type { Core, Struct, Modules } from '@strapi/types';\n\nimport {\n getPaginationInfo,\n shouldCount,\n isPagedPagination,\n transformPaginationResponse,\n} from './pagination';\n\nimport { CoreService } from './core-service';\n\nexport class CollectionTypeService\n extends CoreService\n implements Core.CoreAPI.Service.CollectionType\n{\n private contentType: Struct.CollectionTypeSchema;\n\n constructor(contentType: Struct.CollectionTypeSchema) {\n super();\n\n this.contentType = contentType;\n }\n\n async find(params = {}) {\n const { uid } = this.contentType;\n\n const fetchParams = this.getFetchParams(params);\n\n const paginationInfo = getPaginationInfo(fetchParams);\n const isPaged = isPagedPagination(fetchParams.pagination);\n\n const results = await strapi.documents(uid).findMany({\n ...fetchParams,\n ...paginationInfo,\n });\n\n if (shouldCount(fetchParams)) {\n const count = await strapi.documents(uid).count({ ...fetchParams, ...paginationInfo });\n\n if (typeof count !== 'number') {\n throw new Error('Count should be a number');\n }\n\n return {\n results,\n pagination: transformPaginationResponse(paginationInfo, count, isPaged),\n };\n }\n\n return {\n results,\n pagination: transformPaginationResponse(paginationInfo, undefined, isPaged),\n };\n }\n\n findOne(documentId: Modules.Documents.ID, params = {}) {\n const { uid } = this.contentType;\n\n return strapi.documents(uid).findOne({\n ...this.getFetchParams(params),\n documentId,\n });\n }\n\n async create(params = { data: {} }) {\n const { uid } = this.contentType;\n\n return strapi.documents(uid).create(this.getFetchParams(params));\n }\n\n update(documentId: Modules.Documents.ID, params = { data: {} }) {\n const { uid } = this.contentType;\n\n return strapi.documents(uid).update({\n ...this.getFetchParams(params),\n documentId,\n });\n }\n\n async delete(documentId: Modules.Documents.ID, params = {}) {\n const { uid } = this.contentType;\n\n const { entries } = await strapi.documents(uid).delete({\n ...this.getFetchParams(params),\n documentId,\n });\n\n return { deletedEntries: entries.length };\n }\n}\n\n/**\n *\n * Returns a collection type service to handle default core-api actions\n */\n\nconst createCollectionTypeService = (\n contentType: Struct.CollectionTypeSchema\n): Core.CoreAPI.Service.CollectionType => {\n return new CollectionTypeService(contentType);\n};\n\nexport { createCollectionTypeService };\n"],"names":[],"mappings":";;AAWO,MAAM,8BACH,YAEV;AAAA,EACU;AAAA,EAER,YAAY,aAA0C;AAC9C;AAEN,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,MAAM,KAAK,SAAS,IAAI;AAChB,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,cAAc,KAAK,eAAe,MAAM;AAExC,UAAA,iBAAiB,kBAAkB,WAAW;AAC9C,UAAA,UAAU,kBAAkB,YAAY,UAAU;AAExD,UAAM,UAAU,MAAM,OAAO,UAAU,GAAG,EAAE,SAAS;AAAA,MACnD,GAAG;AAAA,MACH,GAAG;AAAA,IAAA,CACJ;AAEG,QAAA,YAAY,WAAW,GAAG;AAC5B,YAAM,QAAQ,MAAM,OAAO,UAAU,GAAG,EAAE,MAAM,EAAE,GAAG,aAAa,GAAG,eAAgB,CAAA;AAEjF,UAAA,OAAO,UAAU,UAAU;AACvB,cAAA,IAAI,MAAM,0BAA0B;AAAA,MAC5C;AAEO,aAAA;AAAA,QACL;AAAA,QACA,YAAY,4BAA4B,gBAAgB,OAAO,OAAO;AAAA,MAAA;AAAA,IAE1E;AAEO,WAAA;AAAA,MACL;AAAA,MACA,YAAY,4BAA4B,gBAAgB,QAAW,OAAO;AAAA,IAAA;AAAA,EAE9E;AAAA,EAEA,QAAQ,YAAkC,SAAS,IAAI;AAC/C,UAAA,EAAE,IAAI,IAAI,KAAK;AAErB,WAAO,OAAO,UAAU,GAAG,EAAE,QAAQ;AAAA,MACnC,GAAG,KAAK,eAAe,MAAM;AAAA,MAC7B;AAAA,IAAA,CACD;AAAA,EACH;AAAA,EAEA,MAAM,OAAO,SAAS,EAAE,MAAM,MAAM;AAC5B,UAAA,EAAE,IAAI,IAAI,KAAK;AAEd,WAAA,OAAO,UAAU,GAAG,EAAE,OAAO,KAAK,eAAe,MAAM,CAAC;AAAA,EACjE;AAAA,EAEA,OAAO,YAAkC,SAAS,EAAE,MAAM,MAAM;AACxD,UAAA,EAAE,IAAI,IAAI,KAAK;AAErB,WAAO,OAAO,UAAU,GAAG,EAAE,OAAO;AAAA,MAClC,GAAG,KAAK,eAAe,MAAM;AAAA,MAC7B;AAAA,IAAA,CACD;AAAA,EACH;AAAA,EAEA,MAAM,OAAO,YAAkC,SAAS,IAAI;AACpD,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,EAAE,YAAY,MAAM,OAAO,UAAU,GAAG,EAAE,OAAO;AAAA,MACrD,GAAG,KAAK,eAAe,MAAM;AAAA,MAC7B;AAAA,IAAA,CACD;AAEM,WAAA,EAAE,gBAAgB,QAAQ;EACnC;AACF;AAOM,MAAA,8BAA8B,CAClC,gBACwC;AACjC,SAAA,IAAI,sBAAsB,WAAW;AAC9C;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { pagination } from '@strapi/utils';
|
|
1
2
|
interface BasePaginationParams {
|
|
2
3
|
withCount?: boolean | 't' | '1' | 'true' | 'f' | '0' | 'false' | 0 | 1;
|
|
3
4
|
}
|
|
@@ -17,21 +18,13 @@ type PaginationInfo = {
|
|
|
17
18
|
start: number;
|
|
18
19
|
limit: number;
|
|
19
20
|
};
|
|
21
|
+
declare const isPagedPagination: (pagination?: PaginationParams) => pagination is PagedPagination;
|
|
20
22
|
declare const shouldCount: (params: {
|
|
21
23
|
pagination?: PaginationParams;
|
|
22
24
|
}) => boolean;
|
|
23
25
|
declare const getPaginationInfo: (params: {
|
|
24
26
|
pagination?: PaginationParams;
|
|
25
27
|
}) => PaginationInfo;
|
|
26
|
-
declare const transformPaginationResponse: (paginationInfo: PaginationInfo,
|
|
27
|
-
|
|
28
|
-
total: number;
|
|
29
|
-
page: number;
|
|
30
|
-
pageSize: number;
|
|
31
|
-
} | {
|
|
32
|
-
total: number;
|
|
33
|
-
start: number;
|
|
34
|
-
limit: number;
|
|
35
|
-
};
|
|
36
|
-
export { getPaginationInfo, transformPaginationResponse, shouldCount };
|
|
28
|
+
declare const transformPaginationResponse: (paginationInfo: PaginationInfo, total: number | undefined, isPaged: boolean) => pagination.PagePatinationInformation | pagination.OffsetPaginationInformation;
|
|
29
|
+
export { isPagedPagination, shouldCount, getPaginationInfo, transformPaginationResponse };
|
|
37
30
|
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/core-api/service/pagination.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/core-api/service/pagination.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,UAAU,EAAE,MAAM,eAAe,CAAC;AAEnD,UAAU,oBAAoB;IAC5B,SAAS,CAAC,EAAE,OAAO,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,GAAG,GAAG,GAAG,GAAG,GAAG,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;CACxE;AAED,KAAK,eAAe,GAAG,oBAAoB,GAAG;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,gBAAgB,GAAG,oBAAoB,GAAG;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAElE,KAAK,cAAc,GACf;IACE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,GACD;IACE,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAaN,QAAA,MAAM,iBAAiB,gBAAiB,gBAAgB,kCACmC,CAAC;AAE5F,QAAA,MAAM,WAAW,WAAY;IAAE,UAAU,CAAC,EAAE,gBAAgB,CAAA;CAAE,YA0B7D,CAAC;AAEF,QAAA,MAAM,iBAAiB,WAAY;IAAE,UAAU,CAAC,EAAE,gBAAgB,CAAA;CAAE,KAAG,cAStE,CAAC;AAEF,QAAA,MAAM,2BAA2B,mBACf,cAAc,SACvB,MAAM,GAAG,SAAS,WAChB,OAAO,kFAcjB,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,CAAC"}
|
|
@@ -6,7 +6,8 @@ const getLimitConfigDefaults = () => ({
|
|
|
6
6
|
defaultLimit: _.toNumber(strapi.config.get("api.rest.defaultLimit", 25)),
|
|
7
7
|
maxLimit: _.toNumber(strapi.config.get("api.rest.maxLimit")) || null
|
|
8
8
|
});
|
|
9
|
-
const
|
|
9
|
+
const isOffsetPagination = (pagination2) => _.has("start", pagination2) || _.has("limit", pagination2);
|
|
10
|
+
const isPagedPagination = (pagination2) => _.has("page", pagination2) || _.has("pageSize", pagination2) || !isOffsetPagination(pagination2);
|
|
10
11
|
const shouldCount = (params) => {
|
|
11
12
|
if (_.has("pagination.withCount", params)) {
|
|
12
13
|
const withCount = params.pagination?.withCount;
|
|
@@ -28,51 +29,24 @@ const shouldCount = (params) => {
|
|
|
28
29
|
}
|
|
29
30
|
return Boolean(strapi.config.get("api.rest.withCount", true));
|
|
30
31
|
};
|
|
31
|
-
const isOffsetPagination = (pagination) => _.has("start", pagination) || _.has("limit", pagination);
|
|
32
|
-
const isPagedPagination = (pagination) => _.has("page", pagination) || _.has("pageSize", pagination);
|
|
33
32
|
const getPaginationInfo = (params) => {
|
|
34
33
|
const { defaultLimit, maxLimit } = getLimitConfigDefaults();
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"Invalid pagination parameters. Expected either start/limit or page/pageSize"
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
if (!isOffset && !isPaged) {
|
|
44
|
-
return {
|
|
45
|
-
page: 1,
|
|
46
|
-
pageSize: defaultLimit
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if (isPagedPagination(pagination)) {
|
|
50
|
-
const pageSize = _.isUndefined(pagination.pageSize) ? defaultLimit : Math.max(1, _.toNumber(pagination.pageSize));
|
|
51
|
-
return {
|
|
52
|
-
page: Math.max(1, _.toNumber(pagination.page || 1)),
|
|
53
|
-
pageSize: typeof maxLimit === "number" && shouldApplyMaxLimit(pageSize, maxLimit, { isPagedPagination: true }) ? maxLimit : Math.max(1, pageSize)
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
const limit = _.isUndefined(pagination.limit) ? defaultLimit : _.toNumber(pagination.limit);
|
|
57
|
-
return {
|
|
58
|
-
start: Math.max(0, _.toNumber(pagination.start || 0)),
|
|
59
|
-
limit: shouldApplyMaxLimit(limit, maxLimit) ? maxLimit || -1 : Math.max(1, limit)
|
|
60
|
-
};
|
|
34
|
+
const { start, limit } = strapiUtils.pagination.withDefaultPagination(params.pagination || {}, {
|
|
35
|
+
defaults: { offset: { limit: defaultLimit }, page: { pageSize: defaultLimit } },
|
|
36
|
+
maxLimit: maxLimit || -1
|
|
37
|
+
});
|
|
38
|
+
return { start, limit };
|
|
61
39
|
};
|
|
62
|
-
const transformPaginationResponse = (paginationInfo,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
total: count
|
|
68
|
-
};
|
|
40
|
+
const transformPaginationResponse = (paginationInfo, total, isPaged) => {
|
|
41
|
+
const transform = isPaged ? strapiUtils.pagination.transformPagedPaginationInfo : strapiUtils.pagination.transformOffsetPaginationInfo;
|
|
42
|
+
const paginationResponse = transform(paginationInfo, total);
|
|
43
|
+
if (_.isNil(total)) {
|
|
44
|
+
return _.omit(["total", "pageCount"], paginationResponse);
|
|
69
45
|
}
|
|
70
|
-
return
|
|
71
|
-
...paginationInfo,
|
|
72
|
-
total: count
|
|
73
|
-
};
|
|
46
|
+
return paginationResponse;
|
|
74
47
|
};
|
|
75
48
|
exports.getPaginationInfo = getPaginationInfo;
|
|
49
|
+
exports.isPagedPagination = isPagedPagination;
|
|
76
50
|
exports.shouldCount = shouldCount;
|
|
77
51
|
exports.transformPaginationResponse = transformPaginationResponse;
|
|
78
52
|
//# sourceMappingURL=pagination.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.js","sources":["../../../src/core-api/service/pagination.ts"],"sourcesContent":["import { has, toNumber,
|
|
1
|
+
{"version":3,"file":"pagination.js","sources":["../../../src/core-api/service/pagination.ts"],"sourcesContent":["import { omit, has, toNumber, isNil } from 'lodash/fp';\n\nimport { errors, pagination } from '@strapi/utils';\n\ninterface BasePaginationParams {\n withCount?: boolean | 't' | '1' | 'true' | 'f' | '0' | 'false' | 0 | 1;\n}\n\ntype PagedPagination = BasePaginationParams & {\n page?: number;\n pageSize?: number;\n};\n\ntype OffsetPagination = BasePaginationParams & {\n start?: number;\n limit?: number;\n};\n\nexport type PaginationParams = PagedPagination | OffsetPagination;\n\ntype PaginationInfo =\n | {\n page: number;\n pageSize: number;\n }\n | {\n start: number;\n limit: number;\n };\n\n/**\n * Default limit values from config\n */\nconst getLimitConfigDefaults = () => ({\n defaultLimit: toNumber(strapi.config.get('api.rest.defaultLimit', 25)),\n maxLimit: toNumber(strapi.config.get('api.rest.maxLimit')) || null,\n});\n\nconst isOffsetPagination = (pagination?: PaginationParams): pagination is OffsetPagination =>\n has('start', pagination) || has('limit', pagination);\n\nconst isPagedPagination = (pagination?: PaginationParams): pagination is PagedPagination =>\n has('page', pagination) || has('pageSize', pagination) || !isOffsetPagination(pagination);\n\nconst shouldCount = (params: { pagination?: PaginationParams }) => {\n if (has('pagination.withCount', params)) {\n const withCount = params.pagination?.withCount;\n\n if (typeof withCount === 'boolean') {\n return withCount;\n }\n\n if (typeof withCount === 'undefined') {\n return false;\n }\n\n if (['true', 't', '1', 1].includes(withCount)) {\n return true;\n }\n\n if (['false', 'f', '0', 0].includes(withCount)) {\n return false;\n }\n\n throw new errors.ValidationError(\n 'Invalid withCount parameter. Expected \"t\",\"1\",\"true\",\"false\",\"0\",\"f\"'\n );\n }\n\n return Boolean(strapi.config.get('api.rest.withCount', true));\n};\n\nconst getPaginationInfo = (params: { pagination?: PaginationParams }): PaginationInfo => {\n const { defaultLimit, maxLimit } = getLimitConfigDefaults();\n\n const { start, limit } = pagination.withDefaultPagination(params.pagination || {}, {\n defaults: { offset: { limit: defaultLimit }, page: { pageSize: defaultLimit } },\n maxLimit: maxLimit || -1,\n });\n\n return { start, limit };\n};\n\nconst transformPaginationResponse = (\n paginationInfo: PaginationInfo,\n total: number | undefined,\n isPaged: boolean\n) => {\n const transform = isPaged\n ? pagination.transformPagedPaginationInfo\n : pagination.transformOffsetPaginationInfo;\n\n const paginationResponse = transform(paginationInfo, total!);\n\n if (isNil(total)) {\n // Ignore total and pageCount if `total` value is not available.\n return omit(['total', 'pageCount'], paginationResponse) as ReturnType<typeof transform>;\n }\n\n return paginationResponse;\n};\n\nexport { isPagedPagination, shouldCount, getPaginationInfo, transformPaginationResponse };\n"],"names":["toNumber","pagination","has","errors","isNil","omit"],"mappings":";;;;AAiCA,MAAM,yBAAyB,OAAO;AAAA,EACpC,cAAcA,EAAS,SAAA,OAAO,OAAO,IAAI,yBAAyB,EAAE,CAAC;AAAA,EACrE,UAAUA,EAAS,SAAA,OAAO,OAAO,IAAI,mBAAmB,CAAC,KAAK;AAChE;AAEA,MAAM,qBAAqB,CAACC,gBAC1BC,EAAAA,IAAI,SAASD,WAAU,KAAKC,EAAI,IAAA,SAASD,WAAU;AAErD,MAAM,oBAAoB,CAACA,gBACzBC,EAAA,IAAI,QAAQD,WAAU,KAAKC,EAAA,IAAI,YAAYD,WAAU,KAAK,CAAC,mBAAmBA,WAAU;AAEpF,MAAA,cAAc,CAAC,WAA8C;AAC7D,MAAAC,EAAA,IAAI,wBAAwB,MAAM,GAAG;AACjC,UAAA,YAAY,OAAO,YAAY;AAEjC,QAAA,OAAO,cAAc,WAAW;AAC3B,aAAA;AAAA,IACT;AAEI,QAAA,OAAO,cAAc,aAAa;AAC7B,aAAA;AAAA,IACT;AAEI,QAAA,CAAC,QAAQ,KAAK,KAAK,CAAC,EAAE,SAAS,SAAS,GAAG;AACtC,aAAA;AAAA,IACT;AAEI,QAAA,CAAC,SAAS,KAAK,KAAK,CAAC,EAAE,SAAS,SAAS,GAAG;AACvC,aAAA;AAAA,IACT;AAEA,UAAM,IAAIC,YAAO,OAAA;AAAA,MACf;AAAA,IAAA;AAAA,EAEJ;AAEA,SAAO,QAAQ,OAAO,OAAO,IAAI,sBAAsB,IAAI,CAAC;AAC9D;AAEM,MAAA,oBAAoB,CAAC,WAA8D;AACvF,QAAM,EAAE,cAAc,SAAS,IAAI,uBAAuB;AAEpD,QAAA,EAAE,OAAO,UAAUF,YAAAA,WAAW,sBAAsB,OAAO,cAAc,IAAI;AAAA,IACjF,UAAU,EAAE,QAAQ,EAAE,OAAO,aAAa,GAAG,MAAM,EAAE,UAAU,eAAe;AAAA,IAC9E,UAAU,YAAY;AAAA,EAAA,CACvB;AAEM,SAAA,EAAE,OAAO;AAClB;AAEA,MAAM,8BAA8B,CAClC,gBACA,OACA,YACG;AACH,QAAM,YAAY,UACdA,YAAAA,WAAW,+BACXA,YAAAA,WAAW;AAET,QAAA,qBAAqB,UAAU,gBAAgB,KAAM;AAEvD,MAAAG,EAAAA,MAAM,KAAK,GAAG;AAEhB,WAAOC,EAAK,KAAA,CAAC,SAAS,WAAW,GAAG,kBAAkB;AAAA,EACxD;AAEO,SAAA;AACT;;;;;"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { has,
|
|
2
|
-
import { errors } from "@strapi/utils";
|
|
1
|
+
import { has, isNil, omit, toNumber } from "lodash/fp";
|
|
2
|
+
import { errors, pagination } from "@strapi/utils";
|
|
3
3
|
const getLimitConfigDefaults = () => ({
|
|
4
4
|
defaultLimit: toNumber(strapi.config.get("api.rest.defaultLimit", 25)),
|
|
5
5
|
maxLimit: toNumber(strapi.config.get("api.rest.maxLimit")) || null
|
|
6
6
|
});
|
|
7
|
-
const
|
|
7
|
+
const isOffsetPagination = (pagination2) => has("start", pagination2) || has("limit", pagination2);
|
|
8
|
+
const isPagedPagination = (pagination2) => has("page", pagination2) || has("pageSize", pagination2) || !isOffsetPagination(pagination2);
|
|
8
9
|
const shouldCount = (params) => {
|
|
9
10
|
if (has("pagination.withCount", params)) {
|
|
10
11
|
const withCount = params.pagination?.withCount;
|
|
@@ -26,52 +27,25 @@ const shouldCount = (params) => {
|
|
|
26
27
|
}
|
|
27
28
|
return Boolean(strapi.config.get("api.rest.withCount", true));
|
|
28
29
|
};
|
|
29
|
-
const isOffsetPagination = (pagination) => has("start", pagination) || has("limit", pagination);
|
|
30
|
-
const isPagedPagination = (pagination) => has("page", pagination) || has("pageSize", pagination);
|
|
31
30
|
const getPaginationInfo = (params) => {
|
|
32
31
|
const { defaultLimit, maxLimit } = getLimitConfigDefaults();
|
|
33
|
-
const {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"Invalid pagination parameters. Expected either start/limit or page/pageSize"
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
if (!isOffset && !isPaged) {
|
|
42
|
-
return {
|
|
43
|
-
page: 1,
|
|
44
|
-
pageSize: defaultLimit
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
if (isPagedPagination(pagination)) {
|
|
48
|
-
const pageSize = isUndefined(pagination.pageSize) ? defaultLimit : Math.max(1, toNumber(pagination.pageSize));
|
|
49
|
-
return {
|
|
50
|
-
page: Math.max(1, toNumber(pagination.page || 1)),
|
|
51
|
-
pageSize: typeof maxLimit === "number" && shouldApplyMaxLimit(pageSize, maxLimit, { isPagedPagination: true }) ? maxLimit : Math.max(1, pageSize)
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
const limit = isUndefined(pagination.limit) ? defaultLimit : toNumber(pagination.limit);
|
|
55
|
-
return {
|
|
56
|
-
start: Math.max(0, toNumber(pagination.start || 0)),
|
|
57
|
-
limit: shouldApplyMaxLimit(limit, maxLimit) ? maxLimit || -1 : Math.max(1, limit)
|
|
58
|
-
};
|
|
32
|
+
const { start, limit } = pagination.withDefaultPagination(params.pagination || {}, {
|
|
33
|
+
defaults: { offset: { limit: defaultLimit }, page: { pageSize: defaultLimit } },
|
|
34
|
+
maxLimit: maxLimit || -1
|
|
35
|
+
});
|
|
36
|
+
return { start, limit };
|
|
59
37
|
};
|
|
60
|
-
const transformPaginationResponse = (paginationInfo,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
total: count
|
|
66
|
-
};
|
|
38
|
+
const transformPaginationResponse = (paginationInfo, total, isPaged) => {
|
|
39
|
+
const transform = isPaged ? pagination.transformPagedPaginationInfo : pagination.transformOffsetPaginationInfo;
|
|
40
|
+
const paginationResponse = transform(paginationInfo, total);
|
|
41
|
+
if (isNil(total)) {
|
|
42
|
+
return omit(["total", "pageCount"], paginationResponse);
|
|
67
43
|
}
|
|
68
|
-
return
|
|
69
|
-
...paginationInfo,
|
|
70
|
-
total: count
|
|
71
|
-
};
|
|
44
|
+
return paginationResponse;
|
|
72
45
|
};
|
|
73
46
|
export {
|
|
74
47
|
getPaginationInfo,
|
|
48
|
+
isPagedPagination,
|
|
75
49
|
shouldCount,
|
|
76
50
|
transformPaginationResponse
|
|
77
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.mjs","sources":["../../../src/core-api/service/pagination.ts"],"sourcesContent":["import { has, toNumber,
|
|
1
|
+
{"version":3,"file":"pagination.mjs","sources":["../../../src/core-api/service/pagination.ts"],"sourcesContent":["import { omit, has, toNumber, isNil } from 'lodash/fp';\n\nimport { errors, pagination } from '@strapi/utils';\n\ninterface BasePaginationParams {\n withCount?: boolean | 't' | '1' | 'true' | 'f' | '0' | 'false' | 0 | 1;\n}\n\ntype PagedPagination = BasePaginationParams & {\n page?: number;\n pageSize?: number;\n};\n\ntype OffsetPagination = BasePaginationParams & {\n start?: number;\n limit?: number;\n};\n\nexport type PaginationParams = PagedPagination | OffsetPagination;\n\ntype PaginationInfo =\n | {\n page: number;\n pageSize: number;\n }\n | {\n start: number;\n limit: number;\n };\n\n/**\n * Default limit values from config\n */\nconst getLimitConfigDefaults = () => ({\n defaultLimit: toNumber(strapi.config.get('api.rest.defaultLimit', 25)),\n maxLimit: toNumber(strapi.config.get('api.rest.maxLimit')) || null,\n});\n\nconst isOffsetPagination = (pagination?: PaginationParams): pagination is OffsetPagination =>\n has('start', pagination) || has('limit', pagination);\n\nconst isPagedPagination = (pagination?: PaginationParams): pagination is PagedPagination =>\n has('page', pagination) || has('pageSize', pagination) || !isOffsetPagination(pagination);\n\nconst shouldCount = (params: { pagination?: PaginationParams }) => {\n if (has('pagination.withCount', params)) {\n const withCount = params.pagination?.withCount;\n\n if (typeof withCount === 'boolean') {\n return withCount;\n }\n\n if (typeof withCount === 'undefined') {\n return false;\n }\n\n if (['true', 't', '1', 1].includes(withCount)) {\n return true;\n }\n\n if (['false', 'f', '0', 0].includes(withCount)) {\n return false;\n }\n\n throw new errors.ValidationError(\n 'Invalid withCount parameter. Expected \"t\",\"1\",\"true\",\"false\",\"0\",\"f\"'\n );\n }\n\n return Boolean(strapi.config.get('api.rest.withCount', true));\n};\n\nconst getPaginationInfo = (params: { pagination?: PaginationParams }): PaginationInfo => {\n const { defaultLimit, maxLimit } = getLimitConfigDefaults();\n\n const { start, limit } = pagination.withDefaultPagination(params.pagination || {}, {\n defaults: { offset: { limit: defaultLimit }, page: { pageSize: defaultLimit } },\n maxLimit: maxLimit || -1,\n });\n\n return { start, limit };\n};\n\nconst transformPaginationResponse = (\n paginationInfo: PaginationInfo,\n total: number | undefined,\n isPaged: boolean\n) => {\n const transform = isPaged\n ? pagination.transformPagedPaginationInfo\n : pagination.transformOffsetPaginationInfo;\n\n const paginationResponse = transform(paginationInfo, total!);\n\n if (isNil(total)) {\n // Ignore total and pageCount if `total` value is not available.\n return omit(['total', 'pageCount'], paginationResponse) as ReturnType<typeof transform>;\n }\n\n return paginationResponse;\n};\n\nexport { isPagedPagination, shouldCount, getPaginationInfo, transformPaginationResponse };\n"],"names":["pagination"],"mappings":";;AAiCA,MAAM,yBAAyB,OAAO;AAAA,EACpC,cAAc,SAAS,OAAO,OAAO,IAAI,yBAAyB,EAAE,CAAC;AAAA,EACrE,UAAU,SAAS,OAAO,OAAO,IAAI,mBAAmB,CAAC,KAAK;AAChE;AAEA,MAAM,qBAAqB,CAACA,gBAC1B,IAAI,SAASA,WAAU,KAAK,IAAI,SAASA,WAAU;AAErD,MAAM,oBAAoB,CAACA,gBACzB,IAAI,QAAQA,WAAU,KAAK,IAAI,YAAYA,WAAU,KAAK,CAAC,mBAAmBA,WAAU;AAEpF,MAAA,cAAc,CAAC,WAA8C;AAC7D,MAAA,IAAI,wBAAwB,MAAM,GAAG;AACjC,UAAA,YAAY,OAAO,YAAY;AAEjC,QAAA,OAAO,cAAc,WAAW;AAC3B,aAAA;AAAA,IACT;AAEI,QAAA,OAAO,cAAc,aAAa;AAC7B,aAAA;AAAA,IACT;AAEI,QAAA,CAAC,QAAQ,KAAK,KAAK,CAAC,EAAE,SAAS,SAAS,GAAG;AACtC,aAAA;AAAA,IACT;AAEI,QAAA,CAAC,SAAS,KAAK,KAAK,CAAC,EAAE,SAAS,SAAS,GAAG;AACvC,aAAA;AAAA,IACT;AAEA,UAAM,IAAI,OAAO;AAAA,MACf;AAAA,IAAA;AAAA,EAEJ;AAEA,SAAO,QAAQ,OAAO,OAAO,IAAI,sBAAsB,IAAI,CAAC;AAC9D;AAEM,MAAA,oBAAoB,CAAC,WAA8D;AACvF,QAAM,EAAE,cAAc,SAAS,IAAI,uBAAuB;AAEpD,QAAA,EAAE,OAAO,UAAU,WAAW,sBAAsB,OAAO,cAAc,IAAI;AAAA,IACjF,UAAU,EAAE,QAAQ,EAAE,OAAO,aAAa,GAAG,MAAM,EAAE,UAAU,eAAe;AAAA,IAC9E,UAAU,YAAY;AAAA,EAAA,CACvB;AAEM,SAAA,EAAE,OAAO;AAClB;AAEA,MAAM,8BAA8B,CAClC,gBACA,OACA,YACG;AACH,QAAM,YAAY,UACd,WAAW,+BACX,WAAW;AAET,QAAA,qBAAqB,UAAU,gBAAgB,KAAM;AAEvD,MAAA,MAAM,KAAK,GAAG;AAEhB,WAAO,KAAK,CAAC,SAAS,WAAW,GAAG,kBAAkB;AAAA,EACxD;AAEO,SAAA;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-type.d.ts","sourceRoot":"","sources":["../../../src/core-api/service/single-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAAa,iBAAkB,SAAQ,WAAY,YAAW,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU;IAC3F,OAAO,CAAC,WAAW,CAA0B;gBAEjC,WAAW,EAAE,MAAM,CAAC,gBAAgB;IAM1C,aAAa;IASb,IAAI,CAAC,MAAM,KAAK;IAMhB,cAAc,CAAC,MAAM,KAAK;IAe1B,MAAM,CAAC,MAAM,KAAK;;;
|
|
1
|
+
{"version":3,"file":"single-type.d.ts","sourceRoot":"","sources":["../../../src/core-api/service/single-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAAa,iBAAkB,SAAQ,WAAY,YAAW,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU;IAC3F,OAAO,CAAC,WAAW,CAA0B;gBAEjC,WAAW,EAAE,MAAM,CAAC,gBAAgB;IAM1C,aAAa;IASb,IAAI,CAAC,MAAM,KAAK;IAMhB,cAAc,CAAC,MAAM,KAAK;IAe1B,MAAM,CAAC,MAAM,KAAK;;;CAazB;AAED,QAAA,MAAM,uBAAuB,gBACd,OAAO,gBAAgB,KACnC,KAAK,OAAO,CAAC,OAAO,CAAC,UAEvB,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -31,10 +31,11 @@ class SingleTypeService extends coreService.CoreService {
|
|
|
31
31
|
const documentId = await this.getDocumentId();
|
|
32
32
|
if (!documentId)
|
|
33
33
|
return { deletedEntries: 0 };
|
|
34
|
-
|
|
34
|
+
const { entries } = await strapi.documents(uid).delete({
|
|
35
35
|
...this.getFetchParams(params),
|
|
36
36
|
documentId
|
|
37
37
|
});
|
|
38
|
+
return { deletedEntries: entries.length };
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
const createSingleTypeService = (contentType) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-type.js","sources":["../../../src/core-api/service/single-type.ts"],"sourcesContent":["import type { Struct, Core } from '@strapi/types';\nimport { CoreService } from './core-service';\n\nexport class SingleTypeService extends CoreService implements Core.CoreAPI.Service.SingleType {\n private contentType: Struct.SingleTypeSchema;\n\n constructor(contentType: Struct.SingleTypeSchema) {\n super();\n\n this.contentType = contentType;\n }\n\n async getDocumentId() {\n const { uid } = this.contentType;\n\n return strapi.db\n .query(uid)\n .findOne()\n .then((document) => document?.documentId as string);\n }\n\n async find(params = {}) {\n const { uid } = this.contentType;\n\n return strapi.documents(uid).findFirst(this.getFetchParams(params));\n }\n\n async createOrUpdate(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n\n if (documentId) {\n return strapi.documents(uid).update({\n ...this.getFetchParams(params),\n documentId,\n });\n }\n\n return strapi.documents(uid).create(this.getFetchParams(params));\n }\n\n async delete(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n if (!documentId) return { deletedEntries: 0 };\n\n
|
|
1
|
+
{"version":3,"file":"single-type.js","sources":["../../../src/core-api/service/single-type.ts"],"sourcesContent":["import type { Struct, Core } from '@strapi/types';\nimport { CoreService } from './core-service';\n\nexport class SingleTypeService extends CoreService implements Core.CoreAPI.Service.SingleType {\n private contentType: Struct.SingleTypeSchema;\n\n constructor(contentType: Struct.SingleTypeSchema) {\n super();\n\n this.contentType = contentType;\n }\n\n async getDocumentId() {\n const { uid } = this.contentType;\n\n return strapi.db\n .query(uid)\n .findOne()\n .then((document) => document?.documentId as string);\n }\n\n async find(params = {}) {\n const { uid } = this.contentType;\n\n return strapi.documents(uid).findFirst(this.getFetchParams(params));\n }\n\n async createOrUpdate(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n\n if (documentId) {\n return strapi.documents(uid).update({\n ...this.getFetchParams(params),\n documentId,\n });\n }\n\n return strapi.documents(uid).create(this.getFetchParams(params));\n }\n\n async delete(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n if (!documentId) return { deletedEntries: 0 };\n\n const { entries } = await strapi.documents(uid).delete({\n ...this.getFetchParams(params),\n documentId,\n });\n\n return { deletedEntries: entries.length };\n }\n}\n\nconst createSingleTypeService = (\n contentType: Struct.SingleTypeSchema\n): Core.CoreAPI.Service.SingleType => {\n return new SingleTypeService(contentType);\n};\n\nexport { createSingleTypeService };\n"],"names":["CoreService"],"mappings":";;;AAGO,MAAM,0BAA0BA,YAAAA,YAAuD;AAAA,EACpF;AAAA,EAER,YAAY,aAAsC;AAC1C;AAEN,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,MAAM,gBAAgB;AACd,UAAA,EAAE,IAAI,IAAI,KAAK;AAEd,WAAA,OAAO,GACX,MAAM,GAAG,EACT,UACA,KAAK,CAAC,aAAa,UAAU,UAAoB;AAAA,EACtD;AAAA,EAEA,MAAM,KAAK,SAAS,IAAI;AAChB,UAAA,EAAE,IAAI,IAAI,KAAK;AAEd,WAAA,OAAO,UAAU,GAAG,EAAE,UAAU,KAAK,eAAe,MAAM,CAAC;AAAA,EACpE;AAAA,EAEA,MAAM,eAAe,SAAS,IAAI;AAC1B,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,aAAa,MAAM,KAAK;AAE9B,QAAI,YAAY;AACd,aAAO,OAAO,UAAU,GAAG,EAAE,OAAO;AAAA,QAClC,GAAG,KAAK,eAAe,MAAM;AAAA,QAC7B;AAAA,MAAA,CACD;AAAA,IACH;AAEO,WAAA,OAAO,UAAU,GAAG,EAAE,OAAO,KAAK,eAAe,MAAM,CAAC;AAAA,EACjE;AAAA,EAEA,MAAM,OAAO,SAAS,IAAI;AAClB,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,aAAa,MAAM,KAAK;AAC9B,QAAI,CAAC;AAAmB,aAAA,EAAE,gBAAgB;AAEpC,UAAA,EAAE,YAAY,MAAM,OAAO,UAAU,GAAG,EAAE,OAAO;AAAA,MACrD,GAAG,KAAK,eAAe,MAAM;AAAA,MAC7B;AAAA,IAAA,CACD;AAEM,WAAA,EAAE,gBAAgB,QAAQ;EACnC;AACF;AAEM,MAAA,0BAA0B,CAC9B,gBACoC;AAC7B,SAAA,IAAI,kBAAkB,WAAW;AAC1C;;;"}
|
|
@@ -29,10 +29,11 @@ class SingleTypeService extends CoreService {
|
|
|
29
29
|
const documentId = await this.getDocumentId();
|
|
30
30
|
if (!documentId)
|
|
31
31
|
return { deletedEntries: 0 };
|
|
32
|
-
|
|
32
|
+
const { entries } = await strapi.documents(uid).delete({
|
|
33
33
|
...this.getFetchParams(params),
|
|
34
34
|
documentId
|
|
35
35
|
});
|
|
36
|
+
return { deletedEntries: entries.length };
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
const createSingleTypeService = (contentType) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-type.mjs","sources":["../../../src/core-api/service/single-type.ts"],"sourcesContent":["import type { Struct, Core } from '@strapi/types';\nimport { CoreService } from './core-service';\n\nexport class SingleTypeService extends CoreService implements Core.CoreAPI.Service.SingleType {\n private contentType: Struct.SingleTypeSchema;\n\n constructor(contentType: Struct.SingleTypeSchema) {\n super();\n\n this.contentType = contentType;\n }\n\n async getDocumentId() {\n const { uid } = this.contentType;\n\n return strapi.db\n .query(uid)\n .findOne()\n .then((document) => document?.documentId as string);\n }\n\n async find(params = {}) {\n const { uid } = this.contentType;\n\n return strapi.documents(uid).findFirst(this.getFetchParams(params));\n }\n\n async createOrUpdate(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n\n if (documentId) {\n return strapi.documents(uid).update({\n ...this.getFetchParams(params),\n documentId,\n });\n }\n\n return strapi.documents(uid).create(this.getFetchParams(params));\n }\n\n async delete(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n if (!documentId) return { deletedEntries: 0 };\n\n
|
|
1
|
+
{"version":3,"file":"single-type.mjs","sources":["../../../src/core-api/service/single-type.ts"],"sourcesContent":["import type { Struct, Core } from '@strapi/types';\nimport { CoreService } from './core-service';\n\nexport class SingleTypeService extends CoreService implements Core.CoreAPI.Service.SingleType {\n private contentType: Struct.SingleTypeSchema;\n\n constructor(contentType: Struct.SingleTypeSchema) {\n super();\n\n this.contentType = contentType;\n }\n\n async getDocumentId() {\n const { uid } = this.contentType;\n\n return strapi.db\n .query(uid)\n .findOne()\n .then((document) => document?.documentId as string);\n }\n\n async find(params = {}) {\n const { uid } = this.contentType;\n\n return strapi.documents(uid).findFirst(this.getFetchParams(params));\n }\n\n async createOrUpdate(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n\n if (documentId) {\n return strapi.documents(uid).update({\n ...this.getFetchParams(params),\n documentId,\n });\n }\n\n return strapi.documents(uid).create(this.getFetchParams(params));\n }\n\n async delete(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n if (!documentId) return { deletedEntries: 0 };\n\n const { entries } = await strapi.documents(uid).delete({\n ...this.getFetchParams(params),\n documentId,\n });\n\n return { deletedEntries: entries.length };\n }\n}\n\nconst createSingleTypeService = (\n contentType: Struct.SingleTypeSchema\n): Core.CoreAPI.Service.SingleType => {\n return new SingleTypeService(contentType);\n};\n\nexport { createSingleTypeService };\n"],"names":[],"mappings":";AAGO,MAAM,0BAA0B,YAAuD;AAAA,EACpF;AAAA,EAER,YAAY,aAAsC;AAC1C;AAEN,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,MAAM,gBAAgB;AACd,UAAA,EAAE,IAAI,IAAI,KAAK;AAEd,WAAA,OAAO,GACX,MAAM,GAAG,EACT,UACA,KAAK,CAAC,aAAa,UAAU,UAAoB;AAAA,EACtD;AAAA,EAEA,MAAM,KAAK,SAAS,IAAI;AAChB,UAAA,EAAE,IAAI,IAAI,KAAK;AAEd,WAAA,OAAO,UAAU,GAAG,EAAE,UAAU,KAAK,eAAe,MAAM,CAAC;AAAA,EACpE;AAAA,EAEA,MAAM,eAAe,SAAS,IAAI;AAC1B,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,aAAa,MAAM,KAAK;AAE9B,QAAI,YAAY;AACd,aAAO,OAAO,UAAU,GAAG,EAAE,OAAO;AAAA,QAClC,GAAG,KAAK,eAAe,MAAM;AAAA,QAC7B;AAAA,MAAA,CACD;AAAA,IACH;AAEO,WAAA,OAAO,UAAU,GAAG,EAAE,OAAO,KAAK,eAAe,MAAM,CAAC;AAAA,EACjE;AAAA,EAEA,MAAM,OAAO,SAAS,IAAI;AAClB,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,aAAa,MAAM,KAAK;AAC9B,QAAI,CAAC;AAAmB,aAAA,EAAE,gBAAgB;AAEpC,UAAA,EAAE,YAAY,MAAM,OAAO,UAAU,GAAG,EAAE,OAAO;AAAA,MACrD,GAAG,KAAK,eAAe,MAAM;AAAA,MAC7B;AAAA,IAAA,CACD;AAEM,WAAA,EAAE,gBAAgB,QAAQ;EACnC;AACF;AAEM,MAAA,0BAA0B,CAC9B,gBACoC;AAC7B,SAAA,IAAI,kBAAkB,WAAW;AAC1C;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apis.d.ts","sourceRoot":"","sources":["../../src/loaders/apis.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAU,MAAM,eAAe,CAAC;AAgClD,wBAA8B,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"apis.d.ts","sourceRoot":"","sources":["../../src/loaders/apis.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAU,MAAM,eAAe,CAAC;AAgClD,wBAA8B,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,iBAyBzD"}
|
package/dist/loaders/apis.js
CHANGED
|
@@ -53,7 +53,7 @@ const validateContentTypesUnicity = (apis) => {
|
|
|
53
53
|
});
|
|
54
54
|
};
|
|
55
55
|
const loadAPI = async (apiName, dir) => {
|
|
56
|
-
const [index2, config, routes, controllers, services, policies, middlewares, contentTypes] = await Promise.all([
|
|
56
|
+
const [index2, config, routes, controllers, services, policies, middlewares, contentTypes] = (await Promise.all([
|
|
57
57
|
loadIndex(dir),
|
|
58
58
|
loadDir(path.join(dir, "config")),
|
|
59
59
|
loadDir(path.join(dir, "routes")),
|
|
@@ -62,7 +62,7 @@ const loadAPI = async (apiName, dir) => {
|
|
|
62
62
|
loadDir(path.join(dir, "policies")),
|
|
63
63
|
loadDir(path.join(dir, "middlewares")),
|
|
64
64
|
loadContentTypes(apiName, path.join(dir, "content-types"))
|
|
65
|
-
]);
|
|
65
|
+
])).map((result) => result?.result);
|
|
66
66
|
return {
|
|
67
67
|
...index2 || {},
|
|
68
68
|
config: config || {},
|
|
@@ -90,7 +90,7 @@ const loadContentTypes = async (apiName, dir) => {
|
|
|
90
90
|
continue;
|
|
91
91
|
}
|
|
92
92
|
const contentTypeName = normalizeName(fd.name);
|
|
93
|
-
const loadedContentType = await loadDir(path.join(dir, fd.name));
|
|
93
|
+
const loadedContentType = (await loadDir(path.join(dir, fd.name)))?.result;
|
|
94
94
|
if (_$1.isEmpty(loadedContentType) || _$1.isEmpty(loadedContentType.schema)) {
|
|
95
95
|
throw new Error(`Could not load content type found at ${dir}`);
|
|
96
96
|
}
|
|
@@ -105,7 +105,7 @@ const loadContentTypes = async (apiName, dir) => {
|
|
|
105
105
|
});
|
|
106
106
|
contentTypes[normalizeName(contentTypeName)] = contentType;
|
|
107
107
|
}
|
|
108
|
-
return contentTypes;
|
|
108
|
+
return { result: contentTypes };
|
|
109
109
|
};
|
|
110
110
|
const loadDir = async (dir) => {
|
|
111
111
|
if (!await fse__default.default.pathExists(dir)) {
|
|
@@ -118,19 +118,19 @@ const loadDir = async (dir) => {
|
|
|
118
118
|
continue;
|
|
119
119
|
}
|
|
120
120
|
const key = path.basename(fd.name, path.extname(fd.name));
|
|
121
|
-
root[normalizeName(key)] = await loadFile(path.join(dir, fd.name));
|
|
121
|
+
root[normalizeName(key)] = (await loadFile(path.join(dir, fd.name))).result;
|
|
122
122
|
}
|
|
123
|
-
return root;
|
|
123
|
+
return { result: root };
|
|
124
124
|
};
|
|
125
|
-
const loadFile = (file) => {
|
|
125
|
+
const loadFile = async (file) => {
|
|
126
126
|
const ext = path.extname(file);
|
|
127
127
|
switch (ext) {
|
|
128
128
|
case ".js":
|
|
129
|
-
return strapiUtils.importDefault(file);
|
|
129
|
+
return { result: strapiUtils.importDefault(file) };
|
|
130
130
|
case ".json":
|
|
131
|
-
return fse__default.default.readJSON(file);
|
|
131
|
+
return { result: await fse__default.default.readJSON(file) };
|
|
132
132
|
default:
|
|
133
|
-
return {};
|
|
133
|
+
return { result: {} };
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
module.exports = loadAPIs;
|