@nocobase/plugin-users 1.2.12-alpha → 1.3.0-alpha.20240710084543

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.
Files changed (57) hide show
  1. package/package.json +2 -2
  2. package/dist/client/PasswordField.d.ts +0 -10
  3. package/dist/client/RoleUsersManager.d.ts +0 -10
  4. package/dist/client/UserRolesField.d.ts +0 -10
  5. package/dist/client/UsersManagement.d.ts +0 -10
  6. package/dist/client/hooks.d.ts +0 -13
  7. package/dist/client/index.d.ts +0 -13
  8. package/dist/client/index.js +0 -10
  9. package/dist/client/locale.d.ts +0 -9
  10. package/dist/client/schemas/users.d.ts +0 -173
  11. package/dist/client/utils.d.ts +0 -9
  12. package/dist/externalVersion.js +0 -25
  13. package/dist/index.d.ts +0 -10
  14. package/dist/index.js +0 -48
  15. package/dist/locale/en-US.json +0 -7
  16. package/dist/locale/zh-CN.json +0 -7
  17. package/dist/server/actions/users.d.ts +0 -11
  18. package/dist/server/actions/users.js +0 -98
  19. package/dist/server/collections/users.d.ts +0 -10
  20. package/dist/server/collections/users.js +0 -161
  21. package/dist/server/index.d.ts +0 -10
  22. package/dist/server/index.js +0 -49
  23. package/dist/server/locale/en-US.d.ts +0 -17
  24. package/dist/server/locale/en-US.js +0 -39
  25. package/dist/server/locale/es-ES.d.ts +0 -17
  26. package/dist/server/locale/es-ES.js +0 -39
  27. package/dist/server/locale/fr-FR.d.ts +0 -17
  28. package/dist/server/locale/fr-FR.js +0 -39
  29. package/dist/server/locale/index.d.ts +0 -11
  30. package/dist/server/locale/index.js +0 -52
  31. package/dist/server/locale/ja-JP.d.ts +0 -13
  32. package/dist/server/locale/ja-JP.js +0 -35
  33. package/dist/server/locale/pt-BR.d.ts +0 -17
  34. package/dist/server/locale/pt-BR.js +0 -39
  35. package/dist/server/locale/zh-CN.d.ts +0 -17
  36. package/dist/server/locale/zh-CN.js +0 -39
  37. package/dist/server/migrations/20220818072639-add-users-phone-constraint.d.ts +0 -15
  38. package/dist/server/migrations/20220818072639-add-users-phone-constraint.js +0 -66
  39. package/dist/server/migrations/20220818072639-add-users-phone.d.ts +0 -14
  40. package/dist/server/migrations/20220818072639-add-users-phone.js +0 -64
  41. package/dist/server/migrations/20230802170800-add-username-constraint.d.ts +0 -14
  42. package/dist/server/migrations/20230802170800-add-username-constraint.js +0 -64
  43. package/dist/server/migrations/20230802170800-add-username.d.ts +0 -13
  44. package/dist/server/migrations/20230802170800-add-username.js +0 -62
  45. package/dist/server/migrations/20230802183100-update-username.d.ts +0 -14
  46. package/dist/server/migrations/20230802183100-update-username.js +0 -56
  47. package/dist/server/migrations/20230908164036-update-username-interface.d.ts +0 -14
  48. package/dist/server/migrations/20230908164036-update-username-interface.js +0 -55
  49. package/dist/server/migrations/20240410152410-update-phone-interface.d.ts +0 -14
  50. package/dist/server/migrations/20240410152410-update-phone-interface.js +0 -62
  51. package/dist/server/migrations/20240418101937-update-system-fields.d.ts +0 -14
  52. package/dist/server/migrations/20240418101937-update-system-fields.js +0 -146
  53. package/dist/server/models/UserModel.d.ts +0 -12
  54. package/dist/server/models/UserModel.js +0 -49
  55. package/dist/server/server.d.ts +0 -20
  56. package/dist/server/server.js +0 -234
  57. package/dist/swagger/index.json +0 -117
