@nocobase/plugin-system-settings 0.10.0-alpha.5 → 0.11.0-alpha.1

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/client.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './src/client';
2
+ export { default } from './src/client';
3
+
package/client.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./lib/client/index.js');
@@ -0,0 +1,5 @@
1
+ import { Plugin } from '@nocobase/client';
2
+ declare class SystemSettingPlugin extends Plugin {
3
+ load(): Promise<void>;
4
+ }
5
+ export default SystemSettingPlugin;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ function _client() {
8
+ const data = require("@nocobase/client");
9
+ _client = function _client() {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
15
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
16
+ class SystemSettingPlugin extends _client().Plugin {
17
+ load() {
18
+ return _asyncToGenerator(function* () {})();
19
+ }
20
+ }
21
+ var _default = SystemSettingPlugin;
22
+ exports.default = _default;
@@ -0,0 +1 @@
1
+ export { default } from './server';
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "default", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _server.default;
10
+ }
11
+ });
12
+ var _server = _interopRequireDefault(require("./server"));
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
package/package.json CHANGED
@@ -4,12 +4,25 @@
4
4
  "displayName.zh-CN": "系统配置",
5
5
  "description": "A plugin specifically designed to adjust the system-level settings of NocoBase.",
6
6
  "description.zh-CN": "用于调整 nocobase 的系统级设置。",
7
- "version": "0.10.0-alpha.5",
7
+ "version": "0.11.0-alpha.1",
8
8
  "license": "AGPL-3.0",
9
- "main": "./lib/index.js",
10
- "types": "./lib/index.d.ts",
9
+ "main": "./lib/server/index.js",
10
+ "files": [
11
+ "lib",
12
+ "src",
13
+ "README.md",
14
+ "README.zh-CN.md",
15
+ "CHANGELOG.md",
16
+ "server.js",
17
+ "server.d.ts",
18
+ "client.js",
19
+ "client.d.ts"
20
+ ],
11
21
  "devDependencies": {
12
- "@nocobase/test": "0.10.0-alpha.5"
22
+ "@nocobase/client": "0.11.0-alpha.1",
23
+ "@nocobase/database": "0.11.0-alpha.1",
24
+ "@nocobase/server": "0.11.0-alpha.1",
25
+ "@nocobase/test": "0.11.0-alpha.1"
13
26
  },
14
- "gitHead": "1be8fcdad42688064460761cea22830cf392c7c0"
27
+ "gitHead": "7581b6d3a3a54f09f06a9effb7e3e65328281b2b"
15
28
  }
package/server.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './src/server';
2
+ export { default } from './src/server';
3
+
package/server.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./lib/server/index.js');
@@ -0,0 +1,7 @@
1
+ import { Plugin } from '@nocobase/client';
2
+
3
+ class SystemSettingPlugin extends Plugin {
4
+ async load() { }
5
+ }
6
+
7
+ export default SystemSettingPlugin;
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { default } from './server';
@@ -0,0 +1,46 @@
1
+ import { defineCollection } from '@nocobase/database';
2
+
3
+ export default defineCollection({
4
+ namespace: 'system-settings.systemSettings',
5
+ duplicator: 'optional',
6
+ name: 'systemSettings',
7
+ fields: [
8
+ {
9
+ type: 'string',
10
+ name: 'title',
11
+ },
12
+ {
13
+ type: 'boolean',
14
+ name: 'showLogoOnly',
15
+ },
16
+ {
17
+ type: 'boolean',
18
+ name: 'allowSignUp',
19
+ defaultValue: true,
20
+ },
21
+ {
22
+ type: 'boolean',
23
+ name: 'smsAuthEnabled',
24
+ defaultValue: false,
25
+ },
26
+ {
27
+ type: 'belongsTo',
28
+ name: 'logo',
29
+ target: 'attachments',
30
+ },
31
+ {
32
+ type: 'json',
33
+ name: 'enabledLanguages',
34
+ defaultValue: [],
35
+ },
36
+ {
37
+ type: 'string',
38
+ name: 'appLang',
39
+ },
40
+ {
41
+ type: 'json',
42
+ name: 'options',
43
+ defaultValue: {},
44
+ },
45
+ ],
46
+ });
@@ -0,0 +1 @@
1
+ export { default } from './server';
@@ -0,0 +1,17 @@
1
+ import { Migration } from '@nocobase/server';
2
+
3
+ export default class UpdateEnabledLanguagesMigration extends Migration {
4
+ async up() {
5
+ const result = await this.app.version.satisfies('<=0.7.2-alpha.7');
6
+ if (!result) {
7
+ return;
8
+ }
9
+ const SystemSetting = this.context.db.getRepository('systemSettings');
10
+ const setting = await SystemSetting.findOne();
11
+ const enabledLanguages = setting.get('enabledLanguages') || [];
12
+ if (Array.isArray(enabledLanguages) && enabledLanguages.length === 0) {
13
+ setting.set('enabledLanguages', [setting.get('appLang') || 'en-US']);
14
+ await setting.save();
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,53 @@
1
+ import { InstallOptions, Plugin } from '@nocobase/server';
2
+ import { resolve } from 'path';
3
+
4
+ export class SystemSettingsPlugin extends Plugin {
5
+ getInitAppLang(options) {
6
+ return options?.cliArgs?.[0]?.opts?.lang || process.env.INIT_APP_LANG || 'en-US';
7
+ }
8
+
9
+ async install(options?: InstallOptions) {
10
+ await this.db.getRepository('systemSettings').create({
11
+ values: {
12
+ title: 'NocoBase',
13
+ appLang: this.getInitAppLang(options),
14
+ enabledLanguages: [this.getInitAppLang(options)],
15
+ logo: {
16
+ title: 'nocobase-logo',
17
+ filename: '682e5ad037dd02a0fe4800a3e91c283b.png',
18
+ extname: '.png',
19
+ mimetype: 'image/png',
20
+ url: 'https://nocobase.oss-cn-beijing.aliyuncs.com/682e5ad037dd02a0fe4800a3e91c283b.png',
21
+ },
22
+ },
23
+ });
24
+ }
25
+
26
+ beforeLoad() {
27
+ const cmd = this.app.findCommand('install');
28
+ if (cmd) {
29
+ cmd.option('-l, --lang [lang]');
30
+ }
31
+
32
+ this.app.acl.registerSnippet({
33
+ name: `pm.${this.name}.system-settings`,
34
+ actions: ['systemSettings:update'],
35
+ });
36
+ }
37
+
38
+ async load() {
39
+ await this.app.db.import({
40
+ directory: resolve(__dirname, 'collections'),
41
+ });
42
+
43
+ this.app.acl.addFixedParams('systemSettings', 'destroy', () => {
44
+ return {
45
+ 'id.$ne': 1,
46
+ };
47
+ });
48
+
49
+ this.app.acl.allow('systemSettings', 'get', 'public');
50
+ }
51
+ }
52
+
53
+ export default SystemSettingsPlugin;
File without changes
File without changes