@ampsec/platform-client 34.0.0 → 35.1.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.
Files changed (39) hide show
  1. package/build/src/dto/enums/index.d.ts +2 -1
  2. package/build/src/dto/enums/index.js +2 -1
  3. package/build/src/dto/enums/index.js.map +1 -1
  4. package/build/src/dto/enums/{notification.type.d.ts → notification.strategy.d.ts} +1 -1
  5. package/build/src/dto/enums/notification.strategy.js +11 -0
  6. package/build/src/dto/enums/notification.strategy.js.map +1 -0
  7. package/build/src/dto/enums/{workflowStep.type.d.ts → workflowStep.kind.d.ts} +1 -1
  8. package/build/src/dto/enums/workflowStep.kind.js +10 -0
  9. package/build/src/dto/enums/workflowStep.kind.js.map +1 -0
  10. package/build/src/dto/enums/{workflowTrigger.type.d.ts → workflowTrigger.kind.d.ts} +1 -1
  11. package/build/src/dto/enums/workflowTrigger.kind.js +11 -0
  12. package/build/src/dto/enums/workflowTrigger.kind.js.map +1 -0
  13. package/build/src/dto/notification.dto.d.ts +2 -2
  14. package/build/src/dto/workflow.dto.d.ts +4 -4
  15. package/build/src/index.d.ts +1 -0
  16. package/build/src/index.js +1 -0
  17. package/build/src/index.js.map +1 -1
  18. package/build/src/logging.d.ts +7 -0
  19. package/build/src/logging.js +5 -0
  20. package/build/src/logging.js.map +1 -0
  21. package/build/src/services/rest/RestClient.d.ts +4 -0
  22. package/build/src/services/rest/RestClient.js +4 -2
  23. package/build/src/services/rest/RestClient.js.map +1 -1
  24. package/package.json +1 -1
  25. package/src/dto/enums/index.ts +2 -1
  26. package/src/dto/enums/{notification.type.ts → notification.strategy.ts} +1 -1
  27. package/src/dto/enums/{workflowStep.type.ts → workflowStep.kind.ts} +1 -1
  28. package/src/dto/enums/{workflowTrigger.type.ts → workflowTrigger.kind.ts} +1 -1
  29. package/src/dto/notification.dto.ts +2 -2
  30. package/src/dto/workflow.dto.ts +4 -4
  31. package/src/index.ts +1 -0
  32. package/src/logging.ts +8 -0
  33. package/src/services/rest/RestClient.ts +8 -2
  34. package/build/src/dto/enums/notification.type.js +0 -11
  35. package/build/src/dto/enums/notification.type.js.map +0 -1
  36. package/build/src/dto/enums/workflowStep.type.js +0 -10
  37. package/build/src/dto/enums/workflowStep.type.js.map +0 -1
  38. package/build/src/dto/enums/workflowTrigger.type.js +0 -11
  39. package/build/src/dto/enums/workflowTrigger.type.js.map +0 -1
@@ -10,4 +10,5 @@ export * from './jobExecution.status';
10
10
  export * from './notification.status';
11
11
  export * from './riskContributor.type';
12
12
  export * from './saasComponentKind';
13
- export * from './workflowStep.type';
13
+ export * from './workflowStep.kind';
14
+ export * from './notification.strategy';
@@ -26,5 +26,6 @@ __exportStar(require("./jobExecution.status"), exports);
26
26
  __exportStar(require("./notification.status"), exports);
27
27
  __exportStar(require("./riskContributor.type"), exports);
28
28
  __exportStar(require("./saasComponentKind"), exports);
