attlaz-client 1.13.19 → 1.13.21

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/Client.d.ts CHANGED
@@ -28,6 +28,7 @@ import { FlowRunStatsEndpoint } from './Service/FlowRunStatsEndpoint.js';
28
28
  import { FirewallEndpoint } from './Service/FirewallEndpoint.js';
29
29
  import { CodeSourceStrategiesEndpoint } from './Service/CodeSourceStrategiesEndpoint.js';
30
30
  import { SearchEndpoint } from './Service/SearchEndpoint.js';
31
+ import { UserActionEndpoint } from './Service/UserActionEndpoint.js';
31
32
  export declare class Client {
32
33
  private endpoints;
33
34
  private httpClient;
@@ -73,6 +74,7 @@ export declare class Client {
73
74
  getHealthAlertEndpoint(): HealthAlertEndpoint;
74
75
  getCodeSourceStrategiesEndpoint(): CodeSourceStrategiesEndpoint;
75
76
  getSearchEndpoint(): SearchEndpoint;
77
+ getUserActionEndpoint(): UserActionEndpoint;
76
78
  getFirewallEndpoint(): FirewallEndpoint;
77
79
  private getEndpoint;
78
80
  }
package/dist/Client.js CHANGED
@@ -29,6 +29,7 @@ import { FlowRunStatsEndpoint } from './Service/FlowRunStatsEndpoint.js';
29
29
  import { FirewallEndpoint } from './Service/FirewallEndpoint.js';
30
30
  import { CodeSourceStrategiesEndpoint } from './Service/CodeSourceStrategiesEndpoint.js';
31
31
  import { SearchEndpoint } from './Service/SearchEndpoint.js';
32
+ import { UserActionEndpoint } from './Service/UserActionEndpoint.js';
32
33
  export class Client {
33
34
  endpoints;
34
35
  httpClient;
@@ -61,6 +62,7 @@ export class Client {
61
62
  CodeSourceStrategiesEndpoint,
62
63
  FirewallEndpoint,
63
64
  SearchEndpoint,
65
+ UserActionEndpoint,
64
66
  };
65
67
  apiEndpoint = 'https://api.attlaz.com';
66
68
  parseConfig(config) {
@@ -192,6 +194,9 @@ export class Client {
192
194
  getSearchEndpoint() {
193
195
  return this.getEndpoint('search', this.Store.SearchEndpoint);
194
196
  }
197
+ getUserActionEndpoint() {
198
+ return this.getEndpoint('useraction', this.Store.UserActionEndpoint);
199
+ }
195
200
  // TODO: this should be in a separate API?
196
201
  getFirewallEndpoint() {
197
202
  return this.getEndpoint('firewall', this.Store.FirewallEndpoint);
@@ -26,7 +26,9 @@ export class Flow extends MetaDataAware {
26
26
  flow.parallelLimit = Utils.parseInt(rawFlow.parallel_limit);
27
27
  flow.codeSource = rawFlow.code_source;
28
28
  flow.runCommand = rawFlow.run_command;
29
- flow.metadata = DataValueCollection.fromObject(rawFlow.metadata);
29
+ if (Object.prototype.hasOwnProperty.call(rawFlow, 'metadata')) {
30
+ flow.metadata = DataValueCollection.fromObject(rawFlow.metadata);
31
+ }
30
32
  return flow;
31
33
  }
32
34
  }
@@ -26,7 +26,9 @@ export class FlowRun extends MetaDataAware {
26
26
  flowRun.deployId = rawFlowRun.deploy;
27
27
  flowRun.logLevelCount = rawFlowRun.log_level_count;
28
28
  flowRun.logsPurged = Utils.isTrue(rawFlowRun.logs_purged);
29
- flowRun.metadata = DataValueCollection.fromObject(rawFlowRun.metadata);
29
+ if (Object.prototype.hasOwnProperty.call(rawFlowRun, 'metadata')) {
30
+ flowRun.metadata = DataValueCollection.fromObject(rawFlowRun.metadata);
31
+ }
30
32
  return flowRun;
31
33
  }
32
34
  }
@@ -24,7 +24,9 @@ export class Channel extends MetaDataAware {
24
24
  const channel = new Channel(rawChannel.id, rawChannel.owner, rawChannel.label, type, rawChannel.data);
25
25
  channel.state = State.fromString(rawChannel.state);
26
26
  channel.private = Utils.isTrue(rawChannel.private);
27
- channel.metadata = DataValueCollection.fromObject(rawChannel.metadata);
27
+ if (Object.prototype.hasOwnProperty.call(rawChannel, 'metadata')) {
28
+ channel.metadata = DataValueCollection.fromObject(rawChannel.metadata);
29
+ }
28
30
  return channel;
29
31
  }
30
32
  }
@@ -24,7 +24,9 @@ export class Subscriber extends MetaDataAware {
24
24
  static parseRaw(rawSubscriber) {
25
25
  const subscriber = new Subscriber(rawSubscriber.id, rawSubscriber.event_types, rawSubscriber.project_environment, rawSubscriber.flow, rawSubscriber.flow_run, rawSubscriber.channels, rawSubscriber.log_level_threshold);
26
26
  subscriber.state = State.fromString(rawSubscriber.state);
27
- subscriber.metadata = DataValueCollection.fromObject(rawSubscriber.metadata);
27
+ if (Object.prototype.hasOwnProperty.call(rawSubscriber, 'metadata')) {
28
+ subscriber.metadata = DataValueCollection.fromObject(rawSubscriber.metadata);
29
+ }
28
30
  return subscriber;
29
31
  }
30
32
  getLogLevelThreshold() {
@@ -24,7 +24,9 @@ export class Trigger extends MetaDataAware {
24
24
  const trigger = new Trigger(rawTrigger.id, rawTrigger.type, rawTrigger.project_environment, flowId, parsedData);
25
25
  trigger.arguments = rawTrigger.arguments;
26
26
  trigger.state = State.fromString(rawTrigger.state);
27
- trigger.metadata = DataValueCollection.fromObject(rawTrigger.metadata);
27
+ if (Object.prototype.hasOwnProperty.call(rawTrigger, 'metadata')) {
28
+ trigger.metadata = DataValueCollection.fromObject(rawTrigger.metadata);
29
+ }
28
30
  return trigger;
29
31
  }
30
32
  getData() {
@@ -0,0 +1,10 @@
1
+ import { Endpoint } from './Endpoint.js';
2
+ import { UserAction } from '../Model/User/UserAction.js';
3
+ import { CollectionResult } from '../Model/Result/CollectionResult.js';
4
+ import { CursorPagination } from '../Model/Pagination/CursorPagination.js';
5
+ export declare class UserActionEndpoint extends Endpoint {
6
+ getWorkspaceMemberActions(workspaceId: string, memberId: string, pagination?: CursorPagination | null): Promise<CollectionResult<UserAction>>;
7
+ getUserActions(userId: string, pagination?: CursorPagination | null): Promise<CollectionResult<UserAction>>;
8
+ getByResource(resourceId: string, resourceType: string, pagination?: CursorPagination | null): Promise<CollectionResult<UserAction>>;
9
+ private static parse;
10
+ }
@@ -0,0 +1,64 @@
1
+ import { Endpoint } from './Endpoint.js';
2
+ import { Utils } from '../Utils.js';
3
+ import { UserAction } from '../Model/User/UserAction.js';
4
+ import { DataValueCollection } from '../Model/DataValueCollection.js';
5
+ import { QueryString } from '../Http/Data/QueryString.js';
6
+ export class UserActionEndpoint extends Endpoint {
7
+ async getWorkspaceMemberActions(workspaceId, memberId, pagination = null) {
8
+ try {
9
+ const queryString = new QueryString('/workspaces/' + workspaceId + '/members/' + memberId + '/actions');
10
+ queryString.addPagination(pagination);
11
+ const result = await this.requestCollection(queryString, UserActionEndpoint.parse, null, 'GET');
12
+ return result;
13
+ }
14
+ catch (error) {
15
+ if (this.httpClient.isDebugEnabled()) {
16
+ console.error('Failed to load adapter configuration: ', error);
17
+ }
18
+ throw error;
19
+ }
20
+ }
21
+ async getUserActions(userId, pagination = null) {
22
+ try {
23
+ const queryString = new QueryString('/users/' + userId + '/actions');
24
+ queryString.addPagination(pagination);
25
+ const result = await this.requestCollection(queryString, UserActionEndpoint.parse, null, 'GET');
26
+ return result;
27
+ }
28
+ catch (error) {
29
+ if (this.httpClient.isDebugEnabled()) {
30
+ console.error('Failed to load adapter configuration: ', error);
31
+ }
32
+ throw error;
33
+ }
34
+ }
35
+ async getByResource(resourceId, resourceType, pagination = null) {
36
+ try {
37
+ const queryString = new QueryString('/resources/' + resourceType + '/' + resourceId + '/actions');
38
+ queryString.addPagination(pagination);
39
+ const result = await this.requestCollection(queryString, UserActionEndpoint.parse, null, 'GET');
40
+ return result;
41
+ }
42
+ catch (error) {
43
+ if (this.httpClient.isDebugEnabled()) {
44
+ console.error('Failed to load adapter configuration: ', error);
45
+ }
46
+ throw error;
47
+ }
48
+ }
49
+ static parse(rawUserEvent) {
50
+ const userAction = new UserAction();
51
+ userAction.id = rawUserEvent.id;
52
+ userAction.userId = rawUserEvent.user;
53
+ userAction.workspaceId = rawUserEvent.workspace;
54
+ userAction.action = rawUserEvent.action;
55
+ userAction.resourceId = rawUserEvent.resource;
56
+ userAction.resourceType = rawUserEvent.resource_type;
57
+ userAction.description = rawUserEvent.description;
58
+ userAction.ip = rawUserEvent.ip;
59
+ userAction.time = Utils.parseRawDate(rawUserEvent.time);
60
+ userAction.result = rawUserEvent.result;
61
+ userAction.data = DataValueCollection.fromObject(rawUserEvent.data);
62
+ return userAction;
63
+ }
64
+ }
@@ -7,27 +7,6 @@ export class UserEndpoint extends Endpoint {
7
7
  const rawUser = await this.requestObject(cmd, null, User.parse);
8
8
  return rawUser.getData();
9
9
  }
10
- // public async createAuthProvider(providerType: string, data: { code: string; state: string }): Promise<boolean> {
11
- // try {
12
- // const parser = (raw: any): { created: boolean } => raw;
13
- // const result: ObjectResult<{
14
- // created: boolean
15
- // }> = await this.requestObject('/users/auth/providers', {
16
- // provider_type: providerType, code: data.code, state: data.state
17
- // }, parser, 'POST');
18
- // const re: { created: boolean } | null = result.getData();
19
- // if (re === null) {
20
- // console.log('create auth provider wrong data', {result, parsed: re});
21
- // throw new Error('Unable to create auth provider: wrong response from API');
22
- // }
23
- // return re.created;
24
- // } catch (e) {
25
- // if (this.httpClient.isDebugEnabled()) {
26
- // console.error('Failed to assign auth provider: ', e);
27
- // }
28
- // throw e;
29
- // }
30
- // }
31
10
  async removeAuthProvider(providerId) {
32
11
  try {
33
12
  const parser = (raw) => ({ deleted: raw.deleted });
@@ -1,5 +1,4 @@
1
1
  import { Endpoint } from './Endpoint.js';
2
- import { UserAction } from '../Model/User/UserAction.js';
3
2
  import { WorkspaceMember } from '../Model/Workspace/WorkspaceMember.js';
4
3
  import { WorkspaceMemberInvite } from '../Model/Workspace/WorkspaceMemberInvite.js';
5
4
  import { WorkspaceMemberInvite2 } from '../Model/Workspace/WorkspaceMemberInvite2.js';
@@ -9,6 +8,4 @@ export declare class WorkspaceMemberEndpoint extends Endpoint {
9
8
  getByWorkspace(workspaceId: string, pagination?: CursorPagination | null): Promise<CollectionResult<WorkspaceMember>>;
10
9
  invite(workspaceId: string, invites: WorkspaceMemberInvite[]): Promise<boolean>;
11
10
  getWorkspaceInviteByCode(inviteCode: string): Promise<WorkspaceMemberInvite2 | null>;
12
- getWorkspaceMemberEvents(workspaceId: string, memberId: string): Promise<CollectionResult<UserAction>>;
13
- private static parse;
14
11
  }
@@ -1,8 +1,6 @@
1
1
  import { Endpoint } from './Endpoint.js';
2
2
  import { Utils } from '../Utils.js';
3
3
  import { State } from '../Model/State.js';
4
- import { UserAction } from '../Model/User/UserAction.js';
5
- import { DataValueCollection } from '../Model/DataValueCollection.js';
6
4
  import { WorkspaceMember } from '../Model/Workspace/WorkspaceMember.js';
7
5
  import { WorkspaceMemberRole } from '../Model/Workspace/WorkspaceMemberRole.js';
8
6
  import { WorkspaceMemberInviteState } from '../Model/Workspace/WorkspaceMemberInviteState.js';
@@ -68,32 +66,4 @@ export class WorkspaceMemberEndpoint extends Endpoint {
68
66
  }
69
67
  return null;
70
68
  }
71
- async getWorkspaceMemberEvents(workspaceId, memberId) {
72
- try {
73
- const url = '/workspaces/' + workspaceId + '/members/' + memberId + '/events';
74
- const result = await this.requestCollection(url, WorkspaceMemberEndpoint.parse, null, 'GET');
75
- return result;
76
- }
77
- catch (error) {
78
- if (this.httpClient.isDebugEnabled()) {
79
- console.error('Failed to load adapter configuration: ', error);
80
- }
81
- throw error;
82
- }
83
- }
84
- static parse(rawUserEvent) {
85
- const userAction = new UserAction();
86
- userAction.id = rawUserEvent.id;
87
- userAction.userId = rawUserEvent.user;
88
- userAction.workspaceId = rawUserEvent.workspace;
89
- userAction.action = rawUserEvent.action;
90
- userAction.resourceId = rawUserEvent.resource;
91
- userAction.resourceType = rawUserEvent.resource_type;
92
- userAction.description = rawUserEvent.description;
93
- userAction.ip = rawUserEvent.ip;
94
- userAction.time = Utils.parseRawDate(rawUserEvent.time);
95
- userAction.result = rawUserEvent.result;
96
- userAction.data = DataValueCollection.fromObject(rawUserEvent.data);
97
- return userAction;
98
- }
99
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attlaz-client",
3
- "version": "1.13.19",
3
+ "version": "1.13.21",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",