@strapi/plugin-documentation 5.48.1 → 5.50.0

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 (50) hide show
  1. package/dist/admin/components/SettingsForm.js +4 -3
  2. package/dist/admin/components/SettingsForm.js.map +1 -1
  3. package/dist/admin/pages/App.js +3 -2
  4. package/dist/admin/pages/App.js.map +1 -1
  5. package/dist/server/controllers/documentation.js +29 -21
  6. package/dist/server/controllers/documentation.js.map +1 -1
  7. package/dist/server/middlewares/documentation.js +8 -2
  8. package/dist/server/middlewares/documentation.js.map +1 -1
  9. package/dist/server/public/index.html.js +1 -1
  10. package/dist/server/public/index.html.mjs +1 -1
  11. package/dist/server/public/login.html.js +1 -1
  12. package/dist/server/public/login.html.mjs +1 -1
  13. package/dist/server/services/documentation.js +16 -11
  14. package/dist/server/services/documentation.js.map +1 -1
  15. package/dist/server/services/helpers/build-api-endpoint-path.js +9 -5
  16. package/dist/server/services/helpers/build-api-endpoint-path.js.map +1 -1
  17. package/dist/server/services/helpers/build-component-schema.js +5 -1
  18. package/dist/server/services/helpers/build-component-schema.js.map +1 -1
  19. package/dist/server/services/helpers/utils/clean-schema-attributes.js.map +1 -1
  20. package/dist/server/services/helpers/utils/clean-schema-attributes.mjs.map +1 -1
  21. package/dist/server/services/helpers/utils/loop-content-type-names.js +6 -2
  22. package/dist/server/services/helpers/utils/loop-content-type-names.js.map +1 -1
  23. package/dist/server/services/helpers/utils/pascal-case.js +5 -1
  24. package/dist/server/services/helpers/utils/pascal-case.js.map +1 -1
  25. package/dist/server/src/controllers/documentation.d.ts +2 -2
  26. package/dist/server/src/controllers/documentation.d.ts.map +1 -1
  27. package/dist/server/src/controllers/index.d.ts +2 -3
  28. package/dist/server/src/controllers/index.d.ts.map +1 -1
  29. package/dist/server/src/index.d.ts +5 -6
  30. package/dist/server/src/index.d.ts.map +1 -1
  31. package/dist/server/src/middlewares/documentation.d.ts.map +1 -1
  32. package/dist/server/src/middlewares/restrict-access.d.ts.map +1 -1
  33. package/dist/server/src/routes/index.d.ts +0 -1
  34. package/dist/server/src/routes/index.d.ts.map +1 -1
  35. package/dist/server/src/services/documentation.d.ts.map +1 -1
  36. package/dist/server/src/services/helpers/build-api-endpoint-path.d.ts.map +1 -1
  37. package/dist/server/src/services/helpers/build-component-schema.d.ts.map +1 -1
  38. package/dist/server/src/services/helpers/utils/clean-schema-attributes.d.ts +1 -1
  39. package/dist/server/src/services/helpers/utils/clean-schema-attributes.d.ts.map +1 -1
  40. package/dist/server/src/services/helpers/utils/get-api-responses.d.ts.map +1 -1
  41. package/dist/server/src/services/helpers/utils/get-schema-data.d.ts.map +1 -1
  42. package/dist/server/src/services/helpers/utils/loop-content-type-names.d.ts.map +1 -1
  43. package/dist/server/src/services/helpers/utils/pascal-case.d.ts.map +1 -1
  44. package/dist/server/src/services/helpers/utils/routes.d.ts.map +1 -1
  45. package/dist/server/src/services/index.d.ts +3 -3
  46. package/dist/server/src/services/index.d.ts.map +1 -1
  47. package/dist/server/src/services/override.d.ts.map +1 -1
  48. package/dist/server/src/services/utils/get-plugins-that-need-documentation.d.ts.map +1 -1
  49. package/dist/server/src/utils.d.ts.map +1 -1
  50. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"documentation.js","sources":["../../../server/src/services/documentation.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs-extra';\nimport { produce } from 'immer';\nimport type { Core } from '@strapi/types';\n\nimport { builApiEndpointPath, buildComponentSchema } from './helpers';\nimport { getPluginsThatNeedDocumentation } from './utils/get-plugins-that-need-documentation';\nimport { getService } from '../utils';\n\nimport type { Config, PluginConfig } from '../types';\n\nexport type Version = {\n version: string;\n generatedDate: string;\n url: string;\n};\n\nexport type DocumentationService = ReturnType<typeof createService>;\n\nconst createService = ({ strapi }: { strapi: Core.Strapi }) => {\n const config = strapi.config.get('plugin::documentation') as PluginConfig;\n const pluginsThatNeedDocumentation = getPluginsThatNeedDocumentation(config);\n const overrideService = getService('override');\n\n return {\n getDocumentationVersion() {\n return config.info.version;\n },\n\n getFullDocumentationPath() {\n // In production, documentation files live under dist/src/extensions/\n // after the build step. Use dist.extensions for reading.\n const extensionsDir =\n strapi.config.environment === 'production'\n ? strapi.dirs.dist.extensions\n : strapi.dirs.app.extensions;\n\n return path.join(extensionsDir, 'documentation', 'documentation');\n },\n\n getDocumentationVersions(): Version[] {\n return fs\n .readdirSync(this.getFullDocumentationPath())\n .map((version) => {\n try {\n const filePath = path.resolve(\n this.getFullDocumentationPath(),\n version,\n 'full_documentation.json'\n );\n\n const doc = JSON.parse(fs.readFileSync(filePath).toString());\n\n const generatedDate = doc.info['x-generation-date'];\n\n return { version, generatedDate, url: '' };\n } catch (err) {\n return null;\n }\n })\n .filter((x) => x) as Version[];\n },\n\n /**\n * Returns settings stored in core-store\n */\n async getDocumentationAccess() {\n const { restrictedAccess } = (await strapi.store!({\n environment: '',\n type: 'plugin',\n name: 'documentation',\n key: 'config',\n }).get()) as Config;\n\n return { restrictedAccess };\n },\n\n getApiDocumentationPath(api: { name: string; getter: string }) {\n const isProduction = strapi.config.environment === 'production';\n\n if (api.getter === 'plugin') {\n const extensionsDir = isProduction\n ? strapi.dirs.dist.extensions\n : strapi.dirs.app.extensions;\n return path.join(extensionsDir, api.name, 'documentation');\n }\n\n const apiDir = isProduction ? strapi.dirs.dist.api : strapi.dirs.app.api;\n return path.join(apiDir, api.name, 'documentation');\n },\n\n async deleteDocumentation(version: string) {\n const apis = this.getPluginAndApiInfo();\n for (const api of apis) {\n await fs.remove(path.join(this.getApiDocumentationPath(api), version));\n }\n\n await fs.remove(path.join(this.getFullDocumentationPath(), version));\n },\n\n getPluginAndApiInfo() {\n const pluginsToDocument = pluginsThatNeedDocumentation.map((plugin) => {\n return {\n name: plugin,\n getter: 'plugin',\n ctNames: Object.keys(strapi.plugin(plugin).contentTypes),\n };\n });\n\n const apisToDocument = Object.keys(strapi.apis).map((api) => {\n return {\n name: api,\n getter: 'api',\n ctNames: Object.keys(strapi.api(api).contentTypes),\n };\n });\n\n return [...apisToDocument, ...pluginsToDocument];\n },\n\n /**\n * @description - Creates the Swagger json files\n */\n async generateFullDoc(versionOpt?: string) {\n const version = versionOpt ?? this.getDocumentationVersion();\n\n const apis = this.getPluginAndApiInfo();\n const apisThatNeedGeneratedDocumentation = apis.filter(\n ({ name }) => !overrideService.isEnabled(name)\n );\n\n // Initialize the generated documentation with defaults\n const generatedDocumentation = await produce(config, async (draft) => {\n if (draft.servers?.length === 0) {\n // When no servers found set the defaults\n const serverUrl = strapi.config.get('server.absoluteUrl');\n const apiPath = strapi.config.get('api.rest.prefix');\n draft.servers = [\n {\n url: `${serverUrl}${apiPath}`,\n description: 'Development server',\n },\n ];\n }\n\n if (!draft.components) {\n draft.components = {};\n }\n\n // Set the generated date\n draft.info['x-generation-date'] = new Date().toISOString();\n // Set the plugins that need documentation\n draft['x-strapi-config'].plugins = pluginsThatNeedDocumentation;\n\n // Delete the mutateDocumentation key from the config so it doesn't end up in the spec\n delete draft['x-strapi-config'].mutateDocumentation;\n\n // Generate the documentation for each api and update the generatedDocumentation\n for (const api of apisThatNeedGeneratedDocumentation) {\n const newApiPath = builApiEndpointPath(api);\n const generatedSchemas = buildComponentSchema(api);\n\n if (generatedSchemas) {\n draft.components.schemas = { ...draft.components.schemas, ...generatedSchemas };\n }\n\n if (newApiPath) {\n draft.paths = { ...draft.paths, ...newApiPath };\n }\n }\n\n // When overrides are present update the generatedDocumentation\n if (overrideService.registeredOverrides.length > 0) {\n overrideService.registeredOverrides.forEach((override: Partial<PluginConfig>) => {\n // Only run the overrrides when no override version is provided,\n // or when the generated documentation version matches the override version\n if (!override?.info?.version || override.info.version === version) {\n if (override.tags) {\n // Merge override tags with the generated tags\n draft.tags = draft.tags || [];\n draft.tags.push(...override.tags);\n }\n\n if (override.paths) {\n // Merge override paths with the generated paths\n // The override will add a new path or replace the value of an existing path\n draft.paths = { ...draft.paths, ...override.paths };\n }\n\n if (override.components) {\n const keys = Object.keys(override.components) as Array<\n keyof typeof override.components\n >;\n\n keys.forEach((overrideKey) => {\n draft.components = draft.components || {};\n\n const overrideValue = override.components?.[overrideKey];\n const originalValue = draft.components?.[overrideKey];\n\n Object.assign(draft.components, {\n [overrideKey]: {\n ...originalValue,\n ...overrideValue,\n },\n });\n });\n }\n }\n });\n }\n });\n\n // Escape hatch, allow the user to provide a mutateDocumentation function that can alter any part of\n // the generated documentation before it is written to the file system\n const userMutatesDocumentation = config['x-strapi-config'].mutateDocumentation;\n\n const finalDocumentation = userMutatesDocumentation\n ? produce(generatedDocumentation, userMutatesDocumentation)\n : generatedDocumentation;\n\n // Get the file path for the final documentation\n const fullDocJsonPath = path.join(\n this.getFullDocumentationPath(),\n version,\n 'full_documentation.json'\n );\n // Write the documentation to the file system\n await fs.ensureFile(fullDocJsonPath);\n await fs.writeJson(fullDocJsonPath, finalDocumentation, { spaces: 2 });\n },\n };\n};\n\nexport default createService;\n"],"names":["createService","strapi","config","get","pluginsThatNeedDocumentation","getPluginsThatNeedDocumentation","overrideService","getService","getDocumentationVersion","info","version","getFullDocumentationPath","extensionsDir","environment","dirs","dist","extensions","app","path","join","getDocumentationVersions","fs","readdirSync","map","filePath","resolve","doc","JSON","parse","readFileSync","toString","generatedDate","url","err","filter","x","getDocumentationAccess","restrictedAccess","store","type","name","key","getApiDocumentationPath","api","isProduction","getter","apiDir","deleteDocumentation","apis","getPluginAndApiInfo","remove","pluginsToDocument","plugin","ctNames","Object","keys","contentTypes","apisToDocument","generateFullDoc","versionOpt","apisThatNeedGeneratedDocumentation","isEnabled","generatedDocumentation","produce","draft","servers","length","serverUrl","apiPath","description","components","Date","toISOString","plugins","mutateDocumentation","newApiPath","builApiEndpointPath","generatedSchemas","buildComponentSchema","schemas","paths","registeredOverrides","forEach","override","tags","push","overrideKey","overrideValue","originalValue","assign","userMutatesDocumentation","finalDocumentation","fullDocJsonPath","ensureFile","writeJson","spaces"],"mappings":";;;;;;;;;;AAmBA,MAAMA,aAAAA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AAA,CAAMM,UAAU,IAAI,EAAC;AAExC,oCAAA,MAAMiB,aAAAA,GAAgBJ,QAAAA,CAASb,UAAU,GAAGgB,WAAAA,CAAY;AACxD,oCAAA,MAAME,aAAAA,GAAgBxB,KAAAA,CAAMM,UAAU,GAAGgB,WAAAA,CAAY;AAErDhC,oCAAAA,MAAAA,CAAOmC,MAAM,CAACzB,KAAAA,CAAMM,UAAU,EAAE;AAC9B,wCAAA,CAACgB,cAAc;AACb,4CAAA,GAAGE,aAAa;AAChB,4CAAA,GAAGD;AACL;AACF,qCAAA,CAAA;AACF,gCAAA,CAAA,CAAA;AACF,4BAAA;AACF,wBAAA;AACF,oBAAA,CAAA,CAAA;AACF,gBAAA;AACF,YAAA,CAAA,CAAA;;;AAIA,YAAA,MAAMG,wBAAAA,GAA2BxF,MAAM,CAAC,iBAAA,CAAkB,CAACwE,mBAAmB;AAE9E,YAAA,MAAMiB,kBAAAA,GAAqBD,wBAAAA,GACvB3B,aAAAA,CAAQD,sBAAAA,EAAwB4B,wBAAAA,CAAAA,GAChC5B,sBAAAA;;YAGJ,MAAM8B,eAAAA,GAAkB1E,KAAKC,IAAI,CAC/B,IAAI,CAACR,wBAAwB,IAC7BD,OAAAA,EACA,yBAAA,CAAA;;YAGF,MAAMW,EAAAA,CAAGwE,UAAU,CAACD,eAAAA,CAAAA;AACpB,YAAA,MAAMvE,EAAAA,CAAGyE,SAAS,CAACF,eAAAA,EAAiBD,kBAAAA,EAAoB;gBAAEI,MAAAA,EAAQ;AAAE,aAAA,CAAA;AACtE,QAAA;AACF,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"documentation.js","sources":["../../../server/src/services/documentation.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs-extra';\nimport { produce } from 'immer';\nimport type { Core } from '@strapi/types';\n\nimport { builApiEndpointPath, buildComponentSchema } from './helpers';\nimport { getPluginsThatNeedDocumentation } from './utils/get-plugins-that-need-documentation';\nimport { getService } from '../utils';\n\nimport type { Config, PluginConfig } from '../types';\n\nexport type Version = {\n version: string;\n generatedDate: string;\n url: string;\n};\n\nexport type DocumentationService = ReturnType<typeof createService>;\n\nconst createService = ({ strapi }: { strapi: Core.Strapi }) => {\n const config = strapi.config.get('plugin::documentation') as PluginConfig;\n const pluginsThatNeedDocumentation = getPluginsThatNeedDocumentation(config);\n const overrideService = getService('override');\n\n return {\n getDocumentationVersion() {\n return config.info.version;\n },\n\n getFullDocumentationPath() {\n // In production, documentation files live under dist/src/extensions/\n // after the build step. Use dist.extensions for reading.\n const extensionsDir =\n strapi.config.environment === 'production'\n ? strapi.dirs.dist.extensions\n : strapi.dirs.app.extensions;\n\n return path.join(extensionsDir, 'documentation', 'documentation');\n },\n\n getDocumentationVersions(): Version[] {\n return fs\n .readdirSync(this.getFullDocumentationPath())\n .map((version) => {\n try {\n const filePath = path.resolve(\n this.getFullDocumentationPath(),\n version,\n 'full_documentation.json'\n );\n\n const doc = JSON.parse(fs.readFileSync(filePath).toString());\n\n const generatedDate = doc.info['x-generation-date'];\n\n return { version, generatedDate, url: '' };\n } catch (err) {\n return null;\n }\n })\n .filter((x) => x) as Version[];\n },\n\n /**\n * Returns settings stored in core-store\n */\n async getDocumentationAccess() {\n const { restrictedAccess } = (await strapi.store!({\n environment: '',\n type: 'plugin',\n name: 'documentation',\n key: 'config',\n }).get()) as Config;\n\n return { restrictedAccess };\n },\n\n getApiDocumentationPath(api: { name: string; getter: string }) {\n const isProduction = strapi.config.environment === 'production';\n\n if (api.getter === 'plugin') {\n const extensionsDir = isProduction\n ? strapi.dirs.dist.extensions\n : strapi.dirs.app.extensions;\n return path.join(extensionsDir, api.name, 'documentation');\n }\n\n const apiDir = isProduction ? strapi.dirs.dist.api : strapi.dirs.app.api;\n return path.join(apiDir, api.name, 'documentation');\n },\n\n async deleteDocumentation(version: string) {\n const apis = this.getPluginAndApiInfo();\n for (const api of apis) {\n await fs.remove(path.join(this.getApiDocumentationPath(api), version));\n }\n\n await fs.remove(path.join(this.getFullDocumentationPath(), version));\n },\n\n getPluginAndApiInfo() {\n const pluginsToDocument = pluginsThatNeedDocumentation.map((plugin) => {\n return {\n name: plugin,\n getter: 'plugin',\n ctNames: Object.keys(strapi.plugin(plugin).contentTypes),\n };\n });\n\n const apisToDocument = Object.keys(strapi.apis).map((api) => {\n return {\n name: api,\n getter: 'api',\n ctNames: Object.keys(strapi.api(api).contentTypes),\n };\n });\n\n return [...apisToDocument, ...pluginsToDocument];\n },\n\n /**\n * @description - Creates the Swagger json files\n */\n async generateFullDoc(versionOpt?: string) {\n const version = versionOpt ?? this.getDocumentationVersion();\n\n const apis = this.getPluginAndApiInfo();\n const apisThatNeedGeneratedDocumentation = apis.filter(\n ({ name }) => !overrideService.isEnabled(name)\n );\n\n // Initialize the generated documentation with defaults\n const generatedDocumentation = await produce(config, async (draft) => {\n if (draft.servers?.length === 0) {\n // When no servers found set the defaults\n const serverUrl = strapi.config.get('server.absoluteUrl');\n const apiPath = strapi.config.get('api.rest.prefix');\n draft.servers = [\n {\n url: `${serverUrl}${apiPath}`,\n description: 'Development server',\n },\n ];\n }\n\n if (!draft.components) {\n draft.components = {};\n }\n\n // Set the generated date\n draft.info['x-generation-date'] = new Date().toISOString();\n // Set the plugins that need documentation\n draft['x-strapi-config'].plugins = pluginsThatNeedDocumentation;\n\n // Delete the mutateDocumentation key from the config so it doesn't end up in the spec\n delete draft['x-strapi-config'].mutateDocumentation;\n\n // Generate the documentation for each api and update the generatedDocumentation\n for (const api of apisThatNeedGeneratedDocumentation) {\n const newApiPath = builApiEndpointPath(api);\n const generatedSchemas = buildComponentSchema(api);\n\n if (generatedSchemas) {\n draft.components.schemas = { ...draft.components.schemas, ...generatedSchemas };\n }\n\n if (newApiPath) {\n draft.paths = { ...draft.paths, ...newApiPath };\n }\n }\n\n // When overrides are present update the generatedDocumentation\n if (overrideService.registeredOverrides.length > 0) {\n overrideService.registeredOverrides.forEach((override: Partial<PluginConfig>) => {\n // Only run the overrrides when no override version is provided,\n // or when the generated documentation version matches the override version\n if (!override?.info?.version || override.info.version === version) {\n if (override.tags) {\n // Merge override tags with the generated tags\n draft.tags = draft.tags || [];\n draft.tags.push(...override.tags);\n }\n\n if (override.paths) {\n // Merge override paths with the generated paths\n // The override will add a new path or replace the value of an existing path\n draft.paths = { ...draft.paths, ...override.paths };\n }\n\n if (override.components) {\n const keys = Object.keys(override.components) as Array<\n keyof typeof override.components\n >;\n\n keys.forEach((overrideKey) => {\n draft.components = draft.components || {};\n\n const overrideValue = override.components?.[overrideKey];\n const originalValue = draft.components?.[overrideKey];\n\n Object.assign(draft.components, {\n [overrideKey]: {\n ...originalValue,\n ...overrideValue,\n },\n });\n });\n }\n }\n });\n }\n });\n\n // Escape hatch, allow the user to provide a mutateDocumentation function that can alter any part of\n // the generated documentation before it is written to the file system\n const userMutatesDocumentation = config['x-strapi-config'].mutateDocumentation;\n\n const finalDocumentation = userMutatesDocumentation\n ? produce(generatedDocumentation, userMutatesDocumentation)\n : generatedDocumentation;\n\n // Get the file path for the final documentation\n const fullDocJsonPath = path.join(\n this.getFullDocumentationPath(),\n version,\n 'full_documentation.json'\n );\n // Write the documentation to the file system\n await fs.ensureFile(fullDocJsonPath);\n await fs.writeJson(fullDocJsonPath, finalDocumentation, { spaces: 2 });\n },\n };\n};\n\nexport default createService;\n"],"names":["createService","strapi","config","get","pluginsThatNeedDocumentation","getPluginsThatNeedDocumentation","overrideService","getService","getDocumentationVersion","info","version","getFullDocumentationPath","extensionsDir","environment","dirs","dist","extensions","app","path","join","getDocumentationVersions","fs","readdirSync","map","filePath","resolve","doc","JSON","parse","readFileSync","toString","generatedDate","url","err","filter","x","getDocumentationAccess","restrictedAccess","store","type","name","key","getApiDocumentationPath","api","isProduction","getter","apiDir","deleteDocumentation","apis","getPluginAndApiInfo","remove","pluginsToDocument","plugin","ctNames","Object","keys","contentTypes","apisToDocument","generateFullDoc","versionOpt","apisThatNeedGeneratedDocumentation","isEnabled","generatedDocumentation","produce","draft","servers","length","serverUrl","apiPath","description","components","Date","toISOString","plugins","mutateDocumentation","newApiPath","builApiEndpointPath","generatedSchemas","buildComponentSchema","schemas","paths","registeredOverrides","forEach","override","tags","push","overrideKey","overrideValue","originalValue","assign","userMutatesDocumentation","finalDocumentation","fullDocJsonPath","ensureFile","writeJson","spaces"],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAMA,aAAAA,GAAgB,CAAC,EAAEC,MAAM,EAA2B,GAAA;AACxD,IAAA,MAAMC,MAAAA,GAASD,MAAAA,CAAOC,MAAM,CAACC,GAAG,CAAC,uBAAA,CAAA;AACjC,IAAA,MAAMC,+BAA+BC,+DAAAA,CAAgCH,MAAAA,CAAAA;AACrE,IAAA,MAAMI,kBAAkBC,gBAAAA,CAAW,UAAA,CAAA;IAEnC,OAAO;AACLC,QAAAA,uBAAAA,CAAAA,GAAAA;YACE,OAAON,MAAAA,CAAOO,IAAI,CAACC,OAAO;AAC5B,QAAA,CAAA;AAEAC,QAAAA,wBAAAA,CAAAA,GAAAA;;;AAGE,YAAA,MAAMC,gBACJX,MAAAA,CAAOC,MAAM,CAACW,WAAW,KAAK,eAC1BZ,MAAAA,CAAOa,IAAI,CAACC,IAAI,CAACC,UAAU,GAC3Bf,MAAAA,CAAOa,IAAI,CAACG,GAAG,CAACD,UAAU;AAEhC,YAAA,OAAOE,qBAAAA,CAAKC,IAAI,CAACP,aAAAA,EAAe,eAAA,EAAiB,eAAA,CAAA;AACnD,QAAA,CAAA;AAEAQ,QAAAA,wBAAAA,CAAAA,GAAAA;YACE,OAAOC,mBAAAA,CACJC,WAAW,CAAC,IAAI,CAACX,wBAAwB,EAAA,CAAA,CACzCY,GAAG,CAAC,CAACb,OAAAA,GAAAA;gBACJ,IAAI;oBACF,MAAMc,QAAAA,GAAWN,sBAAKO,OAAO,CAC3B,IAAI,CAACd,wBAAwB,IAC7BD,OAAAA,EACA,yBAAA,CAAA;oBAGF,MAAMgB,GAAAA,GAAMC,KAAKC,KAAK,CAACP,oBAAGQ,YAAY,CAACL,UAAUM,QA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@@ var loopContentTypeNames = require('./utils/loop-content-type-names.js');
