attlaz-client 1.23.1 → 1.24.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.
@@ -1,5 +1,6 @@
1
1
  import { CursorPagination } from '../../Model/Pagination/CursorPagination.js';
2
2
  import { State } from '../../Model/State.js';
3
+ import { Filters } from '../../Model/Pagination/Filters.js';
3
4
  export declare class QueryString {
4
5
  private command;
5
6
  private parameters;
@@ -7,6 +8,7 @@ export declare class QueryString {
7
8
  setCommand(command: string): void;
8
9
  set(parameter: string, value: string | number | boolean | string[]): void;
9
10
  addPagination(pagination: CursorPagination | null): void;
11
+ addFilters(filters: Filters): void;
10
12
  addStateFilter(states: State[] | null): void;
11
13
  getParameters(): {
12
14
  parameter: string;
@@ -27,6 +27,12 @@ export class QueryString {
27
27
  }
28
28
  }
29
29
  }
30
+ addFilters(filters) {
31
+ for (const filter of filters.toArray()) {
32
+ const strMethod = filter.method === 'eq' ? '' : '[' + filter.method + ']';
33
+ this.set(filter.field + strMethod, filter.value);
34
+ }
35
+ }
30
36
  addStateFilter(states) {
31
37
  if (states !== null) {
32
38
  this.set('state', states);
@@ -0,0 +1,20 @@
1
+ export declare class Filters {
2
+ /**
3
+ * gte = greater than or equal
4
+ * gt = greater than
5
+ * lte = less than or equal
6
+ * lt = more than
7
+ * eq = equal
8
+ * in = in
9
+ */
10
+ private readonly filters;
11
+ addEqualFilter(field: string, value: string | number): void;
12
+ addBetweenFilter(field: string, valueA: string | number, valueB: string | number): void;
13
+ toArray(): Filter[];
14
+ }
15
+ type Filter = {
16
+ field: string;
17
+ method: string;
18
+ value: string | number;
19
+ };
20
+ export {};
@@ -0,0 +1,33 @@
1
+ export class Filters {
2
+ /**
3
+ * gte = greater than or equal
4
+ * gt = greater than
5
+ * lte = less than or equal
6
+ * lt = more than
7
+ * eq = equal
8
+ * in = in
9
+ */
10
+ filters = [];
11
+ addEqualFilter(field, value) {
12
+ this.filters.push({
13
+ field: field,
14
+ method: 'eq',
15
+ value: value,
16
+ });
17
+ }
18
+ addBetweenFilter(field, valueA, valueB) {
19
+ this.filters.push({
20
+ field: field,
21
+ method: 'gte',
22
+ value: valueA,
23
+ });
24
+ this.filters.push({
25
+ field: field,
26
+ method: 'lte',
27
+ value: valueB,
28
+ });
29
+ }
30
+ toArray() {
31
+ return this.filters;
32
+ }
33
+ }
@@ -6,5 +6,6 @@ export declare class UserActionEndpoint extends Endpoint {
6
6
  getWorkspaceMemberActions(workspaceId: string, memberId: string, pagination?: CursorPagination | null): Promise<CollectionResult<UserAction>>;
7
7
  getUserActions(userId: string, pagination?: CursorPagination | null): Promise<CollectionResult<UserAction>>;
8
8
  getByResource(resourceId: string, resourceType: string, pagination?: CursorPagination | null): Promise<CollectionResult<UserAction>>;
9
+ getAll(pagination?: CursorPagination | null): Promise<CollectionResult<UserAction>>;
9
10
  private static parse;
10
11
  }
@@ -8,8 +8,7 @@ export class UserActionEndpoint extends Endpoint {
8
8
  try {
9
9
  const queryString = new QueryString('/workspaces/' + workspaceId + '/members/' + memberId + '/actions');
10
10
  queryString.addPagination(pagination);
11
- const result = await this.requestCollection(queryString, UserActionEndpoint.parse, null, 'GET');
12
- return result;
11
+ return await this.requestCollection(queryString, UserActionEndpoint.parse, null, 'GET');
13
12
  }
14
13
  catch (error) {
15
14
  if (this.httpClient.isDebugEnabled()) {
@@ -22,8 +21,7 @@ export class UserActionEndpoint extends Endpoint {
22
21
  try {
23
22
  const queryString = new QueryString('/users/' + userId + '/actions');
24
23
  queryString.addPagination(pagination);
25
- const result = await this.requestCollection(queryString, UserActionEndpoint.parse, null, 'GET');
26
- return result;
24
+ return await this.requestCollection(queryString, UserActionEndpoint.parse, null, 'GET');
27
25
  }
28
26
  catch (error) {
29
27
  if (this.httpClient.isDebugEnabled()) {
@@ -36,8 +34,7 @@ export class UserActionEndpoint extends Endpoint {
36
34
  try {
37
35
  const queryString = new QueryString('/resources/' + resourceType + '/' + resourceId + '/actions');
38
36
  queryString.addPagination(pagination);
39
- const result = await this.requestCollection(queryString, UserActionEndpoint.parse, null, 'GET');
40
- return result;
37
+ return await this.requestCollection(queryString, UserActionEndpoint.parse, null, 'GET');
41
38
  }
42
39
  catch (error) {
43
40
  if (this.httpClient.isDebugEnabled()) {
@@ -46,6 +43,11 @@ export class UserActionEndpoint extends Endpoint {
46
43
  throw error;
47
44
  }
48
45
  }
46
+ async getAll(pagination = null) {
47
+ const queryString = new QueryString('/audit-logs');
48
+ queryString.addPagination(pagination);
49
+ return await this.requestCollection(queryString, UserActionEndpoint.parse, null, 'GET');
50
+ }
49
51
  static parse(rawUserEvent) {
50
52
  const userAction = new UserAction();
51
53
  userAction.id = rawUserEvent.id;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.23.0";
1
+ export declare const VERSION = "1.23.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.23.0";
1
+ export const VERSION = "1.23.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attlaz-client",
3
- "version": "1.23.1",
3
+ "version": "1.24.0",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",