attlaz-client 1.10.14 → 1.10.16
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/dist/Model/Adapter/AdapterConnection.d.ts +0 -2
- package/dist/Model/Adapter/AdapterConnection.js +2 -4
- package/dist/Model/DataValueCollection.d.ts +1 -0
- package/dist/Model/DataValueCollection.js +8 -0
- package/dist/Service/AdapterEndpoint.d.ts +4 -1
- package/dist/Service/AdapterEndpoint.js +39 -2
- package/dist/Service/UserEndpoint.js +9 -3
- package/dist/Service/WorkspaceEndpoint.js +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { DataValueCollection } from '../DataValueCollection.js';
|
|
2
1
|
export declare class AdapterConnection {
|
|
3
2
|
id: string;
|
|
4
3
|
key: string;
|
|
5
4
|
adapter: string;
|
|
6
5
|
name: string;
|
|
7
6
|
projectId: string;
|
|
8
|
-
configuration: DataValueCollection;
|
|
9
7
|
constructor();
|
|
10
8
|
static parse(rawAdapterConnection: any): AdapterConnection;
|
|
11
9
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { DataValueCollection } from '../DataValueCollection.js';
|
|
2
1
|
export class AdapterConnection {
|
|
3
2
|
id;
|
|
4
3
|
key;
|
|
5
4
|
adapter;
|
|
6
5
|
name;
|
|
7
6
|
projectId;
|
|
8
|
-
configuration;
|
|
7
|
+
// configuration: DataValueCollection;
|
|
9
8
|
constructor() {
|
|
10
|
-
this.configuration = new DataValueCollection();
|
|
11
9
|
}
|
|
12
10
|
static parse(rawAdapterConnection) {
|
|
13
11
|
const adapterConnection = new AdapterConnection();
|
|
@@ -16,7 +14,7 @@ export class AdapterConnection {
|
|
|
16
14
|
adapterConnection.adapter = rawAdapterConnection.adapter;
|
|
17
15
|
adapterConnection.name = rawAdapterConnection.name;
|
|
18
16
|
adapterConnection.projectId = rawAdapterConnection.project;
|
|
19
|
-
adapterConnection.configuration = DataValueCollection.fromObject(rawAdapterConnection.configuration);
|
|
17
|
+
// adapterConnection.configuration = DataValueCollection.fromObject(rawAdapterConnection.configuration);
|
|
20
18
|
return adapterConnection;
|
|
21
19
|
// adapter.id = rawAdapter.id;
|
|
22
20
|
// adapter.name = rawAdapter.name;
|
|
@@ -8,6 +8,7 @@ export declare class DataValueCollection extends JsonSerializable implements Ite
|
|
|
8
8
|
value: DataValueValue;
|
|
9
9
|
}[]): DataValueCollection;
|
|
10
10
|
set(key: string, value: DataValueValue): void;
|
|
11
|
+
has(key: string): boolean;
|
|
11
12
|
get(key: string): DataValueValue | null;
|
|
12
13
|
unset(key: string): void;
|
|
13
14
|
serialize(): string | null;
|
|
@@ -24,6 +24,14 @@ export class DataValueCollection extends JsonSerializable {
|
|
|
24
24
|
}
|
|
25
25
|
this._values.push(new DataValue(key, value));
|
|
26
26
|
}
|
|
27
|
+
has(key) {
|
|
28
|
+
for (const tag of this._values) {
|
|
29
|
+
if (tag.key === key) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
27
35
|
get(key) {
|
|
28
36
|
for (const tag of this._values) {
|
|
29
37
|
if (tag.key === key) {
|
|
@@ -3,11 +3,14 @@ import { Adapter } from '../Model/Adapter/Adapter.js';
|
|
|
3
3
|
import { AdapterConnection } from '../Model/Adapter/AdapterConnection.js';
|
|
4
4
|
import { AdapterConfiguration } from '../Model/Adapter/AdapterConfiguration.js';
|
|
5
5
|
import { CollectionResult } from '../Model/Result/CollectionResult.js';
|
|
6
|
+
import { DataValueCollection } from '../Model/DataValueCollection';
|
|
6
7
|
export declare class AdapterEndpoint extends Endpoint {
|
|
7
8
|
getAdapters(): Promise<CollectionResult<Adapter>>;
|
|
8
9
|
getAdapter(adapterId: string): Promise<Adapter | null>;
|
|
9
10
|
getAdapterConfiguration(adapterId: string): Promise<CollectionResult<AdapterConfiguration>>;
|
|
10
11
|
getConnections(projectId: string): Promise<CollectionResult<AdapterConnection>>;
|
|
11
12
|
getConnectionByKey(connectionKey: string): Promise<AdapterConnection | null>;
|
|
12
|
-
|
|
13
|
+
getConnectionConfiguration(connectionId: string): Promise<DataValueCollection | null>;
|
|
14
|
+
saveConnection(projectId: string, connection: AdapterConnection): Promise<AdapterConnection>;
|
|
15
|
+
saveConnectionConfiguration(connectionId: string, configuration: DataValueCollection): Promise<boolean>;
|
|
13
16
|
}
|
|
@@ -2,6 +2,7 @@ import { Endpoint } from './Endpoint.js';
|
|
|
2
2
|
import { Adapter } from '../Model/Adapter/Adapter.js';
|
|
3
3
|
import { AdapterConnection } from '../Model/Adapter/AdapterConnection.js';
|
|
4
4
|
import { AdapterConfiguration } from '../Model/Adapter/AdapterConfiguration.js';
|
|
5
|
+
import { DataValueCollection } from '../Model/DataValueCollection';
|
|
5
6
|
export class AdapterEndpoint extends Endpoint {
|
|
6
7
|
async getAdapters() {
|
|
7
8
|
try {
|
|
@@ -65,10 +66,28 @@ export class AdapterEndpoint extends Endpoint {
|
|
|
65
66
|
throw error;
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
|
-
async
|
|
69
|
+
async getConnectionConfiguration(connectionId) {
|
|
70
|
+
try {
|
|
71
|
+
const url = '/connections/' + connectionId + '/configuration';
|
|
72
|
+
const parser = (raw) => (DataValueCollection.fromObject(raw.configuration));
|
|
73
|
+
const result = await this.requestObject(url, null, parser);
|
|
74
|
+
const configuration = result.getData();
|
|
75
|
+
if (configuration === null) {
|
|
76
|
+
throw new Error('Adapter configuration loaded');
|
|
77
|
+
}
|
|
78
|
+
return configuration;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (this.httpClient.isDebugEnabled()) {
|
|
82
|
+
console.error('Failed to load connection: ', error);
|
|
83
|
+
}
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async saveConnection(projectId, connection) {
|
|
69
88
|
try {
|
|
70
89
|
const url = '/projects/' + projectId + '/connections';
|
|
71
|
-
const result = await this.requestObject(url,
|
|
90
|
+
const result = await this.requestObject(url, connection, AdapterConnection.parse, 'POST');
|
|
72
91
|
const updatedAdapterConnection = result.getData();
|
|
73
92
|
if (updatedAdapterConnection === null) {
|
|
74
93
|
throw new Error('AdapterConnection not updated');
|
|
@@ -82,4 +101,22 @@ export class AdapterEndpoint extends Endpoint {
|
|
|
82
101
|
throw error;
|
|
83
102
|
}
|
|
84
103
|
}
|
|
104
|
+
async saveConnectionConfiguration(connectionId, configuration) {
|
|
105
|
+
try {
|
|
106
|
+
const url = '/connections/' + connectionId + '/configuration';
|
|
107
|
+
const parser = (raw) => ({ saved: raw.saved });
|
|
108
|
+
const result = await this.requestObject(url, { configuration: configuration }, parser, 'POST');
|
|
109
|
+
const x = result.getData();
|
|
110
|
+
if (x === null) {
|
|
111
|
+
throw new Error('Unable to save connection configuration: wrong response from API');
|
|
112
|
+
}
|
|
113
|
+
return x.saved;
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
if (this.httpClient.isDebugEnabled()) {
|
|
117
|
+
console.error('Failed to save connection: ', error);
|
|
118
|
+
}
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
85
122
|
}
|
|
@@ -38,9 +38,15 @@ export class UserEndpoint extends Endpoint {
|
|
|
38
38
|
async createAuthProvider(providerType, data) {
|
|
39
39
|
try {
|
|
40
40
|
const parser = (raw) => raw;
|
|
41
|
-
const result = await this.requestObject('/users/auth/providers', {
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
const result = await this.requestObject('/users/auth/providers', {
|
|
42
|
+
provider_type: providerType, code: data.code, state: data.state
|
|
43
|
+
}, parser, 'POST');
|
|
44
|
+
const re = result.getData();
|
|
45
|
+
if (re === null) {
|
|
46
|
+
console.log('create auth provider wrong data', { result, parsed: re });
|
|
47
|
+
throw new Error('Unable to create auth provider: wrong response from API');
|
|
48
|
+
}
|
|
49
|
+
return re.created;
|
|
44
50
|
}
|
|
45
51
|
catch (e) {
|
|
46
52
|
if (this.httpClient.isDebugEnabled()) {
|
|
@@ -15,7 +15,7 @@ export class WorkspaceEndpoint extends Endpoint {
|
|
|
15
15
|
}
|
|
16
16
|
async save(workspace) {
|
|
17
17
|
try {
|
|
18
|
-
const url = '/
|
|
18
|
+
const url = '/workspaces';
|
|
19
19
|
const result = await this.requestObject(url, workspace, Workspace.parse, 'POST');
|
|
20
20
|
const updatedWorkspace = result.getData();
|
|
21
21
|
if (updatedWorkspace === null) {
|