@singularsystems/neo-core 1.0.0-beta.8 → 1.0.0

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 (73) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +4 -0
  3. package/dist/AppServices/Config/ConfigModel.d.ts +3 -1
  4. package/dist/AppServices/Config/ConfigService.d.ts +15 -4
  5. package/dist/AppServices/Config/ConfigService.js +40 -18
  6. package/dist/AppServices/NeoTypes.d.ts +6 -0
  7. package/dist/AppServices/NeoTypes.js +7 -1
  8. package/dist/AppServices/ServiceIdentifier.js +2 -1
  9. package/dist/AxiosUtils.d.ts +27 -0
  10. package/dist/AxiosUtils.js +103 -0
  11. package/dist/Components/ErrorHandler.d.ts +12 -14
  12. package/dist/Components/ErrorHandler.js +15 -36
  13. package/dist/Components/FileManager/FileManager.js +5 -4
  14. package/dist/Components/FileManager/FileUploadBatch.js +2 -1
  15. package/dist/Components/Notifications/Notification.js +2 -1
  16. package/dist/Components/Notifications/NotificationHelper.js +2 -1
  17. package/dist/Components/Notifications/NotificationStore.js +2 -1
  18. package/dist/Components/TaskRunner/ProgressState.js +2 -1
  19. package/dist/Components/TaskRunner/TaskRunner.js +2 -1
  20. package/dist/ConnectionManager.js +2 -1
  21. package/dist/Data/ApiDataSource.d.ts +25 -26
  22. package/dist/Data/ApiDataSource.js +87 -97
  23. package/dist/Data/AsyncDataSource.d.ts +6 -2
  24. package/dist/Data/AsyncDataSource.js +22 -2
  25. package/dist/Data/CacheService.d.ts +4 -7
  26. package/dist/Data/CacheService.js +7 -5
  27. package/dist/Data/DataCacheEntry.d.ts +0 -4
  28. package/dist/Data/DataCacheEntry.js +0 -6
  29. package/dist/Data/DataView.js +4 -2
  30. package/dist/Data/Paging/PageManager.js +9 -8
  31. package/dist/Data/Paging/PageRequest.js +2 -1
  32. package/dist/Data/Serialiser.js +1 -0
  33. package/dist/Data/StaticDataSource.d.ts +1 -2
  34. package/dist/Data/StaticDataSource.js +0 -3
  35. package/dist/Data/WindowedDataView.js +2 -1
  36. package/dist/Data/index.d.ts +1 -1
  37. package/dist/Data/index.js +1 -1
  38. package/dist/Dates/DateUtils.js +2 -1
  39. package/dist/Extensions.d.ts +0 -4
  40. package/dist/Extensions.js +1 -1
  41. package/dist/IndexDb/IDbSet.d.ts +11 -0
  42. package/dist/JsonSchema/JsonSchemaTypes.d.ts +1 -0
  43. package/dist/Localisation/NeoStrings.d.ts +3 -0
  44. package/dist/Localisation/NeoStrings.js +3 -0
  45. package/dist/Model/BaseModels/AuditValues.js +4 -2
  46. package/dist/Model/BaseModels/CriteriaBase.js +2 -1
  47. package/dist/Model/BaseModels/ReasonedUserEvent.js +2 -1
  48. package/dist/Model/BaseModels/UserEvent.js +4 -2
  49. package/dist/Model/BindableBase.js +2 -1
  50. package/dist/Model/IModelBase.d.ts +3 -3
  51. package/dist/Model/ModelCreatorBase.js +2 -1
  52. package/dist/Model/ModelFieldInfo.js +2 -1
  53. package/dist/Model/ObservableValue.js +2 -1
  54. package/dist/NumberUtils.d.ts +3 -1
  55. package/dist/NumberUtils.js +2 -2
  56. package/dist/Routing/MenuItemProvider.js +2 -1
  57. package/dist/Routing/RouteSecurityService.js +2 -1
  58. package/dist/Security/LoginErrorHandler.js +2 -1
  59. package/dist/Security/SecurityService.js +2 -1
  60. package/dist/SignalR/IServerMessageSubscriber.d.ts +4 -0
  61. package/dist/SignalR/index.d.ts +1 -0
  62. package/dist/Validation/DisplayHelper.d.ts +3 -1
  63. package/dist/Validation/RuleContext.d.ts +4 -0
  64. package/dist/Validation/RuleContext.js +4 -0
  65. package/dist/index.d.ts +2 -1
  66. package/dist/index.js +2 -1
  67. package/package.json +9 -7
  68. package/dist/Decimal/DecimalService.d.ts +0 -23
  69. package/dist/Decimal/DecimalService.js +0 -38
  70. package/dist/Decimal/IDecimal.d.ts +0 -25
  71. package/dist/Numeric/IDecimal.d.ts +0 -25
  72. /package/dist/{Decimal/IDecimal.js → IndexDb/IDbSet.js} +0 -0
  73. /package/dist/{Numeric/IDecimal.js → SignalR/IServerMessageSubscriber.js} +0 -0