8
8
  var getApiResponses = require('./utils/get-api-responses.js');
9
9
  var routes = require('./utils/routes.js');
10
10
 
11
- function _interopNamespaceDefault(e) {
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ function _interopNamespace(e) {
14
+ if (e && e.__esModule) return e;
12
15
  var n = Object.create(null);
13
16
  if (e) {
14
17
  Object.keys(e).forEach(function (k) {
@@ -25,7 +28,8 @@ function _interopNamespaceDefault(e) {
25
28
  return Object.freeze(n);
26
29
  }
27
30
 
28
- var pathToRegexp__namespace = /*#__PURE__*/_interopNamespaceDefault(pathToRegexp);
31
+ var ___default = /*#__PURE__*/_interopDefault(_);
32
+ var pathToRegexp__namespace = /*#__PURE__*/_interopNamespace(pathToRegexp);
29
33
 
30
34
  /**
31
35
  * @description Parses a route with ':variable'
@@ -79,7 +83,7 @@ var pathToRegexp__namespace = /*#__PURE__*/_interopNamespaceDefault(pathToRegexp
79
83
  const getPathWithPrefix = (prefix, route)=>{
80
84
  // When the prefix is set on the routes and
81
85
  // the current route is not trying to remove it
82
- if (prefix && !_.has(route.config, 'prefix')) {
86
+ if (prefix && !___default.default.has(route.config, 'prefix')) {
83
87
  // Add the prefix to the path
84
88
  return prefix.concat(route.path);
85
89
  }
@@ -115,7 +119,7 @@ const getPathWithPrefix = (prefix, route)=>{
115
119
  const swaggerConfig = {
116
120
  responses,
117
121
  tags: [
118
- _.upperFirst(uniqueName)
122
+ ___default.default.upperFirst(uniqueName)
119
123
  ],
120
124
  parameters: [],
121
125
  operationId: `${methodVerb}${routePath}`
@@ -144,7 +148,7 @@ const getPathWithPrefix = (prefix, route)=>{
144
148
  };
145
149
  swaggerConfig.requestBody = requestBody;
146
150
  }
147
- _.set(acc, `${routePath}.${methodVerb}`, swaggerConfig);
151
+ ___default.default.set(acc, `${routePath}.${methodVerb}`, swaggerConfig);
148
152
  return acc;
149
153
  }, {});
150
154
  return paths;
@@ -1 +1 @@
1
- {"version":3,"file":"build-api-endpoint-path.js","sources":["../../../../server/src/services/helpers/build-api-endpoint-path.ts"],"sourcesContent":["import _ from 'lodash';\nimport * as pathToRegexp from 'path-to-regexp';\n\nimport type { Core } from '@strapi/types';\nimport type { OpenAPIV3 } from 'openapi-types';\n\nimport pascalCase from './utils/pascal-case';\nimport queryParams from './utils/query-params';\nimport loopContentTypeNames from './utils/loop-content-type-names';\nimport getApiResponses from './utils/get-api-responses';\nimport { hasFindMethod } from './utils/routes';\n\nimport type { Api, ApiInfo } from '../../types';\n\n/**\n * @description Parses a route with ':variable'\n *\n * @param {string} routePath - The route's path property\n * @returns {string}\n */\nconst parsePathWithVariables = (routePath: string): string => {\n const { tokens } = pathToRegexp.parse(routePath);\n\n return tokens\n .map((token) => {\n switch (token.type) {\n case 'text':\n return token.value;\n case 'param':\n return `{${token.name}}`;\n case 'wildcard':\n return `{${token.name}}`;\n case 'group':\n // Handle group tokens by mapping them within the same function context\n return `(${parsePathWithVariables(token.tokens.map((t) => t satisfies pathToRegexp.Token).join(''))})`;\n default:\n throw new Error(`Unknown token type: ${(token as any).type}`);\n }\n })\n .join('');\n};\n\n/**\n * @description Builds the required object for a path parameter\n *\n * @param {string} routePath - The route's path property\n *\n * @returns {object } Swagger path params object\n */\nconst getPathParams = (routePath: string): OpenAPIV3.ParameterObject[] => {\n const { tokens } = pathToRegexp.parse(routePath);\n\n return tokens.reduce((acc, param) => {\n // Skip non-parameter tokens\n if (param.type !== 'param') {\n return acc;\n }\n\n acc.push({\n name: `${param.name}`,\n in: 'path',\n description: '',\n deprecated: false,\n required: true,\n schema: { type: param.name === 'id' ? 'string' : 'number' },\n });\n\n return acc;\n }, [] as OpenAPIV3.ParameterObject[]);\n};\n\nconst getPathWithPrefix = (prefix: string | undefined, route: Core.Route) => {\n // When the prefix is set on the routes and\n // the current route is not trying to remove it\n if (prefix && !_.has(route.config, 'prefix')) {\n // Add the prefix to the path\n return prefix.concat(route.path);\n }\n\n // Otherwise just return path\n return route.path;\n};\n\n/**\n * @description Gets all paths based on routes\n *\n * @param {object} apiInfo\n * @property {object} apiInfo.routeInfo - The api routes object\n * @property {string} apiInfo.uniqueName - Content type name | Api name + Content type name\n * @property {object} apiInfo.contentTypeInfo - The info object found on content type schemas\n *\n * @returns {object}\n */\nconst getPaths = ({ routeInfo, uniqueName, contentTypeInfo, kind }: ApiInfo) => {\n // Get the routes for the current content type\n const contentTypeRoutes = routeInfo.routes.filter((route) => {\n return (\n route.path.includes(contentTypeInfo.pluralName) ||\n route.path.includes(contentTypeInfo.singularName)\n );\n });\n\n const paths = contentTypeRoutes.reduce((acc: any, route: Core.Route) => {\n // TODO: Find a more reliable way to determine list of entities vs a single entity\n const isListOfEntities = hasFindMethod(route.handler);\n const methodVerb = route.method.toLowerCase();\n const hasPathParams = route.path.includes('/:');\n const pathWithPrefix = getPathWithPrefix(routeInfo.prefix, route);\n const routePath = hasPathParams ? parsePathWithVariables(pathWithPrefix) : pathWithPrefix;\n\n const responses = getApiResponses({\n uniqueName,\n route,\n isListOfEntities: kind !== 'singleType' && isListOfEntities,\n });\n\n const swaggerConfig: OpenAPIV3.OperationObject = {\n responses,\n tags: [_.upperFirst(uniqueName)],\n parameters: [],\n operationId: `${methodVerb}${routePath}`,\n };\n\n if (isListOfEntities) {\n swaggerConfig.parameters?.push(...queryParams);\n }\n\n if (hasPathParams) {\n const pathParams = getPathParams(route.path);\n swaggerConfig.parameters?.push(...pathParams);\n }\n\n if (['post', 'put'].includes(methodVerb)) {\n const refName = 'Request';\n const requestBody = {\n required: true,\n content: {\n 'application/json': {\n schema: {\n $ref: `#/components/schemas/${pascalCase(uniqueName)}${refName}`,\n },\n },\n },\n };\n\n swaggerConfig.requestBody = requestBody;\n }\n\n _.set(acc, `${routePath}.${methodVerb}`, swaggerConfig);\n\n return acc;\n }, {});\n\n return paths;\n};\n\n/**\n * @description - Builds the Swagger paths object for each api\n */\nconst buildApiEndpointPath = (api: Api) => {\n // A reusable loop for building paths and component schemas\n // Uses the api param to build a new set of params for each content type\n // Passes these new params to the function provided\n return loopContentTypeNames(api, getPaths);\n};\n\nexport default buildApiEndpointPath;\n"],"names":["parsePathWithVariables","routePath","tokens","pathToRegexp","parse","map","token","type","value","name","t","join","Error","getPathParams","reduce","acc","param","push","in","description","deprecated","required","schema","getPathWithPrefix","prefix","route","_","has","config","concat","path","getPaths","routeInfo","uniqueName","contentTypeInfo","kind","contentTypeRoutes","routes","filter","includes","pluralName","singularName","paths","isListOfEntities","hasFindMethod","handler","methodVerb","method","toLowerCase","hasPathParams","pathWithPrefix","responses","getApiResponses","swaggerConfig","tags","upperFirst","parameters","operationId","queryParams","pathParams","refName","requestBody","content","$ref","pascalCase","set","buildApiEndpointPath","api","loopContentTypeNames"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;;;;;IAMA,MAAMA,yBAAyB,CAACC,SAAAA,GAAAA;AAC9B,IAAA,MAAM,EAAEC,MAAM,EAAE,GAAGC,uBAAAA,CAAaC,KAAK,CAACH,SAAAA,CAAAA;IAEtC,OAAOC,MAAAA,CACJG,GAAG,CAAC,CAACC,KAAAA,GAAAA;AACJ,QAAA,OAAQA,MAAMC,IAAI;YAChB,KAAK,MAAA;AACH,gBAAA,OAAOD,MAAME,KAAK;YACpB,KAAK,OAAA;AACH,gBAAA,OAAO,CAAC,CAAC,EAAEF,MAAMG,IAAI,CAAC,CAAC,CAAC;YAC1B,KAAK,UAAA;AACH,gBAAA,OAAO,CAAC,CAAC,EAAEH,MAAMG,IAAI,CAAC,CAAC,CAAC;YAC1B,KAAK,OAAA;;AAEH,gBAAA,OAAO,CAAC,CAAC,EAAET,sBAAAA,CAAuBM,KAAAA,CAAMJ,MAAM,CAACG,GAAG,CAAC,CAACK,IAAMA,CAAAA,CAAAA,CAAgCC,IAAI,CAAC,EAAA,CAAA,CAAA,CAAK,CAAC,CAAC;AACxG,YAAA;gBACE,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAE,KAACN,CAAcC,IAA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YACpBU,aAAAA,CAAcG,UAAU,EAAEvC,IAAAA,CAAAA,GAAQyC,WAAAA,CAAAA;AACpC,QAAA;AAEA,QAAA,IAAIT,aAAAA,EAAe;YACjB,MAAMU,UAAAA,GAAa9C,aAAAA,CAAcY,KAAAA,CAAMK,IAAI,CAAA;YAC3CuB,aAAAA,CAAcG,UAAU,EAAEvC,IAAAA,CAAAA,GAAQ0C,UAAAA,CAAAA;AACpC,QAAA;QAEA,IAAI;AAAC,YAAA,MAAA;AAAQ,YAAA;SAAM,CAACpB,QAAQ,CAACO,UAAAA,CAAAA,EAAa;AACxC,YAAA,MAAMc,OAAAA,GAAU,SAAA;AAChB,YAAA,MAAMC,WAAAA,GAAc;gBAClBxC,QAAAA,EAAU,IAAA;gBACVyC,OAAAA,EAAS;oBACP,kBAAA,EAAoB;wBAClBxC,MAAAA,EAAQ;AACNyC,4BAAAA,IAAAA,EAAM,CAAC,qBAAqB,EAAEC,UAAAA,CAAW/B,cAAc2B,OAAAA,CAAAA;AACzD;AACF;AACF;AACF,aAAA;AAEAP,YAAAA,aAAAA,CAAcQ,WAAW,GAAGA,WAAAA;AAC9B,QAAA;QAEAnC,CAAAA,CAAEuC,GAAG,CAAClD,GAAAA,EAAK,CAAA,EAAGd,UAAU,CAAC,EAAE6C,YAAY,EAAEO,aAAAA,CAAAA;QAEzC,OAAOtC,GAAAA;AACT,IAAA,CAAA,EAAG,EAAC,CAAA;IAEJ,OAAO2B,KAAAA;AACT,CAAA;AAEA;;IAGA,MAAMwB,uBAAuB,CAACC,GAAAA,GAAAA;;;;AAI5B,IAAA,OAAOC,qBAAqBD,GAAAA,EAAKpC,QAAAA,CAAAA;AACnC;;;;"}
1
+ {"version":3,"file":"build-api-endpoint-path.js","sources":["../../../../server/src/services/helpers/build-api-endpoint-path.ts"],"sourcesContent":["import _ from 'lodash';\nimport * as pathToRegexp from 'path-to-regexp';\n\nimport type { Core } from '@strapi/types';\nimport type { OpenAPIV3 } from 'openapi-types';\n\nimport pascalCase from './utils/pascal-case';\nimport queryParams from './utils/query-params';\nimport loopContentTypeNames from './utils/loop-content-type-names';\nimport getApiResponses from './utils/get-api-responses';\nimport { hasFindMethod } from './utils/routes';\n\nimport type { Api, ApiInfo } from '../../types';\n\n/**\n * @description Parses a route with ':variable'\n *\n * @param {string} routePath - The route's path property\n * @returns {string}\n */\nconst parsePathWithVariables = (routePath: string): string => {\n const { tokens } = pathToRegexp.parse(routePath);\n\n return tokens\n .map((token) => {\n switch (token.type) {\n case 'text':\n return token.value;\n case 'param':\n return `{${token.name}}`;\n case 'wildcard':\n return `{${token.name}}`;\n case 'group':\n // Handle group tokens by mapping them within the same function context\n return `(${parsePathWithVariables(token.tokens.map((t) => t satisfies pathToRegexp.Token).join(''))})`;\n default:\n throw new Error(`Unknown token type: ${(token as any).type}`);\n }\n })\n .join('');\n};\n\n/**\n * @description Builds the required object for a path parameter\n *\n * @param {string} routePath - The route's path property\n *\n * @returns {object } Swagger path params object\n */\nconst getPathParams = (routePath: string): OpenAPIV3.ParameterObject[] => {\n const { tokens } = pathToRegexp.parse(routePath);\n\n return tokens.reduce((acc, param) => {\n // Skip non-parameter tokens\n if (param.type !== 'param') {\n return acc;\n }\n\n acc.push({\n name: `${param.name}`,\n in: 'path',\n description: '',\n deprecated: false,\n required: true,\n schema: { type: param.name === 'id' ? 'string' : 'number' },\n });\n\n return acc;\n }, [] as OpenAPIV3.ParameterObject[]);\n};\n\nconst getPathWithPrefix = (prefix: string | undefined, route: Core.Route) => {\n // When the prefix is set on the routes and\n // the current route is not trying to remove it\n if (prefix && !_.has(route.config, 'prefix')) {\n // Add the prefix to the path\n return prefix.concat(route.path);\n }\n\n // Otherwise just return path\n return route.path;\n};\n\n/**\n * @description Gets all paths based on routes\n *\n * @param {object} apiInfo\n * @property {object} apiInfo.routeInfo - The api routes object\n * @property {string} apiInfo.uniqueName - Content type name | Api name + Content type name\n * @property {object} apiInfo.contentTypeInfo - The info object found on content type schemas\n *\n * @returns {object}\n */\nconst getPaths = ({ routeInfo, uniqueName, contentTypeInfo, kind }: ApiInfo) => {\n // Get the routes for the current content type\n const contentTypeRoutes = routeInfo.routes.filter((route) => {\n return (\n route.path.includes(contentTypeInfo.pluralName) ||\n route.path.includes(contentTypeInfo.singularName)\n );\n });\n\n const paths = contentTypeRoutes.reduce((acc: any, route: Core.Route) => {\n // TODO: Find a more reliable way to determine list of entities vs a single entity\n const isListOfEntities = hasFindMethod(route.handler);\n const methodVerb = route.method.toLowerCase();\n const hasPathParams = route.path.includes('/:');\n const pathWithPrefix = getPathWithPrefix(routeInfo.prefix, route);\n const routePath = hasPathParams ? parsePathWithVariables(pathWithPrefix) : pathWithPrefix;\n\n const responses = getApiResponses({\n uniqueName,\n route,\n isListOfEntities: kind !== 'singleType' && isListOfEntities,\n });\n\n const swaggerConfig: OpenAPIV3.OperationObject = {\n responses,\n tags: [_.upperFirst(uniqueName)],\n parameters: [],\n operationId: `${methodVerb}${routePath}`,\n };\n\n if (isListOfEntities) {\n swaggerConfig.parameters?.push(...queryParams);\n }\n\n if (hasPathParams) {\n const pathParams = getPathParams(route.path);\n swaggerConfig.parameters?.push(...pathParams);\n }\n\n if (['post', 'put'].includes(methodVerb)) {\n const refName = 'Request';\n const requestBody = {\n required: true,\n content: {\n 'application/json': {\n schema: {\n $ref: `#/components/schemas/${pascalCase(uniqueName)}${refName}`,\n },\n },\n },\n };\n\n swaggerConfig.requestBody = requestBody;\n }\n\n _.set(acc, `${routePath}.${methodVerb}`, swaggerConfig);\n\n return acc;\n }, {});\n\n return paths;\n};\n\n/**\n * @description - Builds the Swagger paths object for each api\n */\nconst buildApiEndpointPath = (api: Api) => {\n // A reusable loop for building paths and component schemas\n // Uses the api param to build a new set of params for each content type\n // Passes these new params to the function provided\n return loopContentTypeNames(api, getPaths);\n};\n\nexport default buildApiEndpointPath;\n"],"names":["parsePathWithVariables","routePath","tokens","pathToRegexp","parse","map","token","type","value","name","t","join","Error","getPathParams","reduce","acc","param","push","in","description","deprecated","required","schema","getPathWithPrefix","prefix","route","_","has","config","concat","path","getPaths","routeInfo","uniqueName","contentTypeInfo","kind","contentTypeRoutes","routes","filter","includes","pluralName","singularName","paths","isListOfEntities","hasFindMethod","handler","methodVerb","method","toLowerCase","hasPathParams","pathWithPrefix","responses","getApiResponses","swaggerConfig","tags","upperFirst","parameters","operationId","queryParams","pathParams","refName","requestBody","content","$ref","pascalCase","set","buildApiEndpointPath","api","loopContentTypeNames"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;;;;;IAMA,MAAMA,yBAAyB,CAACC,SAAAA,GAAAA;AAC9B,IAAA,MAAM,EAAEC,MAAM,EAAE,GAAGC,uBAAAA,CAAaC,KAAK,CAACH,SAAAA,CAAAA;IAEtC,OAAOC,MAAAA,CACJG,GAAG,CAAC,CAACC,KAAAA,GAAAA;AACJ,QAAA,OAAQA,MAAMC,IAAI;YAChB,KAAK,MAAA;AACH,gBAAA,OAAOD,MAAME,KAAK;YACpB,KAAK,OAAA;AACH,gBAAA,OAAO,CAAC,CAAC,EAAEF,MAAMG,IAAI,CAAC,CAAC,CAAC;YAC1B,KAAK,UAAA;AACH,gBAAA,OAAO,CAAC,CAAC,EAAEH,MAAMG,IAAI,CAAC,CAAC,CAAC;YAC1B,KAAK,OAAA;;AAEH,gBAAA,OAAO,CAAC,CAAC,EAAET,sBAAAA,CAAuBM,KAAAA,CAAMJ,MAAM,CAACG,GAAG,CAAC,CAACK,IAAMA,CAAAA,CAAAA,CAAgCC,IAAI,CAAC,EAAA,CAAA,CAAA,CAAK,CAAC,CAAC;AACxG,YAAA;gBACE,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAE,KAACN,CAAcC,IAAI,CAAA,CAAE,CAAA;AAChE;AACF,IAAA,CAAA,CAAA,CACCI,IAAI,CAAC,EAAA,CAAA;AACV,CAAA;AAEA;;;;;;IAOA,MAAME,gBAAgB,CAACZ,SAAAA,GAAAA;AACrB,IAAA,MAAM,EAAEC,MAAM,EAAE,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I,CAAA;YAC3CuB,aAAAA,CAAcG,UAAU,EAAEvC,IAAAA,CAAAA,GAAQ0C,UAAAA,CAAAA;AACpC,QAAA;QAEA,IAAI;AAAC,YAAA,MAAA;AAAQ,YAAA;SAAM,CAACpB,QAAQ,CAACO,UAAAA,CAAAA,EAAa;AACxC,YAAA,MAAMc,OAAAA,GAAU,SAAA;AAChB,YAAA,MAAMC,WAAAA,GAAc;gBAClBxC,QAAAA,EAAU,IAAA;gBACVyC,OAAAA,EAAS;oBACP,kBAAA,EAAoB;wBAClBxC,MAAAA,EAAQ;AACNyC,4BAAAA,IAAAA,EAAM,CAAC,qBAAqB,EAAEC,UAAAA,CAAW/B,cAAc2B,OAAAA,CAAAA;AACzD;AACF;AACF;AACF,aAAA;AAEAP,YAAAA,aAAAA,CAAcQ,WAAW,GAAGA,WAAAA;AAC9B,QAAA;QAEAnC,kBAAAA,CAAEuC,GAAG,CAAClD,GAAAA,EAAK,CAAA,EAAGd,UAAU,CAAC,EAAE6C,YAAY,EAAEO,aAAAA,CAAAA;QAEzC,OAAOtC,GAAAA;AACT,IAAA,CAAA,EAAG,EAAC,CAAA;IAEJ,OAAO2B,KAAAA;AACT,CAAA;AAEA;;IAGA,MAAMwB,uBAAuB,CAACC,GAAAA,GAAAA;;;;AAI5B,IAAA,OAAOC,qBAAqBD,GAAAA,EAAKpC,QAAAA,CAAAA;AACnC;;;;"}
@@ -6,6 +6,10 @@ var loopContentTypeNames = require('./utils/loop-content-type-names.js');
6
6
  var pascalCase = require('./utils/pascal-case.js');
7
7
  var routes = require('./utils/routes.js');
8
8
 
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ var ___default = /*#__PURE__*/_interopDefault(_);
12
+
9
13
  const getRequiredAttributes = (allAttributes)=>{
10
14
  const requiredAttributes = [];
11
15
  for(const key in allAttributes){
@@ -49,7 +53,7 @@ const getRequiredAttributes = (allAttributes)=>{
49
53
  'updatedBy',
50
54
  'createdBy'
51
55
  ];
52
- const attributesForRequest = _.omit(attributes, attributesToOmit);
56
+ const attributesForRequest = ___default.default.omit(attributes, attributesToOmit);
53
57
  // Get a list of required attribute names
54
58
  const requiredRequestAttributes = getRequiredAttributes(attributesForRequest);
55
59
  // Build the request schemas when the route has POST or PUT methods
@@ -1 +1 @@
1
- {"version":3,"file":"build-component-schema.js","sources":["../../../../server/src/services/helpers/build-component-schema.ts"],"sourcesContent":["import _ from 'lodash';\n\nimport type { OpenAPIV3 } from 'openapi-types';\nimport type { Core, Struct } from '@strapi/types';\n\nimport cleanSchemaAttributes from './utils/clean-schema-attributes';\nimport loopContentTypeNames from './utils/loop-content-type-names';\nimport pascalCase from './utils/pascal-case';\nimport { hasFindMethod } from './utils/routes';\n\nimport type { Api, ApiInfo } from '../../types';\n\nconst getRequiredAttributes = (allAttributes: Struct.SchemaAttributes) => {\n const requiredAttributes: string[] = [];\n\n for (const key in allAttributes) {\n if (allAttributes[key].required) {\n requiredAttributes.push(key);\n }\n }\n\n return requiredAttributes;\n};\n\n/**\n * @description Get all open api schema objects for a given content type\n *\n * @param {object} apiInfo\n * @property {string} apiInfo.uniqueName - Api name | Api name + Content type name\n * @property {object} apiInfo.attributes - Attributes on content type\n * @property {object} apiInfo.routeInfo - The routes for the api\n *\n * @returns {object} Open API schemas\n */\nconst getAllSchemasForContentType = ({ routeInfo, attributes, uniqueName }: ApiInfo) => {\n // Store response and request schemas in an object\n let strapiComponentSchemas = {};\n const schemas: OpenAPIV3.ComponentsObject = {};\n const typeName = pascalCase(uniqueName);\n\n // adds a ComponentSchema to the Schemas so it can be used as Ref\n const didAddStrapiComponentsToSchemas = (schemaName: string, schema: OpenAPIV3.SchemaObject) => {\n if (!Object.keys(schema) || !Object.keys(schema.properties!)) return false;\n\n // Add the Strapi components to the schema\n strapiComponentSchemas = {\n ...strapiComponentSchemas,\n [schemaName]: schema,\n };\n\n return true;\n };\n\n // Get all the route methods\n const routeMethods = routeInfo.routes.map((route: Core.Route) => route.method);\n\n const attributesToOmit = [\n 'createdAt',\n 'updatedAt',\n 'publishedAt',\n 'publishedBy',\n 'updatedBy',\n 'createdBy',\n ];\n\n const attributesForRequest = _.omit(attributes, attributesToOmit);\n // Get a list of required attribute names\n const requiredRequestAttributes = getRequiredAttributes(attributesForRequest);\n // Build the request schemas when the route has POST or PUT methods\n if (routeMethods.includes('POST') || routeMethods.includes('PUT')) {\n // Build localization requests schemas\n\n // Build the request schema\n Object.assign(schemas, {\n [`${typeName}Request`]: {\n type: 'object',\n required: ['data'],\n properties: {\n data: {\n ...(requiredRequestAttributes.length && { required: requiredRequestAttributes }),\n type: 'object',\n properties: cleanSchemaAttributes(attributesForRequest, {\n isRequest: true,\n didAddStrapiComponentsToSchemas,\n }),\n },\n },\n },\n });\n }\n\n // Check for routes that need to return a list\n const hasListOfEntities = routeInfo.routes.filter((route: Core.Route) =>\n hasFindMethod(route.handler)\n ).length;\n\n if (hasListOfEntities) {\n // Build the list response schema\n Object.assign(schemas, {\n [`${typeName}ListResponse`]: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n items: {\n $ref: `#/components/schemas/${typeName}`,\n },\n },\n meta: {\n type: 'object',\n properties: {\n pagination: {\n type: 'object',\n properties: {\n page: { type: 'integer' },\n pageSize: { type: 'integer', minimum: 25 },\n pageCount: { type: 'integer', maximum: 1 },\n total: { type: 'integer' },\n },\n },\n },\n },\n },\n },\n });\n }\n\n const requiredAttributes = getRequiredAttributes(attributes);\n // Build the response schema\n Object.assign(schemas, {\n [`${typeName}`]: {\n type: 'object',\n ...(requiredAttributes.length && { required: requiredAttributes }),\n properties: {\n id: { oneOf: [{ type: 'string' }, { type: 'number' }] },\n documentId: { type: 'string' },\n ...cleanSchemaAttributes(attributes, { didAddStrapiComponentsToSchemas }),\n },\n },\n\n [`${typeName}Response`]: {\n type: 'object',\n properties: {\n data: {\n $ref: `#/components/schemas/${typeName}`,\n },\n meta: { type: 'object' },\n },\n },\n });\n\n return { ...schemas, ...strapiComponentSchemas };\n};\n\nconst buildComponentSchema = (api: Api) => {\n // A reusable loop for building paths and component schemas\n // Uses the api param to build a new set of params for each content type\n // Passes these new params to the function provided\n return loopContentTypeNames(api, getAllSchemasForContentType);\n};\n\nexport default buildComponentSchema;\n"],"names":["getRequiredAttributes","allAttributes","requiredAttributes","key","required","push","getAllSchemasForContentType","routeInfo","attributes","uniqueName","strapiComponentSchemas","schemas","typeName","pascalCase","didAddStrapiComponentsToSchemas","schemaName","schema","Object","keys","properties","routeMethods","routes","map","route","method","attributesToOmit","attributesForRequest","_","omit","requiredRequestAttributes","includes","assign","type","data","length","cleanSchemaAttributes","isRequest","hasListOfEntities","filter","hasFindMethod","handler","items","$ref","meta","pagination","page","pageSize","minimum","pageCount","maximum","total","id","oneOf","documentId","buildComponentSchema","api","loopContentTypeNames"],"mappings":";;;;;;;;AAYA,MAAMA,wBAAwB,CAACC,aAAAA,GAAAA;AAC7B,IAAA,MAAMC,qBAA+B,EAAE;IAEvC,IAAK,MAAMC,OAAOF,aAAAA,CAAe;AAC/B,QAAA,IAAIA,aAAa,CAACE,GAAAA,CAAI,CAACC,QAAQ,EAAE;AAC/BF,YAAAA,kBAAAA,CAAmBG,IAAI,CAACF,GAAAA,CAAAA;AAC1B,QAAA;AACF,IAAA;IAEA,OAAOD,kBAAAA;AACT,CAAA;AAEA;;;;;;;;;IAUA,MAAMI,8BAA8B,CAAC,EAAEC,SAAS,EAAEC,UAAU,EAAEC,UAAU,EAAW,GAAA;;AAEjF,IAAA,IAAIC,yBAAyB,EAAC;AAC9B,IAAA,MAAMC,UAAsC,EAAC;AAC7C,IAAA,MAAMC,WAAWC,UAAAA,CAAWJ,UAAAA,CAAAA;;IAG5B,MAAMK,+BAAAA,GAAkC,CAACC,UAAAA,EAAoBC,MAAAA,GAAAA;AAC3D,QAAA,IAAI,CAACC,MAAAA,CAAOC,IAAI,CAACF,MAAAA,CAAAA,IAAW,CAACC,MAAAA,CAAOC,IAAI,CAACF,MAAAA,CAAOG,UAAU,CAAA,EAAI,OAA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,IAAAA,EAAM;AAAS,yBAAA;AAAG,wBAAA;4BAAEA,IAAAA,EAAM;AAAS;AAAE;AAAC,iBAAA;gBACtDqB,UAAAA,EAAY;oBAAErB,IAAAA,EAAM;AAAS,iBAAA;AAC7B,gBAAA,GAAGG,sBAAsB3B,UAAAA,EAAY;AAAEM,oBAAAA;iBAAgC;AACzE;AACF,SAAA;AAEA,QAAA,CAAC,CAAA,EAAGF,QAAAA,CAAS,QAAQ,CAAC,GAAG;YACvBoB,IAAAA,EAAM,QAAA;YACNb,UAAAA,EAAY;gBACVc,IAAAA,EAAM;oBACJS,IAAAA,EAAM,CAAC,qBAAqB,EAAE9B,QAAAA,CAAAA;AAChC,iBAAA;gBACA+B,IAAAA,EAAM;oBAAEX,IAAAA,EAAM;AAAS;AACzB;AACF;AACF,KAAA,CAAA;IAEA,OAAO;AAAE,QAAA,GAAGrB,OAAO;AAAE,QAAA,GAAGD;AAAuB,KAAA;AACjD,CAAA;AAEA,MAAM4C,uBAAuB,CAACC,GAAAA,GAAAA;;;;AAI5B,IAAA,OAAOC,qBAAqBD,GAAAA,EAAKjD,2BAAAA,CAAAA;AACnC;;;;"}
1
+ {"version":3,"file":"build-component-schema.js","sources":["../../../../server/src/services/helpers/build-component-schema.ts"],"sourcesContent":["import _ from 'lodash';\n\nimport type { OpenAPIV3 } from 'openapi-types';\nimport type { Core, Struct } from '@strapi/types';\n\nimport cleanSchemaAttributes from './utils/clean-schema-attributes';\nimport loopContentTypeNames from './utils/loop-content-type-names';\nimport pascalCase from './utils/pascal-case';\nimport { hasFindMethod } from './utils/routes';\n\nimport type { Api, ApiInfo } from '../../types';\n\nconst getRequiredAttributes = (allAttributes: Struct.SchemaAttributes) => {\n const requiredAttributes: string[] = [];\n\n for (const key in allAttributes) {\n if (allAttributes[key].required) {\n requiredAttributes.push(key);\n }\n }\n\n return requiredAttributes;\n};\n\n/**\n * @description Get all open api schema objects for a given content type\n *\n * @param {object} apiInfo\n * @property {string} apiInfo.uniqueName - Api name | Api name + Content type name\n * @property {object} apiInfo.attributes - Attributes on content type\n * @property {object} apiInfo.routeInfo - The routes for the api\n *\n * @returns {object} Open API schemas\n */\nconst getAllSchemasForContentType = ({ routeInfo, attributes, uniqueName }: ApiInfo) => {\n // Store response and request schemas in an object\n let strapiComponentSchemas = {};\n const schemas: OpenAPIV3.ComponentsObject = {};\n const typeName = pascalCase(uniqueName);\n\n // adds a ComponentSchema to the Schemas so it can be used as Ref\n const didAddStrapiComponentsToSchemas = (schemaName: string, schema: OpenAPIV3.SchemaObject) => {\n if (!Object.keys(schema) || !Object.keys(schema.properties!)) return false;\n\n // Add the Strapi components to the schema\n strapiComponentSchemas = {\n ...strapiComponentSchemas,\n [schemaName]: schema,\n };\n\n return true;\n };\n\n // Get all the route methods\n const routeMethods = routeInfo.routes.map((route: Core.Route) => route.method);\n\n const attributesToOmit = [\n 'createdAt',\n 'updatedAt',\n 'publishedAt',\n 'publishedBy',\n 'updatedBy',\n 'createdBy',\n ];\n\n const attributesForRequest = _.omit(attributes, attributesToOmit);\n // Get a list of required attribute names\n const requiredRequestAttributes = getRequiredAttributes(attributesForRequest);\n // Build the request schemas when the route has POST or PUT methods\n if (routeMethods.includes('POST') || routeMethods.includes('PUT')) {\n // Build localization requests schemas\n\n // Build the request schema\n Object.assign(schemas, {\n [`${typeName}Request`]: {\n type: 'object',\n required: ['data'],\n properties: {\n data: {\n ...(requiredRequestAttributes.length && { required: requiredRequestAttributes }),\n type: 'object',\n properties: cleanSchemaAttributes(attributesForRequest, {\n isRequest: true,\n didAddStrapiComponentsToSchemas,\n }),\n },\n },\n },\n });\n }\n\n // Check for routes that need to return a list\n const hasListOfEntities = routeInfo.routes.filter((route: Core.Route) =>\n hasFindMethod(route.handler)\n ).length;\n\n if (hasListOfEntities) {\n // Build the list response schema\n Object.assign(schemas, {\n [`${typeName}ListResponse`]: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n items: {\n $ref: `#/components/schemas/${typeName}`,\n },\n },\n meta: {\n type: 'object',\n properties: {\n pagination: {\n type: 'object',\n properties: {\n page: { type: 'integer' },\n pageSize: { type: 'integer', minimum: 25 },\n pageCount: { type: 'integer', maximum: 1 },\n total: { type: 'integer' },\n },\n },\n },\n },\n },\n },\n });\n }\n\n const requiredAttributes = getRequiredAttributes(attributes);\n // Build the response schema\n Object.assign(schemas, {\n [`${typeName}`]: {\n type: 'object',\n ...(requiredAttributes.length && { required: requiredAttributes }),\n properties: {\n id: { oneOf: [{ type: 'string' }, { type: 'number' }] },\n documentId: { type: 'string' },\n ...cleanSchemaAttributes(attributes, { didAddStrapiComponentsToSchemas }),\n },\n },\n\n [`${typeName}Response`]: {\n type: 'object',\n properties: {\n data: {\n $ref: `#/components/schemas/${typeName}`,\n },\n meta: { type: 'object' },\n },\n },\n });\n\n return { ...schemas, ...strapiComponentSchemas };\n};\n\nconst buildComponentSchema = (api: Api) => {\n // A reusable loop for building paths and component schemas\n // Uses the api param to build a new set of params for each content type\n // Passes these new params to the function provided\n return loopContentTypeNames(api, getAllSchemasForContentType);\n};\n\nexport default buildComponentSchema;\n"],"names":["getRequiredAttributes","allAttributes","requiredAttributes","key","required","push","getAllSchemasForContentType","routeInfo","attributes","uniqueName","strapiComponentSchemas","schemas","typeName","pascalCase","didAddStrapiComponentsToSchemas","schemaName","schema","Object","keys","properties","routeMethods","routes","map","route","method","attributesToOmit","attributesForRequest","_","omit","requiredRequestAttributes","includes","assign","type","data","length","cleanSchemaAttributes","isRequest","hasListOfEntities","filter","hasFindMethod","handler","items","$ref","meta","pagination","page","pageSize","minimum","pageCount","maximum","total","id","oneOf","documentId","buildComponentSchema","api","loopContentTypeNames"],"mappings":";;;;;;;;;;;;AAYA,MAAMA,wBAAwB,CAACC,aAAAA,GAAAA;AAC7B,IAAA,MAAMC,qBAA+B,EAAE;IAEvC,IAAK,MAAMC,OAAOF,aAAAA,CAAe;AAC/B,QAAA,IAAIA,aAAa,CAACE,GAAAA,CAAI,CAACC,QAAQ,EAAE;AAC/BF,YA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CAAAA;AACnC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"clean-schema-attributes.js","sources":["../../../../../server/src/services/helpers/utils/clean-schema-attributes.ts"],"sourcesContent":["import type { Struct } from '@strapi/types';\nimport type { OpenAPIV3 } from 'openapi-types';\n\nimport getSchemaData from './get-schema-data';\nimport pascalCase from './pascal-case';\n\ninterface Options {\n typeMap?: Map<string, boolean>;\n isRequest?: boolean;\n didAddStrapiComponentsToSchemas: (name: string, schema: object) => boolean;\n}\n\n/**\n * @description - Convert attribute component names to OpenAPI component names\n *\n * @returns OpenAPI component name\n */\nconst convertComponentName = (component: string, isRef = false): string => {\n const cleanComponentName = `${pascalCase(component)}Component`;\n\n if (isRef) {\n return `#/components/schemas/${cleanComponentName}`;\n }\n return cleanComponentName;\n};\n\n/**\n * @description - Converts types found on attributes to OpenAPI acceptable data types\n *\n * @returns Attributes using OpenAPI acceptable data types\n */\nconst cleanSchemaAttributes = (\n attributes: Struct.SchemaAttributes,\n { typeMap = new Map(), isRequest = false, didAddStrapiComponentsToSchemas }: Options\n) => {\n const schemaAttributes: Record<string, OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject> = {};\n\n for (const prop of Object.keys(attributes)) {\n const attribute = attributes[prop];\n\n switch (attribute.type) {\n case 'password': {\n if (!isRequest) {\n break;\n }\n\n schemaAttributes[prop] = { type: 'string', format: 'password', example: '*******' };\n break;\n }\n case 'email': {\n schemaAttributes[prop] = { type: 'string', format: 'email' };\n break;\n }\n case 'string':\n case 'text':\n case 'richtext': {\n schemaAttributes[prop] = { type: 'string' };\n break;\n }\n case 'timestamp': {\n schemaAttributes[prop] = { type: 'string', format: 'timestamp', example: Date.now() };\n break;\n }\n case 'time': {\n schemaAttributes[prop] = { type: 'string', format: 'time', example: '12:54.000' };\n break;\n }\n case 'date': {\n schemaAttributes[prop] = { type: 'string', format: 'date' };\n break;\n }\n case 'datetime': {\n schemaAttributes[prop] = { type: 'string', format: 'date-time' };\n break;\n }\n case 'boolean': {\n schemaAttributes[prop] = { type: 'boolean' };\n break;\n }\n case 'enumeration': {\n schemaAttributes[prop] = { type: 'string', enum: [...attribute.enum] };\n break;\n }\n case 'decimal':\n case 'float': {\n schemaAttributes[prop] = { type: 'number', format: 'float' };\n break;\n }\n case 'integer': {\n schemaAttributes[prop] = { type: 'integer' };\n break;\n }\n case 'biginteger': {\n schemaAttributes[prop] = { type: 'string', pattern: '^\\\\d*$', example: '123456789' };\n break;\n }\n case 'json':\n case 'blocks': {\n schemaAttributes[prop] = {};\n break;\n }\n case 'uid': {\n schemaAttributes[prop] = { type: 'string' };\n break;\n }\n case 'component': {\n const componentAttributes = strapi.components[attribute.component].attributes;\n const rawComponentSchema: OpenAPIV3.SchemaObject = {\n type: 'object',\n properties: {\n ...(isRequest ? {} : { id: { oneOf: [{ type: 'string' }, { type: 'number' }] } }),\n ...cleanSchemaAttributes(componentAttributes, {\n typeMap,\n isRequest,\n didAddStrapiComponentsToSchemas,\n }),\n },\n };\n\n const refComponentSchema: OpenAPIV3.ReferenceObject = {\n $ref: convertComponentName(attribute.component, true),\n };\n\n const componentExists = didAddStrapiComponentsToSchemas(\n convertComponentName(attribute.component),\n rawComponentSchema\n );\n\n const finalComponentSchema = componentExists ? refComponentSchema : rawComponentSchema;\n if (attribute.repeatable) {\n schemaAttributes[prop] = {\n type: 'array',\n items: finalComponentSchema,\n };\n } else {\n schemaAttributes[prop] = finalComponentSchema;\n }\n break;\n }\n case 'dynamiczone': {\n const components = attribute.components.map((component) => {\n const componentAttributes = strapi.components[component].attributes;\n const rawComponentSchema: OpenAPIV3.SchemaObject = {\n type: 'object',\n properties: {\n ...(isRequest ? {} : { id: { oneOf: [{ type: 'string' }, { type: 'number' }] } }),\n __component: { type: 'string', enum: [component] },\n ...cleanSchemaAttributes(componentAttributes, {\n typeMap,\n isRequest,\n didAddStrapiComponentsToSchemas,\n }),\n },\n };\n\n const refComponentSchema: OpenAPIV3.ReferenceObject = {\n $ref: convertComponentName(component, true),\n };\n\n const componentExists = didAddStrapiComponentsToSchemas(\n convertComponentName(component),\n rawComponentSchema\n );\n const finalComponentSchema = componentExists ? refComponentSchema : rawComponentSchema;\n return finalComponentSchema;\n });\n let discriminator: OpenAPIV3.DiscriminatorObject | undefined;\n if (components.every((component) => Object.hasOwn(component, '$ref'))) {\n discriminator = {\n propertyName: '__component',\n mapping: attribute.components.reduce(\n (acc, component) => {\n acc[component] = convertComponentName(component, true);\n return acc;\n },\n {} as {\n [value: string]: string;\n }\n ),\n };\n }\n\n schemaAttributes[prop] = {\n type: 'array',\n items: {\n anyOf: components,\n },\n discriminator,\n };\n break;\n }\n case 'media': {\n const imageAttributes = strapi.contentType('plugin::upload.file').attributes;\n const isListOfEntities = attribute.multiple ?? false;\n\n if (isRequest) {\n const oneOfType: OpenAPIV3.SchemaObject = {\n oneOf: [{ type: 'integer' }, { type: 'string' }],\n example: 'string or id',\n };\n\n schemaAttributes[prop] = isListOfEntities\n ? { type: 'array', items: oneOfType }\n : oneOfType;\n break;\n }\n\n schemaAttributes[prop] = getSchemaData(\n isListOfEntities,\n cleanSchemaAttributes(imageAttributes, { typeMap, didAddStrapiComponentsToSchemas })\n );\n break;\n }\n\n case 'relation': {\n const isListOfEntities = attribute.relation.includes('ToMany');\n\n if (isRequest) {\n const oneOfType: OpenAPIV3.SchemaObject = {\n oneOf: [{ type: 'integer' }, { type: 'string' }],\n example: 'string or id',\n };\n\n schemaAttributes[prop] = isListOfEntities\n ? { type: 'array', items: oneOfType }\n : oneOfType;\n break;\n }\n\n if (!('target' in attribute) || !attribute.target || typeMap.has(attribute.target)) {\n schemaAttributes[prop] = getSchemaData(isListOfEntities, {});\n\n break;\n }\n\n typeMap.set(attribute.target, true);\n const targetAttributes = strapi.contentType(attribute.target).attributes;\n\n schemaAttributes[prop] = getSchemaData(\n isListOfEntities,\n cleanSchemaAttributes(targetAttributes, {\n typeMap,\n isRequest,\n didAddStrapiComponentsToSchemas,\n })\n );\n\n break;\n }\n default: {\n // @ts-expect-error - This is a catch all for any other types\n throw new Error(`Invalid type ${attribute.type} while generating open api schema.`);\n }\n }\n }\n\n return schemaAttributes;\n};\n\nexport default cleanSchemaAttributes;\n"],"names":["convertComponentName","component","isRef","cleanComponentName","pascalCase","cleanSchemaAttributes","attributes","typeMap","Map","isRequest","didAddStrapiComponentsToSchemas","schemaAttributes","prop","Object","keys","attribute","type","format","example","Date","now","enum","pattern","componentAttributes","strapi","components","rawComponentSchema","properties","id","oneOf","refComponentSchema","$ref","componentExists","finalComponentSchema","repeatable","items","map","__component","discriminator","every","hasOwn","propertyName","mapping","reduce","acc","anyOf","imageAttributes","contentType","isListOfEntities","multiple","oneOfType","getSchemaData","relation","includes","target","has","set","targetAttributes","Error"],"mappings":";;;;;AAYA;;;;AAIC,IACD,MAAMA,oBAAAA,GAAuB,CAACC,SAAAA,EAAmBC,QAAQ,KAAK,GAAA;AAC5D,IAAA,MAAMC,kBAAAA,GAAqB,CAAA,EAAGC,UAAAA,CAAWH,SAAAA,CAAAA,CAAW,SAAS,CAAC;AAE9D,IAAA,IAAIC,KAAAA,EAAO;QACT,OAAO,CAAC,qBAAqB,EAAEC,kBAAAA,CAAAA,CAAoB;AACrD,IAAA;IACA,OAAOA,kBAAAA;AACT,CAAA;AAEA;;;;AAIC,IACD,MAAME,qBAAAA,GAAwB,CAC5BC,UAAAA,EACA,EAAEC,OAAAA,GAAU,IAAIC,GAAAA,EAAK,EAAEC,SAAAA,GAAY,KAAK,EAAEC,+BAA+B,EAAW,GAAA;AAEpF,IAAA,MAAMC,mBAAuF,EAAC;AAE9F,IAAA,KAAK,MAAMC,IAAAA,IAAQC,MAAAA,CAAOC,IAAI,CAACR,UAAAA,CAAAA,CAAa;QAC1C,MAAMS,SAAAA,GAAYT,UAAU,CAACM,IAAAA,CAAK;AAElC,QAAA,OAAQG,UAAUC,IAAI;YACpB,KAAK,UAAA;AAAY,gBAAA;AACf,oBAAA,IAAI,CAACP,SAAAA,EAAW;AACd,wBAAA;AACF,oBAAA;oBA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,OAAA;4BAASmB,KAAAA,EAAOe;yBAAU,GAClCA,SAAAA;AACJ,wBAAA;AACF,oBAAA;AAEA,oBAAA,IAAI,EAAE,QAAA,IAAYnC,SAAQ,KAAM,CAACA,SAAAA,CAAUuC,MAAM,IAAI/C,OAAAA,CAAQgD,GAAG,CAACxC,SAAAA,CAAUuC,MAAM,CAAA,EAAG;AAClF3C,wBAAAA,gBAAgB,CAACC,IAAAA,CAAK,GAAGuC,aAAAA,CAAcH,kBAAkB,EAAC,CAAA;AAE1D,wBAAA;AACF,oBAAA;AAEAzC,oBAAAA,OAAAA,CAAQiD,GAAG,CAACzC,SAAAA,CAAUuC,MAAM,EAAE,IAAA,CAAA;AAC9B,oBAAA,MAAMG,mBAAmBjC,MAAAA,CAAOuB,WAAW,CAAChC,SAAAA,CAAUuC,MAAM,EAAEhD,UAAU;AAExEK,oBAAAA,gBAAgB,CAACC,IAAAA,CAAK,GAAGuC,aAAAA,CACvBH,gBAAAA,EACA3C,sBAAsBoD,gBAAAA,EAAkB;AACtClD,wBAAAA,OAAAA;AACAE,wBAAAA,SAAAA;AACAC,wBAAAA;AACF,qBAAA,CAAA,CAAA;AAGF,oBAAA;AACF,gBAAA;AACA,YAAA;AAAS,gBAAA;;oBAEP,MAAM,IAAIgD,MAAM,CAAC,aAAa,EAAE3C,SAAAA,CAAUC,IAAI,CAAC,kCAAkC,CAAC,CAAA;AACpF,gBAAA;AACF;AACF,IAAA;IAEA,OAAOL,gBAAAA;AACT;;;;"}
1
+ {"version":3,"file":"clean-schema-attributes.js","sources":["../../../../../server/src/services/helpers/utils/clean-schema-attributes.ts"],"sourcesContent":["import type { Struct } from '@strapi/types';\nimport type { OpenAPIV3 } from 'openapi-types';\n\nimport getSchemaData from './get-schema-data';\nimport pascalCase from './pascal-case';\n\ninterface Options {\n typeMap?: Map<string, boolean>;\n isRequest?: boolean;\n didAddStrapiComponentsToSchemas: (name: string, schema: object) => boolean;\n}\n\n/**\n * @description - Convert attribute component names to OpenAPI component names\n *\n * @returns OpenAPI component name\n */\nconst convertComponentName = (component: string, isRef = false): string => {\n const cleanComponentName = `${pascalCase(component)}Component`;\n\n if (isRef) {\n return `#/components/schemas/${cleanComponentName}`;\n }\n return cleanComponentName;\n};\n\n/**\n * @description - Converts types found on attributes to OpenAPI acceptable data types\n *\n * @returns Attributes using OpenAPI acceptable data types\n */\nconst cleanSchemaAttributes = (\n attributes: Struct.SchemaAttributes,\n { typeMap = new Map(), isRequest = false, didAddStrapiComponentsToSchemas }: Options\n): Record<string, OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject> => {\n const schemaAttributes: Record<string, OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject> = {};\n\n for (const prop of Object.keys(attributes)) {\n const attribute = attributes[prop];\n\n switch (attribute.type) {\n case 'password': {\n if (!isRequest) {\n break;\n }\n\n schemaAttributes[prop] = { type: 'string', format: 'password', example: '*******' };\n break;\n }\n case 'email': {\n schemaAttributes[prop] = { type: 'string', format: 'email' };\n break;\n }\n case 'string':\n case 'text':\n case 'richtext': {\n schemaAttributes[prop] = { type: 'string' };\n break;\n }\n case 'timestamp': {\n schemaAttributes[prop] = { type: 'string', format: 'timestamp', example: Date.now() };\n break;\n }\n case 'time': {\n schemaAttributes[prop] = { type: 'string', format: 'time', example: '12:54.000' };\n break;\n }\n case 'date': {\n schemaAttributes[prop] = { type: 'string', format: 'date' };\n break;\n }\n case 'datetime': {\n schemaAttributes[prop] = { type: 'string', format: 'date-time' };\n break;\n }\n case 'boolean': {\n schemaAttributes[prop] = { type: 'boolean' };\n break;\n }\n case 'enumeration': {\n schemaAttributes[prop] = { type: 'string', enum: [...attribute.enum] };\n break;\n }\n case 'decimal':\n case 'float': {\n schemaAttributes[prop] = { type: 'number', format: 'float' };\n break;\n }\n case 'integer': {\n schemaAttributes[prop] = { type: 'integer' };\n break;\n }\n case 'biginteger': {\n schemaAttributes[prop] = { type: 'string', pattern: '^\\\\d*$', example: '123456789' };\n break;\n }\n case 'json':\n case 'blocks': {\n schemaAttributes[prop] = {};\n break;\n }\n case 'uid': {\n schemaAttributes[prop] = { type: 'string' };\n break;\n }\n case 'component': {\n const componentAttributes = strapi.components[attribute.component].attributes;\n const rawComponentSchema: OpenAPIV3.SchemaObject = {\n type: 'object',\n properties: {\n ...(isRequest ? {} : { id: { oneOf: [{ type: 'string' }, { type: 'number' }] } }),\n ...cleanSchemaAttributes(componentAttributes, {\n typeMap,\n isRequest,\n didAddStrapiComponentsToSchemas,\n }),\n },\n };\n\n const refComponentSchema: OpenAPIV3.ReferenceObject = {\n $ref: convertComponentName(attribute.component, true),\n };\n\n const componentExists = didAddStrapiComponentsToSchemas(\n convertComponentName(attribute.component),\n rawComponentSchema\n );\n\n const finalComponentSchema = componentExists ? refComponentSchema : rawComponentSchema;\n if (attribute.repeatable) {\n schemaAttributes[prop] = {\n type: 'array',\n items: finalComponentSchema,\n };\n } else {\n schemaAttributes[prop] = finalComponentSchema;\n }\n break;\n }\n case 'dynamiczone': {\n const components = attribute.components.map((component) => {\n const componentAttributes = strapi.components[component].attributes;\n const rawComponentSchema: OpenAPIV3.SchemaObject = {\n type: 'object',\n properties: {\n ...(isRequest ? {} : { id: { oneOf: [{ type: 'string' }, { type: 'number' }] } }),\n __component: { type: 'string', enum: [component] },\n ...cleanSchemaAttributes(componentAttributes, {\n typeMap,\n isRequest,\n didAddStrapiComponentsToSchemas,\n }),\n },\n };\n\n const refComponentSchema: OpenAPIV3.ReferenceObject = {\n $ref: convertComponentName(component, true),\n };\n\n const componentExists = didAddStrapiComponentsToSchemas(\n convertComponentName(component),\n rawComponentSchema\n );\n const finalComponentSchema = componentExists ? refComponentSchema : rawComponentSchema;\n return finalComponentSchema;\n });\n let discriminator: OpenAPIV3.DiscriminatorObject | undefined;\n if (components.every((component) => Object.hasOwn(component, '$ref'))) {\n discriminator = {\n propertyName: '__component',\n mapping: attribute.components.reduce(\n (acc, component) => {\n acc[component] = convertComponentName(component, true);\n return acc;\n },\n {} as {\n [value: string]: string;\n }\n ),\n };\n }\n\n schemaAttributes[prop] = {\n type: 'array',\n items: {\n anyOf: components,\n },\n discriminator,\n };\n break;\n }\n case 'media': {\n const imageAttributes = strapi.contentType('plugin::upload.file').attributes;\n const isListOfEntities = attribute.multiple ?? false;\n\n if (isRequest) {\n const oneOfType: OpenAPIV3.SchemaObject = {\n oneOf: [{ type: 'integer' }, { type: 'string' }],\n example: 'string or id',\n };\n\n schemaAttributes[prop] = isListOfEntities\n ? { type: 'array', items: oneOfType }\n : oneOfType;\n break;\n }\n\n schemaAttributes[prop] = getSchemaData(\n isListOfEntities,\n cleanSchemaAttributes(imageAttributes, { typeMap, didAddStrapiComponentsToSchemas })\n );\n break;\n }\n\n case 'relation': {\n const isListOfEntities = attribute.relation.includes('ToMany');\n\n if (isRequest) {\n const oneOfType: OpenAPIV3.SchemaObject = {\n oneOf: [{ type: 'integer' }, { type: 'string' }],\n example: 'string or id',\n };\n\n schemaAttributes[prop] = isListOfEntities\n ? { type: 'array', items: oneOfType }\n : oneOfType;\n break;\n }\n\n if (!('target' in attribute) || !attribute.target || typeMap.has(attribute.target)) {\n schemaAttributes[prop] = getSchemaData(isListOfEntities, {});\n\n break;\n }\n\n typeMap.set(attribute.target, true);\n const targetAttributes = strapi.contentType(attribute.target).attributes;\n\n schemaAttributes[prop] = getSchemaData(\n isListOfEntities,\n cleanSchemaAttributes(targetAttributes, {\n typeMap,\n isRequest,\n didAddStrapiComponentsToSchemas,\n })\n );\n\n break;\n }\n default: {\n // @ts-expect-error - This is a catch all for any other types\n throw new Error(`Invalid type ${attribute.type} while generating open api schema.`);\n }\n }\n }\n\n return schemaAttributes;\n};\n\nexport default cleanSchemaAttributes;\n"],"names":["convertComponentName","component","isRef","cleanComponentName","pascalCase","cleanSchemaAttributes","attributes","typeMap","Map","isRequest","didAddStrapiComponentsToSchemas","schemaAttributes","prop","Object","keys","attribute","type","format","example","Date","now","enum","pattern","componentAttributes","strapi","components","rawComponentSchema","properties","id","oneOf","refComponentSchema","$ref","componentExists","finalComponentSchema","repeatable","items","map","__component","discriminator","every","hasOwn","propertyName","mapping","reduce","acc","anyOf","imageAttributes","contentType","isListOfEntities","multiple","oneOfType","getSchemaData","relation","includes","target","has","set","targetAttributes","Error"],"mappings":";;;;;AAYA;;;;AAIC,IACD,MAAMA,oBAAAA,GAAuB,CAACC,SAAAA,EAAmBC,QAAQ,KAAK,GAAA;AAC5D,IAAA,MAAMC,kBAAAA,GAAqB,CAAA,EAAGC,UAAAA,CAAWH,SAAAA,CAAAA,CAAW,SAAS,CAAC;AAE9D,IAAA,IAAIC,KAAAA,EAAO;QACT,OAAO,CAAC,qBAAqB,EAAEC,kBAAAA,CAAAA,CAAoB;AACrD,IAAA;IACA,OAAOA,kBAAAA;AACT,CAAA;AAEA;;;;AAIC,IACD,MAAME,qBAAAA,GAAwB,CAC5BC,UAAAA,EACA,EAAEC,OAAAA,GAAU,IAAIC,GAAAA,EAAK,EAAEC,SAAAA,GAAY,KAAK,EAAEC,+BAA+B,EAAW,GAAA;AAEpF,IAAA,MAAMC,mBAAuF,EAAC;AAE9F,IAAA,KAAK,MAAMC,IAAAA,IAAQC,MAAAA,CAAOC,IAAI,CAACR,UAAAA,CAAAA,CAAa;QAC1C,MAAMS,SAAAA,GAAYT,UAAU,CAACM,IAAAA,CAAK;AAElC,QAAA,OAAQG,UAAUC,IAAI;YACpB,KAAK,UAAA;AAAY,gBAAA;AACf,oBAAA,IAAI,CAACP,SAAAA,EAAW;AACd,wBAAA;AACF,oBAAA;oBAEAE,gBAAgB,CAACC,KAAK,GAAG;wBAAEI,IAAAA,EAAM,QAAA;wBAAUC,MAAAA,EAAQ,UAAA;wBAAYC,OAAAA,EAAS;AAAU,qBAAA;AAClF,oBAAA;AACF,gBAAA;YACA,KAAK,OAAA;AAAS,gBAAA;oBACZP,gBAAgB,CAACC,KAAK,GAAG;wBAAEI,IAAAA,EAAM,QAAA;wBAAUC,MAAAA,EAAQ;AAAQ,qBAAA;AAC3D,oBAAA;AACF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,kBAAkB,EAAC,CAAA;AAE1D,wBAAA;AACF,oBAAA;AAEAzC,oBAAAA,OAAAA,CAAQiD,GAAG,CAACzC,SAAAA,CAAUuC,MAAM,EAAE,IAAA,CAAA;AAC9B,oBAAA,MAAMG,mBAAmBjC,MAAAA,CAAOuB,WAAW,CAAChC,SAAAA,CAAUuC,MAAM,EAAEhD,UAAU;AAExEK,oBAAAA,gBAAgB,CAACC,IAAAA,CAAK,GAAGuC,aAAAA,CACvBH,gBAAAA,EACA3C,sBAAsBoD,gBAAAA,EAAkB;AACtClD,wBAAAA,OAAAA;AACAE,wBAAAA,SAAAA;AACAC,wBAAAA;AACF,qBAAA,CAAA,CAAA;AAGF,oBAAA;AACF,gBAAA;AACA,YAAA;AAAS,gBAAA;;oBAEP,MAAM,IAAIgD,MAAM,CAAC,aAAa,EAAE3C,SAAAA,CAAUC,IAAI,CAAC,kCAAkC,CAAC,CAAA;AACpF,gBAAA;AACF;AACF,IAAA;IAEA,OAAOL,gBAAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"clean-schema-attributes.mjs","sources":["../../../../../server/src/services/helpers/utils/clean-schema-attributes.ts"],"sourcesContent":["import type { Struct } from '@strapi/types';\nimport type { OpenAPIV3 } from 'openapi-types';\n\nimport getSchemaData from './get-schema-data';\nimport pascalCase from './pascal-case';\n\ninterface Options {\n typeMap?: Map<string, boolean>;\n isRequest?: boolean;\n didAddStrapiComponentsToSchemas: (name: string, schema: object) => boolean;\n}\n\n/**\n * @description - Convert attribute component names to OpenAPI component names\n *\n * @returns OpenAPI component name\n */\nconst convertComponentName = (component: string, isRef = false): string => {\n const cleanComponentName = `${pascalCase(component)}Component`;\n\n if (isRef) {\n return `#/components/schemas/${cleanComponentName}`;\n }\n return cleanComponentName;\n};\n\n/**\n * @description - Converts types found on attributes to OpenAPI acceptable data types\n *\n * @returns Attributes using OpenAPI acceptable data types\n */\nconst cleanSchemaAttributes = (\n attributes: Struct.SchemaAttributes,\n { typeMap = new Map(), isRequest = false, didAddStrapiComponentsToSchemas }: Options\n) => {\n const schemaAttributes: Record<string, OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject> = {};\n\n for (const prop of Object.keys(attributes)) {\n const attribute = attributes[prop];\n\n switch (attribute.type) {\n case 'password': {\n if (!isRequest) {\n break;\n }\n\n schemaAttributes[prop] = { type: 'string', format: 'password', example: '*******' };\n break;\n }\n case 'email': {\n schemaAttributes[prop] = { type: 'string', format: 'email' };\n break;\n }\n case 'string':\n case 'text':\n case 'richtext': {\n schemaAttributes[prop] = { type: 'string' };\n break;\n }\n case 'timestamp': {\n schemaAttributes[prop] = { type: 'string', format: 'timestamp', example: Date.now() };\n break;\n }\n case 'time': {\n schemaAttributes[prop] = { type: 'string', format: 'time', example: '12:54.000' };\n break;\n }\n case 'date': {\n schemaAttributes[prop] = { type: 'string', format: 'date' };\n break;\n }\n case 'datetime': {\n schemaAttributes[prop] = { type: 'string', format: 'date-time' };\n break;\n }\n case 'boolean': {\n schemaAttributes[prop] = { type: 'boolean' };\n break;\n }\n case 'enumeration': {\n schemaAttributes[prop] = { type: 'string', enum: [...attribute.enum] };\n break;\n }\n case 'decimal':\n case 'float': {\n schemaAttributes[prop] = { type: 'number', format: 'float' };\n break;\n }\n case 'integer': {\n schemaAttributes[prop] = { type: 'integer' };\n break;\n }\n case 'biginteger': {\n schemaAttributes[prop] = { type: 'string', pattern: '^\\\\d*$', example: '123456789' };\n break;\n }\n case 'json':\n case 'blocks': {\n schemaAttributes[prop] = {};\n break;\n }\n case 'uid': {\n schemaAttributes[prop] = { type: 'string' };\n break;\n }\n case 'component': {\n const componentAttributes = strapi.components[attribute.component].attributes;\n const rawComponentSchema: OpenAPIV3.SchemaObject = {\n type: 'object',\n properties: {\n ...(isRequest ? {} : { id: { oneOf: [{ type: 'string' }, { type: 'number' }] } }),\n ...cleanSchemaAttributes(componentAttributes, {\n typeMap,\n isRequest,\n didAddStrapiComponentsToSchemas,\n }),\n },\n };\n\n const refComponentSchema: OpenAPIV3.ReferenceObject = {\n $ref: convertComponentName(attribute.component, true),\n };\n\n const componentExists = didAddStrapiComponentsToSchemas(\n convertComponentName(attribute.component),\n rawComponentSchema\n );\n\n const finalComponentSchema = componentExists ? refComponentSchema : rawComponentSchema;\n if (attribute.repeatable) {\n schemaAttributes[prop] = {\n type: 'array',\n items: finalComponentSchema,\n };\n } else {\n schemaAttributes[prop] = finalComponentSchema;\n }\n break;\n }\n case 'dynamiczone': {\n const components = attribute.components.map((component) => {\n const componentAttributes = strapi.components[component].attributes;\n const rawComponentSchema: OpenAPIV3.SchemaObject = {\n type: 'object',\n properties: {\n ...(isRequest ? {} : { id: { oneOf: [{ type: 'string' }, { type: 'number' }] } }),\n __component: { type: 'string', enum: [component] },\n ...cleanSchemaAttributes(componentAttributes, {\n typeMap,\n isRequest,\n didAddStrapiComponentsToSchemas,\n }),\n },\n };\n\n const refComponentSchema: OpenAPIV3.ReferenceObject = {\n $ref: convertComponentName(component, true),\n };\n\n const componentExists = didAddStrapiComponentsToSchemas(\n convertComponentName(component),\n rawComponentSchema\n );\n const finalComponentSchema = componentExists ? refComponentSchema : rawComponentSchema;\n return finalComponentSchema;\n });\n let discriminator: OpenAPIV3.DiscriminatorObject | undefined;\n if (components.every((component) => Object.hasOwn(component, '$ref'))) {\n discriminator = {\n propertyName: '__component',\n mapping: attribute.components.reduce(\n (acc, component) => {\n acc[component] = convertComponentName(component, true);\n return acc;\n },\n {} as {\n [value: string]: string;\n }\n ),\n };\n }\n\n schemaAttributes[prop] = {\n type: 'array',\n items: {\n anyOf: components,\n },\n discriminator,\n };\n break;\n }\n case 'media': {\n const imageAttributes = strapi.contentType('plugin::upload.file').attributes;\n const isListOfEntities = attribute.multiple ?? false;\n\n if (isRequest) {\n const oneOfType: OpenAPIV3.SchemaObject = {\n oneOf: [{ type: 'integer' }, { type: 'string' }],\n example: 'string or id',\n };\n\n schemaAttributes[prop] = isListOfEntities\n ? { type: 'array', items: oneOfType }\n : oneOfType;\n break;\n }\n\n schemaAttributes[prop] = getSchemaData(\n isListOfEntities,\n cleanSchemaAttributes(imageAttributes, { typeMap, didAddStrapiComponentsToSchemas })\n );\n break;\n }\n\n case 'relation': {\n const isListOfEntities = attribute.relation.includes('ToMany');\n\n if (isRequest) {\n const oneOfType: OpenAPIV3.SchemaObject = {\n oneOf: [{ type: 'integer' }, { type: 'string' }],\n example: 'string or id',\n };\n\n schemaAttributes[prop] = isListOfEntities\n ? { type: 'array', items: oneOfType }\n : oneOfType;\n break;\n }\n\n if (!('target' in attribute) || !attribute.target || typeMap.has(attribute.target)) {\n schemaAttributes[prop] = getSchemaData(isListOfEntities, {});\n\n break;\n }\n\n typeMap.set(attribute.target, true);\n const targetAttributes = strapi.contentType(attribute.target).attributes;\n\n schemaAttributes[prop] = getSchemaData(\n isListOfEntities,\n cleanSchemaAttributes(targetAttributes, {\n typeMap,\n isRequest,\n didAddStrapiComponentsToSchemas,\n })\n );\n\n break;\n }\n default: {\n // @ts-expect-error - This is a catch all for any other types\n throw new Error(`Invalid type ${attribute.type} while generating open api schema.`);\n }\n }\n }\n\n return schemaAttributes;\n};\n\nexport default cleanSchemaAttributes;\n"],"names":["convertComponentName","component","isRef","cleanComponentName","pascalCase","cleanSchemaAttributes","attributes","typeMap","Map","isRequest","didAddStrapiComponentsToSchemas","schemaAttributes","prop","Object","keys","attribute","type","format","example","Date","now","enum","pattern","componentAttributes","strapi","components","rawComponentSchema","properties","id","oneOf","refComponentSchema","$ref","componentExists","finalComponentSchema","repeatable","items","map","__component","discriminator","every","hasOwn","propertyName","mapping","reduce","acc","anyOf","imageAttributes","contentType","isListOfEntities","multiple","oneOfType","getSchemaData","relation","includes","target","has","set","targetAttributes","Error"],"mappings":";;;AAYA;;;;AAIC,IACD,MAAMA,oBAAAA,GAAuB,CAACC,SAAAA,EAAmBC,QAAQ,KAAK,GAAA;AAC5D,IAAA,MAAMC,kBAAAA,GAAqB,CAAA,EAAGC,UAAAA,CAAWH,SAAAA,CAAAA,CAA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AAA,EAAkB;AACtClD,wBAAAA,OAAAA;AACAE,wBAAAA,SAAAA;AACAC,wBAAAA;AACF,qBAAA,CAAA,CAAA;AAGF,oBAAA;AACF,gBAAA;AACA,YAAA;AAAS,gBAAA;;oBAEP,MAAM,IAAIgD,MAAM,CAAC,aAAa,EAAE3C,SAAAA,CAAUC,IAAI,CAAC,kCAAkC,CAAC,CAAA;AACpF,gBAAA;AACF;AACF,IAAA;IAEA,OAAOL,gBAAAA;AACT;;;;"}
1
+ {"version":3,"file":"clean-schema-attributes.mjs","sources":["../../../../../server/src/services/helpers/utils/clean-schema-attributes.ts"],"sourcesContent":["import type { Struct } from '@strapi/types';\nimport type { OpenAPIV3 } from 'openapi-types';\n\nimport getSchemaData from './get-schema-data';\nimport pascalCase from './pascal-case';\n\ninterface Options {\n typeMap?: Map<string, boolean>;\n isRequest?: boolean;\n didAddStrapiComponentsToSchemas: (name: string, schema: object) => boolean;\n}\n\n/**\n * @description - Convert attribute component names to OpenAPI component names\n *\n * @returns OpenAPI component name\n */\nconst convertComponentName = (component: string, isRef = false): string => {\n const cleanComponentName = `${pascalCase(component)}Component`;\n\n if (isRef) {\n return `#/components/schemas/${cleanComponentName}`;\n }\n return cleanComponentName;\n};\n\n/**\n * @description - Converts types found on attributes to OpenAPI acceptable data types\n *\n * @returns Attributes using OpenAPI acceptable data types\n */\nconst cleanSchemaAttributes = (\n attributes: Struct.SchemaAttributes,\n { typeMap = new Map(), isRequest = false, didAddStrapiComponentsToSchemas }: Options\n): Record<string, OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject> => {\n const schemaAttributes: Record<string, OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject> = {};\n\n for (const prop of Object.keys(attributes)) {\n const attribute = attributes[prop];\n\n switch (attribute.type) {\n case 'password': {\n if (!isRequest) {\n break;\n }\n\n schemaAttributes[prop] = { type: 'string', format: 'password', example: '*******' };\n break;\n }\n case 'email': {\n schemaAttributes[prop] = { type: 'string', format: 'email' };\n break;\n }\n case 'string':\n case 'text':\n case 'richtext': {\n schemaAttributes[prop] = { type: 'string' };\n break;\n }\n case 'timestamp': {\n schemaAttributes[prop] = { type: 'string', format: 'timestamp', example: Date.now() };\n break;\n }\n case 'time': {\n schemaAttributes[prop] = { type: 'string', format: 'time', example: '12:54.000' };\n break;\n }\n case 'date': {\n schemaAttributes[prop] = { type: 'string', format: 'date' };\n break;\n }\n case 'datetime': {\n schemaAttributes[prop] = { type: 'string', format: 'date-time' };\n break;\n }\n case 'boolean': {\n schemaAttributes[prop] = { type: 'boolean' };\n break;\n }\n case 'enumeration': {\n schemaAttributes[prop] = { type: 'string', enum: [...attribute.enum] };\n break;\n }\n case 'decimal':\n case 'float': {\n schemaAttributes[prop] = { type: 'number', format: 'float' };\n break;\n }\n case 'integer': {\n schemaAttributes[prop] = { type: 'integer' };\n break;\n }\n case 'biginteger': {\n schemaAttributes[prop] = { type: 'string', pattern: '^\\\\d*$', example: '123456789' };\n break;\n }\n case 'json':\n case 'blocks': {\n schemaAttributes[prop] = {};\n break;\n }\n case 'uid': {\n schemaAttributes[prop] = { type: 'string' };\n break;\n }\n case 'component': {\n const componentAttributes = strapi.components[attribute.component].attributes;\n const rawComponentSchema: OpenAPIV3.SchemaObject = {\n type: 'object',\n properties: {\n ...(isRequest ? {} : { id: { oneOf: [{ type: 'string' }, { type: 'number' }] } }),\n ...cleanSchemaAttributes(componentAttributes, {\n typeMap,\n isRequest,\n didAddStrapiComponentsToSchemas,\n }),\n },\n };\n\n const refComponentSchema: OpenAPIV3.ReferenceObject = {\n $ref: convertComponentName(attribute.component, true),\n };\n\n const componentExists = didAddStrapiComponentsToSchemas(\n convertComponentName(attribute.component),\n rawComponentSchema\n );\n\n const finalComponentSchema = componentExists ? refComponentSchema : rawComponentSchema;\n if (attribute.repeatable) {\n schemaAttributes[prop] = {\n type: 'array',\n items: finalComponentSchema,\n };\n } else {\n schemaAttributes[prop] = finalComponentSchema;\n }\n break;\n }\n case 'dynamiczone': {\n const components = attribute.components.map((component) => {\n const componentAttributes = strapi.components[component].attributes;\n const rawComponentSchema: OpenAPIV3.SchemaObject = {\n type: 'object',\n properties: {\n ...(isRequest ? {} : { id: { oneOf: [{ type: 'string' }, { type: 'number' }] } }),\n __component: { type: 'string', enum: [component] },\n ...cleanSchemaAttributes(componentAttributes, {\n typeMap,\n isRequest,\n didAddStrapiComponentsToSchemas,\n }),\n },\n };\n\n const refComponentSchema: OpenAPIV3.ReferenceObject = {\n $ref: convertComponentName(component, true),\n };\n\n const componentExists = didAddStrapiComponentsToSchemas(\n convertComponentName(component),\n rawComponentSchema\n );\n const finalComponentSchema = componentExists ? refComponentSchema : rawComponentSchema;\n return finalComponentSchema;\n });\n let discriminator: OpenAPIV3.DiscriminatorObject | undefined;\n if (components.every((component) => Object.hasOwn(component, '$ref'))) {\n discriminator = {\n propertyName: '__component',\n mapping: attribute.components.reduce(\n (acc, component) => {\n acc[component] = convertComponentName(component, true);\n return acc;\n },\n {} as {\n [value: string]: string;\n }\n ),\n };\n }\n\n schemaAttributes[prop] = {\n type: 'array',\n items: {\n anyOf: components,\n },\n discriminator,\n };\n break;\n }\n case 'media': {\n const imageAttributes = strapi.contentType('plugin::upload.file').attributes;\n const isListOfEntities = attribute.multiple ?? false;\n\n if (isRequest) {\n const oneOfType: OpenAPIV3.SchemaObject = {\n oneOf: [{ type: 'integer' }, { type: 'string' }],\n example: 'string or id',\n };\n\n schemaAttributes[prop] = isListOfEntities\n ? { type: 'array', items: oneOfType }\n : oneOfType;\n break;\n }\n\n schemaAttributes[prop] = getSchemaData(\n isListOfEntities,\n cleanSchemaAttributes(imageAttributes, { typeMap, didAddStrapiComponentsToSchemas })\n );\n break;\n }\n\n case 'relation': {\n const isListOfEntities = attribute.relation.includes('ToMany');\n\n if (isRequest) {\n const oneOfType: OpenAPIV3.SchemaObject = {\n oneOf: [{ type: 'integer' }, { type: 'string' }],\n example: 'string or id',\n };\n\n schemaAttributes[prop] = isListOfEntities\n ? { type: 'array', items: oneOfType }\n : oneOfType;\n break;\n }\n\n if (!('target' in attribute) || !attribute.target || typeMap.has(attribute.target)) {\n schemaAttributes[prop] = getSchemaData(isListOfEntities, {});\n\n break;\n }\n\n typeMap.set(attribute.target, true);\n const targetAttributes = strapi.contentType(attribute.target).attributes;\n\n schemaAttributes[prop] = getSchemaData(\n isListOfEntities,\n cleanSchemaAttributes(targetAttributes, {\n typeMap,\n isRequest,\n didAddStrapiComponentsToSchemas,\n })\n );\n\n break;\n }\n default: {\n // @ts-expect-error - This is a catch all for any other types\n throw new Error(`Invalid type ${attribute.type} while generating open api schema.`);\n }\n }\n }\n\n return schemaAttributes;\n};\n\nexport default cleanSchemaAttributes;\n"],"names":["convertComponentName","component","isRef","cleanComponentName","pascalCase","cleanSchemaAttributes","attributes","typeMap","Map","isRequest","didAddStrapiComponentsToSchemas","schemaAttributes","prop","Object","keys","attribute","type","format","example","Date","now","enum","pattern","componentAttributes","strapi","components","rawComponentSchema","properties","id","oneOf","refComponentSchema","$ref","componentExists","finalComponentSchema","repeatable","items","map","__component","discriminator","every","hasOwn","propertyName","mapping","reduce","acc","anyOf","imageAttributes","contentType","isListOfEntities","multiple","oneOfType","getSchemaData","relation","includes","target","has","set","targetAttributes","Error"],"mappings":";;;AAYA;;;;AAIC,IACD,MAAMA,oBAAAA,GAAuB,CAACC,SAAAA,EAAmBC,QAAQ,KAAK,GAAA;AAC5D,IAAA,MAAMC,kBAAAA,GAAqB,CAAA,EAAGC,UAAAA,CAAWH,SAAAA,CAAAA,CAAW,SAAS,CAAC;AAE9D,IAAA,IAAIC,KAAAA,EAAO;QACT,OAAO,CAAC,qBAAqB,EAAEC,kBAAAA,CAAAA,CAAoB;AACrD,IAAA;IACA,OAAOA,kBAAAA;AACT,CAAA;AAEA;;;;AAIC,IACD,MAAME,qBAAAA,GAAwB,CAC5BC,UAAAA,EACA,EAAEC,OAAAA,GAAU,IAAIC,GAAAA,EAAK,EAAEC,SAAAA,GAAY,KAAK,EAAEC,+BAA+B,EA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;;;;"}
@@ -2,6 +2,10 @@
2
2
 
3
3
  var _ = require('lodash');
4
4
 
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var ___default = /*#__PURE__*/_interopDefault(_);
8
+
5
9
  /**
6
10
  * @description A reusable loop for building api endpoint paths and component schemas
7
11
  */ const loopContentTypeNames = (api, callback)=>{
@@ -17,9 +21,9 @@ var _ = require('lodash');
17
21
  continue;
18
22
  }
19
23
  // Uppercase the first letter of the api name
20
- const apiName = _.upperFirst(api.name);
24
+ const apiName = ___default.default.upperFirst(api.name);
21
25
  // Create a unique name if the api name and contentType name don't match
22
- const uniqueName = api.name === contentTypeName ? apiName : `${apiName} - ${_.upperFirst(contentTypeName)}`;
26
+ const uniqueName = api.name === contentTypeName ? apiName : `${apiName} - ${___default.default.upperFirst(contentTypeName)}`;
23
27
  const apiInfo = {
24
28
  ...api,
25
29
  routeInfo,
@@ -1 +1 @@
1
- {"version":3,"file":"loop-content-type-names.js","sources":["../../../../../server/src/services/helpers/utils/loop-content-type-names.ts"],"sourcesContent":["import _ from 'lodash';\n\nimport type { Api, ApiInfo } from '../../../types';\n\n/**\n * @description A reusable loop for building api endpoint paths and component schemas\n */\nconst loopContentTypeNames = (api: Api, callback: (info: ApiInfo) => any) => {\n let result = {};\n for (const contentTypeName of api.ctNames) {\n // Get the attributes found on the api's contentType\n const uid = `${api.getter}::${api.name}.${contentTypeName}`;\n\n const { attributes, info: contentTypeInfo, kind } = strapi.contentType(uid as any);\n\n // Get the routes for the current api\n const routeInfo =\n api.getter === 'plugin'\n ? // @ts-expect-error – TODO: fix this\n strapi.plugin(api.name).routes['content-api']\n : strapi.api(api.name).routes[contentTypeName];\n\n // Continue to next iteration if routeInfo is undefined\n if (!routeInfo) {\n continue;\n }\n\n // Uppercase the first letter of the api name\n const apiName = _.upperFirst(api.name);\n\n // Create a unique name if the api name and contentType name don't match\n const uniqueName =\n api.name === contentTypeName ? apiName : `${apiName} - ${_.upperFirst(contentTypeName)}`;\n\n const apiInfo = {\n ...api,\n routeInfo,\n attributes,\n uniqueName,\n contentTypeInfo,\n kind,\n };\n\n result = {\n ...result,\n ...callback(apiInfo),\n };\n }\n\n return result;\n};\n\nexport default loopContentTypeNames;\n"],"names":["loopContentTypeNames","api","callback","result","contentTypeName","ctNames","uid","getter","name","attributes","info","contentTypeInfo","kind","strapi","contentType","routeInfo","plugin","routes","apiName","_","upperFirst","uniqueName","apiInfo"],"mappings":";;;;AAIA;;IAGA,MAAMA,oBAAAA,GAAuB,CAACC,GAAAA,EAAUC,QAAAA,GAAAA;AACtC,IAAA,IAAIC,SAAS,EAAC;AACd,IAAA,KAAK,MAAMC,eAAAA,IAAmBH,GAAAA,CAAII,OAAO,CAAE;;AAEzC,QAAA,MAAMC,GAAAA,GAAM,CAAA,EAAGL,GAAAA,CAAIM,MAAM,CAAC,EAAE,EAAEN,GAAAA,CAAIO,IAAI,CAAC,CAAC,EAAEJ,eAAAA,CAAAA,CAAiB;QAE3D,MAAM,EAAEK,UAAU,EAAEC,IAAAA,EAAMC,eAAe,EAAEC,IAAI,EAAE,GAAGC,MAAAA,CAAOC,WAAW,CAACR,GAAAA,CAAAA;;QAGvE,MAAMS,SAAAA,GACJd,IAAIM,MAAM,KAAK,WAEXM,MAAAA,CAAOG,MAAM,CAACf,GAAAA,CAAIO,IAAI,CAAA,CAAES,MAAM,CAAC,aAAA,CAAc,GAC7CJ,MAAAA,CAAOZ,GAAG,CAACA,IAAIO,IAAI,CAAA,CAAES,MAAM,CAACb,eAAAA,CAAgB;;AAGlD,QAAA,IAAI,CAACW,SAAAA,EAAW;AACd,YAAA;AACF,QAAA;;AAGA,QAAA,MAAMG,OAAAA,GAAUC,CAAAA,CAAEC,UAAU,CAACnB,IAAIO,IAAI,CAAA;;AAGrC,QAAA,MAAMa,UAAAA,GACJpB,GAAAA,CAAIO,IAAI,KAAKJ,eAAAA,GAAkBc,OAAAA,GAAU,CAAA,EAAGA,OAAAA,CAAQ,GAAG,EAAEC,CAAAA,CAAEC,UAAU,CAAChB,eAAAA,CAAAA,CAAAA,CAAkB;AAE1F,QAAA,MAAMkB,OAAAA,GAAU;AACd,YAAA,GAAGrB,GAAG;AACNc,YAAAA,SAAAA;AACAN,YAAAA,UAAAA;AACAY,YAAAA,UAAAA;AACAV,YAAAA,eAAAA;AACAC,YAAAA;AACF,SAAA;QAEAT,MAAAA,GAAS;AACP,YAAA,GAAGA,MAAM;AACT,YAAA,GAAGD,SAASoB,OAAAA;AACd,SAAA;AACF,IAAA;IAEA,OAAOnB,MAAAA;AACT;;;;"}
1
+ {"version":3,"file":"loop-content-type-names.js","sources":["../../../../../server/src/services/helpers/utils/loop-content-type-names.ts"],"sourcesContent":["import _ from 'lodash';\n\nimport type { Api, ApiInfo } from '../../../types';\n\n/**\n * @description A reusable loop for building api endpoint paths and component schemas\n */\nconst loopContentTypeNames = (api: Api, callback: (info: ApiInfo) => any) => {\n let result = {};\n for (const contentTypeName of api.ctNames) {\n // Get the attributes found on the api's contentType\n const uid = `${api.getter}::${api.name}.${contentTypeName}`;\n\n const { attributes, info: contentTypeInfo, kind } = strapi.contentType(uid as any);\n\n // Get the routes for the current api\n const routeInfo =\n api.getter === 'plugin'\n ? // @ts-expect-error – TODO: fix this\n strapi.plugin(api.name).routes['content-api']\n : strapi.api(api.name).routes[contentTypeName];\n\n // Continue to next iteration if routeInfo is undefined\n if (!routeInfo) {\n continue;\n }\n\n // Uppercase the first letter of the api name\n const apiName = _.upperFirst(api.name);\n\n // Create a unique name if the api name and contentType name don't match\n const uniqueName =\n api.name === contentTypeName ? apiName : `${apiName} - ${_.upperFirst(contentTypeName)}`;\n\n const apiInfo = {\n ...api,\n routeInfo,\n attributes,\n uniqueName,\n contentTypeInfo,\n kind,\n };\n\n result = {\n ...result,\n ...callback(apiInfo),\n };\n }\n\n return result;\n};\n\nexport default loopContentTypeNames;\n"],"names":["loopContentTypeNames","api","callback","result","contentTypeName","ctNames","uid","getter","name","attributes","info","contentTypeInfo","kind","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F,SAAA;QAEAT,MAAAA,GAAS;AACP,YAAA,GAAGA,MAAM;AACT,YAAA,GAAGD,SAASoB,OAAAA;AACd,SAAA;AACF,IAAA;IAEA,OAAOnB,MAAAA;AACT;;;;"}
@@ -2,8 +2,12 @@
2
2
 
3
3
  var _ = require('lodash');
4
4
 
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var ___default = /*#__PURE__*/_interopDefault(_);
8
+
5
9
  const pascalCase = (string)=>{
6
- return _.upperFirst(_.camelCase(string));
10
+ return ___default.default.upperFirst(___default.default.camelCase(string));
7
11
  };
8
12
 
9
13
  module.exports = pascalCase;
@@ -1 +1 @@
1
- {"version":3,"file":"pascal-case.js","sources":["../../../../../server/src/services/helpers/utils/pascal-case.ts"],"sourcesContent":["import _ from 'lodash';\n\nconst pascalCase = (string: string) => {\n return _.upperFirst(_.camelCase(string));\n};\n\nexport default pascalCase;\n"],"names":["pascalCase","string","_","upperFirst","camelCase"],"mappings":";;;;AAEA,MAAMA,aAAa,CAACC,MAAAA,GAAAA;AAClB,IAAA,OAAOC,CAAAA,CAAEC,UAAU,CAACD,CAAAA,CAAEE,SAAS,CAACH,MAAAA,CAAAA,CAAAA;AAClC;;;;"}
1
+ {"version":3,"file":"pascal-case.js","sources":["../../../../../server/src/services/helpers/utils/pascal-case.ts"],"sourcesContent":["import _ from 'lodash';\n\nconst pascalCase = (string: string) => {\n return _.upperFirst(_.camelCase(string));\n};\n\nexport default pascalCase;\n"],"names":["pascalCase","string","_","upperFirst","camelCase"],"mappings":";;;;;;;;AAEA,MAAMA,aAAa,CAACC,MAAAA,GAAAA;AAClB,IAAA,OAAOC,kBAAAA,CAAEC,UAAU,CAACD,kBAAAA,CAAEE,SAAS,CAACH,MAAAA,CAAAA,CAAAA;AAClC;;;;"}
@@ -4,8 +4,8 @@ declare const _default: {
4
4
  index(ctx: Koa.Context, next: Koa.Next): Promise<any>;
5
5
  loginView(ctx: Koa.Context, next: Koa.Next): Promise<any>;
6
6
  login(ctx: Koa.Context): Promise<void>;
7
- regenerateDoc(ctx: Koa.Context): Promise<Koa.Context | undefined>;
8
- deleteDoc(ctx: Koa.Context): Promise<Koa.Context | undefined>;
7
+ regenerateDoc(ctx: Koa.Context): Promise<any>;
8
+ deleteDoc(ctx: Koa.Context): Promise<any>;
9
9
  updateSettings(ctx: Koa.Context): Promise<any>;
10
10
  };
11
11
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"documentation.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/documentation.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;;kBAwBL,IAAI,OAAO;eAkBd,IAAI,OAAO,QAAQ,IAAI,IAAI;mBA4DvB,IAAI,OAAO,QAAQ,IAAI,IAAI;eA4C/B,IAAI,OAAO;uBAwBH,IAAI,OAAO;mBAwBf,IAAI,OAAO;wBAwBN,IAAI,OAAO;;AAnMvC,wBAoNE"}
1
+ {"version":3,"file":"documentation.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/documentation.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;;kBAwBL,GAAG,CAAC,OAAO;eAkBd,GAAG,CAAC,OAAO,QAAQ,GAAG,CAAC,IAAI;mBA4DvB,GAAG,CAAC,OAAO,QAAQ,GAAG,CAAC,IAAI;eA4C/B,GAAG,CAAC,OAAO;uBAwBH,GAAG,CAAC,OAAO;mBAwBf,GAAG,CAAC,OAAO;wBAwBN,GAAG,CAAC,OAAO;;AAnMvC,wBAoNE"}
@@ -1,12 +1,11 @@
1
- /// <reference types="koa" />
2
1
  declare const _default: {
3
2
  documentation: {
4
3
  getInfos(ctx: import("koa").Context): Promise<void>;
5
4
  index(ctx: import("koa").Context, next: import("koa").Next): Promise<any>;
6
5
  loginView(ctx: import("koa").Context, next: import("koa").Next): Promise<any>;
7
6
  login(ctx: import("koa").Context): Promise<void>;
8
- regenerateDoc(ctx: import("koa").Context): Promise<import("koa").Context | undefined>;
9
- deleteDoc(ctx: import("koa").Context): Promise<import("koa").Context | undefined>;
7
+ regenerateDoc(ctx: import("koa").Context): Promise<any>;
8
+ deleteDoc(ctx: import("koa").Context): Promise<any>;
10
9
  updateSettings(ctx: import("koa").Context): Promise<any>;
11
10
  };
12
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,wBAEE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,wBAEE"}
@@ -1,4 +1,3 @@
1
- /// <reference types="koa" />
2
1
  import { bootstrap } from './bootstrap';
3
2
  import { register } from './register';
4
3
  declare const _default: {
@@ -45,8 +44,8 @@ declare const _default: {
45
44
  index(ctx: import("koa").Context, next: import("koa").Next): Promise<any>;
46
45
  loginView(ctx: import("koa").Context, next: import("koa").Next): Promise<any>;
47
46
  login(ctx: import("koa").Context): Promise<void>;
48
- regenerateDoc(ctx: import("koa").Context): Promise<import("koa").Context | undefined>;
49
- deleteDoc(ctx: import("koa").Context): Promise<import("koa").Context | undefined>;
47
+ regenerateDoc(ctx: import("koa").Context): Promise<any>;
48
+ deleteDoc(ctx: import("koa").Context): Promise<any>;
50
49
  updateSettings(ctx: import("koa").Context): Promise<any>;
51
50
  };
52
51
  };
@@ -71,7 +70,7 @@ declare const _default: {
71
70
  getter: string;
72
71
  ctNames: string[];
73
72
  }[];
74
- generateFullDoc(versionOpt?: string | undefined): Promise<void>;
73
+ generateFullDoc(versionOpt?: string): Promise<void>;
75
74
  };
76
75
  override: ({ strapi }: {
77
76
  strapi: import("@strapi/types/dist/core").Strapi;
@@ -82,8 +81,8 @@ declare const _default: {
82
81
  isEnabled(name: string): boolean;
83
82
  registerOverride(override: Partial<import("./types").PluginConfig>, opts?: {
84
83
  pluginOrigin: string;
85
- excludeFromGeneration?: string[] | undefined;
86
- } | undefined): void;
84
+ excludeFromGeneration?: string[];
85
+ }): void;
87
86
  };
88
87
  };
89
88
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/src/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMtC,wBAOE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAcuqB,CAAC;;;;;AAR9sB,wBAOE"}
@@ -1 +1 @@
1
- {"version":3,"file":"documentation.d.ts","sourceRoot":"","sources":["../../../../server/src/middlewares/documentation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,eAAO,MAAM,sBAAsB,eAAsB;IAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CAAE,kBAkB/E,CAAC"}
1
+ {"version":3,"file":"documentation.d.ts","sourceRoot":"","sources":["../../../../server/src/middlewares/documentation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,eAAO,MAAM,sBAAsB,GAAU,YAAY;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE,kBAkB/E,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"restrict-access.d.ts","sourceRoot":"","sources":["../../../../server/src/middlewares/restrict-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;8BAKA,IAAI,OAAO,QAAQ,IAAI,IAAI;AAAtD,wBAiBE"}
1
+ {"version":3,"file":"restrict-access.d.ts","sourceRoot":"","sources":["../../../../server/src/middlewares/restrict-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;yBAKL,KAAK,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,IAAI;AAAtD,wBAiBE"}
@@ -1,4 +1,3 @@
1
- /// <reference types="koa" />
2
1
  declare const _default: ({
3
2
  method: string;
4
3
  path: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/routes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wBA+EE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/routes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wBA+EE"}