attlaz-client 1.4.22 → 1.4.25
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/Http/HttpClientRequest.js +2 -1
- package/dist/Http/OAuthClient.js +2 -1
- package/dist/Model/Adapter/AdapterConnection.d.ts +3 -4
- package/dist/Model/Adapter/AdapterConnection.js +5 -1
- package/dist/Model/DataValue.d.ts +1 -0
- package/dist/Model/DataValue.js +4 -0
- package/dist/Model/DataValueCollection.d.ts +16 -0
- package/dist/Model/DataValueCollection.js +61 -0
- package/dist/Model/JsonSerializable.d.ts +4 -0
- package/dist/Model/JsonSerializable.js +16 -0
- package/dist/Model/Log/Log.d.ts +2 -4
- package/dist/Model/Log/Log.js +3 -13
- package/dist/Service/AdapterEndpoint.d.ts +1 -0
- package/dist/Service/AdapterEndpoint.js +16 -0
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpClientRequest = void 0;
|
|
4
4
|
const Utils_1 = require("../Utils");
|
|
5
|
+
const JsonSerializable_1 = require("../Model/JsonSerializable");
|
|
5
6
|
class HttpClientRequest {
|
|
6
7
|
constructor(url, method = HttpClientRequest.GET) {
|
|
7
8
|
this.headers = {};
|
|
@@ -23,7 +24,7 @@ class HttpClientRequest {
|
|
|
23
24
|
}
|
|
24
25
|
setJsonBody(data) {
|
|
25
26
|
this.setJsonHeader();
|
|
26
|
-
this.body =
|
|
27
|
+
this.body = JsonSerializable_1.JsonSerializable.stringify(data);
|
|
27
28
|
}
|
|
28
29
|
getFullUrl() {
|
|
29
30
|
let result = this.urlObj.href;
|
package/dist/Http/OAuthClient.js
CHANGED
|
@@ -6,6 +6,7 @@ const HttpClient_1 = require("./HttpClient");
|
|
|
6
6
|
const HttpClientRequest_1 = require("./HttpClientRequest");
|
|
7
7
|
const Utils_1 = require("../Utils");
|
|
8
8
|
const ClientOAuth2 = require("client-oauth2");
|
|
9
|
+
const JsonSerializable_1 = require("../Model/JsonSerializable");
|
|
9
10
|
class OAuthClient {
|
|
10
11
|
constructor(options) {
|
|
11
12
|
this.debug = false;
|
|
@@ -139,7 +140,7 @@ class OAuthClient {
|
|
|
139
140
|
let requestData = new HttpClientRequest_1.HttpClientRequest(url, method);
|
|
140
141
|
if ((method === 'POST' || method === 'DELETE' || method === 'PUT') && parameters !== null && parameters !== undefined) {
|
|
141
142
|
if (typeof parameters === 'object') {
|
|
142
|
-
parameters =
|
|
143
|
+
parameters = JsonSerializable_1.JsonSerializable.stringify(parameters);
|
|
143
144
|
}
|
|
144
145
|
else if (typeof parameters === 'string') {
|
|
145
146
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { DataValueCollection } from '../DataValueCollection';
|
|
1
2
|
export declare class AdapterConnection {
|
|
2
3
|
id: number;
|
|
3
4
|
key: string;
|
|
4
5
|
adapter: string;
|
|
5
6
|
name: string;
|
|
6
|
-
configuration:
|
|
7
|
-
|
|
8
|
-
value: string;
|
|
9
|
-
}[];
|
|
7
|
+
configuration: DataValueCollection;
|
|
8
|
+
constructor();
|
|
10
9
|
static parse(rawAdapterConnection: any): AdapterConnection;
|
|
11
10
|
}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AdapterConnection = void 0;
|
|
4
|
+
const DataValueCollection_1 = require("../DataValueCollection");
|
|
4
5
|
class AdapterConnection {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.configuration = new DataValueCollection_1.DataValueCollection();
|
|
8
|
+
}
|
|
5
9
|
static parse(rawAdapterConnection) {
|
|
6
10
|
let adapterConnection = new AdapterConnection();
|
|
7
11
|
adapterConnection.id = rawAdapterConnection.id;
|
|
8
12
|
adapterConnection.key = rawAdapterConnection.key;
|
|
9
13
|
adapterConnection.adapter = rawAdapterConnection.adapter;
|
|
10
14
|
adapterConnection.name = rawAdapterConnection.name;
|
|
11
|
-
adapterConnection.configuration = rawAdapterConnection.configuration;
|
|
15
|
+
adapterConnection.configuration = DataValueCollection_1.DataValueCollection.fromObject(rawAdapterConnection.configuration);
|
|
12
16
|
return adapterConnection;
|
|
13
17
|
// adapter.id = rawAdapter.id;
|
|
14
18
|
// adapter.name = rawAdapter.name;
|
package/dist/Model/DataValue.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DataValue, DataValueValue } from './DataValue';
|
|
2
|
+
import { JsonSerializable } from './JsonSerializable';
|
|
3
|
+
export declare class DataValueCollection extends JsonSerializable implements Iterable<DataValue> {
|
|
4
|
+
private values;
|
|
5
|
+
get length(): number;
|
|
6
|
+
static fromObject(rawValues: {
|
|
7
|
+
key: string;
|
|
8
|
+
value: DataValueValue;
|
|
9
|
+
}[]): DataValueCollection;
|
|
10
|
+
set(key: string, value: DataValueValue): void;
|
|
11
|
+
get(key: string): DataValueValue | null;
|
|
12
|
+
unset(key: string): void;
|
|
13
|
+
serialize(): string | null;
|
|
14
|
+
[Symbol.iterator](): Iterator<DataValue>;
|
|
15
|
+
jsonSerialize(): any;
|
|
16
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataValueCollection = void 0;
|
|
4
|
+
const DataValue_1 = require("./DataValue");
|
|
5
|
+
const Utils_1 = require("../Utils");
|
|
6
|
+
const JsonSerializable_1 = require("./JsonSerializable");
|
|
7
|
+
class DataValueCollection extends JsonSerializable_1.JsonSerializable {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.values = [];
|
|
11
|
+
}
|
|
12
|
+
get length() {
|
|
13
|
+
return this.values.length;
|
|
14
|
+
}
|
|
15
|
+
static fromObject(rawValues) {
|
|
16
|
+
if (Utils_1.Utils.isNullOrUndefined(rawValues)) {
|
|
17
|
+
return new DataValueCollection();
|
|
18
|
+
}
|
|
19
|
+
const result = new DataValueCollection();
|
|
20
|
+
for (const rawValue of rawValues) {
|
|
21
|
+
// TODO: validate rawTag
|
|
22
|
+
result.set(rawValue.key, rawValue.value);
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
set(key, value) {
|
|
27
|
+
const existingIndex = this.values.findIndex((tag) => {
|
|
28
|
+
return tag.key === key;
|
|
29
|
+
});
|
|
30
|
+
if (existingIndex !== -1) {
|
|
31
|
+
this.values.splice(existingIndex);
|
|
32
|
+
}
|
|
33
|
+
this.values.push(new DataValue_1.DataValue(key, value));
|
|
34
|
+
}
|
|
35
|
+
get(key) {
|
|
36
|
+
for (const tag of this.values) {
|
|
37
|
+
if (tag.key === key) {
|
|
38
|
+
return tag.value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
unset(key) {
|
|
44
|
+
this.values = this.values.filter((tag) => {
|
|
45
|
+
return tag.key !== key;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
serialize() {
|
|
49
|
+
if (this.values.length === 0) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return JSON.stringify(this.values);
|
|
53
|
+
}
|
|
54
|
+
[Symbol.iterator]() {
|
|
55
|
+
return this.values.values();
|
|
56
|
+
}
|
|
57
|
+
jsonSerialize() {
|
|
58
|
+
return this.values;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.DataValueCollection = DataValueCollection;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonSerializable = void 0;
|
|
4
|
+
class JsonSerializable {
|
|
5
|
+
static stringify(object) {
|
|
6
|
+
const replacer = (key, value) => {
|
|
7
|
+
// Filtering out properties
|
|
8
|
+
if (value instanceof JsonSerializable && 'jsonSerialize' in value) {
|
|
9
|
+
return value.jsonSerialize();
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
};
|
|
13
|
+
return JSON.stringify(object, replacer);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.JsonSerializable = JsonSerializable;
|
package/dist/Model/Log/Log.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LogLevel } from "./LogLevel";
|
|
2
2
|
import { LogStreamId } from './LogStreamId';
|
|
3
|
-
import { DataValue, DataValueValue } from '../DataValue';
|
|
4
3
|
import { LogStatus } from './LogStatus';
|
|
4
|
+
import { DataValueCollection } from '../DataValueCollection';
|
|
5
5
|
export declare class Log {
|
|
6
6
|
id: string;
|
|
7
7
|
readonly logStream: LogStreamId;
|
|
@@ -10,10 +10,8 @@ export declare class Log {
|
|
|
10
10
|
message: string;
|
|
11
11
|
context: object;
|
|
12
12
|
status: LogStatus;
|
|
13
|
-
tags:
|
|
13
|
+
tags: DataValueCollection;
|
|
14
14
|
_version: string;
|
|
15
15
|
constructor(logStream: LogStreamId, level: LogLevel, date: Date);
|
|
16
16
|
static parse(rawLog: any): Log;
|
|
17
|
-
setTag(key: string, value: DataValueValue): void;
|
|
18
|
-
getTagValue(key: string): DataValueValue | null;
|
|
19
17
|
}
|
package/dist/Model/Log/Log.js
CHANGED
|
@@ -4,13 +4,14 @@ exports.Log = void 0;
|
|
|
4
4
|
const LogLevel_1 = require("./LogLevel");
|
|
5
5
|
const LogStreamId_1 = require("./LogStreamId");
|
|
6
6
|
const LogStatus_1 = require("./LogStatus");
|
|
7
|
+
const DataValueCollection_1 = require("../DataValueCollection");
|
|
7
8
|
class Log {
|
|
8
9
|
constructor(logStream, level, date) {
|
|
9
10
|
this.status = LogStatus_1.LogStatus.Normal;
|
|
10
|
-
this.tags = [];
|
|
11
11
|
this.logStream = logStream;
|
|
12
12
|
this.level = level;
|
|
13
13
|
this.date = date;
|
|
14
|
+
this.tags = new DataValueCollection_1.DataValueCollection();
|
|
14
15
|
}
|
|
15
16
|
static parse(rawLog) {
|
|
16
17
|
const date = new Date(rawLog.date);
|
|
@@ -23,20 +24,9 @@ class Log {
|
|
|
23
24
|
if (rawLog.status !== null && rawLog.status !== undefined && rawLog.status !== '') {
|
|
24
25
|
log.status = LogStatus_1.LogStatus.fromString(rawLog.status);
|
|
25
26
|
}
|
|
26
|
-
log.tags = rawLog.tags;
|
|
27
|
+
log.tags = DataValueCollection_1.DataValueCollection.fromObject(rawLog.tags);
|
|
27
28
|
log._version = rawLog._version;
|
|
28
29
|
return log;
|
|
29
30
|
}
|
|
30
|
-
setTag(key, value) {
|
|
31
|
-
this.tags.push({ key, value });
|
|
32
|
-
}
|
|
33
|
-
getTagValue(key) {
|
|
34
|
-
for (const tag of this.tags) {
|
|
35
|
-
if (tag.key === key) {
|
|
36
|
-
return tag.value;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
31
|
}
|
|
42
32
|
exports.Log = Log;
|
|
@@ -9,4 +9,5 @@ export declare class AdapterEndpoint extends Endpoint {
|
|
|
9
9
|
getAdapterConfiguration(adapterId: string): Promise<DataResult<AdapterConfiguration[]>>;
|
|
10
10
|
getConnections(projectId: string): Promise<DataResult<AdapterConnection[]>>;
|
|
11
11
|
getConnectionByKey(connectionKey: string): Promise<DataResult<AdapterConnection>>;
|
|
12
|
+
saveConnection(projectId: string, adapter: AdapterConnection): Promise<DataResult<AdapterConnection>>;
|
|
12
13
|
}
|
|
@@ -76,5 +76,21 @@ class AdapterEndpoint extends Endpoint_1.Endpoint {
|
|
|
76
76
|
throw error;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
async saveConnection(projectId, adapter) {
|
|
80
|
+
try {
|
|
81
|
+
let url = '/connections';
|
|
82
|
+
const data = adapter;
|
|
83
|
+
data.projectId = projectId;
|
|
84
|
+
const result = await this.request(url, data, 'POST');
|
|
85
|
+
result.setData(AdapterConnection_1.AdapterConnection.parse(result.getData()));
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (this.httpClient.isDebugEnabled()) {
|
|
90
|
+
console.error('Failed to save connection: ', error);
|
|
91
|
+
}
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
79
95
|
}
|
|
80
96
|
exports.AdapterEndpoint = AdapterEndpoint;
|