@rosoftlab/core 1.0.5-alpha-8 → 1.0.5-alpha-9
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/fesm2022/rosoftlab-core.mjs +236 -464
- package/fesm2022/rosoftlab-core.mjs.map +1 -1
- package/lib/auth/auth.service.d.ts +3 -0
- package/lib/base-components/base-table-implementation.d.ts +3 -2
- package/lib/index.d.ts +0 -2
- package/lib/interfaces/overrides.interface.d.ts +0 -2
- package/lib/models/base.model.d.ts +3 -10
- package/lib/models/file.d.ts +9 -0
- package/lib/models/index.d.ts +1 -0
- package/lib/services/base-datastore.service.d.ts +5 -13
- package/lib/services/cache.service.d.ts +1 -0
- package/lib/services/datastore-port.d.ts +4 -4
- package/lib/services/file.service.d.ts +16 -0
- package/lib/services/index.d.ts +1 -0
- package/package.json +8 -7
- package/lib/constants/symbols.d.ts +0 -1
- package/lib/converters/date/date.converter.d.ts +0 -5
- package/lib/decorators/attribute.decorator.d.ts +0 -2
- package/lib/interfaces/attribute-decorator-options.interface.d.ts +0 -8
|
@@ -4,8 +4,8 @@ import * as i0 from '@angular/core';
|
|
|
4
4
|
import { InjectionToken, Optional, Inject, Injectable, inject, Input, Component, HostBinding, Directive, Pipe, NgModule } from '@angular/core';
|
|
5
5
|
import * as i1 from 'oidc-client-ts';
|
|
6
6
|
import { User as User$1, UserManager } from 'oidc-client-ts';
|
|
7
|
-
import { BehaviorSubject, firstValueFrom,
|
|
8
|
-
import { map, tap,
|
|
7
|
+
import { BehaviorSubject, firstValueFrom, of, Observable, throwError, ReplaySubject } from 'rxjs';
|
|
8
|
+
import { switchMap, catchError, map, tap, filter } from 'rxjs/operators';
|
|
9
9
|
import * as i5 from '@angular/common';
|
|
10
10
|
import { Location, DatePipe, DecimalPipe, PercentPipe, CommonModule } from '@angular/common';
|
|
11
11
|
import * as i1$2 from '@angular/forms';
|
|
@@ -14,10 +14,9 @@ import * as i2 from '@angular/router';
|
|
|
14
14
|
import { Router, ActivatedRoute, UrlSegment, NavigationEnd } from '@angular/router';
|
|
15
15
|
import * as i1$3 from '@ngx-translate/core';
|
|
16
16
|
import { TranslateService, TranslateModule, TranslateLoader } from '@ngx-translate/core';
|
|
17
|
-
import { parseISO } from 'date-fns';
|
|
18
|
-
import { __decorate, __metadata } from 'tslib';
|
|
19
17
|
import { compare } from 'fast-json-patch';
|
|
20
18
|
import queryString from 'query-string';
|
|
19
|
+
import { __decorate, __metadata } from 'tslib';
|
|
21
20
|
|
|
22
21
|
class Tokens {
|
|
23
22
|
}
|
|
@@ -38,6 +37,83 @@ class AuthService {
|
|
|
38
37
|
this._authNavStatusSource.next(this.isAuthenticated());
|
|
39
38
|
});
|
|
40
39
|
}
|
|
40
|
+
async restoreUserFromStorage() {
|
|
41
|
+
if (this.user) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const stored = await this.manager.getUser();
|
|
46
|
+
if (stored) {
|
|
47
|
+
this.user = stored;
|
|
48
|
+
this._authNavStatusSource.next(this.isAuthenticated());
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// ignore
|
|
54
|
+
}
|
|
55
|
+
const raw = this.findOidcUserInWebStorage();
|
|
56
|
+
if (!raw) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const parsed = JSON.parse(raw);
|
|
61
|
+
const profile = parsed?.profile ?? this.decodeJwt(parsed?.access_token) ?? this.decodeJwt(parsed?.id_token);
|
|
62
|
+
const hydrated = new User$1({
|
|
63
|
+
...parsed,
|
|
64
|
+
profile: profile ?? parsed?.profile ?? { sub: 'offline' }
|
|
65
|
+
});
|
|
66
|
+
this.user = hydrated;
|
|
67
|
+
this._authNavStatusSource.next(this.isAuthenticated());
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
findOidcUserInWebStorage() {
|
|
75
|
+
try {
|
|
76
|
+
if (typeof localStorage !== 'undefined') {
|
|
77
|
+
const key = Object.keys(localStorage).find((k) => k.startsWith('oidc.user:'));
|
|
78
|
+
if (key) {
|
|
79
|
+
return localStorage.getItem(key);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// ignore
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
if (typeof sessionStorage !== 'undefined') {
|
|
88
|
+
const key = Object.keys(sessionStorage).find((k) => k.startsWith('oidc.user:'));
|
|
89
|
+
if (key) {
|
|
90
|
+
return sessionStorage.getItem(key);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// ignore
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
decodeJwt(token) {
|
|
100
|
+
if (!token || typeof token !== 'string') {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
const parts = token.split('.');
|
|
104
|
+
if (parts.length < 2) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const payload = parts[1].replace(/-/g, '+').replace(/_/g, '/');
|
|
109
|
+
const padded = payload.padEnd(payload.length + ((4 - (payload.length % 4)) % 4), '=');
|
|
110
|
+
const decoded = atob(padded);
|
|
111
|
+
return JSON.parse(decoded);
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
41
117
|
login() {
|
|
42
118
|
this.manager.clearStaleState().then(() => {
|
|
43
119
|
this.manager.signinRedirect();
|
|
@@ -113,10 +189,13 @@ class AuthService {
|
|
|
113
189
|
body.set('scope', this.guestSettings?.scope || 'openid profile offline_access');
|
|
114
190
|
await firstValueFrom(this.http.post(`${authUrlToUse}/connect/token`, body.toString(), {
|
|
115
191
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
|
|
116
|
-
}).pipe(
|
|
192
|
+
}).pipe(switchMap((response) => {
|
|
117
193
|
if (!response.access_token) {
|
|
118
194
|
throw new Error('Login failed');
|
|
119
195
|
}
|
|
196
|
+
const headers = { Authorization: `Bearer ${response.access_token}` };
|
|
197
|
+
return this.http.get(`${authUrlToUse}/connect/userinfo`, { headers }).pipe(catchError(() => of(null)), map((profile) => ({ response, profile })));
|
|
198
|
+
}), map(({ response, profile }) => {
|
|
120
199
|
const expires_at = response.expires_in ? Math.floor(Date.now() / 1000) + response.expires_in : 0;
|
|
121
200
|
const user = new User$1({
|
|
122
201
|
id_token: response.id_token || '',
|
|
@@ -125,13 +204,7 @@ class AuthService {
|
|
|
125
204
|
refresh_token: response.refresh_token || '',
|
|
126
205
|
token_type: response.token_type || 'Bearer',
|
|
127
206
|
scope: response.scope || '',
|
|
128
|
-
profile: {
|
|
129
|
-
sub: 'guest', // Dummy sub for guest
|
|
130
|
-
iss: authUrlToUse,
|
|
131
|
-
aud: this.manager.settings.client_id,
|
|
132
|
-
exp: expires_at,
|
|
133
|
-
iat: Math.floor(Date.now() / 1000)
|
|
134
|
-
}, // Cast to any to avoid strict typing
|
|
207
|
+
profile: (profile ?? { sub: 'guest' }),
|
|
135
208
|
expires_at: expires_at,
|
|
136
209
|
userState: null
|
|
137
210
|
});
|
|
@@ -392,7 +465,7 @@ class BaseService {
|
|
|
392
465
|
else {
|
|
393
466
|
fromModel = docTypeOrFormGroup;
|
|
394
467
|
}
|
|
395
|
-
return this.datastore.saveRecord(fromModel
|
|
468
|
+
return this.datastore.saveRecord(fromModel);
|
|
396
469
|
}
|
|
397
470
|
else {
|
|
398
471
|
return this.patch(docTypeOrFormGroup, origModel, id);
|
|
@@ -406,7 +479,7 @@ class BaseService {
|
|
|
406
479
|
else {
|
|
407
480
|
fromModel = docTypeOrFormGroup;
|
|
408
481
|
}
|
|
409
|
-
return this.datastore.patchRecord(fromModel
|
|
482
|
+
return this.datastore.patchRecord(fromModel, origModel);
|
|
410
483
|
}
|
|
411
484
|
newModel(data) {
|
|
412
485
|
return new this.modelType(data);
|
|
@@ -427,7 +500,7 @@ class BaseService {
|
|
|
427
500
|
return saveModel;
|
|
428
501
|
}
|
|
429
502
|
serializeModel(model) {
|
|
430
|
-
return this.datastore.modelToEntity(model
|
|
503
|
+
return this.datastore.modelToEntity(model);
|
|
431
504
|
}
|
|
432
505
|
getSelectValues(property) {
|
|
433
506
|
return null;
|
|
@@ -721,6 +794,7 @@ class BaseTableImplementation {
|
|
|
721
794
|
.map((segment) => new UrlSegment(segment, {}));
|
|
722
795
|
this.basePath = currentUrlSegments.map((segment) => segment.path).join('/');
|
|
723
796
|
}
|
|
797
|
+
ngOnDestroy() { }
|
|
724
798
|
get hostClasses() {
|
|
725
799
|
return this.hostClass;
|
|
726
800
|
}
|
|
@@ -836,28 +910,6 @@ var CellTextAlign;
|
|
|
836
910
|
CellTextAlign["right"] = "right";
|
|
837
911
|
})(CellTextAlign || (CellTextAlign = {}));
|
|
838
912
|
|
|
839
|
-
// tslint:disable-next-line:variable-name
|
|
840
|
-
const AttributeMetadata = Symbol('AttributeMetadata');
|
|
841
|
-
|
|
842
|
-
class DateConverter {
|
|
843
|
-
mask(value) {
|
|
844
|
-
if (value instanceof Date && !isNaN(value.getTime())) {
|
|
845
|
-
return value;
|
|
846
|
-
}
|
|
847
|
-
const d = parseISO(value);
|
|
848
|
-
if (d instanceof Date && !isNaN(d.getTime())) {
|
|
849
|
-
return d;
|
|
850
|
-
}
|
|
851
|
-
else {
|
|
852
|
-
return value;
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
unmask(value) {
|
|
856
|
-
// const result = format(value, 'YYYY-MM-DDTHH:mm:ssZ');
|
|
857
|
-
return value;
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
|
|
861
913
|
class MetadataStorage {
|
|
862
914
|
static { this.metadataMap = new WeakMap(); }
|
|
863
915
|
static getMetadata(key, target, propertyKey) {
|
|
@@ -895,89 +947,6 @@ class MetadataStorage {
|
|
|
895
947
|
}
|
|
896
948
|
}
|
|
897
949
|
|
|
898
|
-
function Attribute(options = {}) {
|
|
899
|
-
return (target, propertyName) => {
|
|
900
|
-
const converter = (dataType, value, forSerialisation = false) => {
|
|
901
|
-
let attrConverter;
|
|
902
|
-
if (dataType) {
|
|
903
|
-
if (options.converter) {
|
|
904
|
-
attrConverter = options.converter;
|
|
905
|
-
}
|
|
906
|
-
else if (dataType === Date) {
|
|
907
|
-
attrConverter = new DateConverter();
|
|
908
|
-
}
|
|
909
|
-
else {
|
|
910
|
-
const datatype = new dataType();
|
|
911
|
-
if (datatype.mask && datatype.unmask) {
|
|
912
|
-
attrConverter = datatype;
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
if (attrConverter) {
|
|
916
|
-
if (!forSerialisation) {
|
|
917
|
-
return attrConverter.mask(value);
|
|
918
|
-
}
|
|
919
|
-
return attrConverter.unmask(value);
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
return value;
|
|
923
|
-
};
|
|
924
|
-
const saveAnnotations = () => {
|
|
925
|
-
const metadata = MetadataStorage.getMetadata('Attribute', target) || {};
|
|
926
|
-
metadata[propertyName] = {
|
|
927
|
-
marked: true
|
|
928
|
-
};
|
|
929
|
-
MetadataStorage.setMetadata('Attribute', metadata, target);
|
|
930
|
-
const mappingMetadata = MetadataStorage.getMetadata('AttributeMapping', target) || {};
|
|
931
|
-
const serializedPropertyName = options.serializedName !== undefined ? options.serializedName : propertyName;
|
|
932
|
-
mappingMetadata[serializedPropertyName] = propertyName;
|
|
933
|
-
MetadataStorage.setMetadata('AttributeMapping', mappingMetadata, target);
|
|
934
|
-
const requiredMetadata = MetadataStorage.getMetadata('AttributeRequired', target) || {};
|
|
935
|
-
requiredMetadata[serializedPropertyName] = options.required !== undefined ? options.required : false;
|
|
936
|
-
MetadataStorage.setMetadata('AttributeRequired', requiredMetadata, target);
|
|
937
|
-
const defaultMetadata = MetadataStorage.getMetadata('AttributedefaultValue', target) || {};
|
|
938
|
-
defaultMetadata[serializedPropertyName] = options.defaultValue !== undefined ? options.defaultValue : null;
|
|
939
|
-
MetadataStorage.setMetadata('AttributedefaultValue', defaultMetadata, target);
|
|
940
|
-
const formSubGroupMetadata = MetadataStorage.getMetadata('AttributeformSubGroup', target) || {};
|
|
941
|
-
formSubGroupMetadata[serializedPropertyName] = options.formSubGroup !== undefined ? options.formSubGroup : null;
|
|
942
|
-
MetadataStorage.setMetadata('AttributeformSubGroup', formSubGroupMetadata, target);
|
|
943
|
-
};
|
|
944
|
-
const setMetadata = (hasDirtyAttributes, instance, oldValue, newValue, isNew) => {
|
|
945
|
-
const targetType = MetadataStorage.getMetadata('design:type', target, propertyName);
|
|
946
|
-
if (!instance[AttributeMetadata]) {
|
|
947
|
-
instance[AttributeMetadata] = {};
|
|
948
|
-
}
|
|
949
|
-
const propertyHasDirtyAttributes = typeof oldValue === 'undefined' && !isNew ? false : hasDirtyAttributes;
|
|
950
|
-
instance[AttributeMetadata][propertyName] = {
|
|
951
|
-
newValue,
|
|
952
|
-
oldValue,
|
|
953
|
-
serializedName: options.serializedName,
|
|
954
|
-
hasDirtyAttributes: propertyHasDirtyAttributes,
|
|
955
|
-
serialisationValue: converter(targetType, newValue, true)
|
|
956
|
-
};
|
|
957
|
-
};
|
|
958
|
-
const getter = function () {
|
|
959
|
-
return this['_' + propertyName];
|
|
960
|
-
};
|
|
961
|
-
const setter = function (newVal) {
|
|
962
|
-
const targetType = MetadataStorage.getMetadata('design:type', target, propertyName);
|
|
963
|
-
const convertedValue = converter(targetType, newVal);
|
|
964
|
-
if (convertedValue !== this['_' + propertyName]) {
|
|
965
|
-
setMetadata(true, this, this['_' + propertyName], newVal, !this.id);
|
|
966
|
-
this['_' + propertyName] = convertedValue;
|
|
967
|
-
}
|
|
968
|
-
};
|
|
969
|
-
if (delete target[propertyName]) {
|
|
970
|
-
saveAnnotations();
|
|
971
|
-
Object.defineProperty(target, propertyName, {
|
|
972
|
-
get: getter,
|
|
973
|
-
set: setter,
|
|
974
|
-
enumerable: true,
|
|
975
|
-
configurable: true
|
|
976
|
-
});
|
|
977
|
-
}
|
|
978
|
-
};
|
|
979
|
-
}
|
|
980
|
-
|
|
981
950
|
function BaseDatastoreConfig(config = {}) {
|
|
982
951
|
// tslint:disable-next-line:only-arrow-functions
|
|
983
952
|
return (target) => {
|
|
@@ -1016,6 +985,14 @@ class CacheService {
|
|
|
1016
985
|
constructor() {
|
|
1017
986
|
this.cache = {};
|
|
1018
987
|
}
|
|
988
|
+
pruneExpired() {
|
|
989
|
+
const now = Date.now();
|
|
990
|
+
Object.keys(this.cache).forEach((key) => {
|
|
991
|
+
if (this.cache[key].expiration <= now) {
|
|
992
|
+
delete this.cache[key];
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
}
|
|
1019
996
|
get(key) {
|
|
1020
997
|
const cachedItem = this.cache[key];
|
|
1021
998
|
if (cachedItem && cachedItem.expiration > Date.now()) {
|
|
@@ -1025,6 +1002,7 @@ class CacheService {
|
|
|
1025
1002
|
return null;
|
|
1026
1003
|
}
|
|
1027
1004
|
set(key, data, expiresInMs) {
|
|
1005
|
+
this.pruneExpired();
|
|
1028
1006
|
const expiration = Date.now() + expiresInMs;
|
|
1029
1007
|
this.cache[key] = { data, expiration };
|
|
1030
1008
|
}
|
|
@@ -1113,73 +1091,33 @@ class BaseModel {
|
|
|
1113
1091
|
Object.assign(this, data);
|
|
1114
1092
|
}
|
|
1115
1093
|
}
|
|
1116
|
-
get attributeMetadata() {
|
|
1117
|
-
const attributesMetadata = this[AttributeMetadata];
|
|
1118
|
-
return attributesMetadata;
|
|
1119
|
-
}
|
|
1120
|
-
set attributeMetadata(val) {
|
|
1121
|
-
this[AttributeMetadata] = val;
|
|
1122
|
-
}
|
|
1123
|
-
get hasDirtyAttributes() {
|
|
1124
|
-
const attributesMetadata = this[AttributeMetadata];
|
|
1125
|
-
let hasDirtyAttributes = false;
|
|
1126
|
-
for (const propertyName in attributesMetadata) {
|
|
1127
|
-
if (attributesMetadata.hasOwnProperty(propertyName)) {
|
|
1128
|
-
const metadata = attributesMetadata[propertyName];
|
|
1129
|
-
if (metadata.hasDirtyAttributes) {
|
|
1130
|
-
hasDirtyAttributes = true;
|
|
1131
|
-
break;
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
return hasDirtyAttributes;
|
|
1136
|
-
}
|
|
1137
|
-
rollbackAttributes() {
|
|
1138
|
-
const attributesMetadata = this[AttributeMetadata];
|
|
1139
|
-
let metadata;
|
|
1140
|
-
for (const propertyName in attributesMetadata) {
|
|
1141
|
-
if (attributesMetadata.hasOwnProperty(propertyName)) {
|
|
1142
|
-
if (attributesMetadata[propertyName].hasDirtyAttributes) {
|
|
1143
|
-
this[propertyName] = attributesMetadata[propertyName].oldValue;
|
|
1144
|
-
metadata = {
|
|
1145
|
-
hasDirtyAttributes: false,
|
|
1146
|
-
newValue: attributesMetadata[propertyName].oldValue,
|
|
1147
|
-
oldValue: undefined
|
|
1148
|
-
};
|
|
1149
|
-
attributesMetadata[propertyName] = metadata;
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
this[AttributeMetadata] = attributesMetadata;
|
|
1154
|
-
}
|
|
1155
1094
|
get modelConfig() {
|
|
1156
1095
|
return MetadataStorage.getMetadata('BaseModelConfig', this.constructor);
|
|
1157
1096
|
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1097
|
+
getModelPropertyNames(model) {
|
|
1098
|
+
const staticFields = model.constructor.fields;
|
|
1099
|
+
if (Array.isArray(staticFields) && staticFields.length) {
|
|
1100
|
+
return staticFields.reduce((acc, key) => {
|
|
1101
|
+
acc[key] = key;
|
|
1102
|
+
return acc;
|
|
1103
|
+
}, {});
|
|
1104
|
+
}
|
|
1164
1105
|
const properties = {};
|
|
1165
|
-
Object.keys(
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1106
|
+
Object.keys(model)
|
|
1107
|
+
.filter((key) => !key.startsWith('_') && key !== 'highlighted')
|
|
1108
|
+
.forEach((key) => {
|
|
1109
|
+
properties[key] = key;
|
|
1169
1110
|
});
|
|
1170
1111
|
return properties;
|
|
1171
1112
|
}
|
|
1172
|
-
getModelPropertyNames(model) {
|
|
1173
|
-
return MetadataStorage.getMergedMetadata('AttributeMapping', model);
|
|
1174
|
-
}
|
|
1175
1113
|
getModelRequiredPropertyNames(model) {
|
|
1176
|
-
return
|
|
1114
|
+
return model.constructor.requiredFields || {};
|
|
1177
1115
|
}
|
|
1178
1116
|
getModelDefaultPropertyValues(model) {
|
|
1179
|
-
return
|
|
1117
|
+
return model.constructor.defaultValues || {};
|
|
1180
1118
|
}
|
|
1181
1119
|
getModelSubGroupPropertyNames(model) {
|
|
1182
|
-
return
|
|
1120
|
+
return model.constructor.formSubGroups || {};
|
|
1183
1121
|
}
|
|
1184
1122
|
getFromGroup(fb) {
|
|
1185
1123
|
const props = Object.keys(this.getModelPropertyNames(this));
|
|
@@ -1246,10 +1184,6 @@ class BaseModel {
|
|
|
1246
1184
|
return '';
|
|
1247
1185
|
}
|
|
1248
1186
|
}
|
|
1249
|
-
__decorate([
|
|
1250
|
-
Attribute({ serializedName: 'id' }),
|
|
1251
|
-
__metadata("design:type", Object)
|
|
1252
|
-
], BaseModel.prototype, "id", void 0);
|
|
1253
1187
|
|
|
1254
1188
|
class ErrorResponse {
|
|
1255
1189
|
constructor(errors) {
|
|
@@ -1323,49 +1257,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
1323
1257
|
|
|
1324
1258
|
class BaseDatastore {
|
|
1325
1259
|
// tslint:enable:max-line-length
|
|
1326
|
-
get getDirtyAttributes() {
|
|
1327
|
-
if (this.datastoreConfig.overrides
|
|
1328
|
-
&& this.datastoreConfig.overrides.getDirtyAttributes) {
|
|
1329
|
-
return this.datastoreConfig.overrides.getDirtyAttributes;
|
|
1330
|
-
}
|
|
1331
|
-
else {
|
|
1332
|
-
return BaseDatastore.getDirtyAttributes;
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
get getAllAttributes() {
|
|
1336
|
-
if (this.datastoreConfig.overrides
|
|
1337
|
-
&& this.datastoreConfig.overrides.getAllAttributes) {
|
|
1338
|
-
return this.datastoreConfig.overrides.getAllAttributes;
|
|
1339
|
-
}
|
|
1340
|
-
else {
|
|
1341
|
-
return BaseDatastore.getAllAttributes;
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
1260
|
// protected config: DatastoreConfig;
|
|
1345
|
-
static getDirtyAttributes(attributesMetadata) {
|
|
1346
|
-
const dirtyData = {};
|
|
1347
|
-
for (const propertyName in attributesMetadata) {
|
|
1348
|
-
if (attributesMetadata.hasOwnProperty(propertyName)) {
|
|
1349
|
-
const metadata = attributesMetadata[propertyName];
|
|
1350
|
-
if (metadata.hasDirtyAttributes) {
|
|
1351
|
-
const attributeName = metadata.serializedName != null ? metadata.serializedName : propertyName;
|
|
1352
|
-
dirtyData[attributeName] = metadata.serialisationValue ? metadata.serialisationValue : metadata.newValue;
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
return dirtyData;
|
|
1357
|
-
}
|
|
1358
|
-
static getAllAttributes(attributesMetadata) {
|
|
1359
|
-
const dirtyData = {};
|
|
1360
|
-
for (const propertyName in attributesMetadata) {
|
|
1361
|
-
if (attributesMetadata.hasOwnProperty(propertyName)) {
|
|
1362
|
-
const metadata = attributesMetadata[propertyName];
|
|
1363
|
-
const attributeName = metadata.serializedName != null ? metadata.serializedName : propertyName;
|
|
1364
|
-
dirtyData[attributeName] = metadata.serialisationValue ? metadata.serialisationValue : metadata.newValue;
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
return dirtyData;
|
|
1368
|
-
}
|
|
1369
1261
|
constructor(httpClient, cacheService) {
|
|
1370
1262
|
this.httpClient = httpClient;
|
|
1371
1263
|
this.cacheService = cacheService;
|
|
@@ -1373,16 +1265,15 @@ class BaseDatastore {
|
|
|
1373
1265
|
this._store = {};
|
|
1374
1266
|
// tslint:enable:max-line-length
|
|
1375
1267
|
// tslint:disable-next-line:ban-types
|
|
1376
|
-
this.toQueryString = this.datastoreConfig.overrides
|
|
1377
|
-
|
|
1378
|
-
|
|
1268
|
+
this.toQueryString = this.datastoreConfig.overrides && this.datastoreConfig.overrides.toQueryString
|
|
1269
|
+
? this.datastoreConfig.overrides.toQueryString
|
|
1270
|
+
: this._toQueryString;
|
|
1379
1271
|
}
|
|
1380
1272
|
findAll(modelType, params, headers, customUrl) {
|
|
1381
1273
|
const customHeadhers = this.buildHeaders(headers);
|
|
1382
1274
|
const htmlParams = this.buildParams(modelType, params);
|
|
1383
1275
|
const url = this.buildUrl(modelType, customUrl);
|
|
1384
|
-
const response = this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true })
|
|
1385
|
-
.pipe(map(res => this.extractQueryData(res, modelType)), catchError(this.handleError));
|
|
1276
|
+
const response = this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true }).pipe(map((res) => this.extractQueryData(res, modelType)), catchError(this.handleError));
|
|
1386
1277
|
return response;
|
|
1387
1278
|
}
|
|
1388
1279
|
findRecord(modelType, id, params, headers, customUrl) {
|
|
@@ -1392,8 +1283,7 @@ class BaseDatastore {
|
|
|
1392
1283
|
url += '/' + id;
|
|
1393
1284
|
}
|
|
1394
1285
|
const htmlParams = this.buildParams(modelType, params);
|
|
1395
|
-
const response = this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true })
|
|
1396
|
-
.pipe(map(res => this.entityToModel(res, modelType, undefined)), catchError(this.handleError));
|
|
1286
|
+
const response = this.httpClient.get(url, { headers: customHeadhers, params: htmlParams, withCredentials: true }).pipe(map((res) => this.entityToModel(res, modelType, undefined)), catchError(this.handleError));
|
|
1397
1287
|
return response;
|
|
1398
1288
|
}
|
|
1399
1289
|
getCustom(modelType, params, headers, customUrl, customResponseType) {
|
|
@@ -1402,16 +1292,21 @@ class BaseDatastore {
|
|
|
1402
1292
|
const htmlParams = this.buildParams(modelType, params);
|
|
1403
1293
|
if (!customResponseType)
|
|
1404
1294
|
customResponseType = 'json';
|
|
1405
|
-
return this.httpClient.get(url, {
|
|
1295
|
+
return this.httpClient.get(url, {
|
|
1296
|
+
headers: customHeadhers,
|
|
1297
|
+
params: htmlParams,
|
|
1298
|
+
withCredentials: true,
|
|
1299
|
+
responseType: customResponseType
|
|
1300
|
+
});
|
|
1406
1301
|
}
|
|
1407
1302
|
postCustom(modelType, body, params, headers, customUrl) {
|
|
1408
|
-
const customHeadhers = this.buildHeaders(headers);
|
|
1303
|
+
const customHeadhers = this.buildHeaders(headers, 'application/json');
|
|
1409
1304
|
const url = this.buildUrl(modelType, customUrl);
|
|
1410
1305
|
const htmlParams = this.buildParams(modelType, params);
|
|
1411
1306
|
return this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, reportProgress: true, withCredentials: true });
|
|
1412
1307
|
}
|
|
1413
1308
|
patchCustom(modelType, body, params, headers, customUrl) {
|
|
1414
|
-
const customHeadhers = this.buildHeaders(headers);
|
|
1309
|
+
const customHeadhers = this.buildHeaders(headers, 'application/json');
|
|
1415
1310
|
const url = this.buildUrl(modelType, customUrl);
|
|
1416
1311
|
const htmlParams = this.buildParams(modelType, params);
|
|
1417
1312
|
return this.httpClient.patch(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
|
|
@@ -1419,14 +1314,13 @@ class BaseDatastore {
|
|
|
1419
1314
|
createRecord(modelType, data) {
|
|
1420
1315
|
return new modelType(data);
|
|
1421
1316
|
}
|
|
1422
|
-
saveRecord(
|
|
1317
|
+
saveRecord(model, params, headers, customUrl, customBody) {
|
|
1423
1318
|
const modelType = model.constructor;
|
|
1424
|
-
const
|
|
1425
|
-
const customHeadhers = this.buildHeaders(headers);
|
|
1319
|
+
const customHeadhers = this.buildHeaders(headers, 'application/json');
|
|
1426
1320
|
const url = this.buildUrl(modelType, customUrl);
|
|
1427
1321
|
const htmlParams = this.buildParams(modelType, params);
|
|
1428
1322
|
let httpCall;
|
|
1429
|
-
const body = customBody || this.modelToEntity(model
|
|
1323
|
+
const body = customBody || this.modelToEntity(model);
|
|
1430
1324
|
if (model.id) {
|
|
1431
1325
|
// tslint:disable-next-line:max-line-length
|
|
1432
1326
|
httpCall = this.httpClient.patch(url + '/' + model.id, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
|
|
@@ -1434,33 +1328,27 @@ class BaseDatastore {
|
|
|
1434
1328
|
else {
|
|
1435
1329
|
httpCall = this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
|
|
1436
1330
|
}
|
|
1437
|
-
return httpCall
|
|
1438
|
-
.pipe(map(res => {
|
|
1331
|
+
return httpCall.pipe(map((res) => {
|
|
1439
1332
|
this.cacheService.clearCacheContainingKeyword(url);
|
|
1440
|
-
|
|
1441
|
-
return this.entityToModel(data, modelType);
|
|
1333
|
+
return this.entityToModel(res, modelType);
|
|
1442
1334
|
}), catchError(this.handleError));
|
|
1443
1335
|
}
|
|
1444
|
-
patchRecord(
|
|
1336
|
+
patchRecord(model, origModel, params, headers, customUrl) {
|
|
1445
1337
|
const modelType = model.constructor;
|
|
1446
|
-
const
|
|
1447
|
-
const customHeadhers = this.buildHeaders(headers);
|
|
1338
|
+
const customHeadhers = this.buildHeaders(headers, 'application/json-patch+json');
|
|
1448
1339
|
const url = this.buildUrl(modelType, customUrl);
|
|
1449
1340
|
const htmlParams = this.buildParams(modelType, params);
|
|
1450
1341
|
let httpCall;
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
const patch = compare(origData, newData);
|
|
1342
|
+
if (!origModel) {
|
|
1343
|
+
return this.replaceRecord(model, params, headers, customUrl);
|
|
1344
|
+
}
|
|
1345
|
+
model.id = origModel.id;
|
|
1346
|
+
const patch = compare(this.modelToEntity(origModel), this.modelToEntity(model));
|
|
1457
1347
|
if (patch.length > 0) {
|
|
1458
1348
|
httpCall = this.httpClient.patch(url + '/' + model.id, patch, { headers: customHeadhers, params: htmlParams, withCredentials: true });
|
|
1459
|
-
return httpCall
|
|
1460
|
-
.pipe(map(res => {
|
|
1349
|
+
return httpCall.pipe(map((res) => {
|
|
1461
1350
|
this.cacheService.clearCacheContainingKeyword(url);
|
|
1462
|
-
|
|
1463
|
-
return this.entityToModel(data, modelType);
|
|
1351
|
+
return this.entityToModel(res, modelType);
|
|
1464
1352
|
}), catchError(this.handleError));
|
|
1465
1353
|
}
|
|
1466
1354
|
else {
|
|
@@ -1474,25 +1362,22 @@ class BaseDatastore {
|
|
|
1474
1362
|
// model: T,
|
|
1475
1363
|
// origModel: T): any {
|
|
1476
1364
|
// }
|
|
1477
|
-
replaceRecord(
|
|
1365
|
+
replaceRecord(model, params, headers, customUrl, customBody) {
|
|
1478
1366
|
const modelType = model.constructor;
|
|
1479
|
-
const
|
|
1480
|
-
const customHeadhers = this.buildHeaders(headers);
|
|
1367
|
+
const customHeadhers = this.buildHeaders(headers, 'application/json');
|
|
1481
1368
|
const url = this.buildUrl(modelType, customUrl);
|
|
1482
1369
|
const htmlParams = this.buildParams(modelType, params);
|
|
1483
1370
|
let httpCall;
|
|
1484
|
-
const body = customBody || this.modelToEntity(model
|
|
1371
|
+
const body = customBody || this.modelToEntity(model);
|
|
1485
1372
|
if (model.id) {
|
|
1486
1373
|
httpCall = this.httpClient.put(url + '/' + model.id, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
|
|
1487
1374
|
}
|
|
1488
1375
|
else {
|
|
1489
1376
|
httpCall = this.httpClient.post(url, body, { headers: customHeadhers, params: htmlParams, withCredentials: true });
|
|
1490
1377
|
}
|
|
1491
|
-
return httpCall
|
|
1492
|
-
.pipe(map(res => {
|
|
1378
|
+
return httpCall.pipe(map((res) => {
|
|
1493
1379
|
this.cacheService.clearCacheContainingKeyword(url);
|
|
1494
|
-
|
|
1495
|
-
return this.entityToModel(data, modelType);
|
|
1380
|
+
return this.entityToModel(res, modelType);
|
|
1496
1381
|
}), catchError(this.handleError));
|
|
1497
1382
|
}
|
|
1498
1383
|
deleteRecord(modelType, id, headers, customUrl) {
|
|
@@ -1502,8 +1387,7 @@ class BaseDatastore {
|
|
|
1502
1387
|
url = url + '/' + id;
|
|
1503
1388
|
}
|
|
1504
1389
|
// const idParam = new HttpParams().set('id', id);
|
|
1505
|
-
return this.httpClient.delete(url, { headers: customHeadhers, withCredentials: true })
|
|
1506
|
-
.pipe(map(res => {
|
|
1390
|
+
return this.httpClient.delete(url, { headers: customHeadhers, withCredentials: true }).pipe(map((res) => {
|
|
1507
1391
|
this.cacheService.clearCacheContainingKeyword(url);
|
|
1508
1392
|
return res;
|
|
1509
1393
|
}), catchError(this.handleError));
|
|
@@ -1531,7 +1415,6 @@ class BaseDatastore {
|
|
|
1531
1415
|
return result;
|
|
1532
1416
|
}
|
|
1533
1417
|
deserializeModel(modelType, data) {
|
|
1534
|
-
data = this.transformSerializedNamesToPropertyNames(modelType, data);
|
|
1535
1418
|
return new modelType(data);
|
|
1536
1419
|
}
|
|
1537
1420
|
handleError(error) {
|
|
@@ -1553,60 +1436,20 @@ class BaseDatastore {
|
|
|
1553
1436
|
const metaModel = MetadataStorage.getMetadata('BaseModelConfig', modelType).meta;
|
|
1554
1437
|
return new metaModel(body);
|
|
1555
1438
|
}
|
|
1556
|
-
resetMetadataAttributes(res, attributesMetadata, modelType) {
|
|
1557
|
-
// TODO check why is attributesMetadata from the arguments never used
|
|
1558
|
-
for (const propertyName in attributesMetadata) {
|
|
1559
|
-
if (attributesMetadata.hasOwnProperty(propertyName)) {
|
|
1560
|
-
const metadata = attributesMetadata[propertyName];
|
|
1561
|
-
if (metadata.hasDirtyAttributes) {
|
|
1562
|
-
metadata.hasDirtyAttributes = false;
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
if (res) {
|
|
1567
|
-
res.attributeMetadata = attributesMetadata;
|
|
1568
|
-
}
|
|
1569
|
-
return res;
|
|
1570
|
-
}
|
|
1571
1439
|
get datastoreConfig() {
|
|
1572
1440
|
const configFromDecorator = MetadataStorage.getMetadata('BaseDatastoreConfig', this.constructor);
|
|
1573
1441
|
return Object.assign(configFromDecorator, this.config);
|
|
1574
1442
|
}
|
|
1575
|
-
|
|
1576
|
-
const apiFieldMap = this.getApiFieldMap(modelType);
|
|
1577
|
-
if (apiFieldMap) {
|
|
1578
|
-
const properties = {};
|
|
1579
|
-
Object.keys(apiFieldMap).forEach((serializedName) => {
|
|
1580
|
-
if (attributes[serializedName] !== null && attributes[serializedName] !== undefined) {
|
|
1581
|
-
properties[apiFieldMap[serializedName]] = attributes[serializedName];
|
|
1582
|
-
}
|
|
1583
|
-
});
|
|
1584
|
-
return properties;
|
|
1585
|
-
}
|
|
1586
|
-
const serializedNameToPropertyName = this.getModelPropertyNames(modelType.prototype);
|
|
1587
|
-
const properties = {};
|
|
1588
|
-
Object.keys(serializedNameToPropertyName).forEach((serializedName) => {
|
|
1589
|
-
if (attributes[serializedName] !== null && attributes[serializedName] !== undefined) {
|
|
1590
|
-
properties[serializedNameToPropertyName[serializedName]] = attributes[serializedName];
|
|
1591
|
-
}
|
|
1592
|
-
});
|
|
1593
|
-
return properties;
|
|
1594
|
-
}
|
|
1595
|
-
getModelPropertyNames(model) {
|
|
1596
|
-
return MetadataStorage.getMergedMetadata('AttributeMapping', model);
|
|
1597
|
-
}
|
|
1598
|
-
getApiFieldMap(modelType) {
|
|
1599
|
-
return modelType.apiFieldMap || null;
|
|
1600
|
-
}
|
|
1601
|
-
buildHeaders(customHeaders) {
|
|
1443
|
+
buildHeaders(customHeaders, contentType) {
|
|
1602
1444
|
const headers = {
|
|
1603
|
-
Accept: 'application/json
|
|
1604
|
-
// 'Content-Type': 'application/vnd.api+json',
|
|
1605
|
-
'Content-Type': 'application/json-patch+json'
|
|
1445
|
+
Accept: 'application/json'
|
|
1606
1446
|
};
|
|
1447
|
+
if (contentType) {
|
|
1448
|
+
headers['Content-Type'] = contentType;
|
|
1449
|
+
}
|
|
1607
1450
|
if (customHeaders && customHeaders.keys().length) {
|
|
1608
1451
|
// tslint:disable-next-line:variable-name
|
|
1609
|
-
Object.assign({}, headers, customHeaders.keys().map(header_name => {
|
|
1452
|
+
Object.assign({}, headers, customHeaders.keys().map((header_name) => {
|
|
1610
1453
|
headers['' + header_name] = customHeaders.get(header_name);
|
|
1611
1454
|
}));
|
|
1612
1455
|
}
|
|
@@ -1616,13 +1459,11 @@ class BaseDatastore {
|
|
|
1616
1459
|
let httpParams = new HttpParams();
|
|
1617
1460
|
if (params) {
|
|
1618
1461
|
Object.keys(params)
|
|
1619
|
-
.filter(key => {
|
|
1462
|
+
.filter((key) => {
|
|
1620
1463
|
const v = params[key];
|
|
1621
|
-
return
|
|
1622
|
-
(v.length > 0) :
|
|
1623
|
-
(v !== null && v !== undefined);
|
|
1464
|
+
return Array.isArray(v) || typeof v === 'string' ? v.length > 0 : v !== null && v !== undefined;
|
|
1624
1465
|
})
|
|
1625
|
-
.forEach(key => {
|
|
1466
|
+
.forEach((key) => {
|
|
1626
1467
|
httpParams = httpParams.set(key, params[key]);
|
|
1627
1468
|
});
|
|
1628
1469
|
}
|
|
@@ -1644,16 +1485,22 @@ class BaseDatastore {
|
|
|
1644
1485
|
const deserializedModel = model || this.deserializeModel(modelType, body.data || body);
|
|
1645
1486
|
return deserializedModel;
|
|
1646
1487
|
}
|
|
1647
|
-
modelToEntity(model
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
attributes = this.getAllAttributes(attributesMetadata, model);
|
|
1488
|
+
modelToEntity(model) {
|
|
1489
|
+
if (!model) {
|
|
1490
|
+
return model;
|
|
1651
1491
|
}
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1492
|
+
const entity = {};
|
|
1493
|
+
Object.keys(model).forEach((key) => {
|
|
1494
|
+
if (key.startsWith('_') || key === 'highlighted' || key === 'attributeMetadata') {
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1497
|
+
const value = model[key];
|
|
1498
|
+
if (typeof value === 'function') {
|
|
1499
|
+
return;
|
|
1500
|
+
}
|
|
1501
|
+
entity[key] = value;
|
|
1502
|
+
});
|
|
1503
|
+
return entity;
|
|
1657
1504
|
}
|
|
1658
1505
|
_toQueryString(params) {
|
|
1659
1506
|
return queryString.stringify(params, { arrayFormat: 'bracket' });
|
|
@@ -1688,90 +1535,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
1688
1535
|
|
|
1689
1536
|
let Employee = class Employee extends BaseModel {
|
|
1690
1537
|
};
|
|
1691
|
-
__decorate([
|
|
1692
|
-
Attribute({ serializedName: 'userName', required: true }),
|
|
1693
|
-
__metadata("design:type", String)
|
|
1694
|
-
], Employee.prototype, "userName", void 0);
|
|
1695
|
-
__decorate([
|
|
1696
|
-
Attribute({ serializedName: 'firstName', required: true }),
|
|
1697
|
-
__metadata("design:type", String)
|
|
1698
|
-
], Employee.prototype, "firstName", void 0);
|
|
1699
|
-
__decorate([
|
|
1700
|
-
Attribute({ serializedName: 'lastName', required: true }),
|
|
1701
|
-
__metadata("design:type", String)
|
|
1702
|
-
], Employee.prototype, "lastName", void 0);
|
|
1703
|
-
__decorate([
|
|
1704
|
-
Attribute({ serializedName: 'email', required: true }),
|
|
1705
|
-
__metadata("design:type", String)
|
|
1706
|
-
], Employee.prototype, "email", void 0);
|
|
1707
|
-
__decorate([
|
|
1708
|
-
Attribute({ serializedName: 'role', required: true }),
|
|
1709
|
-
__metadata("design:type", Object)
|
|
1710
|
-
], Employee.prototype, "role", void 0);
|
|
1711
|
-
__decorate([
|
|
1712
|
-
Attribute({ serializedName: 'password' }),
|
|
1713
|
-
__metadata("design:type", String)
|
|
1714
|
-
], Employee.prototype, "password", void 0);
|
|
1715
|
-
__decorate([
|
|
1716
|
-
Attribute({ serializedName: 'confirmPassword' }),
|
|
1717
|
-
__metadata("design:type", String)
|
|
1718
|
-
], Employee.prototype, "confirmPassword", void 0);
|
|
1719
|
-
__decorate([
|
|
1720
|
-
Attribute({ serializedName: 'extraData' }),
|
|
1721
|
-
__metadata("design:type", String)
|
|
1722
|
-
], Employee.prototype, "extraData", void 0);
|
|
1723
1538
|
Employee = __decorate([
|
|
1724
1539
|
BaseModelConfig({
|
|
1725
1540
|
type: 'employee'
|
|
1726
1541
|
})
|
|
1727
1542
|
], Employee);
|
|
1728
1543
|
|
|
1544
|
+
let File = class File extends BaseModel {
|
|
1545
|
+
constructor() {
|
|
1546
|
+
super(...arguments);
|
|
1547
|
+
// Gets or sets if the file is a temporary one and not saved to s3
|
|
1548
|
+
this.isTemporary = false;
|
|
1549
|
+
}
|
|
1550
|
+
};
|
|
1551
|
+
File = __decorate([
|
|
1552
|
+
BaseModelConfig({
|
|
1553
|
+
type: 'file'
|
|
1554
|
+
})
|
|
1555
|
+
], File);
|
|
1556
|
+
|
|
1729
1557
|
let Menu = class Menu extends BaseModel {
|
|
1730
1558
|
};
|
|
1731
|
-
__decorate([
|
|
1732
|
-
Attribute({ serializedName: 'header' }),
|
|
1733
|
-
__metadata("design:type", String)
|
|
1734
|
-
], Menu.prototype, "header", void 0);
|
|
1735
|
-
__decorate([
|
|
1736
|
-
Attribute({ serializedName: 'icon' }),
|
|
1737
|
-
__metadata("design:type", String)
|
|
1738
|
-
], Menu.prototype, "icon", void 0);
|
|
1739
|
-
__decorate([
|
|
1740
|
-
Attribute({ serializedName: 'link' }),
|
|
1741
|
-
__metadata("design:type", String)
|
|
1742
|
-
], Menu.prototype, "link", void 0);
|
|
1743
|
-
__decorate([
|
|
1744
|
-
Attribute({ serializedName: 'title' }),
|
|
1745
|
-
__metadata("design:type", String)
|
|
1746
|
-
], Menu.prototype, "title", void 0);
|
|
1747
|
-
__decorate([
|
|
1748
|
-
Attribute({ serializedName: 'sublinks' }),
|
|
1749
|
-
__metadata("design:type", Array)
|
|
1750
|
-
], Menu.prototype, "sublinks", void 0);
|
|
1751
|
-
__decorate([
|
|
1752
|
-
Attribute({ serializedName: 'target' }),
|
|
1753
|
-
__metadata("design:type", String)
|
|
1754
|
-
], Menu.prototype, "target", void 0);
|
|
1755
|
-
__decorate([
|
|
1756
|
-
Attribute({ serializedName: 'external' }),
|
|
1757
|
-
__metadata("design:type", Boolean)
|
|
1758
|
-
], Menu.prototype, "external", void 0);
|
|
1759
|
-
__decorate([
|
|
1760
|
-
Attribute({ serializedName: 'description' }),
|
|
1761
|
-
__metadata("design:type", String)
|
|
1762
|
-
], Menu.prototype, "description", void 0);
|
|
1763
|
-
__decorate([
|
|
1764
|
-
Attribute({ serializedName: 'order' }),
|
|
1765
|
-
__metadata("design:type", Number)
|
|
1766
|
-
], Menu.prototype, "order", void 0);
|
|
1767
|
-
__decorate([
|
|
1768
|
-
Attribute({ serializedName: 'translationKey' }),
|
|
1769
|
-
__metadata("design:type", String)
|
|
1770
|
-
], Menu.prototype, "translationKey", void 0);
|
|
1771
|
-
__decorate([
|
|
1772
|
-
Attribute({ serializedName: 'color' }),
|
|
1773
|
-
__metadata("design:type", String)
|
|
1774
|
-
], Menu.prototype, "color", void 0);
|
|
1775
1559
|
Menu = __decorate([
|
|
1776
1560
|
BaseModelConfig({
|
|
1777
1561
|
type: 'user',
|
|
@@ -1781,46 +1565,6 @@ Menu = __decorate([
|
|
|
1781
1565
|
|
|
1782
1566
|
let Right = class Right extends BaseModel {
|
|
1783
1567
|
};
|
|
1784
|
-
__decorate([
|
|
1785
|
-
Attribute({ serializedName: 'name' }),
|
|
1786
|
-
__metadata("design:type", String)
|
|
1787
|
-
], Right.prototype, "name", void 0);
|
|
1788
|
-
__decorate([
|
|
1789
|
-
Attribute({ serializedName: 'rightKey' }),
|
|
1790
|
-
__metadata("design:type", String)
|
|
1791
|
-
], Right.prototype, "rightKey", void 0);
|
|
1792
|
-
__decorate([
|
|
1793
|
-
Attribute({ serializedName: 'pagePath' }),
|
|
1794
|
-
__metadata("design:type", String)
|
|
1795
|
-
], Right.prototype, "pagePath", void 0);
|
|
1796
|
-
__decorate([
|
|
1797
|
-
Attribute({ serializedName: 'order' }),
|
|
1798
|
-
__metadata("design:type", Number)
|
|
1799
|
-
], Right.prototype, "order", void 0);
|
|
1800
|
-
__decorate([
|
|
1801
|
-
Attribute({ serializedName: 'isMenu' }),
|
|
1802
|
-
__metadata("design:type", Boolean)
|
|
1803
|
-
], Right.prototype, "isMenu", void 0);
|
|
1804
|
-
__decorate([
|
|
1805
|
-
Attribute({ serializedName: 'resourceName' }),
|
|
1806
|
-
__metadata("design:type", String)
|
|
1807
|
-
], Right.prototype, "resourceName", void 0);
|
|
1808
|
-
__decorate([
|
|
1809
|
-
Attribute({ serializedName: 'parentId' }),
|
|
1810
|
-
__metadata("design:type", String)
|
|
1811
|
-
], Right.prototype, "parentId", void 0);
|
|
1812
|
-
__decorate([
|
|
1813
|
-
Attribute({ serializedName: 'color' }),
|
|
1814
|
-
__metadata("design:type", String)
|
|
1815
|
-
], Right.prototype, "color", void 0);
|
|
1816
|
-
__decorate([
|
|
1817
|
-
Attribute({ serializedName: 'defaultRoles' }),
|
|
1818
|
-
__metadata("design:type", String)
|
|
1819
|
-
], Right.prototype, "defaultRoles", void 0);
|
|
1820
|
-
__decorate([
|
|
1821
|
-
Attribute({ serializedName: 'icon' }),
|
|
1822
|
-
__metadata("design:type", String)
|
|
1823
|
-
], Right.prototype, "icon", void 0);
|
|
1824
1568
|
Right = __decorate([
|
|
1825
1569
|
BaseModelConfig({
|
|
1826
1570
|
type: 'right',
|
|
@@ -1830,14 +1574,6 @@ Right = __decorate([
|
|
|
1830
1574
|
|
|
1831
1575
|
let Role = class Role extends BaseModel {
|
|
1832
1576
|
};
|
|
1833
|
-
__decorate([
|
|
1834
|
-
Attribute({ serializedName: 'name' }),
|
|
1835
|
-
__metadata("design:type", String)
|
|
1836
|
-
], Role.prototype, "name", void 0);
|
|
1837
|
-
__decorate([
|
|
1838
|
-
Attribute({ serializedName: 'roleDetail' }),
|
|
1839
|
-
__metadata("design:type", Object)
|
|
1840
|
-
], Role.prototype, "roleDetail", void 0);
|
|
1841
1577
|
Role = __decorate([
|
|
1842
1578
|
BaseModelConfig({
|
|
1843
1579
|
type: 'role'
|
|
@@ -1849,18 +1585,6 @@ let User = class User extends BaseModel {
|
|
|
1849
1585
|
return this.firstName + ' ' + this.lastName;
|
|
1850
1586
|
}
|
|
1851
1587
|
};
|
|
1852
|
-
__decorate([
|
|
1853
|
-
Attribute({ serializedName: 'firstName' }),
|
|
1854
|
-
__metadata("design:type", String)
|
|
1855
|
-
], User.prototype, "firstName", void 0);
|
|
1856
|
-
__decorate([
|
|
1857
|
-
Attribute({ serializedName: 'lastName' }),
|
|
1858
|
-
__metadata("design:type", String)
|
|
1859
|
-
], User.prototype, "lastName", void 0);
|
|
1860
|
-
__decorate([
|
|
1861
|
-
Attribute({ serializedName: 'email' }),
|
|
1862
|
-
__metadata("design:type", String)
|
|
1863
|
-
], User.prototype, "email", void 0);
|
|
1864
1588
|
User = __decorate([
|
|
1865
1589
|
BaseModelConfig({
|
|
1866
1590
|
type: 'user'
|
|
@@ -1885,6 +1609,50 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
1885
1609
|
args: [DATASTORE_PORT]
|
|
1886
1610
|
}] }] });
|
|
1887
1611
|
|
|
1612
|
+
class FileService extends BaseService {
|
|
1613
|
+
constructor(datastore, httpClient) {
|
|
1614
|
+
super(datastore);
|
|
1615
|
+
this.httpClient = httpClient;
|
|
1616
|
+
this.setModelType(File);
|
|
1617
|
+
}
|
|
1618
|
+
upload(file, filename) {
|
|
1619
|
+
const url = `${this.datastore.buildUrl(this.modelType)}/upload`;
|
|
1620
|
+
const formData = new FormData();
|
|
1621
|
+
const safeName = filename || file.name || `upload-${Date.now()}`;
|
|
1622
|
+
formData.append('file', file, safeName);
|
|
1623
|
+
return this.httpClient.post(url, formData, { withCredentials: true });
|
|
1624
|
+
}
|
|
1625
|
+
download(fileId, responseType = 'blob') {
|
|
1626
|
+
const url = `${this.datastore.buildUrl(this.modelType)}/download`;
|
|
1627
|
+
const params = new HttpParams().set('fileId', fileId);
|
|
1628
|
+
return this.httpClient.get(url, {
|
|
1629
|
+
params,
|
|
1630
|
+
withCredentials: true,
|
|
1631
|
+
responseType: responseType
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
fileUrl(fileId) {
|
|
1635
|
+
const url = `${this.datastore.buildUrl(this.modelType)}/${fileId}/fileurl`;
|
|
1636
|
+
return this.httpClient.get(url, { withCredentials: true });
|
|
1637
|
+
}
|
|
1638
|
+
putFileUrl(fileId) {
|
|
1639
|
+
const url = `${this.datastore.buildUrl(this.modelType)}/putfileurl`;
|
|
1640
|
+
const params = new HttpParams().set('fileId', fileId);
|
|
1641
|
+
return this.httpClient.get(url, { params, withCredentials: true });
|
|
1642
|
+
}
|
|
1643
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: FileService, deps: [{ token: DATASTORE_PORT }, { token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1644
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: FileService, providedIn: 'root' }); }
|
|
1645
|
+
}
|
|
1646
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: FileService, decorators: [{
|
|
1647
|
+
type: Injectable,
|
|
1648
|
+
args: [{
|
|
1649
|
+
providedIn: 'root'
|
|
1650
|
+
}]
|
|
1651
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1652
|
+
type: Inject,
|
|
1653
|
+
args: [DATASTORE_PORT]
|
|
1654
|
+
}] }, { type: i1$1.HttpClient }] });
|
|
1655
|
+
|
|
1888
1656
|
class LocalFileService {
|
|
1889
1657
|
constructor(http) {
|
|
1890
1658
|
this.http = http;
|
|
@@ -1898,11 +1666,15 @@ class LocalFileService {
|
|
|
1898
1666
|
this.cache.set(jsonUrl, dataSubject);
|
|
1899
1667
|
this.http
|
|
1900
1668
|
.get(jsonUrl)
|
|
1901
|
-
.pipe(tap((data) => dataSubject.next(data)) // Cache the fetched data
|
|
1902
|
-
)
|
|
1903
1669
|
.subscribe({
|
|
1904
|
-
next: (data) =>
|
|
1905
|
-
|
|
1670
|
+
next: (data) => {
|
|
1671
|
+
dataSubject.next(data);
|
|
1672
|
+
dataSubject.complete();
|
|
1673
|
+
},
|
|
1674
|
+
error: (err) => {
|
|
1675
|
+
this.cache.delete(jsonUrl);
|
|
1676
|
+
dataSubject.error(err);
|
|
1677
|
+
}
|
|
1906
1678
|
});
|
|
1907
1679
|
return dataSubject.asObservable(); // Return observable
|
|
1908
1680
|
}
|
|
@@ -2206,5 +1978,5 @@ function getValueFromJsonData(jsonData, key) {
|
|
|
2206
1978
|
* Generated bundle index. Do not edit.
|
|
2207
1979
|
*/
|
|
2208
1980
|
|
|
2209
|
-
export {
|
|
1981
|
+
export { AuthService, BaseCrudImplementation, BaseDatastore, BaseDatastoreConfig, BaseFormEditComponent, BaseMetaModel, BaseModel, BaseModelConfig, BaseQueryData, BaseService, BaseTableImplementation, CacheInterceptor, CacheService, CellTextAlign, Configurations, CustomType, CustomValidators, DATASTORE_PORT, DIALOG_SERVICE_TOKEN, DatastoreCore, DynamicallyModelResolver, DynamicallyServiceResolver, Employee, EmployeeService, ErrorResponse, FieldErrorDisplayComponent, File, FileService, GridLayoutFormat, InputErrorPipe, LocalFileService, MODEL_SERVICE, MODEL_TOKEN, Menu, MetadataStorage, Nl2brPipe, OIDC_CLIENT_SETTINGS, OIDC_GUEST_CLIENT_SETTINGS, PROVIDERS, PageNotFoundComponent, RSL_FORM_IMPLEMENTATIONS_TOKEN, Right, RightService, Role, RoleService, RouteHistoryService, RslBaseModule, Rule, Tokens, TranslateloaderService, UnderConstructionComponent, User, UserService, getValueFromJsonData, provideAuth, provideOidcUserManager, readFileAsync };
|
|
2210
1982
|
//# sourceMappingURL=rosoftlab-core.mjs.map
|