@@ -1,12 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
- import { Model } from '@nocobase/database';
10
- export declare class UserModel extends Model {
11
- desensitize(): UserModel;
12
- }
@@ -1,49 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- var __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var UserModel_exports = {};
28
- __export(UserModel_exports, {
29
- UserModel: () => UserModel
30
- });
31
- module.exports = __toCommonJS(UserModel_exports);
32
- var import_database = require("@nocobase/database");
33
- class UserModel extends import_database.Model {
34
- desensitize() {
35
- const { fields } = this.constructor.collection;
36
- const result = this.constructor.build({}, { isNewRecord: this.isNewRecord });
37
- for (const [name, value] of Object.entries(this.get())) {
38
- const field = fields.get(name);
39
- if (field && !field.options.hidden) {
40
- result.set(name, value);
41
- }
42
- }
43
- return result;
44
- }
45
- }
46
- // Annotate the CommonJS export names for ESM import in node:
47
- 0 && (module.exports = {
48
- UserModel
49
- });
@@ -1,20 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
- import { Plugin } from '@nocobase/server';
10
- export default class PluginUsersServer extends Plugin {
11
- beforeLoad(): Promise<void>;
12
- load(): Promise<void>;
13
- getInstallingData(options?: any): {
14
- rootEmail: any;
15
- rootPassword: any;
16
- rootNickname: any;
17
- rootUsername: any;
18
- };
19
- install(options: any): Promise<void>;
20
- }
@@ -1,234 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- var __create = Object.create;
11
- var __defProp = Object.defineProperty;
12
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
- var __getOwnPropNames = Object.getOwnPropertyNames;
14
- var __getProtoOf = Object.getPrototypeOf;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __export = (target, all) => {
17
- for (var name in all)
18
- __defProp(target, name, { get: all[name], enumerable: true });
19
- };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") {
22
- for (let key of __getOwnPropNames(from))
23
- if (!__hasOwnProp.call(to, key) && key !== except)
24
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
- }
26
- return to;
27
- };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
36
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
- var server_exports = {};
38
- __export(server_exports, {
39
- default: () => PluginUsersServer
40
- });
41
- module.exports = __toCommonJS(server_exports);
42
- var import_database = require("@nocobase/database");
43
- var import_server = require("@nocobase/server");
44
- var import_utils = require("@nocobase/utils");
45
- var import_path = require("path");
46
- var actions = __toESM(require("./actions/users"));
47
- var import_UserModel = require("./models/UserModel");
48
- class PluginUsersServer extends import_server.Plugin {
49
- async beforeLoad() {
50
- this.db.registerModels({
51
- UserModel: import_UserModel.UserModel
52
- });
53
- this.db.registerOperators({
54
- $isCurrentUser(_, ctx) {
55
- var _a, _b, _c, _d;
56
- return {
57
- [import_database.Op.eq]: ((_d = (_c = (_b = (_a = ctx == null ? void 0 : ctx.app) == null ? void 0 : _a.ctx) == null ? void 0 : _b.state) == null ? void 0 : _c.currentUser) == null ? void 0 : _d.id) || -1
58
- };
59
- },
60
- $isNotCurrentUser(_, ctx) {
61
- var _a, _b, _c, _d;
62
- return {
63
- [import_database.Op.ne]: ((_d = (_c = (_b = (_a = ctx == null ? void 0 : ctx.app) == null ? void 0 : _a.ctx) == null ? void 0 : _b.state) == null ? void 0 : _c.currentUser) == null ? void 0 : _d.id) || -1
64
- };
65
- },
66
- $isVar(val, ctx) {
67
- var _a, _b;
68
- const obj = (0, import_utils.parse)({ val: `{{${val}}}` })(JSON.parse(JSON.stringify((_b = (_a = ctx == null ? void 0 : ctx.app) == null ? void 0 : _a.ctx) == null ? void 0 : _b.state)));
69
- return {
70
- [import_database.Op.eq]: obj.val
71
- };
72
- }
73
- });
74
- this.db.on("field.afterAdd", ({ collection, field }) => {
75
- if (field.options.interface === "createdBy") {
76
- collection.setField("createdById", {
77
- type: "context",
78
- dataType: "bigInt",
79
- dataIndex: "state.currentUser.id",
80
- createOnly: true,
81
- visible: true,
82
- index: true
83
- });
84
- }
85
- if (field.options.interface === "updatedBy") {
86
- collection.setField("updatedById", {
87
- type: "context",
88
- dataType: "bigInt",
89
- dataIndex: "state.currentUser.id",
90
- visible: true,
91
- index: true
92
- });
93
- }
94
- });
95
- this.db.on("afterDefineCollection", (collection) => {
96
- const { createdBy, updatedBy } = collection.options;
97
- if (createdBy === true) {
98
- collection.setField("createdById", {
99
- type: "context",
100
- dataType: "bigInt",
101
- dataIndex: "state.currentUser.id",
102
- createOnly: true,
103
- visible: true,
104
- index: true
105
- });
106
- collection.setField("createdBy", {
107
- type: "belongsTo",
108
- target: "users",
109
- foreignKey: "createdById",
110
- targetKey: "id",
111
- uiSchema: {
112
- type: "object",
113
- title: '{{t("Created by")}}',
114
- "x-component": "AssociationField",
115
- "x-component-props": {
116
- fieldNames: {
117
- value: "id",
118
- label: "nickname"
119
- }
120
- },
121
- "x-read-pretty": true
122
- },
123
- interface: "createdBy"
124
- });
125
- }
126
- if (updatedBy === true) {
127
- collection.setField("updatedById", {
128
- type: "context",
129
- dataType: "bigInt",
130
- dataIndex: "state.currentUser.id",
131
- visible: true,
132
- index: true
133
- });
134
- collection.setField("updatedBy", {
135
- type: "belongsTo",
136
- target: "users",
137
- foreignKey: "updatedById",
138
- targetKey: "id",
139
- uiSchema: {
140
- type: "object",
141
- title: '{{t("Last updated by")}}',
142
- "x-component": "AssociationField",
143
- "x-component-props": {
144
- fieldNames: {
145
- value: "id",
146
- label: "nickname"
147
- }
148
- },
149
- "x-read-pretty": true
150
- },
151
- interface: "updatedBy"
152
- });
153
- }
154
- });
155
- for (const [key, action] of Object.entries(actions)) {
156
- this.app.resourcer.registerActionHandler(`users:${key}`, action);
157
- }
158
- this.app.acl.addFixedParams("users", "destroy", () => {
159
- return {
160
- filter: {
161
- "id.$ne": 1
162
- }
163
- };
164
- });
165
- this.app.acl.addFixedParams("collections", "destroy", () => {
166
- return {
167
- filter: {
168
- "name.$ne": "users"
169
- }
170
- };
171
- });
172
- const loggedInActions = ["updateProfile"];
173
- loggedInActions.forEach((action) => this.app.acl.allow("users", action, "loggedIn"));
174
- this.app.acl.registerSnippet({
175
- name: `pm.${this.name}`,
176
- actions: ["users:*"]
177
- });
178
- }
179
- async load() {
180
- await this.importCollections((0, import_path.resolve)(__dirname, "collections"));
181
- this.db.addMigrations({
182
- namespace: "users",
183
- directory: (0, import_path.resolve)(__dirname, "migrations"),
184
- context: {
185
- plugin: this
186
- }
187
- });
188
- this.app.resourcer.use(async (ctx, next) => {
189
- await next();
190
- const { associatedName, resourceName, actionName, values } = ctx.action.params;
191
- const cache = ctx.app.cache;
192
- if (associatedName === "roles" && resourceName === "users" && ["add", "remove", "set"].includes(actionName) && (values == null ? void 0 : values.length)) {
193
- for (const userId of values) {
194
- await cache.del(`roles:${userId}`);
195
- }
196
- }
197
- });
198
- }
199
- getInstallingData(options = {}) {
200
- var _a;
201
- const { INIT_ROOT_NICKNAME, INIT_ROOT_PASSWORD, INIT_ROOT_EMAIL, INIT_ROOT_USERNAME } = process.env;
202
- const {
203
- rootEmail = INIT_ROOT_EMAIL || "admin@nocobase.com",
204
- rootPassword = INIT_ROOT_PASSWORD || "admin123",
205
- rootNickname = INIT_ROOT_NICKNAME || "Super Admin",
206
- rootUsername = INIT_ROOT_USERNAME || "nocobase"
207
- } = options.users || ((_a = options == null ? void 0 : options.cliArgs) == null ? void 0 : _a[0]) || {};
208
- return {
209
- rootEmail,
210
- rootPassword,
211
- rootNickname,
212
- rootUsername
213
- };
214
- }
215
- async install(options) {
216
- const { rootNickname, rootPassword, rootEmail, rootUsername } = this.getInstallingData(options);
217
- const User = this.db.getCollection("users");
218
- if (await User.repository.findOne({ filter: { email: rootEmail } })) {
219
- return;
220
- }
221
- await User.repository.create({
222
- values: {
223
- email: rootEmail,
224
- password: rootPassword,
225
- nickname: rootNickname,
226
- username: rootUsername
227
- }
228
- });
229
- const repo = this.db.getRepository("collections");
230
- if (repo) {
231
- await repo.db2cm("users");
232
- }
233
- }
234
- }
@@ -1,117 +0,0 @@
1
- {
2
- "openapi": "3.0.2",
3
- "info": {
4
- "title": "NocoBase API - Users plugin"
5
- },
6
- "tags": [],
7
- "paths": {
8
- "/users:list": {
9
- "get": {
10
- "tags": ["users"],
11
- "description": "",
12
- "parameters": [],
13
- "responses": {
14
- "200": {
15
- "description": "OK"
16
- }
17
- }
18
- }
19
- },
20
- "/users:get": {
21
- "get": {
22
- "tags": ["users"],
23
- "description": "",
24
- "parameters": [],
25
- "responses": {
26
- "200": {
27
- "description": "OK"
28
- }
29
- }
30
- }
31
- },
32
- "/users:create": {
33
- "post": {
34
- "tags": ["users"],
35
- "description": "",
36
- "parameters": [],
37
- "responses": {
38
- "200": {
39
- "description": "OK"
40
- }
41
- }
42
- }
43
- },
44
- "/users:update": {
45
- "post": {
46
- "tags": ["users"],
47
- "description": "",
48
- "parameters": [],
49
- "responses": {
50
- "200": {
51
- "description": "OK"
52
- }
53
- }
54
- }
55
- },
56
- "/users:updateProfile": {
57
- "post": {
58
- "tags": ["users"],
59
- "description": "",
60
- "parameters": [],
61
- "responses": {
62
- "200": {
63
- "description": "OK"
64
- }
65
- }
66
- }
67
- },
68
- "/users:changePassword": {
69
- "post": {
70
- "tags": ["users"],
71
- "description": "",
72
- "parameters": [],
73
- "responses": {
74
- "200": {
75
- "description": "OK"
76
- }
77
- }
78
- }
79
- },
80
- "/users:destroy": {
81
- "post": {
82
- "tags": ["users"],
83
- "description": "",
84
- "parameters": [],
85
- "responses": {
86
- "200": {
87
- "description": "OK"
88
- }
89
- }
90
- }
91
- },
92
- "/{collectionName}/{collectionIndex}/createdBy:get": {
93
- "post": {
94
- "tags": ["$collection.createdBy"],
95
- "description": "",
96
- "parameters": [],
97
- "responses": {
98
- "200": {
99
- "description": "OK"
100
- }
101
- }
102
- }
103
- },
104
- "/{collectionName}/{collectionIndex}/updatedBy:get": {
105
- "post": {
106
- "tags": ["$collection.updatedBy"],
107
- "description": "",
108
- "parameters": [],
109
- "responses": {
110
- "200": {
111
- "description": "OK"
112
- }
113
- }
114
- }
115
- }
116
- }
117
- }