29
- __exportStar(require("./workflowStep.type"), exports);
29
+ __exportStar(require("./workflowStep.kind"), exports);
30
+ __exportStar(require("./notification.strategy"), exports);
30
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/dto/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,iDAA+B;AAC/B,wDAAsC;AACtC,6CAA2B;AAC3B,qDAAmC;AACnC,gDAA8B;AAC9B,qDAAmC;AACnC,mDAAiC;AACjC,wDAAsC;AACtC,wDAAsC;AACtC,yDAAuC;AACvC,sDAAoC;AACpC,sDAAoC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/dto/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,iDAA+B;AAC/B,wDAAsC;AACtC,6CAA2B;AAC3B,qDAAmC;AACnC,gDAA8B;AAC9B,qDAAmC;AACnC,mDAAiC;AACjC,wDAAsC;AACtC,wDAAsC;AACtC,yDAAuC;AACvC,sDAAoC;AACpC,sDAAoC;AACpC,0DAAwC"}
@@ -1,4 +1,4 @@
1
- export declare enum NotificationType {
1
+ export declare enum NotificationStrategy {
2
2
  LLM = "LLM",
3
3
  RAW = "RAW",
4
4
  TEMPLATE = "TEMPLATE"
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotificationStrategy = void 0;
4
+ /* eslint-disable no-unused-vars */
5
+ var NotificationStrategy;
6
+ (function (NotificationStrategy) {
7
+ NotificationStrategy["LLM"] = "LLM";
8
+ NotificationStrategy["RAW"] = "RAW";
9
+ NotificationStrategy["TEMPLATE"] = "TEMPLATE";
10
+ })(NotificationStrategy || (exports.NotificationStrategy = NotificationStrategy = {}));
11
+ //# sourceMappingURL=notification.strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification.strategy.js","sourceRoot":"","sources":["../../../../src/dto/enums/notification.strategy.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,mCAAW,CAAA;IACX,mCAAW,CAAA;IACX,6CAAqB,CAAA;AACvB,CAAC,EAJW,oBAAoB,oCAApB,oBAAoB,QAI/B"}
@@ -1,4 +1,4 @@
1
- export declare enum WorkflowStepType {
1
+ export declare enum WorkflowStepKind {
2
2
  NOTIFICATION = "NOTIFICATION",
3
3
  PAUSE = "PAUSE"
4
4
  }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkflowStepKind = void 0;
4
+ /* eslint-disable no-unused-vars */
5
+ var WorkflowStepKind;
6
+ (function (WorkflowStepKind) {
7
+ WorkflowStepKind["NOTIFICATION"] = "NOTIFICATION";
8
+ WorkflowStepKind["PAUSE"] = "PAUSE";
9
+ })(WorkflowStepKind || (exports.WorkflowStepKind = WorkflowStepKind = {}));
10
+ //# sourceMappingURL=workflowStep.kind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflowStep.kind.js","sourceRoot":"","sources":["../../../../src/dto/enums/workflowStep.kind.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,iDAA6B,CAAA;IAC7B,mCAAe,CAAA;AACjB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B"}
@@ -1,4 +1,4 @@
1
- export declare enum WorkflowTriggerType {
1
+ export declare enum WorkflowTriggerKind {
2
2
  FINDING = "FINDING",
3
3
  USER = "USER",
4
4
  SAAS_COMPONENT = "SAAS_COMPONENT"
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkflowTriggerKind = void 0;
4
+ /* eslint-disable no-unused-vars */
5
+ var WorkflowTriggerKind;
6
+ (function (WorkflowTriggerKind) {
7
+ WorkflowTriggerKind["FINDING"] = "FINDING";
8
+ WorkflowTriggerKind["USER"] = "USER";
9
+ WorkflowTriggerKind["SAAS_COMPONENT"] = "SAAS_COMPONENT";
10
+ })(WorkflowTriggerKind || (exports.WorkflowTriggerKind = WorkflowTriggerKind = {}));
11
+ //# sourceMappingURL=workflowTrigger.kind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflowTrigger.kind.js","sourceRoot":"","sources":["../../../../src/dto/enums/workflowTrigger.kind.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC7B,0CAAmB,CAAA;IACnB,oCAAa,CAAA;IACb,wDAAiC,CAAA;AACnC,CAAC,EAJW,mBAAmB,mCAAnB,mBAAmB,QAI9B"}
@@ -1,9 +1,9 @@
1
1
  import { BaseDto, BaseUpsertDto } from './base.dto';
2
2
  import { NotificationStatus } from './enums';
3
- import { NotificationType } from './enums/notification.type';
3
+ import { NotificationStrategy } from './enums/notification.strategy';
4
4
  import { NotificationStepData, TrainingNotificationStepData } from './workflow.dto';
5
5
  export type NotificationSchema = {
6
- type: NotificationType;
6
+ strategy: NotificationStrategy;
7
7
  };
8
8
  export type TemplateNotificationSchema = NotificationSchema & {
9
9
  /** ID of the template to be used for the notification */
@@ -1,6 +1,6 @@
1
1
  import { BaseDto } from './base.dto';
2
- import { WorkflowStepType } from './enums/workflowStep.type';
3
- import { WorkflowTriggerType } from './enums/workflowTrigger.type';
2
+ import { WorkflowStepKind } from './enums/workflowStep.kind';
3
+ import { WorkflowTriggerKind } from './enums/workflowTrigger.kind';
4
4
  import { NotificationSchema, TemplateNotificationSchema, RawNotificationSchema } from './notification.dto';
5
5
  export type NotificationStepData = {
6
6
  /** Name of the device to which the notification of finding applies */
@@ -24,7 +24,7 @@ export type PauseStepData = {
24
24
  };
25
25
  export type WorkflowStep = {
26
26
  /** Type of the notification step, either NOTIFICATION or PAUSE */
27
- type: WorkflowStepType;
27
+ kind: WorkflowStepKind;
28
28
  /** Schema for the notification step */
29
29
  schema?: NotificationSchema | TemplateNotificationSchema | RawNotificationSchema;
30
30
  /** Data associated with the notification step */
@@ -46,7 +46,7 @@ export type WorkflowTriggerRule = {
46
46
  };
47
47
  export type WorkflowTrigger = {
48
48
  /** Type of the trigger */
49
- type: WorkflowTriggerType;
49
+ kind: WorkflowTriggerKind;
50
50
  /** Rule to which the applicable entity type must conform to trigger the workflow */
51
51
  rule: unknown;
52
52
  };
@@ -1,4 +1,5 @@
1
1
  export * from './dto';
2
2
  export * from './etag';
3
+ export * from './logging';
3
4
  export * from './services';
4
5
  export * from './FilterCriteria';
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./dto"), exports);
18
18
  __exportStar(require("./etag"), exports);
19
+ __exportStar(require("./logging"), exports);
19
20
  __exportStar(require("./services"), exports);
20
21
  __exportStar(require("./FilterCriteria"), exports);
21
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,yCAAuB;AACvB,6CAA2B;AAC3B,mDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,yCAAuB;AACvB,4CAA0B;AAC1B,6CAA2B;AAC3B,mDAAiC"}
@@ -0,0 +1,7 @@
1
+ export interface AmpLogger {
2
+ info(_message: unknown, _meta?: unknown): void;
3
+ debug(_message: unknown, _meta?: unknown): void;
4
+ warn(_message: unknown, _meta?: unknown): void;
5
+ error(_message: unknown, _meta?: unknown): void;
6
+ }
7
+ export declare const defaultLogger: AmpLogger;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultLogger = void 0;
4
+ exports.defaultLogger = console;
5
+ //# sourceMappingURL=logging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../src/logging.ts"],"names":[],"mappings":";;;AAOa,QAAA,aAAa,GAAc,OAAO,CAAC"}
@@ -4,6 +4,7 @@ import { RestResponse } from './RestResponse';
4
4
  import { RestClientRetryStrategy } from './retry.rest';
5
5
  import { HeadersMap } from './utils';
6
6
  import { RestClientRateLimitStrategy } from './rateLimit.rest';
7
+ import { AmpLogger } from '../../logging';
7
8
  export type AmpRestClientOptions = {
8
9
  baseUrl: string;
9
10
  token: string;
@@ -11,6 +12,7 @@ export type AmpRestClientOptions = {
11
12
  retryStrategy?: RestClientRetryStrategy;
12
13
  rateLimitStrategy?: RestClientRateLimitStrategy;
13
14
  verbose?: boolean;
15
+ logger?: AmpLogger;
14
16
  client?: AxiosStatic;
15
17
  };
16
18
  export type RestClientOptions = {
@@ -20,6 +22,7 @@ export type RestClientOptions = {
20
22
  retryStrategy?: RestClientRetryStrategy;
21
23
  rateLimitStrategy?: RestClientRateLimitStrategy;
22
24
  verbose?: boolean;
25
+ logger?: AmpLogger;
23
26
  client?: AxiosStatic;
24
27
  };
25
28
  /**
@@ -40,6 +43,7 @@ export declare class DefaultRestClient {
40
43
  protected readonly retryStrategy: RestClientRetryStrategy;
41
44
  protected readonly rateLimitStrategy: RestClientRateLimitStrategy;
42
45
  protected readonly verbose: boolean;
46
+ protected readonly logger: AmpLogger;
43
47
  constructor(options?: RestClientOptions);
44
48
  call(request: RestRequest): Promise<RestResponse>;
45
49
  }
@@ -33,6 +33,7 @@ const axios_1 = __importStar(require("axios"));
33
33
  const retry_rest_1 = require("./retry.rest");
34
34
  const utils_1 = require("./utils");
35
35
  const rateLimit_rest_1 = require("./rateLimit.rest");
36
+ const logging_1 = require("../../logging");
36
37
  /**
37
38
  * DefaultRestClient is a default implementation of RestClient.
38
39
  * It defaults to useing axios to make REST calls and adds reasonble defaults
@@ -56,7 +57,8 @@ class DefaultRestClient {
56
57
  var _a;
57
58
  this.ampAxios.defaults.headers.common[key] = (_a = options.headers) === null || _a === void 0 ? void 0 : _a[key];
58
59
  });
59
- this.verbose = (_c = options.verbose) !== null && _c !== void 0 ? _c : false;
60
+ this.verbose = options.verbose || !!options.logger;
61
+ this.logger = (_c = options.logger) !== null && _c !== void 0 ? _c : logging_1.defaultLogger;
60
62
  this.ampAxios.defaults.headers.common['Accepts'] = 'application/json';
61
63
  this.ampAxios.defaults.headers.post['Content-Type'] = 'application/json';
62
64
  this.ampAxios.defaults.headers.put['Content-Type'] = 'application/json';
@@ -69,7 +71,7 @@ class DefaultRestClient {
69
71
  try {
70
72
  await this.rateLimitStrategy.reserve(req);
71
73
  if (this.verbose)
72
- console.log('Request', req);
74
+ this.logger.info('Request', req);
73
75
  const res = await this.ampAxios.request(req);
74
76
  return {
75
77
  status: res.status,
@@ -1 +1 @@
1
- {"version":3,"file":"RestClient.js","sourceRoot":"","sources":["../../../../src/services/rest/RestClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;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IAAI,GAAG,YAAY,kBAAU,EAAE;gBAC7B,MAAM,UAAU,GAAG,GAAiB,CAAC;gBACrC,OAAO;oBACL,MAAM,EAAE,MAAA,MAAA,UAAU,CAAC,QAAQ,0CAAE,MAAM,mCAAI,GAAG;oBAC1C,OAAO,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,sBAAc,EAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;oBACvE,IAAI,EAAE,IAAI;oBACV,KAAK,EAAE,GAAG;iBACX,CAAC;aACH;YACD,MAAM,GAAG,CAAC;SACX;IACH,CAAC;CACF;AArDD,8CAqDC;AAEM,MAAM,gBAAgB,GAAG,CAAC,OAA6B,EAAc,EAAE;;IAC5E,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC;QACtC,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,OAAO,CAAC,KAAK,EAAE;SACzC;QACD,iBAAiB,EAAE,IAAI,kDAAiC,CAAC,EAAE,CAAC;QAC5D,OAAO,EAAE,MAAA,OAAO,CAAC,OAAO,mCAAI,KAAK;QACjC,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAXW,QAAA,gBAAgB,oBAW3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampsec/platform-client",
3
- "version": "34.0.0",
3
+ "version": "35.1.0",
4
4
  "description": "",
5
5
  "main": "build/src/index.js",
6
6
  "runkitExampleFilename": "example/main.js",
@@ -10,4 +10,5 @@ export * from './jobExecution.status';
10
10
  export * from './notification.status';
11
11
  export * from './riskContributor.type';
12
12
  export * from './saasComponentKind';
13
- export * from './workflowStep.type';
13
+ export * from './workflowStep.kind';
14
+ export * from './notification.strategy';
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-unused-vars */
2
- export enum NotificationType {
2
+ export enum NotificationStrategy {
3
3
  LLM = 'LLM',
4
4
  RAW = 'RAW',
5
5
  TEMPLATE = 'TEMPLATE',
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-unused-vars */
2
- export enum WorkflowStepType {
2
+ export enum WorkflowStepKind {
3
3
  NOTIFICATION = 'NOTIFICATION',
4
4
  PAUSE = 'PAUSE',
5
5
  }
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-unused-vars */
2
- export enum WorkflowTriggerType {
2
+ export enum WorkflowTriggerKind {
3
3
  FINDING = 'FINDING',
4
4
  USER = 'USER',
5
5
  SAAS_COMPONENT = 'SAAS_COMPONENT',
@@ -1,10 +1,10 @@
1
1
  import {BaseDto, BaseUpsertDto} from './base.dto';
2
2
  import {NotificationStatus} from './enums';
3
- import {NotificationType} from './enums/notification.type';
3
+ import {NotificationStrategy} from './enums/notification.strategy';
4
4
  import {NotificationStepData, TrainingNotificationStepData} from './workflow.dto';
5
5
 
6
6
  export type NotificationSchema = {
7
- type: NotificationType;
7
+ strategy: NotificationStrategy;
8
8
  };
9
9
 
10
10
  export type TemplateNotificationSchema = NotificationSchema & {
@@ -1,6 +1,6 @@
1
1
  import {BaseDto} from './base.dto';
2
- import {WorkflowStepType} from './enums/workflowStep.type';
3
- import {WorkflowTriggerType} from './enums/workflowTrigger.type';
2
+ import {WorkflowStepKind} from './enums/workflowStep.kind';
3
+ import {WorkflowTriggerKind} from './enums/workflowTrigger.kind';
4
4
  import {NotificationSchema, TemplateNotificationSchema, RawNotificationSchema} from './notification.dto';
5
5
 
6
6
  export type NotificationStepData = {
@@ -28,7 +28,7 @@ export type PauseStepData = {
28
28
 
29
29
  export type WorkflowStep = {
30
30
  /** Type of the notification step, either NOTIFICATION or PAUSE */
31
- type: WorkflowStepType;
31
+ kind: WorkflowStepKind;
32
32
  /** Schema for the notification step */
33
33
  schema?: NotificationSchema | TemplateNotificationSchema | RawNotificationSchema;
34
34
  /** Data associated with the notification step */
@@ -59,7 +59,7 @@ export type WorkflowTriggerRule = {
59
59
 
60
60
  export type WorkflowTrigger = {
61
61
  /** Type of the trigger */
62
- type: WorkflowTriggerType;
62
+ kind: WorkflowTriggerKind;
63
63
  /** Rule to which the applicable entity type must conform to trigger the workflow */
64
64
  rule: unknown;
65
65
  };
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './dto';
2
2
  export * from './etag';
3
+ export * from './logging';
3
4
  export * from './services';
4
5
  export * from './FilterCriteria';
package/src/logging.ts ADDED
@@ -0,0 +1,8 @@
1
+ export interface AmpLogger {
2
+ info(_message: unknown, _meta?: unknown): void;
3
+ debug(_message: unknown, _meta?: unknown): void;
4
+ warn(_message: unknown, _meta?: unknown): void;
5
+ error(_message: unknown, _meta?: unknown): void;
6
+ }
7
+
8
+ export const defaultLogger: AmpLogger = console;
@@ -6,6 +6,7 @@ import {RestResponse} from './RestResponse';
6
6
  import {RestClientRetryStrategy, noopRestRetryStrategy} from './retry.rest';
7
7
  import {HeadersMap, convertHeaders} from './utils';
8
8
  import {RestClientRateLimitStrategy, StaticRestClientRateLimitStrategy, noopRestClientRateLimitStrategy} from './rateLimit.rest';
9
+ import {AmpLogger, defaultLogger} from '../../logging';
9
10
 
10
11
  export type AmpRestClientOptions = {
11
12
  baseUrl: string;
@@ -14,6 +15,7 @@ export type AmpRestClientOptions = {
14
15
  retryStrategy?: RestClientRetryStrategy;
15
16
  rateLimitStrategy?: RestClientRateLimitStrategy;
16
17
  verbose?: boolean;
18
+ logger?: AmpLogger;
17
19
  client?: AxiosStatic;
18
20
  };
19
21
 
@@ -24,6 +26,7 @@ export type RestClientOptions = {
24
26
  retryStrategy?: RestClientRetryStrategy;
25
27
  rateLimitStrategy?: RestClientRateLimitStrategy;
26
28
  verbose?: boolean;
29
+ logger?: AmpLogger;
27
30
  client?: AxiosStatic;
28
31
  };
29
32
 
@@ -46,6 +49,8 @@ export class DefaultRestClient {
46
49
  protected readonly retryStrategy: RestClientRetryStrategy;
47
50
  protected readonly rateLimitStrategy: RestClientRateLimitStrategy;
48
51
  protected readonly verbose: boolean;
52
+ protected readonly logger: AmpLogger;
53
+
49
54
  constructor(options: RestClientOptions = {}) {
50
55
  // TODO: rest client
51
56
  const client = options.client ?? axios;
@@ -59,7 +64,8 @@ export class DefaultRestClient {
59
64
  Object.keys(options.headers ?? {}).forEach(key => {
60
65
  this.ampAxios.defaults.headers.common[key] = options.headers?.[key];
61
66
  });
62
- this.verbose = options.verbose ?? false;
67
+ this.verbose = options.verbose || !!options.logger;
68
+ this.logger = options.logger ?? defaultLogger;
63
69
  this.ampAxios.defaults.headers.common['Accepts'] = 'application/json';
64
70
  this.ampAxios.defaults.headers.post['Content-Type'] = 'application/json';
65
71
  this.ampAxios.defaults.headers.put['Content-Type'] = 'application/json';
@@ -70,7 +76,7 @@ export class DefaultRestClient {
70
76
  const req = _.merge(request);
71
77
  try {
72
78
  await this.rateLimitStrategy.reserve(req);
73
- if (this.verbose) console.log('Request', req);
79
+ if (this.verbose) this.logger.info('Request', req);
74
80
  const res = await this.ampAxios.request(req);
75
81
  return {
76
82
  status: res.status,
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NotificationType = void 0;
4
- /* eslint-disable no-unused-vars */
5
- var NotificationType;
6
- (function (NotificationType) {
7
- NotificationType["LLM"] = "LLM";
8
- NotificationType["RAW"] = "RAW";
9
- NotificationType["TEMPLATE"] = "TEMPLATE";
10
- })(NotificationType || (exports.NotificationType = NotificationType = {}));
11
- //# sourceMappingURL=notification.type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notification.type.js","sourceRoot":"","sources":["../../../../src/dto/enums/notification.type.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,+BAAW,CAAA;IACX,+BAAW,CAAA;IACX,yCAAqB,CAAA;AACvB,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B"}
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WorkflowStepType = void 0;
4
- /* eslint-disable no-unused-vars */
5
- var WorkflowStepType;
6
- (function (WorkflowStepType) {
7
- WorkflowStepType["NOTIFICATION"] = "NOTIFICATION";
8
- WorkflowStepType["PAUSE"] = "PAUSE";
9
- })(WorkflowStepType || (exports.WorkflowStepType = WorkflowStepType = {}));
10
- //# sourceMappingURL=workflowStep.type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflowStep.type.js","sourceRoot":"","sources":["../../../../src/dto/enums/workflowStep.type.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,iDAA6B,CAAA;IAC7B,mCAAe,CAAA;AACjB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WorkflowTriggerType = void 0;
4
- /* eslint-disable no-unused-vars */
5
- var WorkflowTriggerType;
6
- (function (WorkflowTriggerType) {
7
- WorkflowTriggerType["FINDING"] = "FINDING";
8
- WorkflowTriggerType["USER"] = "USER";
9
- WorkflowTriggerType["SAAS_COMPONENT"] = "SAAS_COMPONENT";
10
- })(WorkflowTriggerType || (exports.WorkflowTriggerType = WorkflowTriggerType = {}));
11
- //# sourceMappingURL=workflowTrigger.type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflowTrigger.type.js","sourceRoot":"","sources":["../../../../src/dto/enums/workflowTrigger.type.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC7B,0CAAmB,CAAA;IACnB,oCAAa,CAAA;IACb,wDAAiC,CAAA;AACnC,CAAC,EAJW,mBAAmB,mCAAnB,mBAAmB,QAI9B"}