flamerest 1.0.44 → 1.0.47

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 (3) hide show
  1. package/REST.d.ts +1 -1
  2. package/REST.js +29 -19
  3. package/package.json +1 -1
package/REST.d.ts CHANGED
@@ -29,7 +29,7 @@ export function get<T>(table: string, where?: object | string | null, expand?: o
29
29
  * @param {object} params
30
30
  * @returns
31
31
  */
32
- export function all<T>(table: string, params?: { where?: object, fields?: object | Array<string>, sort?: Array<string>, page?: number, perPage?: number }): Promise<Rows<T>>;
32
+ export function all<T>(table: string, params?: { where?: object, fields?: object | Array<string>, sort?: Array<string>, page?: number, perPage?: number, tree?: number }): Promise<Rows<T>>;
33
33
 
34
34
  /**
35
35
  * Стандартный ответ от Request с несколькими строками
package/REST.js CHANGED
@@ -295,9 +295,10 @@ class FLAMEREST {
295
295
  * @param RemoveDuplicates
296
296
  * @param format
297
297
  * @param titles Это чтобы мы могли контроллить какие названия полей мы будет загружать при экспорте, чтобы они были как в таблице
298
+ * @param tree дерево
298
299
  * @return Promise<>
299
300
  */
300
- get(table, where, expand, fields, sortfields, page, perPage, RemoveDuplicates, format, titles) {
301
+ get(table, where, expand, fields, sortfields, page, perPage, RemoveDuplicates, format, titles, tree) {
301
302
 
302
303
  // Нормализуем имена таблиц
303
304
  table = table.replace(/_/g, "");
@@ -313,6 +314,10 @@ class FLAMEREST {
313
314
  if (where !== undefined && where !== null)
314
315
  json.where = where;
315
316
 
317
+ // Генерим условия
318
+ if (tree !== undefined && tree !== null)
319
+ json.tree = tree;
320
+
316
321
  if (fields !== undefined && fields !== null)
317
322
  json.fields = fields;
318
323
 
@@ -484,31 +489,36 @@ class FLAMEREST {
484
489
  for (let val in values) {
485
490
 
486
491
  // Преобразуем
487
- if (typeof values[val] === 'object'
488
- && values[val].hasOwnProperty('value')
492
+ let value = values[val];
493
+ let isRef = false;
494
+ if (value instanceof Object
495
+ && value.hasOwnProperty('_value')
489
496
  && (
490
- values[val].value instanceof Event ||
491
- values[val].value instanceof HTMLInputElement ||
492
- values[val].value instanceof ClipboardEvent ||
493
- values[val].value instanceof DataTransfer ||
494
- values[val].value instanceof FileList
497
+ value._value instanceof Event ||
498
+ value._value instanceof HTMLInputElement ||
499
+ value._value instanceof ClipboardEvent ||
500
+ value._value instanceof DataTransfer ||
501
+ value._value instanceof FileList
495
502
  )
496
- ) values[val] = values[val].value;
503
+ ) {value = value.value; isRef = true}
497
504
 
498
- if (values[val] instanceof Event && values[val].target instanceof HTMLInputElement && values[val].target.type === 'file') values[val] = values[val].target.files;
499
- if (values[val] instanceof HTMLInputElement && values[val].type === 'file') values[val] = values[val].files;
500
- if (values[val] instanceof ClipboardEvent) values[val] = values[val].clipboardData.files;
501
- if (values[val] instanceof DataTransfer) values[val] = values[val].files;
502
- if (values[val] instanceof FileList) {
505
+ if (value instanceof Event && value.target instanceof HTMLInputElement && value.target.type === 'file') value = value.target.files;
506
+ if (value instanceof HTMLInputElement && value.type === 'file') value = value.files;
507
+ if (value instanceof ClipboardEvent) value = value.clipboardData.files;
508
+ if (value instanceof DataTransfer) value = value.files;
509
+ if (value instanceof FileList) {
503
510
  let newValues = [];
504
- values[val] = Array.from(values[val]);
505
- for (let file in values[val]) {
511
+ value = Array.from(value);
512
+ for (let file in value) {
506
513
  newValues.push({
507
- 'name': values[val][file].name,
508
- 'data': await this.readFileAsync(values[val][file])
514
+ 'name': value[file].name,
515
+ 'data': await this.readFileAsync(value[file])
509
516
  });
510
517
  }
511
- values[val] = newValues;
518
+ if (isRef)
519
+ values[val].value = newValues;
520
+ else
521
+ values[val] = newValues;
512
522
  }
513
523
  }
514
524
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flamerest",
3
- "version": "1.0.44",
3
+ "version": "1.0.47",
4
4
  "description": "",
5
5
  "main": "REST.js",
6
6
  "typings": "./REST.d.ts",