@strapi/core 0.0.0-next.69e2ba3406b9409abc96eb4e19c3184ba6e49d98 → 0.0.0-next.6a38f974ec7350286f5c323503fb1e90c54da7ca
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/configuration/index.d.ts +1 -0
- package/dist/configuration/index.d.ts.map +1 -1
- package/dist/configuration/index.js +1 -0
- package/dist/configuration/index.js.map +1 -1
- package/dist/configuration/index.mjs +1 -0
- package/dist/configuration/index.mjs.map +1 -1
- package/dist/configuration/urls.d.ts.map +1 -1
- package/dist/configuration/urls.js +13 -4
- package/dist/configuration/urls.js.map +1 -1
- package/dist/configuration/urls.mjs +13 -4
- package/dist/configuration/urls.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 +128 -0
- package/dist/core-api/routes/validation/utils.js.map +1 -0
- package/dist/core-api/routes/validation/utils.mjs +106 -0
- package/dist/core-api/routes/validation/utils.mjs.map +1 -0
- package/dist/domain/content-type/index.d.ts.map +1 -1
- package/dist/domain/content-type/index.js +17 -1
- package/dist/domain/content-type/index.js.map +1 -1
- package/dist/domain/content-type/index.mjs +17 -1
- package/dist/domain/content-type/index.mjs.map +1 -1
- 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/ee/index.d.ts +6 -0
- package/dist/ee/index.d.ts.map +1 -1
- package/dist/ee/index.js +29 -3
- package/dist/ee/index.js.map +1 -1
- package/dist/ee/index.mjs +30 -4
- package/dist/ee/index.mjs.map +1 -1
- package/dist/ee/license.d.ts +3 -1
- package/dist/ee/license.d.ts.map +1 -1
- package/dist/ee/license.js +8 -2
- package/dist/ee/license.js.map +1 -1
- package/dist/ee/license.mjs +9 -4
- package/dist/ee/license.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/index.js +1 -1
- package/dist/index.mjs +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/migrations/first-published-at.d.ts +4 -0
- package/dist/migrations/first-published-at.d.ts.map +1 -0
- package/dist/migrations/first-published-at.js +51 -0
- package/dist/migrations/first-published-at.js.map +1 -0
- package/dist/migrations/first-published-at.mjs +49 -0
- package/dist/migrations/first-published-at.mjs.map +1 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +5 -0
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/index.mjs +5 -0
- package/dist/migrations/index.mjs.map +1 -1
- package/dist/package.json.js +17 -14
- package/dist/package.json.js.map +1 -1
- package/dist/package.json.mjs +17 -14
- package/dist/package.json.mjs.map +1 -1
- package/dist/services/core-store.d.ts +2 -2
- package/dist/services/core-store.d.ts.map +1 -1
- package/dist/services/core-store.js.map +1 -1
- package/dist/services/core-store.mjs.map +1 -1
- package/dist/services/document-service/entries.d.ts.map +1 -1
- package/dist/services/document-service/entries.js +42 -0
- package/dist/services/document-service/entries.js.map +1 -1
- package/dist/services/document-service/entries.mjs +43 -1
- package/dist/services/document-service/entries.mjs.map +1 -1
- package/dist/services/document-service/first-published-at.d.ts +7 -0
- package/dist/services/document-service/first-published-at.d.ts.map +1 -0
- package/dist/services/document-service/first-published-at.js +31 -0
- package/dist/services/document-service/first-published-at.js.map +1 -0
- package/dist/services/document-service/first-published-at.mjs +28 -0
- package/dist/services/document-service/first-published-at.mjs.map +1 -0
- 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 +12 -8
- package/dist/services/document-service/repository.js.map +1 -1
- package/dist/services/document-service/repository.mjs +13 -9
- 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 +3 -0
- package/dist/services/entity-validator/validators.js.map +1 -1
- package/dist/services/entity-validator/validators.mjs +3 -0
- package/dist/services/entity-validator/validators.mjs.map +1 -1
- package/dist/services/metrics/admin-user-hash.d.ts.map +1 -1
- package/dist/services/metrics/admin-user-hash.js.map +1 -1
- package/dist/services/metrics/admin-user-hash.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 +5 -5
- package/dist/services/metrics/sender.js.map +1 -1
- package/dist/services/metrics/sender.mjs +6 -6
- 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/fetch.d.ts +5 -1
- package/dist/utils/fetch.d.ts.map +1 -1
- package/dist/utils/fetch.js +8 -4
- package/dist/utils/fetch.js.map +1 -1
- package/dist/utils/fetch.mjs +8 -4
- package/dist/utils/fetch.mjs.map +1 -1
- package/dist/utils/transform-content-types-to-models.d.ts +197 -0
- package/dist/utils/transform-content-types-to-models.d.ts.map +1 -1
- package/package.json +17 -14
|
@@ -26,6 +26,9 @@ const createRouteScopeGenerator = (namespace)=>(route)=>{
|
|
|
26
26
|
* @param {import('../../').Strapi} strapi
|
|
27
27
|
*/ const registerAdminRoutes = (strapi)=>{
|
|
28
28
|
const generateRouteScope = createRouteScopeGenerator(`admin::`);
|
|
29
|
+
// Instantiate function-like routers
|
|
30
|
+
// Mutate admin.routes in-place and make sure router factories are instantiated correctly
|
|
31
|
+
strapi.admin.routes = instantiateRouterInputs(strapi.admin.routes, strapi);
|
|
29
32
|
_.forEach(strapi.admin.routes, (router)=>{
|
|
30
33
|
router.type = router.type || 'admin';
|
|
31
34
|
router.prefix = router.prefix || `/admin`;
|
|
@@ -58,9 +61,12 @@ const createRouteScopeGenerator = (namespace)=>(route)=>{
|
|
|
58
61
|
routes: plugin.routes
|
|
59
62
|
});
|
|
60
63
|
} else {
|
|
64
|
+
// Instantiate function-like routers
|
|
65
|
+
// Mutate plugin.routes in-place and make sure router factories are instantiated correctly
|
|
66
|
+
plugin.routes = instantiateRouterInputs(plugin.routes, strapi);
|
|
61
67
|
_.forEach(plugin.routes, (router)=>{
|
|
62
|
-
router.type = router.type
|
|
63
|
-
router.prefix = router.prefix
|
|
68
|
+
router.type = router.type ?? 'admin';
|
|
69
|
+
router.prefix = router.prefix ?? `/${pluginName}`;
|
|
64
70
|
router.routes.forEach((route)=>{
|
|
65
71
|
generateRouteScope(route);
|
|
66
72
|
route.info = {
|
|
@@ -78,6 +84,8 @@ const createRouteScopeGenerator = (namespace)=>(route)=>{
|
|
|
78
84
|
for (const apiName of Object.keys(strapi.apis)){
|
|
79
85
|
const api = strapi.api(apiName);
|
|
80
86
|
const generateRouteScope = createRouteScopeGenerator(`api::${apiName}`);
|
|
87
|
+
// Mutate api.routes in-place and make sure router factories are instantiated correctly
|
|
88
|
+
api.routes = instantiateRouterInputs(api.routes, strapi);
|
|
81
89
|
_.forEach(api.routes, (router)=>{
|
|
82
90
|
// TODO: remove once auth setup
|
|
83
91
|
// pass meta down to compose endpoint
|
|
@@ -92,6 +100,18 @@ const createRouteScopeGenerator = (namespace)=>(route)=>{
|
|
|
92
100
|
});
|
|
93
101
|
}
|
|
94
102
|
};
|
|
103
|
+
const instantiateRouterInputs = (routers, strapi)=>{
|
|
104
|
+
const entries = Object.entries(routers);
|
|
105
|
+
return entries.reduce((record, [key, inputOrCallback])=>{
|
|
106
|
+
const isCallback = typeof inputOrCallback === 'function';
|
|
107
|
+
return {
|
|
108
|
+
...record,
|
|
109
|
+
[key]: isCallback ? inputOrCallback({
|
|
110
|
+
strapi
|
|
111
|
+
}) : inputOrCallback
|
|
112
|
+
};
|
|
113
|
+
}, {});
|
|
114
|
+
};
|
|
95
115
|
|
|
96
116
|
export { registerAllRoutes as default };
|
|
97
117
|
//# sourceMappingURL=register-routes.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-routes.mjs","sources":["../../../src/services/server/register-routes.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Core } from '@strapi/types';\n\nconst createRouteScopeGenerator = (namespace: string) => (route: Core.RouteInput) => {\n const prefix = namespace.endsWith('::') ? namespace : `${namespace}.`;\n\n if (typeof route.handler === 'string') {\n _.defaultsDeep(route, {\n config: {\n auth: {\n scope: [`${route.handler.startsWith(prefix) ? '' : prefix}${route.handler}`],\n },\n },\n });\n }\n};\n\n/**\n * Register all routes\n */\nexport default (strapi: Core.Strapi) => {\n registerAdminRoutes(strapi);\n registerAPIRoutes(strapi);\n registerPluginRoutes(strapi);\n};\n\n/**\n * Register admin routes\n * @param {import('../../').Strapi} strapi\n */\nconst registerAdminRoutes = (strapi: Core.Strapi) => {\n const generateRouteScope = createRouteScopeGenerator(`admin::`);\n\n _.forEach(strapi.admin.routes, (router) => {\n router.type = router.type || 'admin';\n router.prefix = router.prefix || `/admin`;\n router.routes.forEach((route) => {\n generateRouteScope(route);\n route.info = { pluginName: 'admin' };\n });\n strapi.server.routes(router);\n });\n};\n\n/**\n * Register plugin routes\n * @param {import('../../').Strapi} strapi\n */\nconst registerPluginRoutes = (strapi: Core.Strapi) => {\n for (const pluginName of Object.keys(strapi.plugins)) {\n const plugin = strapi.plugins[pluginName];\n\n const generateRouteScope = createRouteScopeGenerator(`plugin::${pluginName}`);\n\n if (Array.isArray(plugin.routes)) {\n plugin.routes.forEach((route) => {\n generateRouteScope(route);\n route.info = { pluginName };\n });\n\n strapi.server.routes({\n type: 'admin',\n prefix: `/${pluginName}`,\n routes: plugin.routes,\n });\n } else {\n _.forEach(plugin.routes, (router) => {\n router.type = router.type
|
|
1
|
+
{"version":3,"file":"register-routes.mjs","sources":["../../../src/services/server/register-routes.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Core } from '@strapi/types';\n\nconst createRouteScopeGenerator = (namespace: string) => (route: Core.RouteInput) => {\n const prefix = namespace.endsWith('::') ? namespace : `${namespace}.`;\n\n if (typeof route.handler === 'string') {\n _.defaultsDeep(route, {\n config: {\n auth: {\n scope: [`${route.handler.startsWith(prefix) ? '' : prefix}${route.handler}`],\n },\n },\n });\n }\n};\n\n/**\n * Register all routes\n */\nexport default (strapi: Core.Strapi) => {\n registerAdminRoutes(strapi);\n registerAPIRoutes(strapi);\n registerPluginRoutes(strapi);\n};\n\n/**\n * Register admin routes\n * @param {import('../../').Strapi} strapi\n */\nconst registerAdminRoutes = (strapi: Core.Strapi) => {\n const generateRouteScope = createRouteScopeGenerator(`admin::`);\n\n // Instantiate function-like routers\n // Mutate admin.routes in-place and make sure router factories are instantiated correctly\n strapi.admin.routes = instantiateRouterInputs(strapi.admin.routes, strapi);\n\n _.forEach(strapi.admin.routes, (router) => {\n router.type = router.type || 'admin';\n router.prefix = router.prefix || `/admin`;\n router.routes.forEach((route) => {\n generateRouteScope(route);\n route.info = { pluginName: 'admin' };\n });\n strapi.server.routes(router);\n });\n};\n\n/**\n * Register plugin routes\n * @param {import('../../').Strapi} strapi\n */\nconst registerPluginRoutes = (strapi: Core.Strapi) => {\n for (const pluginName of Object.keys(strapi.plugins)) {\n const plugin = strapi.plugins[pluginName];\n\n const generateRouteScope = createRouteScopeGenerator(`plugin::${pluginName}`);\n\n if (Array.isArray(plugin.routes)) {\n plugin.routes.forEach((route) => {\n generateRouteScope(route);\n route.info = { pluginName };\n });\n\n strapi.server.routes({\n type: 'admin',\n prefix: `/${pluginName}`,\n routes: plugin.routes,\n });\n } else {\n // Instantiate function-like routers\n // Mutate plugin.routes in-place and make sure router factories are instantiated correctly\n plugin.routes = instantiateRouterInputs(plugin.routes, strapi);\n\n _.forEach(plugin.routes, (router) => {\n router.type = router.type ?? 'admin';\n router.prefix = router.prefix ?? `/${pluginName}`;\n router.routes.forEach((route) => {\n generateRouteScope(route);\n route.info = { pluginName };\n });\n\n strapi.server.routes(router);\n });\n }\n }\n};\n\n/**\n * Register api routes\n */\nconst registerAPIRoutes = (strapi: Core.Strapi) => {\n for (const apiName of Object.keys(strapi.apis)) {\n const api = strapi.api(apiName);\n\n const generateRouteScope = createRouteScopeGenerator(`api::${apiName}`);\n\n // Mutate api.routes in-place and make sure router factories are instantiated correctly\n api.routes = instantiateRouterInputs(api.routes, strapi);\n\n _.forEach(api.routes, (router) => {\n // TODO: remove once auth setup\n // pass meta down to compose endpoint\n router.type = 'content-api';\n router.routes?.forEach((route) => {\n generateRouteScope(route);\n route.info = { apiName };\n });\n\n return strapi.server.routes(router);\n });\n }\n};\n\nconst instantiateRouterInputs = (\n routers: Record<string, Core.RouterConfig>,\n strapi: Core.Strapi\n): Record<string, Core.Router> => {\n const entries = Object.entries(routers);\n\n return entries.reduce((record, [key, inputOrCallback]) => {\n const isCallback = typeof inputOrCallback === 'function';\n\n return { ...record, [key]: isCallback ? inputOrCallback({ strapi }) : inputOrCallback };\n }, {});\n};\n"],"names":["createRouteScopeGenerator","namespace","route","prefix","endsWith","handler","_","defaultsDeep","config","auth","scope","startsWith","strapi","registerAdminRoutes","registerAPIRoutes","registerPluginRoutes","generateRouteScope","admin","routes","instantiateRouterInputs","forEach","router","type","info","pluginName","server","Object","keys","plugins","plugin","Array","isArray","apiName","apis","api","routers","entries","reduce","record","key","inputOrCallback","isCallback"],"mappings":";;AAGA,MAAMA,yBAAAA,GAA4B,CAACC,SAAAA,GAAsB,CAACC,KAAAA,GAAAA;QACxD,MAAMC,MAAAA,GAASF,SAAUG,CAAAA,QA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MAAM,CAACP,MAAM,CAACG,MAAAA,CAAAA;AAC9B,SAAA,CAAA;AACF;AACF,CAAA;AAEA,MAAMF,uBAAAA,GAA0B,CAC9BgB,OACAvB,EAAAA,MAAAA,GAAAA;IAEA,MAAMwB,OAAAA,GAAUV,MAAOU,CAAAA,OAAO,CAACD,OAAAA,CAAAA;AAE/B,IAAA,OAAOC,QAAQC,MAAM,CAAC,CAACC,MAAQ,EAAA,CAACC,KAAKC,eAAgB,CAAA,GAAA;QACnD,MAAMC,UAAAA,GAAa,OAAOD,eAAoB,KAAA,UAAA;QAE9C,OAAO;AAAE,YAAA,GAAGF,MAAM;YAAE,CAACC,GAAAA,GAAME,UAAAA,GAAaD,eAAgB,CAAA;AAAE5B,gBAAAA;aAAY4B,CAAAA,GAAAA;AAAgB,SAAA;AACxF,KAAA,EAAG,EAAC,CAAA;AACN,CAAA;;;;"}
|
|
@@ -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,IAA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A,IAAI,IAAI,EAAE;AACpBT,gBAAAA,IAAAA,EAAMA,IAAQ,IAAA;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,IA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,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;;;;"}
|
|
@@ -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;;;;"}
|
package/dist/utils/fetch.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { Core, Modules } from '@strapi/types';
|
|
2
|
-
|
|
2
|
+
interface StrapiFetchOptions {
|
|
3
|
+
logs?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const createStrapiFetch: (strapi: Core.Strapi, options?: StrapiFetchOptions) => Modules.Fetch.Fetch;
|
|
3
6
|
export type Fetch = Modules.Fetch.Fetch;
|
|
7
|
+
export {};
|
|
4
8
|
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/utils/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/utils/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAKnD,UAAU,kBAAkB;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAGD,eAAO,MAAM,iBAAiB,WACpB,KAAK,MAAM,YACT,kBAAkB,KAC3B,aAAa,MA4Bf,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC"}
|
package/dist/utils/fetch.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var undici = require('undici');
|
|
4
4
|
|
|
5
|
-
// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici
|
|
6
5
|
// Create a wrapper for Node's Fetch API that applies a global proxy
|
|
7
|
-
const createStrapiFetch = (strapi)=>{
|
|
6
|
+
const createStrapiFetch = (strapi, options)=>{
|
|
7
|
+
const { logs = true } = options ?? {};
|
|
8
8
|
function strapiFetch(url, options) {
|
|
9
9
|
const fetchOptions = {
|
|
10
10
|
...strapiFetch.dispatcher ? {
|
|
@@ -12,12 +12,16 @@ const createStrapiFetch = (strapi)=>{
|
|
|
12
12
|
} : {},
|
|
13
13
|
...options
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
if (logs) {
|
|
16
|
+
strapi.log.debug(`Making request for ${url}`);
|
|
17
|
+
}
|
|
16
18
|
return fetch(url, fetchOptions);
|
|
17
19
|
}
|
|
18
20
|
const proxy = strapi.config.get('server.proxy.fetch') || strapi.config.get('server.proxy.global');
|
|
19
21
|
if (proxy) {
|
|
20
|
-
|
|
22
|
+
if (logs) {
|
|
23
|
+
strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);
|
|
24
|
+
}
|
|
21
25
|
strapiFetch.dispatcher = new undici.ProxyAgent(proxy);
|
|
22
26
|
}
|
|
23
27
|
return strapiFetch;
|
package/dist/utils/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sources":["../../src/utils/fetch.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport { ProxyAgent } from 'undici';\n\n// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici\n\n// Create a wrapper for Node's Fetch API that applies a global proxy\nexport const createStrapiFetch = (strapi: Core.Strapi): Modules.Fetch.Fetch => {\n function strapiFetch(url: RequestInfo | URL, options?: RequestInit) {\n const fetchOptions = {\n ...(strapiFetch.dispatcher ? { dispatcher: strapiFetch.dispatcher } : {}),\n ...options,\n };\n strapi.log.debug(`Making request for ${url}`);\n return fetch(url, fetchOptions);\n }\n\n const proxy =\n strapi.config.get<ConstructorParameters<typeof ProxyAgent>[0]>('server.proxy.fetch') ||\n strapi.config.get<string>('server.proxy.global');\n\n if (proxy) {\n strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);\n strapiFetch.dispatcher = new ProxyAgent(proxy);\n }\n\n return strapiFetch;\n};\n\nexport type Fetch = Modules.Fetch.Fetch;\n"],"names":["createStrapiFetch","strapi","
|
|
1
|
+
{"version":3,"file":"fetch.js","sources":["../../src/utils/fetch.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport { ProxyAgent } from 'undici';\n\n// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici\n\ninterface StrapiFetchOptions {\n logs?: boolean;\n}\n\n// Create a wrapper for Node's Fetch API that applies a global proxy\nexport const createStrapiFetch = (\n strapi: Core.Strapi,\n options?: StrapiFetchOptions\n): Modules.Fetch.Fetch => {\n const { logs = true } = options ?? {};\n\n function strapiFetch(url: RequestInfo | URL, options?: RequestInit) {\n const fetchOptions = {\n ...(strapiFetch.dispatcher ? { dispatcher: strapiFetch.dispatcher } : {}),\n ...options,\n };\n\n if (logs) {\n strapi.log.debug(`Making request for ${url}`);\n }\n\n return fetch(url, fetchOptions);\n }\n\n const proxy =\n strapi.config.get<ConstructorParameters<typeof ProxyAgent>[0]>('server.proxy.fetch') ||\n strapi.config.get<string>('server.proxy.global');\n\n if (proxy) {\n if (logs) {\n strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);\n }\n strapiFetch.dispatcher = new ProxyAgent(proxy);\n }\n\n return strapiFetch;\n};\n\nexport type Fetch = Modules.Fetch.Fetch;\n"],"names":["createStrapiFetch","strapi","options","logs","strapiFetch","url","fetchOptions","dispatcher","log","debug","fetch","proxy","config","get","info","ProxyAgent"],"mappings":";;;;AASA;AACO,MAAMA,iBAAoB,GAAA,CAC/BC,MACAC,EAAAA,OAAAA,GAAAA;AAEA,IAAA,MAAM,EAAEC,IAAO,GAAA,IAAI,EAAE,GAAGD,WAAW,EAAC;IAEpC,SAASE,WAAAA,CAAYC,GAAsB,EAAEH,OAAqB,EAAA;AAChE,QAAA,MAAMI,YAAe,GAAA;YACnB,GAAIF,WAAAA,CAAYG,UAAU,GAAG;AAAEA,gBAAAA,UAAAA,EAAYH,YAAYG;AAAW,aAAA,GAAI,EAAE;AACxE,YAAA,GAAGL;AACL,SAAA;AAEA,QAAA,IAAIC,IAAM,EAAA;YACRF,MAAOO,CAAAA,GAAG,CAACC,KAAK,CAAC,CAAC,mBAAmB,EAAEJ,IAAI,CAAC,CAAA;AAC9C;AAEA,QAAA,OAAOK,MAAML,GAAKC,EAAAA,YAAAA,CAAAA;AACpB;IAEA,MAAMK,KAAAA,GACJV,MAAOW,CAAAA,MAAM,CAACC,GAAG,CAA8C,oBAAA,CAAA,IAC/DZ,MAAOW,CAAAA,MAAM,CAACC,GAAG,CAAS,qBAAA,CAAA;AAE5B,IAAA,IAAIF,KAAO,EAAA;AACT,QAAA,IAAIR,IAAM,EAAA;YACRF,MAAOO,CAAAA,GAAG,CAACM,IAAI,CAAC,CAAC,gCAAgC,EAAEH,MAAM,CAAC,CAAA;AAC5D;QACAP,WAAYG,CAAAA,UAAU,GAAG,IAAIQ,iBAAWJ,CAAAA,KAAAA,CAAAA;AAC1C;IAEA,OAAOP,WAAAA;AACT;;;;"}
|
package/dist/utils/fetch.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ProxyAgent } from 'undici';
|
|
2
2
|
|
|
3
|
-
// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici
|
|
4
3
|
// Create a wrapper for Node's Fetch API that applies a global proxy
|
|
5
|
-
const createStrapiFetch = (strapi)=>{
|
|
4
|
+
const createStrapiFetch = (strapi, options)=>{
|
|
5
|
+
const { logs = true } = options ?? {};
|
|
6
6
|
function strapiFetch(url, options) {
|
|
7
7
|
const fetchOptions = {
|
|
8
8
|
...strapiFetch.dispatcher ? {
|
|
@@ -10,12 +10,16 @@ const createStrapiFetch = (strapi)=>{
|
|
|
10
10
|
} : {},
|
|
11
11
|
...options
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
if (logs) {
|
|
14
|
+
strapi.log.debug(`Making request for ${url}`);
|
|
15
|
+
}
|
|
14
16
|
return fetch(url, fetchOptions);
|
|
15
17
|
}
|
|
16
18
|
const proxy = strapi.config.get('server.proxy.fetch') || strapi.config.get('server.proxy.global');
|
|
17
19
|
if (proxy) {
|
|
18
|
-
|
|
20
|
+
if (logs) {
|
|
21
|
+
strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);
|
|
22
|
+
}
|
|
19
23
|
strapiFetch.dispatcher = new ProxyAgent(proxy);
|
|
20
24
|
}
|
|
21
25
|
return strapiFetch;
|
package/dist/utils/fetch.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.mjs","sources":["../../src/utils/fetch.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport { ProxyAgent } from 'undici';\n\n// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici\n\n// Create a wrapper for Node's Fetch API that applies a global proxy\nexport const createStrapiFetch = (strapi: Core.Strapi): Modules.Fetch.Fetch => {\n function strapiFetch(url: RequestInfo | URL, options?: RequestInit) {\n const fetchOptions = {\n ...(strapiFetch.dispatcher ? { dispatcher: strapiFetch.dispatcher } : {}),\n ...options,\n };\n strapi.log.debug(`Making request for ${url}`);\n return fetch(url, fetchOptions);\n }\n\n const proxy =\n strapi.config.get<ConstructorParameters<typeof ProxyAgent>[0]>('server.proxy.fetch') ||\n strapi.config.get<string>('server.proxy.global');\n\n if (proxy) {\n strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);\n strapiFetch.dispatcher = new ProxyAgent(proxy);\n }\n\n return strapiFetch;\n};\n\nexport type Fetch = Modules.Fetch.Fetch;\n"],"names":["createStrapiFetch","strapi","
|
|
1
|
+
{"version":3,"file":"fetch.mjs","sources":["../../src/utils/fetch.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport { ProxyAgent } from 'undici';\n\n// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici\n\ninterface StrapiFetchOptions {\n logs?: boolean;\n}\n\n// Create a wrapper for Node's Fetch API that applies a global proxy\nexport const createStrapiFetch = (\n strapi: Core.Strapi,\n options?: StrapiFetchOptions\n): Modules.Fetch.Fetch => {\n const { logs = true } = options ?? {};\n\n function strapiFetch(url: RequestInfo | URL, options?: RequestInit) {\n const fetchOptions = {\n ...(strapiFetch.dispatcher ? { dispatcher: strapiFetch.dispatcher } : {}),\n ...options,\n };\n\n if (logs) {\n strapi.log.debug(`Making request for ${url}`);\n }\n\n return fetch(url, fetchOptions);\n }\n\n const proxy =\n strapi.config.get<ConstructorParameters<typeof ProxyAgent>[0]>('server.proxy.fetch') ||\n strapi.config.get<string>('server.proxy.global');\n\n if (proxy) {\n if (logs) {\n strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);\n }\n strapiFetch.dispatcher = new ProxyAgent(proxy);\n }\n\n return strapiFetch;\n};\n\nexport type Fetch = Modules.Fetch.Fetch;\n"],"names":["createStrapiFetch","strapi","options","logs","strapiFetch","url","fetchOptions","dispatcher","log","debug","fetch","proxy","config","get","info","ProxyAgent"],"mappings":";;AASA;AACO,MAAMA,iBAAoB,GAAA,CAC/BC,MACAC,EAAAA,OAAAA,GAAAA;AAEA,IAAA,MAAM,EAAEC,IAAO,GAAA,IAAI,EAAE,GAAGD,WAAW,EAAC;IAEpC,SAASE,WAAAA,CAAYC,GAAsB,EAAEH,OAAqB,EAAA;AAChE,QAAA,MAAMI,YAAe,GAAA;YACnB,GAAIF,WAAAA,CAAYG,UAAU,GAAG;AAAEA,gBAAAA,UAAAA,EAAYH,YAAYG;AAAW,aAAA,GAAI,EAAE;AACxE,YAAA,GAAGL;AACL,SAAA;AAEA,QAAA,IAAIC,IAAM,EAAA;YACRF,MAAOO,CAAAA,GAAG,CAACC,KAAK,CAAC,CAAC,mBAAmB,EAAEJ,IAAI,CAAC,CAAA;AAC9C;AAEA,QAAA,OAAOK,MAAML,GAAKC,EAAAA,YAAAA,CAAAA;AACpB;IAEA,MAAMK,KAAAA,GACJV,MAAOW,CAAAA,MAAM,CAACC,GAAG,CAA8C,oBAAA,CAAA,IAC/DZ,MAAOW,CAAAA,MAAM,CAACC,GAAG,CAAS,qBAAA,CAAA;AAE5B,IAAA,IAAIF,KAAO,EAAA;AACT,QAAA,IAAIR,IAAM,EAAA;YACRF,MAAOO,CAAAA,GAAG,CAACM,IAAI,CAAC,CAAC,gCAAgC,EAAEH,MAAM,CAAC,CAAA;AAC5D;QACAP,WAAYG,CAAAA,UAAU,GAAG,IAAIQ,UAAWJ,CAAAA,KAAAA,CAAAA;AAC1C;IAEA,OAAOP,WAAAA;AACT;;;;"}
|