files.com 1.0.191 → 1.0.194
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/_VERSION +1 -1
- package/docs/models/Site.md +2 -0
- package/docs/models/User.md +6 -0
- package/lib/Errors.js +17 -18
- package/lib/models/User.js +9 -0
- package/package.json +1 -1
- package/src/Errors.js +11 -12
- package/src/models/User.js +10 -0
package/_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.194
|
package/docs/models/Site.md
CHANGED
@@ -178,6 +178,7 @@
|
|
178
178
|
"dav_permission": true,
|
179
179
|
"disabled": true,
|
180
180
|
"email": "john.doe@files.com",
|
181
|
+
"first_login_at": "2000-01-01T01:00:00Z",
|
181
182
|
"ftp_permission": true,
|
182
183
|
"group_ids": "",
|
183
184
|
"header_text": "User-specific message.",
|
@@ -209,6 +210,7 @@
|
|
209
210
|
"externally_managed": true,
|
210
211
|
"time_zone": "Pacific Time (US & Canada)",
|
211
212
|
"type_of_2fa": "yubi",
|
213
|
+
"updated_at": "2000-01-01T01:00:00Z",
|
212
214
|
"user_root": ""
|
213
215
|
},
|
214
216
|
"user_lockout": true,
|
package/docs/models/User.md
CHANGED
@@ -22,6 +22,7 @@
|
|
22
22
|
"dav_permission": true,
|
23
23
|
"disabled": true,
|
24
24
|
"email": "john.doe@files.com",
|
25
|
+
"first_login_at": "2000-01-01T01:00:00Z",
|
25
26
|
"ftp_permission": true,
|
26
27
|
"group_ids": "",
|
27
28
|
"header_text": "User-specific message.",
|
@@ -53,6 +54,7 @@
|
|
53
54
|
"externally_managed": true,
|
54
55
|
"time_zone": "Pacific Time (US & Canada)",
|
55
56
|
"type_of_2fa": "yubi",
|
57
|
+
"updated_at": "2000-01-01T01:00:00Z",
|
56
58
|
"user_root": ""
|
57
59
|
}
|
58
60
|
```
|
@@ -73,6 +75,7 @@
|
|
73
75
|
* `dav_permission` (boolean): Can the user connect with WebDAV?
|
74
76
|
* `disabled` (boolean): Is user disabled? Disabled users cannot log in, and do not count for billing purposes. Users can be automatically disabled after an inactivity period via a Site setting.
|
75
77
|
* `email` (email): User email address
|
78
|
+
* `first_login_at` (date-time): User's first login time
|
76
79
|
* `ftp_permission` (boolean): Can the user access with FTP/FTPS?
|
77
80
|
* `group_ids` (string): Comma-separated list of group IDs of which this user is a member
|
78
81
|
* `header_text` (string): Text to display to the user in the header of the UI
|
@@ -104,6 +107,7 @@
|
|
104
107
|
* `externally_managed` (boolean): Is this user managed by a SsoStrategy?
|
105
108
|
* `time_zone` (string): User time zone
|
106
109
|
* `type_of_2fa` (string): Type(s) of 2FA methods in use. Will be either `sms`, `totp`, `u2f`, `yubi`, or multiple values sorted alphabetically and joined by an underscore.
|
110
|
+
* `updated_at` (date-time): User record last updated at. Note this may be incremented because of internal or external updates.
|
107
111
|
* `user_root` (string): Root folder for FTP (and optionally SFTP if the appropriate site-wide setting is set.) Note that this is not used for API, Desktop, or Web interface.
|
108
112
|
* `avatar_file` (file): An image file for your user avatar.
|
109
113
|
* `avatar_delete` (boolean): If true, the avatar will be deleted.
|
@@ -414,6 +418,7 @@ await user.update({
|
|
414
418
|
"dav_permission": true,
|
415
419
|
"disabled": true,
|
416
420
|
"email": "john.doe@files.com",
|
421
|
+
"first_login_at": "2000-01-01T01:00:00Z",
|
417
422
|
"ftp_permission": true,
|
418
423
|
"group_ids": "",
|
419
424
|
"header_text": "User-specific message.",
|
@@ -445,6 +450,7 @@ await user.update({
|
|
445
450
|
"externally_managed": true,
|
446
451
|
"time_zone": "Pacific Time (US & Canada)",
|
447
452
|
"type_of_2fa": "yubi",
|
453
|
+
"updated_at": "2000-01-01T01:00:00Z",
|
448
454
|
"user_root": ""
|
449
455
|
}
|
450
456
|
```
|
package/lib/Errors.js
CHANGED
@@ -54,7 +54,7 @@ var FilesApiError = /*#__PURE__*/function (_FilesError) {
|
|
54
54
|
var _this2;
|
55
55
|
|
56
56
|
(0, _classCallCheck2.default)(this, FilesApiError);
|
57
|
-
_this2 = _super2.call(this, message
|
57
|
+
_this2 = _super2.call(this, message);
|
58
58
|
_this2.name = 'FilesApiError';
|
59
59
|
_this2.code = code;
|
60
60
|
return _this2;
|
@@ -75,16 +75,17 @@ var toPascalCase = function toPascalCase(string) {
|
|
75
75
|
};
|
76
76
|
|
77
77
|
var handleErrorResponse = function handleErrorResponse(error) {
|
78
|
-
var _errorData;
|
78
|
+
var _errorData, _errorData2;
|
79
79
|
|
80
80
|
var response = error.response;
|
81
81
|
var errorData = response === null || response === void 0 ? void 0 : response.data;
|
82
|
-
var
|
82
|
+
var message = ((_errorData = errorData) === null || _errorData === void 0 ? void 0 : _errorData.error) || (response === null || response === void 0 ? void 0 : response.statusText) || error.message;
|
83
|
+
var code = (response === null || response === void 0 ? void 0 : response.status) || ((_errorData2 = errorData) === null || _errorData2 === void 0 ? void 0 : _errorData2['http-code']) || 0;
|
83
84
|
|
84
85
|
if (!errorData) {
|
85
|
-
_Logger.default.error('FilesApiError Exception >', code,
|
86
|
+
_Logger.default.error('FilesApiError Exception >', code, message);
|
86
87
|
|
87
|
-
throw new FilesApiError(
|
88
|
+
throw new FilesApiError(message, code);
|
88
89
|
}
|
89
90
|
|
90
91
|
if (Array.isArray(errorData)) {
|
@@ -92,34 +93,32 @@ var handleErrorResponse = function handleErrorResponse(error) {
|
|
92
93
|
}
|
93
94
|
|
94
95
|
if (!errorData.type) {
|
95
|
-
_Logger.default.error('FilesApiError Exception >', code,
|
96
|
+
_Logger.default.error('FilesApiError Exception >', code, message);
|
96
97
|
|
97
|
-
throw new FilesApiError(
|
98
|
+
throw new FilesApiError(message, code);
|
98
99
|
}
|
99
100
|
|
100
101
|
var parts = errorData.type.split('/');
|
101
|
-
var errorFamily;
|
102
|
-
var errorType;
|
103
102
|
var className;
|
104
103
|
|
105
104
|
if (parts.length > 1) {
|
106
|
-
var _parts$map = parts.map(toPascalCase)
|
105
|
+
var _parts$map = parts.map(toPascalCase),
|
106
|
+
_parts$map2 = (0, _slicedToArray2.default)(_parts$map, 2),
|
107
|
+
errorFamily = _parts$map2[0],
|
108
|
+
errorType = _parts$map2[1];
|
107
109
|
|
108
|
-
var _parts$map2 = (0, _slicedToArray2.default)(_parts$map, 2);
|
109
|
-
|
110
|
-
errorFamily = _parts$map2[0];
|
111
|
-
errorType = _parts$map2[1];
|
112
110
|
className = "".concat(errorFamily, "_").concat(errorType, "Error");
|
113
111
|
} else {
|
114
|
-
|
115
|
-
|
112
|
+
var _errorType = toPascalCase(parts[0]);
|
113
|
+
|
114
|
+
className = "".concat(_errorType, "Error");
|
116
115
|
}
|
117
116
|
|
118
117
|
var ErrorClass = errorClasses[className];
|
119
118
|
|
120
|
-
_Logger.default.error("".concat(className, " Exception >"), code,
|
119
|
+
_Logger.default.error("".concat(className, " Exception >"), code, message);
|
121
120
|
|
122
|
-
throw new ErrorClass(
|
121
|
+
throw new ErrorClass(message, code);
|
123
122
|
}; // general errors
|
124
123
|
|
125
124
|
|
package/lib/models/User.js
CHANGED
@@ -142,6 +142,12 @@ var User = /*#__PURE__*/(0, _createClass2.default)(function User() {
|
|
142
142
|
(0, _defineProperty2.default)(this, "setEmail", function (value) {
|
143
143
|
_this.attributes.email = value;
|
144
144
|
});
|
145
|
+
(0, _defineProperty2.default)(this, "getFirstLoginAt", function () {
|
146
|
+
return _this.attributes.first_login_at;
|
147
|
+
});
|
148
|
+
(0, _defineProperty2.default)(this, "setFirstLoginAt", function (value) {
|
149
|
+
_this.attributes.first_login_at = value;
|
150
|
+
});
|
145
151
|
(0, _defineProperty2.default)(this, "getFtpPermission", function () {
|
146
152
|
return _this.attributes.ftp_permission;
|
147
153
|
});
|
@@ -328,6 +334,9 @@ var User = /*#__PURE__*/(0, _createClass2.default)(function User() {
|
|
328
334
|
(0, _defineProperty2.default)(this, "setTypeOf2fa", function (value) {
|
329
335
|
_this.attributes.type_of_2fa = value;
|
330
336
|
});
|
337
|
+
(0, _defineProperty2.default)(this, "getUpdatedAt", function () {
|
338
|
+
return _this.attributes.updated_at;
|
339
|
+
});
|
331
340
|
(0, _defineProperty2.default)(this, "getUserRoot", function () {
|
332
341
|
return _this.attributes.user_root;
|
333
342
|
});
|
package/package.json
CHANGED
package/src/Errors.js
CHANGED
@@ -9,7 +9,7 @@ export class FilesError extends Error {
|
|
9
9
|
|
10
10
|
export class FilesApiError extends FilesError {
|
11
11
|
constructor(message, code) {
|
12
|
-
super(message
|
12
|
+
super(message)
|
13
13
|
this.name = 'FilesApiError'
|
14
14
|
this.code = code
|
15
15
|
}
|
@@ -28,11 +28,12 @@ export const handleErrorResponse = error => {
|
|
28
28
|
const response = error.response
|
29
29
|
let errorData = response?.data
|
30
30
|
|
31
|
+
const message = errorData?.error || response?.statusText || error.message
|
31
32
|
const code = response?.status || errorData?.['http-code'] || 0
|
32
33
|
|
33
34
|
if (!errorData) {
|
34
|
-
Logger.error('FilesApiError Exception >', code,
|
35
|
-
throw new FilesApiError(
|
35
|
+
Logger.error('FilesApiError Exception >', code, message)
|
36
|
+
throw new FilesApiError(message, code)
|
36
37
|
}
|
37
38
|
|
38
39
|
if (Array.isArray(errorData)) {
|
@@ -40,28 +41,26 @@ export const handleErrorResponse = error => {
|
|
40
41
|
}
|
41
42
|
|
42
43
|
if (!errorData.type) {
|
43
|
-
Logger.error('FilesApiError Exception >', code,
|
44
|
-
throw new FilesApiError(
|
44
|
+
Logger.error('FilesApiError Exception >', code, message)
|
45
|
+
throw new FilesApiError(message, code)
|
45
46
|
}
|
46
47
|
|
47
48
|
const parts = errorData.type.split('/')
|
48
49
|
|
49
|
-
let errorFamily
|
50
|
-
let errorType
|
51
50
|
let className
|
52
|
-
|
51
|
+
|
53
52
|
if (parts.length > 1) {
|
54
|
-
[errorFamily, errorType] = parts.map(toPascalCase)
|
53
|
+
const [errorFamily, errorType] = parts.map(toPascalCase)
|
55
54
|
className = `${errorFamily}_${errorType}Error`
|
56
55
|
} else {
|
57
|
-
|
56
|
+
const errorType = toPascalCase(parts[0])
|
58
57
|
className = `${errorType}Error`
|
59
58
|
}
|
60
59
|
|
61
60
|
const ErrorClass = errorClasses[className]
|
62
61
|
|
63
|
-
Logger.error(`${className} Exception >`, code,
|
64
|
-
throw new ErrorClass(
|
62
|
+
Logger.error(`${className} Exception >`, code, message)
|
63
|
+
throw new ErrorClass(message, code)
|
65
64
|
}
|
66
65
|
|
67
66
|
// general errors
|
package/src/models/User.js
CHANGED
@@ -131,6 +131,13 @@ class User {
|
|
131
131
|
this.attributes.email = value
|
132
132
|
}
|
133
133
|
|
134
|
+
// date-time # User's first login time
|
135
|
+
getFirstLoginAt = () => this.attributes.first_login_at
|
136
|
+
|
137
|
+
setFirstLoginAt = value => {
|
138
|
+
this.attributes.first_login_at = value
|
139
|
+
}
|
140
|
+
|
134
141
|
// boolean # Can the user access with FTP/FTPS?
|
135
142
|
getFtpPermission = () => this.attributes.ftp_permission
|
136
143
|
|
@@ -348,6 +355,9 @@ class User {
|
|
348
355
|
this.attributes.type_of_2fa = value
|
349
356
|
}
|
350
357
|
|
358
|
+
// date-time # User record last updated at. Note this may be incremented because of internal or external updates.
|
359
|
+
getUpdatedAt = () => this.attributes.updated_at
|
360
|
+
|
351
361
|
// string # Root folder for FTP (and optionally SFTP if the appropriate site-wide setting is set.) Note that this is not used for API, Desktop, or Web interface.
|
352
362
|
getUserRoot = () => this.attributes.user_root
|
353
363
|
|