@@ -25,7 +25,7 @@ var ConnectionInfo = /** @class */ (function () {
25
25
  return ConnectionInfo;
26
26
  }());
27
27
  export { ConnectionInfo };
28
- export var ConnectionManager = /** @class */ (function () {
28
+ var ConnectionManager = /** @class */ (function () {
29
29
  function ConnectionManager() {
30
30
  this._connections = new Map();
31
31
  }
@@ -58,3 +58,4 @@ export var ConnectionManager = /** @class */ (function () {
58
58
  ], ConnectionManager);
59
59
  return ConnectionManager;
60
60
  }());
61
+ export { ConnectionManager };
@@ -1,15 +1,9 @@
1
1
  import { AsyncDataSource, IAsyncDataSource } from './AsyncDataSource';
2
2
  import { AxiosPromise } from 'axios';
3
- import List from '../Model/List';
3
+ import { PlainObject, IBindableBase } from "../Model/IModelBase";
4
+ import { IDbSet } from "../IndexDb/IDbSet";
4
5
  export interface IApiDataSource<T> extends IAsyncDataSource<T> {
5
6
  }
6
- export declare class CallbackDataSource<T> extends AsyncDataSource<T> {
7
- private callBack;
8
- private defaultData;
9
- constructor(callBack: () => Promise<any>, defaultData: T);
10
- protected getDataAsync(): Promise<any>;
11
- copy(): IAsyncDataSource<T>;
12
- }
13
7
  /**
14
8
  * Allows an api endpoint to be used directly by a consumer such as a drop down element.
15
9
  * If you need the data to be deserialised into a specific lookup model, use ApiClientLookupDataSource.
@@ -19,28 +13,33 @@ export declare class ApiClientDataSource<T> extends AsyncDataSource<T> implement
19
13
  private defaultData?;
20
14
  constructor(getMethod: () => AxiosPromise<T>, defaultData?: T | undefined);
21
15
  protected getDataAsync(): Promise<T>;
22
- /** Provides a copy of this datasource, without any data. */
23
- copy(): ApiClientDataSource<T>;
16
+ }
17
+ export declare abstract class ConvertingApiClientDataSource<T> extends AsyncDataSource<T> implements IApiDataSource<T> {
18
+ protected getMethod: () => AxiosPromise<any>;
19
+ private supportOffline;
20
+ constructor(getMethod: () => AxiosPromise<any>, defaultData: T, supportOffline: boolean);
21
+ protected abstract convertData(rawData: any): T;
22
+ protected abstract offlineGet(): Promise<any>;
23
+ protected abstract offlineStore(data: any): Promise<void>;
24
+ protected getDataAsync(): Promise<T>;
24
25
  }
25
26
  /**
26
27
  * Allows an api endpoint to be used directly by a consumer such as a drop down element.
27
28
  * Deserialises the json data returned by the api into a list of the specified lookup object.
28
29
  */
29
- export declare class ApiClientLookupDataSource<T> extends AsyncDataSource<T[]> implements IApiDataSource<T[]> {
30
- private getMethod;
31
- private deserialiseType?;
32
- private defaultData?;
33
- constructor(getMethod: () => AxiosPromise<any>, deserialiseType?: (new () => T) | undefined, defaultData?: T[] | undefined);
34
- protected getDataAsync(): Promise<List<T>>;
35
- /** Provides a copy of this datasource, without any data. */
36
- copy(): ApiClientLookupDataSource<T>;
30
+ export declare class ApiClientLookupDataSource<T extends IBindableBase> extends ConvertingApiClientDataSource<T[]> {
31
+ private deserialiseType;
32
+ private dbSet?;
33
+ constructor(getMethod: () => AxiosPromise<PlainObject<T>[]>, deserialiseType: (new () => T), defaultData?: T[], dbSet?: IDbSet<import("../Model/IModelBase").PlainObject<Exclude<keyof T, keyof import("../Model/IModelBase").IModelBase> & { [P_1 in keyof T]: T[P_1] extends Function ? never : P_1; }[keyof T] extends infer T_1 extends keyof T ? { [P in T_1]: T[P]; } : never>> | undefined);
34
+ protected offlineGet(): Promise<any>;
35
+ protected offlineStore(rawData: any): Promise<void>;
36
+ protected convertData(rawData: any): T[];
37
37
  }
38
- export declare class ApiDataSource<T> extends AsyncDataSource<T> implements IApiDataSource<T> {
39
- private apiEndpoint;
40
- private defaultData;
41
- private axiosInstance;
42
- constructor(apiEndpoint: string, defaultData: T, axiosInstance?: import("axios").AxiosStatic);
43
- protected getDataAsync(): Promise<any>;
44
- /** Provides a copy of this datasource, without any data. */
45
- copy(): ApiDataSource<T>;
38
+ export declare class ApiClientSingleLookupDataSource<T extends IBindableBase> extends ConvertingApiClientDataSource<T> {
39
+ private deserialiseType;
40
+ private dbSet?;
41
+ constructor(getMethod: () => AxiosPromise<PlainObject<T>>, deserialiseType: (new () => T), defaultData?: T, dbSet?: IDbSet<import("../Model/IModelBase").PlainObject<Exclude<keyof T, keyof import("../Model/IModelBase").IModelBase> & { [P_1 in keyof T]: T[P_1] extends Function ? never : P_1; }[keyof T] extends infer T_1 extends keyof T ? { [P in T_1]: T[P]; } : never>> | undefined);
42
+ protected offlineGet(): Promise<any>;
43
+ protected offlineStore(rawData: any): Promise<void>;
44
+ protected convertData(rawData: any): T;
46
45
  }
@@ -1,58 +1,13 @@
1
1
  import { __awaiter, __decorate, __extends, __generator, __metadata } from "tslib";
2
2
  import { AsyncDataSource } from './AsyncDataSource';
3
- import { Globals } from '../Misc';
4
3
  import NeoModel from '../Model/NeoModel';
5
- import { NeoTypes } from '../AppServices';
6
4
  import List from '../Model/List';
7
- export var CallbackDataSource = /** @class */ (function (_super) {
8
- __extends(CallbackDataSource, _super);
9
- function CallbackDataSource(callBack, defaultData) {
10
- var _this = _super.call(this, defaultData) || this;
11
- _this.callBack = callBack;
12
- _this.defaultData = defaultData;
13
- return _this;
14
- }
15
- CallbackDataSource_1 = CallbackDataSource;
16
- CallbackDataSource.prototype.getDataAsync = function () {
17
- return this.callBack();
18
- };
19
- CallbackDataSource.prototype.copy = function () {
20
- return new CallbackDataSource_1(this.callBack, this.defaultData);
21
- };
22
- var CallbackDataSource_1;
23
- CallbackDataSource = CallbackDataSource_1 = __decorate([
24
- NeoModel,
25
- __metadata("design:paramtypes", [Function, Object])
26
- ], CallbackDataSource);
27
- return CallbackDataSource;
28
- }(AsyncDataSource));
29
- function unwrapAxiosPromise(axiosPromise) {
30
- var _this = this;
31
- return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
32
- var _a, e_1;
33
- return __generator(this, function (_b) {
34
- switch (_b.label) {
35
- case 0:
36
- _b.trys.push([0, 2, , 3]);
37
- _a = resolve;
38
- return [4 /*yield*/, axiosPromise];
39
- case 1:
40
- _a.apply(void 0, [(_b.sent()).data]);
41
- return [3 /*break*/, 3];
42
- case 2:
43
- e_1 = _b.sent();
44
- reject(e_1);
45
- return [3 /*break*/, 3];
46
- case 3: return [2 /*return*/];
47
- }
48
- });
49
- }); });
50
- }
5
+ import AxiosUtils from "../AxiosUtils";
51
6
  /**
52
7
  * Allows an api endpoint to be used directly by a consumer such as a drop down element.
53
8
  * If you need the data to be deserialised into a specific lookup model, use ApiClientLookupDataSource.
54
9
  */
