@nocobase/server 0.7.0-alpha.8 → 0.7.0-alpha.80
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/lib/acl/available-action.js +37 -35
- package/lib/acl/index.js +45 -21
- package/lib/app-manager.d.ts +3 -3
- package/lib/app-manager.js +151 -72
- package/lib/application.d.ts +3 -2
- package/lib/application.js +291 -153
- package/lib/commands/console.d.ts +2 -3
- package/lib/commands/console.js +33 -24
- package/lib/commands/db-auth.d.ts +3 -0
- package/lib/commands/db-auth.js +26 -0
- package/lib/commands/db-clean.d.ts +3 -0
- package/lib/commands/db-clean.js +27 -0
- package/lib/commands/db-sync.d.ts +2 -4
- package/lib/commands/db-sync.js +25 -23
- package/lib/commands/index.d.ts +1 -2
- package/lib/commands/index.js +29 -29
- package/lib/commands/install.d.ts +2 -4
- package/lib/commands/install.js +68 -20
- package/lib/commands/start.d.ts +2 -4
- package/lib/commands/start.js +28 -22
- package/lib/commands/upgrade.d.ts +6 -0
- package/lib/commands/upgrade.js +45 -0
- package/lib/helper.js +132 -61
- package/lib/index.js +85 -32
- package/lib/middlewares/data-wrapping.js +65 -55
- package/lib/middlewares/index.js +30 -14
- package/lib/middlewares/table2resource.js +89 -52
- package/lib/plugin-manager.js +124 -55
- package/lib/plugin.js +65 -45
- package/lib/read-config.js +159 -64
- package/package.json +8 -13
- package/esm/acl/available-action.d.ts +0 -5
- package/esm/acl/available-action.js +0 -36
- package/esm/acl/available-action.js.map +0 -1
- package/esm/acl/index.d.ts +0 -2
- package/esm/acl/index.js +0 -19
- package/esm/acl/index.js.map +0 -1
- package/esm/app-manager.d.ts +0 -19
- package/esm/app-manager.js +0 -69
- package/esm/app-manager.js.map +0 -1
- package/esm/application.d.ts +0 -97
- package/esm/application.js +0 -156
- package/esm/application.js.map +0 -1
- package/esm/commands/console.d.ts +0 -4
- package/esm/commands/console.js +0 -25
- package/esm/commands/console.js.map +0 -1
- package/esm/commands/create-plugin/create-plugin.d.ts +0 -2
- package/esm/commands/create-plugin/create-plugin.js +0 -29
- package/esm/commands/create-plugin/create-plugin.js.map +0 -1
- package/esm/commands/create-plugin/index.d.ts +0 -5
- package/esm/commands/create-plugin/index.js +0 -6
- package/esm/commands/create-plugin/index.js.map +0 -1
- package/esm/commands/create-plugin/resources/templates/package-json.d.ts +0 -11
- package/esm/commands/create-plugin/resources/templates/package-json.js +0 -11
- package/esm/commands/create-plugin/resources/templates/package-json.js.map +0 -1
- package/esm/commands/create-plugin/resources/templates/plugin.d.ts +0 -4
- package/esm/commands/create-plugin/resources/templates/plugin.js +0 -12
- package/esm/commands/create-plugin/resources/templates/plugin.js.map +0 -1
- package/esm/commands/db-sync.d.ts +0 -5
- package/esm/commands/db-sync.js +0 -25
- package/esm/commands/db-sync.js.map +0 -1
- package/esm/commands/index.d.ts +0 -3
- package/esm/commands/index.js +0 -26
- package/esm/commands/index.js.map +0 -1
- package/esm/commands/install.d.ts +0 -5
- package/esm/commands/install.js +0 -23
- package/esm/commands/install.js.map +0 -1
- package/esm/commands/start.d.ts +0 -5
- package/esm/commands/start.js +0 -23
- package/esm/commands/start.js.map +0 -1
- package/esm/helper.d.ts +0 -7
- package/esm/helper.js +0 -59
- package/esm/helper.js.map +0 -1
- package/esm/index.d.ts +0 -7
- package/esm/index.js +0 -9
- package/esm/index.js.map +0 -1
- package/esm/middlewares/data-wrapping.d.ts +0 -3
- package/esm/middlewares/data-wrapping.js +0 -54
- package/esm/middlewares/data-wrapping.js.map +0 -1
- package/esm/middlewares/index.d.ts +0 -2
- package/esm/middlewares/index.js +0 -3
- package/esm/middlewares/index.js.map +0 -1
- package/esm/middlewares/table2resource.d.ts +0 -6
- package/esm/middlewares/table2resource.js +0 -51
- package/esm/middlewares/table2resource.js.map +0 -1
- package/esm/plugin-manager.d.ts +0 -23
- package/esm/plugin-manager.js +0 -57
- package/esm/plugin-manager.js.map +0 -1
- package/esm/plugin.d.ts +0 -32
- package/esm/plugin.js +0 -43
- package/esm/plugin.js.map +0 -1
- package/esm/read-config.d.ts +0 -8
- package/esm/read-config.js +0 -63
- package/esm/read-config.js.map +0 -1
- package/lib/acl/available-action.js.map +0 -1
- package/lib/acl/index.js.map +0 -1
- package/lib/app-manager.js.map +0 -1
- package/lib/application.js.map +0 -1
- package/lib/commands/console.js.map +0 -1
- package/lib/commands/create-plugin/create-plugin.d.ts +0 -2
- package/lib/commands/create-plugin/create-plugin.js +0 -31
- package/lib/commands/create-plugin/create-plugin.js.map +0 -1
- package/lib/commands/create-plugin/index.d.ts +0 -5
- package/lib/commands/create-plugin/index.js +0 -8
- package/lib/commands/create-plugin/index.js.map +0 -1
- package/lib/commands/create-plugin/resources/templates/package-json.d.ts +0 -11
- package/lib/commands/create-plugin/resources/templates/package-json.js +0 -13
- package/lib/commands/create-plugin/resources/templates/package-json.js.map +0 -1
- package/lib/commands/create-plugin/resources/templates/plugin.d.ts +0 -4
- package/lib/commands/create-plugin/resources/templates/plugin.js +0 -33
- package/lib/commands/create-plugin/resources/templates/plugin.js.map +0 -1
- package/lib/commands/db-sync.js.map +0 -1
- package/lib/commands/index.js.map +0 -1
- package/lib/commands/install.js.map +0 -1
- package/lib/commands/start.js.map +0 -1
- package/lib/helper.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/middlewares/data-wrapping.js.map +0 -1
- package/lib/middlewares/index.js.map +0 -1
- package/lib/middlewares/table2resource.js.map +0 -1
- package/lib/plugin-manager.js.map +0 -1
- package/lib/plugin.js.map +0 -1
- package/lib/read-config.js.map +0 -1
- package/tsconfig.build.json +0 -9
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kBAAe,CAAO,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IACxC,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IACvB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,CAAC;IAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,SAAS,CAAC;IAE/D,MAAM,GAAG,CAAC,KAAK,CAAC;QACd,OAAO;QACP,MAAM,EAAE;YACN,IAAI;YACJ,IAAI;SACL;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,4CAA4C,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAA,CAAC","sourcesContent":["export default async ({ app, cliArgs }) => {\n const [opts] = cliArgs;\n const port = opts.port || process.env.SERVER_PORT || 3000;\n const host = opts.host || process.env.SERVER_HOST || '0.0.0.0';\n\n await app.start({\n cliArgs,\n listen: {\n port,\n host,\n },\n });\n\n console.log(`🚀 nocobase server had started at http://${host}:${port}`);\n};\n"]}
|
package/lib/helper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,qDAA6B;AAC7B,kEAA0C;AAC1C,oEAA4C;AAE5C,sDAA8B;AAE9B,oEAAwC;AAExC,+DAA2D;AAC3D,iEAA8D;AAE9D,SAAgB,UAAU,CAAC,OAA2B;IACpD,MAAM,QAAQ,GAAG,iBAAO,CAAC,cAAc,EAAE,CAAC;IAC1C,QAAQ,CAAC,IAAI,iBACX,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,EAAE,IACV,OAAO,CAAC,IAAI,EACf,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC;AARD,gCAQC;AAED,SAAgB,cAAc,CAAC,OAA2B;IACxD,IAAI,OAAO,CAAC,QAAQ,YAAY,kBAAQ,EAAE;QACxC,OAAO,OAAO,CAAC,QAAQ,CAAC;KACzB;SAAM;QACL,OAAO,IAAI,kBAAQ,CAAC,OAAO,CAAC,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AC,GAAG,CAAC,CAAC;SAC1B;QACD,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,YAAY,KAAK,KAAK,EAAE;QAClC,GAAG,CAAC,GAAG,CAAC,IAAA,4BAAY,GAAE,CAAC,CAAC;KACzB;IAED,GAAG,CAAC,GAAG,CAAC,IAAA,+BAAc,GAAE,CAAC,CAAC;IAC1B,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,iBAAiB,EAAE,CAAC,CAAC;AAC7C,CAAC;AAtCD,kDAsCC","sourcesContent":["import cors from '@koa/cors';\nimport Database from '@nocobase/database';\nimport Resourcer from '@nocobase/resourcer';\nimport { Command } from 'commander';\nimport i18next from 'i18next';\nimport { DefaultContext, DefaultState } from 'koa';\nimport bodyParser from 'koa-bodyparser';\nimport Application, { ApplicationOptions } from './application';\nimport { dataWrapping } from './middlewares/data-wrapping';\nimport { table2resource } from './middlewares/table2resource';\n\nexport function createI18n(options: ApplicationOptions) {\n const instance = i18next.createInstance();\n instance.init({\n lng: 'en-US',\n resources: {},\n ...options.i18n,\n });\n return instance;\n}\n\nexport function createDatabase(options: ApplicationOptions) {\n if (options.database instanceof Database) {\n return options.database;\n } else {\n return new Database(options.database);\n }\n}\n\nexport function createResourcer(options: ApplicationOptions) {\n return new Resourcer({ ...options.resourcer });\n}\n\nexport function registerMiddlewares(app: Application, options: ApplicationOptions) {\n if (options.bodyParser !== false) {\n app.use(\n bodyParser({\n ...options.bodyParser,\n }),\n );\n }\n\n app.use(\n cors({\n exposeHeaders: ['content-disposition'],\n ...options.cors,\n }),\n );\n\n app.use<DefaultState, DefaultContext>(async (ctx, next) => {\n ctx.getBearerToken = () => {\n return ctx.get('Authorization').replace(/^Bearer\\s+/gi, '');\n };\n ctx.db = app.db;\n ctx.resourcer = app.resourcer;\n const i18n = app.i18n.cloneInstance({ initImmediate: false });\n ctx.i18n = i18n;\n ctx.t = i18n.t.bind(i18n);\n const lng = (ctx.request.query.locale as string) || ctx.acceptsLanguages().shift();\n if (lng !== '*' && lng) {\n i18n.changeLanguage(lng);\n }\n await next();\n });\n\n if (options.dataWrapping !== false) {\n app.use(dataWrapping());\n }\n\n app.use(table2resource());\n app.use(app.resourcer.restApiMiddleware());\n}\n"]}
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,gDAA8B;AAC9B,6CAAuD;AAA9C,sGAAA,WAAW,OAAW;AAC/B,6DAA6C;AAC7C,2CAAyB;AACzB,mDAAiC;AACjC,gDAA8B","sourcesContent":["export { AppManager } from './app-manager';\nexport * from './application';\nexport { Application as default } from './application';\nexport * as middlewares from './middlewares';\nexport * from './plugin';\nexport * from './plugin-manager';\nexport * from './read-config';\n\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data-wrapping.js","sourceRoot":"","sources":["../../src/middlewares/data-wrapping.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAgB,YAAY;IAC1B,OAAO,SAAe,YAAY,CAAC,GAAY,EAAE,IAAU;;;YACzD,MAAM,IAAI,EAAE,CAAC;YACb,IAAI,GAAG,CAAC,mBAAmB,EAAE;gBAC3B,OAAO;aACR;YACD,IAAI,CAAC,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,0CAAE,MAAM,CAAA,EAAE;gBACxB,OAAO;aACR;YACD,IAAI,GAAG,CAAC,IAAI,YAAY,MAAM,EAAE;gBAC9B,OAAO;aACR;YACD,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;gBACb,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC;aACf;YACD,MAAM,KAAoB,GAAG,CAAC,IAAI,EAA5B,EAAE,IAAI,OAAsB,EAAjB,IAAI,cAAf,QAAiB,CAAW,CAAC;YACnC,IAAI,IAAI,EAAE;gBACR,GAAG,CAAC,IAAI,GAAG;oBACT,IAAI,EAAE,IAAI;oBACV,IAAI;iBACL,CAAC;aACH;iBAAM;gBACL,GAAG,CAAC,IAAI,GAAG;oBACT,IAAI,EAAE,GAAG,CAAC,IAAI;iBACf,CAAC;aACH;;KACF,CAAC;AACJ,CAAC;AA3BD,oCA2BC;AAED,kBAAe,YAAY,CAAC","sourcesContent":["import { Context, Next } from '@nocobase/actions';\n\nexport function dataWrapping() {\n return async function dataWrapping(ctx: Context, next: Next) {\n await next();\n if (ctx.withoutDataWrapping) {\n return;\n }\n if (!ctx?.action?.params) {\n return;\n }\n if (ctx.body instanceof Buffer) {\n return;\n }\n if (!ctx.body) {\n ctx.body = {};\n }\n const { rows, ...meta } = ctx.body;\n if (rows) {\n ctx.body = {\n data: rows,\n meta,\n };\n } else {\n ctx.body = {\n data: ctx.body,\n };\n }\n };\n}\n\nexport default dataWrapping;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middlewares/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAiC;AACjC,kDAAgC","sourcesContent":["export * from './table2resource';\nexport * from './data-wrapping';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"table2resource.js","sourceRoot":"","sources":["../../src/middlewares/table2resource.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAoG;AAGpG,SAAgB,cAAc;IAC5B,OAAO,SAAe,cAAc,CAAC,GAAwC,EAAE,IAAwB;;YACrG,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;YAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,EAAE,CAAC;YACxB,IAAI,MAAM,GAAG,IAAA,wBAAY,EACvB;gBACE,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI;gBACtB,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM;aAC3B,EACD;gBACE,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,MAAM;gBAChC,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS;aACvC,CACF,CAAC;YACF,IAAI,CAAC,MAAM,EAAE;gBACX,OAAO,IAAI,EAAE,CAAC;aACf;YACD,MAAM,YAAY,GAAG,IAAA,2BAAe,EAAC,MAAM,CAAC,CAAC;YAC7C,aAAa;YACb,IAAI,SAAS,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE;gBACrC,OAAO,IAAI,EAAE,CAAC;aACf;YACD,MAAM,CAAC,cAAc,EAAE,SAAS,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC5D,iBAAiB;YACjB,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE;gBAC3C,OAAO,IAAI,EAAE,CAAC;aACf;YACD,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;YAC1D,IAAI,YAAY,GAAiB,QAAQ,CAAC;YAC1C,IAAI,SAAS,IAAI,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;gBAC/C,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;gBAC7C,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC;aAC3B;YACD,SAAS,CAAC,MAAM,CAAC;gBACf,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,YAAY;aACnB,CAAC,CAAC;YACH,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;KAAA,CAAC;AACJ,CAAC;AAvCD,wCAuCC;AAED,kBAAe,cAAc,CAAC","sourcesContent":["import { getNameByParams, parseRequest, ResourcerContext, ResourceType } from '@nocobase/resourcer';\nimport Database from '@nocobase/database';\n\nexport function table2resource() {\n return async function table2resource(ctx: ResourcerContext & { db: Database }, next: () => Promise<any>) {\n const resourcer = ctx.resourcer;\n const database = ctx.db;\n let params = parseRequest(\n {\n path: ctx.request.path,\n method: ctx.request.method,\n },\n {\n prefix: resourcer.options.prefix,\n accessors: resourcer.options.accessors,\n },\n );\n if (!params) {\n return next();\n }\n const resourceName = getNameByParams(params);\n // 如果资源名称未被定义\n if (resourcer.isDefined(resourceName)) {\n return next();\n }\n const [collectionName, fieldName] = resourceName.split('.');\n // 如果经过加载后是已经定义的表\n if (!database.hasCollection(collectionName)) {\n return next();\n }\n const collection = database.getCollection(collectionName);\n let resourceType: ResourceType = 'single';\n if (fieldName && collection.hasField(fieldName)) {\n const field = collection.getField(fieldName);\n resourceType = field.type;\n }\n resourcer.define({\n type: resourceType,\n name: resourceName,\n });\n return next();\n };\n}\n\nexport default table2resource;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-manager.js","sourceRoot":"","sources":["../src/plugin-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAcA,MAAa,aAAa;IAIxB,YAAY,OAA6B;QAF/B,YAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;QAG5C,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IACzB,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,GAAG,CAAsB,WAAgB,EAAE,OAAW;QACpD,MAAM,QAAQ,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAEpD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;QAEhC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,IAAI,CAAC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'@nocobase/database';\nimport Application from './application';\nimport { Plugin } from './plugin';\n\ninterface PluginManagerOptions {\n app: Application;\n}\n\nexport interface InstallOptions {\n cliArgs?: any[];\n clean?: CleanOptions | boolean;\n sync?: SyncOptions;\n}\n\nexport class PluginManager {\n app: Application;\n protected plugins = new Map<string, Plugin>();\n\n constructor(options: PluginManagerOptions) {\n this.app = options.app;\n }\n\n getPlugins() {\n return this.plugins;\n }\n\n get(name: string) {\n return this.plugins.get(name);\n }\n\n add<P = Plugin, O = any>(pluginClass: any, options?: O): P {\n const instance = new pluginClass(this.app, options);\n\n const name = instance.getName();\n\n if (this.plugins.has(name)) {\n throw new Error(`plugin name [${name}] `);\n }\n\n this.plugins.set(name, instance);\n\n return instance;\n }\n\n async load() {\n await this.app.emitAsync('beforeLoadAll');\n\n for (const [name, plugin] of this.plugins) {\n await plugin.beforeLoad();\n }\n\n for (const [name, plugin] of this.plugins) {\n await this.app.emitAsync('beforeLoadPlugin', plugin);\n await plugin.load();\n await this.app.emitAsync('afterLoadPlugin', plugin);\n }\n\n await this.app.emitAsync('afterLoadAll');\n }\n\n async install(options?: InstallOptions) {\n for (const [name, plugin] of this.plugins) {\n await this.app.emitAsync('beforeInstallPlugin', plugin, options);\n await plugin.install(options);\n await this.app.emitAsync('afterInstallPlugin', plugin, options);\n }\n }\n\n static resolvePlugin(pluginName: string) {\n return require(pluginName).default;\n }\n}\n"]}
|
package/lib/plugin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,0EAAuC;AAuBvC,MAAsB,MAAM;IAK1B,YAAY,GAAgB,EAAE,OAAW;QACvC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC;QACjB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAED,UAAU,CAAC,OAAU;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,IAAK,EAAU,CAAC;IACxC,CAAC;IAID,UAAU,KAAI,CAAC;IAET,OAAO,CAAC,OAAwB;8DAAG,CAAC;KAAA;IAEpC,IAAI;;YACR,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;YAC7C,IAAI,cAAc,EAAE;gBAClB,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;oBACnB,SAAS,EAAE,cAAc;iBAC1B,CAAC,CAAC;aACJ;QACH,CAAC;KAAA;IAED,cAAc;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAES,cAAc,CAAC,OAAe;QACtC,MAAM,CAAC,GAAG,IAAA,2BAAM,EAAC,OAAO,CAAC,CAAC;QAC1B,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;QAClC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;CACF;AAvCD,wBAuCC","sourcesContent":["import { Database } from '@nocobase/database';\nimport { Application } from './application';\nimport finder from 'find-package-json';\n\nimport { InstallOptions } from './plugin-manager';\n\nexport interface PluginInterface {\n beforeLoad?: () => void;\n load();\n getName(): string;\n}\n\nexport interface PluginOptions {\n activate?: boolean;\n displayName?: string;\n description?: string;\n version?: string;\n install?: (this: Plugin) => void;\n load?: (this: Plugin) => void;\n plugin?: typeof Plugin;\n [key: string]: any;\n}\n\nexport type PluginType = typeof Plugin;\n\nexport abstract class Plugin<O = any> implements PluginInterface {\n options: O;\n app: Application;\n db: Database;\n\n constructor(app: Application, options?: O) {\n this.app = app;\n this.db = app.db;\n this.setOptions(options);\n }\n\n setOptions(options: O) {\n this.options = options || ({} as any);\n }\n\n public abstract getName(): string;\n\n beforeLoad() {}\n\n async install(options?: InstallOptions) {}\n\n async load() {\n const collectionPath = this.collectionPath();\n if (collectionPath) {\n await this.db.import({\n directory: collectionPath,\n });\n }\n }\n\n collectionPath() {\n return null;\n }\n\n protected getPackageName(dirname: string) {\n const f = finder(dirname);\n const packageObj = f.next().value;\n return packageObj['name'];\n }\n}\n"]}
|
package/lib/read-config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read-config.js","sourceRoot":"","sources":["../src/read-config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAA4B;AAC5B,4CAAoB;AACpB,gDAAwB;AAExB,SAAsB,UAAU,CAAC,GAAW;;QAC1C,MAAM,UAAU,GAAG,IAAI,uBAAuB,EAAE,CAAC;QACjD,MAAM,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACzC,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;CAAA;AAJD,gCAIC;AAED,MAAa,uBAAuB;IAApC;QACY,UAAK,GAAG,IAAI,GAAG,EAAe,CAAC;IAuB3C,CAAC;IArBC,GAAG,CAAC,GAAW,EAAE,YAAY,GAAG,SAAS;QACvC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACvB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SAC5B;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAU;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,QAAQ;QACN,MAAM,MAAM,GAAG,EAAE,CAAC;QAElB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE;YAC/C,gBAAM,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;SAChC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAxBD,0DAwBC;AAED,SAAsB,iBAAiB,CAAC,gBAAw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repository = new ConfigurationRepository();\n await loadConfiguration(dir, repository);\n return repository.toObject();\n}\n\nexport class ConfigurationRepository {\n protected items = new Map<string, any>();\n\n get(key: string, defaultValue = undefined) {\n if (this.items.has(key)) {\n return this.items.get(key);\n }\n\n return defaultValue;\n }\n\n set(key: string, value: any) {\n return this.items.set(key, value);\n }\n\n toObject() {\n const result = {};\n\n for (const [key, value] of this.items.entries()) {\n lodash.set(result, key, value);\n }\n\n return result;\n }\n}\n\nexport async function loadConfiguration(configurationDir: string, repository: ConfigurationRepository) {\n const getConfigurationFiles = async (dir: string, prefix = []) => {\n const files = await fs.promises.readdir(dir, { withFileTypes: true });\n for (const file of files) {\n if (file.isDirectory()) {\n await getConfigurationFiles(path.join(dir, file.name), [...prefix, file.name]);\n } else {\n if (!['ts', 'js'].includes(file.name.split('.').slice(1).join('.'))) {\n continue;\n }\n\n const filePath = path.join(dir, file.name);\n const keyName = path.parse(filePath).name;\n const configuration = require(filePath).default;\n\n repository.set([...prefix, keyName].join('.'), configuration);\n }\n }\n };\n\n await getConfigurationFiles(configurationDir);\n}\n"]}
|
package/tsconfig.build.json
DELETED