@nocobase/plugin-users 0.18.0-alpha.9 → 0.19.0-alpha.10
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 +2 -0
- package/client.js +1 -0
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +5 -5
- package/dist/server/collections/users.d.ts +1 -2
- package/dist/server/collections/users.js +7 -6
- package/dist/server/migrations/20220818072639-add-users-phone-constraint.d.ts +7 -0
- package/dist/server/migrations/20220818072639-add-users-phone-constraint.js +57 -0
- package/dist/server/migrations/20220818072639-add-users-phone.d.ts +1 -0
- package/dist/server/migrations/20220818072639-add-users-phone.js +2 -7
- package/dist/server/migrations/20230802170800-add-username-constraint.d.ts +6 -0
- package/dist/server/migrations/20230802170800-add-username-constraint.js +55 -0
- package/dist/server/migrations/20230802170800-add-username.d.ts +1 -1
- package/dist/server/migrations/20230802170800-add-username.js +2 -9
- package/dist/server/migrations/20230802183100-update-username.d.ts +1 -0
- package/dist/server/migrations/20230802183100-update-username.js +1 -4
- package/dist/server/migrations/20230908164036-update-username-interface.d.ts +1 -0
- package/dist/server/migrations/20230908164036-update-username-interface.js +1 -0
- package/dist/server/server.d.ts +1 -5
- package/dist/server/server.js +5 -21
- package/package.json +9 -4
- package/server.d.ts +2 -0
- package/server.js +1 -0
package/client.d.ts
ADDED
package/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client/index.js');
|
package/dist/client/index.d.ts
CHANGED
package/dist/client/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("@nocobase/client")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client"],n):(e=typeof globalThis!="undefined"?globalThis:e||self,n(e["@nocobase/plugin-users"]={},e["@nocobase/client"]))})(this,function(e,n){"use strict";var
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("@nocobase/client")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client"],n):(e=typeof globalThis!="undefined"?globalThis:e||self,n(e["@nocobase/plugin-users"]={},e["@nocobase/client"]))})(this,function(e,n){"use strict";var d=(e,n,i)=>new Promise((u,l)=>{var c=s=>{try{t(i.next(s))}catch(o){l(o)}},f=s=>{try{t(i.throw(s))}catch(o){l(o)}},t=s=>s.done?u(s.value):Promise.resolve(s.value).then(c,f);t((i=i.apply(e,n)).next())});class i extends n.Plugin{load(){return d(this,null,function*(){})}}e.PluginUsersClient=i,e.default=i,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@nocobase/client": "0.
|
|
3
|
-
"@nocobase/database": "0.
|
|
4
|
-
"@nocobase/server": "0.
|
|
5
|
-
"@nocobase/utils": "0.
|
|
6
|
-
"@nocobase/actions": "0.
|
|
2
|
+
"@nocobase/client": "0.19.0-alpha.10",
|
|
3
|
+
"@nocobase/database": "0.19.0-alpha.10",
|
|
4
|
+
"@nocobase/server": "0.19.0-alpha.10",
|
|
5
|
+
"@nocobase/utils": "0.19.0-alpha.10",
|
|
6
|
+
"@nocobase/actions": "0.19.0-alpha.10"
|
|
7
7
|
};
|
|
@@ -20,11 +20,11 @@ __export(users_exports, {
|
|
|
20
20
|
default: () => users_default
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(users_exports);
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
var import_database = require("@nocobase/database");
|
|
24
|
+
var users_default = (0, import_database.defineCollection)({
|
|
25
|
+
origin: "@nocobase/plugin-users",
|
|
26
|
+
dumpRules: {
|
|
27
|
+
group: "user"
|
|
28
28
|
},
|
|
29
29
|
name: "users",
|
|
30
30
|
title: '{{t("Users")}}',
|
|
@@ -33,6 +33,7 @@ var users_default = {
|
|
|
33
33
|
createdBy: true,
|
|
34
34
|
updatedBy: true,
|
|
35
35
|
logging: true,
|
|
36
|
+
shared: true,
|
|
36
37
|
fields: [
|
|
37
38
|
{
|
|
38
39
|
name: "id",
|
|
@@ -119,4 +120,4 @@ var users_default = {
|
|
|
119
120
|
defaultValue: {}
|
|
120
121
|
}
|
|
121
122
|
]
|
|
122
|
-
};
|
|
123
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var add_users_phone_constraint_exports = {};
|
|
19
|
+
__export(add_users_phone_constraint_exports, {
|
|
20
|
+
default: () => AddUsersPhoneMigration
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(add_users_phone_constraint_exports);
|
|
23
|
+
var import_database = require("@nocobase/database");
|
|
24
|
+
var import_server = require("@nocobase/server");
|
|
25
|
+
class AddUsersPhoneMigration extends import_server.Migration {
|
|
26
|
+
on = "beforeLoad";
|
|
27
|
+
appVersion = "<0.7.5-alpha.1";
|
|
28
|
+
async up() {
|
|
29
|
+
const collection = this.db.collection({
|
|
30
|
+
name: "users",
|
|
31
|
+
fields: [
|
|
32
|
+
{
|
|
33
|
+
type: "string",
|
|
34
|
+
name: "phone"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
const tableNameWithSchema = collection.getTableNameWithSchema();
|
|
39
|
+
const field = collection.getField("phone");
|
|
40
|
+
const exists = await field.existsInDb();
|
|
41
|
+
if (!exists) {
|
|
42
|
+
await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, field.columnName(), {
|
|
43
|
+
type: import_database.DataTypes.STRING
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
await this.db.sequelize.getQueryInterface().addConstraint(tableNameWithSchema, {
|
|
48
|
+
type: "unique",
|
|
49
|
+
fields: [field.columnName()]
|
|
50
|
+
});
|
|
51
|
+
} catch (error) {
|
|
52
|
+
}
|
|
53
|
+
this.db.removeCollection("users");
|
|
54
|
+
}
|
|
55
|
+
async down() {
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -22,11 +22,8 @@ __export(add_users_phone_exports, {
|
|
|
22
22
|
module.exports = __toCommonJS(add_users_phone_exports);
|
|
23
23
|
var import_server = require("@nocobase/server");
|
|
24
24
|
class AddUsersPhoneMigration extends import_server.Migration {
|
|
25
|
+
appVersion = "<0.7.5-alpha.1";
|
|
25
26
|
async up() {
|
|
26
|
-
const match = await this.app.version.satisfies("<=0.7.4-alpha.7");
|
|
27
|
-
if (!match) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
27
|
const Field = this.context.db.getRepository("fields");
|
|
31
28
|
const existed = await Field.count({
|
|
32
29
|
filter: {
|
|
@@ -49,9 +46,7 @@ class AddUsersPhoneMigration extends import_server.Migration {
|
|
|
49
46
|
"x-validator": "phone",
|
|
50
47
|
require: true
|
|
51
48
|
}
|
|
52
|
-
}
|
|
53
|
-
// NOTE: to trigger hook
|
|
54
|
-
context: {}
|
|
49
|
+
}
|
|
55
50
|
});
|
|
56
51
|
}
|
|
57
52
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var add_username_constraint_exports = {};
|
|
19
|
+
__export(add_username_constraint_exports, {
|
|
20
|
+
default: () => AddUserNameMigration
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(add_username_constraint_exports);
|
|
23
|
+
var import_database = require("@nocobase/database");
|
|
24
|
+
var import_server = require("@nocobase/server");
|
|
25
|
+
class AddUserNameMigration extends import_server.Migration {
|
|
26
|
+
on = "beforeLoad";
|
|
27
|
+
appVersion = "<0.13.0-alpha.1";
|
|
28
|
+
async up() {
|
|
29
|
+
const collection = this.db.collection({
|
|
30
|
+
name: "users",
|
|
31
|
+
fields: [
|
|
32
|
+
{
|
|
33
|
+
type: "string",
|
|
34
|
+
name: "username"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
const tableNameWithSchema = collection.getTableNameWithSchema();
|
|
39
|
+
const field = collection.getField("username");
|
|
40
|
+
const exists = await field.existsInDb();
|
|
41
|
+
if (!exists) {
|
|
42
|
+
await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, field.columnName(), {
|
|
43
|
+
type: import_database.DataTypes.STRING
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
await this.db.sequelize.getQueryInterface().addConstraint(tableNameWithSchema, {
|
|
48
|
+
type: "unique",
|
|
49
|
+
fields: [field.columnName()]
|
|
50
|
+
});
|
|
51
|
+
} catch (error) {
|
|
52
|
+
}
|
|
53
|
+
this.db.removeCollection("users");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -22,11 +22,8 @@ __export(add_username_exports, {
|
|
|
22
22
|
module.exports = __toCommonJS(add_username_exports);
|
|
23
23
|
var import_server = require("@nocobase/server");
|
|
24
24
|
class AddUserNameMigration extends import_server.Migration {
|
|
25
|
+
appVersion = "<0.13.0-alpha.1";
|
|
25
26
|
async up() {
|
|
26
|
-
const match = await this.app.version.satisfies("<=0.12.0-alpha.4");
|
|
27
|
-
if (!match) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
27
|
const Field = this.context.db.getRepository("fields");
|
|
31
28
|
const existed = await Field.count({
|
|
32
29
|
filter: {
|
|
@@ -49,12 +46,8 @@ class AddUserNameMigration extends import_server.Migration {
|
|
|
49
46
|
"x-validator": { username: true },
|
|
50
47
|
required: true
|
|
51
48
|
}
|
|
52
|
-
}
|
|
53
|
-
// NOTE: to trigger hook
|
|
54
|
-
context: {}
|
|
49
|
+
}
|
|
55
50
|
});
|
|
56
51
|
}
|
|
57
52
|
}
|
|
58
|
-
async down() {
|
|
59
|
-
}
|
|
60
53
|
}
|
|
@@ -22,11 +22,8 @@ __export(update_username_exports, {
|
|
|
22
22
|
module.exports = __toCommonJS(update_username_exports);
|
|
23
23
|
var import_server = require("@nocobase/server");
|
|
24
24
|
class UpdateUserNameMigration extends import_server.Migration {
|
|
25
|
+
appVersion = "<0.13.0-alpha.1";
|
|
25
26
|
async up() {
|
|
26
|
-
const match = await this.app.version.satisfies("<=0.12.0-alpha.4");
|
|
27
|
-
if (!match) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
27
|
const repo = this.context.db.getRepository("users");
|
|
31
28
|
const user = await repo.findOne({
|
|
32
29
|
filter: {
|
|
@@ -22,6 +22,7 @@ __export(update_username_interface_exports, {
|
|
|
22
22
|
module.exports = __toCommonJS(update_username_interface_exports);
|
|
23
23
|
var import_server = require("@nocobase/server");
|
|
24
24
|
class UpdateUserNameInterfaceMigration extends import_server.Migration {
|
|
25
|
+
appVersion = "<0.13.0-alpha.10";
|
|
25
26
|
async up() {
|
|
26
27
|
const match = await this.app.version.satisfies("<=0.13.0-alpha.8");
|
|
27
28
|
if (!match) {
|
package/dist/server/server.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { Plugin } from '@nocobase/server';
|
|
2
|
-
export
|
|
3
|
-
name?: string;
|
|
4
|
-
}
|
|
5
|
-
export default class UsersPlugin extends Plugin<UserPluginConfig> {
|
|
6
|
-
constructor(app: any, options: any);
|
|
2
|
+
export default class PluginUsersServer extends Plugin {
|
|
7
3
|
beforeLoad(): Promise<void>;
|
|
8
4
|
load(): Promise<void>;
|
|
9
5
|
getInstallingData(options?: any): {
|
package/dist/server/server.js
CHANGED
|
@@ -27,30 +27,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
var server_exports = {};
|
|
29
29
|
__export(server_exports, {
|
|
30
|
-
default: () =>
|
|
30
|
+
default: () => PluginUsersServer
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(server_exports);
|
|
33
33
|
var import_database = require("@nocobase/database");
|
|
34
34
|
var import_server = require("@nocobase/server");
|
|
35
35
|
var import_utils = require("@nocobase/utils");
|
|
36
36
|
var import_path = require("path");
|
|
37
|
-
var import__ = require("./");
|
|
38
37
|
var actions = __toESM(require("./actions/users"));
|
|
39
|
-
|
|
40
|
-
class UsersPlugin extends import_server.Plugin {
|
|
41
|
-
constructor(app, options) {
|
|
42
|
-
super(app, options);
|
|
43
|
-
}
|
|
38
|
+
class PluginUsersServer extends import_server.Plugin {
|
|
44
39
|
async beforeLoad() {
|
|
45
|
-
this.app.i18n.addResources("zh-CN", import__.namespace, import_locale.zhCN);
|
|
46
|
-
this.app.i18n.addResources("en-US", import__.namespace, import_locale.enUS);
|
|
47
|
-
const cmd = this.app.findCommand("install");
|
|
48
|
-
if (cmd) {
|
|
49
|
-
cmd.requiredOption("-u, --root-username <rootUsername>", "", process.env.INIT_ROOT_USERNAME);
|
|
50
|
-
cmd.requiredOption("-e, --root-email <rootEmail>", "", process.env.INIT_ROOT_EMAIL);
|
|
51
|
-
cmd.requiredOption("-p, --root-password <rootPassword>", "", process.env.INIT_ROOT_PASSWORD);
|
|
52
|
-
cmd.option("-n, --root-nickname <rootNickname>");
|
|
53
|
-
}
|
|
54
40
|
this.db.registerOperators({
|
|
55
41
|
$isCurrentUser(_, ctx) {
|
|
56
42
|
var _a, _b, _c, _d;
|
|
@@ -127,9 +113,7 @@ class UsersPlugin extends import_server.Plugin {
|
|
|
127
113
|
loggedInActions.forEach((action) => this.app.acl.allow("users", action, "loggedIn"));
|
|
128
114
|
}
|
|
129
115
|
async load() {
|
|
130
|
-
await this.
|
|
131
|
-
directory: (0, import_path.resolve)(__dirname, "collections")
|
|
132
|
-
});
|
|
116
|
+
await this.importCollections((0, import_path.resolve)(__dirname, "collections"));
|
|
133
117
|
this.db.addMigrations({
|
|
134
118
|
namespace: "users",
|
|
135
119
|
directory: (0, import_path.resolve)(__dirname, "migrations"),
|
|
@@ -142,8 +126,8 @@ class UsersPlugin extends import_server.Plugin {
|
|
|
142
126
|
var _a;
|
|
143
127
|
const { INIT_ROOT_NICKNAME, INIT_ROOT_PASSWORD, INIT_ROOT_EMAIL, INIT_ROOT_USERNAME } = process.env;
|
|
144
128
|
const {
|
|
145
|
-
rootEmail = INIT_ROOT_EMAIL,
|
|
146
|
-
rootPassword = INIT_ROOT_PASSWORD,
|
|
129
|
+
rootEmail = INIT_ROOT_EMAIL || "admin@nocobase.com",
|
|
130
|
+
rootPassword = INIT_ROOT_PASSWORD || "admin123",
|
|
147
131
|
rootNickname = INIT_ROOT_NICKNAME || "Super Admin",
|
|
148
132
|
rootUsername = INIT_ROOT_USERNAME || "nocobase"
|
|
149
133
|
} = options.users || ((_a = options == null ? void 0 : options.cliArgs) == null ? void 0 : _a[0]) || {};
|
package/package.json
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
"name": "@nocobase/plugin-users",
|
|
3
3
|
"displayName": "Users",
|
|
4
4
|
"displayName.zh-CN": "用户",
|
|
5
|
-
"description": "Provides a basic user model
|
|
6
|
-
"description.zh-CN": "
|
|
7
|
-
"version": "0.
|
|
5
|
+
"description": "Provides a basic user model, as well as createdBy and updatedBy fields..",
|
|
6
|
+
"description.zh-CN": "提供了基础的用户模型,以及创建人和最后更新人字段。",
|
|
7
|
+
"version": "0.19.0-alpha.10",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
|
+
"homepage": "https://docs.nocobase.com/plugins/users",
|
|
11
|
+
"homepage.zh-CN": "https://docs-cn.nocobase.com/plugins/users",
|
|
10
12
|
"devDependencies": {
|
|
11
13
|
"@types/jsonwebtoken": "^8.5.8",
|
|
12
14
|
"jsonwebtoken": "^8.5.1"
|
|
@@ -22,5 +24,8 @@
|
|
|
22
24
|
"@nocobase/test": "0.x",
|
|
23
25
|
"@nocobase/utils": "0.x"
|
|
24
26
|
},
|
|
25
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "d09d81eba67339da36bcec27939a85b35d180770",
|
|
28
|
+
"keywords": [
|
|
29
|
+
"Users & permissions"
|
|
30
|
+
]
|
|
26
31
|
}
|
package/server.d.ts
ADDED
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/server/index.js');
|