55
- export var ApiClientDataSource = /** @class */ (function (_super) {
10
+ var ApiClientDataSource = /** @class */ (function (_super) {
56
11
  __extends(ApiClientDataSource, _super);
57
12
  function ApiClientDataSource(getMethod, defaultData) {
58
13
  var _this = _super.call(this, defaultData !== null && defaultData !== void 0 ? defaultData : []) || this;
@@ -60,81 +15,116 @@ export var ApiClientDataSource = /** @class */ (function (_super) {
60
15
  _this.defaultData = defaultData;
61
16
  return _this;
62
17
  }
63
- ApiClientDataSource_1 = ApiClientDataSource;
64
18
  ApiClientDataSource.prototype.getDataAsync = function () {
65
- return unwrapAxiosPromise(this.getMethod());
66
- };
67
- /** Provides a copy of this datasource, without any data. */
68
- ApiClientDataSource.prototype.copy = function () {
69
- return new ApiClientDataSource_1(this.getMethod, this.defaultData);
19
+ return __awaiter(this, void 0, void 0, function () {
20
+ return __generator(this, function (_a) {
21
+ switch (_a.label) {
22
+ case 0: return [4 /*yield*/, this.getMethod()];
23
+ case 1: return [2 /*return*/, (_a.sent()).data];
24
+ }
25
+ });
26
+ });
70
27
  };
71
- var ApiClientDataSource_1;
72
- ApiClientDataSource = ApiClientDataSource_1 = __decorate([
28
+ ApiClientDataSource = __decorate([
73
29
  NeoModel,
74
30
  __metadata("design:paramtypes", [Function, Object])
75
31
  ], ApiClientDataSource);
76
32
  return ApiClientDataSource;
77
33
  }(AsyncDataSource));
78
- /**
79
- * Allows an api endpoint to be used directly by a consumer such as a drop down element.
80
- * Deserialises the json data returned by the api into a list of the specified lookup object.
81
- */
82
- export var ApiClientLookupDataSource = /** @class */ (function (_super) {
83
- __extends(ApiClientLookupDataSource, _super);
84
- function ApiClientLookupDataSource(getMethod, deserialiseType, defaultData) {
85
- var _this = _super.call(this, defaultData !== null && defaultData !== void 0 ? defaultData : []) || this;
34
+ export { ApiClientDataSource };
35
+ var ConvertingApiClientDataSource = /** @class */ (function (_super) {
36
+ __extends(ConvertingApiClientDataSource, _super);
37
+ function ConvertingApiClientDataSource(getMethod, defaultData, supportOffline) {
38
+ var _this = _super.call(this, defaultData) || this;
86
39
  _this.getMethod = getMethod;
87
- _this.deserialiseType = deserialiseType;
88
- _this.defaultData = defaultData;
40
+ _this.supportOffline = supportOffline;
89
41
  return _this;
90
42
  }
91
- ApiClientLookupDataSource_1 = ApiClientLookupDataSource;
92
- ApiClientLookupDataSource.prototype.getDataAsync = function () {
43
+ ConvertingApiClientDataSource.prototype.getDataAsync = function () {
93
44
  return __awaiter(this, void 0, void 0, function () {
94
- var rawData;
45
+ var rawData, result;
95
46
  return __generator(this, function (_a) {
96
47
  switch (_a.label) {
97
- case 0: return [4 /*yield*/, unwrapAxiosPromise(this.getMethod())];
48
+ case 0:
49
+ if (!navigator.onLine) return [3 /*break*/, 2];
50
+ return [4 /*yield*/, AxiosUtils.catchErrors(this.getMethod())];
98
51
  case 1:
52
+ result = _a.sent();
53
+ if (result.success) {
54
+ rawData = result.data;
55
+ if (this.supportOffline) {
56
+ this.offlineStore(rawData);
57
+ }
58
+ }
59
+ else if (!result.isNetworkError || !this.supportOffline) {
60
+ throw result.error;
61
+ }
62
+ _a.label = 2;
63
+ case 2:
64
+ if (!this.supportOffline) return [3 /*break*/, 4];
65
+ return [4 /*yield*/, this.offlineGet()];
66
+ case 3:
99
67
  rawData = _a.sent();
100
- return [2 /*return*/, List.fromJSArray(this.deserialiseType, rawData)];
68
+ _a.label = 4;
69
+ case 4: return [2 /*return*/, this.convertData(rawData)];
101
70
  }
102
71
  });
103
72
  });
104
73
  };
105
- /** Provides a copy of this datasource, without any data. */
106
- ApiClientLookupDataSource.prototype.copy = function () {
107
- return new ApiClientLookupDataSource_1(this.getMethod, this.deserialiseType, this.defaultData);
74
+ return ConvertingApiClientDataSource;
75
+ }(AsyncDataSource));
76
+ export { ConvertingApiClientDataSource };
77
+ /**
78
+ * Allows an api endpoint to be used directly by a consumer such as a drop down element.
79
+ * Deserialises the json data returned by the api into a list of the specified lookup object.
80
+ */
81
+ var ApiClientLookupDataSource = /** @class */ (function (_super) {
82
+ __extends(ApiClientLookupDataSource, _super);
83
+ function ApiClientLookupDataSource(getMethod, deserialiseType, defaultData, dbSet) {
84
+ var _this = _super.call(this, getMethod, defaultData !== null && defaultData !== void 0 ? defaultData : [], dbSet !== undefined) || this;
85
+ _this.deserialiseType = deserialiseType;
86
+ _this.dbSet = dbSet;
87
+ return _this;
88
+ }
89
+ ApiClientLookupDataSource.prototype.offlineGet = function () {
90
+ return this.dbSet.getAllAsync();
91
+ };
92
+ ApiClientLookupDataSource.prototype.offlineStore = function (rawData) {
93
+ return this.dbSet.putAsync(rawData);
108
94
  };
109
- var ApiClientLookupDataSource_1;
110
- ApiClientLookupDataSource = ApiClientLookupDataSource_1 = __decorate([
95
+ ApiClientLookupDataSource.prototype.convertData = function (rawData) {
96
+ return List.fromJSArray(this.deserialiseType, rawData);
97
+ };
98
+ ApiClientLookupDataSource = __decorate([
111
99
  NeoModel,
112
- __metadata("design:paramtypes", [Function, Function, Array])
100
+ __metadata("design:paramtypes", [Function, Function, Array, Object])
113
101
  ], ApiClientLookupDataSource);
114
102
  return ApiClientLookupDataSource;
115
- }(AsyncDataSource));
116
- export var ApiDataSource = /** @class */ (function (_super) {
117
- __extends(ApiDataSource, _super);
118
- function ApiDataSource(apiEndpoint, defaultData, axiosInstance) {
119
- if (axiosInstance === void 0) { axiosInstance = Globals.appService.get(NeoTypes.Axios); }
120
- var _this = _super.call(this, defaultData) || this;
121
- _this.apiEndpoint = apiEndpoint;
122
- _this.defaultData = defaultData;
123
- _this.axiosInstance = axiosInstance;
103
+ }(ConvertingApiClientDataSource));
104
+ export { ApiClientLookupDataSource };
105
+ var ApiClientSingleLookupDataSource = /** @class */ (function (_super) {
106
+ __extends(ApiClientSingleLookupDataSource, _super);
107
+ function ApiClientSingleLookupDataSource(getMethod, deserialiseType, defaultData, dbSet) {
108
+ var _this = _super.call(this, getMethod, defaultData !== null && defaultData !== void 0 ? defaultData : new deserialiseType(), dbSet !== undefined) || this;
109
+ _this.deserialiseType = deserialiseType;
110
+ _this.dbSet = dbSet;
124
111
  return _this;
125
112
  }
126
- ApiDataSource_1 = ApiDataSource;
127
- ApiDataSource.prototype.getDataAsync = function () {
128
- return unwrapAxiosPromise(this.axiosInstance.get(this.apiEndpoint));
113
+ ApiClientSingleLookupDataSource.prototype.offlineGet = function () {
114
+ return this.dbSet.getAsync(1);
129
115
  };
130
- /** Provides a copy of this datasource, without any data. */
131
- ApiDataSource.prototype.copy = function () {
132
- return new ApiDataSource_1(this.apiEndpoint, this.defaultData);
116
+ ApiClientSingleLookupDataSource.prototype.offlineStore = function (rawData) {
117
+ return this.dbSet.putAsync(rawData, 1);
133
118
  };
134
- var ApiDataSource_1;
135
- ApiDataSource = ApiDataSource_1 = __decorate([
119
+ ApiClientSingleLookupDataSource.prototype.convertData = function (rawData) {
120
+ var model = new this.deserialiseType();
121
+ model.set(rawData);
122
+ return model;
123
+ };
124
+ ApiClientSingleLookupDataSource = __decorate([
136
125
  NeoModel,
137
- __metadata("design:paramtypes", [String, Object, Object])
138
- ], ApiDataSource);
139
- return ApiDataSource;
140
- }(AsyncDataSource));
126
+ __metadata("design:paramtypes", [Function, Function, Object, Object])
127
+ ], ApiClientSingleLookupDataSource);
128
+ return ApiClientSingleLookupDataSource;
129
+ }(ConvertingApiClientDataSource));
130
+ export { ApiClientSingleLookupDataSource };
@@ -17,7 +17,6 @@ export interface IAsyncDataSource<T> {
17
17
  readonly fetchError: string | null;
18
18
  /** Current promise created as a result of fetchData being called. */
19
19
  readonly promise: Promise<T> | null;
20
- copy(): IAsyncDataSource<T>;
21
20
  }
22
21
  export declare abstract class AsyncDataSource<T> implements IAsyncDataSource<T> {
23
22
  isLoading: boolean;
@@ -31,5 +30,10 @@ export declare abstract class AsyncDataSource<T> implements IAsyncDataSource<T>
31
30
  private executeFetchAsync;
32
31
  fetchDataAsync(clearPreviousError?: boolean): Promise<T>;
33
32
  fetchInitial(): Promise<T>;
34
- abstract copy(): IAsyncDataSource<T>;
33
+ }
34
+ export declare class CallbackDataSource<T> extends AsyncDataSource<T> {
35
+ private callBack;
36
+ private defaultData;
37
+ constructor(callBack: () => Promise<any>, defaultData: T);
38
+ protected getDataAsync(): Promise<any>;
35
39
  }
@@ -1,7 +1,8 @@
1
- import { __awaiter, __decorate, __generator, __metadata } from "tslib";
1
+ import { __awaiter, __decorate, __extends, __generator, __metadata } from "tslib";
2
2
  import { Utils } from '../Utils';
3
3
  import { Observable } from '../Model/Decorators';
4
- export var AsyncDataSource = /** @class */ (function () {
4
+ import NeoModel from "../Model/NeoModel";
5
+ var AsyncDataSource = /** @class */ (function () {
5
6
  function AsyncDataSource(defaultData) {
6
7
  this.isLoading = false;
7
8
  this.fetchError = null;
@@ -77,3 +78,22 @@ export var AsyncDataSource = /** @class */ (function () {
77
78
  ], AsyncDataSource.prototype, "fetchError", void 0);
78
79
  return AsyncDataSource;
79
80
  }());
81
+ export { AsyncDataSource };
82
+ var CallbackDataSource = /** @class */ (function (_super) {
83
+ __extends(CallbackDataSource, _super);
84
+ function CallbackDataSource(callBack, defaultData) {
85
+ var _this = _super.call(this, defaultData) || this;
86
+ _this.callBack = callBack;
87
+ _this.defaultData = defaultData;
88
+ return _this;
89
+ }
90
+ CallbackDataSource.prototype.getDataAsync = function () {
91
+ return this.callBack();
92
+ };
93
+ CallbackDataSource = __decorate([
94
+ NeoModel,
95
+ __metadata("design:paramtypes", [Function, Object])
96
+ ], CallbackDataSource);
97
+ return CallbackDataSource;
98
+ }(AsyncDataSource));
99
+ export { CallbackDataSource };
@@ -2,6 +2,8 @@ import { IAsyncDataSource } from './AsyncDataSource';
2
2
  import { AxiosPromise } from 'axios';
3
3
  import { DataCacheEntry } from './DataCacheEntry';
4
4
  import { PlainObject } from '../Model/IModelBase';
5
+ import { BindableBase } from "../Model/BindableBase";
6
+ import { IDbSet } from "../IndexDb/IDbSet";
5
7
  export interface ICachedDataService {
6
8
  expireAll(expireDescendants?: boolean): void;
7
9
  }
@@ -10,12 +12,6 @@ export declare class CachedDataService implements ICachedDataService {
10
12
  private dataSources;
11
13
  private children;
12
14
  constructor(base?: CachedDataService);
13
- /**
14
- * Registers an api datasource.
15
- * @param apiEndpoint Api endpoint from which to get data.
16
- * @param lifeTimeMinutes No of minutes from the data retrieval time that the cache is valid for.
17
- */
18
- protected register<T>(apiEndpoint: string, lifeTimeMinutes: number, defaultData?: T): DataCacheEntry<T>;
19
15
  /**
20
16
  * Registers an api datasource.
21
17
  * @param apiEndpoint ClientApi method from which to get data.
@@ -33,8 +29,9 @@ export declare class CachedDataService implements ICachedDataService {
33
29
  * @param childType Child type to create when deserialising data.
34
30
  * @param apiMethod Api client method from which to get data.
35
31
  * @param lifeTimeMinutes No of minutes from the data retrieval time that the cache is valid for.
32
+ * @param dbSet DbSet for offline storage.
36
33
  */
37
- protected registerList<T>(childType: (new () => T), apiMethod: () => AxiosPromise<PlainObject<T>[]>, lifeTimeMinutes: number): DataCacheEntry<T[]>;
34
+ protected registerList<T extends BindableBase>(childType: (new () => T), apiMethod: () => AxiosPromise<PlainObject<T>[]>, lifeTimeMinutes: number, dbSet?: IDbSet<PlainObject<T>>): DataCacheEntry<T[]>;
38
35
  /** Expires all data */
39
36
  expireAll(expireDescendants?: boolean): void;
40
37
  }
@@ -1,9 +1,9 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
- import { ApiDataSource, ApiClientDataSource, ApiClientLookupDataSource } from './ApiDataSource';
2
+ import { ApiClientDataSource, ApiClientLookupDataSource } from './ApiDataSource';
3
3
  import { injectable } from 'inversify';
4
4
  import { DataCacheEntry } from './DataCacheEntry';
5
5
  /** Service for managing cached data. */
6
- export var CachedDataService = /** @class */ (function () {
6
+ var CachedDataService = /** @class */ (function () {
7
7
  function CachedDataService(base) {
8
8
  this.dataSources = [];
9
9
  this.children = [];
@@ -21,7 +21,7 @@ export var CachedDataService = /** @class */ (function () {
21
21
  apiSource = new ApiClientDataSource(apiEndpointOrDataSource, defaultData);
22
22
  }
23
23
  else {
24
- apiSource = new ApiDataSource(apiEndpointOrDataSource, defaultData);
24
+ throw Error("Unknown data source");
25
25
  }
26
26
  var cacheEntry = new DataCacheEntry(apiSource, lifeTimeMinutes);
27
27
  ;
@@ -33,9 +33,10 @@ export var CachedDataService = /** @class */ (function () {
33
33
  * @param childType Child type to create when deserialising data.
34
34
  * @param apiMethod Api client method from which to get data.
35
35
  * @param lifeTimeMinutes No of minutes from the data retrieval time that the cache is valid for.
36
+ * @param dbSet DbSet for offline storage.
36
37
  */
37
- CachedDataService.prototype.registerList = function (childType, apiMethod, lifeTimeMinutes) {
38
- var dataSource = new ApiClientLookupDataSource(apiMethod, childType);
38
+ CachedDataService.prototype.registerList = function (childType, apiMethod, lifeTimeMinutes, dbSet) {
39
+ var dataSource = new ApiClientLookupDataSource(apiMethod, childType, undefined, dbSet);
39
40
  var cacheEntry = new DataCacheEntry(dataSource, lifeTimeMinutes);
40
41
  ;
41
42
  this.dataSources.push(cacheEntry);
@@ -61,3 +62,4 @@ export var CachedDataService = /** @class */ (function () {
61
62
  ], CachedDataService);
62
63
  return CachedDataService;
63
64
  }());
65
+ export { CachedDataService };
@@ -28,10 +28,6 @@ export declare class DataCacheEntry<T> implements IDataCacheEntry {
28
28
  * Returns a promise from which data can be obtained. Data will be re-fetched if the lifetime has been exceeded.
29
29
  */
30
30
  getDataAsync(): Promise<T>;
31
- /**
32
- * Returns a new instance of the api datasource which is not cached. Fetch will not be initiated.
33
- */
34
- getNew(): IAsyncDataSource<T>;
35
31
  /**
36
32
  * Expires the datasource.
37
33
  * @param refetch True if the datasource must be refetched. This will cause any consumers of this datasource to rebind to the updated data.
@@ -43,12 +43,6 @@ var DataCacheEntry = /** @class */ (function () {
43
43
  DataCacheEntry.prototype.getDataAsync = function () {
44
44
  return this.get(true).promise;
45
45
  };
46
- /**
47
- * Returns a new instance of the api datasource which is not cached. Fetch will not be initiated.
48
- */
49
- DataCacheEntry.prototype.getNew = function () {
50
- return this.dataSource.copy();
51
- };
52
46
  /**
53
47
  * Expires the datasource.
54
48
  * @param refetch True if the datasource must be refetched. This will cause any consumers of this datasource to rebind to the updated data.
@@ -3,7 +3,7 @@ import NeoModel from '../Model/NeoModel';
3
3
  import { Observable, Computed } from '../Model/Decorators';
4
4
  import { SortOperation } from './SortOperation';
5
5
  /** A DataView is a container of data with sorting and filtering capability. */
6
- export var DataViewBase = /** @class */ (function () {
6
+ var DataViewBase = /** @class */ (function () {
7
7
  function DataViewBase(originalSource) {
8
8
  this.originalSource = originalSource;
9
9
  this.sortInfo = [];
@@ -161,7 +161,8 @@ export var DataViewBase = /** @class */ (function () {
161
161
  ], DataViewBase.prototype, "sortedItems", null);
162
162
  return DataViewBase;
163
163
  }());
164
- export var DataView = /** @class */ (function (_super) {
164
+ export { DataViewBase };
165
+ var DataView = /** @class */ (function (_super) {
165
166
  __extends(DataView, _super);
166
167
  function DataView() {
167
168
  return _super !== null && _super.apply(this, arguments) || this;
@@ -171,3 +172,4 @@ export var DataView = /** @class */ (function (_super) {
171
172
  ], DataView);
172
173
  return DataView;
173
174
  }(DataViewBase));
175
+ export { DataView };
@@ -6,7 +6,7 @@ import { Misc, AppServices } from '../../';
6
6
  import { Observable } from '../../Model/Decorators';
7
7
  import { SortOperation } from '../SortOperation';
8
8
  import List from '../../Model/List';
9
- export var PageManager = /** @class */ (function (_super) {
9
+ var PageManager = /** @class */ (function (_super) {
10
10
  __extends(PageManager, _super);
11
11
  function PageManager(criteria, modelType, dataSource, options) {
12
12
  var _this = _super.call(this, []) || this;
@@ -150,10 +150,10 @@ export var PageManager = /** @class */ (function (_super) {
150
150
  * @param getCount True if criteria has changed, and the total number of records needs to be refetched.
151
151
  * @param taskRunner Optional alternate task runner to use.
152
152
  */
153
- PageManager.prototype.refreshData = function (getCount, taskRunner) {
154
- if (getCount === void 0) { getCount = true; }
155
- return __awaiter(this, void 0, void 0, function () {
153
+ PageManager.prototype.refreshData = function () {
154
+ return __awaiter(this, arguments, void 0, function (getCount, taskRunner) {
156
155
  var request;
156
+ if (getCount === void 0) { getCount = true; }
157
157
  return __generator(this, function (_a) {
158
158
  switch (_a.label) {
159
159
  case 0:
@@ -208,9 +208,9 @@ export var PageManager = /** @class */ (function (_super) {
208
208
  });
209
209
  };
210
210
  PageManager.prototype.fetchAndSetData = function (request) {
211
- var _a;
212
211
  return __awaiter(this, void 0, void 0, function () {
213
212
  var response, data;
213
+ var _a;
214
214
  return __generator(this, function (_b) {
215
215
  switch (_b.label) {
216
216
  case 0: return [4 /*yield*/, this.dataSource(request)];
@@ -231,10 +231,10 @@ export var PageManager = /** @class */ (function (_super) {
231
231
  });
232
232
  };
233
233
  /* Will set the data to the provided list. This will still invoke the `afterFetch` */
234
- PageManager.prototype.setData = function (pageRecords, totalRecords) {
235
- if (totalRecords === void 0) { totalRecords = 0; }
236
- return __awaiter(this, void 0, void 0, function () {
234
+ PageManager.prototype.setData = function (pageRecords_1) {
235
+ return __awaiter(this, arguments, void 0, function (pageRecords, totalRecords) {
237
236
  var newData, task;
237
+ if (totalRecords === void 0) { totalRecords = 0; }
238
238
  return __generator(this, function (_a) {
239
239
  switch (_a.label) {
240
240
  case 0:
@@ -370,3 +370,4 @@ export var PageManager = /** @class */ (function (_super) {
370
370
  ], PageManager);
371
371
  return PageManager;
372
372
  }(DataViewBase));
373
+ export { PageManager };
@@ -1,7 +1,7 @@
1
1
  import { __decorate, __extends, __metadata } from "tslib";
2
2
  import NeoModel from '../../Model/NeoModel';
3
3
  import ValueObject from '../../Model/ValueObject';
4
- export var PageRequest = /** @class */ (function (_super) {
4
+ var PageRequest = /** @class */ (function (_super) {
5
5
  __extends(PageRequest, _super);
6
6
  function PageRequest(criteria) {
7
7
  var _this = _super.call(this) || this;
@@ -36,3 +36,4 @@ export var PageRequest = /** @class */ (function (_super) {
36
36
  ], PageRequest);
37
37
  return PageRequest;
38
38
  }(ValueObject));
39
+ export { PageRequest };
@@ -115,6 +115,7 @@ var Serialiser = /** @class */ (function () {
115
115
  propertyInfo.serialise !== SerialiseType.Never &&
116
116
  propertyInfo.serialise !== SerialiseType.MappingOnly &&
117
117
  (propertyInfo.serialise !== SerialiseType.FullOnly || this.options.includeClean)) {
118
+ //@ts-ignore
118
119
  var fromValue = from[key];
119
120
  var isChildObject = (fromValue && fromValue instanceof Object && !(fromValue instanceof Date) && !(NumberUtils.decimalService.isDecimal(fromValue))) || propertyInfo.relationType === RelationType.ChildObject;
120
121
  if (fromValue instanceof Array) {
@@ -1,9 +1,8 @@
1
- import { AsyncDataSource, IAsyncDataSource } from './AsyncDataSource';
1
+ import { AsyncDataSource } from './AsyncDataSource';
2
2
  import { IEnumItem } from '../Model/EnumHelper';
3
3
  export declare class StaticDataSource<T> extends AsyncDataSource<T> {
4
4
  constructor(staticData: T);
5
5
  static fromEnum(enumObject: any): StaticDataSource<IEnumItem[]>;
6
6
  getDataAsync(): Promise<Awaited<T>>;
7
7
  get willLoad(): boolean;
8
- copy(): IAsyncDataSource<T>;
9
8
  }
@@ -19,9 +19,6 @@ var StaticDataSource = /** @class */ (function (_super) {
19
19
  enumerable: false,
20
20
  configurable: true
21
21
  });
22
- StaticDataSource.prototype.copy = function () {
23
- return new StaticDataSource(this.data);
24
- };
25
22
  return StaticDataSource;
26
23
  }(AsyncDataSource));
27
24
  export { StaticDataSource };
@@ -2,7 +2,7 @@ import { __decorate, __extends, __metadata } from "tslib";
2
2
  import { DataViewBase } from './DataView';
3
3
  import { Observable } from '../Model/Decorators';
4
4
  import NeoModel from '../Model/NeoModel';
5
- export var WindowedDataView = /** @class */ (function (_super) {
5
+ var WindowedDataView = /** @class */ (function (_super) {
6
6
  __extends(WindowedDataView, _super);
7
7
  function WindowedDataView() {
8
8
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -47,3 +47,4 @@ export var WindowedDataView = /** @class */ (function (_super) {
47
47
  ], WindowedDataView);
48
48
  return WindowedDataView;
49
49
  }(DataViewBase));
50
+ export { WindowedDataView };
@@ -1,5 +1,5 @@
1
1
  export * from './AsyncDataSource';
2
- export { ApiClientDataSource, ApiClientLookupDataSource, CallbackDataSource } from './ApiDataSource';
2
+ export { ApiClientDataSource, ApiClientLookupDataSource, ApiClientSingleLookupDataSource } from './ApiDataSource';
3
3
  export { IDataCacheEntry, DataCacheEntry, IArrayCacheEntry } from './DataCacheEntry';
4
4
  export * from './CacheService';
5
5
  export * from './DataView';
@@ -1,5 +1,5 @@
1
1
  export * from './AsyncDataSource';
2
- export { ApiClientDataSource, ApiClientLookupDataSource, CallbackDataSource } from './ApiDataSource';
2
+ export { ApiClientDataSource, ApiClientLookupDataSource, ApiClientSingleLookupDataSource } from './ApiDataSource';
3
3
  export { DataCacheEntry } from './DataCacheEntry';
4
4
  export * from './CacheService';
5
5
  export * from './DataView';
@@ -191,7 +191,8 @@ var DateUtils = /** @class */ (function () {
191
191
  // 31 May - 1 month == 31 April == 1 May, this will fix that:
192
192
  var newMonth = newDate.getMonth();
193
193
  var oldMonth = date.getMonth();
194
- if (newMonth !== oldMonth + (timeSpan.months % 12)) {
194
+ // JS % operator gives remainder, not mod
195
+ if (newMonth !== ((oldMonth + (timeSpan.months % 12) + 12) % 12)) {
195
196
  newDate.setDate(0);
196
197
  }
197
198
  }