attlaz-client 1.9.13 → 1.9.15

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,4 @@
1
+ import { DataValueCollection } from '../Model/DataValueCollection';
2
+ export declare abstract class MetaDataAware {
3
+ metadata: DataValueCollection;
4
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MetaDataAware = void 0;
4
+ class MetaDataAware {
5
+ }
6
+ exports.MetaDataAware = MetaDataAware;
@@ -1,6 +1,7 @@
1
1
  import { State } from '../State';
2
2
  import { StateAware } from '../StateAware';
3
- export declare class Flow implements StateAware {
3
+ import { MetaDataAware } from '../../Core/MetaDataAware';
4
+ export declare class Flow extends MetaDataAware implements StateAware {
4
5
  id: string;
5
6
  key: string;
6
7
  name: string;
@@ -10,5 +11,5 @@ export declare class Flow implements StateAware {
10
11
  state: State;
11
12
  /** The maximum number of tasks to run at any time (0 = no limit) **/
12
13
  parallelLimit: number;
13
- static parse(rawTask: any): Flow;
14
+ static parse(rawFlow: any): Flow;
14
15
  }
@@ -3,23 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Flow = void 0;
4
4
  const State_1 = require("../State");
5
5
  const Utils_1 = require("../../Utils");
6
- class Flow {
6
+ const MetaDataAware_1 = require("../../Core/MetaDataAware");
7
+ const DataValueCollection_1 = require("../DataValueCollection");
8
+ class Flow extends MetaDataAware_1.MetaDataAware {
7
9
  constructor() {
10
+ super(...arguments);
8
11
  this.isDirect = false;
9
12
  this.state = State_1.State.Active;
10
13
  /** The maximum number of tasks to run at any time (0 = no limit) **/
11
14
  this.parallelLimit = 0;
12
15
  }
13
- static parse(rawTask) {
16
+ static parse(rawFlow) {
14
17
  const task = new Flow();
15
- task.id = rawTask.id;
16
- task.key = rawTask.key;
17
- task.projectId = rawTask.project;
18
- task.name = rawTask.name;
19
- task.description = rawTask.description;
20
- task.isDirect = Utils_1.Utils.isTrue(rawTask.is_direct);
21
- task.state = State_1.State.fromString(rawTask.state);
22
- task.parallelLimit = Utils_1.Utils.parseInt(rawTask.parallel_limit);
18
+ task.id = rawFlow.id;
19
+ task.key = rawFlow.key;
20
+ task.projectId = rawFlow.project;
21
+ task.name = rawFlow.name;
22
+ task.description = rawFlow.description;
23
+ task.isDirect = Utils_1.Utils.isTrue(rawFlow.is_direct);
24
+ task.state = State_1.State.fromString(rawFlow.state);
25
+ task.parallelLimit = Utils_1.Utils.parseInt(rawFlow.parallel_limit);
26
+ task.metadata = DataValueCollection_1.DataValueCollection.fromObject(rawFlow.metadata);
23
27
  return task;
24
28
  }
25
29
  }
@@ -1,6 +1,7 @@
1
1
  import { LogLevel } from '../Log/LogLevel';
2
2
  import { FlowRunPriority } from './FlowRunPriority';
3
- export declare class FlowRun {
3
+ import { MetaDataAware } from '../../Core/MetaDataAware';
4
+ export declare class FlowRun extends MetaDataAware {
4
5
  id: string;
5
6
  flowId: string;
6
7
  name: string;
@@ -11,5 +12,5 @@ export declare class FlowRun {
11
12
  deployId: string;
12
13
  logLevelCount: Map<LogLevel, number>;
13
14
  logsPurged: boolean;
14
- static parse(rawTaskExecution: any): FlowRun;
15
+ static parse(rawFlowRun: any): FlowRun;
15
16
  }
@@ -3,26 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FlowRun = void 0;
4
4
  const Utils_1 = require("../../Utils");
5
5
  const FlowRunPriority_1 = require("./FlowRunPriority");
6
- class FlowRun {
6
+ const MetaDataAware_1 = require("../../Core/MetaDataAware");
7
+ const DataValueCollection_1 = require("../DataValueCollection");
8
+ class FlowRun extends MetaDataAware_1.MetaDataAware {
7
9
  constructor() {
10
+ super(...arguments);
8
11
  // TODO: implement priority object
9
12
  this.priority = FlowRunPriority_1.FlowRunPriority.None;
10
13
  this.logsPurged = false;
11
14
  }
12
- static parse(rawTaskExecution) {
13
- let taskExecution = new FlowRun();
14
- taskExecution.id = rawTaskExecution.id;
15
- // taskExecution.code = rawTaskExecution.code;
16
- taskExecution.name = rawTaskExecution.name;
17
- taskExecution.flowId = rawTaskExecution.flow;
18
- taskExecution.arguments = rawTaskExecution.arguments;
19
- taskExecution.projectEnvironmentId = rawTaskExecution.project_environment;
20
- taskExecution.priority = FlowRunPriority_1.FlowRunPriority.fromString(rawTaskExecution.priority);
21
- taskExecution.triggerId = rawTaskExecution.trigger;
22
- taskExecution.deployId = rawTaskExecution.deploy;
23
- taskExecution.logLevelCount = rawTaskExecution.log_level_count;
24
- taskExecution.logsPurged = Utils_1.Utils.isTrue(rawTaskExecution.logs_purged);
25
- return taskExecution;
15
+ static parse(rawFlowRun) {
16
+ let flowRun = new FlowRun();
17
+ flowRun.id = rawFlowRun.id;
18
+ flowRun.flowId = rawFlowRun.flow;
19
+ flowRun.arguments = rawFlowRun.arguments;
20
+ flowRun.projectEnvironmentId = rawFlowRun.project_environment;
21
+ flowRun.priority = FlowRunPriority_1.FlowRunPriority.fromString(rawFlowRun.priority);
22
+ flowRun.triggerId = rawFlowRun.trigger;
23
+ flowRun.deployId = rawFlowRun.deploy;
24
+ flowRun.logLevelCount = rawFlowRun.log_level_count;
25
+ flowRun.logsPurged = Utils_1.Utils.isTrue(rawFlowRun.logs_purged);
26
+ flowRun.metadata = DataValueCollection_1.DataValueCollection.fromObject(rawFlowRun.metadata);
27
+ return flowRun;
26
28
  }
27
29
  }
28
30
  exports.FlowRun = FlowRun;
@@ -1,7 +1,8 @@
1
1
  import { ChannelType } from './ChannelType';
2
2
  import { State } from '../../State';
3
3
  import { StateAware } from '../../StateAware';
4
- export declare class Channel implements StateAware {
4
+ import { MetaDataAware } from '../../../Core/MetaDataAware';
5
+ export declare class Channel extends MetaDataAware implements StateAware {
5
6
  id: string;
6
7
  owner: string;
7
8
  label: string;
@@ -4,8 +4,11 @@ exports.Channel = void 0;
4
4
  const ChannelType_1 = require("./ChannelType");
5
5
  const State_1 = require("../../State");
6
6
  const Utils_1 = require("../../../Utils");
7
- class Channel {
7
+ const MetaDataAware_1 = require("../../../Core/MetaDataAware");
8
+ const DataValueCollection_1 = require("../../DataValueCollection");
9
+ class Channel extends MetaDataAware_1.MetaDataAware {
8
10
  constructor(id, owner, label, type, data) {
11
+ super();
9
12
  this.state = State_1.State.Active;
10
13
  this.private = false;
11
14
  this.id = id;
@@ -19,6 +22,7 @@ class Channel {
19
22
  const channel = new Channel(rawChannel.id, rawChannel.owner, rawChannel.label, type, rawChannel.data);
20
23
  channel.state = State_1.State.fromString(rawChannel.state);
21
24
  channel.private = Utils_1.Utils.isTrue(rawChannel.private);
25
+ channel.metadata = DataValueCollection_1.DataValueCollection.fromObject(rawChannel.metadata);
22
26
  return channel;
23
27
  }
24
28
  }
@@ -2,7 +2,8 @@ import { State } from '../State';
2
2
  import { EventType } from '../Event/EventType';
3
3
  import { LogLevel } from '../Log/LogLevel';
4
4
  import { StateAware } from '../StateAware';
5
- export declare class Subscriber implements StateAware {
5
+ import { MetaDataAware } from '../../Core/MetaDataAware';
6
+ export declare class Subscriber extends MetaDataAware implements StateAware {
6
7
  id: string;
7
8
  eventTypes: EventType[];
8
9
  projectEnvironment: string;
@@ -3,8 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Subscriber = void 0;
4
4
  const State_1 = require("../State");
5
5
  const LogLevel_1 = require("../Log/LogLevel");
6
- class Subscriber {
6
+ const MetaDataAware_1 = require("../../Core/MetaDataAware");
7
+ const DataValueCollection_1 = require("../DataValueCollection");
8
+ class Subscriber extends MetaDataAware_1.MetaDataAware {
7
9
  constructor(id, eventTypes, projectEnvironment, task, taskExecution, channels, logLevelThreshold = LogLevel_1.LogLevel.Debug) {
10
+ super();
8
11
  this.state = State_1.State.Active;
9
12
  this.id = id;
10
13
  this.eventTypes = eventTypes;
@@ -17,6 +20,7 @@ class Subscriber {
17
20
  static parseRaw(rawSubscriber) {
18
21
  let subscriber = new Subscriber(rawSubscriber.id, rawSubscriber.eventTypes, rawSubscriber.projectEnvironment, rawSubscriber.task, rawSubscriber.task_execution, rawSubscriber.channels, rawSubscriber.logLevelThreshold);
19
22
  subscriber.state = State_1.State.fromString(rawSubscriber.state);
23
+ subscriber.metadata = DataValueCollection_1.DataValueCollection.fromObject(rawSubscriber.metadata);
20
24
  return subscriber;
21
25
  }
22
26
  getLogLevelThreshold() {
@@ -2,7 +2,8 @@ import { TriggerData } from "./TriggerData";
2
2
  import { State } from '../State';
3
3
  import { TriggerType } from './TriggerType';
4
4
  import { StateAware } from '../StateAware';
5
- export declare class Trigger implements StateAware {
5
+ import { MetaDataAware } from '../../Core/MetaDataAware';
6
+ export declare class Trigger extends MetaDataAware implements StateAware {
6
7
  id: string;
7
8
  type: TriggerType;
8
9
  projectEnvironmentId: string;
@@ -6,8 +6,11 @@ const TriggerType_1 = require("./TriggerType");
6
6
  const ScheduleTriggerData_1 = require("./ScheduleTriggerData");
7
7
  const WebhookTriggerData_1 = require("./WebhookTriggerData");
8
8
  const ApiTriggerData_1 = require("./ApiTriggerData");
9
- class Trigger {
9
+ const MetaDataAware_1 = require("../../Core/MetaDataAware");
10
+ const DataValueCollection_1 = require("../DataValueCollection");
11
+ class Trigger extends MetaDataAware_1.MetaDataAware {
10
12
  constructor(id, type, projectEnvironmentId, flowId, data) {
13
+ super();
11
14
  this.state = State_1.State.Active;
12
15
  this.id = id;
13
16
  this.type = type;
@@ -17,6 +20,7 @@ class Trigger {
17
20
  this.arguments = {};
18
21
  }
19
22
  static parse(rawTrigger) {
23
+ console.log(rawTrigger);
20
24
  const type = TriggerType_1.TriggerType.fromString(rawTrigger.type);
21
25
  const data = rawTrigger.data;
22
26
  const flowId = rawTrigger.flow;
@@ -37,6 +41,7 @@ class Trigger {
37
41
  let trigger = new Trigger(rawTrigger.id, type, rawTrigger.project_environment, flowId, triggerData);
38
42
  trigger.arguments = rawTrigger.arguments;
39
43
  trigger.state = State_1.State.fromString(rawTrigger.state);
44
+ trigger.metadata = DataValueCollection_1.DataValueCollection.fromObject(rawTrigger.metadata);
40
45
  return trigger;
41
46
  }
42
47
  getData() {
@@ -1,12 +1,12 @@
1
1
  import { OAuthClient } from '../Http/OAuthClient';
2
- import { DataResult } from '../Model/Result/DataResult';
3
2
  import { CollectionResult } from '../Model/Result/CollectionResult';
4
3
  import { ObjectResult } from '../Model/Result/ObjectResult';
5
4
  export declare abstract class Endpoint {
6
5
  protected httpClient: OAuthClient;
7
6
  constructor(httpClient: OAuthClient);
7
+ private formatParameters;
8
+ private formatKey;
8
9
  requestCollection<T>(action: string, parameters: any, parser: (input: any) => T, method?: string, signWithOauthToken?: boolean): Promise<CollectionResult<T>>;
9
10
  requestObject<T>(action: string, parameters: any, parser: (input: any) => T, method?: string, signWithOauthToken?: boolean): Promise<ObjectResult<T>>;
10
- request<T>(action: string, parameters?: any, method?: string, signWithOauthToken?: boolean): Promise<DataResult<T>>;
11
11
  parseCollection<T>(rawData: object[], parser: (input: any) => T): T[];
12
12
  }
@@ -1,17 +1,68 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Endpoint = void 0;
4
- const DataResult_1 = require("../Model/Result/DataResult");
5
4
  const CollectionResult_1 = require("../Model/Result/CollectionResult");
6
5
  const ObjectResult_1 = require("../Model/Result/ObjectResult");
7
6
  const HttpClient_1 = require("../Http/HttpClient");
8
7
  const Utils_1 = require("../Utils");
9
8
  const ObjectWrapper_1 = require("../Model/Result/ObjectWrapper");
9
+ const DataValueCollection_1 = require("../Model/DataValueCollection");
10
+ const JsonSerializable_1 = require("../Model/JsonSerializable");
10
11
  class Endpoint {
11
12
  constructor(httpClient) {
12
13
  this.httpClient = httpClient;
13
14
  }
15
+ formatParameters(data = null) {
16
+ if (data === null || data === undefined) {
17
+ return null;
18
+ }
19
+ if (Array.isArray(data)) {
20
+ const result = [];
21
+ for (const value of data) {
22
+ result.push(this.formatParameters(value));
23
+ }
24
+ return result;
25
+ }
26
+ // if (DateHelper.isDate(data)) {
27
+ // return DateHelper.toString(data);
28
+ // }
29
+ // tODo: this does not seem to work correclty
30
+ if (data instanceof JsonSerializable_1.JsonSerializable && 'jsonSerialize' in data) {
31
+ return data.jsonSerialize();
32
+ }
33
+ if (typeof data === 'object') {
34
+ if (
35
+ // data instanceof WorkspaceId ||
36
+ // data instanceof ProjectEnvironmentId ||
37
+ // data instanceof ProjectId ||
38
+ // data instanceof OrganisationId ||
39
+ // data instanceof FlowId ||
40
+ // data instanceof FlowRunId ||
41
+ // data instanceof UserId ||
42
+ // data instanceof DataCollectionResult ||
43
+ // data instanceof SuccessResult ||
44
+ data instanceof DataValueCollection_1.DataValueCollection) {
45
+ return this.formatParameters(data.jsonSerialize());
46
+ }
47
+ const result = {};
48
+ for (const [key, value] of Object.entries(data)) {
49
+ const formattedKey = this.formatKey(key);
50
+ result[formattedKey] = this.formatParameters(value);
51
+ }
52
+ return result;
53
+ }
54
+ return data;
55
+ }
56
+ formatKey(key) {
57
+ let formattedKey = key.replace(/([A-Z])/g, ' $1');
58
+ formattedKey = formattedKey.split(' ').join('_').toLowerCase();
59
+ if (formattedKey.endsWith('_id')) {
60
+ formattedKey = formattedKey.substring(0, formattedKey.length - '_id'.length);
61
+ }
62
+ return formattedKey;
63
+ }
14
64
  async requestCollection(action, parameters = null, parser, method = 'GET', signWithOauthToken = true) {
65
+ parameters = this.formatParameters(parameters);
15
66
  const requestResponse = await this.httpClient.request(action, parameters, method, signWithOauthToken);
16
67
  const result = new CollectionResult_1.CollectionResult();
17
68
  /**
@@ -32,6 +83,7 @@ class Endpoint {
32
83
  return result;
33
84
  }
34
85
  async requestObject(action, parameters = null, parser, method = 'GET', signWithOauthToken = true) {
86
+ parameters = this.formatParameters(parameters);
35
87
  const result = new ObjectResult_1.ObjectResult();
36
88
  try {
37
89
  let requestResponse = await this.httpClient.request(action, parameters, method, signWithOauthToken);
@@ -39,8 +91,8 @@ class Endpoint {
39
91
  /**
40
92
  * Parse errors
41
93
  */
42
- // TODO: temporary check untill we know the API is fully upgraded
43
- if (requestResponse.hasOwnProperty('data') && requestResponse.data !== undefined) {
94
+ // TODO: temporary check until we know the API is fully upgraded
95
+ if ((requestResponse.hasOwnProperty('data') && !requestResponse.hasOwnProperty('id')) && requestResponse.data !== undefined) {
44
96
  console.error('Response for object "' + action + '" seem to still use old "data" property', { requestResponse });
45
97
  requestResponse = requestResponse.data;
46
98
  }
@@ -57,10 +109,11 @@ class Endpoint {
57
109
  return result;
58
110
  }
59
111
  ;
60
- async request(action, parameters = null, method = 'GET', signWithOauthToken = true) {
61
- const result = await this.httpClient.request(action, parameters, method, signWithOauthToken);
62
- return DataResult_1.DataResult.parse(result);
63
- }
112
+ // public async request<T>(action: string, parameters: any | null = null, method: string = 'GET', signWithOauthToken: boolean = true): Promise<DataResult<T>> {
113
+ // const result: any = await this.httpClient.request(action, parameters, method, signWithOauthToken);
114
+ //
115
+ // return DataResult.parse<T>(result);
116
+ // }
64
117
  parseCollection(rawData, parser) {
65
118
  const data = [];
66
119
  if (!Array.isArray(rawData)) {
@@ -50,7 +50,7 @@ class FlowRunEndpoint extends Endpoint_1.Endpoint {
50
50
  }
51
51
  async getFlowRunSummary(flowRunId) {
52
52
  try {
53
- const result = await this.requestObject('/taskexecutions/' + flowRunId + '/summaries', null, FlowRunSummary_1.FlowRunSummary.parse);
53
+ const result = await this.requestObject('/flowruns/' + flowRunId + '/summaries', null, FlowRunSummary_1.FlowRunSummary.parse);
54
54
  return result;
55
55
  }
56
56
  catch (error) {
@@ -25,7 +25,7 @@ class StorageEndpoint extends Endpoint_1.Endpoint {
25
25
  let cmd = '/projectenvironments/' + projectEnvironmentId + '/storage/' + storageType + '/' + poolKey;
26
26
  try {
27
27
  const parser = (raw) => {
28
- return raw.cleared;
28
+ return raw.deleted;
29
29
  };
30
30
  const result = await this.requestObject(cmd, null, parser, 'DELETE');
31
31
  const re = result.getData();
@@ -33,7 +33,7 @@ class StorageEndpoint extends Endpoint_1.Endpoint {
33
33
  console.log('clearpool wrong data', { result, parsed: re });
34
34
  throw new Error('Something went wrong');
35
35
  }
36
- return re.cleared;
36
+ return re.deleted;
37
37
  }
38
38
  catch (ex) {
39
39
  if (this.httpClient.isDebugEnabled()) {
@@ -90,7 +90,7 @@ class WorkspaceMemberEndpoint extends Endpoint_1.Endpoint {
90
90
  userAction.userId = rawUserEvent.user;
91
91
  userAction.workspaceId = rawUserEvent.workspace;
92
92
  userAction.action = rawUserEvent.action;
93
- userAction.resourceId = rawUserEvent.resource_id;
93
+ userAction.resourceId = rawUserEvent.resource;
94
94
  userAction.resourceType = rawUserEvent.resource_type;
95
95
  userAction.description = rawUserEvent.description;
96
96
  userAction.ip = rawUserEvent.ip;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attlaz-client",
3
- "version": "1.9.13",
3
+ "version": "1.9.15",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",