attlaz-client 1.9.45 → 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.
@@ -0,0 +1,5 @@
1
+ export declare class QueryString {
2
+ private parameters;
3
+ set(parameter: string, value: string | number | boolean): void;
4
+ build(): string;
5
+ }
@@ -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,4 @@
1
+ export declare class CursorPagination {
2
+ limit: number | null;
3
+ startingAfter: string | null;
4
+ }
@@ -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
  }
@@ -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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attlaz-client",
3
- "version": "1.9.45",
3
+ "version": "1.9.46",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",