@yomotech/view-toolkit 0.0.55 → 0.0.56
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.
|
@@ -860,10 +860,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.2", ngImpor
|
|
|
860
860
|
|
|
861
861
|
class Couchdb {
|
|
862
862
|
utilityService;
|
|
863
|
+
platform;
|
|
863
864
|
remoteCouchDbBaseUrl = 'https://couchdb.yomotech.de';
|
|
864
865
|
webProxyBaseUrl = '/couchdb-api';
|
|
865
|
-
constructor(utilityService) {
|
|
866
|
+
constructor(utilityService, platform) {
|
|
866
867
|
this.utilityService = utilityService;
|
|
868
|
+
this.platform = platform;
|
|
867
869
|
}
|
|
868
870
|
async getTenantDatabases(tenantKey) {
|
|
869
871
|
const normalizedTenantKey = tenantKey?.trim();
|
|
@@ -883,7 +885,7 @@ class Couchdb {
|
|
|
883
885
|
}
|
|
884
886
|
if (result.data &&
|
|
885
887
|
Array.isArray(result.data.databases)) {
|
|
886
|
-
return result.data
|
|
888
|
+
return result.data;
|
|
887
889
|
}
|
|
888
890
|
throw new Error(`Invalid /tenant-dbs response: ` +
|
|
889
891
|
`${this.stringifyErrorDetails(result.data)}`);
|
|
@@ -904,30 +906,21 @@ class Couchdb {
|
|
|
904
906
|
const result = await this.sendGetRequest(path, await this.getReadHeaders());
|
|
905
907
|
const doc = result.data;
|
|
906
908
|
if (!result.ok) {
|
|
907
|
-
console.error(`Failed to fetch file "${docId}" ` +
|
|
908
|
-
`from "${dbName}": ` +
|
|
909
|
-
`${result.status}`, doc);
|
|
909
|
+
console.error(`Failed to fetch file "${docId}" ` + `from "${dbName}": ` + `${result.status}`, doc);
|
|
910
910
|
return null;
|
|
911
911
|
}
|
|
912
912
|
if (!doc?.data) {
|
|
913
|
-
console.error(`Document "${docId}" ` +
|
|
914
|
-
`does not contain file data`);
|
|
913
|
+
console.error(`Document "${docId}" ` + `does not contain file data`);
|
|
915
914
|
return null;
|
|
916
915
|
}
|
|
917
|
-
const fileName = doc.name ||
|
|
918
|
-
|
|
919
|
-
docId;
|
|
920
|
-
if (doc.type === 'media' ||
|
|
921
|
-
doc.type === 'base64file' ||
|
|
922
|
-
this.isBinaryMediaFile(fileName, doc.contentType)) {
|
|
916
|
+
const fileName = doc.name || doc.path || docId;
|
|
917
|
+
if (doc.type === 'media' || doc.type === 'base64file' || this.isBinaryMediaFile(fileName, doc.contentType)) {
|
|
923
918
|
const mimeType = this.getMimeType(fileName, doc.contentType);
|
|
924
919
|
return {
|
|
925
|
-
type: doc.type ||
|
|
926
|
-
'base64file',
|
|
920
|
+
type: doc.type || 'base64file',
|
|
927
921
|
mimeType,
|
|
928
922
|
base64: doc.data,
|
|
929
|
-
src: `data:${mimeType};base64,` +
|
|
930
|
-
`${doc.data}`,
|
|
923
|
+
src: `data:${mimeType};base64,` + `${doc.data}`,
|
|
931
924
|
name: doc.name,
|
|
932
925
|
path: doc.path,
|
|
933
926
|
metadata: doc.metadata || {},
|
|
@@ -992,7 +985,6 @@ class Couchdb {
|
|
|
992
985
|
}
|
|
993
986
|
async sendNativeGetRequest(path, headers) {
|
|
994
987
|
const url = `${this.remoteCouchDbBaseUrl}${path}`;
|
|
995
|
-
console.log('[CouchDB][Native] GET:', url);
|
|
996
988
|
try {
|
|
997
989
|
const response = await CapacitorHttp.get({
|
|
998
990
|
url,
|
|
@@ -1009,7 +1001,7 @@ class Couchdb {
|
|
|
1009
1001
|
};
|
|
1010
1002
|
}
|
|
1011
1003
|
catch (error) {
|
|
1012
|
-
console.
|
|
1004
|
+
console.log('[CouchDB][Native] Request failed:', error);
|
|
1013
1005
|
return {
|
|
1014
1006
|
ok: false,
|
|
1015
1007
|
status: this.extractNativeErrorStatus(error),
|
|
@@ -1073,8 +1065,7 @@ class Couchdb {
|
|
|
1073
1065
|
getDocumentPath(dbName, docId) {
|
|
1074
1066
|
const encodedDbName = encodeURIComponent(dbName.trim().toLowerCase());
|
|
1075
1067
|
const encodedDocId = encodeURIComponent(docId.trim());
|
|
1076
|
-
return (`/${encodedDbName}/` +
|
|
1077
|
-
`${encodedDocId}`);
|
|
1068
|
+
return (`/${encodedDbName}/` + `${encodedDocId}`);
|
|
1078
1069
|
}
|
|
1079
1070
|
async getReadHeaders() {
|
|
1080
1071
|
return {
|
|
@@ -1083,31 +1074,27 @@ class Couchdb {
|
|
|
1083
1074
|
};
|
|
1084
1075
|
}
|
|
1085
1076
|
async buildTenantHeaders() {
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
.getLocalStorage('
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1077
|
+
let tenantKey = "";
|
|
1078
|
+
let tenantName = "";
|
|
1079
|
+
if (this.platform.ANDROID || this.platform.IOS) {
|
|
1080
|
+
tenantKey = await this.utilityService.getLocalStorage('tenantKey');
|
|
1081
|
+
tenantName = await this.utilityService.getLocalStorage('tenantName');
|
|
1082
|
+
}
|
|
1083
|
+
else {
|
|
1084
|
+
tenantKey = await this.utilityService.getStorage('tenantKey');
|
|
1085
|
+
tenantName = await this.utilityService.getStorage('tenantName');
|
|
1086
|
+
}
|
|
1087
|
+
const selectedTenant = await this.utilityService.getLocalStorage('selectedTenant');
|
|
1088
|
+
if (typeof tenantKey === 'string' && tenantKey.trim()) {
|
|
1089
|
+
return { 'X-Tenant-Key': tenantKey.trim() };
|
|
1095
1090
|
}
|
|
1096
|
-
const normalizedTenantName = typeof tenantName === 'string'
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
const normalizedSelectedTenant = typeof selectedTenant === 'string'
|
|
1100
|
-
? selectedTenant.trim()
|
|
1101
|
-
: '';
|
|
1102
|
-
const tenant = normalizedTenantName ||
|
|
1103
|
-
normalizedSelectedTenant;
|
|
1091
|
+
const normalizedTenantName = typeof tenantName === 'string' ? tenantName.trim() : '';
|
|
1092
|
+
const normalizedSelectedTenant = typeof selectedTenant === 'string' ? selectedTenant.trim() : '';
|
|
1093
|
+
const tenant = normalizedTenantName || normalizedSelectedTenant;
|
|
1104
1094
|
if (!tenant) {
|
|
1105
|
-
throw new Error('Missing tenantKey, tenantName, ' +
|
|
1106
|
-
'or selectedTenant');
|
|
1095
|
+
throw new Error('Missing tenantKey, tenantName, ' + 'or selectedTenant');
|
|
1107
1096
|
}
|
|
1108
|
-
return {
|
|
1109
|
-
'X-Tenant': tenant,
|
|
1110
|
-
};
|
|
1097
|
+
return { 'X-Tenant': tenant, };
|
|
1111
1098
|
}
|
|
1112
1099
|
async parseJsonOrText(response) {
|
|
1113
1100
|
const rawText = await response.text();
|
|
@@ -1223,7 +1210,7 @@ class Couchdb {
|
|
|
1223
1210
|
}
|
|
1224
1211
|
return 'application/octet-stream';
|
|
1225
1212
|
}
|
|
1226
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: Couchdb, deps: [{ token: UtilityService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1213
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: Couchdb, deps: [{ token: UtilityService }, { token: i1.Platform }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1227
1214
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: Couchdb, providedIn: 'root' });
|
|
1228
1215
|
}
|
|
1229
1216
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: Couchdb, decorators: [{
|
|
@@ -1231,7 +1218,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.2", ngImpor
|
|
|
1231
1218
|
args: [{
|
|
1232
1219
|
providedIn: 'root',
|
|
1233
1220
|
}]
|
|
1234
|
-
}], ctorParameters: () => [{ type: UtilityService }] });
|
|
1221
|
+
}], ctorParameters: () => [{ type: UtilityService }, { type: i1.Platform }] });
|
|
1235
1222
|
|
|
1236
1223
|
class ConfigService {
|
|
1237
1224
|
couchdbService;
|
|
@@ -1292,7 +1279,10 @@ class ConfigService {
|
|
|
1292
1279
|
this.config = {
|
|
1293
1280
|
issuer: 'http://dummy',
|
|
1294
1281
|
clientId: 'dummy',
|
|
1295
|
-
redirectUri:
|
|
1282
|
+
redirectUri: window.location.origin,
|
|
1283
|
+
responseType: 'code',
|
|
1284
|
+
scope: 'openid profile email',
|
|
1285
|
+
showDebugInformation: true,
|
|
1296
1286
|
pkce: true,
|
|
1297
1287
|
};
|
|
1298
1288
|
}
|
|
@@ -1357,7 +1347,7 @@ class ConfigService {
|
|
|
1357
1347
|
if (!this.keycloakConfig)
|
|
1358
1348
|
return null;
|
|
1359
1349
|
return {
|
|
1360
|
-
issuer: this.keycloakConfig?.issuer,
|
|
1350
|
+
issuer: this.keycloakConfig?.issuer ?? 'http://dummy',
|
|
1361
1351
|
clientId: this.keycloakConfig?.clientId,
|
|
1362
1352
|
redirectUri: this.keycloakConfig.redirectUri,
|
|
1363
1353
|
logoutRedirectUri: this.keycloakConfig.logoutRedirectUri,
|