@nocobase/plugin-users 0.21.0-alpha.9 → 1.0.0-alpha.2

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.
@@ -1,15 +1,16 @@
1
1
  module.exports = {
2
2
  "react": "18.2.0",
3
3
  "antd": "5.12.8",
4
- "@nocobase/client": "0.21.0-alpha.9",
4
+ "@nocobase/client": "1.0.0-alpha.2",
5
5
  "@formily/react": "2.3.0",
6
6
  "@formily/core": "2.3.0",
7
- "@nocobase/plugin-acl": "0.21.0-alpha.9",
7
+ "@nocobase/plugin-acl": "1.0.0-alpha.2",
8
8
  "react-i18next": "11.18.6",
9
- "@nocobase/database": "0.21.0-alpha.9",
10
- "@nocobase/server": "0.21.0-alpha.9",
11
- "@nocobase/utils": "0.21.0-alpha.9",
12
- "@nocobase/cache": "0.21.0-alpha.9",
9
+ "@nocobase/database": "1.0.0-alpha.2",
10
+ "@nocobase/server": "1.0.0-alpha.2",
11
+ "@nocobase/utils": "1.0.0-alpha.2",
12
+ "@nocobase/cache": "1.0.0-alpha.2",
13
13
  "@formily/shared": "2.3.0",
14
- "@nocobase/actions": "0.21.0-alpha.9"
14
+ "@nocobase/actions": "1.0.0-alpha.2",
15
+ "lodash": "4.17.21"
15
16
  };
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
  var users_exports = {};
19
29
  __export(users_exports, {
@@ -22,8 +32,9 @@ __export(users_exports, {
22
32
  });
23
33
  module.exports = __toCommonJS(users_exports);
24
34
  var import_actions = require("@nocobase/actions");
35
+ var import_lodash = __toESM(require("lodash"));
25
36
  async function updateProfile(ctx, next) {
26
- const { values } = ctx.action.params;
37
+ const values = ctx.action.params.values || {};
27
38
  const { currentUser } = ctx.state;
28
39
  if (!currentUser) {
29
40
  ctx.throw(401);
@@ -31,7 +42,7 @@ async function updateProfile(ctx, next) {
31
42
  const UserRepo = ctx.db.getRepository("users");
32
43
  const result = await UserRepo.update({
33
44
  filterByTk: currentUser.id,
34
- values
45
+ values: import_lodash.default.pick(values, ["nickname", "username", "email", "phone", "systemSettings", "appLang"])
35
46
  });
36
47
  ctx.body = result;
37
48
  await next();
@@ -117,6 +117,36 @@ var users_default = (0, import_database.defineCollection)({
117
117
  type: "json",
118
118
  name: "systemSettings",
119
119
  defaultValue: {}
120
+ },
121
+ {
122
+ uiSchema: {
123
+ "x-component-props": {
124
+ dateFormat: "YYYY-MM-DD"
125
+ },
126
+ type: "datetime",
127
+ title: '{{t("Created at")}}',
128
+ "x-component": "DatePicker",
129
+ "x-read-pretty": true
130
+ },
131
+ name: "createdAt",
132
+ type: "date",
133
+ field: "createdAt",
134
+ interface: "createdAt"
135
+ },
136
+ {
137
+ uiSchema: {
138
+ "x-component-props": {
139
+ dateFormat: "YYYY-MM-DD"
140
+ },
141
+ type: "datetime",
142
+ title: '{{t("Last updated at")}}',
143
+ "x-component": "DatePicker",
144
+ "x-read-pretty": true
145
+ },
146
+ name: "updatedAt",
147
+ type: "date",
148
+ field: "updatedAt",
149
+ interface: "updatedAt"
120
150
  }
121
151
  ]
122
152
  });
@@ -0,0 +1,6 @@
1
+ import { Migration } from '@nocobase/server';
2
+ export default class extends Migration {
3
+ on: string;
4
+ appVersion: string;
5
+ up(): Promise<void>;
6
+ }
@@ -0,0 +1,137 @@
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 update_system_fields_exports = {};
19
+ __export(update_system_fields_exports, {
20
+ default: () => update_system_fields_default
21
+ });
22
+ module.exports = __toCommonJS(update_system_fields_exports);
23
+ var import_server = require("@nocobase/server");
24
+ class update_system_fields_default extends import_server.Migration {
25
+ on = "afterLoad";
26
+ // 'beforeLoad' or 'afterLoad'
27
+ appVersion = "<0.21.0-alpha.11";
28
+ async up() {
29
+ const Field = this.context.db.getRepository("fields");
30
+ const createdByField = await Field.findOne({
31
+ filter: {
32
+ name: "createdBy",
33
+ collectionName: "users",
34
+ interface: null
35
+ }
36
+ });
37
+ if (createdByField) {
38
+ await createdByField.update({
39
+ interface: "createdBy",
40
+ options: {
41
+ ...createdByField.options,
42
+ uiSchema: {
43
+ type: "object",
44
+ title: '{{t("Created by")}}',
45
+ "x-component": "AssociationField",
46
+ "x-component-props": {
47
+ fieldNames: {
48
+ value: "id",
49
+ label: "nickname"
50
+ }
51
+ },
52
+ "x-read-pretty": true
53
+ }
54
+ }
55
+ });
56
+ }
57
+ const updatedByField = await Field.findOne({
58
+ filter: {
59
+ name: "updatedBy",
60
+ collectionName: "users",
61
+ interface: null
62
+ }
63
+ });
64
+ if (updatedByField) {
65
+ await updatedByField.update({
66
+ interface: "updatedBy",
67
+ options: {
68
+ ...updatedByField.options,
69
+ uiSchema: {
70
+ type: "object",
71
+ title: '{{t("Last updated by")}}',
72
+ "x-component": "AssociationField",
73
+ "x-component-props": {
74
+ fieldNames: {
75
+ value: "id",
76
+ label: "nickname"
77
+ }
78
+ },
79
+ "x-read-pretty": true
80
+ }
81
+ }
82
+ });
83
+ }
84
+ const createdAtField = await Field.count({
85
+ filter: {
86
+ name: "createdAt",
87
+ collectionName: "users"
88
+ }
89
+ });
90
+ if (!createdAtField) {
91
+ await Field.create({
92
+ values: {
93
+ collectionName: "users",
94
+ uiSchema: {
95
+ "x-component-props": {
96
+ dateFormat: "YYYY-MM-DD"
97
+ },
98
+ type: "datetime",
99
+ title: '{{t("Created at")}}',
100
+ "x-component": "DatePicker",
101
+ "x-read-pretty": true
102
+ },
103
+ name: "createdAt",
104
+ field: "createdAt",
105
+ type: "date",
106
+ interface: "createdAt"
107
+ }
108
+ });
109
+ }
110
+ const updatedAtField = await Field.count({
111
+ filter: {
112
+ name: "updatedAt",
113
+ collectionName: "users"
114
+ }
115
+ });
116
+ if (!updatedAtField) {
117
+ await Field.create({
118
+ values: {
119
+ collectionName: "users",
120
+ uiSchema: {
121
+ "x-component-props": {
122
+ dateFormat: "YYYY-MM-DD"
123
+ },
124
+ type: "datetime",
125
+ title: '{{t("Last updated at")}}',
126
+ "x-component": "DatePicker",
127
+ "x-read-pretty": true
128
+ },
129
+ name: "updatedAt",
130
+ field: "updatedAt",
131
+ type: "date",
132
+ interface: "updatedAt"
133
+ }
134
+ });
135
+ }
136
+ }
137
+ }
@@ -98,7 +98,20 @@ class PluginUsersServer extends import_server.Plugin {
98
98
  type: "belongsTo",
99
99
  target: "users",
100
100
  foreignKey: "createdById",
101
- targetKey: "id"
101
+ targetKey: "id",
102
+ uiSchema: {
103
+ type: "object",
104
+ title: '{{t("Created by")}}',
105
+ "x-component": "AssociationField",
106
+ "x-component-props": {
107
+ fieldNames: {
108
+ value: "id",
109
+ label: "nickname"
110
+ }
111
+ },
112
+ "x-read-pretty": true
113
+ },
114
+ interface: "createdBy"
102
115
  });
103
116
  }
104
117
  if (updatedBy === true) {
@@ -113,7 +126,20 @@ class PluginUsersServer extends import_server.Plugin {
113
126
  type: "belongsTo",
114
127
  target: "users",
115
128
  foreignKey: "updatedById",
116
- targetKey: "id"
129
+ targetKey: "id",
130
+ uiSchema: {
131
+ type: "object",
132
+ title: '{{t("Last updated by")}}',
133
+ "x-component": "AssociationField",
134
+ "x-component-props": {
135
+ fieldNames: {
136
+ value: "id",
137
+ label: "nickname"
138
+ }
139
+ },
140
+ "x-read-pretty": true
141
+ },
142
+ interface: "updatedBy"
117
143
  });
118
144
  }
