@strapi/plugin-documentation 5.37.1 → 5.38.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.
- package/dist/admin/components/SettingsForm.js.map +1 -1
- package/dist/admin/components/SettingsForm.mjs +2 -2
- package/dist/admin/components/SettingsForm.mjs.map +1 -1
- package/dist/admin/constants.js.map +1 -1
- package/dist/admin/constants.mjs.map +1 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/pages/App.js.map +1 -1
- package/dist/admin/pages/App.mjs.map +1 -1
- package/dist/admin/pages/Settings.js.map +1 -1
- package/dist/admin/pages/Settings.mjs.map +1 -1
- package/dist/admin/services/api.js.map +1 -1
- package/dist/admin/services/api.mjs.map +1 -1
- package/dist/admin/utils/getTrad.js.map +1 -1
- package/dist/admin/utils/getTrad.mjs.map +1 -1
- package/dist/admin/utils/prefixPluginTranslations.js.map +1 -1
- package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -1
- package/dist/server/bootstrap.js.map +1 -1
- package/dist/server/bootstrap.mjs.map +1 -1
- package/dist/server/config/default-plugin-config.js.map +1 -1
- package/dist/server/config/default-plugin-config.mjs.map +1 -1
- package/dist/server/config/index.js.map +1 -1
- package/dist/server/config/index.mjs.map +1 -1
- package/dist/server/controllers/documentation.js.map +1 -1
- package/dist/server/controllers/documentation.mjs.map +1 -1
- package/dist/server/controllers/index.js.map +1 -1
- package/dist/server/controllers/index.mjs.map +1 -1
- package/dist/server/index.js +8 -8
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/middlewares/documentation.js.map +1 -1
- package/dist/server/middlewares/documentation.mjs.map +1 -1
- package/dist/server/middlewares/restrict-access.js.map +1 -1
- package/dist/server/middlewares/restrict-access.mjs.map +1 -1
- package/dist/server/register.js.map +1 -1
- package/dist/server/register.mjs.map +1 -1
- package/dist/server/routes/index.js.map +1 -1
- package/dist/server/routes/index.mjs.map +1 -1
- package/dist/server/services/documentation.js.map +1 -1
- package/dist/server/services/documentation.mjs.map +1 -1
- package/dist/server/services/helpers/build-api-endpoint-path.js.map +1 -1
- package/dist/server/services/helpers/build-api-endpoint-path.mjs.map +1 -1
- package/dist/server/services/helpers/build-component-schema.js.map +1 -1
- package/dist/server/services/helpers/build-component-schema.mjs.map +1 -1
- package/dist/server/services/helpers/utils/clean-schema-attributes.js.map +1 -1
- package/dist/server/services/helpers/utils/clean-schema-attributes.mjs.map +1 -1
- package/dist/server/services/helpers/utils/get-api-responses.js.map +1 -1
- package/dist/server/services/helpers/utils/get-api-responses.mjs.map +1 -1
- package/dist/server/services/helpers/utils/get-schema-data.js.map +1 -1
- package/dist/server/services/helpers/utils/get-schema-data.mjs.map +1 -1
- package/dist/server/services/helpers/utils/loop-content-type-names.js.map +1 -1
- package/dist/server/services/helpers/utils/loop-content-type-names.mjs.map +1 -1
- package/dist/server/services/helpers/utils/pascal-case.js.map +1 -1
- package/dist/server/services/helpers/utils/pascal-case.mjs.map +1 -1
- package/dist/server/services/helpers/utils/query-params.js.map +1 -1
- package/dist/server/services/helpers/utils/query-params.mjs.map +1 -1
- package/dist/server/services/helpers/utils/routes.js.map +1 -1
- package/dist/server/services/helpers/utils/routes.mjs.map +1 -1
- package/dist/server/services/index.js.map +1 -1
- package/dist/server/services/index.mjs +4 -4
- package/dist/server/services/index.mjs.map +1 -1
- package/dist/server/services/override.js.map +1 -1
- package/dist/server/services/override.mjs.map +1 -1
- package/dist/server/services/utils/get-plugins-that-need-documentation.js.map +1 -1
- package/dist/server/services/utils/get-plugins-that-need-documentation.mjs.map +1 -1
- package/dist/server/utils.js.map +1 -1
- package/dist/server/utils.mjs.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.mjs","sources":["../../server/src/bootstrap.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { getService } from './utils';\n\n// Add permissions\nconst RBAC_ACTIONS = [\n {\n section: 'plugins',\n displayName: 'Access the Documentation',\n uid: 'read',\n pluginName: 'documentation',\n },\n {\n section: 'plugins',\n displayName: 'Update and delete',\n uid: 'settings.update',\n pluginName: 'documentation',\n },\n {\n section: 'plugins',\n displayName: 'Regenerate',\n uid: 'settings.regenerate',\n pluginName: 'documentation',\n },\n {\n section: 'settings',\n displayName: 'Access the documentation settings page',\n uid: 'settings.read',\n pluginName: 'documentation',\n category: 'documentation',\n },\n];\n\nexport async function bootstrap({ strapi }: { strapi: Core.Strapi }) {\n await strapi.service('admin::permission').actionProvider.registerMany(RBAC_ACTIONS);\n\n const pluginStore = strapi.store!({\n environment: '',\n type: 'plugin',\n name: 'documentation',\n });\n\n const config = await pluginStore.get({ key: 'config' });\n\n if (!config) {\n pluginStore.set({ key: 'config', value: { restrictedAccess: false } });\n }\n if (process.env.NODE_ENV !== 'production') {\n await getService('documentation').generateFullDoc();\n }\n}\n"],"names":["RBAC_ACTIONS","section","displayName","uid","pluginName","category","bootstrap","strapi","service","actionProvider","registerMany","pluginStore","store","environment","type","name","config","get","key","set","value","restrictedAccess","process","env","NODE_ENV","getService","generateFullDoc"],"mappings":";;AAIA;AACA,MAAMA,
|
|
1
|
+
{"version":3,"file":"bootstrap.mjs","sources":["../../server/src/bootstrap.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { getService } from './utils';\n\n// Add permissions\nconst RBAC_ACTIONS = [\n {\n section: 'plugins',\n displayName: 'Access the Documentation',\n uid: 'read',\n pluginName: 'documentation',\n },\n {\n section: 'plugins',\n displayName: 'Update and delete',\n uid: 'settings.update',\n pluginName: 'documentation',\n },\n {\n section: 'plugins',\n displayName: 'Regenerate',\n uid: 'settings.regenerate',\n pluginName: 'documentation',\n },\n {\n section: 'settings',\n displayName: 'Access the documentation settings page',\n uid: 'settings.read',\n pluginName: 'documentation',\n category: 'documentation',\n },\n];\n\nexport async function bootstrap({ strapi }: { strapi: Core.Strapi }) {\n await strapi.service('admin::permission').actionProvider.registerMany(RBAC_ACTIONS);\n\n const pluginStore = strapi.store!({\n environment: '',\n type: 'plugin',\n name: 'documentation',\n });\n\n const config = await pluginStore.get({ key: 'config' });\n\n if (!config) {\n pluginStore.set({ key: 'config', value: { restrictedAccess: false } });\n }\n if (process.env.NODE_ENV !== 'production') {\n await getService('documentation').generateFullDoc();\n }\n}\n"],"names":["RBAC_ACTIONS","section","displayName","uid","pluginName","category","bootstrap","strapi","service","actionProvider","registerMany","pluginStore","store","environment","type","name","config","get","key","set","value","restrictedAccess","process","env","NODE_ENV","getService","generateFullDoc"],"mappings":";;AAIA;AACA,MAAMA,YAAAA,GAAe;AACnB,IAAA;QACEC,OAAAA,EAAS,SAAA;QACTC,WAAAA,EAAa,0BAAA;QACbC,GAAAA,EAAK,MAAA;QACLC,UAAAA,EAAY;AACd,KAAA;AACA,IAAA;QACEH,OAAAA,EAAS,SAAA;QACTC,WAAAA,EAAa,mBAAA;QACbC,GAAAA,EAAK,iBAAA;QACLC,UAAAA,EAAY;AACd,KAAA;AACA,IAAA;QACEH,OAAAA,EAAS,SAAA;QACTC,WAAAA,EAAa,YAAA;QACbC,GAAAA,EAAK,qBAAA;QACLC,UAAAA,EAAY;AACd,KAAA;AACA,IAAA;QACEH,OAAAA,EAAS,UAAA;QACTC,WAAAA,EAAa,wCAAA;QACbC,GAAAA,EAAK,eAAA;QACLC,UAAAA,EAAY,eAAA;QACZC,QAAAA,EAAU;AACZ;AACD,CAAA;AAEM,eAAeC,SAAAA,CAAU,EAAEC,MAAM,EAA2B,EAAA;AACjE,IAAA,MAAMA,OAAOC,OAAO,CAAC,qBAAqBC,cAAc,CAACC,YAAY,CAACV,YAAAA,CAAAA;IAEtE,MAAMW,WAAAA,GAAcJ,MAAAA,CAAOK,KAAK,CAAE;QAChCC,WAAAA,EAAa,EAAA;QACbC,IAAAA,EAAM,QAAA;QACNC,IAAAA,EAAM;AACR,KAAA,CAAA;AAEA,IAAA,MAAMC,MAAAA,GAAS,MAAML,WAAAA,CAAYM,GAAG,CAAC;QAAEC,GAAAA,EAAK;AAAS,KAAA,CAAA;AAErD,IAAA,IAAI,CAACF,MAAAA,EAAQ;AACXL,QAAAA,WAAAA,CAAYQ,GAAG,CAAC;YAAED,GAAAA,EAAK,QAAA;YAAUE,KAAAA,EAAO;gBAAEC,gBAAAA,EAAkB;AAAM;AAAE,SAAA,CAAA;AACtE,IAAA;AACA,IAAA,IAAIC,OAAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,YAAA,EAAc;QACzC,MAAMC,UAAAA,CAAW,iBAAiBC,eAAe,EAAA;AACnD,IAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-plugin-config.js","sources":["../../../server/src/config/default-plugin-config.ts"],"sourcesContent":["import type { PluginConfig } from '../types';\n\nexport const defaultConfig: PluginConfig = {\n openapi: '3.0.0',\n info: {\n version: '1.0.0',\n title: 'DOCUMENTATION',\n description: '',\n termsOfService: 'YOUR_TERMS_OF_SERVICE_URL',\n contact: {\n name: 'TEAM',\n email: 'contact-email@something.io',\n url: 'mywebsite.io',\n },\n license: {\n name: 'Apache 2.0',\n url: 'https://www.apache.org/licenses/LICENSE-2.0.html',\n },\n },\n 'x-strapi-config': {\n plugins: null,\n mutateDocumentation: null,\n },\n servers: [],\n externalDocs: {\n description: 'Find out more',\n url: 'https://docs.strapi.io/developer-docs/latest/getting-started/introduction.html',\n },\n security: [\n {\n bearerAuth: [],\n },\n ],\n paths: {},\n components: {\n securitySchemes: {\n bearerAuth: {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n },\n },\n schemas: {\n Error: {\n type: 'object',\n required: ['error'],\n properties: {\n data: {\n nullable: true,\n oneOf: [{ type: 'object' }, { type: 'array', items: { type: 'object' } }],\n },\n error: {\n type: 'object',\n properties: {\n status: {\n type: 'integer',\n },\n name: {\n type: 'string',\n },\n message: {\n type: 'string',\n },\n details: {\n type: 'object',\n },\n },\n },\n },\n },\n },\n },\n};\n"],"names":["defaultConfig","openapi","info","version","title","description","termsOfService","contact","name","email","url","license","plugins","mutateDocumentation","servers","externalDocs","security","bearerAuth","paths","components","securitySchemes","type","scheme","bearerFormat","schemas","Error","required","properties","data","nullable","oneOf","items","error","status","message","details"],"mappings":";;MAEaA,
|
|
1
|
+
{"version":3,"file":"default-plugin-config.js","sources":["../../../server/src/config/default-plugin-config.ts"],"sourcesContent":["import type { PluginConfig } from '../types';\n\nexport const defaultConfig: PluginConfig = {\n openapi: '3.0.0',\n info: {\n version: '1.0.0',\n title: 'DOCUMENTATION',\n description: '',\n termsOfService: 'YOUR_TERMS_OF_SERVICE_URL',\n contact: {\n name: 'TEAM',\n email: 'contact-email@something.io',\n url: 'mywebsite.io',\n },\n license: {\n name: 'Apache 2.0',\n url: 'https://www.apache.org/licenses/LICENSE-2.0.html',\n },\n },\n 'x-strapi-config': {\n plugins: null,\n mutateDocumentation: null,\n },\n servers: [],\n externalDocs: {\n description: 'Find out more',\n url: 'https://docs.strapi.io/developer-docs/latest/getting-started/introduction.html',\n },\n security: [\n {\n bearerAuth: [],\n },\n ],\n paths: {},\n components: {\n securitySchemes: {\n bearerAuth: {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n },\n },\n schemas: {\n Error: {\n type: 'object',\n required: ['error'],\n properties: {\n data: {\n nullable: true,\n oneOf: [{ type: 'object' }, { type: 'array', items: { type: 'object' } }],\n },\n error: {\n type: 'object',\n properties: {\n status: {\n type: 'integer',\n },\n name: {\n type: 'string',\n },\n message: {\n type: 'string',\n },\n details: {\n type: 'object',\n },\n },\n },\n },\n },\n },\n },\n};\n"],"names":["defaultConfig","openapi","info","version","title","description","termsOfService","contact","name","email","url","license","plugins","mutateDocumentation","servers","externalDocs","security","bearerAuth","paths","components","securitySchemes","type","scheme","bearerFormat","schemas","Error","required","properties","data","nullable","oneOf","items","error","status","message","details"],"mappings":";;MAEaA,aAAAA,GAA8B;IACzCC,OAAAA,EAAS,OAAA;IACTC,IAA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IAAAA,EAAM;gCACJa,IAAAA,EAAM;AACR,6BAAA;4BACAa,OAAAA,EAAS;gCACPb,IAAAA,EAAM;AACR,6BAAA;4BACAc,OAAAA,EAAS;gCACPd,IAAAA,EAAM;AACR;AACF;AACF;AACF;AACF;AACF;AACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-plugin-config.mjs","sources":["../../../server/src/config/default-plugin-config.ts"],"sourcesContent":["import type { PluginConfig } from '../types';\n\nexport const defaultConfig: PluginConfig = {\n openapi: '3.0.0',\n info: {\n version: '1.0.0',\n title: 'DOCUMENTATION',\n description: '',\n termsOfService: 'YOUR_TERMS_OF_SERVICE_URL',\n contact: {\n name: 'TEAM',\n email: 'contact-email@something.io',\n url: 'mywebsite.io',\n },\n license: {\n name: 'Apache 2.0',\n url: 'https://www.apache.org/licenses/LICENSE-2.0.html',\n },\n },\n 'x-strapi-config': {\n plugins: null,\n mutateDocumentation: null,\n },\n servers: [],\n externalDocs: {\n description: 'Find out more',\n url: 'https://docs.strapi.io/developer-docs/latest/getting-started/introduction.html',\n },\n security: [\n {\n bearerAuth: [],\n },\n ],\n paths: {},\n components: {\n securitySchemes: {\n bearerAuth: {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n },\n },\n schemas: {\n Error: {\n type: 'object',\n required: ['error'],\n properties: {\n data: {\n nullable: true,\n oneOf: [{ type: 'object' }, { type: 'array', items: { type: 'object' } }],\n },\n error: {\n type: 'object',\n properties: {\n status: {\n type: 'integer',\n },\n name: {\n type: 'string',\n },\n message: {\n type: 'string',\n },\n details: {\n type: 'object',\n },\n },\n },\n },\n },\n },\n },\n};\n"],"names":["defaultConfig","openapi","info","version","title","description","termsOfService","contact","name","email","url","license","plugins","mutateDocumentation","servers","externalDocs","security","bearerAuth","paths","components","securitySchemes","type","scheme","bearerFormat","schemas","Error","required","properties","data","nullable","oneOf","items","error","status","message","details"],"mappings":"MAEaA,
|
|
1
|
+
{"version":3,"file":"default-plugin-config.mjs","sources":["../../../server/src/config/default-plugin-config.ts"],"sourcesContent":["import type { PluginConfig } from '../types';\n\nexport const defaultConfig: PluginConfig = {\n openapi: '3.0.0',\n info: {\n version: '1.0.0',\n title: 'DOCUMENTATION',\n description: '',\n termsOfService: 'YOUR_TERMS_OF_SERVICE_URL',\n contact: {\n name: 'TEAM',\n email: 'contact-email@something.io',\n url: 'mywebsite.io',\n },\n license: {\n name: 'Apache 2.0',\n url: 'https://www.apache.org/licenses/LICENSE-2.0.html',\n },\n },\n 'x-strapi-config': {\n plugins: null,\n mutateDocumentation: null,\n },\n servers: [],\n externalDocs: {\n description: 'Find out more',\n url: 'https://docs.strapi.io/developer-docs/latest/getting-started/introduction.html',\n },\n security: [\n {\n bearerAuth: [],\n },\n ],\n paths: {},\n components: {\n securitySchemes: {\n bearerAuth: {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n },\n },\n schemas: {\n Error: {\n type: 'object',\n required: ['error'],\n properties: {\n data: {\n nullable: true,\n oneOf: [{ type: 'object' }, { type: 'array', items: { type: 'object' } }],\n },\n error: {\n type: 'object',\n properties: {\n status: {\n type: 'integer',\n },\n name: {\n type: 'string',\n },\n message: {\n type: 'string',\n },\n details: {\n type: 'object',\n },\n },\n },\n },\n },\n },\n },\n};\n"],"names":["defaultConfig","openapi","info","version","title","description","termsOfService","contact","name","email","url","license","plugins","mutateDocumentation","servers","externalDocs","security","bearerAuth","paths","components","securitySchemes","type","scheme","bearerFormat","schemas","Error","required","properties","data","nullable","oneOf","items","error","status","message","details"],"mappings":"MAEaA,aAAAA,GAA8B;IACzCC,OAAAA,EAAS,OAAA;IACTC,IAAAA,EAAM;QACJC,OAAAA,EAAS,OAAA;QACTC,KAAAA,EAAO,eAAA;QACPC,WAAAA,EAAa,EAAA;QACbC,cAAAA,EAAgB,2BAAA;QAChBC,OAAAA,EAAS;YACPC,IAAAA,EAAM,MAAA;YACNC,KAAAA,EAAO,4BAAA;YACPC,GAAAA,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1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../server/src/config/index.ts"],"sourcesContent":["import { defaultConfig } from './default-plugin-config';\n\nexport const config = {\n default: defaultConfig,\n};\n"],"names":["config","default","defaultConfig"],"mappings":";;;;MAEaA,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../server/src/config/index.ts"],"sourcesContent":["import { defaultConfig } from './default-plugin-config';\n\nexport const config = {\n default: defaultConfig,\n};\n"],"names":["config","default","defaultConfig"],"mappings":";;;;MAEaA,MAAAA,GAAS;IACpBC,OAAAA,EAASC;AACX;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../server/src/config/index.ts"],"sourcesContent":["import { defaultConfig } from './default-plugin-config';\n\nexport const config = {\n default: defaultConfig,\n};\n"],"names":["config","default","defaultConfig"],"mappings":";;MAEaA,
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../server/src/config/index.ts"],"sourcesContent":["import { defaultConfig } from './default-plugin-config';\n\nexport const config = {\n default: defaultConfig,\n};\n"],"names":["config","default","defaultConfig"],"mappings":";;MAEaA,MAAAA,GAAS;IACpBC,OAAAA,EAASC;AACX;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentation.js","sources":["../../../server/src/controllers/documentation.ts"],"sourcesContent":["import path from 'path';\nimport bcrypt from 'bcryptjs';\nimport fs from 'fs-extra';\nimport _ from 'lodash';\nimport koaStatic from 'koa-static';\nimport { yup, validateYupSchema } from '@strapi/utils';\n\nimport type Koa from 'koa';\nimport type {} from 'koa-body';\n\nimport { getService } from '../utils';\nimport type { Config } from '../types';\n\nconst validation = {\n validateSettings: validateYupSchema(\n yup.object().shape({\n restrictedAccess: yup.boolean(),\n password: yup\n .string()\n .min(8)\n .matches(/[a-z]/, '${path} must contain at least one lowercase character')\n .matches(/[A-Z]/, '${path} must contain at least one uppercase character')\n .matches(/\\d/, '${path} must contain at least one number')\n .when('restrictedAccess', (value, initSchema) => {\n return value ? initSchema.required('password is required') : initSchema;\n }),\n })\n ),\n};\n\nexport default {\n async getInfos(ctx: Koa.Context) {\n try {\n const docService = getService('documentation');\n const docVersions = docService.getDocumentationVersions();\n const documentationAccess = await docService.getDocumentationAccess();\n\n ctx.send({\n docVersions,\n currentVersion: docService.getDocumentationVersion(),\n prefix: '/documentation',\n documentationAccess,\n });\n } catch (err) {\n strapi.log.error(err);\n ctx.badRequest();\n }\n },\n\n async index(ctx: Koa.Context, next: Koa.Next) {\n try {\n /**\n * We don't expose the specs using koa-static or something else due to security reasons.\n * That's why, we need to read the file localy and send the specs through it when we serve the Swagger UI.\n */\n const { major, minor, patch } = ctx.params;\n const version =\n major && minor && patch\n ? `${major}.${minor}.${patch}`\n : getService('documentation').getDocumentationVersion();\n\n const openAPISpecsPath = path.join(\n strapi.dirs.app.extensions,\n 'documentation',\n 'documentation',\n version,\n 'full_documentation.json'\n );\n\n try {\n const documentation = fs.readFileSync(openAPISpecsPath, 'utf8');\n\n const layout = (await import('../public/index.html')).default;\n\n const filledLayout = _.template(layout)({\n backendUrl: strapi.config.server.url,\n spec: JSON.stringify(JSON.parse(documentation)),\n });\n\n try {\n const layoutPath = path.resolve(\n strapi.dirs.app.extensions,\n 'documentation',\n 'public',\n 'index.html'\n );\n await fs.ensureFile(layoutPath);\n await fs.writeFile(layoutPath, filledLayout);\n\n // Serve the file.\n ctx.url = path.basename(`${ctx.url}/index.html`);\n\n try {\n const staticFolder = path.resolve(\n strapi.dirs.app.extensions,\n 'documentation',\n 'public'\n );\n return koaStatic(staticFolder)(ctx, next);\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n },\n\n async loginView(ctx: Koa.Context, next: Koa.Next) {\n // lazy require cheerio\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const cheerio = require('cheerio');\n\n const { error } = ctx.query;\n\n try {\n const layout = (await import('../public/login.html')).default;\n\n const filledLayout = _.template(layout.toString())({\n actionUrl: `${strapi.config.server.url}/documentation/login`,\n });\n\n const $ = cheerio.load(filledLayout);\n\n $('.error').text(_.isEmpty(error) ? '' : 'Wrong password...');\n\n try {\n const layoutPath = path.resolve(\n strapi.dirs.app.extensions,\n 'documentation',\n 'public',\n 'login.html'\n );\n await fs.ensureFile(layoutPath);\n await fs.writeFile(layoutPath, $.html());\n\n ctx.url = path.basename(`${ctx.url}/login.html`);\n\n try {\n const staticFolder = path.resolve(strapi.dirs.app.extensions, 'documentation', 'public');\n return koaStatic(staticFolder)(ctx, next);\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n },\n\n async login(ctx: Koa.Context) {\n const {\n body: { password },\n } = ctx.request;\n\n const { password: hash } = (await strapi\n .store({ type: 'plugin', name: 'documentation', key: 'config' })\n .get()) as { password: string };\n\n const isValid = await bcrypt.compare(password, hash);\n\n let querystring = '?error=password';\n\n if (isValid && ctx.session) {\n ctx.session.documentation = {\n logged: true,\n };\n\n querystring = '';\n }\n\n ctx.redirect(`${strapi.config.server.url}/documentation${querystring}`);\n },\n\n async regenerateDoc(ctx: Koa.Context) {\n const { version } = ctx.request.body;\n\n const service = getService('documentation');\n\n const documentationVersions = service.getDocumentationVersions().map((el) => el.version);\n\n if (_.isEmpty(version)) {\n return ctx.badRequest('Please provide a version.');\n }\n\n if (!documentationVersions.includes(version)) {\n return ctx.badRequest('The version you are trying to generate does not exist.');\n }\n\n try {\n strapi.reload.isWatching = false;\n await service.generateFullDoc(version);\n ctx.send({ ok: true });\n } finally {\n strapi.reload.isWatching = true;\n }\n },\n\n async deleteDoc(ctx: Koa.Context) {\n const { version } = ctx.params;\n\n const service = getService('documentation');\n\n const documentationVersions = service.getDocumentationVersions().map((el) => el.version);\n\n if (_.isEmpty(version)) {\n return ctx.badRequest('Please provide a version.');\n }\n\n if (!documentationVersions.includes(version)) {\n return ctx.badRequest('The version you are trying to delete does not exist.');\n }\n\n try {\n strapi.reload.isWatching = false;\n await service.deleteDocumentation(version);\n ctx.send({ ok: true });\n } finally {\n strapi.reload.isWatching = true;\n }\n },\n\n async updateSettings(ctx: Koa.Context) {\n const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' });\n\n const data = await validation.validateSettings(ctx.request.body);\n\n const config: Config = {\n restrictedAccess: Boolean(data.restrictedAccess),\n };\n\n if (data.password) {\n config.password = await bcrypt.hash(data.password, 10);\n }\n\n await pluginStore.set({ key: 'config', value: config });\n\n return ctx.send({ ok: true });\n },\n};\n"],"names":["validation","validateSettings","validateYupSchema","yup","object","shape","restrictedAccess","boolean","password","string","min","matches","when","value","initSchema","required","getInfos","ctx","docService","getService","docVersions","getDocumentationVersions","documentationAccess","getDocumentationAccess","send","currentVersion","getDocumentationVersion","prefix","err","strapi","log","error","badRequest","index","next","major","minor","patch","params","version","openAPISpecsPath","path","join","dirs","app","extensions","documentation","fs","readFileSync","layout","default","filledLayout","_","template","backendUrl","config","server","url","spec","JSON","stringify","parse","layoutPath","resolve","ensureFile","writeFile","basename","staticFolder","koaStatic","e","loginView","cheerio","require","query","toString","actionUrl","$","load","text","isEmpty","html","login","body","request","hash","store","type","name","key","get","isValid","bcrypt","compare","querystring","session","logged","redirect","regenerateDoc","service","documentationVersions","map","el","includes","reload","isWatching","generateFullDoc","ok","deleteDoc","deleteDocumentation","updateSettings","pluginStore","data","Boolean","set"],"mappings":";;;;;;;;;;;;AAaA,MAAMA,UAAa,GAAA;AACjBC,IAAAA,gBAAAA,EAAkBC,uBAChBC,CAAAA,SAAAA,CAAIC,MAAM,EAAA,CAAGC,KAAK,CAAC;AACjBC,QAAAA,gBAAAA,EAAkBH,UAAII,OAAO,EAAA;QAC7BC,QAAUL,EAAAA,SAAAA,CACPM,MAAM,EACNC,CAAAA,GAAG,CAAC,CACJC,CAAAA,CAAAA,OAAO,CAAC,OAAA,EAAS,uDACjB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,EAAE;YACjB+C,MAAO/C,CAAAA,QAAQ,GAAG,MAAMmF,MAAAA,CAAOP,IAAI,CAAC2B,IAAAA,CAAKvG,QAAQ,EAAE,EAAA,CAAA;AACrD;QAEA,MAAMsG,WAAAA,CAAYG,GAAG,CAAC;YAAEzB,GAAK,EAAA,QAAA;YAAU3E,KAAO0C,EAAAA;AAAO,SAAA,CAAA;QAErD,OAAOtC,GAAAA,CAAIO,IAAI,CAAC;YAAEkF,EAAI,EAAA;AAAK,SAAA,CAAA;AAC7B;AACF,CAAE;;;;"}
|
|
1
|
+
{"version":3,"file":"documentation.js","sources":["../../../server/src/controllers/documentation.ts"],"sourcesContent":["import path from 'path';\nimport bcrypt from 'bcryptjs';\nimport fs from 'fs-extra';\nimport _ from 'lodash';\nimport koaStatic from 'koa-static';\nimport { yup, validateYupSchema } from '@strapi/utils';\n\nimport type Koa from 'koa';\nimport type {} from 'koa-body';\n\nimport { getService } from '../utils';\nimport type { Config } from '../types';\n\nconst validation = {\n validateSettings: validateYupSchema(\n yup.object().shape({\n restrictedAccess: yup.boolean(),\n password: yup\n .string()\n .min(8)\n .matches(/[a-z]/, '${path} must contain at least one lowercase character')\n .matches(/[A-Z]/, '${path} must contain at least one uppercase character')\n .matches(/\\d/, '${path} must contain at least one number')\n .when('restrictedAccess', (value, initSchema) => {\n return value ? initSchema.required('password is required') : initSchema;\n }),\n })\n ),\n};\n\nexport default {\n async getInfos(ctx: Koa.Context) {\n try {\n const docService = getService('documentation');\n const docVersions = docService.getDocumentationVersions();\n const documentationAccess = await docService.getDocumentationAccess();\n\n ctx.send({\n docVersions,\n currentVersion: docService.getDocumentationVersion(),\n prefix: '/documentation',\n documentationAccess,\n });\n } catch (err) {\n strapi.log.error(err);\n ctx.badRequest();\n }\n },\n\n async index(ctx: Koa.Context, next: Koa.Next) {\n try {\n /**\n * We don't expose the specs using koa-static or something else due to security reasons.\n * That's why, we need to read the file localy and send the specs through it when we serve the Swagger UI.\n */\n const { major, minor, patch } = ctx.params;\n const version =\n major && minor && patch\n ? `${major}.${minor}.${patch}`\n : getService('documentation').getDocumentationVersion();\n\n const openAPISpecsPath = path.join(\n strapi.dirs.app.extensions,\n 'documentation',\n 'documentation',\n version,\n 'full_documentation.json'\n );\n\n try {\n const documentation = fs.readFileSync(openAPISpecsPath, 'utf8');\n\n const layout = (await import('../public/index.html')).default;\n\n const filledLayout = _.template(layout)({\n backendUrl: strapi.config.server.url,\n spec: JSON.stringify(JSON.parse(documentation)),\n });\n\n try {\n const layoutPath = path.resolve(\n strapi.dirs.app.extensions,\n 'documentation',\n 'public',\n 'index.html'\n );\n await fs.ensureFile(layoutPath);\n await fs.writeFile(layoutPath, filledLayout);\n\n // Serve the file.\n ctx.url = path.basename(`${ctx.url}/index.html`);\n\n try {\n const staticFolder = path.resolve(\n strapi.dirs.app.extensions,\n 'documentation',\n 'public'\n );\n return koaStatic(staticFolder)(ctx, next);\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n },\n\n async loginView(ctx: Koa.Context, next: Koa.Next) {\n // lazy require cheerio\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const cheerio = require('cheerio');\n\n const { error } = ctx.query;\n\n try {\n const layout = (await import('../public/login.html')).default;\n\n const filledLayout = _.template(layout.toString())({\n actionUrl: `${strapi.config.server.url}/documentation/login`,\n });\n\n const $ = cheerio.load(filledLayout);\n\n $('.error').text(_.isEmpty(error) ? '' : 'Wrong password...');\n\n try {\n const layoutPath = path.resolve(\n strapi.dirs.app.extensions,\n 'documentation',\n 'public',\n 'login.html'\n );\n await fs.ensureFile(layoutPath);\n await fs.writeFile(layoutPath, $.html());\n\n ctx.url = path.basename(`${ctx.url}/login.html`);\n\n try {\n const staticFolder = path.resolve(strapi.dirs.app.extensions, 'documentation', 'public');\n return koaStatic(staticFolder)(ctx, next);\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n },\n\n async login(ctx: Koa.Context) {\n const {\n body: { password },\n } = ctx.request;\n\n const { password: hash } = (await strapi\n .store({ type: 'plugin', name: 'documentation', key: 'config' })\n .get()) as { password: string };\n\n const isValid = await bcrypt.compare(password, hash);\n\n let querystring = '?error=password';\n\n if (isValid && ctx.session) {\n ctx.session.documentation = {\n logged: true,\n };\n\n querystring = '';\n }\n\n ctx.redirect(`${strapi.config.server.url}/documentation${querystring}`);\n },\n\n async regenerateDoc(ctx: Koa.Context) {\n const { version } = ctx.request.body;\n\n const service = getService('documentation');\n\n const documentationVersions = service.getDocumentationVersions().map((el) => el.version);\n\n if (_.isEmpty(version)) {\n return ctx.badRequest('Please provide a version.');\n }\n\n if (!documentationVersions.includes(version)) {\n return ctx.badRequest('The version you are trying to generate does not exist.');\n }\n\n try {\n strapi.reload.isWatching = false;\n await service.generateFullDoc(version);\n ctx.send({ ok: true });\n } finally {\n strapi.reload.isWatching = true;\n }\n },\n\n async deleteDoc(ctx: Koa.Context) {\n const { version } = ctx.params;\n\n const service = getService('documentation');\n\n const documentationVersions = service.getDocumentationVersions().map((el) => el.version);\n\n if (_.isEmpty(version)) {\n return ctx.badRequest('Please provide a version.');\n }\n\n if (!documentationVersions.includes(version)) {\n return ctx.badRequest('The version you are trying to delete does not exist.');\n }\n\n try {\n strapi.reload.isWatching = false;\n await service.deleteDocumentation(version);\n ctx.send({ ok: true });\n } finally {\n strapi.reload.isWatching = true;\n }\n },\n\n async updateSettings(ctx: Koa.Context) {\n const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' });\n\n const data = await validation.validateSettings(ctx.request.body);\n\n const config: Config = {\n restrictedAccess: Boolean(data.restrictedAccess),\n };\n\n if (data.password) {\n config.password = await bcrypt.hash(data.password, 10);\n }\n\n await pluginStore.set({ key: 'config', value: config });\n\n return ctx.send({ ok: true });\n },\n};\n"],"names":["validation","validateSettings","validateYupSchema","yup","object","shape","restrictedAccess","boolean","password","string","min","matches","when","value","initSchema","required","getInfos","ctx","docService","getService","docVersions","getDocumentationVersions","documentationAccess","getDocumentationAccess","send","currentVersion","getDocumentationVersion","prefix","err","strapi","log","error","badRequest","index","next","major","minor","patch","params","version","openAPISpecsPath","path","join","dirs","app","extensions","documentation","fs","readFileSync","layout","default","filledLayout","_","template","backendUrl","config","server","url","spec","JSON","stringify","parse","layoutPath","resolve","ensureFile","writeFile","basename","staticFolder","koaStatic","e","loginView","cheerio","require","query","toString","actionUrl","$","load","text","isEmpty","html","login","body","request","hash","store","type","name","key","get","isValid","bcrypt","compare","querystring","session","logged","redirect","regenerateDoc","service","documentationVersions","map","el","includes","reload","isWatching","generateFullDoc","ok","deleteDoc","deleteDocumentation","updateSettings","pluginStore","data","Boolean","set"],"mappings":";;;;;;;;;;;;AAaA,MAAMA,UAAAA,GAAa;AACjBC,IAAAA,gBAAAA,EAAkBC,uBAAAA,CAChBC,SAAAA,CAAIC,MAAM,EAAA,CAAGC,KAAK,CAAC;AACjBC,QAAAA,gBAAAA,EAAkBH,UAAII,OAAO,EAAA;QAC7BC,QAAAA,EAAUL,SAAAA,CACPM,MAAM,EAAA,CACNC,GAAG,CAAC,CAAA,CAAA,CACJC,OAAO,CAAC,OAAA,EAAS,uDAAA,CAAA,CACjBA,OAAO,CAAC,OAAA,EAAS,uDAAA,CAAA,CACjBA,OAAO,CAAC,IAAA,EAAM,4CACdC,IAAI,CAAC,kBAAA,EAAoB,CAACC,KAAAA,EAAOC,UAAAA,GAAAA;AAChC,YAAA,OAAOD,KAAAA,GAAQC,UAAAA,CAAWC,QAAQ,CAAC,sBAAA,CAAA,GAA0BD,UAAAA;AAC/D,QAAA,CAAA;AACJ,KAAA,CAAA;AAEJ,CAAA;AAEA,oBAAe;AACb,IAAA,MAAME,UAASC,GAAgB,EAAA;QAC7B,IAAI;AACF,YAAA,MAAMC,aAAaC,kBAAAA,CAAW,eAAA,CAAA;YAC9B,MAAMC,WAAAA,G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A,EAAK,QAAA;YAAU3E,KAAAA,EAAO0C;AAAO,SAAA,CAAA;QAErD,OAAOtC,GAAAA,CAAIO,IAAI,CAAC;YAAEkF,EAAAA,EAAI;AAAK,SAAA,CAAA;AAC7B,IAAA;AACF,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentation.mjs","sources":["../../../server/src/controllers/documentation.ts"],"sourcesContent":["import path from 'path';\nimport bcrypt from 'bcryptjs';\nimport fs from 'fs-extra';\nimport _ from 'lodash';\nimport koaStatic from 'koa-static';\nimport { yup, validateYupSchema } from '@strapi/utils';\n\nimport type Koa from 'koa';\nimport type {} from 'koa-body';\n\nimport { getService } from '../utils';\nimport type { Config } from '../types';\n\nconst validation = {\n validateSettings: validateYupSchema(\n yup.object().shape({\n restrictedAccess: yup.boolean(),\n password: yup\n .string()\n .min(8)\n .matches(/[a-z]/, '${path} must contain at least one lowercase character')\n .matches(/[A-Z]/, '${path} must contain at least one uppercase character')\n .matches(/\\d/, '${path} must contain at least one number')\n .when('restrictedAccess', (value, initSchema) => {\n return value ? initSchema.required('password is required') : initSchema;\n }),\n })\n ),\n};\n\nexport default {\n async getInfos(ctx: Koa.Context) {\n try {\n const docService = getService('documentation');\n const docVersions = docService.getDocumentationVersions();\n const documentationAccess = await docService.getDocumentationAccess();\n\n ctx.send({\n docVersions,\n currentVersion: docService.getDocumentationVersion(),\n prefix: '/documentation',\n documentationAccess,\n });\n } catch (err) {\n strapi.log.error(err);\n ctx.badRequest();\n }\n },\n\n async index(ctx: Koa.Context, next: Koa.Next) {\n try {\n /**\n * We don't expose the specs using koa-static or something else due to security reasons.\n * That's why, we need to read the file localy and send the specs through it when we serve the Swagger UI.\n */\n const { major, minor, patch } = ctx.params;\n const version =\n major && minor && patch\n ? `${major}.${minor}.${patch}`\n : getService('documentation').getDocumentationVersion();\n\n const openAPISpecsPath = path.join(\n strapi.dirs.app.extensions,\n 'documentation',\n 'documentation',\n version,\n 'full_documentation.json'\n );\n\n try {\n const documentation = fs.readFileSync(openAPISpecsPath, 'utf8');\n\n const layout = (await import('../public/index.html')).default;\n\n const filledLayout = _.template(layout)({\n backendUrl: strapi.config.server.url,\n spec: JSON.stringify(JSON.parse(documentation)),\n });\n\n try {\n const layoutPath = path.resolve(\n strapi.dirs.app.extensions,\n 'documentation',\n 'public',\n 'index.html'\n );\n await fs.ensureFile(layoutPath);\n await fs.writeFile(layoutPath, filledLayout);\n\n // Serve the file.\n ctx.url = path.basename(`${ctx.url}/index.html`);\n\n try {\n const staticFolder = path.resolve(\n strapi.dirs.app.extensions,\n 'documentation',\n 'public'\n );\n return koaStatic(staticFolder)(ctx, next);\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n },\n\n async loginView(ctx: Koa.Context, next: Koa.Next) {\n // lazy require cheerio\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const cheerio = require('cheerio');\n\n const { error } = ctx.query;\n\n try {\n const layout = (await import('../public/login.html')).default;\n\n const filledLayout = _.template(layout.toString())({\n actionUrl: `${strapi.config.server.url}/documentation/login`,\n });\n\n const $ = cheerio.load(filledLayout);\n\n $('.error').text(_.isEmpty(error) ? '' : 'Wrong password...');\n\n try {\n const layoutPath = path.resolve(\n strapi.dirs.app.extensions,\n 'documentation',\n 'public',\n 'login.html'\n );\n await fs.ensureFile(layoutPath);\n await fs.writeFile(layoutPath, $.html());\n\n ctx.url = path.basename(`${ctx.url}/login.html`);\n\n try {\n const staticFolder = path.resolve(strapi.dirs.app.extensions, 'documentation', 'public');\n return koaStatic(staticFolder)(ctx, next);\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n },\n\n async login(ctx: Koa.Context) {\n const {\n body: { password },\n } = ctx.request;\n\n const { password: hash } = (await strapi\n .store({ type: 'plugin', name: 'documentation', key: 'config' })\n .get()) as { password: string };\n\n const isValid = await bcrypt.compare(password, hash);\n\n let querystring = '?error=password';\n\n if (isValid && ctx.session) {\n ctx.session.documentation = {\n logged: true,\n };\n\n querystring = '';\n }\n\n ctx.redirect(`${strapi.config.server.url}/documentation${querystring}`);\n },\n\n async regenerateDoc(ctx: Koa.Context) {\n const { version } = ctx.request.body;\n\n const service = getService('documentation');\n\n const documentationVersions = service.getDocumentationVersions().map((el) => el.version);\n\n if (_.isEmpty(version)) {\n return ctx.badRequest('Please provide a version.');\n }\n\n if (!documentationVersions.includes(version)) {\n return ctx.badRequest('The version you are trying to generate does not exist.');\n }\n\n try {\n strapi.reload.isWatching = false;\n await service.generateFullDoc(version);\n ctx.send({ ok: true });\n } finally {\n strapi.reload.isWatching = true;\n }\n },\n\n async deleteDoc(ctx: Koa.Context) {\n const { version } = ctx.params;\n\n const service = getService('documentation');\n\n const documentationVersions = service.getDocumentationVersions().map((el) => el.version);\n\n if (_.isEmpty(version)) {\n return ctx.badRequest('Please provide a version.');\n }\n\n if (!documentationVersions.includes(version)) {\n return ctx.badRequest('The version you are trying to delete does not exist.');\n }\n\n try {\n strapi.reload.isWatching = false;\n await service.deleteDocumentation(version);\n ctx.send({ ok: true });\n } finally {\n strapi.reload.isWatching = true;\n }\n },\n\n async updateSettings(ctx: Koa.Context) {\n const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' });\n\n const data = await validation.validateSettings(ctx.request.body);\n\n const config: Config = {\n restrictedAccess: Boolean(data.restrictedAccess),\n };\n\n if (data.password) {\n config.password = await bcrypt.hash(data.password, 10);\n }\n\n await pluginStore.set({ key: 'config', value: config });\n\n return ctx.send({ ok: true });\n },\n};\n"],"names":["validation","validateSettings","validateYupSchema","yup","object","shape","restrictedAccess","boolean","password","string","min","matches","when","value","initSchema","required","getInfos","ctx","docService","getService","docVersions","getDocumentationVersions","documentationAccess","getDocumentationAccess","send","currentVersion","getDocumentationVersion","prefix","err","strapi","log","error","badRequest","index","next","major","minor","patch","params","version","openAPISpecsPath","path","join","dirs","app","extensions","documentation","fs","readFileSync","layout","default","filledLayout","_","template","backendUrl","config","server","url","spec","JSON","stringify","parse","layoutPath","resolve","ensureFile","writeFile","basename","staticFolder","koaStatic","e","loginView","cheerio","require","query","toString","actionUrl","$","load","text","isEmpty","html","login","body","request","hash","store","type","name","key","get","isValid","bcrypt","compare","querystring","session","logged","redirect","regenerateDoc","service","documentationVersions","map","el","includes","reload","isWatching","generateFullDoc","ok","deleteDoc","deleteDocumentation","updateSettings","pluginStore","data","Boolean","set"],"mappings":";;;;;;;;AAaA,MAAMA,UAAa,GAAA;AACjBC,IAAAA,gBAAAA,EAAkBC,iBAChBC,CAAAA,GAAAA,CAAIC,MAAM,EAAA,CAAGC,KAAK,CAAC;AACjBC,QAAAA,gBAAAA,EAAkBH,IAAII,OAAO,EAAA;QAC7BC,QAAUL,EAAAA,GAAAA,CACPM,MAAM,EACNC,CAAAA,GAAG,CAAC,CACJC,CAAAA,CAAAA,OAAO,CAAC,OAAA,EAAS,uDACjBA,CAAAA,CAAAA,OAAO,CAAC,OAAS,EAAA,uDAAA,CAAA,CACjBA,OAAO,CAAC,IAAA,EAAM,4CACdC,IAAI,CAAC,kBAAoB,EAAA,CAACC,KAAOC,EAAAA,UAAAA,GAAAA;AAChC,YAAA,OAAOD,KAAQC,GAAAA,UAAAA,CAAWC,QAAQ,CAAC,sBAA0BD,CAAAA,GAAAA,UAAAA;AAC/D,SAAA;AACJ,KAAA,CAAA;AAEJ,CAAA;AAEA,oBAAe;AACb,IAAA,MAAME,UAASC,GAAgB,EAAA;QAC7B,IAAI;AACF,YAAA,MAAMC,aAAaC,UAAW,CAAA,eAAA,CAAA;YAC9B,MAAMC,WAAAA,GAAcF,WAAWG,wBAAwB,EAAA;YACvD,MAAMC,mBAAAA,GAAsB,MAAMJ,UAAAA,CAAWK,sBAAsB,EAAA;AAEnEN,YAAAA,GAAAA,CAAIO,IAAI,CAAC;AACPJ,gBAAAA,WAAAA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,KAAA;YAC3B,MAAMN,OAAAA,CAAQU,mBAAmB,CAACrE,OAAAA,CAAAA;AAClCtB,YAAAA,GAAAA,CAAIO,IAAI,CAAC;gBAAEkF,EAAI,EAAA;AAAK,aAAA,CAAA;SACZ,QAAA;YACR7E,MAAO0E,CAAAA,MAAM,CAACC,UAAU,GAAG,IAAA;AAC7B;AACF,KAAA;AAEA,IAAA,MAAMK,gBAAe5F,GAAgB,EAAA;QACnC,MAAM6F,WAAAA,GAAcjF,MAAOwD,CAAAA,KAAK,CAAC;YAAEC,IAAM,EAAA,QAAA;YAAUC,IAAM,EAAA;AAAgB,SAAA,CAAA;QAEzE,MAAMwB,IAAAA,GAAO,MAAM/G,UAAWC,CAAAA,gBAAgB,CAACgB,GAAIkE,CAAAA,OAAO,CAACD,IAAI,CAAA;AAE/D,QAAA,MAAM3B,MAAiB,GAAA;YACrBjD,gBAAkB0G,EAAAA,OAAAA,CAAQD,KAAKzG,gBAAgB;AACjD,SAAA;QAEA,IAAIyG,IAAAA,CAAKvG,QAAQ,EAAE;YACjB+C,MAAO/C,CAAAA,QAAQ,GAAG,MAAMmF,MAAAA,CAAOP,IAAI,CAAC2B,IAAAA,CAAKvG,QAAQ,EAAE,EAAA,CAAA;AACrD;QAEA,MAAMsG,WAAAA,CAAYG,GAAG,CAAC;YAAEzB,GAAK,EAAA,QAAA;YAAU3E,KAAO0C,EAAAA;AAAO,SAAA,CAAA;QAErD,OAAOtC,GAAAA,CAAIO,IAAI,CAAC;YAAEkF,EAAI,EAAA;AAAK,SAAA,CAAA;AAC7B;AACF,CAAE;;;;"}
|
|
1
|
+
{"version":3,"file":"documentation.mjs","sources":["../../../server/src/controllers/documentation.ts"],"sourcesContent":["import path from 'path';\nimport bcrypt from 'bcryptjs';\nimport fs from 'fs-extra';\nimport _ from 'lodash';\nimport koaStatic from 'koa-static';\nimport { yup, validateYupSchema } from '@strapi/utils';\n\nimport type Koa from 'koa';\nimport type {} from 'koa-body';\n\nimport { getService } from '../utils';\nimport type { Config } from '../types';\n\nconst validation = {\n validateSettings: validateYupSchema(\n yup.object().shape({\n restrictedAccess: yup.boolean(),\n password: yup\n .string()\n .min(8)\n .matches(/[a-z]/, '${path} must contain at least one lowercase character')\n .matches(/[A-Z]/, '${path} must contain at least one uppercase character')\n .matches(/\\d/, '${path} must contain at least one number')\n .when('restrictedAccess', (value, initSchema) => {\n return value ? initSchema.required('password is required') : initSchema;\n }),\n })\n ),\n};\n\nexport default {\n async getInfos(ctx: Koa.Context) {\n try {\n const docService = getService('documentation');\n const docVersions = docService.getDocumentationVersions();\n const documentationAccess = await docService.getDocumentationAccess();\n\n ctx.send({\n docVersions,\n currentVersion: docService.getDocumentationVersion(),\n prefix: '/documentation',\n documentationAccess,\n });\n } catch (err) {\n strapi.log.error(err);\n ctx.badRequest();\n }\n },\n\n async index(ctx: Koa.Context, next: Koa.Next) {\n try {\n /**\n * We don't expose the specs using koa-static or something else due to security reasons.\n * That's why, we need to read the file localy and send the specs through it when we serve the Swagger UI.\n */\n const { major, minor, patch } = ctx.params;\n const version =\n major && minor && patch\n ? `${major}.${minor}.${patch}`\n : getService('documentation').getDocumentationVersion();\n\n const openAPISpecsPath = path.join(\n strapi.dirs.app.extensions,\n 'documentation',\n 'documentation',\n version,\n 'full_documentation.json'\n );\n\n try {\n const documentation = fs.readFileSync(openAPISpecsPath, 'utf8');\n\n const layout = (await import('../public/index.html')).default;\n\n const filledLayout = _.template(layout)({\n backendUrl: strapi.config.server.url,\n spec: JSON.stringify(JSON.parse(documentation)),\n });\n\n try {\n const layoutPath = path.resolve(\n strapi.dirs.app.extensions,\n 'documentation',\n 'public',\n 'index.html'\n );\n await fs.ensureFile(layoutPath);\n await fs.writeFile(layoutPath, filledLayout);\n\n // Serve the file.\n ctx.url = path.basename(`${ctx.url}/index.html`);\n\n try {\n const staticFolder = path.resolve(\n strapi.dirs.app.extensions,\n 'documentation',\n 'public'\n );\n return koaStatic(staticFolder)(ctx, next);\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n },\n\n async loginView(ctx: Koa.Context, next: Koa.Next) {\n // lazy require cheerio\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const cheerio = require('cheerio');\n\n const { error } = ctx.query;\n\n try {\n const layout = (await import('../public/login.html')).default;\n\n const filledLayout = _.template(layout.toString())({\n actionUrl: `${strapi.config.server.url}/documentation/login`,\n });\n\n const $ = cheerio.load(filledLayout);\n\n $('.error').text(_.isEmpty(error) ? '' : 'Wrong password...');\n\n try {\n const layoutPath = path.resolve(\n strapi.dirs.app.extensions,\n 'documentation',\n 'public',\n 'login.html'\n );\n await fs.ensureFile(layoutPath);\n await fs.writeFile(layoutPath, $.html());\n\n ctx.url = path.basename(`${ctx.url}/login.html`);\n\n try {\n const staticFolder = path.resolve(strapi.dirs.app.extensions, 'documentation', 'public');\n return koaStatic(staticFolder)(ctx, next);\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n } catch (e) {\n strapi.log.error(e);\n }\n },\n\n async login(ctx: Koa.Context) {\n const {\n body: { password },\n } = ctx.request;\n\n const { password: hash } = (await strapi\n .store({ type: 'plugin', name: 'documentation', key: 'config' })\n .get()) as { password: string };\n\n const isValid = await bcrypt.compare(password, hash);\n\n let querystring = '?error=password';\n\n if (isValid && ctx.session) {\n ctx.session.documentation = {\n logged: true,\n };\n\n querystring = '';\n }\n\n ctx.redirect(`${strapi.config.server.url}/documentation${querystring}`);\n },\n\n async regenerateDoc(ctx: Koa.Context) {\n const { version } = ctx.request.body;\n\n const service = getService('documentation');\n\n const documentationVersions = service.getDocumentationVersions().map((el) => el.version);\n\n if (_.isEmpty(version)) {\n return ctx.badRequest('Please provide a version.');\n }\n\n if (!documentationVersions.includes(version)) {\n return ctx.badRequest('The version you are trying to generate does not exist.');\n }\n\n try {\n strapi.reload.isWatching = false;\n await service.generateFullDoc(version);\n ctx.send({ ok: true });\n } finally {\n strapi.reload.isWatching = true;\n }\n },\n\n async deleteDoc(ctx: Koa.Context) {\n const { version } = ctx.params;\n\n const service = getService('documentation');\n\n const documentationVersions = service.getDocumentationVersions().map((el) => el.version);\n\n if (_.isEmpty(version)) {\n return ctx.badRequest('Please provide a version.');\n }\n\n if (!documentationVersions.includes(version)) {\n return ctx.badRequest('The version you are trying to delete does not exist.');\n }\n\n try {\n strapi.reload.isWatching = false;\n await service.deleteDocumentation(version);\n ctx.send({ ok: true });\n } finally {\n strapi.reload.isWatching = true;\n }\n },\n\n async updateSettings(ctx: Koa.Context) {\n const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' });\n\n const data = await validation.validateSettings(ctx.request.body);\n\n const config: Config = {\n restrictedAccess: Boolean(data.restrictedAccess),\n };\n\n if (data.password) {\n config.password = await bcrypt.hash(data.password, 10);\n }\n\n await pluginStore.set({ key: 'config', value: config });\n\n return ctx.send({ ok: true });\n },\n};\n"],"names":["validation","validateSettings","validateYupSchema","yup","object","shape","restrictedAccess","boolean","password","string","min","matches","when","value","initSchema","required","getInfos","ctx","docService","getService","docVersions","getDocumentationVersions","documentationAccess","getDocumentationAccess","send","currentVersion","getDocumentationVersion","prefix","err","strapi","log","error","badRequest","index","next","major","minor","patch","params","version","openAPISpecsPath","path","join","dirs","app","extensions","documentation","fs","readFileSync","layout","default","filledLayout","_","template","backendUrl","config","server","url","spec","JSON","stringify","parse","layoutPath","resolve","ensureFile","writeFile","basename","staticFolder","koaStatic","e","loginView","cheerio","require","query","toString","actionUrl","$","load","text","isEmpty","html","login","body","request","hash","store","type","name","key","get","isValid","bcrypt","compare","querystring","session","logged","redirect","regenerateDoc","service","documentationVersions","map","el","includes","reload","isWatching","generateFullDoc","ok","deleteDoc","deleteDocumentation","updateSettings","pluginStore","data","Boolean","set"],"mappings":";;;;;;;;AAaA,MAAMA,UAAAA,GAAa;AACjBC,IAAAA,gBAAAA,EAAkBC,iBAAAA,CAChBC,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C7B,QAAA;AACF,IAAA,CAAA;AAEA,IAAA,MAAMK,gBAAe5F,GAAgB,EAAA;QACnC,MAAM6F,WAAAA,GAAcjF,MAAAA,CAAOwD,KAAK,CAAC;YAAEC,IAAAA,EAAM,QAAA;YAAUC,IAAAA,EAAM;AAAgB,SAAA,CAAA;QAEzE,MAAMwB,IAAAA,GAAO,MAAM/G,UAAAA,CAAWC,gBAAgB,CAACgB,GAAAA,CAAIkE,OAAO,CAACD,IAAI,CAAA;AAE/D,QAAA,MAAM3B,MAAAA,GAAiB;YACrBjD,gBAAAA,EAAkB0G,OAAAA,CAAQD,KAAKzG,gBAAgB;AACjD,SAAA;QAEA,IAAIyG,IAAAA,CAAKvG,QAAQ,EAAE;YACjB+C,MAAAA,CAAO/C,QAAQ,GAAG,MAAMmF,MAAAA,CAAOP,IAAI,CAAC2B,IAAAA,CAAKvG,QAAQ,EAAE,EAAA,CAAA;AACrD,QAAA;QAEA,MAAMsG,WAAAA,CAAYG,GAAG,CAAC;YAAEzB,GAAAA,EAAK,QAAA;YAAU3E,KAAAA,EAAO0C;AAAO,SAAA,CAAA;QAErD,OAAOtC,GAAAA,CAAIO,IAAI,CAAC;YAAEkF,EAAAA,EAAI;AAAK,SAAA,CAAA;AAC7B,IAAA;AACF,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../server/src/controllers/index.ts"],"sourcesContent":["import documentation from './documentation';\n\nexport default {\n documentation,\n};\n"],"names":["documentation"],"mappings":";;;;AAEA,kBAAe;AACbA,IAAAA;AACF,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../server/src/controllers/index.ts"],"sourcesContent":["import documentation from './documentation';\n\nexport default {\n documentation,\n};\n"],"names":["documentation"],"mappings":";;;;AAEA,kBAAe;AACbA,IAAAA;AACF,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../server/src/controllers/index.ts"],"sourcesContent":["import documentation from './documentation';\n\nexport default {\n documentation,\n};\n"],"names":["documentation"],"mappings":";;AAEA,kBAAe;AACbA,IAAAA;AACF,
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../server/src/controllers/index.ts"],"sourcesContent":["import documentation from './documentation';\n\nexport default {\n documentation,\n};\n"],"names":["documentation"],"mappings":";;AAEA,kBAAe;AACbA,IAAAA;AACF,CAAA;;;;"}
|
package/dist/server/index.js
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
var bootstrap = require('./bootstrap.js');
|
|
4
4
|
var register = require('./register.js');
|
|
5
|
-
var index$
|
|
6
|
-
var index$
|
|
7
|
-
var index$
|
|
8
|
-
var index$
|
|
5
|
+
var index$1 = require('./services/index.js');
|
|
6
|
+
var index$3 = require('./routes/index.js');
|
|
7
|
+
var index$2 = require('./controllers/index.js');
|
|
8
|
+
var index$4 = require('./config/index.js');
|
|
9
9
|
|
|
10
10
|
var index = {
|
|
11
11
|
bootstrap: bootstrap.bootstrap,
|
|
12
|
-
config: index$
|
|
13
|
-
routes: index$
|
|
14
|
-
controllers: index$
|
|
12
|
+
config: index$4.config,
|
|
13
|
+
routes: index$3,
|
|
14
|
+
controllers: index$2,
|
|
15
15
|
register: register.register,
|
|
16
|
-
services: index$
|
|
16
|
+
services: index$1
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
module.exports = index;
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../server/src/index.ts"],"sourcesContent":["import { bootstrap } from './bootstrap';\nimport { register } from './register';\nimport services from './services';\nimport routes from './routes';\nimport controllers from './controllers';\nimport { config } from './config';\n\nexport default {\n bootstrap,\n config,\n routes,\n controllers,\n register,\n services,\n};\n"],"names":["bootstrap","config","routes","controllers","register","services"],"mappings":";;;;;;;;;AAOA,YAAe;AACbA,eAAAA,mBAAAA;AACAC,YAAAA,cAAAA;AACAC,YAAAA,OAAAA;AACAC,iBAAAA,OAAAA;AACAC,cAAAA,iBAAAA;AACAC,cAAAA;AACF,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../server/src/index.ts"],"sourcesContent":["import { bootstrap } from './bootstrap';\nimport { register } from './register';\nimport services from './services';\nimport routes from './routes';\nimport controllers from './controllers';\nimport { config } from './config';\n\nexport default {\n bootstrap,\n config,\n routes,\n controllers,\n register,\n services,\n};\n"],"names":["bootstrap","config","routes","controllers","register","services"],"mappings":";;;;;;;;;AAOA,YAAe;AACbA,eAAAA,mBAAAA;AACAC,YAAAA,cAAAA;AACAC,YAAAA,OAAAA;AACAC,iBAAAA,OAAAA;AACAC,cAAAA,iBAAAA;AACAC,cAAAA;AACF,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../server/src/index.ts"],"sourcesContent":["import { bootstrap } from './bootstrap';\nimport { register } from './register';\nimport services from './services';\nimport routes from './routes';\nimport controllers from './controllers';\nimport { config } from './config';\n\nexport default {\n bootstrap,\n config,\n routes,\n controllers,\n register,\n services,\n};\n"],"names":["bootstrap","config","routes","controllers","register","services"],"mappings":";;;;;;;AAOA,YAAe;AACbA,IAAAA,SAAAA;AACAC,IAAAA,MAAAA;AACAC,IAAAA,MAAAA;AACAC,IAAAA,WAAAA;AACAC,IAAAA,QAAAA;AACAC,IAAAA;AACF,
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../server/src/index.ts"],"sourcesContent":["import { bootstrap } from './bootstrap';\nimport { register } from './register';\nimport services from './services';\nimport routes from './routes';\nimport controllers from './controllers';\nimport { config } from './config';\n\nexport default {\n bootstrap,\n config,\n routes,\n controllers,\n register,\n services,\n};\n"],"names":["bootstrap","config","routes","controllers","register","services"],"mappings":";;;;;;;AAOA,YAAe;AACbA,IAAAA,SAAAA;AACAC,IAAAA,MAAAA;AACAC,IAAAA,MAAAA;AACAC,IAAAA,WAAAA;AACAC,IAAAA,QAAAA;AACAC,IAAAA;AACF,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentation.js","sources":["../../../server/src/middlewares/documentation.ts"],"sourcesContent":["import path from 'path';\nimport koaStatic from 'koa-static';\nimport swaggerUi from 'swagger-ui-dist';\n\nimport type { Core } from '@strapi/types';\n\nexport const addDocumentMiddlewares = async ({ strapi }: { strapi: Core.Strapi }) => {\n strapi.server.routes([\n {\n method: 'GET',\n path: '/plugins/documentation/(.*)',\n async handler(ctx, next) {\n ctx.url = path.basename(ctx.url);\n\n return koaStatic(swaggerUi.getAbsoluteFSPath(), {\n maxage: 86400000,\n defer: true,\n })(ctx, next);\n },\n config: {\n auth: false,\n },\n },\n ]);\n};\n"],"names":["addDocumentMiddlewares","strapi","server","routes","method","path","handler","ctx","next","url","basename","koaStatic","swaggerUi","getAbsoluteFSPath","maxage","defer","config","auth"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"documentation.js","sources":["../../../server/src/middlewares/documentation.ts"],"sourcesContent":["import path from 'path';\nimport koaStatic from 'koa-static';\nimport swaggerUi from 'swagger-ui-dist';\n\nimport type { Core } from '@strapi/types';\n\nexport const addDocumentMiddlewares = async ({ strapi }: { strapi: Core.Strapi }) => {\n strapi.server.routes([\n {\n method: 'GET',\n path: '/plugins/documentation/(.*)',\n async handler(ctx, next) {\n ctx.url = path.basename(ctx.url);\n\n return koaStatic(swaggerUi.getAbsoluteFSPath(), {\n maxage: 86400000,\n defer: true,\n })(ctx, next);\n },\n config: {\n auth: false,\n },\n },\n ]);\n};\n"],"names":["addDocumentMiddlewares","strapi","server","routes","method","path","handler","ctx","next","url","basename","koaStatic","swaggerUi","getAbsoluteFSPath","maxage","defer","config","auth"],"mappings":";;;;;;AAMO,MAAMA,sBAAAA,GAAyB,OAAO,EAAEC,MAAM,EAA2B,GAAA;IAC9EA,MAAAA,CAAOC,MAAM,CAACC,MAAM,CAAC;AACnB,QAAA;YACEC,MAAAA,EAAQ,KAAA;YACRC,IAAAA,EAAM,6BAAA;YACN,MAAMC,OAAAA,CAAAA,CAAQC,GAAG,EAAEC,IAAI,EAAA;AACrBD,gBAAAA,GAAAA,CAAIE,GAAG,GAAGJ,IAAAA,CAAKK,QAAQ,CAACH,IAAIE,GAAG,CAAA;gBAE/B,OAAOE,SAAAA,CAAUC,SAAAA,CAAUC,iBAAiB,EAAA,EAAI;oBAC9CC,MAAAA,EAAQ,QAAA;oBACRC,KAAAA,EAAO;AACT,iBAAA,CAAA,CAAGR,GAAAA,EAAKC,IAAAA,CAAAA;AACV,YAAA,CAAA;YACAQ,MAAAA,EAAQ;gBACNC,IAAAA,EAAM;AACR;AACF;AACD,KAAA,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentation.mjs","sources":["../../../server/src/middlewares/documentation.ts"],"sourcesContent":["import path from 'path';\nimport koaStatic from 'koa-static';\nimport swaggerUi from 'swagger-ui-dist';\n\nimport type { Core } from '@strapi/types';\n\nexport const addDocumentMiddlewares = async ({ strapi }: { strapi: Core.Strapi }) => {\n strapi.server.routes([\n {\n method: 'GET',\n path: '/plugins/documentation/(.*)',\n async handler(ctx, next) {\n ctx.url = path.basename(ctx.url);\n\n return koaStatic(swaggerUi.getAbsoluteFSPath(), {\n maxage: 86400000,\n defer: true,\n })(ctx, next);\n },\n config: {\n auth: false,\n },\n },\n ]);\n};\n"],"names":["addDocumentMiddlewares","strapi","server","routes","method","path","handler","ctx","next","url","basename","koaStatic","swaggerUi","getAbsoluteFSPath","maxage","defer","config","auth"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"documentation.mjs","sources":["../../../server/src/middlewares/documentation.ts"],"sourcesContent":["import path from 'path';\nimport koaStatic from 'koa-static';\nimport swaggerUi from 'swagger-ui-dist';\n\nimport type { Core } from '@strapi/types';\n\nexport const addDocumentMiddlewares = async ({ strapi }: { strapi: Core.Strapi }) => {\n strapi.server.routes([\n {\n method: 'GET',\n path: '/plugins/documentation/(.*)',\n async handler(ctx, next) {\n ctx.url = path.basename(ctx.url);\n\n return koaStatic(swaggerUi.getAbsoluteFSPath(), {\n maxage: 86400000,\n defer: true,\n })(ctx, next);\n },\n config: {\n auth: false,\n },\n },\n ]);\n};\n"],"names":["addDocumentMiddlewares","strapi","server","routes","method","path","handler","ctx","next","url","basename","koaStatic","swaggerUi","getAbsoluteFSPath","maxage","defer","config","auth"],"mappings":";;;;AAMO,MAAMA,sBAAAA,GAAyB,OAAO,EAAEC,MAAM,EAA2B,GAAA;IAC9EA,MAAAA,CAAOC,MAAM,CAACC,MAAM,CAAC;AACnB,QAAA;YACEC,MAAAA,EAAQ,KAAA;YACRC,IAAAA,EAAM,6BAAA;YACN,MAAMC,OAAAA,CAAAA,CAAQC,GAAG,EAAEC,IAAI,EAAA;AACrBD,gBAAAA,GAAAA,CAAIE,GAAG,GAAGJ,IAAAA,CAAKK,QAAQ,CAACH,IAAIE,GAAG,CAAA;gBAE/B,OAAOE,SAAAA,CAAUC,SAAAA,CAAUC,iBAAiB,EAAA,EAAI;oBAC9CC,MAAAA,EAAQ,QAAA;oBACRC,KAAAA,EAAO;AACT,iBAAA,CAAA,CAAGR,GAAAA,EAAKC,IAAAA,CAAAA;AACV,YAAA,CAAA;YACAQ,MAAAA,EAAQ;gBACNC,IAAAA,EAAM;AACR;AACF;AACD,KAAA,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restrict-access.js","sources":["../../../server/src/middlewares/restrict-access.ts"],"sourcesContent":["import type Koa from 'koa';\nimport type {} from 'koa-session';\n\nimport type { Config } from '../types';\n\nexport default async (ctx: Koa.Context, next: Koa.Next) => {\n const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' });\n\n const config = (await pluginStore.get({ key: 'config' })) as Config;\n\n if (!config.restrictedAccess) {\n return next();\n }\n\n if (!ctx.session || !ctx.session.documentation || !ctx.session.documentation.logged) {\n const querystring = ctx.querystring ? `?${ctx.querystring}` : '';\n\n return ctx.redirect(`${strapi.config.server.url}/documentation/login${querystring}`);\n }\n\n // Execute the action.\n return next();\n};\n"],"names":["ctx","next","pluginStore","strapi","store","type","name","config","get","key","restrictedAccess","session","documentation","logged","querystring","redirect","server","url"],"mappings":";;AAKA,qBAAe,CAAA,OAAOA,
|
|
1
|
+
{"version":3,"file":"restrict-access.js","sources":["../../../server/src/middlewares/restrict-access.ts"],"sourcesContent":["import type Koa from 'koa';\nimport type {} from 'koa-session';\n\nimport type { Config } from '../types';\n\nexport default async (ctx: Koa.Context, next: Koa.Next) => {\n const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' });\n\n const config = (await pluginStore.get({ key: 'config' })) as Config;\n\n if (!config.restrictedAccess) {\n return next();\n }\n\n if (!ctx.session || !ctx.session.documentation || !ctx.session.documentation.logged) {\n const querystring = ctx.querystring ? `?${ctx.querystring}` : '';\n\n return ctx.redirect(`${strapi.config.server.url}/documentation/login${querystring}`);\n }\n\n // Execute the action.\n return next();\n};\n"],"names":["ctx","next","pluginStore","strapi","store","type","name","config","get","key","restrictedAccess","session","documentation","logged","querystring","redirect","server","url"],"mappings":";;AAKA,qBAAe,CAAA,OAAOA,GAAAA,EAAkBC,IAAAA,GAAAA;IACtC,MAAMC,WAAAA,GAAcC,MAAAA,CAAOC,KAAK,CAAC;QAAEC,IAAAA,EAAM,QAAA;QAAUC,IAAAA,EAAM;AAAgB,KAAA,CAAA;AAEzE,IAAA,MAAMC,MAAAA,GAAU,MAAML,WAAAA,CAAYM,GAAG,CAAC;QAAEC,GAAAA,EAAK;AAAS,KAAA,CAAA;IAEtD,IAAI,CAACF,MAAAA,CAAOG,gBAAgB,EAAE;QAC5B,OAAOT,IAAAA,EAAAA;AACT,IAAA;AAEA,IAAA,IAAI,CAACD,GAAAA,CAAIW,OAAO,IAAI,CAACX,IAAIW,OAAO,CAACC,aAAa,IAAI,CAACZ,GAAAA,CAAIW,OAAO,CAACC,aAAa,CAACC,MAAM,EAAE;QACnF,MAAMC,WAAAA,GAAcd,GAAAA,CAAIc,WAAW,GAAG,CAAC,CAAC,EAAEd,GAAAA,CAAIc,WAAW,CAAA,CAAE,GAAG,EAAA;AAE9D,QAAA,OAAOd,GAAAA,CAAIe,QAAQ,CAAC,CAAA,EAAGZ,MAAAA,CAAOI,MAAM,CAACS,MAAM,CAACC,GAAG,CAAC,oBAAoB,EAAEH,WAAAA,CAAAA,CAAa,CAAA;AACrF,IAAA;;IAGA,OAAOb,IAAAA,EAAAA;AACT,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restrict-access.mjs","sources":["../../../server/src/middlewares/restrict-access.ts"],"sourcesContent":["import type Koa from 'koa';\nimport type {} from 'koa-session';\n\nimport type { Config } from '../types';\n\nexport default async (ctx: Koa.Context, next: Koa.Next) => {\n const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' });\n\n const config = (await pluginStore.get({ key: 'config' })) as Config;\n\n if (!config.restrictedAccess) {\n return next();\n }\n\n if (!ctx.session || !ctx.session.documentation || !ctx.session.documentation.logged) {\n const querystring = ctx.querystring ? `?${ctx.querystring}` : '';\n\n return ctx.redirect(`${strapi.config.server.url}/documentation/login${querystring}`);\n }\n\n // Execute the action.\n return next();\n};\n"],"names":["ctx","next","pluginStore","strapi","store","type","name","config","get","key","restrictedAccess","session","documentation","logged","querystring","redirect","server","url"],"mappings":"AAKA,qBAAe,CAAA,OAAOA,
|
|
1
|
+
{"version":3,"file":"restrict-access.mjs","sources":["../../../server/src/middlewares/restrict-access.ts"],"sourcesContent":["import type Koa from 'koa';\nimport type {} from 'koa-session';\n\nimport type { Config } from '../types';\n\nexport default async (ctx: Koa.Context, next: Koa.Next) => {\n const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' });\n\n const config = (await pluginStore.get({ key: 'config' })) as Config;\n\n if (!config.restrictedAccess) {\n return next();\n }\n\n if (!ctx.session || !ctx.session.documentation || !ctx.session.documentation.logged) {\n const querystring = ctx.querystring ? `?${ctx.querystring}` : '';\n\n return ctx.redirect(`${strapi.config.server.url}/documentation/login${querystring}`);\n }\n\n // Execute the action.\n return next();\n};\n"],"names":["ctx","next","pluginStore","strapi","store","type","name","config","get","key","restrictedAccess","session","documentation","logged","querystring","redirect","server","url"],"mappings":"AAKA,qBAAe,CAAA,OAAOA,GAAAA,EAAkBC,IAAAA,GAAAA;IACtC,MAAMC,WAAAA,GAAcC,MAAAA,CAAOC,KAAK,CAAC;QAAEC,IAAAA,EAAM,QAAA;QAAUC,IAAAA,EAAM;AAAgB,KAAA,CAAA;AAEzE,IAAA,MAAMC,MAAAA,GAAU,MAAML,WAAAA,CAAYM,GAAG,CAAC;QAAEC,GAAAA,EAAK;AAAS,KAAA,CAAA;IAEtD,IAAI,CAACF,MAAAA,CAAOG,gBAAgB,EAAE;QAC5B,OAAOT,IAAAA,EAAAA;AACT,IAAA;AAEA,IAAA,IAAI,CAACD,GAAAA,CAAIW,OAAO,IAAI,CAACX,IAAIW,OAAO,CAACC,aAAa,IAAI,CAACZ,GAAAA,CAAIW,OAAO,CAACC,aAAa,CAACC,MAAM,EAAE;QACnF,MAAMC,WAAAA,GAAcd,GAAAA,CAAIc,WAAW,GAAG,CAAC,CAAC,EAAEd,GAAAA,CAAIc,WAAW,CAAA,CAAE,GAAG,EAAA;AAE9D,QAAA,OAAOd,GAAAA,CAAIe,QAAQ,CAAC,CAAA,EAAGZ,MAAAA,CAAOI,MAAM,CAACS,MAAM,CAACC,GAAG,CAAC,oBAAoB,EAAEH,WAAAA,CAAAA,CAAa,CAAA;AACrF,IAAA;;IAGA,OAAOb,IAAAA,EAAAA;AACT,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sources":["../../server/src/register.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { addDocumentMiddlewares } from './middlewares/documentation';\n\nexport async function register({ strapi }: { strapi: Core.Strapi }) {\n await addDocumentMiddlewares({ strapi });\n}\n"],"names":["register","strapi","addDocumentMiddlewares"],"mappings":";;;;AAIO,eAAeA,QAAAA,CAAS,EAAEC,MAAM,EAA2B,EAAA;AAChE,IAAA,MAAMC,
|
|
1
|
+
{"version":3,"file":"register.js","sources":["../../server/src/register.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { addDocumentMiddlewares } from './middlewares/documentation';\n\nexport async function register({ strapi }: { strapi: Core.Strapi }) {\n await addDocumentMiddlewares({ strapi });\n}\n"],"names":["register","strapi","addDocumentMiddlewares"],"mappings":";;;;AAIO,eAAeA,QAAAA,CAAS,EAAEC,MAAM,EAA2B,EAAA;AAChE,IAAA,MAAMC,oCAAAA,CAAuB;AAAED,QAAAA;AAAO,KAAA,CAAA;AACxC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.mjs","sources":["../../server/src/register.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { addDocumentMiddlewares } from './middlewares/documentation';\n\nexport async function register({ strapi }: { strapi: Core.Strapi }) {\n await addDocumentMiddlewares({ strapi });\n}\n"],"names":["register","strapi","addDocumentMiddlewares"],"mappings":";;AAIO,eAAeA,QAAAA,CAAS,EAAEC,MAAM,EAA2B,EAAA;AAChE,IAAA,MAAMC,
|
|
1
|
+
{"version":3,"file":"register.mjs","sources":["../../server/src/register.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { addDocumentMiddlewares } from './middlewares/documentation';\n\nexport async function register({ strapi }: { strapi: Core.Strapi }) {\n await addDocumentMiddlewares({ strapi });\n}\n"],"names":["register","strapi","addDocumentMiddlewares"],"mappings":";;AAIO,eAAeA,QAAAA,CAAS,EAAEC,MAAM,EAA2B,EAAA;AAChE,IAAA,MAAMC,sBAAAA,CAAuB;AAAED,QAAAA;AAAO,KAAA,CAAA;AACxC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../server/src/routes/index.ts"],"sourcesContent":["import restrictAccess from '../middlewares/restrict-access';\n\nexport default [\n {\n method: 'GET',\n path: '/',\n handler: 'documentation.index',\n config: {\n auth: false,\n middlewares: [restrictAccess],\n },\n },\n {\n method: 'GET',\n path: '/v:major(\\\\d+).:minor(\\\\d+).:patch(\\\\d+)',\n handler: 'documentation.index',\n config: {\n auth: false,\n middlewares: [restrictAccess],\n },\n },\n {\n method: 'GET',\n path: '/login',\n handler: 'documentation.loginView',\n config: {\n auth: false,\n },\n },\n {\n method: 'POST',\n path: '/login',\n handler: 'documentation.login',\n config: {\n auth: false,\n },\n },\n {\n method: 'GET',\n path: '/getInfos',\n handler: 'documentation.getInfos',\n config: {\n policies: [\n { name: 'admin::hasPermissions', config: { actions: ['plugin::documentation.read'] } },\n ],\n },\n },\n {\n method: 'POST',\n path: '/regenerateDoc',\n handler: 'documentation.regenerateDoc',\n config: {\n policies: [\n {\n name: 'admin::hasPermissions',\n config: { actions: ['plugin::documentation.settings.regenerate'] },\n },\n ],\n },\n },\n {\n method: 'PUT',\n path: '/updateSettings',\n handler: 'documentation.updateSettings',\n config: {\n policies: [\n {\n name: 'admin::hasPermissions',\n config: { actions: ['plugin::documentation.settings.update'] },\n },\n ],\n },\n },\n {\n method: 'DELETE',\n path: '/deleteDoc/:version',\n handler: 'documentation.deleteDoc',\n config: {\n policies: [],\n },\n },\n];\n"],"names":["method","path","handler","config","auth","middlewares","restrictAccess","policies","name","actions"],"mappings":";;;;AAEA,aAAe;AACb,IAAA;QACEA,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../server/src/routes/index.ts"],"sourcesContent":["import restrictAccess from '../middlewares/restrict-access';\n\nexport default [\n {\n method: 'GET',\n path: '/',\n handler: 'documentation.index',\n config: {\n auth: false,\n middlewares: [restrictAccess],\n },\n },\n {\n method: 'GET',\n path: '/v:major(\\\\d+).:minor(\\\\d+).:patch(\\\\d+)',\n handler: 'documentation.index',\n config: {\n auth: false,\n middlewares: [restrictAccess],\n },\n },\n {\n method: 'GET',\n path: '/login',\n handler: 'documentation.loginView',\n config: {\n auth: false,\n },\n },\n {\n method: 'POST',\n path: '/login',\n handler: 'documentation.login',\n config: {\n auth: false,\n },\n },\n {\n method: 'GET',\n path: '/getInfos',\n handler: 'documentation.getInfos',\n config: {\n policies: [\n { name: 'admin::hasPermissions', config: { actions: ['plugin::documentation.read'] } },\n ],\n },\n },\n {\n method: 'POST',\n path: '/regenerateDoc',\n handler: 'documentation.regenerateDoc',\n config: {\n policies: [\n {\n name: 'admin::hasPermissions',\n config: { actions: ['plugin::documentation.settings.regenerate'] },\n },\n ],\n },\n },\n {\n method: 'PUT',\n path: '/updateSettings',\n handler: 'documentation.updateSettings',\n config: {\n policies: [\n {\n name: 'admin::hasPermissions',\n config: { actions: ['plugin::documentation.settings.update'] },\n },\n ],\n },\n },\n {\n method: 'DELETE',\n path: '/deleteDoc/:version',\n handler: 'documentation.deleteDoc',\n config: {\n policies: [],\n },\n },\n];\n"],"names":["method","path","handler","config","auth","middlewares","restrictAccess","policies","name","actions"],"mappings":";;;;AAEA,aAAe;AACb,IAAA;QACEA,MAAAA,EAAQ,KAAA;QACRC,IAAAA,EAAM,GAAA;QACNC,OAAAA,EAAS,qBAAA;QACTC,MAAAA,EAAQ;YACNC,IAAAA,EAAM,KAAA;YACNC,WAAAA,EAAa;AAACC,gBAAAA;AAAe;AAC/B;AACF,KAAA;AACA,IAAA;QACEN,MAAAA,EAAQ,KAAA;QACRC,IAAAA,EAAM,0CAAA;QACNC,OAAAA,EAAS,qBAAA;QACTC,MAAAA,EAAQ;YACNC,IAAAA,EAAM,KAAA;YACNC,WAAAA,EAAa;AAACC,gBAAAA;AAAe;AAC/B;AACF,KAAA;AACA,IAAA;QACEN,MAAAA,EAAQ,KAAA;QACRC,IAAAA,EAAM,QAAA;QACNC,OAAAA,EAAS,yBAAA;QACTC,MAAAA,EAAQ;YACNC,IAAAA,EAAM;AACR;AACF,KAAA;AACA,IAAA;QACEJ,MAAAA,EAAQ,MAAA;QACRC,IAAAA,EAAM,QAAA;QACNC,OAAAA,EAAS,qBAAA;QACTC,MAAAA,EAAQ;YACNC,IAAAA,EAAM;AACR;AACF,KAAA;AACA,IAAA;QACEJ,MAAAA,EAAQ,KAAA;QACRC,IAAAA,EAAM,WAAA;QACNC,OAAAA,EAAS,wBAAA;QACTC,MAAAA,EAAQ;YACNI,QAAAA,EAAU;AACR,gBAAA;oBAAEC,IAAAA,EAAM,uBAAA;oBAAyBL,MAAAA,EAAQ;wBAAEM,OAAAA,EAAS;AAAC,4BAAA;AAA6B;AAAC;AAAE;AACtF;AACH;AACF,KAAA;AACA,IAAA;QACET,MAAAA,EAAQ,MAAA;QACRC,IAAAA,EAAM,gBAAA;QACNC,OAAAA,EAAS,6BAAA;QACTC,MAAAA,EAAQ;YACNI,QAAAA,EAAU;AACR,gBAAA;oBACEC,IAAAA,EAAM,uBAAA;oBACNL,MAAAA,EAAQ;wBAAEM,OAAAA,EAAS;AAAC,4BAAA;AAA4C;AAAC;AACnE;AACD;AACH;AACF,KAAA;AACA,IAAA;QACET,MAAAA,EAAQ,KAAA;QACRC,IAAAA,EAAM,iBAAA;QACNC,OAAAA,EAAS,8BAAA;QACTC,MAAAA,EAAQ;YACNI,QAAAA,EAAU;AACR,gBAAA;oBACEC,IAAAA,EAAM,uBAAA;oBACNL,MAAAA,EAAQ;wBAAEM,OAAAA,EAAS;AAAC,4BAAA;AAAwC;AAAC;AAC/D;AACD;AACH;AACF,KAAA;AACA,IAAA;QACET,MAAAA,EAAQ,QAAA;QACRC,IAAAA,EAAM,qBAAA;QACNC,OAAAA,EAAS,yBAAA;QACTC,MAAAA,EAAQ;AACNI,YAAAA,QAAAA,EAAU;AACZ;AACF;CACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../server/src/routes/index.ts"],"sourcesContent":["import restrictAccess from '../middlewares/restrict-access';\n\nexport default [\n {\n method: 'GET',\n path: '/',\n handler: 'documentation.index',\n config: {\n auth: false,\n middlewares: [restrictAccess],\n },\n },\n {\n method: 'GET',\n path: '/v:major(\\\\d+).:minor(\\\\d+).:patch(\\\\d+)',\n handler: 'documentation.index',\n config: {\n auth: false,\n middlewares: [restrictAccess],\n },\n },\n {\n method: 'GET',\n path: '/login',\n handler: 'documentation.loginView',\n config: {\n auth: false,\n },\n },\n {\n method: 'POST',\n path: '/login',\n handler: 'documentation.login',\n config: {\n auth: false,\n },\n },\n {\n method: 'GET',\n path: '/getInfos',\n handler: 'documentation.getInfos',\n config: {\n policies: [\n { name: 'admin::hasPermissions', config: { actions: ['plugin::documentation.read'] } },\n ],\n },\n },\n {\n method: 'POST',\n path: '/regenerateDoc',\n handler: 'documentation.regenerateDoc',\n config: {\n policies: [\n {\n name: 'admin::hasPermissions',\n config: { actions: ['plugin::documentation.settings.regenerate'] },\n },\n ],\n },\n },\n {\n method: 'PUT',\n path: '/updateSettings',\n handler: 'documentation.updateSettings',\n config: {\n policies: [\n {\n name: 'admin::hasPermissions',\n config: { actions: ['plugin::documentation.settings.update'] },\n },\n ],\n },\n },\n {\n method: 'DELETE',\n path: '/deleteDoc/:version',\n handler: 'documentation.deleteDoc',\n config: {\n policies: [],\n },\n },\n];\n"],"names":["method","path","handler","config","auth","middlewares","restrictAccess","policies","name","actions"],"mappings":";;AAEA,aAAe;AACb,IAAA;QACEA,
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../server/src/routes/index.ts"],"sourcesContent":["import restrictAccess from '../middlewares/restrict-access';\n\nexport default [\n {\n method: 'GET',\n path: '/',\n handler: 'documentation.index',\n config: {\n auth: false,\n middlewares: [restrictAccess],\n },\n },\n {\n method: 'GET',\n path: '/v:major(\\\\d+).:minor(\\\\d+).:patch(\\\\d+)',\n handler: 'documentation.index',\n config: {\n auth: false,\n middlewares: [restrictAccess],\n },\n },\n {\n method: 'GET',\n path: '/login',\n handler: 'documentation.loginView',\n config: {\n auth: false,\n },\n },\n {\n method: 'POST',\n path: '/login',\n handler: 'documentation.login',\n config: {\n auth: false,\n },\n },\n {\n method: 'GET',\n path: '/getInfos',\n handler: 'documentation.getInfos',\n config: {\n policies: [\n { name: 'admin::hasPermissions', config: { actions: ['plugin::documentation.read'] } },\n ],\n },\n },\n {\n method: 'POST',\n path: '/regenerateDoc',\n handler: 'documentation.regenerateDoc',\n config: {\n policies: [\n {\n name: 'admin::hasPermissions',\n config: { actions: ['plugin::documentation.settings.regenerate'] },\n },\n ],\n },\n },\n {\n method: 'PUT',\n path: '/updateSettings',\n handler: 'documentation.updateSettings',\n config: {\n policies: [\n {\n name: 'admin::hasPermissions',\n config: { actions: ['plugin::documentation.settings.update'] },\n },\n ],\n },\n },\n {\n method: 'DELETE',\n path: '/deleteDoc/:version',\n handler: 'documentation.deleteDoc',\n config: {\n policies: [],\n },\n },\n];\n"],"names":["method","path","handler","config","auth","middlewares","restrictAccess","policies","name","actions"],"mappings":";;AAEA,aAAe;AACb,IAAA;QACEA,MAAAA,EAAQ,KAAA;QACRC,IAAAA,EAAM,GAAA;QACNC,OAAAA,EAAS,qBAAA;QACTC,MAAAA,EAAQ;YACNC,IAAAA,EAAM,KAAA;YACNC,WAAAA,EAAa;AAACC,gBAAAA;AAAe;AAC/B;AACF,KAAA;AACA,IAAA;QACEN,MAAAA,EAAQ,KAAA;QACRC,IAAAA,EAAM,0CAAA;QACNC,OAAAA,EAAS,qBAAA;QACTC,MAAAA,EAAQ;YACNC,IAAAA,EAAM,KAAA;YACNC,WAAAA,EAAa;AAACC,gBAAAA;AAAe;AAC/B;AACF,KAAA;AACA,IAAA;QACEN,MAAAA,EAAQ,KAAA;QACRC,IAAAA,EAAM,QAAA;QACNC,OAAAA,EAAS,yBAAA;QACTC,MAAAA,EAAQ;YACNC,IAAAA,EAAM;AACR;AACF,KAAA;AACA,IAAA;QACEJ,MAAAA,EAAQ,MAAA;QACRC,IAAAA,EAAM,QAAA;QACNC,OAAAA,EAAS,qBAAA;QACTC,MAAAA,EAAQ;YACNC,IAAAA,EAAM;AACR;AACF,KAAA;AACA,IAAA;QACEJ,MAAAA,EAAQ,KAAA;QACRC,IAAAA,EAAM,WAAA;QACNC,OAAAA,EAAS,wBAAA;QACTC,MAAAA,EAAQ;YACNI,QAAAA,EAAU;AACR,gBAAA;oBAAEC,IAAAA,EAAM,uBAAA;oBAAyBL,MAAAA,EAAQ;wBAAEM,OAAAA,EAAS;AAAC,4BAAA;AAA6B;AAAC;AAAE;AACtF;AACH;AACF,KAAA;AACA,IAAA;QACET,MAAAA,EAAQ,MAAA;QACRC,IAAAA,EAAM,gBAAA;QACNC,OAAAA,EAAS,6BAAA;QACTC,MAAAA,EAAQ;YACNI,QAAAA,EAAU;AACR,gBAAA;oBACEC,IAAAA,EAAM,uBAAA;oBACNL,MAAAA,EAAQ;wBAAEM,OAAAA,EAAS;AAAC,4BAAA;AAA4C;AAAC;AACnE;AACD;AACH;AACF,KAAA;AACA,IAAA;QACET,MAAAA,EAAQ,KAAA;QACRC,IAAAA,EAAM,iBAAA;QACNC,OAAAA,EAAS,8BAAA;QACTC,MAAAA,EAAQ;YACNI,QAAAA,EAAU;AACR,gBAAA;oBACEC,IAAAA,EAAM,uBAAA;oBACNL,MAAAA,EAAQ;wBAAEM,OAAAA,EAAS;AAAC,4BAAA;AAAwC;AAAC;AAC/D;AACD;AACH;AACF,KAAA;AACA,IAAA;QACET,MAAAA,EAAQ,QAAA;QACRC,IAAAA,EAAM,qBAAA;QACNC,OAAAA,EAAS,yBAAA;QACTC,MAAAA,EAAQ;AACNI,YAAAA,QAAAA,EAAU;AACZ;AACF;CACD;;;;"}
|
|
@@ -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 return path.join(strapi.dirs.app.extensions, '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 if (api.getter === 'plugin') {\n return path.join(strapi.dirs.app.extensions, api.name, 'documentation');\n }\n\n return path.join(strapi.dirs.app.api, 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","path","join","dirs","app","extensions","getDocumentationVersions","fs","readdirSync","map","filePath","resolve","doc","JSON","parse","readFileSync","toString","generatedDate","url","err","filter","x","getDocumentationAccess","restrictedAccess","store","environment","type","name","key","getApiDocumentationPath","api","getter","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,aAAgB,GAAA,CAAC,EAAEC,MAAM,EAA2B,GAAA;AACxD,IAAA,MAAMC,MAASD,GA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/B,IAAI,CAACF,wBAAwB,IAC7BD,OACA,EAAA,yBAAA,CAAA;;YAGF,MAAMQ,EAAAA,CAAGuE,UAAU,CAACD,eAAAA,CAAAA;AACpB,YAAA,MAAMtE,EAAGwE,CAAAA,SAAS,CAACF,eAAAA,EAAiBD,kBAAoB,EAAA;gBAAEI,MAAQ,EAAA;AAAE,aAAA,CAAA;AACtE;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 return path.join(strapi.dirs.app.extensions, '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 if (api.getter === 'plugin') {\n return path.join(strapi.dirs.app.extensions, api.name, 'documentation');\n }\n\n return path.join(strapi.dirs.app.api, 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","path","join","dirs","app","extensions","getDocumentationVersions","fs","readdirSync","map","filePath","resolve","doc","JSON","parse","readFileSync","toString","generatedDate","url","err","filter","x","getDocumentationAccess","restrictedAccess","store","environment","type","name","key","getApiDocumentationPath","api","getter","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;YACE,OAAOC,IAAAA,CAAKC,IAAI,CAACZ,MAAAA,CAAOa,IAAI,CAACC,GAAG,CAACC,UAAU,EAAE,eAAA,EAAiB,eAAA,CAAA;AAChE,QAAA,CAAA;AAEAC,QAAAA,wBAAAA,CAAAA,GAAAA;YACE,OAAOC,EAAAA,CACJC,WAAW,CAAC,IAAI,CAACR,wBAAwB,EAAA,CAAA,CACzCS,GAAG,CAAC,CAACV,OAAAA,GAAAA;gBACJ,IAAI;oBACF,MAAMW,QAAAA,GAAWT,KAAKU,OAAO,CAC3B,IAAI,CAACX,wBAAwB,IAC7BD,OAA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