@strapi/core 0.0.0-next.8d576f41729640e32a4a0cfcb258b6288e6631f6 → 0.0.0-next.8f0cdd4f9e4697ffed86c783465297fe532713f8
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.map +1 -1
- package/dist/Strapi.js +2 -0
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs +2 -0
- package/dist/Strapi.mjs.map +1 -1
- package/dist/core-api/routes/index.d.ts +4 -22
- package/dist/core-api/routes/index.d.ts.map +1 -1
- package/dist/core-api/routes/index.js +150 -8
- package/dist/core-api/routes/index.js.map +1 -1
- package/dist/core-api/routes/index.mjs +131 -8
- package/dist/core-api/routes/index.mjs.map +1 -1
- package/dist/core-api/routes/validation/attributes.d.ts +244 -0
- package/dist/core-api/routes/validation/attributes.d.ts.map +1 -0
- package/dist/core-api/routes/validation/attributes.js +560 -0
- package/dist/core-api/routes/validation/attributes.js.map +1 -0
- package/dist/core-api/routes/validation/attributes.mjs +521 -0
- package/dist/core-api/routes/validation/attributes.mjs.map +1 -0
- package/dist/core-api/routes/validation/common.d.ts +105 -0
- package/dist/core-api/routes/validation/common.d.ts.map +1 -0
- package/dist/core-api/routes/validation/common.js +116 -0
- package/dist/core-api/routes/validation/common.js.map +1 -0
- package/dist/core-api/routes/validation/common.mjs +95 -0
- package/dist/core-api/routes/validation/common.mjs.map +1 -0
- package/dist/core-api/routes/validation/component.d.ts +34 -0
- package/dist/core-api/routes/validation/component.d.ts.map +1 -0
- package/dist/core-api/routes/validation/component.js +45 -0
- package/dist/core-api/routes/validation/component.js.map +1 -0
- package/dist/core-api/routes/validation/component.mjs +43 -0
- package/dist/core-api/routes/validation/component.mjs.map +1 -0
- package/dist/core-api/routes/validation/constants.d.ts +8 -0
- package/dist/core-api/routes/validation/constants.d.ts.map +1 -0
- package/dist/core-api/routes/validation/constants.js +18 -0
- package/dist/core-api/routes/validation/constants.js.map +1 -0
- package/dist/core-api/routes/validation/constants.mjs +16 -0
- package/dist/core-api/routes/validation/constants.mjs.map +1 -0
- package/dist/core-api/routes/validation/content-type.d.ts +128 -0
- package/dist/core-api/routes/validation/content-type.d.ts.map +1 -0
- package/dist/core-api/routes/validation/content-type.js +201 -0
- package/dist/core-api/routes/validation/content-type.js.map +1 -0
- package/dist/core-api/routes/validation/content-type.mjs +180 -0
- package/dist/core-api/routes/validation/content-type.mjs.map +1 -0
- package/dist/core-api/routes/validation/index.d.ts +5 -0
- package/dist/core-api/routes/validation/index.d.ts.map +1 -0
- package/dist/core-api/routes/validation/mappers.d.ts +105 -0
- package/dist/core-api/routes/validation/mappers.d.ts.map +1 -0
- package/dist/core-api/routes/validation/mappers.js +238 -0
- package/dist/core-api/routes/validation/mappers.js.map +1 -0
- package/dist/core-api/routes/validation/mappers.mjs +214 -0
- package/dist/core-api/routes/validation/mappers.mjs.map +1 -0
- package/dist/core-api/routes/validation/utils.d.ts +47 -0
- package/dist/core-api/routes/validation/utils.d.ts.map +1 -0
- package/dist/core-api/routes/validation/utils.js +112 -0
- package/dist/core-api/routes/validation/utils.js.map +1 -0
- package/dist/core-api/routes/validation/utils.mjs +90 -0
- package/dist/core-api/routes/validation/utils.mjs.map +1 -0
- package/dist/domain/module/index.d.ts.map +1 -1
- package/dist/domain/module/index.js +3 -0
- package/dist/domain/module/index.js.map +1 -1
- package/dist/domain/module/index.mjs +3 -0
- package/dist/domain/module/index.mjs.map +1 -1
- package/dist/factories.d.ts +3 -1
- package/dist/factories.d.ts.map +1 -1
- package/dist/factories.js +10 -2
- package/dist/factories.js.map +1 -1
- package/dist/factories.mjs +10 -3
- package/dist/factories.mjs.map +1 -1
- package/dist/middlewares/cors.d.ts +9 -1
- package/dist/middlewares/cors.d.ts.map +1 -1
- package/dist/middlewares/cors.js +39 -17
- package/dist/middlewares/cors.js.map +1 -1
- package/dist/middlewares/cors.mjs +39 -18
- package/dist/middlewares/cors.mjs.map +1 -1
- package/dist/package.json.js +15 -12
- package/dist/package.json.js.map +1 -1
- package/dist/package.json.mjs +15 -12
- package/dist/package.json.mjs.map +1 -1
- package/dist/services/document-service/entries.d.ts.map +1 -1
- package/dist/services/document-service/entries.js.map +1 -1
- package/dist/services/document-service/entries.mjs.map +1 -1
- package/dist/services/document-service/internationalization.d.ts +6 -1
- package/dist/services/document-service/internationalization.d.ts.map +1 -1
- package/dist/services/document-service/internationalization.js +32 -0
- package/dist/services/document-service/internationalization.js.map +1 -1
- package/dist/services/document-service/internationalization.mjs +32 -1
- 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 +5 -4
- package/dist/services/document-service/repository.js.map +1 -1
- package/dist/services/document-service/repository.mjs +6 -5
- package/dist/services/document-service/repository.mjs.map +1 -1
- package/dist/services/entity-validator/index.d.ts.map +1 -1
- package/dist/services/entity-validator/index.js +9 -0
- package/dist/services/entity-validator/index.js.map +1 -1
- package/dist/services/entity-validator/index.mjs +9 -0
- package/dist/services/entity-validator/index.mjs.map +1 -1
- package/dist/services/entity-validator/validators.d.ts +1 -0
- package/dist/services/entity-validator/validators.d.ts.map +1 -1
- package/dist/services/entity-validator/validators.js.map +1 -1
- package/dist/services/entity-validator/validators.mjs.map +1 -1
- package/dist/services/metrics/index.d.ts +1 -1
- package/dist/services/metrics/index.d.ts.map +1 -1
- package/dist/services/metrics/index.js +9 -8
- package/dist/services/metrics/index.js.map +1 -1
- package/dist/services/metrics/index.mjs +9 -8
- package/dist/services/metrics/index.mjs.map +1 -1
- package/dist/services/metrics/sender.d.ts.map +1 -1
- package/dist/services/metrics/sender.js +2 -2
- package/dist/services/metrics/sender.js.map +1 -1
- package/dist/services/metrics/sender.mjs +2 -2
- package/dist/services/metrics/sender.mjs.map +1 -1
- package/dist/services/server/register-routes.js +22 -2
- package/dist/services/server/register-routes.js.map +1 -1
- package/dist/services/server/register-routes.mjs +22 -2
- package/dist/services/server/register-routes.mjs.map +1 -1
- package/dist/services/server/routing.d.ts +10 -0
- package/dist/services/server/routing.d.ts.map +1 -1
- package/dist/services/server/routing.js +7 -1
- package/dist/services/server/routing.js.map +1 -1
- package/dist/services/server/routing.mjs +7 -1
- package/dist/services/server/routing.mjs.map +1 -1
- package/dist/services/utils/conditional-fields.d.ts +3 -0
- package/dist/services/utils/conditional-fields.d.ts.map +1 -0
- package/dist/services/utils/conditional-fields.js +22 -0
- package/dist/services/utils/conditional-fields.js.map +1 -0
- package/dist/services/utils/conditional-fields.mjs +20 -0
- package/dist/services/utils/conditional-fields.mjs.map +1 -0
- package/dist/utils/transform-content-types-to-models.d.ts +196 -0
- package/dist/utils/transform-content-types-to-models.d.ts.map +1 -1
- package/package.json +15 -12
|
@@ -7,6 +7,16 @@ declare const validateRouteConfig: (routeConfig: Core.RouteInput) => import("yup
|
|
|
7
7
|
method: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
|
|
8
8
|
path: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
|
|
9
9
|
handler: import("yup/lib/Lazy").default<import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>> | import("yup/lib/mixed").MixedSchema<any, Record<string, any>, any> | import("yup/lib/array").RequiredArraySchema<yup.AnySchema, import("yup/lib/types").AnyObject, any[] | undefined>, any>;
|
|
10
|
+
request: import("yup/lib/object").OptionalObjectSchema<{
|
|
11
|
+
params: import("yup/lib/object").OptionalObjectSchema<import("yup/lib/object").ObjectShape, Record<string, any>, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
12
|
+
query: import("yup/lib/object").OptionalObjectSchema<import("yup/lib/object").ObjectShape, Record<string, any>, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
13
|
+
body: import("yup/lib/object").OptionalObjectSchema<import("yup/lib/object").ObjectShape, Record<string, any>, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
14
|
+
}, Record<string, any>, import("yup/lib/object").TypeOfShape<{
|
|
15
|
+
params: import("yup/lib/object").OptionalObjectSchema<import("yup/lib/object").ObjectShape, Record<string, any>, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
16
|
+
query: import("yup/lib/object").OptionalObjectSchema<import("yup/lib/object").ObjectShape, Record<string, any>, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
17
|
+
body: import("yup/lib/object").OptionalObjectSchema<import("yup/lib/object").ObjectShape, Record<string, any>, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
18
|
+
}>>;
|
|
19
|
+
response: import("yup/lib/object").OptionalObjectSchema<import("yup/lib/object").ObjectShape, Record<string, any>, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
10
20
|
config: import("yup/lib/object").OptionalObjectSchema<{
|
|
11
21
|
auth: import("yup/lib/Lazy").default<import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, Record<string, any>> | import("yup/lib/object").OptionalObjectSchema<{
|
|
12
22
|
scope: import("yup/lib/array").RequiredArraySchema<import("yup").StringSchema<string | undefined, Record<string, any>, string | undefined>, import("yup/lib/types").AnyObject, (string | undefined)[] | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../../src/services/server/routing.ts"],"names":[],"mappings":";;AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../../src/services/server/routing.ts"],"names":[],"mappings":";;AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAkE1C,QAAA,MAAM,mBAAmB,gBAAiB,KAAK,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAYxD,CAAC;AAEF,QAAA,MAAM,kBAAkB,WAAY,KAAK,MAAM,SAAQ;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE;wBAmB3C,WAAW,GAAG,KAAK,UAAU,EAAE,UAAU,MAAM;CAkB3E,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -36,6 +36,12 @@ const routeSchema = strapiUtils.yup.object({
|
|
|
36
36
|
}
|
|
37
37
|
return strapiUtils.yup.mixed().isFunction().required();
|
|
38
38
|
}),
|
|
39
|
+
request: strapiUtils.yup.object({
|
|
40
|
+
params: strapiUtils.yup.object().notRequired(),
|
|
41
|
+
query: strapiUtils.yup.object().notRequired(),
|
|
42
|
+
body: strapiUtils.yup.object().notRequired()
|
|
43
|
+
}).notRequired(),
|
|
44
|
+
response: strapiUtils.yup.object().notRequired(),
|
|
39
45
|
config: strapiUtils.yup.object({
|
|
40
46
|
auth: strapiUtils.yup.lazy((value)=>{
|
|
41
47
|
if (value === false) {
|
|
@@ -73,7 +79,7 @@ const createRouteManager = (strapi, opts = {})=>{
|
|
|
73
79
|
const routeWithInfo = Object.assign(route, {
|
|
74
80
|
info: {
|
|
75
81
|
...route.info ?? {},
|
|
76
|
-
type: type
|
|
82
|
+
type: type ?? 'api'
|
|
77
83
|
}
|
|
78
84
|
});
|
|
79
85
|
composeEndpoint$1(routeWithInfo, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sources":["../../../src/services/server/routing.ts"],"sourcesContent":["import Router from '@koa/router';\nimport { has } from 'lodash/fp';\nimport { yup } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\n\nimport createEndpointComposer from './compose-endpoint';\n\nconst policyOrMiddlewareSchema = yup.lazy((value) => {\n if (typeof value === 'string') {\n return yup.string().required();\n }\n\n if (typeof value === 'function') {\n return yup.mixed().isFunction();\n }\n\n return yup.object({\n name: yup.string().required(),\n options: yup.object().notRequired(), // any options\n });\n});\n\nconst routeSchema = yup.object({\n method: yup.string().oneOf(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'ALL']).required(),\n path: yup.string().required(),\n handler: yup.lazy((value) => {\n if (typeof value === 'string') {\n return yup.string().required();\n }\n\n if (Array.isArray(value)) {\n return yup.array().required();\n }\n\n return yup.mixed().isFunction().required();\n }),\n config: yup\n .object({\n auth: yup.lazy((value) => {\n if (value === false) {\n return yup.boolean().required();\n }\n\n return yup.object({\n scope: yup.array().of(yup.string()).required(),\n });\n }),\n policies: yup\n .array()\n // FIXME: fixed in yup v1\n .of(policyOrMiddlewareSchema as any)\n .notRequired(),\n middlewares: yup\n .array()\n // FIXME: fixed in yup v1\n .of(policyOrMiddlewareSchema as any)\n .notRequired(),\n })\n .notRequired(),\n});\n\nconst validateRouteConfig = (routeConfig: Core.RouteInput) => {\n try {\n return routeSchema.validateSync(routeConfig, {\n strict: true,\n abortEarly: false,\n stripUnknown: true,\n });\n } catch (error) {\n if (error instanceof yup.ValidationError) {\n throw new Error(`Invalid route config ${error.message}`);\n }\n }\n};\n\nconst createRouteManager = (strapi: Core.Strapi, opts: { type?: string } = {}) => {\n const { type } = opts;\n\n const composeEndpoint = createEndpointComposer(strapi);\n\n const createRoute = (route: Core.RouteInput, router: Router) => {\n validateRouteConfig(route);\n\n // NOTE: the router type is used to tag controller actions and for authentication / authorization so we need to pass this info down to the route level\n const routeWithInfo = Object.assign(route, {\n info: {\n ...(route.info ?? {}),\n type: type
|
|
1
|
+
{"version":3,"file":"routing.js","sources":["../../../src/services/server/routing.ts"],"sourcesContent":["import Router from '@koa/router';\nimport { has } from 'lodash/fp';\nimport { yup } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\n\nimport createEndpointComposer from './compose-endpoint';\n\nconst policyOrMiddlewareSchema = yup.lazy((value) => {\n if (typeof value === 'string') {\n return yup.string().required();\n }\n\n if (typeof value === 'function') {\n return yup.mixed().isFunction();\n }\n\n return yup.object({\n name: yup.string().required(),\n options: yup.object().notRequired(), // any options\n });\n});\n\nconst routeSchema = yup.object({\n method: yup.string().oneOf(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'ALL']).required(),\n path: yup.string().required(),\n handler: yup.lazy((value) => {\n if (typeof value === 'string') {\n return yup.string().required();\n }\n\n if (Array.isArray(value)) {\n return yup.array().required();\n }\n\n return yup.mixed().isFunction().required();\n }),\n request: yup\n .object({\n params: yup.object().notRequired(),\n query: yup.object().notRequired(),\n body: yup.object().notRequired(),\n })\n .notRequired(),\n response: yup.object().notRequired(),\n config: yup\n .object({\n auth: yup.lazy((value) => {\n if (value === false) {\n return yup.boolean().required();\n }\n\n return yup.object({\n scope: yup.array().of(yup.string()).required(),\n });\n }),\n policies: yup\n .array()\n // FIXME: fixed in yup v1\n .of(policyOrMiddlewareSchema as any)\n .notRequired(),\n middlewares: yup\n .array()\n // FIXME: fixed in yup v1\n .of(policyOrMiddlewareSchema as any)\n .notRequired(),\n })\n .notRequired(),\n});\n\nconst validateRouteConfig = (routeConfig: Core.RouteInput) => {\n try {\n return routeSchema.validateSync(routeConfig, {\n strict: true,\n abortEarly: false,\n stripUnknown: true,\n });\n } catch (error) {\n if (error instanceof yup.ValidationError) {\n throw new Error(`Invalid route config ${error.message}`);\n }\n }\n};\n\nconst createRouteManager = (strapi: Core.Strapi, opts: { type?: string } = {}) => {\n const { type } = opts;\n\n const composeEndpoint = createEndpointComposer(strapi);\n\n const createRoute = (route: Core.RouteInput, router: Router) => {\n validateRouteConfig(route);\n\n // NOTE: the router type is used to tag controller actions and for authentication / authorization so we need to pass this info down to the route level\n const routeWithInfo = Object.assign(route, {\n info: {\n ...(route.info ?? {}),\n type: type ?? 'api',\n },\n });\n\n composeEndpoint(routeWithInfo, { router });\n };\n\n const addRoutes = (routes: Core.Router | Core.RouteInput[], router: Router) => {\n if (Array.isArray(routes)) {\n routes.forEach((route) => createRoute(route, router));\n } else if (routes.routes) {\n const subRouter = new Router({ prefix: routes.prefix });\n\n routes.routes.forEach((route) => {\n const hasPrefix = has('prefix', route.config);\n createRoute(route, hasPrefix ? router : subRouter);\n });\n\n return router.use(subRouter.routes(), subRouter.allowedMethods());\n }\n };\n\n return {\n addRoutes,\n };\n};\n\nexport { validateRouteConfig, createRouteManager };\n"],"names":["policyOrMiddlewareSchema","yup","lazy","value","string","required","mixed","isFunction","object","name","options","notRequired","routeSchema","method","oneOf","path","handler","Array","isArray","array","request","params","query","body","response","config","auth","boolean","scope","of","policies","middlewares","validateRouteConfig","routeConfig","validateSync","strict","abortEarly","stripUnknown","error","ValidationError","Error","message","createRouteManager","strapi","opts","type","composeEndpoint","createEndpointComposer","createRoute","route","router","routeWithInfo","Object","assign","info","addRoutes","routes","forEach","subRouter","Router","prefix","hasPrefix","has","use","allowedMethods"],"mappings":";;;;;;;AAOA,MAAMA,wBAA2BC,GAAAA,eAAAA,CAAIC,IAAI,CAAC,CAACC,KAAAA,GAAAA;IACzC,IAAI,OAAOA,UAAU,QAAU,EAAA;QAC7B,OAAOF,eAAAA,CAAIG,MAAM,EAAA,CAAGC,QAAQ,EAAA;AAC9B;IAEA,IAAI,OAAOF,UAAU,UAAY,EAAA;QAC/B,OAAOF,eAAAA,CAAIK,KAAK,EAAA,CAAGC,UAAU,EAAA;AAC/B;IAEA,OAAON,eAAAA,CAAIO,MAAM,CAAC;QAChBC,IAAMR,EAAAA,eAAAA,CAAIG,MAAM,EAAA,CAAGC,QAAQ,EAAA;QAC3BK,OAAST,EAAAA,eAAAA,CAAIO,MAAM,EAAA,CAAGG,WAAW;AACnC,KAAA,CAAA;AACF,CAAA,CAAA;AAEA,MAAMC,WAAAA,GAAcX,eAAIO,CAAAA,MAAM,CAAC;AAC7BK,IAAAA,MAAAA,EAAQZ,eAAIG,CAAAA,MAAM,EAAGU,CAAAA,KAAK,C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A;AAChB;AACF,SAAA,CAAA;AAEAC,QAAAA,iBAAAA,CAAgBK,aAAe,EAAA;AAAED,YAAAA;AAAO,SAAA,CAAA;AAC1C,KAAA;IAEA,MAAMK,SAAAA,GAAY,CAACC,MAAyCN,EAAAA,MAAAA,GAAAA;QAC1D,IAAIjC,KAAAA,CAAMC,OAAO,CAACsC,MAAS,CAAA,EAAA;AACzBA,YAAAA,MAAAA,CAAOC,OAAO,CAAC,CAACR,KAAAA,GAAUD,YAAYC,KAAOC,EAAAA,MAAAA,CAAAA,CAAAA;SACxC,MAAA,IAAIM,MAAOA,CAAAA,MAAM,EAAE;YACxB,MAAME,SAAAA,GAAY,IAAIC,MAAO,CAAA;AAAEC,gBAAAA,MAAAA,EAAQJ,OAAOI;AAAO,aAAA,CAAA;AAErDJ,YAAAA,MAAAA,CAAOA,MAAM,CAACC,OAAO,CAAC,CAACR,KAAAA,GAAAA;AACrB,gBAAA,MAAMY,SAAYC,GAAAA,MAAAA,CAAI,QAAUb,EAAAA,KAAAA,CAAMxB,MAAM,CAAA;gBAC5CuB,WAAYC,CAAAA,KAAAA,EAAOY,YAAYX,MAASQ,GAAAA,SAAAA,CAAAA;AAC1C,aAAA,CAAA;AAEA,YAAA,OAAOR,OAAOa,GAAG,CAACL,UAAUF,MAAM,EAAA,EAAIE,UAAUM,cAAc,EAAA,CAAA;AAChE;AACF,KAAA;IAEA,OAAO;AACLT,QAAAA;AACF,KAAA;AACF;;;;;"}
|
|
@@ -34,6 +34,12 @@ const routeSchema = yup.object({
|
|
|
34
34
|
}
|
|
35
35
|
return yup.mixed().isFunction().required();
|
|
36
36
|
}),
|
|
37
|
+
request: yup.object({
|
|
38
|
+
params: yup.object().notRequired(),
|
|
39
|
+
query: yup.object().notRequired(),
|
|
40
|
+
body: yup.object().notRequired()
|
|
41
|
+
}).notRequired(),
|
|
42
|
+
response: yup.object().notRequired(),
|
|
37
43
|
config: yup.object({
|
|
38
44
|
auth: yup.lazy((value)=>{
|
|
39
45
|
if (value === false) {
|
|
@@ -71,7 +77,7 @@ const createRouteManager = (strapi, opts = {})=>{
|
|
|
71
77
|
const routeWithInfo = Object.assign(route, {
|
|
72
78
|
info: {
|
|
73
79
|
...route.info ?? {},
|
|
74
|
-
type: type
|
|
80
|
+
type: type ?? 'api'
|
|
75
81
|
}
|
|
76
82
|
});
|
|
77
83
|
composeEndpoint(routeWithInfo, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.mjs","sources":["../../../src/services/server/routing.ts"],"sourcesContent":["import Router from '@koa/router';\nimport { has } from 'lodash/fp';\nimport { yup } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\n\nimport createEndpointComposer from './compose-endpoint';\n\nconst policyOrMiddlewareSchema = yup.lazy((value) => {\n if (typeof value === 'string') {\n return yup.string().required();\n }\n\n if (typeof value === 'function') {\n return yup.mixed().isFunction();\n }\n\n return yup.object({\n name: yup.string().required(),\n options: yup.object().notRequired(), // any options\n });\n});\n\nconst routeSchema = yup.object({\n method: yup.string().oneOf(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'ALL']).required(),\n path: yup.string().required(),\n handler: yup.lazy((value) => {\n if (typeof value === 'string') {\n return yup.string().required();\n }\n\n if (Array.isArray(value)) {\n return yup.array().required();\n }\n\n return yup.mixed().isFunction().required();\n }),\n config: yup\n .object({\n auth: yup.lazy((value) => {\n if (value === false) {\n return yup.boolean().required();\n }\n\n return yup.object({\n scope: yup.array().of(yup.string()).required(),\n });\n }),\n policies: yup\n .array()\n // FIXME: fixed in yup v1\n .of(policyOrMiddlewareSchema as any)\n .notRequired(),\n middlewares: yup\n .array()\n // FIXME: fixed in yup v1\n .of(policyOrMiddlewareSchema as any)\n .notRequired(),\n })\n .notRequired(),\n});\n\nconst validateRouteConfig = (routeConfig: Core.RouteInput) => {\n try {\n return routeSchema.validateSync(routeConfig, {\n strict: true,\n abortEarly: false,\n stripUnknown: true,\n });\n } catch (error) {\n if (error instanceof yup.ValidationError) {\n throw new Error(`Invalid route config ${error.message}`);\n }\n }\n};\n\nconst createRouteManager = (strapi: Core.Strapi, opts: { type?: string } = {}) => {\n const { type } = opts;\n\n const composeEndpoint = createEndpointComposer(strapi);\n\n const createRoute = (route: Core.RouteInput, router: Router) => {\n validateRouteConfig(route);\n\n // NOTE: the router type is used to tag controller actions and for authentication / authorization so we need to pass this info down to the route level\n const routeWithInfo = Object.assign(route, {\n info: {\n ...(route.info ?? {}),\n type: type
|
|
1
|
+
{"version":3,"file":"routing.mjs","sources":["../../../src/services/server/routing.ts"],"sourcesContent":["import Router from '@koa/router';\nimport { has } from 'lodash/fp';\nimport { yup } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\n\nimport createEndpointComposer from './compose-endpoint';\n\nconst policyOrMiddlewareSchema = yup.lazy((value) => {\n if (typeof value === 'string') {\n return yup.string().required();\n }\n\n if (typeof value === 'function') {\n return yup.mixed().isFunction();\n }\n\n return yup.object({\n name: yup.string().required(),\n options: yup.object().notRequired(), // any options\n });\n});\n\nconst routeSchema = yup.object({\n method: yup.string().oneOf(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'ALL']).required(),\n path: yup.string().required(),\n handler: yup.lazy((value) => {\n if (typeof value === 'string') {\n return yup.string().required();\n }\n\n if (Array.isArray(value)) {\n return yup.array().required();\n }\n\n return yup.mixed().isFunction().required();\n }),\n request: yup\n .object({\n params: yup.object().notRequired(),\n query: yup.object().notRequired(),\n body: yup.object().notRequired(),\n })\n .notRequired(),\n response: yup.object().notRequired(),\n config: yup\n .object({\n auth: yup.lazy((value) => {\n if (value === false) {\n return yup.boolean().required();\n }\n\n return yup.object({\n scope: yup.array().of(yup.string()).required(),\n });\n }),\n policies: yup\n .array()\n // FIXME: fixed in yup v1\n .of(policyOrMiddlewareSchema as any)\n .notRequired(),\n middlewares: yup\n .array()\n // FIXME: fixed in yup v1\n .of(policyOrMiddlewareSchema as any)\n .notRequired(),\n })\n .notRequired(),\n});\n\nconst validateRouteConfig = (routeConfig: Core.RouteInput) => {\n try {\n return routeSchema.validateSync(routeConfig, {\n strict: true,\n abortEarly: false,\n stripUnknown: true,\n });\n } catch (error) {\n if (error instanceof yup.ValidationError) {\n throw new Error(`Invalid route config ${error.message}`);\n }\n }\n};\n\nconst createRouteManager = (strapi: Core.Strapi, opts: { type?: string } = {}) => {\n const { type } = opts;\n\n const composeEndpoint = createEndpointComposer(strapi);\n\n const createRoute = (route: Core.RouteInput, router: Router) => {\n validateRouteConfig(route);\n\n // NOTE: the router type is used to tag controller actions and for authentication / authorization so we need to pass this info down to the route level\n const routeWithInfo = Object.assign(route, {\n info: {\n ...(route.info ?? {}),\n type: type ?? 'api',\n },\n });\n\n composeEndpoint(routeWithInfo, { router });\n };\n\n const addRoutes = (routes: Core.Router | Core.RouteInput[], router: Router) => {\n if (Array.isArray(routes)) {\n routes.forEach((route) => createRoute(route, router));\n } else if (routes.routes) {\n const subRouter = new Router({ prefix: routes.prefix });\n\n routes.routes.forEach((route) => {\n const hasPrefix = has('prefix', route.config);\n createRoute(route, hasPrefix ? router : subRouter);\n });\n\n return router.use(subRouter.routes(), subRouter.allowedMethods());\n }\n };\n\n return {\n addRoutes,\n };\n};\n\nexport { validateRouteConfig, createRouteManager };\n"],"names":["policyOrMiddlewareSchema","yup","lazy","value","string","required","mixed","isFunction","object","name","options","notRequired","routeSchema","method","oneOf","path","handler","Array","isArray","array","request","params","query","body","response","config","auth","boolean","scope","of","policies","middlewares","validateRouteConfig","routeConfig","validateSync","strict","abortEarly","stripUnknown","error","ValidationError","Error","message","createRouteManager","strapi","opts","type","composeEndpoint","createEndpointComposer","createRoute","route","router","routeWithInfo","Object","assign","info","addRoutes","routes","forEach","subRouter","Router","prefix","hasPrefix","has","use","allowedMethods"],"mappings":";;;;;AAOA,MAAMA,wBAA2BC,GAAAA,GAAAA,CAAIC,IAAI,CAAC,CAACC,KAAAA,GAAAA;IACzC,IAAI,OAAOA,UAAU,QAAU,EAAA;QAC7B,OAAOF,GAAAA,CAAIG,MAA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OAAOR,OAAOa,GAAG,CAACL,UAAUF,MAAM,EAAA,EAAIE,UAAUM,cAAc,EAAA,CAAA;AAChE;AACF,KAAA;IAEA,OAAO;AACLT,QAAAA;AACF,KAAA;AACF;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditional-fields.d.ts","sourceRoot":"","sources":["../../../src/services/utils/conditional-fields.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,4BAA4B,WAuBjC,CAAC;AAEF,eAAe,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fp = require('lodash/fp');
|
|
4
|
+
|
|
5
|
+
const getNumberOfConditionalFields = ()=>{
|
|
6
|
+
const contentTypes = strapi.contentTypes;
|
|
7
|
+
const components = strapi.components;
|
|
8
|
+
const countConditionalFieldsInSchema = (schema)=>{
|
|
9
|
+
return fp.pipe(fp.map('attributes'), fp.flatMap(fp.values), fp.sumBy((attribute)=>{
|
|
10
|
+
if (attribute.conditions && typeof attribute.conditions === 'object') {
|
|
11
|
+
return 1;
|
|
12
|
+
}
|
|
13
|
+
return 0;
|
|
14
|
+
}))(schema);
|
|
15
|
+
};
|
|
16
|
+
const contentTypeCount = countConditionalFieldsInSchema(contentTypes);
|
|
17
|
+
const componentCount = countConditionalFieldsInSchema(components);
|
|
18
|
+
return contentTypeCount + componentCount;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
module.exports = getNumberOfConditionalFields;
|
|
22
|
+
//# sourceMappingURL=conditional-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditional-fields.js","sources":["../../../src/services/utils/conditional-fields.ts"],"sourcesContent":["import { map, values, sumBy, pipe, flatMap } from 'lodash/fp';\nimport type { Schema, UID } from '@strapi/types';\n\nconst getNumberOfConditionalFields = () => {\n const contentTypes: Record<UID.ContentType, Schema.ContentType> = strapi.contentTypes;\n const components: Record<UID.Component, Schema.Component> = strapi.components;\n\n const countConditionalFieldsInSchema = (\n schema: Record<string, Schema.ContentType | Schema.Component>\n ) => {\n return pipe(\n map('attributes'),\n flatMap(values),\n sumBy((attribute: Schema.Attribute.AnyAttribute) => {\n if (attribute.conditions && typeof attribute.conditions === 'object') {\n return 1;\n }\n return 0;\n })\n )(schema);\n };\n\n const contentTypeCount = countConditionalFieldsInSchema(contentTypes);\n const componentCount = countConditionalFieldsInSchema(components);\n\n return contentTypeCount + componentCount;\n};\n\nexport default getNumberOfConditionalFields;\n"],"names":["getNumberOfConditionalFields","contentTypes","strapi","components","countConditionalFieldsInSchema","schema","pipe","map","flatMap","values","sumBy","attribute","conditions","contentTypeCount","componentCount"],"mappings":";;;;AAGA,MAAMA,4BAA+B,GAAA,IAAA;IACnC,MAAMC,YAAAA,GAA4DC,OAAOD,YAAY;IACrF,MAAME,UAAAA,GAAsDD,OAAOC,UAAU;AAE7E,IAAA,MAAMC,iCAAiC,CACrCC,MAAAA,GAAAA;AAEA,QAAA,OAAOC,QACLC,MAAI,CAAA,YAAA,CAAA,EACJC,UAAQC,CAAAA,SAAAA,CAAAA,EACRC,SAAM,CAACC,SAAAA,GAAAA;AACL,YAAA,IAAIA,UAAUC,UAAU,IAAI,OAAOD,SAAUC,CAAAA,UAAU,KAAK,QAAU,EAAA;gBACpE,OAAO,CAAA;AACT;YACA,OAAO,CAAA;SAETP,CAAAA,CAAAA,CAAAA,MAAAA,CAAAA;AACJ,KAAA;AAEA,IAAA,MAAMQ,mBAAmBT,8BAA+BH,CAAAA,YAAAA,CAAAA;AACxD,IAAA,MAAMa,iBAAiBV,8BAA+BD,CAAAA,UAAAA,CAAAA;AAEtD,IAAA,OAAOU,gBAAmBC,GAAAA,cAAAA;AAC5B;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { pipe, map, flatMap, values, sumBy } from 'lodash/fp';
|
|
2
|
+
|
|
3
|
+
const getNumberOfConditionalFields = ()=>{
|
|
4
|
+
const contentTypes = strapi.contentTypes;
|
|
5
|
+
const components = strapi.components;
|
|
6
|
+
const countConditionalFieldsInSchema = (schema)=>{
|
|
7
|
+
return pipe(map('attributes'), flatMap(values), sumBy((attribute)=>{
|
|
8
|
+
if (attribute.conditions && typeof attribute.conditions === 'object') {
|
|
9
|
+
return 1;
|
|
10
|
+
}
|
|
11
|
+
return 0;
|
|
12
|
+
}))(schema);
|
|
13
|
+
};
|
|
14
|
+
const contentTypeCount = countConditionalFieldsInSchema(contentTypes);
|
|
15
|
+
const componentCount = countConditionalFieldsInSchema(components);
|
|
16
|
+
return contentTypeCount + componentCount;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { getNumberOfConditionalFields as default };
|
|
20
|
+
//# sourceMappingURL=conditional-fields.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditional-fields.mjs","sources":["../../../src/services/utils/conditional-fields.ts"],"sourcesContent":["import { map, values, sumBy, pipe, flatMap } from 'lodash/fp';\nimport type { Schema, UID } from '@strapi/types';\n\nconst getNumberOfConditionalFields = () => {\n const contentTypes: Record<UID.ContentType, Schema.ContentType> = strapi.contentTypes;\n const components: Record<UID.Component, Schema.Component> = strapi.components;\n\n const countConditionalFieldsInSchema = (\n schema: Record<string, Schema.ContentType | Schema.Component>\n ) => {\n return pipe(\n map('attributes'),\n flatMap(values),\n sumBy((attribute: Schema.Attribute.AnyAttribute) => {\n if (attribute.conditions && typeof attribute.conditions === 'object') {\n return 1;\n }\n return 0;\n })\n )(schema);\n };\n\n const contentTypeCount = countConditionalFieldsInSchema(contentTypes);\n const componentCount = countConditionalFieldsInSchema(components);\n\n return contentTypeCount + componentCount;\n};\n\nexport default getNumberOfConditionalFields;\n"],"names":["getNumberOfConditionalFields","contentTypes","strapi","components","countConditionalFieldsInSchema","schema","pipe","map","flatMap","values","sumBy","attribute","conditions","contentTypeCount","componentCount"],"mappings":";;AAGA,MAAMA,4BAA+B,GAAA,IAAA;IACnC,MAAMC,YAAAA,GAA4DC,OAAOD,YAAY;IACrF,MAAME,UAAAA,GAAsDD,OAAOC,UAAU;AAE7E,IAAA,MAAMC,iCAAiC,CACrCC,MAAAA,GAAAA;AAEA,QAAA,OAAOC,KACLC,GAAI,CAAA,YAAA,CAAA,EACJC,OAAQC,CAAAA,MAAAA,CAAAA,EACRC,MAAM,CAACC,SAAAA,GAAAA;AACL,YAAA,IAAIA,UAAUC,UAAU,IAAI,OAAOD,SAAUC,CAAAA,UAAU,KAAK,QAAU,EAAA;gBACpE,OAAO,CAAA;AACT;YACA,OAAO,CAAA;SAETP,CAAAA,CAAAA,CAAAA,MAAAA,CAAAA;AACJ,KAAA;AAEA,IAAA,MAAMQ,mBAAmBT,8BAA+BH,CAAAA,YAAAA,CAAAA;AACxD,IAAA,MAAMa,iBAAiBV,8BAA+BD,CAAAA,UAAAA,CAAAA;AAEtD,IAAA,OAAOU,gBAAmBC,GAAAA,cAAAA;AAC5B;;;;"}
|