119
145
  });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "用户",
5
5
  "description": "Provides basic user model, as well as created by and updated by fields.",
6
6
  "description.zh-CN": "提供了基础的用户模型,以及创建人和最后更新人字段。",
7
- "version": "0.21.0-alpha.9",
7
+ "version": "1.0.0-alpha.2",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/users",
@@ -14,17 +14,17 @@
14
14
  "jsonwebtoken": "^8.5.1"
15
15
  },
16
16
  "peerDependencies": {
17
- "@nocobase/actions": "0.x",
18
- "@nocobase/client": "0.x",
19
- "@nocobase/database": "0.x",
20
- "@nocobase/plugin-acl": "0.x",
21
- "@nocobase/plugin-auth": "0.x",
22
- "@nocobase/resourcer": "0.x",
23
- "@nocobase/server": "0.x",
24
- "@nocobase/test": "0.x",
25
- "@nocobase/utils": "0.x"
17
+ "@nocobase/actions": "1.x",
18
+ "@nocobase/client": "1.x",
19
+ "@nocobase/database": "1.x",
20
+ "@nocobase/plugin-acl": "1.x",
21
+ "@nocobase/plugin-auth": "1.x",
22
+ "@nocobase/resourcer": "1.x",
23
+ "@nocobase/server": "1.x",
24
+ "@nocobase/test": "1.x",
25
+ "@nocobase/utils": "1.x"
26
26
  },
27
- "gitHead": "a6fe6c4ee532c04e5a50ec777bf76436ca624cbd",
27
+ "gitHead": "f89dbc9e67d58404a2e484a5e124f739f340dcf8",
28
28
  "keywords": [
29
29
  "Users & permissions"
30
30
  ]