attlaz-client 1.15.8 → 1.16.0

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,9 @@
1
+ export declare abstract class EntityId {
2
+ protected readonly id: string;
3
+ protected readonly abstract TYPE: string;
4
+ constructor(id: string);
5
+ getIdType(): string;
6
+ toString(): string;
7
+ jsonSerialize(): any;
8
+ isEqual<T extends this>(entityId: T): boolean;
9
+ }
@@ -0,0 +1,27 @@
1
+ export class EntityId {
2
+ id;
3
+ constructor(id) {
4
+ this.id = id;
5
+ if (id === null || id === undefined || (id + '').length < 1) {
6
+ throw new Error('Invalid id');
7
+ }
8
+ if ((id + '').length !== 27) {
9
+ // console.error('Id `' + id + '` does not seem a valid KSUID (type `' + this.getIdType() + '`)');
10
+ }
11
+ }
12
+ getIdType() {
13
+ return this.TYPE;
14
+ }
15
+ toString() {
16
+ return this.id;
17
+ }
18
+ jsonSerialize() {
19
+ return this.toString();
20
+ }
21
+ isEqual(entityId) {
22
+ if (this.getIdType() !== entityId.getIdType()) {
23
+ throw new Error('Types are not the same');
24
+ }
25
+ return this.getIdType() !== '' && entityId.getIdType() !== '' && this.getIdType() === entityId.getIdType() && this.toString() === entityId.toString();
26
+ }
27
+ }
@@ -1,5 +1,5 @@
1
- export declare class LogStreamId {
2
- readonly id: string;
3
- constructor(id: string);
1
+ import { EntityId } from '../EntityId.js';
2
+ export declare class LogStreamId extends EntityId {
3
+ protected readonly TYPE: string;
4
4
  jsonSerialize(): string;
5
5
  }
@@ -1,8 +1,6 @@
1
- export class LogStreamId {
2
- id;
3
- constructor(id) {
4
- this.id = id;
5
- }
1
+ import { EntityId } from '../EntityId.js';
2
+ export class LogStreamId extends EntityId {
3
+ TYPE = 'logStreamId';
6
4
  jsonSerialize() {
7
5
  return this.id;
8
6
  }
@@ -37,12 +37,12 @@ export class LogEndpoint extends Endpoint {
37
37
  const strTags = arrTags.join(',');
38
38
  arrQuery.push('tags=' + strTags);
39
39
  }
40
- const cmd = '/logstreams/' + Utils.base64encode(logQuery.logStreamId.id) + '/logs/?' + arrQuery.join('&');
40
+ const cmd = '/logstreams/' + Utils.base64encode(logQuery.logStreamId.toString()) + '/logs/?' + arrQuery.join('&');
41
41
  const result = await this.requestCollection(cmd, Log.parse);
42
42
  return result;
43
43
  }
44
44
  async getCursoredLogEntries(logStreamId, pagination, filter) {
45
- const queryString = new QueryString('/logstreams/' + Utils.base64encode(logStreamId.id) + '/logs');
45
+ const queryString = new QueryString('/logstreams/' + Utils.base64encode(logStreamId.toString()) + '/logs');
46
46
  queryString.addPagination(pagination);
47
47
  if (filter !== null && filter !== undefined) {
48
48
  if (filter.tags !== null && filter.tags.length > 0) {
@@ -64,7 +64,7 @@ export class LogEndpoint extends Endpoint {
64
64
  }
65
65
  async save(log) {
66
66
  try {
67
- const cmd = '/logstreams/' + Utils.base64encode(log.logStream.id) + '/logs';
67
+ const cmd = '/logstreams/' + Utils.base64encode(log.logStream.toString()) + '/logs';
68
68
  const result = await this.requestObject(cmd, log, Log.parse, 'POST');
69
69
  const updatedLogEntry = result.getData();
70
70
  if (updatedLogEntry === null) {
@@ -99,7 +99,7 @@ export class LogEndpoint extends Endpoint {
99
99
  }
100
100
  }
101
101
  async clear(logStreamId) {
102
- const cmd = '/logstreams/' + Utils.base64encode(logStreamId.id) + '/clear';
102
+ const cmd = '/logstreams/' + Utils.base64encode(logStreamId.toString()) + '/clear';
103
103
  try {
104
104
  const parser = (raw) => ({ cleared: raw.cleared });
105
105
  const result = await this.requestObject(cmd, null, parser, 'POST');
@@ -119,7 +119,7 @@ export class LogEndpoint extends Endpoint {
119
119
  }
120
120
  async getInformation(logStreamId) {
121
121
  try {
122
- const url = '/logstreams/' + Utils.base64encode(logStreamId.id) + '/info';
122
+ const url = '/logstreams/' + Utils.base64encode(logStreamId.toString()) + '/info';
123
123
  const result = await this.requestObject(url, null, LogStreamInformation.parse);
124
124
  return result.getData();
125
125
  }
package/dist/index.d.ts CHANGED
@@ -93,6 +93,7 @@ export { WorkspaceMemberRole } from './Model/Workspace/WorkspaceMemberRole.js';
93
93
  /** * */
94
94
  export { Config } from './Model/Config.js';
95
95
  export { DataValue, DataValueValue } from './Model/DataValue.js';
96
+ export { EntityId } from './Model/EntityId.js';
96
97
  export { DataValueCollection } from './Model/DataValueCollection.js';
97
98
  export { EntityType } from './Model/EntityType.js';
98
99
  export { InboxMessage } from './Model/Inbox/InboxMessage.js';
package/dist/index.js CHANGED
@@ -88,6 +88,7 @@ export { WorkspaceMemberRole } from './Model/Workspace/WorkspaceMemberRole.js';
88
88
  /** * */
89
89
  export { Config } from './Model/Config.js';
90
90
  export { DataValue } from './Model/DataValue.js';
91
+ export { EntityId } from './Model/EntityId.js';
91
92
  export { DataValueCollection } from './Model/DataValueCollection.js';
92
93
  export { EntityType } from './Model/EntityType.js';
93
94
  export { InboxMessage } from './Model/Inbox/InboxMessage.js';
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.13.51";
1
+ export declare const VERSION = "1.16.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.13.51";
1
+ export const VERSION = "1.16.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attlaz-client",
3
- "version": "1.15.8",
3
+ "version": "1.16.0",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",