attlaz-client 1.4.23 → 1.4.26
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/DataValueCollection.d.ts +7 -4
- package/dist/Model/DataValueCollection.js +22 -14
- package/dist/Model/JsonSerializable.d.ts +4 -0
- package/dist/Model/JsonSerializable.js +16 -0
- package/dist/Model/Log/Log.d.ts +3 -3
- package/dist/Model/Log/Log.js +4 -3
- 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,8 +1,9 @@
|
|
|
1
|
-
import { DataValueValue } from './DataValue';
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { DataValue, DataValueValue } from './DataValue';
|
|
2
|
+
import { JsonSerializable } from './JsonSerializable';
|
|
3
|
+
export declare class DataValueCollection extends JsonSerializable implements Iterable<DataValue> {
|
|
4
|
+
private _values;
|
|
4
5
|
get length(): number;
|
|
5
|
-
static fromObject(
|
|
6
|
+
static fromObject(rawValues: {
|
|
6
7
|
key: string;
|
|
7
8
|
value: DataValueValue;
|
|
8
9
|
}[]): DataValueCollection;
|
|
@@ -10,4 +11,6 @@ export declare class DataValueCollection {
|
|
|
10
11
|
get(key: string): DataValueValue | null;
|
|
11
12
|
unset(key: string): void;
|
|
12
13
|
serialize(): string | null;
|
|
14
|
+
[Symbol.iterator](): Iterator<DataValue>;
|
|
15
|
+
jsonSerialize(): any;
|
|
13
16
|
}
|
|
@@ -3,35 +3,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DataValueCollection = void 0;
|
|
4
4
|
const DataValue_1 = require("./DataValue");
|
|
5
5
|
const Utils_1 = require("../Utils");
|
|
6
|
-
|
|
6
|
+
const JsonSerializable_1 = require("./JsonSerializable");
|
|
7
|
+
class DataValueCollection extends JsonSerializable_1.JsonSerializable {
|
|
7
8
|
constructor() {
|
|
8
|
-
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this._values = [];
|
|
9
11
|
}
|
|
10
12
|
get length() {
|
|
11
|
-
return this.
|
|
13
|
+
return this._values.length;
|
|
12
14
|
}
|
|
13
|
-
static fromObject(
|
|
14
|
-
if (Utils_1.Utils.isNullOrUndefined(
|
|
15
|
+
static fromObject(rawValues) {
|
|
16
|
+
if (Utils_1.Utils.isNullOrUndefined(rawValues)) {
|
|
15
17
|
return new DataValueCollection();
|
|
16
18
|
}
|
|
17
19
|
const result = new DataValueCollection();
|
|
18
|
-
for (const
|
|
20
|
+
for (const rawValue of rawValues) {
|
|
19
21
|
// TODO: validate rawTag
|
|
20
|
-
result.set(
|
|
22
|
+
result.set(rawValue.key, rawValue.value);
|
|
21
23
|
}
|
|
22
24
|
return result;
|
|
23
25
|
}
|
|
24
26
|
set(key, value) {
|
|
25
|
-
const existingIndex = this.
|
|
27
|
+
const existingIndex = this._values.findIndex((tag) => {
|
|
26
28
|
return tag.key === key;
|
|
27
29
|
});
|
|
28
30
|
if (existingIndex !== -1) {
|
|
29
|
-
this.
|
|
31
|
+
this._values.splice(existingIndex);
|
|
30
32
|
}
|
|
31
|
-
this.
|
|
33
|
+
this._values.push(new DataValue_1.DataValue(key, value));
|
|
32
34
|
}
|
|
33
35
|
get(key) {
|
|
34
|
-
for (const tag of this.
|
|
36
|
+
for (const tag of this._values) {
|
|
35
37
|
if (tag.key === key) {
|
|
36
38
|
return tag.value;
|
|
37
39
|
}
|
|
@@ -39,15 +41,21 @@ class DataValueCollection {
|
|
|
39
41
|
return null;
|
|
40
42
|
}
|
|
41
43
|
unset(key) {
|
|
42
|
-
this.
|
|
44
|
+
this._values = this._values.filter((tag) => {
|
|
43
45
|
return tag.key !== key;
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
48
|
serialize() {
|
|
47
|
-
if (this.
|
|
49
|
+
if (this._values.length === 0) {
|
|
48
50
|
return null;
|
|
49
51
|
}
|
|
50
|
-
return JSON.stringify(this.
|
|
52
|
+
return JSON.stringify(this._values);
|
|
53
|
+
}
|
|
54
|
+
[Symbol.iterator]() {
|
|
55
|
+
return this._values.values();
|
|
56
|
+
}
|
|
57
|
+
jsonSerialize() {
|
|
58
|
+
return this._values;
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
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
|
@@ -3,15 +3,15 @@ import { LogStreamId } from './LogStreamId';
|
|
|
3
3
|
import { LogStatus } from './LogStatus';
|
|
4
4
|
import { DataValueCollection } from '../DataValueCollection';
|
|
5
5
|
export declare class Log {
|
|
6
|
-
id: string;
|
|
6
|
+
id: string | null;
|
|
7
7
|
readonly logStream: LogStreamId;
|
|
8
8
|
readonly date: Date;
|
|
9
9
|
readonly level: LogLevel;
|
|
10
|
-
message: string;
|
|
10
|
+
readonly message: string;
|
|
11
11
|
context: object;
|
|
12
12
|
status: LogStatus;
|
|
13
13
|
tags: DataValueCollection;
|
|
14
14
|
_version: string;
|
|
15
|
-
constructor(logStream: LogStreamId, level: LogLevel, date: Date);
|
|
15
|
+
constructor(logStream: LogStreamId, message: string, level: LogLevel, date: Date);
|
|
16
16
|
static parse(rawLog: any): Log;
|
|
17
17
|
}
|
package/dist/Model/Log/Log.js
CHANGED
|
@@ -6,9 +6,11 @@ const LogStreamId_1 = require("./LogStreamId");
|
|
|
6
6
|
const LogStatus_1 = require("./LogStatus");
|
|
7
7
|
const DataValueCollection_1 = require("../DataValueCollection");
|
|
8
8
|
class Log {
|
|
9
|
-
constructor(logStream, level, date) {
|
|
9
|
+
constructor(logStream, message, level, date) {
|
|
10
|
+
this.id = null;
|
|
10
11
|
this.status = LogStatus_1.LogStatus.Normal;
|
|
11
12
|
this.logStream = logStream;
|
|
13
|
+
this.message = message;
|
|
12
14
|
this.level = level;
|
|
13
15
|
this.date = date;
|
|
14
16
|
this.tags = new DataValueCollection_1.DataValueCollection();
|
|
@@ -17,9 +19,8 @@ class Log {
|
|
|
17
19
|
const date = new Date(rawLog.date);
|
|
18
20
|
const level = LogLevel_1.LogLevel.fromString(rawLog.level);
|
|
19
21
|
const logStream = new LogStreamId_1.LogStreamId(rawLog.logStream.id);
|
|
20
|
-
let log = new Log(logStream, level, date);
|
|
22
|
+
let log = new Log(logStream, rawLog.message, level, date);
|
|
21
23
|
log.id = rawLog.id;
|
|
22
|
-
log.message = rawLog.message;
|
|
23
24
|
log.context = rawLog.context;
|
|
24
25
|
if (rawLog.status !== null && rawLog.status !== undefined && rawLog.status !== '') {
|
|
25
26
|
log.status = LogStatus_1.LogStatus.fromString(rawLog.status);
|