@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 ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/client';
2
+ export { default } from './dist/client';
package/client.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client/index.js');
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from '@nocobase/client';
2
- declare class UsersPlugin extends Plugin {
2
+ export declare class PluginUsersClient extends Plugin {
3
3
  load(): Promise<void>;
4
4
  }
5
- export default UsersPlugin;
5
+ export default PluginUsersClient;
@@ -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 l=(e,n,o)=>new Promise((u,d)=>{var c=i=>{try{s(o.next(i))}catch(t){d(t)}},f=i=>{try{s(o.throw(i))}catch(t){d(t)}},s=i=>i.done?u(i.value):Promise.resolve(i.value).then(c,f);s((o=o.apply(e,n)).next())});class o extends n.Plugin{load(){return l(this,null,function*(){})}}e.default=o,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
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"}})});
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
- "@nocobase/client": "0.18.0-alpha.9",
3
- "@nocobase/database": "0.18.0-alpha.9",
4
- "@nocobase/server": "0.18.0-alpha.9",
5
- "@nocobase/utils": "0.18.0-alpha.9",
6
- "@nocobase/actions": "0.18.0-alpha.9"
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
  };
@@ -1,3 +1,2 @@
1
- import { CollectionOptions } from '@nocobase/database';
2
- declare const _default: CollectionOptions;
1
+ declare const _default: import("@nocobase/database").CollectionOptions;
3
2
  export default _default;
@@ -20,11 +20,11 @@ __export(users_exports, {
20
20
  default: () => users_default
21
21
  });
22
22
  module.exports = __toCommonJS(users_exports);
23
- var users_default = {
24
- namespace: "users.users",
25
- duplicator: {
26
- dumpable: "optional",
27
- with: "rolesUsers"
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,7 @@
1
+ import { Migration } from '@nocobase/server';
2
+ export default class AddUsersPhoneMigration extends Migration {
3
+ on: string;
4
+ appVersion: string;
5
+ up(): Promise<void>;
6
+ down(): Promise<void>;
7
+ }
@@ -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
+ }
@@ -1,5 +1,6 @@
1
1
  import { Migration } from '@nocobase/server';
2
2
  export default class AddUsersPhoneMigration extends Migration {
3
+ appVersion: string;
3
4
  up(): Promise<void>;
4
5
  down(): Promise<void>;
5
6
  }
@@ -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,6 @@
1
+ import { Migration } from '@nocobase/server';
2
+ export default class AddUserNameMigration extends Migration {
3
+ on: string;
4
+ appVersion: string;
5
+ up(): Promise<void>;
6
+ }
@@ -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
+ }
@@ -1,5 +1,5 @@
1
1
  import { Migration } from '@nocobase/server';
2
2
  export default class AddUserNameMigration extends Migration {
3
+ appVersion: string;
3
4
  up(): Promise<void>;
4
- down(): Promise<void>;
5
5
  }
@@ -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
  }
@@ -1,5 +1,6 @@
1
1
  import { Migration } from '@nocobase/server';
2
2
  export default class UpdateUserNameMigration extends Migration {
3
+ appVersion: string;
3
4
  up(): Promise<void>;
4
5
  down(): Promise<void>;
5
6
  }
@@ -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: {
@@ -1,5 +1,6 @@
1
1
  import { Migration } from '@nocobase/server';
2
2
  export default class UpdateUserNameInterfaceMigration extends Migration {
3
+ appVersion: string;
3
4
  up(): Promise<void>;
4
5
  down(): Promise<void>;
5
6
  }
@@ -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) {
@@ -1,9 +1,5 @@
1
1
  import { Plugin } from '@nocobase/server';
2
- export interface UserPluginConfig {
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): {
@@ -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: () => UsersPlugin
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
- var import_locale = require("./locale");
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.db.import({
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 and a password-based user authentication type, and extended the createdBy and updatedBy field types",
6
- "description.zh-CN": "提供了基础的用户模型和基于密码的用户认证方式,并拓展了创建人和最后更新人字段类型",
7
- "version": "0.18.0-alpha.9",
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": "34ca0df4eede2e83fc86297b0fe19eba970e2b1b"
27
+ "gitHead": "d09d81eba67339da36bcec27939a85b35d180770",
28
+ "keywords": [
29
+ "Users & permissions"
30
+ ]
26
31
  }
package/server.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/server';
2
+ export { default } from './dist/server';
package/server.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/server/index.js');