@singularsystems/neo-core 1.0.0-alpha.1 → 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.
@@ -12,5 +12,5 @@ export declare class ReadApiClient<TModel, TKey extends string | number> extends
12
12
  /** Gets a list of entities */
13
13
  get(): AxiosPromise<PlainObject<TModel>[]>;
14
14
  /** Gets a single entity using the provided id. */
15
- getById(id: TKey): AxiosPromise<{ [P_2 in Exclude<keyof TModel, keyof import("../Model/IModelBase").IModelBase> & { [P_1 in keyof TModel]: TModel[P_1] extends Function ? never : P_1; }[keyof TModel]]: TModel[P_2]; } extends infer T ? { [P in keyof T]: { [P_2 in Exclude<keyof TModel, keyof import("../Model/IModelBase").IModelBase> & { [P_1 in keyof TModel]: TModel[P_1] extends Function ? never : P_1; }[keyof TModel]]: TModel[P_2]; }[P] extends import("..").List<infer I> ? I[] : { [P_2 in Exclude<keyof TModel, keyof import("../Model/IModelBase").IModelBase> & { [P_1 in keyof TModel]: TModel[P_1] extends Function ? never : P_1; }[keyof TModel]]: TModel[P_2]; }[P]; } : never>;
15
+ getById(id: TKey): AxiosPromise<PlainObject<TModel>>;
16
16
  }
@@ -1,7 +1,6 @@
1
1
  import { IMetaItem } from '../Model/IModelBase';
2
2
  import { SortOperation } from './SortOperation';
3
3
  import PropertyInfo from '../Model/PropertyInfo';
4
- declare type sortValueFn = (c: any) => any;
5
4
  /** A DataView is a container of data with sorting and filtering capability. */
6
5
  export declare abstract class DataViewBase<T> {
7
6
  private originalSource;
@@ -36,17 +35,9 @@ export declare abstract class DataViewBase<T> {
36
35
  private getSortedItems;
37
36
  getItems(): T[];
38
37
  getMetaItem(): IMetaItem | null;
38
+ static unTrackedSort(callback: () => void): void;
39
39
  private static getDefaultSortValueFn;
40
40
  private static getSortValueSortFn;
41
- /**
42
- * Returns true if this object has observable properties. If so, frameworkSortFn will be used for sorting
43
- */
44
- static useFrameworkSortCompareFn: (item: any, propertyKey: string) => boolean;
45
- /**
46
- * Sort function provided by vue / react neo frameworks which know how to access raw field values.
47
- */
48
- static frameworkSortValueFn: sortValueFn;
49
41
  }
50
42
  export declare class DataView<T> extends DataViewBase<T> {
51
43
  }
52
- export {};
@@ -95,8 +95,8 @@ var DataViewBase = /** @class */ (function () {
95
95
  else {
96
96
  var sortInfo = this.sortInfo;
97
97
  if (sortInfo && sortInfo.length) {
98
- var sortFns = [];
99
- var itemsToSort = filtered.filter(function (c) { return c[_this.noSortSymbol] === undefined; });
98
+ var sortFns_1 = [];
99
+ var itemsToSort_1 = filtered.filter(function (c) { return c[_this.noSortSymbol] === undefined; });
100
100
  var endItems = filtered.filter(function (c) { return c[_this.noSortSymbol] !== undefined; });
101
101
  for (var _i = 0, sortInfo_1 = sortInfo; _i < sortInfo_1.length; _i++) {
102
102
  var sortColumn = sortInfo_1[_i];
@@ -106,19 +106,16 @@ var DataViewBase = /** @class */ (function () {
106
106
  valueFn = DataViewBase.getSortValueSortFn(property.propertyName);
107
107
  }
108
108
  else {
109
- if (DataViewBase.useFrameworkSortCompareFn(filtered[0], property.propertyName)) {
110
- valueFn = DataViewBase.frameworkSortValueFn(property.propertyName);
111
- }
112
- else {
113
- valueFn = DataViewBase.getDefaultSortValueFn(property.propertyName);
114
- }
109
+ valueFn = DataViewBase.getDefaultSortValueFn(property.propertyName);
115
110
  }
116
- sortFns.push({ property: property, valueFn: valueFn, direction: sortColumn.sortAscending ? "asc" : "desc" });
111
+ sortFns_1.push({ property: property, valueFn: valueFn, direction: sortColumn.sortAscending ? "asc" : "desc" });
117
112
  }
118
- for (var i = sortFns.length - 1; i >= 0; i--) {
119
- itemsToSort.sortBy(sortFns[i].valueFn, sortFns[i].direction, sortFns[i].property.propertyType);
120
- }
121
- return __spreadArray(__spreadArray([], itemsToSort, true), endItems, true);
113
+ DataViewBase.unTrackedSort(function () {
114
+ for (var i = sortFns_1.length - 1; i >= 0; i--) {
115
+ itemsToSort_1.sortBy(sortFns_1[i].valueFn, sortFns_1[i].direction, sortFns_1[i].property.propertyType);
116
+ }
117
+ });
118
+ return __spreadArray(__spreadArray([], itemsToSort_1, true), endItems, true);
122
119
  }
123
120
  return filtered;
124
121
  }
@@ -138,6 +135,9 @@ var DataViewBase = /** @class */ (function () {
138
135
  return null;
139
136
  }
140
137
  };
138
+ DataViewBase.unTrackedSort = function (callback) {
139
+ callback();
140
+ };
141
141
  DataViewBase.getDefaultSortValueFn = function (propertyName) {
142
142
  return function (c) { return c[propertyName]; };
143
143
  };
@@ -13,7 +13,7 @@ export default class List<T> extends Array<T> {
13
13
  * This is needed because vue / mobx changes the prototype to its own.
14
14
  */
15
15
  static copyMethods(toInstance: any): void;
16
- setupProxy(proxy: any, attachedTo: any, propertyKey: string): void;
16
+ setupProxy(proxy: any, attachedTo: any): void;
17
17
  /**
18
18
  * Converts the neo models to plain javascript objects without tracking state.
19
19
  * @param options Serialisation options.
@@ -41,28 +41,10 @@ var List = /** @class */ (function (_super) {
41
41
  }
42
42
  }
43
43
  };
44
- List.prototype.setupProxy = function (proxy, attachedTo, propertyKey) {
44
+ List.prototype.setupProxy = function (proxy, attachedTo) {
45
45
  proxy.childObjectType = this.childObjectType;
46
46
  proxy._deletedList = new ObservableValue([]);
47
47
  proxy.attachedTo = attachedTo;
48
- // Prevent direct writes to properties of type List.
49
- Object.defineProperty(attachedTo, propertyKey, { set: function (value) {
50
- if (!value) {
51
- proxy.length = 0;
52
- }
53
- else {
54
- if (value.childObjectType && value.setParent) {
55
- // Cannot re-assign this property, so we have to clear the array, and copy the items from the source array.
56
- Utils.batchUpdate(function () {
57
- proxy.length = 0;
58
- proxy.push.apply(proxy, value);
59
- });
60
- }
61
- else {
62
- throw "Do not assign a plain array to a List property. Either call ".concat(propertyKey, ".set(...) or ").concat(propertyKey, ".update(...)");
63
- }
64
- }
65
- } });
66
48
  };
67
49
  List.prototype.toJSArray = function (options) {
68
50
  if (options === void 0) { options = {}; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singularsystems/neo-core",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.2",
4
4
  "description": "Core functionality for the Neo client library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",