files.com 1.2.122 → 1.2.124
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +107 -0
- package/_VERSION +1 -1
- package/docs/models/Site.md +2 -0
- package/lib/Files.js +1 -1
- package/lib/models/Site.js +4 -0
- package/package.json +1 -1
- package/src/Files.js +1 -1
- package/src/models/Site.js +3 -0
package/README.md
CHANGED
@@ -194,6 +194,113 @@ Files.configureNetwork({
|
|
194
194
|
})
|
195
195
|
```
|
196
196
|
|
197
|
+
## Sort and Filter
|
198
|
+
|
199
|
+
Several of the Files.com API resources have list operations that return multiple instances of the resource. The List operations
|
200
|
+
can be sorted and filtered.
|
201
|
+
|
202
|
+
### Sorting
|
203
|
+
|
204
|
+
The returned data can be sorted by passing in the ```sort_by``` method argument.
|
205
|
+
|
206
|
+
Each resource has a set of valid fields for sorting and can be sorted by one field at a time.
|
207
|
+
|
208
|
+
The argument value is a Javascript object that has a property of the resource field name sort on and a value of either ```"asc"``` or ```"desc"``` to specify the sort order.
|
209
|
+
|
210
|
+
### Filters
|
211
|
+
|
212
|
+
Filters apply selection criteria to the underlying query that returns the results. Filters can be applied individually to select resource fields
|
213
|
+
and/or in a combination with each other. The results of applying filters and filter combinations can be sorted by a single field.
|
214
|
+
|
215
|
+
The passed in argument value is a Javascript object that has a property of the resource field name to filter on and a passed in value to use in the filter comparison.
|
216
|
+
|
217
|
+
Each resource has their own set of valid filters and fields, valid combinations of filters, and sortable fields.
|
218
|
+
|
219
|
+
#### Types of Filters
|
220
|
+
|
221
|
+
##### Exact Filter
|
222
|
+
|
223
|
+
`filter` - find resources that have an exact field value match to a passed in value. (i.e., FIELD_VALUE = PASS_IN_VALUE).
|
224
|
+
|
225
|
+
#### Range Filters
|
226
|
+
|
227
|
+
`filter_gt` - find resources that have a field value that is greater than the passed in value. (i.e., FIELD_VALUE > PASS_IN_VALUE).
|
228
|
+
|
229
|
+
`filter_gte` - find resources that have a field value that is greater than or equal to the passed in value. (i.e., FIELD_VALUE >= PASS_IN_VALUE).
|
230
|
+
|
231
|
+
`filter_lt` - find resources that have a field value that is less than the passed in value. (i.e., FIELD_VALUE < PASS_IN_VALUE).
|
232
|
+
|
233
|
+
`filter_lte` - find resources that have a field value that is less than or equal to the passed in value. (i.e., FIELD_VALUE \<= PASS_IN_VALUE).
|
234
|
+
|
235
|
+
##### Pattern Filter
|
236
|
+
|
237
|
+
`filter_prefix` - find resources where the specified field is prefixed by the supplied value. This is applicable to values that are strings.
|
238
|
+
|
239
|
+
```javascript title="Sort Example"
|
240
|
+
// users sorted by username
|
241
|
+
Files.setApiKey('my-key');
|
242
|
+
var users = await User.list({
|
243
|
+
sort_by: { username: "asc"}
|
244
|
+
})
|
245
|
+
|
246
|
+
for (var i = 0; i < users.length; i++) {
|
247
|
+
console.log(users[i].username);
|
248
|
+
}
|
249
|
+
```
|
250
|
+
|
251
|
+
```javascript title="Exact Filter Example"
|
252
|
+
// non admin users
|
253
|
+
Files.setApiKey('my-key');
|
254
|
+
var users = await User.list({
|
255
|
+
filter: { not_site_admin: true },
|
256
|
+
sort_by: { username: "asc"}
|
257
|
+
})
|
258
|
+
|
259
|
+
for (var i = 0; i < users.length; i++) {
|
260
|
+
console.log(users[i].username);
|
261
|
+
}
|
262
|
+
```
|
263
|
+
|
264
|
+
```javascript title="Range Filter Example"
|
265
|
+
// users who haven't logged in since 2024-01-01
|
266
|
+
Files.setApiKey('my-key');
|
267
|
+
var users = await User.list({
|
268
|
+
filter_gte: { last_login_at: "2024-01-01" },
|
269
|
+
sort_by: { last_login_at: "asc"}
|
270
|
+
})
|
271
|
+
|
272
|
+
for (var i = 0; i < users.length; i++) {
|
273
|
+
console.log(users[i].username);
|
274
|
+
}
|
275
|
+
```
|
276
|
+
|
277
|
+
```javascript title="Pattern Filter Example"
|
278
|
+
// users who usernames start with 'test'
|
279
|
+
Files.setApiKey('my-key');
|
280
|
+
var users = await User.list({
|
281
|
+
filter_prefix: { username: "test" },
|
282
|
+
sort_by: { last_login_at: "asc"}
|
283
|
+
})
|
284
|
+
|
285
|
+
for (var i = 0; i < users.length; i++) {
|
286
|
+
console.log(users[i].username);
|
287
|
+
}
|
288
|
+
```
|
289
|
+
|
290
|
+
```javascript title="Combined Filter Example"
|
291
|
+
// users who usernames start with 'test' and are not admins
|
292
|
+
Files.setApiKey('my-key');
|
293
|
+
var users = await User.list({
|
294
|
+
filter_prefix: { username: "test" },
|
295
|
+
filter: { not_site_admin: true },
|
296
|
+
sort_by: { last_login_at: "asc"}
|
297
|
+
})
|
298
|
+
|
299
|
+
for (var i = 0; i < users.length; i++) {
|
300
|
+
console.log(users[i].username);
|
301
|
+
}
|
302
|
+
```
|
303
|
+
|
197
304
|
## Errors
|
198
305
|
|
199
306
|
The Files.com JavaScript SDK will return errors by raising exceptions. There are many exception classes defined in the Files SDK that correspond
|
package/_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.124
|
package/docs/models/Site.md
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
```
|
6
6
|
{
|
7
|
+
"id": 1,
|
7
8
|
"name": "My Site",
|
8
9
|
"additional_text_file_types": [
|
9
10
|
"example"
|
@@ -285,6 +286,7 @@
|
|
285
286
|
}
|
286
287
|
```
|
287
288
|
|
289
|
+
* `id` (int64): Site Id
|
288
290
|
* `name` (string): Site name
|
289
291
|
* `additional_text_file_types` (array(string)): Additional extensions that are considered text files
|
290
292
|
* `allowed_2fa_method_sms` (boolean): Is SMS two factor authentication allowed?
|
package/lib/Files.js
CHANGED
@@ -11,7 +11,7 @@ var endpointPrefix = '/api/rest/v1';
|
|
11
11
|
var apiKey;
|
12
12
|
var baseUrl = 'https://app.files.com';
|
13
13
|
var sessionId = null;
|
14
|
-
var version = '1.2.
|
14
|
+
var version = '1.2.124';
|
15
15
|
var userAgent = "Files.com JavaScript SDK v".concat(version);
|
16
16
|
var logLevel = _Logger.LogLevel.INFO;
|
17
17
|
var debugRequest = false;
|
package/lib/models/Site.js
CHANGED
@@ -33,6 +33,10 @@ var Site = /*#__PURE__*/(0, _createClass2.default)(function Site() {
|
|
33
33
|
(0, _defineProperty2.default)(this, "isLoaded", function () {
|
34
34
|
return !!_this.attributes.id;
|
35
35
|
});
|
36
|
+
// int64 # Site Id
|
37
|
+
(0, _defineProperty2.default)(this, "getId", function () {
|
38
|
+
return _this.attributes.id;
|
39
|
+
});
|
36
40
|
// string # Site name
|
37
41
|
(0, _defineProperty2.default)(this, "getName", function () {
|
38
42
|
return _this.attributes.name;
|
package/package.json
CHANGED
package/src/Files.js
CHANGED