@strapi/strapi 4.25.2 → 4.25.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/Strapi.js +3 -3
  2. package/dist/Strapi.js.map +1 -1
  3. package/dist/commands/actions/routes/list/action.js +2 -2
  4. package/dist/commands/actions/routes/list/action.js.map +1 -1
  5. package/dist/commands/utils/helpers.js +2 -2
  6. package/dist/commands/utils/helpers.js.map +1 -1
  7. package/dist/core/app-configuration/index.js +2 -2
  8. package/dist/core/app-configuration/index.js.map +1 -1
  9. package/dist/core/domain/content-type/index.js +4 -4
  10. package/dist/core/domain/content-type/index.js.map +1 -1
  11. package/dist/core/loaders/apis.js +2 -2
  12. package/dist/core/loaders/apis.js.map +1 -1
  13. package/dist/core/loaders/plugins/get-enabled-plugins.js +8 -8
  14. package/dist/core/loaders/plugins/get-enabled-plugins.js.map +1 -1
  15. package/dist/core/loaders/plugins/get-user-plugins-config.js +2 -2
  16. package/dist/core/loaders/plugins/get-user-plugins-config.js.map +1 -1
  17. package/dist/core/loaders/plugins/index.js +6 -6
  18. package/dist/core/loaders/plugins/index.js.map +1 -1
  19. package/dist/core/registries/apis.js +2 -2
  20. package/dist/core/registries/apis.js.map +1 -1
  21. package/dist/core/registries/content-types.js +3 -3
  22. package/dist/core/registries/content-types.js.map +1 -1
  23. package/dist/core/registries/controllers.js +3 -3
  24. package/dist/core/registries/controllers.js.map +1 -1
  25. package/dist/core/registries/custom-fields.js +4 -4
  26. package/dist/core/registries/custom-fields.js.map +1 -1
  27. package/dist/core/registries/hooks.js +2 -2
  28. package/dist/core/registries/hooks.js.map +1 -1
  29. package/dist/core/registries/middlewares.js +3 -3
  30. package/dist/core/registries/middlewares.js.map +1 -1
  31. package/dist/core/registries/modules.js +3 -3
  32. package/dist/core/registries/modules.js.map +1 -1
  33. package/dist/core/registries/plugins.js +2 -2
  34. package/dist/core/registries/plugins.js.map +1 -1
  35. package/dist/core/registries/policies.js +3 -3
  36. package/dist/core/registries/policies.js.map +1 -1
  37. package/dist/core/registries/services.js +3 -3
  38. package/dist/core/registries/services.js.map +1 -1
  39. package/dist/core-api/controller/collection-type.js +3 -3
  40. package/dist/core-api/controller/collection-type.js.map +1 -1
  41. package/dist/core-api/controller/index.js +2 -2
  42. package/dist/core-api/controller/index.js.map +1 -1
  43. package/dist/core-api/controller/single-type.js +2 -2
  44. package/dist/core-api/controller/single-type.js.map +1 -1
  45. package/dist/core-api/controller/transform.js +7 -7
  46. package/dist/core-api/controller/transform.js.map +1 -1
  47. package/dist/core-api/service/collection-type.js +2 -2
  48. package/dist/core-api/service/collection-type.js.map +1 -1
  49. package/dist/core-api/service/pagination.js +10 -10
  50. package/dist/core-api/service/pagination.js.map +1 -1
  51. package/dist/core-api/service/single-type.js +2 -2
  52. package/dist/core-api/service/single-type.js.map +1 -1
  53. package/dist/ee/index.js +3 -3
  54. package/dist/ee/index.js.map +1 -1
  55. package/dist/factories.js +4 -4
  56. package/dist/factories.js.map +1 -1
  57. package/dist/load/filepath-to-prop-path.d.ts +1 -1
  58. package/dist/load/filepath-to-prop-path.d.ts.map +1 -1
  59. package/dist/load/filepath-to-prop-path.js +27 -6
  60. package/dist/load/filepath-to-prop-path.js.map +1 -1
  61. package/dist/load/filepath-to-prop-path.mjs +25 -5
  62. package/dist/load/filepath-to-prop-path.mjs.map +1 -1
  63. package/dist/load/load-files.js +2 -2
  64. package/dist/load/load-files.js.map +1 -1
  65. package/dist/load/load-files.mjs +2 -2
  66. package/dist/load/load-files.mjs.map +1 -1
  67. package/dist/middlewares/body.js +2 -2
  68. package/dist/middlewares/body.js.map +1 -1
  69. package/dist/middlewares/public/index.js +4 -4
  70. package/dist/middlewares/public/index.js.map +1 -1
  71. package/dist/middlewares/responses.js +2 -2
  72. package/dist/middlewares/responses.js.map +1 -1
  73. package/dist/middlewares/security.js +3 -3
  74. package/dist/middlewares/security.js.map +1 -1
  75. package/dist/middlewares/session.js +2 -2
  76. package/dist/middlewares/session.js.map +1 -1
  77. package/dist/services/auth/index.js +3 -3
  78. package/dist/services/auth/index.js.map +1 -1
  79. package/dist/services/core-store.js +3 -3
  80. package/dist/services/core-store.js.map +1 -1
  81. package/dist/services/cron.js +3 -3
  82. package/dist/services/cron.js.map +1 -1
  83. package/dist/services/entity-service/attributes/transforms.js +3 -3
  84. package/dist/services/entity-service/attributes/transforms.js.map +1 -1
  85. package/dist/services/entity-service/components.js +18 -18
  86. package/dist/services/entity-service/components.js.map +1 -1
  87. package/dist/services/entity-service/params.js +2 -2
  88. package/dist/services/entity-service/params.js.map +1 -1
  89. package/dist/services/entity-validator/index.js +19 -19
  90. package/dist/services/entity-validator/index.js.map +1 -1
  91. package/dist/services/server/compose-endpoint.js +7 -7
  92. package/dist/services/server/compose-endpoint.js.map +1 -1
  93. package/dist/services/server/koa.js +3 -3
  94. package/dist/services/server/koa.js.map +1 -1
  95. package/dist/services/server/middleware.js +3 -3
  96. package/dist/services/server/middleware.js.map +1 -1
  97. package/dist/services/server/routing.js +2 -2
  98. package/dist/services/server/routing.js.map +1 -1
  99. package/dist/services/utils/dynamic-zones.js +5 -5
  100. package/dist/services/utils/dynamic-zones.js.map +1 -1
  101. package/dist/utils/cron.js +3 -3
  102. package/dist/utils/cron.js.map +1 -1
  103. package/dist/utils/is-initialized.js +3 -3
  104. package/dist/utils/is-initialized.js.map +1 -1
  105. package/dist/utils/startup-logger.js +4 -4
  106. package/dist/utils/startup-logger.js.map +1 -1
  107. package/dist/utils/startup-logger.mjs +3 -3
  108. package/dist/utils/startup-logger.mjs.map +1 -1
  109. package/package.json +21 -21
  110. package/dist/load/glob.d.ts +0 -7
  111. package/dist/load/glob.d.ts.map +0 -1
  112. package/dist/load/glob.js +0 -15
  113. package/dist/load/glob.js.map +0 -1
  114. package/dist/load/glob.mjs +0 -14
  115. package/dist/load/glob.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/core/loaders/plugins/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { defaultsDeep, defaults, getOr, get } from 'lodash/fp';\nimport { env } from '@strapi/utils';\nimport type { Strapi, Plugin } from '@strapi/types';\nimport { loadFile } from '../../app-configuration/load-config-file';\nimport loadFiles from '../../../load/load-files';\nimport { getEnabledPlugins } from './get-enabled-plugins';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface Plugins {\n [key: string]: Plugin.LoadedPlugin;\n}\n\nconst defaultPlugin = {\n bootstrap() {},\n destroy() {},\n register() {},\n config: {\n default: {},\n validator() {},\n },\n routes: [],\n controllers: {},\n services: {},\n policies: {},\n middlewares: {},\n contentTypes: {},\n};\n\nconst applyUserExtension = async (plugins: Plugins) => {\n const extensionsDir = strapi.dirs.dist.extensions;\n if (!(await fse.pathExists(extensionsDir))) {\n return;\n }\n\n const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');\n const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n // first: load json schema\n for (const ctName of Object.keys(plugin.contentTypes)) {\n const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);\n if (extendedSchema) {\n plugin.contentTypes[ctName].schema = {\n ...plugin.contentTypes[ctName].schema,\n ...extendedSchema,\n };\n }\n }\n // second: execute strapi-server extension\n const strapiServer = get([pluginName, 'strapi-server'], strapiServers);\n if (strapiServer) {\n plugins[pluginName] = await strapiServer(plugin);\n }\n }\n};\n\nconst applyUserConfig = async (plugins: Plugins) => {\n const userPluginsConfig = await getUserPluginsConfig();\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);\n const defaultConfig =\n typeof plugin.config.default === 'function'\n ? plugin.config.default({ env })\n : plugin.config.default;\n\n const config = defaultsDeep(defaultConfig, userPluginConfig);\n try {\n plugin.config.validator(config);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error regarding ${pluginName} config: ${e.message}`);\n }\n\n throw e;\n }\n plugin.config = config;\n }\n};\n\nexport default async function loadPlugins(strapi: Strapi) {\n const plugins: Plugins = {};\n\n const enabledPlugins = await getEnabledPlugins(strapi);\n\n strapi.config.set('enabledPlugins', enabledPlugins);\n\n for (const pluginName of Object.keys(enabledPlugins)) {\n const enabledPlugin = enabledPlugins[pluginName];\n\n let serverEntrypointPath;\n\n try {\n serverEntrypointPath = join(enabledPlugin.pathToPlugin, 'strapi-server.js');\n } catch (e) {\n throw new Error(\n `Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove it's configuration.`\n );\n }\n\n // only load plugins with a server entrypoint\n if (!(await fse.pathExists(serverEntrypointPath))) {\n continue;\n }\n\n const pluginServer = loadFile(serverEntrypointPath);\n plugins[pluginName] = {\n ...defaultPlugin,\n ...pluginServer,\n config: defaults(defaultPlugin.config, pluginServer.config),\n routes: pluginServer.routes ?? defaultPlugin.routes,\n };\n }\n\n // TODO: validate plugin format\n await applyUserConfig(plugins);\n await applyUserExtension(plugins);\n\n for (const pluginName of Object.keys(plugins)) {\n strapi.container.get('plugins').add(pluginName, plugins[pluginName]);\n }\n}\n"],"names":["fse","get","getUserPluginsConfig","getOr","env","defaultsDeep","strapi","getEnabledPlugins","join","loadFile","defaults"],"mappings":";;;;;;;;;;;AAcA,MAAM,gBAAgB;AAAA,EACpB,YAAY;AAAA,EAAC;AAAA,EACb,UAAU;AAAA,EAAC;AAAA,EACX,WAAW;AAAA,EAAC;AAAA,EACZ,QAAQ;AAAA,IACN,SAAS,CAAC;AAAA,IACV,YAAY;AAAA,IAAC;AAAA,EACf;AAAA,EACA,QAAQ,CAAC;AAAA,EACT,aAAa,CAAC;AAAA,EACd,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,aAAa,CAAC;AAAA,EACd,cAAc,CAAC;AACjB;AAEA,MAAM,qBAAqB,OAAO,YAAqB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,EAAE;AAAA,MACtE;AAEM,YAAA;AAAA,IACR;AACA,WAAO,SAAS;AAAA,EAClB;AACF;AAEA,eAA8B,YAAYC,SAAgB;AACxD,QAAM,UAAmB,CAAA;AAEnB,QAAA,iBAAiB,MAAMC,oCAAkBD,OAAM;AAErDA,UAAO,OAAO,IAAI,kBAAkB,cAAc;AAElD,aAAW,cAAc,OAAO,KAAK,cAAc,GAAG;AAC9C,UAAA,gBAAgB,eAAe,UAAU;AAE3C,QAAA;AAEA,QAAA;AACqB,6BAAAE,KAAAA,KAAK,cAAc,cAAc,kBAAkB;AAAA,aACnE,GAAG;AACV,YAAM,IAAI;AAAA,QACR,4BAA4B,UAAU,YAAY,UAAU;AAAA,MAAA;AAAA,IAEhE;AAGA,QAAI,CAAE,MAAMR,aAAAA,QAAI,WAAW,oBAAoB,GAAI;AACjD;AAAA,IACF;AAEM,UAAA,eAAeS,wBAAS,oBAAoB;AAClD,YAAQ,UAAU,IAAI;AAAA,MACpB,GAAG;AAAA,MACH,GAAG;AAAA,MACH,QAAQC,EAAAA,SAAS,cAAc,QAAQ,aAAa,MAAM;AAAA,MAC1D,QAAQ,aAAa,UAAU,cAAc;AAAA,IAAA;AAAA,EAEjD;AAGA,QAAM,gBAAgB,OAAO;AAC7B,QAAM,mBAAmB,OAAO;AAEhC,aAAW,cAAc,OAAO,KAAK,OAAO,GAAG;AAC7CJ,YAAO,UAAU,IAAI,SAAS,EAAE,IAAI,YAAY,QAAQ,UAAU,CAAC;AAAA,EACrE;AACF;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/core/loaders/plugins/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { defaultsDeep, defaults, getOr, get } from 'lodash/fp';\nimport { env } from '@strapi/utils';\nimport type { Strapi, Plugin } from '@strapi/types';\nimport { loadFile } from '../../app-configuration/load-config-file';\nimport loadFiles from '../../../load/load-files';\nimport { getEnabledPlugins } from './get-enabled-plugins';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface Plugins {\n [key: string]: Plugin.LoadedPlugin;\n}\n\nconst defaultPlugin = {\n bootstrap() {},\n destroy() {},\n register() {},\n config: {\n default: {},\n validator() {},\n },\n routes: [],\n controllers: {},\n services: {},\n policies: {},\n middlewares: {},\n contentTypes: {},\n};\n\nconst applyUserExtension = async (plugins: Plugins) => {\n const extensionsDir = strapi.dirs.dist.extensions;\n if (!(await fse.pathExists(extensionsDir))) {\n return;\n }\n\n const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');\n const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n // first: load json schema\n for (const ctName of Object.keys(plugin.contentTypes)) {\n const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);\n if (extendedSchema) {\n plugin.contentTypes[ctName].schema = {\n ...plugin.contentTypes[ctName].schema,\n ...extendedSchema,\n };\n }\n }\n // second: execute strapi-server extension\n const strapiServer = get([pluginName, 'strapi-server'], strapiServers);\n if (strapiServer) {\n plugins[pluginName] = await strapiServer(plugin);\n }\n }\n};\n\nconst applyUserConfig = async (plugins: Plugins) => {\n const userPluginsConfig = await getUserPluginsConfig();\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);\n const defaultConfig =\n typeof plugin.config.default === 'function'\n ? plugin.config.default({ env })\n : plugin.config.default;\n\n const config = defaultsDeep(defaultConfig, userPluginConfig);\n try {\n plugin.config.validator(config);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error regarding ${pluginName} config: ${e.message}`);\n }\n\n throw e;\n }\n plugin.config = config;\n }\n};\n\nexport default async function loadPlugins(strapi: Strapi) {\n const plugins: Plugins = {};\n\n const enabledPlugins = await getEnabledPlugins(strapi);\n\n strapi.config.set('enabledPlugins', enabledPlugins);\n\n for (const pluginName of Object.keys(enabledPlugins)) {\n const enabledPlugin = enabledPlugins[pluginName];\n\n let serverEntrypointPath;\n\n try {\n serverEntrypointPath = join(enabledPlugin.pathToPlugin, 'strapi-server.js');\n } catch (e) {\n throw new Error(\n `Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove it's configuration.`\n );\n }\n\n // only load plugins with a server entrypoint\n if (!(await fse.pathExists(serverEntrypointPath))) {\n continue;\n }\n\n const pluginServer = loadFile(serverEntrypointPath);\n plugins[pluginName] = {\n ...defaultPlugin,\n ...pluginServer,\n config: defaults(defaultPlugin.config, pluginServer.config),\n routes: pluginServer.routes ?? defaultPlugin.routes,\n };\n }\n\n // TODO: validate plugin format\n await applyUserConfig(plugins);\n await applyUserExtension(plugins);\n\n for (const pluginName of Object.keys(plugins)) {\n strapi.container.get('plugins').add(pluginName, plugins[pluginName]);\n }\n}\n"],"names":["fse","get","getUserPluginsConfig","getOr","env","defaultsDeep","strapi","getEnabledPlugins","join","loadFile","defaults"],"mappings":";;;;;;;;;;;AAcA,MAAM,gBAAgB;AAAA,EACpB,YAAY;AAAA,EAAC;AAAA,EACb,UAAU;AAAA,EAAC;AAAA,EACX,WAAW;AAAA,EAAC;AAAA,EACZ,QAAQ;AAAA,IACN,SAAS,CAAC;AAAA,IACV,YAAY;AAAA,IAAC;AAAA,EACf;AAAA,EACA,QAAQ,CAAC;AAAA,EACT,aAAa,CAAC;AAAA,EACd,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,aAAa,CAAC;AAAA,EACd,cAAc,CAAC;AACjB;AAEA,MAAM,qBAAqB,OAAO,YAAqB;AAC/C,QAAA,gBAAgB,OAAO,KAAK,KAAK;AACvC,MAAI,CAAE,MAAMA,aAAAA,QAAI,WAAW,aAAa,GAAI;AAC1C;AAAA,EACF;AAEA,QAAM,kBAAkB,MAAM,UAAU,eAAe,iCAAiC;AACxF,QAAM,gBAAgB,MAAM,UAAU,eAAe,qBAAqB;AAE1E,aAAW,cAAc,OAAO,KAA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AAK,cAAc,GAAG;AAC9C,UAAA,gBAAgB,eAAe,UAAU;AAE3C,QAAA;AAEA,QAAA;AACqB,6BAAAE,KAAAA,KAAK,cAAc,cAAc,kBAAkB;AAAA,aACnE,GAAG;AACV,YAAM,IAAI;AAAA,QACR,4BAA4B,UAAU,YAAY,UAAU;AAAA,MAAA;AAAA,IAEhE;AAGA,QAAI,CAAE,MAAMR,aAAAA,QAAI,WAAW,oBAAoB,GAAI;AACjD;AAAA,IACF;AAEM,UAAA,eAAeS,wBAAS,oBAAoB;AAClD,YAAQ,UAAU,IAAI;AAAA,MACpB,GAAG;AAAA,MACH,GAAG;AAAA,MACH,QAAQC,GAAAA,SAAS,cAAc,QAAQ,aAAa,MAAM;AAAA,MAC1D,QAAQ,aAAa,UAAU,cAAc;AAAA,IAAA;AAAA,EAEjD;AAGA,QAAM,gBAAgB,OAAO;AAC7B,QAAM,mBAAmB,OAAO;AAEhC,aAAW,cAAc,OAAO,KAAK,OAAO,GAAG;AAC7CJ,YAAO,UAAU,IAAI,SAAS,EAAE,IAAI,YAAY,QAAQ,UAAU,CAAC;AAAA,EACrE;AACF;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const apisRegistry = (strapi) => {
4
4
  const apis = {};
5
5
  return {
@@ -10,7 +10,7 @@ const apisRegistry = (strapi) => {
10
10
  return apis;
11
11
  },
12
12
  add(apiName, apiConfig) {
13
- if (_.has(apiName, apis)) {
13
+ if (fp.has(apiName, apis)) {
14
14
  throw new Error(`API ${apiName} has already been registered.`);
15
15
  }
16
16
  const api = strapi.container.get("modules").add(`api::${apiName}`, apiConfig);
@@ -1 +1 @@
1
- {"version":3,"file":"apis.js","sources":["../../../src/core/registries/apis.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Strapi } from '@strapi/types';\n\nconst apisRegistry = (strapi: Strapi) => {\n const apis: Record<string, unknown> = {};\n\n return {\n get(name: string) {\n return apis[name];\n },\n getAll() {\n return apis;\n },\n add(apiName: string, apiConfig: unknown) {\n if (has(apiName, apis)) {\n throw new Error(`API ${apiName} has already been registered.`);\n }\n\n const api = strapi.container.get('modules').add(`api::${apiName}`, apiConfig);\n\n apis[apiName] = api;\n\n return apis[apiName];\n },\n };\n};\n\nexport default apisRegistry;\n"],"names":["has"],"mappings":";;AAGM,MAAA,eAAe,CAAC,WAAmB;AACvC,QAAM,OAAgC,CAAA;AAE/B,SAAA;AAAA,IACL,IAAI,MAAc;AAChB,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,IACA,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,SAAiB,WAAoB;AACnC,UAAAA,EAAA,IAAI,SAAS,IAAI,GAAG;AACtB,cAAM,IAAI,MAAM,OAAO,OAAO,+BAA+B;AAAA,MAC/D;AAEM,YAAA,MAAM,OAAO,UAAU,IAAI,SAAS,EAAE,IAAI,QAAQ,OAAO,IAAI,SAAS;AAE5E,WAAK,OAAO,IAAI;AAEhB,aAAO,KAAK,OAAO;AAAA,IACrB;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"apis.js","sources":["../../../src/core/registries/apis.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Strapi } from '@strapi/types';\n\nconst apisRegistry = (strapi: Strapi) => {\n const apis: Record<string, unknown> = {};\n\n return {\n get(name: string) {\n return apis[name];\n },\n getAll() {\n return apis;\n },\n add(apiName: string, apiConfig: unknown) {\n if (has(apiName, apis)) {\n throw new Error(`API ${apiName} has already been registered.`);\n }\n\n const api = strapi.container.get('modules').add(`api::${apiName}`, apiConfig);\n\n apis[apiName] = api;\n\n return apis[apiName];\n },\n };\n};\n\nexport default apisRegistry;\n"],"names":["has"],"mappings":";;AAGM,MAAA,eAAe,CAAC,WAAmB;AACvC,QAAM,OAAgC,CAAA;AAE/B,SAAA;AAAA,IACL,IAAI,MAAc;AAChB,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,IACA,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,SAAiB,WAAoB;AACnC,UAAAA,GAAA,IAAI,SAAS,IAAI,GAAG;AACtB,cAAM,IAAI,MAAM,OAAO,OAAO,+BAA+B;AAAA,MAC/D;AAEM,YAAA,MAAM,OAAO,UAAU,IAAI,SAAS,EAAE,IAAI,QAAQ,OAAO,IAAI,SAAS;AAE5E,WAAK,OAAO,IAAI;AAEhB,aAAO,KAAK,OAAO;AAAA,IACrB;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const index = require("../domain/content-type/index.js");
4
4
  const utils = require("../utils.js");
5
5
  const validateKeySameToSingularName = (contentTypes) => {
@@ -31,7 +31,7 @@ const contentTypesRegistry = () => {
31
31
  * Returns a map with all the contentTypes in a namespace
32
32
  */
33
33
  getAll(namespace) {
34
- return _.pickBy((_2, uid) => utils.hasNamespace(uid, namespace))(contentTypes);
34
+ return fp.pickBy((_, uid) => utils.hasNamespace(uid, namespace))(contentTypes);
35
35
  },
36
36
  /**
37
37
  * Registers a contentType
@@ -47,7 +47,7 @@ const contentTypesRegistry = () => {
47
47
  validateKeySameToSingularName(newContentTypes);
48
48
  for (const rawCtName of Object.keys(newContentTypes)) {
49
49
  const uid = utils.addNamespace(rawCtName, namespace);
50
- if (_.has(uid, contentTypes)) {
50
+ if (fp.has(uid, contentTypes)) {
51
51
  throw new Error(`Content-type ${uid} has already been registered.`);
52
52
  }
53
53
  contentTypes[uid] = index.createContentType(uid, newContentTypes[rawCtName]);
@@ -1 +1 @@
1
- {"version":3,"file":"content-types.js","sources":["../../../src/core/registries/content-types.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Common, Schema } from '@strapi/types';\nimport { createContentType, ContentTypeDefinition } from '../domain/content-type';\nimport { addNamespace, hasNamespace } from '../utils';\n\ntype ContentTypesInput = Record<string, ContentTypeDefinition>;\ntype ContentTypeExtendFn = (contentType: Schema.ContentType) => Schema.ContentType;\n\nconst validateKeySameToSingularName = (contentTypes: ContentTypesInput) => {\n for (const ctName of Object.keys(contentTypes)) {\n const contentType = contentTypes[ctName];\n\n if (ctName !== contentType.schema.info.singularName) {\n throw new Error(\n `The key of the content-type should be the same as its singularName. Found ${ctName} and ${contentType.schema.info.singularName}.`\n );\n }\n }\n};\n\nconst contentTypesRegistry = () => {\n const contentTypes: Record<string, Schema.ContentType> = {};\n\n return {\n /**\n * Returns this list of registered contentTypes uids\n */\n keys() {\n return Object.keys(contentTypes);\n },\n\n /**\n * Returns the instance of a contentType. Instantiate the contentType if not already done\n */\n get(uid: Common.UID.ContentType) {\n return contentTypes[uid];\n },\n\n /**\n * Returns a map with all the contentTypes in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(contentTypes);\n },\n\n /**\n * Registers a contentType\n */\n set(uid: Common.UID.ContentType, contentType: Schema.ContentType) {\n contentTypes[uid] = contentType;\n return this;\n },\n\n /**\n * Registers a map of contentTypes for a specific namespace\n */\n add(namespace: string, newContentTypes: ContentTypesInput) {\n validateKeySameToSingularName(newContentTypes);\n\n for (const rawCtName of Object.keys(newContentTypes)) {\n const uid = addNamespace(rawCtName, namespace);\n\n if (has(uid, contentTypes)) {\n throw new Error(`Content-type ${uid} has already been registered.`);\n }\n\n contentTypes[uid] = createContentType(uid, newContentTypes[rawCtName]);\n }\n },\n\n /**\n * Wraps a contentType to extend it\n */\n extend(ctUID: Common.UID.ContentType, extendFn: ContentTypeExtendFn) {\n const currentContentType = this.get(ctUID);\n\n if (!currentContentType) {\n throw new Error(`Content-Type ${ctUID} doesn't exist`);\n }\n\n const newContentType = extendFn(currentContentType);\n contentTypes[ctUID] = newContentType;\n\n return this;\n },\n };\n};\n\nexport default contentTypesRegistry;\n"],"names":["pickBy","_","hasNamespace","addNamespace","has","createContentType"],"mappings":";;;;AAQA,MAAM,gCAAgC,CAAC,iBAAo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AEM,YAAA,iBAAiB,SAAS,kBAAkB;AAClD,mBAAa,KAAK,IAAI;AAEf,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"content-types.js","sources":["../../../src/core/registries/content-types.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Common, Schema } from '@strapi/types';\nimport { createContentType, ContentTypeDefinition } from '../domain/content-type';\nimport { addNamespace, hasNamespace } from '../utils';\n\ntype ContentTypesInput = Record<string, ContentTypeDefinition>;\ntype ContentTypeExtendFn = (contentType: Schema.ContentType) => Schema.ContentType;\n\nconst validateKeySameToSingularName = (contentTypes: ContentTypesInput) => {\n for (const ctName of Object.keys(contentTypes)) {\n const contentType = contentTypes[ctName];\n\n if (ctName !== contentType.schema.info.singularName) {\n throw new Error(\n `The key of the content-type should be the same as its singularName. Found ${ctName} and ${contentType.schema.info.singularName}.`\n );\n }\n }\n};\n\nconst contentTypesRegistry = () => {\n const contentTypes: Record<string, Schema.ContentType> = {};\n\n return {\n /**\n * Returns this list of registered contentTypes uids\n */\n keys() {\n return Object.keys(contentTypes);\n },\n\n /**\n * Returns the instance of a contentType. Instantiate the contentType if not already done\n */\n get(uid: Common.UID.ContentType) {\n return contentTypes[uid];\n },\n\n /**\n * Returns a map with all the contentTypes in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(contentTypes);\n },\n\n /**\n * Registers a contentType\n */\n set(uid: Common.UID.ContentType, contentType: Schema.ContentType) {\n contentTypes[uid] = contentType;\n return this;\n },\n\n /**\n * Registers a map of contentTypes for a specific namespace\n */\n add(namespace: string, newContentTypes: ContentTypesInput) {\n validateKeySameToSingularName(newContentTypes);\n\n for (const rawCtName of Object.keys(newContentTypes)) {\n const uid = addNamespace(rawCtName, namespace);\n\n if (has(uid, contentTypes)) {\n throw new Error(`Content-type ${uid} has already been registered.`);\n }\n\n contentTypes[uid] = createContentType(uid, newContentTypes[rawCtName]);\n }\n },\n\n /**\n * Wraps a contentType to extend it\n */\n extend(ctUID: Common.UID.ContentType, extendFn: ContentTypeExtendFn) {\n const currentContentType = this.get(ctUID);\n\n if (!currentContentType) {\n throw new Error(`Content-Type ${ctUID} doesn't exist`);\n }\n\n const newContentType = extendFn(currentContentType);\n contentTypes[ctUID] = newContentType;\n\n return this;\n },\n };\n};\n\nexport default contentTypesRegistry;\n"],"names":["pickBy","hasNamespace","addNamespace","has","createContentType"],"mappings":";;;;AAQA,MAAM,gCAAgC,CAAC,iBAAoC;AACzE,aAAW,UAAU,OAAO,KAAK,YAAY,GAAG;AACxC,UAAA,cAAc,aAAa,MAAM;AAEvC,QAAI,WAAW,YAAY,OAAO,KAAK,cAAc;AACnD,YAAM,IAAI;AAAA,QACR,6EAA6E,MAAM,QAAQ,YAAY,OAAO,KAAK,YAAY;AAAA,MAAA;AAAA,IAEnI;AAAA,EACF;AACF;AAEA,MAAM,uBAAuB,MAAM;AACjC,QAAM,eAAmD,CAAA;AAElD,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,YAAY;AAAA,IACjC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAA6B;AAC/B,aAAO,aAAa,GAAG;AAAA,IACzB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,WAAmB;AACjB,aAAAA,GAAA,OAAO,CAAC,GAAG,QAAQC,MAAAA,aAAa,KAAK,SAAS,CAAC,EAAE,YAAY;AAAA,IACtE;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAA6B,aAAiC;AAChE,mBAAa,GAAG,IAAI;AACb,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,WAAmB,iBAAoC;AACzD,oCAA8B,eAAe;AAE7C,iBAAW,aAAa,OAAO,KAAK,eAAe,GAAG;AAC9C,cAAA,MAAMC,MAAAA,aAAa,WAAW,SAAS;AAEzC,YAAAC,GAAA,IAAI,KAAK,YAAY,GAAG;AAC1B,gBAAM,IAAI,MAAM,gBAAgB,GAAG,+BAA+B;AAAA,QACpE;AAEA,qBAAa,GAAG,IAAIC,MAAA,kBAAkB,KAAK,gBAAgB,SAAS,CAAC;AAAA,MACvE;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,OAA+B,UAA+B;AAC7D,YAAA,qBAAqB,KAAK,IAAI,KAAK;AAEzC,UAAI,CAAC,oBAAoB;AACvB,cAAM,IAAI,MAAM,gBAAgB,KAAK,gBAAgB;AAAA,MACvD;AAEM,YAAA,iBAAiB,SAAS,kBAAkB;AAClD,mBAAa,KAAK,IAAI;AAEf,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const utils = require("../utils.js");
4
4
  const controllersRegistry = (strapi) => {
5
5
  const controllers = {};
@@ -28,7 +28,7 @@ const controllersRegistry = (strapi) => {
28
28
  * Returns a map with all the controller in a namespace
29
29
  */
30
30
  getAll(namespace) {
31
- const filteredControllers = _.pickBy((_2, uid) => utils.hasNamespace(uid, namespace))(controllers);
31
+ const filteredControllers = fp.pickBy((_, uid) => utils.hasNamespace(uid, namespace))(controllers);
32
32
  const map = {};
33
33
  for (const uid of Object.keys(filteredControllers)) {
34
34
  Object.defineProperty(map, uid, {
@@ -55,7 +55,7 @@ const controllersRegistry = (strapi) => {
55
55
  for (const controllerName of Object.keys(newControllers)) {
56
56
  const controller = newControllers[controllerName];
57
57
  const uid = utils.addNamespace(controllerName, namespace);
58
- if (_.has(uid, controllers)) {
58
+ if (fp.has(uid, controllers)) {
59
59
  throw new Error(`Controller ${uid} has already been registered.`);
60
60
  }
61
61
  controllers[uid] = controller;
@@ -1 +1 @@
1
- {"version":3,"file":"controllers.js","sources":["../../../src/core/registries/controllers.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Strapi, Common } from '@strapi/types';\nimport { addNamespace, hasNamespace } from '../utils';\n\nexport type ControllerFactory =\n | ((params: { strapi: Strapi }) => Common.Controller)\n | Common.Controller;\nexport type ControllerFactoryMap = Record<Common.UID.Controller, ControllerFactory>;\nexport type ControllerMap = Record<Common.UID.Controller, Common.Controller>;\nexport type ControllerExtendFn = (service: Common.Controller) => Common.Controller;\n\nconst controllersRegistry = (strapi: Strapi) => {\n const controllers: ControllerFactoryMap = {};\n const instances: ControllerMap = {};\n\n return {\n /**\n * Returns this list of registered controllers uids\n */\n keys() {\n return Object.keys(controllers);\n },\n\n /**\n * Returns the instance of a controller. Instantiate the controller if not already done\n */\n get(uid: Common.UID.Controller) {\n if (instances[uid]) {\n return instances[uid];\n }\n\n const controller = controllers[uid];\n\n if (controller) {\n instances[uid] = typeof controller === 'function' ? controller({ strapi }) : controller;\n return instances[uid];\n }\n },\n\n /**\n * Returns a map with all the controller in a namespace\n */\n getAll(namespace: string) {\n const filteredControllers = pickBy((_, uid) => hasNamespace(uid, namespace))(controllers);\n\n const map = {};\n for (const uid of Object.keys(filteredControllers) as Common.UID.Controller[]) {\n Object.defineProperty(map, uid, {\n enumerable: true,\n get: () => {\n return this.get(uid);\n },\n });\n }\n\n return map;\n },\n\n /**\n * Registers a controller\n */\n set(uid: Common.UID.Controller, value: ControllerFactory) {\n controllers[uid] = value;\n delete instances[uid];\n return this;\n },\n\n /**\n * Registers a map of controllers for a specific namespace\n */\n add(namespace: string, newControllers: ControllerFactoryMap) {\n for (const controllerName of Object.keys(newControllers) as Common.UID.Controller[]) {\n const controller = newControllers[controllerName];\n const uid = addNamespace(controllerName, namespace) as Common.UID.Controller;\n\n if (has(uid, controllers)) {\n throw new Error(`Controller ${uid} has already been registered.`);\n }\n\n controllers[uid] = controller;\n }\n\n return this;\n },\n\n /**\n * Wraps a controller to extend it\n */\n extend(controllerUID: Common.UID.Controller, extendFn: ControllerExtendFn) {\n const currentController = this.get(controllerUID);\n\n if (!currentController) {\n throw new Error(`Controller ${controllerUID} doesn't exist`);\n }\n\n const newController = extendFn(currentController);\n instances[controllerUID] = newController;\n\n return this;\n },\n };\n};\n\nexport default controllersRegistry;\n"],"names":["pickBy","_","hasNamespace","addNamespace","has"],"mappings":";;;AAWM,MAAA,sBAAsB,CAAC,WAAmB;AAC9C,QAAM,cAAoC,CAAA;AAC1C,QAAM,YAA2B,CAAA;AAE1B,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,WAAW;AAAA,IAChC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAA4B;AAC1B,UAAA,UAAU,GAAG,GAAG;AAClB,eAAO,UAAU,GAAG;AAAA,MACtB;AAEM,YAAA,aAAa,YAAY,GAAG;AAElC,UAAI,YAAY;AACJ,kBAAA,GAAG,IAAI,OAAO,eAAe,aAAa,WAAW,EAAE,QAAQ,IAAI;AAC7E,eAAO,UAAU,GAAG;AAAA,MACtB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,WAAmB;AAClB,YAAA,sBAAsBA,EAAAA,OAAO,CAACC,IAAG,QAAQC,mBAAa,KAAK,SAAS,CAAC,EAAE,WAAW;AAExF,YAAM,MAAM,CAAA;AACZ,iBAAW,OAAO,OAAO,KAAK,mBAAmB,GAA8B;AACtE,eAAA,eAAe,KAAK,KAAK;AAAA,UAC9B,YAAY;AAAA,UACZ,KAAK,MAAM;AACF,mBAAA,KAAK,IAAI,GAAG;AAAA,UACrB;AAAA,QAAA,CACD;AAAA,MACH;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAA4B,OAA0B;AACxD,kBAAY,GAAG,IAAI;AACnB,aAAO,UAAU,GAAG;AACb,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,WAAmB,gBAAsC;AAC3D,iBAAW,kBAAkB,OAAO,KAAK,cAAc,GAA8B;AAC7E,cAAA,aAAa,eAAe,cAAc;AAC1C,cAAA,MAAMC,MAAAA,aAAa,gBAAgB,SAAS;AAE9C,YAAAC,EAAA,IAAI,KAAK,WAAW,GAAG;AACzB,gBAAM,IAAI,MAAM,cAAc,GAAG,+BAA+B;AAAA,QAClE;AAEA,oBAAY,GAAG,IAAI;AAAA,MACrB;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,eAAsC,UAA8B;AACnE,YAAA,oBAAoB,KAAK,IAAI,aAAa;AAEhD,UAAI,CAAC,mBAAmB;AACtB,cAAM,IAAI,MAAM,cAAc,aAAa,gBAAgB;AAAA,MAC7D;AAEM,YAAA,gBAAgB,SAAS,iBAAiB;AAChD,gBAAU,aAAa,IAAI;AAEpB,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"controllers.js","sources":["../../../src/core/registries/controllers.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Strapi, Common } from '@strapi/types';\nimport { addNamespace, hasNamespace } from '../utils';\n\nexport type ControllerFactory =\n | ((params: { strapi: Strapi }) => Common.Controller)\n | Common.Controller;\nexport type ControllerFactoryMap = Record<Common.UID.Controller, ControllerFactory>;\nexport type ControllerMap = Record<Common.UID.Controller, Common.Controller>;\nexport type ControllerExtendFn = (service: Common.Controller) => Common.Controller;\n\nconst controllersRegistry = (strapi: Strapi) => {\n const controllers: ControllerFactoryMap = {};\n const instances: ControllerMap = {};\n\n return {\n /**\n * Returns this list of registered controllers uids\n */\n keys() {\n return Object.keys(controllers);\n },\n\n /**\n * Returns the instance of a controller. Instantiate the controller if not already done\n */\n get(uid: Common.UID.Controller) {\n if (instances[uid]) {\n return instances[uid];\n }\n\n const controller = controllers[uid];\n\n if (controller) {\n instances[uid] = typeof controller === 'function' ? controller({ strapi }) : controller;\n return instances[uid];\n }\n },\n\n /**\n * Returns a map with all the controller in a namespace\n */\n getAll(namespace: string) {\n const filteredControllers = pickBy((_, uid) => hasNamespace(uid, namespace))(controllers);\n\n const map = {};\n for (const uid of Object.keys(filteredControllers) as Common.UID.Controller[]) {\n Object.defineProperty(map, uid, {\n enumerable: true,\n get: () => {\n return this.get(uid);\n },\n });\n }\n\n return map;\n },\n\n /**\n * Registers a controller\n */\n set(uid: Common.UID.Controller, value: ControllerFactory) {\n controllers[uid] = value;\n delete instances[uid];\n return this;\n },\n\n /**\n * Registers a map of controllers for a specific namespace\n */\n add(namespace: string, newControllers: ControllerFactoryMap) {\n for (const controllerName of Object.keys(newControllers) as Common.UID.Controller[]) {\n const controller = newControllers[controllerName];\n const uid = addNamespace(controllerName, namespace) as Common.UID.Controller;\n\n if (has(uid, controllers)) {\n throw new Error(`Controller ${uid} has already been registered.`);\n }\n\n controllers[uid] = controller;\n }\n\n return this;\n },\n\n /**\n * Wraps a controller to extend it\n */\n extend(controllerUID: Common.UID.Controller, extendFn: ControllerExtendFn) {\n const currentController = this.get(controllerUID);\n\n if (!currentController) {\n throw new Error(`Controller ${controllerUID} doesn't exist`);\n }\n\n const newController = extendFn(currentController);\n instances[controllerUID] = newController;\n\n return this;\n },\n };\n};\n\nexport default controllersRegistry;\n"],"names":["pickBy","hasNamespace","addNamespace","has"],"mappings":";;;AAWM,MAAA,sBAAsB,CAAC,WAAmB;AAC9C,QAAM,cAAoC,CAAA;AAC1C,QAAM,YAA2B,CAAA;AAE1B,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,WAAW;AAAA,IAChC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAA4B;AAC1B,UAAA,UAAU,GAAG,GAAG;AAClB,eAAO,UAAU,GAAG;AAAA,MACtB;AAEM,YAAA,aAAa,YAAY,GAAG;AAElC,UAAI,YAAY;AACJ,kBAAA,GAAG,IAAI,OAAO,eAAe,aAAa,WAAW,EAAE,QAAQ,IAAI;AAC7E,eAAO,UAAU,GAAG;AAAA,MACtB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,WAAmB;AAClB,YAAA,sBAAsBA,GAAAA,OAAO,CAAC,GAAG,QAAQC,mBAAa,KAAK,SAAS,CAAC,EAAE,WAAW;AAExF,YAAM,MAAM,CAAA;AACZ,iBAAW,OAAO,OAAO,KAAK,mBAAmB,GAA8B;AACtE,eAAA,eAAe,KAAK,KAAK;AAAA,UAC9B,YAAY;AAAA,UACZ,KAAK,MAAM;AACF,mBAAA,KAAK,IAAI,GAAG;AAAA,UACrB;AAAA,QAAA,CACD;AAAA,MACH;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAA4B,OAA0B;AACxD,kBAAY,GAAG,IAAI;AACnB,aAAO,UAAU,GAAG;AACb,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,WAAmB,gBAAsC;AAC3D,iBAAW,kBAAkB,OAAO,KAAK,cAAc,GAA8B;AAC7E,cAAA,aAAa,eAAe,cAAc;AAC1C,cAAA,MAAMC,MAAAA,aAAa,gBAAgB,SAAS;AAE9C,YAAAC,GAAA,IAAI,KAAK,WAAW,GAAG;AACzB,gBAAM,IAAI,MAAM,cAAc,GAAG,+BAA+B;AAAA,QAClE;AAEA,oBAAY,GAAG,IAAI;AAAA,MACrB;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,eAAsC,UAA8B;AACnE,YAAA,oBAAoB,KAAK,IAAI,aAAa;AAEhD,UAAI,CAAC,mBAAmB;AACtB,cAAM,IAAI,MAAM,cAAc,aAAa,gBAAgB;AAAA,MAC7D;AAEM,YAAA,gBAAgB,SAAS,iBAAiB;AAChD,gBAAU,aAAa,IAAI;AAEpB,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const ALLOWED_TYPES = [
4
4
  "biginteger",
5
5
  "boolean",
@@ -34,7 +34,7 @@ const customFieldsRegistry = (strapi) => {
34
34
  add(customField) {
35
35
  const customFieldList = Array.isArray(customField) ? customField : [customField];
36
36
  for (const cf of customFieldList) {
37
- if (!_.has("name", cf) || !_.has("type", cf)) {
37
+ if (!fp.has("name", cf) || !fp.has("type", cf)) {
38
38
  throw new Error(`Custom fields require a 'name' and 'type' key`);
39
39
  }
40
40
  const { name, plugin, type, inputSize } = cf;
@@ -48,7 +48,7 @@ const customFieldsRegistry = (strapi) => {
48
48
  throw new Error(`Custom field name: '${name}' is not a valid object key`);
49
49
  }
50
50
  if (inputSize) {
51
- if (!_.isPlainObject(inputSize) || !_.has("default", inputSize) || !_.has("isResizable", inputSize)) {
51
+ if (!fp.isPlainObject(inputSize) || !fp.has("default", inputSize) || !fp.has("isResizable", inputSize)) {
52
52
  throw new Error(`inputSize should be an object with 'default' and 'isResizable' keys`);
53
53
  }
54
54
  if (![4, 6, 8, 12].includes(inputSize.default)) {
@@ -59,7 +59,7 @@ const customFieldsRegistry = (strapi) => {
59
59
  }
60
60
  }
61
61
  const uid = plugin && strapi.plugin(plugin) ? `plugin::${plugin}.${name}` : `global::${name}`;
62
- if (_.has(uid, customFields)) {
62
+ if (fp.has(uid, customFields)) {
63
63
  throw new Error(`Custom field: '${uid}' has already been registered`);
64
64
  }
65
65
  customFields[uid] = cf;
@@ -1 +1 @@
1
- {"version":3,"file":"custom-fields.js","sources":["../../../src/core/registries/custom-fields.ts"],"sourcesContent":["import { has, isPlainObject } from 'lodash/fp';\n\nimport type { Strapi, CustomFields } from '@strapi/types';\n\nconst ALLOWED_TYPES = [\n 'biginteger',\n 'boolean',\n 'date',\n 'datetime',\n 'decimal',\n 'email',\n 'enumeration',\n 'float',\n 'integer',\n 'json',\n 'password',\n 'richtext',\n 'string',\n 'text',\n 'time',\n 'uid',\n] as const;\n\nconst customFieldsRegistry = (strapi: Strapi) => {\n const customFields: Record<string, unknown> = {};\n\n return {\n getAll() {\n return customFields;\n },\n get(customField: string) {\n const registeredCustomField = customFields[customField];\n if (!registeredCustomField) {\n throw new Error(`Could not find Custom Field: ${customField}`);\n }\n\n return registeredCustomField;\n },\n add(\n customField: CustomFields.CustomFieldServerOptions | CustomFields.CustomFieldServerOptions[]\n ) {\n const customFieldList = Array.isArray(customField) ? customField : [customField];\n\n for (const cf of customFieldList) {\n if (!has('name', cf) || !has('type', cf)) {\n throw new Error(`Custom fields require a 'name' and 'type' key`);\n }\n\n const { name, plugin, type, inputSize } = cf;\n if (!ALLOWED_TYPES.includes(type)) {\n throw new Error(\n `Custom field type: '${type}' is not a valid Strapi type or it can't be used with a Custom Field`\n );\n }\n\n const isValidObjectKey = /^(?![0-9])[a-zA-Z0-9$_-]+$/g;\n if (!isValidObjectKey.test(name)) {\n throw new Error(`Custom field name: '${name}' is not a valid object key`);\n }\n\n // Validate inputSize when provided\n if (inputSize) {\n if (\n !isPlainObject(inputSize) ||\n !has('default', inputSize) ||\n !has('isResizable', inputSize)\n ) {\n throw new Error(`inputSize should be an object with 'default' and 'isResizable' keys`);\n }\n if (![4, 6, 8, 12].includes(inputSize.default)) {\n throw new Error('Custom fields require a valid default input size');\n }\n if (typeof inputSize.isResizable !== 'boolean') {\n throw new Error('Custom fields should specify if their input is resizable');\n }\n }\n\n // When no plugin is specified, or it isn't found in Strapi, default to global\n const uid =\n plugin && strapi.plugin(plugin) ? `plugin::${plugin}.${name}` : `global::${name}`;\n\n if (has(uid, customFields)) {\n throw new Error(`Custom field: '${uid}' has already been registered`);\n }\n\n customFields[uid] = cf;\n }\n },\n };\n};\n\nexport default customFieldsRegistry;\n"],"names":["has","isPlainObject"],"mappings":";;AAIA,MAAM,gBAAgB;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEM,MAAA,uBAAuB,CAAC,WAAmB;AAC/C,QAAM,eAAwC,CAAA;AAEvC,SAAA;AAAA,IACL,SAAS;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Y,GAAG;AAC1B,gBAAM,IAAI,MAAM,kBAAkB,GAAG,+BAA+B;AAAA,QACtE;AAEA,qBAAa,GAAG,IAAI;AAAA,MACtB;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"custom-fields.js","sources":["../../../src/core/registries/custom-fields.ts"],"sourcesContent":["import { has, isPlainObject } from 'lodash/fp';\n\nimport type { Strapi, CustomFields } from '@strapi/types';\n\nconst ALLOWED_TYPES = [\n 'biginteger',\n 'boolean',\n 'date',\n 'datetime',\n 'decimal',\n 'email',\n 'enumeration',\n 'float',\n 'integer',\n 'json',\n 'password',\n 'richtext',\n 'string',\n 'text',\n 'time',\n 'uid',\n] as const;\n\nconst customFieldsRegistry = (strapi: Strapi) => {\n const customFields: Record<string, unknown> = {};\n\n return {\n getAll() {\n return customFields;\n },\n get(customField: string) {\n const registeredCustomField = customFields[customField];\n if (!registeredCustomField) {\n throw new Error(`Could not find Custom Field: ${customField}`);\n }\n\n return registeredCustomField;\n },\n add(\n customField: CustomFields.CustomFieldServerOptions | CustomFields.CustomFieldServerOptions[]\n ) {\n const customFieldList = Array.isArray(customField) ? customField : [customField];\n\n for (const cf of customFieldList) {\n if (!has('name', cf) || !has('type', cf)) {\n throw new Error(`Custom fields require a 'name' and 'type' key`);\n }\n\n const { name, plugin, type, inputSize } = cf;\n if (!ALLOWED_TYPES.includes(type)) {\n throw new Error(\n `Custom field type: '${type}' is not a valid Strapi type or it can't be used with a Custom Field`\n );\n }\n\n const isValidObjectKey = /^(?![0-9])[a-zA-Z0-9$_-]+$/g;\n if (!isValidObjectKey.test(name)) {\n throw new Error(`Custom field name: '${name}' is not a valid object key`);\n }\n\n // Validate inputSize when provided\n if (inputSize) {\n if (\n !isPlainObject(inputSize) ||\n !has('default', inputSize) ||\n !has('isResizable', inputSize)\n ) {\n throw new Error(`inputSize should be an object with 'default' and 'isResizable' keys`);\n }\n if (![4, 6, 8, 12].includes(inputSize.default)) {\n throw new Error('Custom fields require a valid default input size');\n }\n if (typeof inputSize.isResizable !== 'boolean') {\n throw new Error('Custom fields should specify if their input is resizable');\n }\n }\n\n // When no plugin is specified, or it isn't found in Strapi, default to global\n const uid =\n plugin && strapi.plugin(plugin) ? `plugin::${plugin}.${name}` : `global::${name}`;\n\n if (has(uid, customFields)) {\n throw new Error(`Custom field: '${uid}' has already been registered`);\n }\n\n customFields[uid] = cf;\n }\n },\n };\n};\n\nexport default customFieldsRegistry;\n"],"names":["has","isPlainObject"],"mappings":";;AAIA,MAAM,gBAAgB;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEM,MAAA,uBAAuB,CAAC,WAAmB;AAC/C,QAAM,eAAwC,CAAA;AAEvC,SAAA;AAAA,IACL,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,aAAqB;AACjB,YAAA,wBAAwB,aAAa,WAAW;AACtD,UAAI,CAAC,uBAAuB;AAC1B,cAAM,IAAI,MAAM,gCAAgC,WAAW,EAAE;AAAA,MAC/D;AAEO,aAAA;AAAA,IACT;AAAA,IACA,IACE,aACA;AACA,YAAM,kBAAkB,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW;AAE/E,iBAAW,MAAM,iBAAiB;AAC5B,YAAA,CAACA,GAAAA,IAAI,QAAQ,EAAE,KAAK,CAACA,OAAI,QAAQ,EAAE,GAAG;AAClC,gBAAA,IAAI,MAAM,+CAA+C;AAAA,QACjE;AAEA,cAAM,EAAE,MAAM,QAAQ,MAAM,cAAc;AAC1C,YAAI,CAAC,cAAc,SAAS,IAAI,GAAG;AACjC,gBAAM,IAAI;AAAA,YACR,uBAAuB,IAAI;AAAA,UAAA;AAAA,QAE/B;AAEA,cAAM,mBAAmB;AACzB,YAAI,CAAC,iBAAiB,KAAK,IAAI,GAAG;AAChC,gBAAM,IAAI,MAAM,uBAAuB,IAAI,6BAA6B;AAAA,QAC1E;AAGA,YAAI,WAAW;AACb,cACE,CAACC,GAAA,cAAc,SAAS,KACxB,CAACD,GAAAA,IAAI,WAAW,SAAS,KACzB,CAACA,GAAAA,IAAI,eAAe,SAAS,GAC7B;AACM,kBAAA,IAAI,MAAM,qEAAqE;AAAA,UACvF;AACI,cAAA,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,EAAE,SAAS,UAAU,OAAO,GAAG;AACxC,kBAAA,IAAI,MAAM,kDAAkD;AAAA,UACpE;AACI,cAAA,OAAO,UAAU,gBAAgB,WAAW;AACxC,kBAAA,IAAI,MAAM,0DAA0D;AAAA,UAC5E;AAAA,QACF;AAGA,cAAM,MACJ,UAAU,OAAO,OAAO,MAAM,IAAI,WAAW,MAAM,IAAI,IAAI,KAAK,WAAW,IAAI;AAE7E,YAAAA,GAAA,IAAI,KAAK,YAAY,GAAG;AAC1B,gBAAM,IAAI,MAAM,kBAAkB,GAAG,+BAA+B;AAAA,QACtE;AAEA,qBAAa,GAAG,IAAI;AAAA,MACtB;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const utils = require("../utils.js");
4
4
  const hooksRegistry = () => {
5
5
  const hooks = {};
@@ -20,7 +20,7 @@ const hooksRegistry = () => {
20
20
  * Returns a map with all the hooks in a namespace
21
21
  */
22
22
  getAll(namespace) {
23
- return _.pickBy((_2, uid) => utils.hasNamespace(uid, namespace))(hooks);
23
+ return fp.pickBy((_, uid) => utils.hasNamespace(uid, namespace))(hooks);
24
24
  },
25
25
  /**
26
26
  * Registers a hook
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sources":["../../../src/core/registries/hooks.ts"],"sourcesContent":["import { pickBy } from 'lodash/fp';\nimport { addNamespace, hasNamespace } from '../utils';\n\ntype Handler = (context: any) => any;\n\ntype AsyncHook = {\n handlers: Handler[];\n register(handler: Handler): AsyncHook;\n delete(handler: Handler): AsyncHook;\n call(): Promise<void>;\n};\n\ntype SyncHook = {\n get handlers(): Handler[];\n register(handler: Handler): SyncHook;\n delete(handler: Handler): SyncHook;\n call(): void;\n};\n\nexport type Hook = AsyncHook | SyncHook;\n\ntype HookExtendFn = (hook: Hook) => Hook;\n\nconst hooksRegistry = () => {\n const hooks: Record<string, Hook> = {};\n\n return {\n /**\n * Returns this list of registered hooks uids\n */\n keys() {\n return Object.keys(hooks);\n },\n\n /**\n * Returns the instance of a hook.\n */\n get(uid: string) {\n return hooks[uid];\n },\n\n /**\n * Returns a map with all the hooks in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(hooks);\n },\n\n /**\n * Registers a hook\n */\n set(uid: string, hook: Hook) {\n hooks[uid] = hook;\n return this;\n },\n\n /**\n * Registers a map of hooks for a specific namespace\n */\n add(namespace: string, hooks: Record<string, Hook>) {\n for (const hookName of Object.keys(hooks)) {\n const hook = hooks[hookName];\n const uid = addNamespace(hookName, namespace);\n\n this.set(uid, hook);\n }\n\n return this;\n },\n\n /**\n * Wraps a hook to extend it\n */\n extend(uid: string, extendFn: HookExtendFn) {\n const currentHook = this.get(uid);\n\n if (!currentHook) {\n throw new Error(`Hook ${uid} doesn't exist`);\n }\n\n const newHook = extendFn(currentHook);\n hooks[uid] = newHook;\n\n return this;\n },\n };\n};\n\nexport default hooksRegistry;\n"],"names":["pickBy","_","hasNamespace","hooks","addNamespace"],"mappings":";;;AAuBA,MAAM,gBAAgB,MAAM;AAC1B,QAAM,QAA8B,CAAA;AAE7B,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,KAAK;AAAA,IAC1B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa;AACf,aAAO,MAAM,GAAG;AAAA,IAClB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,WAAmB;AACjB,aAAAA,EAAA,OAAO,CAACC,IAAG,QAAQC,MAAAA,aAAa,KAAK,SAAS,CAAC,EAAE,KAAK;AAAA,IAC/D;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa,MAAY;AAC3B,YAAM,GAAG,IAAI;AACN,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,WAAmBC,QAA6B;AAClD,iBAAW,YAAY,OAAO,KAAKA,MAAK,GAAG;AACnC,cAAA,OAAOA,OAAM,QAAQ;AACrB,cAAA,MAAMC,MAAAA,aAAa,UAAU,SAAS;AAEvC,aAAA,IAAI,KAAK,IAAI;AAAA,MACpB;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,KAAa,UAAwB;AACpC,YAAA,cAAc,KAAK,IAAI,GAAG;AAEhC,UAAI,CAAC,aAAa;AAChB,cAAM,IAAI,MAAM,QAAQ,GAAG,gBAAgB;AAAA,MAC7C;AAEM,YAAA,UAAU,SAAS,WAAW;AACpC,YAAM,GAAG,IAAI;AAEN,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"hooks.js","sources":["../../../src/core/registries/hooks.ts"],"sourcesContent":["import { pickBy } from 'lodash/fp';\nimport { addNamespace, hasNamespace } from '../utils';\n\ntype Handler = (context: any) => any;\n\ntype AsyncHook = {\n handlers: Handler[];\n register(handler: Handler): AsyncHook;\n delete(handler: Handler): AsyncHook;\n call(): Promise<void>;\n};\n\ntype SyncHook = {\n get handlers(): Handler[];\n register(handler: Handler): SyncHook;\n delete(handler: Handler): SyncHook;\n call(): void;\n};\n\nexport type Hook = AsyncHook | SyncHook;\n\ntype HookExtendFn = (hook: Hook) => Hook;\n\nconst hooksRegistry = () => {\n const hooks: Record<string, Hook> = {};\n\n return {\n /**\n * Returns this list of registered hooks uids\n */\n keys() {\n return Object.keys(hooks);\n },\n\n /**\n * Returns the instance of a hook.\n */\n get(uid: string) {\n return hooks[uid];\n },\n\n /**\n * Returns a map with all the hooks in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(hooks);\n },\n\n /**\n * Registers a hook\n */\n set(uid: string, hook: Hook) {\n hooks[uid] = hook;\n return this;\n },\n\n /**\n * Registers a map of hooks for a specific namespace\n */\n add(namespace: string, hooks: Record<string, Hook>) {\n for (const hookName of Object.keys(hooks)) {\n const hook = hooks[hookName];\n const uid = addNamespace(hookName, namespace);\n\n this.set(uid, hook);\n }\n\n return this;\n },\n\n /**\n * Wraps a hook to extend it\n */\n extend(uid: string, extendFn: HookExtendFn) {\n const currentHook = this.get(uid);\n\n if (!currentHook) {\n throw new Error(`Hook ${uid} doesn't exist`);\n }\n\n const newHook = extendFn(currentHook);\n hooks[uid] = newHook;\n\n return this;\n },\n };\n};\n\nexport default hooksRegistry;\n"],"names":["pickBy","hasNamespace","hooks","addNamespace"],"mappings":";;;AAuBA,MAAM,gBAAgB,MAAM;AAC1B,QAAM,QAA8B,CAAA;AAE7B,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,KAAK;AAAA,IAC1B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa;AACf,aAAO,MAAM,GAAG;AAAA,IAClB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,WAAmB;AACjB,aAAAA,GAAA,OAAO,CAAC,GAAG,QAAQC,MAAAA,aAAa,KAAK,SAAS,CAAC,EAAE,KAAK;AAAA,IAC/D;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa,MAAY;AAC3B,YAAM,GAAG,IAAI;AACN,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,WAAmBC,QAA6B;AAClD,iBAAW,YAAY,OAAO,KAAKA,MAAK,GAAG;AACnC,cAAA,OAAOA,OAAM,QAAQ;AACrB,cAAA,MAAMC,MAAAA,aAAa,UAAU,SAAS;AAEvC,aAAA,IAAI,KAAK,IAAI;AAAA,MACpB;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,KAAa,UAAwB;AACpC,YAAA,cAAc,KAAK,IAAI,GAAG;AAEhC,UAAI,CAAC,aAAa;AAChB,cAAM,IAAI,MAAM,QAAQ,GAAG,gBAAgB;AAAA,MAC7C;AAEM,YAAA,UAAU,SAAS,WAAW;AACpC,YAAM,GAAG,IAAI;AAEN,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const utils = require("../utils.js");
4
4
  const middlewaresRegistry = () => {
5
5
  const middlewares = {};
@@ -20,7 +20,7 @@ const middlewaresRegistry = () => {
20
20
  * Returns a map with all the middlewares in a namespace
21
21
  */
22
22
  getAll(namespace) {
23
- return _.pickBy((_2, uid) => utils.hasNamespace(uid, namespace))(middlewares);
23
+ return fp.pickBy((_, uid) => utils.hasNamespace(uid, namespace))(middlewares);
24
24
  },
25
25
  /**
26
26
  * Registers a middleware
@@ -36,7 +36,7 @@ const middlewaresRegistry = () => {
36
36
  for (const middlewareName of Object.keys(rawMiddlewares)) {
37
37
  const middleware = rawMiddlewares[middlewareName];
38
38
  const uid = utils.addNamespace(middlewareName, namespace);
39
- if (_.has(uid, middlewares)) {
39
+ if (fp.has(uid, middlewares)) {
40
40
  throw new Error(`Middleware ${uid} has already been registered.`);
41
41
  }
42
42
  middlewares[uid] = middleware;
@@ -1 +1 @@
1
- {"version":3,"file":"middlewares.js","sources":["../../../src/core/registries/middlewares.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Common } from '@strapi/types';\nimport { addNamespace, hasNamespace } from '../utils';\n\ntype MiddlewareExtendFn = (middleware: Common.Middleware) => Common.Middleware;\n\n// TODO: move instantiation part here instead of in the server service\nconst middlewaresRegistry = () => {\n const middlewares: Record<Common.UID.Middleware, Common.Middleware> = {};\n\n return {\n /**\n * Returns this list of registered middlewares uids\n */\n keys() {\n return Object.keys(middlewares);\n },\n\n /**\n * Returns the instance of a middleware. Instantiate the middleware if not already done\n */\n get(uid: Common.UID.Middleware) {\n return middlewares[uid];\n },\n\n /**\n * Returns a map with all the middlewares in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(middlewares);\n },\n\n /**\n * Registers a middleware\n */\n set(uid: Common.UID.Middleware, middleware: Common.Middleware) {\n middlewares[uid] = middleware;\n return this;\n },\n\n /**\n * Registers a map of middlewares for a specific namespace\n */\n add(namespace: string, rawMiddlewares: Record<string, Common.Middleware> = {}) {\n for (const middlewareName of Object.keys(rawMiddlewares)) {\n const middleware = rawMiddlewares[middlewareName];\n const uid = addNamespace(middlewareName, namespace) as Common.UID.Middleware;\n\n if (has(uid, middlewares)) {\n throw new Error(`Middleware ${uid} has already been registered.`);\n }\n middlewares[uid] = middleware;\n }\n },\n\n /**\n * Wraps a middleware to extend it\n */\n extend(uid: Common.UID.Middleware, extendFn: MiddlewareExtendFn) {\n const currentMiddleware = this.get(uid);\n\n if (!currentMiddleware) {\n throw new Error(`Middleware ${uid} doesn't exist`);\n }\n\n const newMiddleware = extendFn(currentMiddleware);\n middlewares[uid] = newMiddleware;\n\n return this;\n },\n };\n};\n\nexport default middlewaresRegistry;\n"],"names":["pickBy","_","hasNamespace","addNamespace","has"],"mappings":";;;AAOA,MAAM,sBAAsB,MAAM;AAChC,QAAM,cAAgE,CAAA;AAE/D,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,WAAW;AAAA,IAChC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAA4B;AAC9B,aAAO,YAAY,GAAG;AAAA,IACxB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,WAAmB;AACjB,aAAAA,EAAA,OAAO,CAACC,IAAG,QAAQC,MAAAA,aAAa,KAAK,SAAS,CAAC,EAAE,WAAW;AAAA,IACrE;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAA4B,YAA+B;AAC7D,kBAAY,GAAG,IAAI;AACZ,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,WAAmB,iBAAoD,IAAI;AAC7E,iBAAW,kBAAkB,OAAO,KAAK,cAAc,GAAG;AAClD,cAAA,aAAa,eAAe,cAAc;AAC1C,cAAA,MAAMC,MAAAA,aAAa,gBAAgB,SAAS;AAE9C,YAAAC,EAAA,IAAI,KAAK,WAAW,GAAG;AACzB,gBAAM,IAAI,MAAM,cAAc,GAAG,+BAA+B;AAAA,QAClE;AACA,oBAAY,GAAG,IAAI;AAAA,MACrB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,KAA4B,UAA8B;AACzD,YAAA,oBAAoB,KAAK,IAAI,GAAG;AAEtC,UAAI,CAAC,mBAAmB;AACtB,cAAM,IAAI,MAAM,cAAc,GAAG,gBAAgB;AAAA,MACnD;AAEM,YAAA,gBAAgB,SAAS,iBAAiB;AAChD,kBAAY,GAAG,IAAI;AAEZ,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"middlewares.js","sources":["../../../src/core/registries/middlewares.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Common } from '@strapi/types';\nimport { addNamespace, hasNamespace } from '../utils';\n\ntype MiddlewareExtendFn = (middleware: Common.Middleware) => Common.Middleware;\n\n// TODO: move instantiation part here instead of in the server service\nconst middlewaresRegistry = () => {\n const middlewares: Record<Common.UID.Middleware, Common.Middleware> = {};\n\n return {\n /**\n * Returns this list of registered middlewares uids\n */\n keys() {\n return Object.keys(middlewares);\n },\n\n /**\n * Returns the instance of a middleware. Instantiate the middleware if not already done\n */\n get(uid: Common.UID.Middleware) {\n return middlewares[uid];\n },\n\n /**\n * Returns a map with all the middlewares in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(middlewares);\n },\n\n /**\n * Registers a middleware\n */\n set(uid: Common.UID.Middleware, middleware: Common.Middleware) {\n middlewares[uid] = middleware;\n return this;\n },\n\n /**\n * Registers a map of middlewares for a specific namespace\n */\n add(namespace: string, rawMiddlewares: Record<string, Common.Middleware> = {}) {\n for (const middlewareName of Object.keys(rawMiddlewares)) {\n const middleware = rawMiddlewares[middlewareName];\n const uid = addNamespace(middlewareName, namespace) as Common.UID.Middleware;\n\n if (has(uid, middlewares)) {\n throw new Error(`Middleware ${uid} has already been registered.`);\n }\n middlewares[uid] = middleware;\n }\n },\n\n /**\n * Wraps a middleware to extend it\n */\n extend(uid: Common.UID.Middleware, extendFn: MiddlewareExtendFn) {\n const currentMiddleware = this.get(uid);\n\n if (!currentMiddleware) {\n throw new Error(`Middleware ${uid} doesn't exist`);\n }\n\n const newMiddleware = extendFn(currentMiddleware);\n middlewares[uid] = newMiddleware;\n\n return this;\n },\n };\n};\n\nexport default middlewaresRegistry;\n"],"names":["pickBy","hasNamespace","addNamespace","has"],"mappings":";;;AAOA,MAAM,sBAAsB,MAAM;AAChC,QAAM,cAAgE,CAAA;AAE/D,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,WAAW;AAAA,IAChC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAA4B;AAC9B,aAAO,YAAY,GAAG;AAAA,IACxB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,WAAmB;AACjB,aAAAA,GAAA,OAAO,CAAC,GAAG,QAAQC,MAAAA,aAAa,KAAK,SAAS,CAAC,EAAE,WAAW;AAAA,IACrE;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAA4B,YAA+B;AAC7D,kBAAY,GAAG,IAAI;AACZ,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,WAAmB,iBAAoD,IAAI;AAC7E,iBAAW,kBAAkB,OAAO,KAAK,cAAc,GAAG;AAClD,cAAA,aAAa,eAAe,cAAc;AAC1C,cAAA,MAAMC,MAAAA,aAAa,gBAAgB,SAAS;AAE9C,YAAAC,GAAA,IAAI,KAAK,WAAW,GAAG;AACzB,gBAAM,IAAI,MAAM,cAAc,GAAG,+BAA+B;AAAA,QAClE;AACA,oBAAY,GAAG,IAAI;AAAA,MACrB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,KAA4B,UAA8B;AACzD,YAAA,oBAAoB,KAAK,IAAI,GAAG;AAEtC,UAAI,CAAC,mBAAmB;AACtB,cAAM,IAAI,MAAM,cAAc,GAAG,gBAAgB;AAAA,MACnD;AAEM,YAAA,gBAAgB,SAAS,iBAAiB;AAChD,kBAAY,GAAG,IAAI;AAEZ,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const index = require("../domain/module/index.js");
4
4
  const modulesRegistry = (strapi) => {
5
5
  const modules = {};
@@ -8,10 +8,10 @@ const modulesRegistry = (strapi) => {
8
8
  return modules[namespace];
9
9
  },
10
10
  getAll(prefix = "") {
11
- return _.pickBy((mod, namespace) => namespace.startsWith(prefix))(modules);
11
+ return fp.pickBy((mod, namespace) => namespace.startsWith(prefix))(modules);
12
12
  },
13
13
  add(namespace, rawModule) {
14
- if (_.has(namespace, modules)) {
14
+ if (fp.has(namespace, modules)) {
15
15
  throw new Error(`Module ${namespace} has already been registered.`);
16
16
  }
17
17
  modules[namespace] = index.createModule(namespace, rawModule, strapi);
@@ -1 +1 @@
1
- {"version":3,"file":"modules.js","sources":["../../../src/core/registries/modules.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Strapi } from '@strapi/types';\nimport { createModule, RawModule, Module } from '../domain/module';\n\ntype ModuleMap = { [namespace: string]: Module };\n\nconst modulesRegistry = (strapi: Strapi) => {\n const modules: ModuleMap = {};\n\n return {\n get(namespace: string) {\n return modules[namespace];\n },\n getAll(prefix = '') {\n return pickBy<ModuleMap>((mod, namespace) => namespace.startsWith(prefix))(modules);\n },\n add(namespace: string, rawModule: RawModule) {\n if (has(namespace, modules)) {\n throw new Error(`Module ${namespace} has already been registered.`);\n }\n\n modules[namespace] = createModule(namespace, rawModule, strapi);\n modules[namespace].load();\n\n return modules[namespace];\n },\n async bootstrap() {\n for (const mod of Object.values(modules)) {\n await mod.bootstrap();\n }\n },\n async register() {\n for (const mod of Object.values(modules)) {\n await mod.register();\n }\n },\n async destroy() {\n for (const mod of Object.values(modules)) {\n await mod.destroy();\n }\n },\n };\n};\n\nexport default modulesRegistry;\n"],"names":["pickBy","has","createModule"],"mappings":";;;AAMM,MAAA,kBAAkB,CAAC,WAAmB;AAC1C,QAAM,UAAqB,CAAA;AAEpB,SAAA;AAAA,IACL,IAAI,WAAmB;AACrB,aAAO,QAAQ,SAAS;AAAA,IAC1B;AAAA,IACA,OAAO,SAAS,IAAI;AACX,aAAAA,EAAA,OAAkB,CAAC,KAAK,cAAc,UAAU,WAAW,MAAM,CAAC,EAAE,OAAO;AAAA,IACpF;AAAA,IACA,IAAI,WAAmB,WAAsB;AACvC,UAAAC,EAAA,IAAI,WAAW,OAAO,GAAG;AAC3B,cAAM,IAAI,MAAM,UAAU,SAAS,+BAA+B;AAAA,MACpE;AAEA,cAAQ,SAAS,IAAIC,MAAAA,aAAa,WAAW,WAAW,MAAM;AACtD,cAAA,SAAS,EAAE;AAEnB,aAAO,QAAQ,SAAS;AAAA,IAC1B;AAAA,IACA,MAAM,YAAY;AAChB,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,IACA,MAAM,WAAW;AACf,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,IACA,MAAM,UAAU;AACd,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"modules.js","sources":["../../../src/core/registries/modules.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Strapi } from '@strapi/types';\nimport { createModule, RawModule, Module } from '../domain/module';\n\ntype ModuleMap = { [namespace: string]: Module };\n\nconst modulesRegistry = (strapi: Strapi) => {\n const modules: ModuleMap = {};\n\n return {\n get(namespace: string) {\n return modules[namespace];\n },\n getAll(prefix = '') {\n return pickBy<ModuleMap>((mod, namespace) => namespace.startsWith(prefix))(modules);\n },\n add(namespace: string, rawModule: RawModule) {\n if (has(namespace, modules)) {\n throw new Error(`Module ${namespace} has already been registered.`);\n }\n\n modules[namespace] = createModule(namespace, rawModule, strapi);\n modules[namespace].load();\n\n return modules[namespace];\n },\n async bootstrap() {\n for (const mod of Object.values(modules)) {\n await mod.bootstrap();\n }\n },\n async register() {\n for (const mod of Object.values(modules)) {\n await mod.register();\n }\n },\n async destroy() {\n for (const mod of Object.values(modules)) {\n await mod.destroy();\n }\n },\n };\n};\n\nexport default modulesRegistry;\n"],"names":["pickBy","has","createModule"],"mappings":";;;AAMM,MAAA,kBAAkB,CAAC,WAAmB;AAC1C,QAAM,UAAqB,CAAA;AAEpB,SAAA;AAAA,IACL,IAAI,WAAmB;AACrB,aAAO,QAAQ,SAAS;AAAA,IAC1B;AAAA,IACA,OAAO,SAAS,IAAI;AACX,aAAAA,GAAA,OAAkB,CAAC,KAAK,cAAc,UAAU,WAAW,MAAM,CAAC,EAAE,OAAO;AAAA,IACpF;AAAA,IACA,IAAI,WAAmB,WAAsB;AACvC,UAAAC,GAAA,IAAI,WAAW,OAAO,GAAG;AAC3B,cAAM,IAAI,MAAM,UAAU,SAAS,+BAA+B;AAAA,MACpE;AAEA,cAAQ,SAAS,IAAIC,MAAAA,aAAa,WAAW,WAAW,MAAM;AACtD,cAAA,SAAS,EAAE;AAEnB,aAAO,QAAQ,SAAS;AAAA,IAC1B;AAAA,IACA,MAAM,YAAY;AAChB,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,IACA,MAAM,WAAW;AACf,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,IACA,MAAM,UAAU;AACd,iBAAW,OAAO,OAAO,OAAO,OAAO,GAAG;AACxC,cAAM,IAAI;MACZ;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const pluginsRegistry = (strapi) => {
4
4
  const plugins = {};
5
5
  return {
@@ -10,7 +10,7 @@ const pluginsRegistry = (strapi) => {
10
10
  return plugins;
11
11
  },
12
12
  add(name, pluginConfig) {
13
- if (_.has(name, plugins)) {
13
+ if (fp.has(name, plugins)) {
14
14
  throw new Error(`Plugin ${name} has already been registered.`);
15
15
  }
16
16
  const pluginModule = strapi.container.get("modules").add(`plugin::${name}`, pluginConfig);
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.js","sources":["../../../src/core/registries/plugins.ts"],"sourcesContent":["import { has } from 'lodash/fp';\n\nimport type { Strapi, Common } from '@strapi/types';\n\ntype PluginMap = Record<string, Common.Plugin>;\n\nconst pluginsRegistry = (strapi: Strapi) => {\n const plugins: PluginMap = {};\n\n return {\n get(name: string) {\n return plugins[name];\n },\n getAll() {\n return plugins;\n },\n add(name: string, pluginConfig: Common.Plugin) {\n if (has(name, plugins)) {\n throw new Error(`Plugin ${name} has already been registered.`);\n }\n\n const pluginModule = strapi.container.get('modules').add(`plugin::${name}`, pluginConfig);\n plugins[name] = pluginModule;\n\n return plugins[name];\n },\n };\n};\n\nexport default pluginsRegistry;\n"],"names":["has"],"mappings":";;AAMM,MAAA,kBAAkB,CAAC,WAAmB;AAC1C,QAAM,UAAqB,CAAA;AAEpB,SAAA;AAAA,IACL,IAAI,MAAc;AAChB,aAAO,QAAQ,IAAI;AAAA,IACrB;AAAA,IACA,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,MAAc,cAA6B;AACzC,UAAAA,EAAA,IAAI,MAAM,OAAO,GAAG;AACtB,cAAM,IAAI,MAAM,UAAU,IAAI,+BAA+B;AAAA,MAC/D;AAEM,YAAA,eAAe,OAAO,UAAU,IAAI,SAAS,EAAE,IAAI,WAAW,IAAI,IAAI,YAAY;AACxF,cAAQ,IAAI,IAAI;AAEhB,aAAO,QAAQ,IAAI;AAAA,IACrB;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"plugins.js","sources":["../../../src/core/registries/plugins.ts"],"sourcesContent":["import { has } from 'lodash/fp';\n\nimport type { Strapi, Common } from '@strapi/types';\n\ntype PluginMap = Record<string, Common.Plugin>;\n\nconst pluginsRegistry = (strapi: Strapi) => {\n const plugins: PluginMap = {};\n\n return {\n get(name: string) {\n return plugins[name];\n },\n getAll() {\n return plugins;\n },\n add(name: string, pluginConfig: Common.Plugin) {\n if (has(name, plugins)) {\n throw new Error(`Plugin ${name} has already been registered.`);\n }\n\n const pluginModule = strapi.container.get('modules').add(`plugin::${name}`, pluginConfig);\n plugins[name] = pluginModule;\n\n return plugins[name];\n },\n };\n};\n\nexport default pluginsRegistry;\n"],"names":["has"],"mappings":";;AAMM,MAAA,kBAAkB,CAAC,WAAmB;AAC1C,QAAM,UAAqB,CAAA;AAEpB,SAAA;AAAA,IACL,IAAI,MAAc;AAChB,aAAO,QAAQ,IAAI;AAAA,IACrB;AAAA,IACA,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,MAAc,cAA6B;AACzC,UAAAA,GAAA,IAAI,MAAM,OAAO,GAAG;AACtB,cAAM,IAAI,MAAM,UAAU,IAAI,+BAA+B;AAAA,MAC/D;AAEM,YAAA,eAAe,OAAO,UAAU,IAAI,SAAS,EAAE,IAAI,WAAW,IAAI,IAAI,YAAY;AACxF,cAAQ,IAAI,IAAI;AAEhB,aAAO,QAAQ,IAAI;AAAA,IACrB;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const utils = require("../utils.js");
4
4
  const policiesRegistry = () => {
5
5
  const policies = {};
@@ -20,7 +20,7 @@ const policiesRegistry = () => {
20
20
  * Returns a map with all the policies in a namespace
21
21
  */
22
22
  getAll(namespace) {
23
- return _.pickBy((_2, uid) => utils.hasNamespace(uid, namespace))(policies);
23
+ return fp.pickBy((_, uid) => utils.hasNamespace(uid, namespace))(policies);
24
24
  },
25
25
  /**
26
26
  * Registers a policy
@@ -36,7 +36,7 @@ const policiesRegistry = () => {
36
36
  for (const policyName of Object.keys(newPolicies)) {
37
37
  const policy = newPolicies[policyName];
38
38
  const uid = utils.addNamespace(policyName, namespace);
39
- if (_.has(uid, policies)) {
39
+ if (fp.has(uid, policies)) {
40
40
  throw new Error(`Policy ${uid} has already been registered.`);
41
41
  }
42
42
  policies[uid] = policy;
@@ -1 +1 @@
1
- {"version":3,"file":"policies.js","sources":["../../../src/core/registries/policies.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Common } from '@strapi/types';\nimport { addNamespace, hasNamespace } from '../utils';\n\ntype PolicyExtendFn = (policy: Common.Policy) => Common.Policy;\ntype PolicyMap = Record<string, Common.Policy>;\n\n// TODO: move instantiation part here instead of in the policy utils\nconst policiesRegistry = () => {\n const policies: PolicyMap = {};\n\n return {\n /**\n * Returns this list of registered policies uids\n */\n keys() {\n return Object.keys(policies);\n },\n\n /**\n * Returns the instance of a policy. Instantiate the policy if not already done\n */\n get(uid: Common.UID.Policy) {\n return policies[uid];\n },\n\n /**\n * Returns a map with all the policies in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(policies);\n },\n\n /**\n * Registers a policy\n */\n set(uid: string, policy: Common.Policy) {\n policies[uid] = policy;\n return this;\n },\n\n /**\n * Registers a map of policies for a specific namespace\n */\n add(namespace: string, newPolicies: PolicyMap) {\n for (const policyName of Object.keys(newPolicies)) {\n const policy = newPolicies[policyName];\n const uid = addNamespace(policyName, namespace);\n\n if (has(uid, policies)) {\n throw new Error(`Policy ${uid} has already been registered.`);\n }\n policies[uid] = policy;\n }\n },\n\n /**\n * Wraps a policy to extend it\n * @param {string} uid\n * @param {(policy: Policy) => Policy} extendFn\n */\n extend(uid: Common.UID.Policy, extendFn: PolicyExtendFn) {\n const currentPolicy = this.get(uid);\n\n if (!currentPolicy) {\n throw new Error(`Policy ${uid} doesn't exist`);\n }\n\n const newPolicy = extendFn(currentPolicy);\n policies[uid] = newPolicy;\n\n return this;\n },\n };\n};\n\nexport default policiesRegistry;\n"],"names":["pickBy","_","hasNamespace","addNamespace","has"],"mappings":";;;AAQA,MAAM,mBAAmB,MAAM;AAC7B,QAAM,WAAsB,CAAA;AAErB,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,QAAQ;AAAA,IAC7B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAwB;AAC1B,aAAO,SAAS,GAAG;AAAA,IACrB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,WAAmB;AACjB,aAAAA,EAAA,OAAO,CAACC,IAAG,QAAQC,MAAAA,aAAa,KAAK,SAAS,CAAC,EAAE,QAAQ;AAAA,IAClE;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa,QAAuB;AACtC,eAAS,GAAG,IAAI;AACT,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,WAAmB,aAAwB;AAC7C,iBAAW,cAAc,OAAO,KAAK,WAAW,GAAG;AAC3C,cAAA,SAAS,YAAY,UAAU;AAC/B,cAAA,MAAMC,MAAAA,aAAa,YAAY,SAAS;AAE1C,YAAAC,EAAA,IAAI,KAAK,QAAQ,GAAG;AACtB,gBAAM,IAAI,MAAM,UAAU,GAAG,+BAA+B;AAAA,QAC9D;AACA,iBAAS,GAAG,IAAI;AAAA,MAClB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,OAAO,KAAwB,UAA0B;AACjD,YAAA,gBAAgB,KAAK,IAAI,GAAG;AAElC,UAAI,CAAC,eAAe;AAClB,cAAM,IAAI,MAAM,UAAU,GAAG,gBAAgB;AAAA,MAC/C;AAEM,YAAA,YAAY,SAAS,aAAa;AACxC,eAAS,GAAG,IAAI;AAET,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"policies.js","sources":["../../../src/core/registries/policies.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Common } from '@strapi/types';\nimport { addNamespace, hasNamespace } from '../utils';\n\ntype PolicyExtendFn = (policy: Common.Policy) => Common.Policy;\ntype PolicyMap = Record<string, Common.Policy>;\n\n// TODO: move instantiation part here instead of in the policy utils\nconst policiesRegistry = () => {\n const policies: PolicyMap = {};\n\n return {\n /**\n * Returns this list of registered policies uids\n */\n keys() {\n return Object.keys(policies);\n },\n\n /**\n * Returns the instance of a policy. Instantiate the policy if not already done\n */\n get(uid: Common.UID.Policy) {\n return policies[uid];\n },\n\n /**\n * Returns a map with all the policies in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(policies);\n },\n\n /**\n * Registers a policy\n */\n set(uid: string, policy: Common.Policy) {\n policies[uid] = policy;\n return this;\n },\n\n /**\n * Registers a map of policies for a specific namespace\n */\n add(namespace: string, newPolicies: PolicyMap) {\n for (const policyName of Object.keys(newPolicies)) {\n const policy = newPolicies[policyName];\n const uid = addNamespace(policyName, namespace);\n\n if (has(uid, policies)) {\n throw new Error(`Policy ${uid} has already been registered.`);\n }\n policies[uid] = policy;\n }\n },\n\n /**\n * Wraps a policy to extend it\n * @param {string} uid\n * @param {(policy: Policy) => Policy} extendFn\n */\n extend(uid: Common.UID.Policy, extendFn: PolicyExtendFn) {\n const currentPolicy = this.get(uid);\n\n if (!currentPolicy) {\n throw new Error(`Policy ${uid} doesn't exist`);\n }\n\n const newPolicy = extendFn(currentPolicy);\n policies[uid] = newPolicy;\n\n return this;\n },\n };\n};\n\nexport default policiesRegistry;\n"],"names":["pickBy","hasNamespace","addNamespace","has"],"mappings":";;;AAQA,MAAM,mBAAmB,MAAM;AAC7B,QAAM,WAAsB,CAAA;AAErB,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,QAAQ;AAAA,IAC7B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAwB;AAC1B,aAAO,SAAS,GAAG;AAAA,IACrB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,WAAmB;AACjB,aAAAA,GAAA,OAAO,CAAC,GAAG,QAAQC,MAAAA,aAAa,KAAK,SAAS,CAAC,EAAE,QAAQ;AAAA,IAClE;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa,QAAuB;AACtC,eAAS,GAAG,IAAI;AACT,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,WAAmB,aAAwB;AAC7C,iBAAW,cAAc,OAAO,KAAK,WAAW,GAAG;AAC3C,cAAA,SAAS,YAAY,UAAU;AAC/B,cAAA,MAAMC,MAAAA,aAAa,YAAY,SAAS;AAE1C,YAAAC,GAAA,IAAI,KAAK,QAAQ,GAAG;AACtB,gBAAM,IAAI,MAAM,UAAU,GAAG,+BAA+B;AAAA,QAC9D;AACA,iBAAS,GAAG,IAAI;AAAA,MAClB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,OAAO,KAAwB,UAA0B;AACjD,YAAA,gBAAgB,KAAK,IAAI,GAAG;AAElC,UAAI,CAAC,eAAe;AAClB,cAAM,IAAI,MAAM,UAAU,GAAG,gBAAgB;AAAA,MAC/C;AAEM,YAAA,YAAY,SAAS,aAAa;AACxC,eAAS,GAAG,IAAI;AAET,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const utils = require("../utils.js");
4
4
  const servicesRegistry = (strapi) => {
5
5
  const services = {};
@@ -28,7 +28,7 @@ const servicesRegistry = (strapi) => {
28
28
  * Returns a map with all the services in a namespace
29
29
  */
30
30
  getAll(namespace) {
31
- const filteredServices = _.pickBy((_2, uid) => utils.hasNamespace(uid, namespace))(services);
31
+ const filteredServices = fp.pickBy((_, uid) => utils.hasNamespace(uid, namespace))(services);
32
32
  const map = {};
33
33
  for (const uid of Object.keys(filteredServices)) {
34
34
  Object.defineProperty(map, uid, {
@@ -55,7 +55,7 @@ const servicesRegistry = (strapi) => {
55
55
  for (const serviceName of Object.keys(newServices)) {
56
56
  const service = newServices[serviceName];
57
57
  const uid = utils.addNamespace(serviceName, namespace);
58
- if (_.has(uid, services)) {
58
+ if (fp.has(uid, services)) {
59
59
  throw new Error(`Service ${uid} has already been registered.`);
60
60
  }
61
61
  services[uid] = service;
@@ -1 +1 @@
1
- {"version":3,"file":"services.js","sources":["../../../src/core/registries/services.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Strapi, Common } from '@strapi/types';\nimport { addNamespace, hasNamespace } from '../utils';\n\nexport type ServiceFactory = (params: { strapi: Strapi }) => Common.Service | Common.Service;\nexport type ServiceFactoryMap = Record<string, ServiceFactory>;\nexport type ServiceMap = Record<string, Common.Service>;\nexport type ServiceExtendFn = (service: Common.Service) => Common.Service;\n\nconst servicesRegistry = (strapi: Strapi) => {\n const services: ServiceFactoryMap = {};\n const instantiatedServices: ServiceMap = {};\n\n return {\n /**\n * Returns this list of registered services uids\n */\n keys() {\n return Object.keys(services);\n },\n\n /**\n * Returns the instance of a service. Instantiate the service if not already done\n */\n get(uid: Common.UID.Service) {\n if (instantiatedServices[uid]) {\n return instantiatedServices[uid];\n }\n\n const service = services[uid];\n if (service) {\n instantiatedServices[uid] = typeof service === 'function' ? service({ strapi }) : service;\n return instantiatedServices[uid];\n }\n },\n\n /**\n * Returns a map with all the services in a namespace\n */\n getAll(namespace: string): ServiceMap {\n const filteredServices = pickBy((_, uid) => hasNamespace(uid, namespace))(services);\n\n // create lazy accessor to avoid instantiating the services;\n const map = {};\n for (const uid of Object.keys(filteredServices)) {\n Object.defineProperty(map, uid, {\n enumerable: true,\n get: () => {\n return this.get(uid as Common.UID.Service);\n },\n });\n }\n\n return map;\n },\n\n /**\n * Registers a service\n */\n set(uid: string, service: ServiceFactory) {\n services[uid] = service;\n delete instantiatedServices[uid];\n return this;\n },\n\n /**\n * Registers a map of services for a specific namespace\n */\n add(namespace: string, newServices: ServiceFactoryMap) {\n for (const serviceName of Object.keys(newServices)) {\n const service = newServices[serviceName];\n const uid = addNamespace(serviceName, namespace);\n\n if (has(uid, services)) {\n throw new Error(`Service ${uid} has already been registered.`);\n }\n services[uid] = service;\n }\n\n return this;\n },\n\n /**\n * Wraps a service to extend it\n */\n extend(uid: Common.UID.Service, extendFn: ServiceExtendFn) {\n const currentService = this.get(uid);\n\n if (!currentService) {\n throw new Error(`Service ${uid} doesn't exist`);\n }\n\n const newService = extendFn(currentService);\n instantiatedServices[uid] = newService;\n\n return this;\n },\n };\n};\n\nexport default servicesRegistry;\n"],"names":["pickBy","_","hasNamespace","addNamespace","has"],"mappings":";;;AASM,MAAA,mBAAmB,CAAC,WAAmB;AAC3C,QAAM,WAA8B,CAAA;AACpC,QAAM,uBAAmC,CAAA;AAElC,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,QAAQ;AAAA,IAC7B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAyB;AACvB,UAAA,qBAAqB,GAAG,GAAG;AAC7B,eAAO,qBAAqB,GAAG;AAAA,MACjC;AAEM,YAAA,UAAU,SAAS,GAAG;AAC5B,UAAI,SAAS;AACU,6BAAA,GAAG,I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ources":["../../../src/core/registries/services.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Strapi, Common } from '@strapi/types';\nimport { addNamespace, hasNamespace } from '../utils';\n\nexport type ServiceFactory = (params: { strapi: Strapi }) => Common.Service | Common.Service;\nexport type ServiceFactoryMap = Record<string, ServiceFactory>;\nexport type ServiceMap = Record<string, Common.Service>;\nexport type ServiceExtendFn = (service: Common.Service) => Common.Service;\n\nconst servicesRegistry = (strapi: Strapi) => {\n const services: ServiceFactoryMap = {};\n const instantiatedServices: ServiceMap = {};\n\n return {\n /**\n * Returns this list of registered services uids\n */\n keys() {\n return Object.keys(services);\n },\n\n /**\n * Returns the instance of a service. Instantiate the service if not already done\n */\n get(uid: Common.UID.Service) {\n if (instantiatedServices[uid]) {\n return instantiatedServices[uid];\n }\n\n const service = services[uid];\n if (service) {\n instantiatedServices[uid] = typeof service === 'function' ? service({ strapi }) : service;\n return instantiatedServices[uid];\n }\n },\n\n /**\n * Returns a map with all the services in a namespace\n */\n getAll(namespace: string): ServiceMap {\n const filteredServices = pickBy((_, uid) => hasNamespace(uid, namespace))(services);\n\n // create lazy accessor to avoid instantiating the services;\n const map = {};\n for (const uid of Object.keys(filteredServices)) {\n Object.defineProperty(map, uid, {\n enumerable: true,\n get: () => {\n return this.get(uid as Common.UID.Service);\n },\n });\n }\n\n return map;\n },\n\n /**\n * Registers a service\n */\n set(uid: string, service: ServiceFactory) {\n services[uid] = service;\n delete instantiatedServices[uid];\n return this;\n },\n\n /**\n * Registers a map of services for a specific namespace\n */\n add(namespace: string, newServices: ServiceFactoryMap) {\n for (const serviceName of Object.keys(newServices)) {\n const service = newServices[serviceName];\n const uid = addNamespace(serviceName, namespace);\n\n if (has(uid, services)) {\n throw new Error(`Service ${uid} has already been registered.`);\n }\n services[uid] = service;\n }\n\n return this;\n },\n\n /**\n * Wraps a service to extend it\n */\n extend(uid: Common.UID.Service, extendFn: ServiceExtendFn) {\n const currentService = this.get(uid);\n\n if (!currentService) {\n throw new Error(`Service ${uid} doesn't exist`);\n }\n\n const newService = extendFn(currentService);\n instantiatedServices[uid] = newService;\n\n return this;\n },\n };\n};\n\nexport default servicesRegistry;\n"],"names":["pickBy","hasNamespace","addNamespace","has"],"mappings":";;;AASM,MAAA,mBAAmB,CAAC,WAAmB;AAC3C,QAAM,WAA8B,CAAA;AACpC,QAAM,uBAAmC,CAAA;AAElC,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,QAAQ;AAAA,IAC7B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAyB;AACvB,UAAA,qBAAqB,GAAG,GAAG;AAC7B,eAAO,qBAAqB,GAAG;AAAA,MACjC;AAEM,YAAA,UAAU,SAAS,GAAG;AAC5B,UAAI,SAAS;AACU,6BAAA,GAAG,IAAI,OAAO,YAAY,aAAa,QAAQ,EAAE,QAAQ,IAAI;AAClF,eAAO,qBAAqB,GAAG;AAAA,MACjC;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,WAA+B;AAC9B,YAAA,mBAAmBA,GAAAA,OAAO,CAAC,GAAG,QAAQC,mBAAa,KAAK,SAAS,CAAC,EAAE,QAAQ;AAGlF,YAAM,MAAM,CAAA;AACZ,iBAAW,OAAO,OAAO,KAAK,gBAAgB,GAAG;AACxC,eAAA,eAAe,KAAK,KAAK;AAAA,UAC9B,YAAY;AAAA,UACZ,KAAK,MAAM;AACF,mBAAA,KAAK,IAAI,GAAyB;AAAA,UAC3C;AAAA,QAAA,CACD;AAAA,MACH;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAa,SAAyB;AACxC,eAAS,GAAG,IAAI;AAChB,aAAO,qBAAqB,GAAG;AACxB,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,WAAmB,aAAgC;AACrD,iBAAW,eAAe,OAAO,KAAK,WAAW,GAAG;AAC5C,cAAA,UAAU,YAAY,WAAW;AACjC,cAAA,MAAMC,MAAAA,aAAa,aAAa,SAAS;AAE3C,YAAAC,GAAA,IAAI,KAAK,QAAQ,GAAG;AACtB,gBAAM,IAAI,MAAM,WAAW,GAAG,+BAA+B;AAAA,QAC/D;AACA,iBAAS,GAAG,IAAI;AAAA,MAClB;AAEO,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,KAAyB,UAA2B;AACnD,YAAA,iBAAiB,KAAK,IAAI,GAAG;AAEnC,UAAI,CAAC,gBAAgB;AACnB,cAAM,IAAI,MAAM,WAAW,GAAG,gBAAgB;AAAA,MAChD;AAEM,YAAA,aAAa,SAAS,cAAc;AAC1C,2BAAqB,GAAG,IAAI;AAErB,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const strapiUtils = require("@strapi/utils");
4
4
  const transform = require("./transform.js");
5
5
  const createCollectionTypeController = ({
@@ -39,7 +39,7 @@ const createCollectionTypeController = ({
39
39
  await this.validateQuery(ctx);
40
40
  const sanitizedQuery = await this.sanitizeQuery(ctx);
41
41
  const body = transform.parseBody(ctx);
42
- if (!_.isObject(body.data)) {
42
+ if (!fp.isObject(body.data)) {
43
43
  throw new strapiUtils.errors.ValidationError('Missing "data" payload in the request body');
44
44
  }
45
45
  const sanitizedInputData = await this.sanitizeInput(body.data, ctx);
@@ -61,7 +61,7 @@ const createCollectionTypeController = ({
61
61
  await this.validateQuery(ctx);
62
62
  const sanitizedQuery = await this.sanitizeQuery(ctx);
63
63
  const body = transform.parseBody(ctx);
64
- if (!_.isObject(body.data)) {
64
+ if (!fp.isObject(body.data)) {
65
65
  throw new strapiUtils.errors.ValidationError('Missing "data" payload in the request body');
66
66
  }
67
67
  const sanitizedInputData = await this.sanitizeInput(body.data, ctx);
@@ -1 +1 @@
1
- {"version":3,"file":"collection-type.js","sources":["../../../src/core-api/controller/collection-type.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { CoreApi, Schema, Utils, Common } from '@strapi/types';\nimport type Koa from 'koa';\n\nimport { parseBody } from './transform';\n\ninterface Options {\n contentType: Schema.CollectionType;\n}\n\n/**\n *\n * Returns a collection type controller to handle default core-api actions\n */\nconst createCollectionTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<CoreApi.Controller.CollectionType> => {\n const uid = contentType.uid as Common.UID.Service;\n\n return {\n /**\n * Retrieve records.\n */\n async find(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const { results, pagination } = await strapi.service(uid).find(sanitizedQuery);\n const sanitizedResults = await this.sanitizeOutput(results, ctx);\n return this.transformResponse(sanitizedResults, { pagination });\n },\n\n /**\n * Retrieve a record.\n *\n * @return {Object}\n */\n async findOne(ctx) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).findOne(id, sanitizedQuery);\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Create a record.\n *\n * @return {Object}\n */\n async create(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const body = parseBody(ctx);\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).create({\n ...sanitizedQuery,\n data: sanitizedInputData,\n files: 'files' in body ? body.files : undefined,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Update a record.\n *\n * @return {Object}\n */\n async update(ctx: Koa.Context) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const body = parseBody(ctx);\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).update(id, {\n ...sanitizedQuery,\n data: sanitizedInputData,\n files: 'files' in body ? body.files : undefined,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Destroy a record.\n *\n * @return {Object}\n */\n async delete(ctx) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).delete(id, sanitizedQuery);\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n };\n};\n\nexport default createCollectionTypeController;\n"],"names":["parseBody","isObject","errors"],"mappings":";;;;AAeA,MAAM,iCAAiC,CAAC;AAAA,EACtC;AACF,MAAyE;AACvE,QAAM,MAAM,YAAY;AAEjB,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,MAAM,KAAK,KAAK;AACR,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAE7C,YAAA,EAAE,SAAS,WAAA,IAAe,MAAM,OAAO,QAAQ,GAAG,EAAE,KAAK,cAAc;AAC7E,YAAM,mBAAmB,MAAM,KAAK,eAAe,SAAS,GAAG;AAC/D,aAAO,KAAK,kBAAkB,kBAAkB,EAAE,WAAY,CAAA;AAAA,IAChE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,MAAM,QAAQ,KAAK;AACX,YAAA,EAAE,GAAG,IAAI,IAAI;AACb,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAE7C,YAAA,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,QAAQ,IAAI,cAAc;AACnE,YAAM,kBAAkB,MAAM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GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,MAAM,OAAO,KAAK;AACV,YAAA,EAAE,GAAG,IAAI,IAAI;AACb,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAE7C,YAAA,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,IAAI,cAAc;AAClE,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"collection-type.js","sources":["../../../src/core-api/controller/collection-type.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport type { CoreApi, Schema, Utils, Common } from '@strapi/types';\nimport type Koa from 'koa';\n\nimport { parseBody } from './transform';\n\ninterface Options {\n contentType: Schema.CollectionType;\n}\n\n/**\n *\n * Returns a collection type controller to handle default core-api actions\n */\nconst createCollectionTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<CoreApi.Controller.CollectionType> => {\n const uid = contentType.uid as Common.UID.Service;\n\n return {\n /**\n * Retrieve records.\n */\n async find(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const { results, pagination } = await strapi.service(uid).find(sanitizedQuery);\n const sanitizedResults = await this.sanitizeOutput(results, ctx);\n return this.transformResponse(sanitizedResults, { pagination });\n },\n\n /**\n * Retrieve a record.\n *\n * @return {Object}\n */\n async findOne(ctx) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).findOne(id, sanitizedQuery);\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Create a record.\n *\n * @return {Object}\n */\n async create(ctx) {\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const body = parseBody(ctx);\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).create({\n ...sanitizedQuery,\n data: sanitizedInputData,\n files: 'files' in body ? body.files : undefined,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Update a record.\n *\n * @return {Object}\n */\n async update(ctx: Koa.Context) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const body = parseBody(ctx);\n\n if (!isObject(body.data)) {\n throw new errors.ValidationError('Missing \"data\" payload in the request body');\n }\n\n const sanitizedInputData = await this.sanitizeInput(body.data, ctx);\n\n const entity = await strapi.service(uid).update(id, {\n ...sanitizedQuery,\n data: sanitizedInputData,\n files: 'files' in body ? body.files : undefined,\n });\n\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n\n /**\n * Destroy a record.\n *\n * @return {Object}\n */\n async delete(ctx) {\n const { id } = ctx.params;\n await this.validateQuery(ctx);\n const sanitizedQuery = await this.sanitizeQuery(ctx);\n\n const entity = await strapi.service(uid).delete(id, sanitizedQuery);\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n };\n};\n\nexport default createCollectionTypeController;\n"],"names":["parseBody","isObject","errors"],"mappings":";;;;AAeA,MAAM,iCAAiC,CAAC;AAAA,EACtC;AACF,MAAyE;AACvE,QAAM,MAAM,YAAY;AAEjB,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,MAAM,KAAK,KAAK;AACR,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAE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,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAE7C,YAAA,OAAOF,oBAAU,GAAG;AAE1B,UAAI,CAACC,GAAA,SAAS,KAAK,IAAI,GAAG;AAClB,cAAA,IAAIC,YAAO,OAAA,gBAAgB,4CAA4C;AAAA,MAC/E;AAEA,YAAM,qBAAqB,MAAM,KAAK,cAAc,KAAK,MAAM,GAAG;AAElE,YAAM,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,IAAI;AAAA,QAClD,GAAG;AAAA,QACH,MAAM;AAAA,QACN,OAAO,WAAW,OAAO,KAAK,QAAQ;AAAA,MAAA,CACvC;AAED,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,MAAM,OAAO,KAAK;AACV,YAAA,EAAE,GAAG,IAAI,IAAI;AACb,YAAA,KAAK,cAAc,GAAG;AAC5B,YAAM,iBAAiB,MAAM,KAAK,cAAc,GAAG;AAE7C,YAAA,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,IAAI,cAAc;AAClE,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;AAAA,EAAA;AAEJ;;"}
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const _ = require("lodash/fp");
3
+ const fp = require("lodash/fp");
4
4
  const strapiUtils = require("@strapi/utils");
5
5
  const transform = require("./transform.js");
6
6
  const singleType = require("./single-type.js");
7
7
  const collectionType = require("./collection-type.js");
8
8
  const isSingleType = (contentType) => strapiUtils.contentTypes.isSingleType(contentType);
9
- const getAuthFromKoaContext = (ctx) => _.prop("state.auth", ctx) ?? {};
9
+ const getAuthFromKoaContext = (ctx) => fp.prop("state.auth", ctx) ?? {};
10
10
  function createController({
11
11
  contentType
12
12
  }) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/core-api/controller/index.ts"],"sourcesContent":["import { prop } from 'lodash/fp';\nimport type Koa from 'koa';\nimport { contentTypes as contentTypeUtils, sanitize, validate } from '@strapi/utils';\nimport type { CoreApi, Schema } from '@strapi/types';\n\nimport { transformResponse } from './transform';\nimport createSingleTypeController from './single-type';\nimport createCollectionTypeController from './collection-type';\n\nconst isSingleType = (contentType: Schema.ContentType): contentType is Schema.SingleType =>\n contentTypeUtils.isSingleType(contentType);\n\nconst getAuthFromKoaContext = (ctx: Koa.Context) => prop('state.auth', ctx) ?? {};\n\nfunction createController<T extends Schema.SingleType | Schema.CollectionType>(opts: {\n contentType: T;\n}): T extends Schema.SingleType ? CoreApi.Controller.SingleType : CoreApi.Controller.CollectionType;\nfunction createController({\n contentType,\n}: {\n contentType: Schema.SingleType | Schema.CollectionType;\n}) {\n const proto: CoreApi.Controller.Base = {\n transformResponse(data, meta) {\n return transformResponse(data, meta, { contentType });\n },\n\n async sanitizeOutput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return sanitize.contentAPI.output(data, contentType, { auth });\n },\n\n async sanitizeInput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return sanitize.contentAPI.input(data, contentType, { auth });\n },\n\n async sanitizeQuery(ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return sanitize.contentAPI.query(ctx.query, contentType, { auth });\n },\n\n async validateQuery(ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return validate.contentAPI.query(ctx.query, contentType, { auth });\n },\n\n async validateInput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return validate.contentAPI.input(data, contentType, { auth });\n },\n };\n\n let ctrl;\n\n if (isSingleType(contentType)) {\n ctrl = createSingleTypeController({ contentType });\n } else {\n ctrl = createCollectionTypeController({ contentType });\n }\n\n return Object.assign(Object.create(proto), ctrl);\n}\n\nexport { createController };\n"],"names":["contentTypeUtils","prop","transformResponse","sanitize","validate","createSingleTypeController","createCollectionTypeController"],"mappings":";;;;;;;AASA,MAAM,eAAe,CAAC,gBACpBA,YAAA,aAAiB,aAAa,WAAW;AAE3C,MAAM,wBAAwB,CAAC,QAAqBC,EAAAA,KAAK,cAAc,GAAG,KAAK;AAK/E,SAAS,iBAAiB;AAAA,EACxB;AACF,GAEG;AACD,QAAM,QAAiC;AAAA,IACrC,kBAAkB,MAAM,MAAM;AAC5B,aAAOC,UAAkB,kBAAA,MAAM,MAAM,EAAE,YAAa,CAAA;AAAA,IACtD;AAAA,IAEA,MAAM,eAAe,MAAM,KAAK;AACxB,YAAA,OAAO,sBAAsB,GAAG;AAEtC,aAAOC,YAAAA,SAAS,WAAW,OAAO,MAAM,aAAa,EAAE,MAAM;AAAA,IAC/D;AAAA,IAEA,MAAM,cAAc,MAAM,KAAK;AACvB,YAAA,OAAO,sBAAsB,GAAG;AAEtC,aAAOA,YAAAA,SAAS,WAAW,MAAM,MAAM,aAAa,EAAE,MAAM;AAAA,IAC9D;AAAA,IAEA,MAAM,cAAc,KAAK;AACjB,YAAA,OAAO,sBAAsB,GAAG;AAE/B,aAAAA,YAAA,SAAS,WAAW,MAAM,IAAI,OAAO,aAAa,EAAE,MAAM;AAAA,IACnE;AAAA,IAEA,MAAM,cAAc,KAAK;AACjB,YAAA,OAAO,sBAAsB,GAAG;AAE/B,aAAAC,YAAA,SAAS,WAAW,MAAM,IAAI,OAAO,aAAa,EAAE,MAAM;AAAA,IACnE;AAAA,IAEA,MAAM,cAAc,MAAM,KAAK;AACvB,YAAA,OAAO,sBAAsB,GAAG;AAEtC,aAAOA,YAAAA,SAAS,WAAW,MAAM,MAAM,aAAa,EAAE,MAAM;AAAA,IAC9D;AAAA,EAAA;AAGE,MAAA;AAEA,MAAA,aAAa,WAAW,GAAG;AACtB,WAAAC,WAA2B,EAAE,YAAA,CAAa;AAAA,EAAA,OAC5C;AACE,WAAAC,eAA+B,EAAE,YAAA,CAAa;AAAA,EACvD;AAEA,SAAO,OAAO,OAAO,OAAO,OAAO,KAAK,GAAG,IAAI;AACjD;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/core-api/controller/index.ts"],"sourcesContent":["import { prop } from 'lodash/fp';\nimport type Koa from 'koa';\nimport { contentTypes as contentTypeUtils, sanitize, validate } from '@strapi/utils';\nimport type { CoreApi, Schema } from '@strapi/types';\n\nimport { transformResponse } from './transform';\nimport createSingleTypeController from './single-type';\nimport createCollectionTypeController from './collection-type';\n\nconst isSingleType = (contentType: Schema.ContentType): contentType is Schema.SingleType =>\n contentTypeUtils.isSingleType(contentType);\n\nconst getAuthFromKoaContext = (ctx: Koa.Context) => prop('state.auth', ctx) ?? {};\n\nfunction createController<T extends Schema.SingleType | Schema.CollectionType>(opts: {\n contentType: T;\n}): T extends Schema.SingleType ? CoreApi.Controller.SingleType : CoreApi.Controller.CollectionType;\nfunction createController({\n contentType,\n}: {\n contentType: Schema.SingleType | Schema.CollectionType;\n}) {\n const proto: CoreApi.Controller.Base = {\n transformResponse(data, meta) {\n return transformResponse(data, meta, { contentType });\n },\n\n async sanitizeOutput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return sanitize.contentAPI.output(data, contentType, { auth });\n },\n\n async sanitizeInput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return sanitize.contentAPI.input(data, contentType, { auth });\n },\n\n async sanitizeQuery(ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return sanitize.contentAPI.query(ctx.query, contentType, { auth });\n },\n\n async validateQuery(ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return validate.contentAPI.query(ctx.query, contentType, { auth });\n },\n\n async validateInput(data, ctx) {\n const auth = getAuthFromKoaContext(ctx);\n\n return validate.contentAPI.input(data, contentType, { auth });\n },\n };\n\n let ctrl;\n\n if (isSingleType(contentType)) {\n ctrl = createSingleTypeController({ contentType });\n } else {\n ctrl = createCollectionTypeController({ contentType });\n }\n\n return Object.assign(Object.create(proto), ctrl);\n}\n\nexport { createController };\n"],"names":["contentTypeUtils","prop","transformResponse","sanitize","validate","createSingleTypeController","createCollectionTypeController"],"mappings":";;;;;;;AASA,MAAM,eAAe,CAAC,gBACpBA,YAAA,aAAiB,aAAa,WAAW;AAE3C,MAAM,wBAAwB,CAAC,QAAqBC,GAAAA,KAAK,cAAc,GAAG,KAAK;AAK/E,SAAS,iBAAiB;AAAA,EACxB;AACF,GAEG;AACD,QAAM,QAAiC;AAAA,IACrC,kBAAkB,MAAM,MAAM;AAC5B,aAAOC,UAAkB,kBAAA,MAAM,MAAM,EAAE,YAAa,CAAA;AAAA,IACtD;AAAA,IAEA,MAAM,eAAe,MAAM,KAAK;AACxB,YAAA,OAAO,sBAAsB,GAAG;AAEtC,aAAOC,YAAAA,SAAS,WAAW,OAAO,MAAM,aAAa,EAAE,MAAM;AAAA,IAC/D;AAAA,IAEA,MAAM,cAAc,MAAM,KAAK;AACvB,YAAA,OAAO,sBAAsB,GAAG;AAEtC,aAAOA,YAAAA,SAAS,WAAW,MAAM,MAAM,aAAa,EAAE,MAAM;AAAA,IAC9D;AAAA,IAEA,MAAM,cAAc,KAAK;AACjB,YAAA,OAAO,sBAAsB,GAAG;AAE/B,aAAAA,YAAA,SAAS,WAAW,MAAM,IAAI,OAAO,aAAa,EAAE,MAAM;AAAA,IACnE;AAAA,IAEA,MAAM,cAAc,KAAK;AACjB,YAAA,OAAO,sBAAsB,GAAG;AAE/B,aAAAC,YAAA,SAAS,WAAW,MAAM,IAAI,OAAO,aAAa,EAAE,MAAM;AAAA,IACnE;AAAA,IAEA,MAAM,cAAc,MAAM,KAAK;AACvB,YAAA,OAAO,sBAAsB,GAAG;AAEtC,aAAOA,YAAAA,SAAS,WAAW,MAAM,MAAM,aAAa,EAAE,MAAM;AAAA,IAC9D;AAAA,EAAA;AAGE,MAAA;AAEA,MAAA,aAAa,WAAW,GAAG;AACtB,WAAAC,WAA2B,EAAE,YAAA,CAAa;AAAA,EAAA,OAC5C;AACE,WAAAC,eAA+B,EAAE,YAAA,CAAa;AAAA,EACvD;AAEA,SAAO,OAAO,OAAO,OAAO,OAAO,KAAK,GAAG,IAAI;AACjD;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const _ = require("lodash/fp");
2
+ const fp = require("lodash/fp");
3
3
  const strapiUtils = require("@strapi/utils");
4
4
  const transform = require("./transform.js");
5
5
  const createSingleTypeController = ({
@@ -26,7 +26,7 @@ const createSingleTypeController = ({
26
26
  async update(ctx) {
27
27
  const { query } = ctx.request;
28
28
  const body = transform.parseBody(ctx);
29
- if (!_.isObject(body.data)) {
29
+ if (!fp.isObject(body.data)) {
30
30
  throw new strapiUtils.errors.ValidationError('Missing "data" payload in the request body');
31
31
  }
32
32
  const sanitizedInputData = await this.sanitizeInput(body.data, ctx);
@@ -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 { Schema, CoreApi, Utils, Common } from '@strapi/types';\n\nimport { parseBody } from './transform';\n\ninterface Options {\n contentType: Schema.SingleType;\n}\n\n/**\n * Returns a single type controller to handle default core-api actions\n */\nconst createSingleTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<CoreApi.Controller.SingleType> => {\n const uid = contentType.uid as Common.UID.Service;\n\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 * @return {Object}\n */\n async update(ctx) {\n const { query } = ctx.request;\n const body = parseBody(ctx);\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 files: 'files' in body ? body.files : undefined,\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 const entity = await strapi.service(uid).delete(query);\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n };\n};\n\nexport default createSingleTypeController;\n"],"names":["parseBody","isObject","errors"],"mappings":";;;;AAaA,MAAM,6BAA6B,CAAC;AAAA,EAClC;AACF,MAAqE;AACnE,QAAM,MAAM,YAAY;AAEjB,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;AAAA;AAAA,IAOA,MAAM,OAAO,KAAK;AACV,YAAA,EAAE,MAAM,IAAI,IAAI;AAChB,YAAA,OAAOA,oBAAU,GAAG;AAE1B,UAAI,CAACC,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,QACN,OAAO,WAAW,OAAO,KAAK,QAAQ;AAAA,MAAA,CACvC;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,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,KAAK;AACrD,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAAe;AAAA,IAC/C;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 { Schema, CoreApi, Utils, Common } from '@strapi/types';\n\nimport { parseBody } from './transform';\n\ninterface Options {\n contentType: Schema.SingleType;\n}\n\n/**\n * Returns a single type controller to handle default core-api actions\n */\nconst createSingleTypeController = ({\n contentType,\n}: Options): Utils.PartialWithThis<CoreApi.Controller.SingleType> => {\n const uid = contentType.uid as Common.UID.Service;\n\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 * @return {Object}\n */\n async update(ctx) {\n const { query } = ctx.request;\n const body = parseBody(ctx);\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 files: 'files' in body ? body.files : undefined,\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 const entity = await strapi.service(uid).delete(query);\n const sanitizedEntity = await this.sanitizeOutput(entity, ctx);\n\n return this.transformResponse(sanitizedEntity);\n },\n };\n};\n\nexport default createSingleTypeController;\n"],"names":["parseBody","isObject","errors"],"mappings":";;;;AAaA,MAAM,6BAA6B,CAAC;AAAA,EAClC;AACF,MAAqE;AACnE,QAAM,MAAM,YAAY;AAEjB,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;AAAA;AAAA,IAOA,MAAM,OAAO,KAAK;AACV,YAAA,EAAE,MAAM,IAAI,IAAI;AAChB,YAAA,OAAOA,oBAAU,GAAG;AAE1B,UAAI,CAACC,GAAA,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,QACN,OAAO,WAAW,OAAO,KAAK,QAAQ;AAAA,MAAA,CACvC;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,SAAS,MAAM,OAAO,QAAQ,GAAG,EAAE,OAAO,KAAK;AACrD,YAAM,kBAAkB,MAAM,KAAK,eAAe,QAAQ,GAAG;AAEtD,aAAA,KAAK,kBAAkB,eAA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