attlaz-client 1.9.44 → 1.9.46
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/Data/QueryString.d.ts +5 -0
- package/dist/Http/Data/QueryString.js +19 -0
- package/dist/Model/Pagination/CursorPagination.d.ts +4 -0
- package/dist/Model/Pagination/CursorPagination.js +10 -0
- package/dist/Service/Endpoint.d.ts +3 -0
- package/dist/Service/Endpoint.js +13 -0
- package/dist/Service/LogEndpoint.d.ts +2 -0
- package/dist/Service/LogEndpoint.js +6 -0
- package/dist/Service/UserEndpoint.d.ts +1 -1
- package/dist/Service/UserEndpoint.js +6 -7
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryString = void 0;
|
|
4
|
+
class QueryString {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.parameters = [];
|
|
7
|
+
}
|
|
8
|
+
set(parameter, value) {
|
|
9
|
+
this.parameters.push({ parameter, value });
|
|
10
|
+
}
|
|
11
|
+
build() {
|
|
12
|
+
const output = [];
|
|
13
|
+
for (const parameter of this.parameters) {
|
|
14
|
+
output.push(parameter.parameter + '=' + parameter.value);
|
|
15
|
+
}
|
|
16
|
+
return output.join('&');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.QueryString = QueryString;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CursorPagination = void 0;
|
|
4
|
+
class CursorPagination {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.limit = null;
|
|
7
|
+
this.startingAfter = null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.CursorPagination = CursorPagination;
|
|
@@ -2,6 +2,8 @@ import { OAuthClient } from '../Http/OAuthClient';
|
|
|
2
2
|
import { CollectionResult } from '../Model/Result/CollectionResult';
|
|
3
3
|
import { ObjectResult } from '../Model/Result/ObjectResult';
|
|
4
4
|
import { Parameters } from '../Http/Data/Parameters';
|
|
5
|
+
import { CursorPagination } from '../Model/Pagination/CursorPagination';
|
|
6
|
+
import { QueryString } from '../Http/Data/QueryString';
|
|
5
7
|
export declare abstract class Endpoint {
|
|
6
8
|
protected httpClient: OAuthClient;
|
|
7
9
|
constructor(httpClient: OAuthClient);
|
|
@@ -11,4 +13,5 @@ export declare abstract class Endpoint {
|
|
|
11
13
|
requestObject<T>(action: string, parameters: Parameters | undefined, parser: (input: any) => T, method?: string, signWithOauthToken?: boolean): Promise<ObjectResult<T>>;
|
|
12
14
|
parseCollection<T>(rawData: object[], parser: (input: any) => T): T[];
|
|
13
15
|
private parseObject;
|
|
16
|
+
protected buildQuery(pagination: CursorPagination | null): QueryString;
|
|
14
17
|
}
|
package/dist/Service/Endpoint.js
CHANGED
|
@@ -9,6 +9,7 @@ const ObjectWrapper_1 = require("../Model/Result/ObjectWrapper");
|
|
|
9
9
|
const DataValueCollection_1 = require("../Model/DataValueCollection");
|
|
10
10
|
const JsonSerializable_1 = require("../Model/JsonSerializable");
|
|
11
11
|
const LogStreamId_1 = require("../Model/Log/LogStreamId");
|
|
12
|
+
const QueryString_1 = require("../Http/Data/QueryString");
|
|
12
13
|
class Endpoint {
|
|
13
14
|
constructor(httpClient) {
|
|
14
15
|
this.httpClient = httpClient;
|
|
@@ -132,5 +133,17 @@ class Endpoint {
|
|
|
132
133
|
const parsedData = parser(wrappedData);
|
|
133
134
|
return parsedData;
|
|
134
135
|
}
|
|
136
|
+
buildQuery(pagination) {
|
|
137
|
+
const queryString = new QueryString_1.QueryString();
|
|
138
|
+
if (pagination !== null && pagination !== undefined) {
|
|
139
|
+
if (pagination.limit !== null && pagination.limit !== undefined) {
|
|
140
|
+
queryString.set('limit', pagination.limit);
|
|
141
|
+
}
|
|
142
|
+
if (pagination.startingAfter !== null && pagination.startingAfter !== undefined) {
|
|
143
|
+
queryString.set('starting_after', pagination.startingAfter);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return queryString;
|
|
147
|
+
}
|
|
135
148
|
}
|
|
136
149
|
exports.Endpoint = Endpoint;
|
|
@@ -5,8 +5,10 @@ import { LogStreamId } from '../Model/Log/LogStreamId';
|
|
|
5
5
|
import { CollectionResult } from '../Model/Result/CollectionResult';
|
|
6
6
|
import { LogStreamInformation } from '../Model/Log/LogStreamInformation';
|
|
7
7
|
import { LogStream } from '../Model/Log/LogStream';
|
|
8
|
+
import { CursorPagination } from '../Model/Pagination/CursorPagination';
|
|
8
9
|
export declare class LogEndpoint extends Endpoint {
|
|
9
10
|
getLogs(logQuery: LogQuery): Promise<CollectionResult<Log>>;
|
|
11
|
+
getCursoredLogEntries(logStreamId: LogStreamId, pagination: CursorPagination | null): Promise<CollectionResult<Log>>;
|
|
10
12
|
save(log: Log): Promise<Log>;
|
|
11
13
|
delete(logId: string): Promise<boolean>;
|
|
12
14
|
clear(logStreamId: LogStreamId): Promise<boolean>;
|
|
@@ -43,6 +43,12 @@ class LogEndpoint extends Endpoint_1.Endpoint {
|
|
|
43
43
|
const result = await this.requestCollection(cmd, null, Log_1.Log.parse);
|
|
44
44
|
return result;
|
|
45
45
|
}
|
|
46
|
+
async getCursoredLogEntries(logStreamId, pagination) {
|
|
47
|
+
const queryString = this.buildQuery(pagination);
|
|
48
|
+
let cmd = '/logstreams/' + Utils_1.Utils.base64encode(logStreamId.id) + '/logs/?' + queryString.build();
|
|
49
|
+
const result = await this.requestCollection(cmd, null, Log_1.Log.parse);
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
46
52
|
async save(log) {
|
|
47
53
|
try {
|
|
48
54
|
let cmd = '/logstreams/' + Utils_1.Utils.base64encode(log.logStream.id) + '/logs';
|
|
@@ -20,7 +20,7 @@ export declare class UserEndpoint extends Endpoint {
|
|
|
20
20
|
allowed: boolean;
|
|
21
21
|
}>>;
|
|
22
22
|
update(user: User): Promise<User>;
|
|
23
|
-
create(user: User, invitationCode?: string | null): Promise<User>;
|
|
23
|
+
create(user: User, password: string, invitationCode?: string | null): Promise<User>;
|
|
24
24
|
requestResetPassword(email: string): Promise<boolean>;
|
|
25
25
|
resetPassword(code: string, password: string): Promise<boolean>;
|
|
26
26
|
}
|
|
@@ -90,7 +90,7 @@ class UserEndpoint extends Endpoint_1.Endpoint {
|
|
|
90
90
|
async update(user) {
|
|
91
91
|
try {
|
|
92
92
|
let url = '/users/' + user.id;
|
|
93
|
-
const result = await this.requestObject(url,
|
|
93
|
+
const result = await this.requestObject(url, user, User_1.User.parse, 'POST');
|
|
94
94
|
const updatedUser = result.getData();
|
|
95
95
|
if (updatedUser === null) {
|
|
96
96
|
throw new Error('User not updated');
|
|
@@ -104,14 +104,13 @@ class UserEndpoint extends Endpoint_1.Endpoint {
|
|
|
104
104
|
throw e;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
async create(user, invitationCode = null) {
|
|
107
|
+
async create(user, password, invitationCode = null) {
|
|
108
108
|
try {
|
|
109
109
|
let url = '/users/';
|
|
110
|
-
const data =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const result = await this.requestObject(url, data, parser, 'PUT', false);
|
|
110
|
+
const data = user;
|
|
111
|
+
data.password = password;
|
|
112
|
+
data.invitation_code = invitationCode;
|
|
113
|
+
const result = await this.requestObject(url, data, User_1.User.parse, 'PUT', false);
|
|
115
114
|
const createdUser = result.getData();
|
|
116
115
|
if (createdUser === null) {
|
|
117
116
|
throw new Error('User not created');
|