@ampsec/platform-client 35.1.0 → 37.0.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.
@@ -11,4 +11,4 @@ export * from './notification.status';
11
11
  export * from './riskContributor.type';
12
12
  export * from './saasComponentKind';
13
13
  export * from './workflowStep.kind';
14
- export * from './notification.strategy';
14
+ export * from './notification.kind';
@@ -27,5 +27,5 @@ __exportStar(require("./notification.status"), exports);
27
27
  __exportStar(require("./riskContributor.type"), exports);
28
28
  __exportStar(require("./saasComponentKind"), exports);
29
29
  __exportStar(require("./workflowStep.kind"), exports);
30
- __exportStar(require("./notification.strategy"), exports);
30
+ __exportStar(require("./notification.kind"), exports);
31
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;AACpC,0DAAwC"}
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,sDAAoC"}
@@ -1,4 +1,4 @@
1
- export declare enum NotificationStrategy {
1
+ export declare enum NotificationKind {
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.NotificationKind = void 0;
4
+ /* eslint-disable no-unused-vars */
5
+ var NotificationKind;
6
+ (function (NotificationKind) {
7
+ NotificationKind["LLM"] = "LLM";
8
+ NotificationKind["RAW"] = "RAW";
9
+ NotificationKind["TEMPLATE"] = "TEMPLATE";
10
+ })(NotificationKind || (exports.NotificationKind = NotificationKind = {}));
11
+ //# sourceMappingURL=notification.kind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification.kind.js","sourceRoot":"","sources":["../../../../src/dto/enums/notification.kind.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,15 +1,12 @@
1
1
  import { BaseDto, BaseUpsertDto } from './base.dto';
2
2
  import { NotificationStatus } from './enums';
3
- import { NotificationStrategy } from './enums/notification.strategy';
3
+ import { NotificationKind } from './enums/notification.kind';
4
4
  import { NotificationStepData, TrainingNotificationStepData } from './workflow.dto';
5
- export type NotificationSchema = {
6
- strategy: NotificationStrategy;
7
- };
8
- export type TemplateNotificationSchema = NotificationSchema & {
5
+ export type TemplateNotificationSchema = {
9
6
  /** ID of the template to be used for the notification */
10
7
  templateId: string;
11
8
  };
12
- export type RawNotificationSchema = NotificationSchema & {
9
+ export type RawNotificationSchema = {
13
10
  /** Optional user provided notification message */
14
11
  rawContent: string;
15
12
  };
@@ -24,6 +21,8 @@ export type NotificationAddress = {
24
21
  webhooks?: string[];
25
22
  };
26
23
  export type NotificationUpsertDto = BaseUpsertDto & {
24
+ /** Kind of the notification */
25
+ kind: NotificationKind;
27
26
  /** Workflow ID for which the notification is being created */
28
27
  wfid: string;
29
28
  /** Finding ID for which the notification is being created */
@@ -39,6 +38,6 @@ export type NotificationUpsertDto = BaseUpsertDto & {
39
38
  /** Data to be used for the notification */
40
39
  data: NotificationStepData | TrainingNotificationStepData;
41
40
  /** Schema for the notification */
42
- schema: NotificationSchema | RawNotificationSchema | TemplateNotificationSchema;
41
+ schema?: RawNotificationSchema | TemplateNotificationSchema;
43
42
  };
44
43
  export type NotificationDto = NotificationUpsertDto & BaseDto;
@@ -1,7 +1,8 @@
1
1
  import { BaseDto } from './base.dto';
2
+ import { NotificationKind } from './enums';
2
3
  import { WorkflowStepKind } from './enums/workflowStep.kind';
3
4
  import { WorkflowTriggerKind } from './enums/workflowTrigger.kind';
4
- import { NotificationSchema, TemplateNotificationSchema, RawNotificationSchema } from './notification.dto';
5
+ import { TemplateNotificationSchema, RawNotificationSchema } from './notification.dto';
5
6
  export type NotificationStepData = {
6
7
  /** Name of the device to which the notification of finding applies */
7
8
  deviceName: string | null;
@@ -25,8 +26,10 @@ export type PauseStepData = {
25
26
  export type WorkflowStep = {
26
27
  /** Type of the notification step, either NOTIFICATION or PAUSE */
27
28
  kind: WorkflowStepKind;
29
+ /** Kind of the notification */
30
+ notificationKind?: NotificationKind;
28
31
  /** Schema for the notification step */
29
- schema?: NotificationSchema | TemplateNotificationSchema | RawNotificationSchema;
32
+ schema?: TemplateNotificationSchema | RawNotificationSchema;
30
33
  /** Data associated with the notification step */
31
34
  data: NotificationStepData | TrainingNotificationStepData | PauseStepData;
32
35
  /** Step number to transition the workflow to on success */
@@ -5,3 +5,4 @@ export interface AmpLogger {
5
5
  error(_message: unknown, _meta?: unknown): void;
6
6
  }
7
7
  export declare const defaultLogger: AmpLogger;
8
+ export declare const noopLogger: AmpLogger;
@@ -1,5 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultLogger = void 0;
3
+ exports.noopLogger = exports.defaultLogger = void 0;
4
4
  exports.defaultLogger = console;
5
+ exports.noopLogger = {
6
+ info: () => { },
7
+ debug: () => { },
8
+ warn: () => { },
9
+ error: () => { },
10
+ };
5
11
  //# sourceMappingURL=logging.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../src/logging.ts"],"names":[],"mappings":";;;AAOa,QAAA,aAAa,GAAc,OAAO,CAAC"}
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../src/logging.ts"],"names":[],"mappings":";;;AAOa,QAAA,aAAa,GAAc,OAAO,CAAC;AACnC,QAAA,UAAU,GAAc;IACnC,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;IACd,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;IACf,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;IACd,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;CAChB,CAAC"}
@@ -11,7 +11,6 @@ export type AmpRestClientOptions = {
11
11
  timeout?: number;
12
12
  retryStrategy?: RestClientRetryStrategy;
13
13
  rateLimitStrategy?: RestClientRateLimitStrategy;
14
- verbose?: boolean;
15
14
  logger?: AmpLogger;
16
15
  client?: AxiosStatic;
17
16
  };
@@ -21,7 +20,6 @@ export type RestClientOptions = {
21
20
  timeout?: number;
22
21
  retryStrategy?: RestClientRetryStrategy;
23
22
  rateLimitStrategy?: RestClientRateLimitStrategy;
24
- verbose?: boolean;
25
23
  logger?: AmpLogger;
26
24
  client?: AxiosStatic;
27
25
  };
@@ -42,7 +40,6 @@ export declare class DefaultRestClient {
42
40
  protected readonly ampAxios: Axios;
43
41
  protected readonly retryStrategy: RestClientRetryStrategy;
44
42
  protected readonly rateLimitStrategy: RestClientRateLimitStrategy;
45
- protected readonly verbose: boolean;
46
43
  protected readonly logger: AmpLogger;
47
44
  constructor(options?: RestClientOptions);
48
45
  call(request: RestRequest): Promise<RestResponse>;
@@ -57,8 +57,7 @@ class DefaultRestClient {
57
57
  var _a;
58
58
  this.ampAxios.defaults.headers.common[key] = (_a = options.headers) === null || _a === void 0 ? void 0 : _a[key];
59
59
  });
60
- this.verbose = options.verbose || !!options.logger;
61
- this.logger = (_c = options.logger) !== null && _c !== void 0 ? _c : logging_1.defaultLogger;
60
+ this.logger = (_c = options.logger) !== null && _c !== void 0 ? _c : logging_1.noopLogger;
62
61
  this.ampAxios.defaults.headers.common['Accepts'] = 'application/json';
63
62
  this.ampAxios.defaults.headers.post['Content-Type'] = 'application/json';
64
63
  this.ampAxios.defaults.headers.put['Content-Type'] = 'application/json';
@@ -70,8 +69,7 @@ class DefaultRestClient {
70
69
  const req = lodash_1.default.merge(request);
71
70
  try {
72
71
  await this.rateLimitStrategy.reserve(req);
73
- if (this.verbose)
74
- this.logger.info('Request', req);
72
+ this.logger.debug({ req }); // noop logger by default
75
73
  const res = await this.ampAxios.request(req);
76
74
  return {
77
75
  status: res.status,
@@ -96,14 +94,13 @@ class DefaultRestClient {
96
94
  }
97
95
  exports.DefaultRestClient = DefaultRestClient;
98
96
  const getAmpRestClient = (options) => {
99
- var _a;
100
97
  const ampClient = new DefaultRestClient({
101
98
  baseUrl: options.baseUrl,
102
99
  headers: {
103
100
  Authorization: `Bearer ${options.token}`,
104
101
  },
105
102
  rateLimitStrategy: new rateLimit_rest_1.StaticRestClientRateLimitStrategy(50),
106
- verbose: (_a = options.verbose) !== null && _a !== void 0 ? _a : false,
103
+ logger: options.logger,
107
104
  client: options.client,
108
105
  });
109
106
  return ampClient;
@@ -1 +1 @@
1
- {"version":3,"file":"RestClient.js","sourceRoot":"","sources":["../../../../src/services/rest/RestClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAuB;AACvB,4CAAoB;AACpB,+CAA4D;AAG5D,6CAA4E;AAC5E,mCAAmD;AACnD,qDAAiI;AACjI,2CAAuD;AA+BvD;;;;;;GAMG;AACH,MAAa,iBAAiB;IAO5B,YAAY,UAA6B,EAAE;;QACzC,oBAAoB;QACpB,MAAM,MAAM,GAAG,MAAA,OAAO,CAAC,MAAM,mCAAI,eAAK,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;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oBACV,KAAK,EAAE,GAAG;iBACX,CAAC;aACH;YACD,MAAM,GAAG,CAAC;SACX;IACH,CAAC;CACF;AAnDD,8CAmDC;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,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,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": "35.1.0",
3
+ "version": "37.0.0",
4
4
  "description": "",
5
5
  "main": "build/src/index.js",
6
6
  "runkitExampleFilename": "example/main.js",
@@ -11,4 +11,4 @@ export * from './notification.status';
11
11
  export * from './riskContributor.type';
12
12
  export * from './saasComponentKind';
13
13
  export * from './workflowStep.kind';
14
- export * from './notification.strategy';
14
+ export * from './notification.kind';
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-unused-vars */
2
- export enum NotificationStrategy {
2
+ export enum NotificationKind {
3
3
  LLM = 'LLM',
4
4
  RAW = 'RAW',
5
5
  TEMPLATE = 'TEMPLATE',
@@ -1,18 +1,14 @@
1
1
  import {BaseDto, BaseUpsertDto} from './base.dto';
2
2
  import {NotificationStatus} from './enums';
3
- import {NotificationStrategy} from './enums/notification.strategy';
3
+ import {NotificationKind} from './enums/notification.kind';
4
4
  import {NotificationStepData, TrainingNotificationStepData} from './workflow.dto';
5
5
 
6
- export type NotificationSchema = {
7
- strategy: NotificationStrategy;
8
- };
9
-
10
- export type TemplateNotificationSchema = NotificationSchema & {
6
+ export type TemplateNotificationSchema = {
11
7
  /** ID of the template to be used for the notification */
12
8
  templateId: string;
13
9
  };
14
10
 
15
- export type RawNotificationSchema = NotificationSchema & {
11
+ export type RawNotificationSchema = {
16
12
  /** Optional user provided notification message */
17
13
  rawContent: string;
18
14
  };
@@ -29,6 +25,8 @@ export type NotificationAddress = {
29
25
  };
30
26
 
31
27
  export type NotificationUpsertDto = BaseUpsertDto & {
28
+ /** Kind of the notification */
29
+ kind: NotificationKind;
32
30
  /** Workflow ID for which the notification is being created */
33
31
  wfid: string;
34
32
  /** Finding ID for which the notification is being created */
@@ -44,7 +42,7 @@ export type NotificationUpsertDto = BaseUpsertDto & {
44
42
  /** Data to be used for the notification */
45
43
  data: NotificationStepData | TrainingNotificationStepData;
46
44
  /** Schema for the notification */
47
- schema: NotificationSchema | RawNotificationSchema | TemplateNotificationSchema;
45
+ schema?: RawNotificationSchema | TemplateNotificationSchema;
48
46
  };
49
47
 
50
48
  export type NotificationDto = NotificationUpsertDto & BaseDto;
@@ -1,7 +1,8 @@
1
1
  import {BaseDto} from './base.dto';
2
+ import {NotificationKind} from './enums';
2
3
  import {WorkflowStepKind} from './enums/workflowStep.kind';
3
4
  import {WorkflowTriggerKind} from './enums/workflowTrigger.kind';
4
- import {NotificationSchema, TemplateNotificationSchema, RawNotificationSchema} from './notification.dto';
5
+ import {TemplateNotificationSchema, RawNotificationSchema} from './notification.dto';
5
6
 
6
7
  export type NotificationStepData = {
7
8
  /** Name of the device to which the notification of finding applies */
@@ -29,8 +30,10 @@ export type PauseStepData = {
29
30
  export type WorkflowStep = {
30
31
  /** Type of the notification step, either NOTIFICATION or PAUSE */
31
32
  kind: WorkflowStepKind;
33
+ /** Kind of the notification */
34
+ notificationKind?: NotificationKind;
32
35
  /** Schema for the notification step */
33
- schema?: NotificationSchema | TemplateNotificationSchema | RawNotificationSchema;
36
+ schema?: TemplateNotificationSchema | RawNotificationSchema;
34
37
  /** Data associated with the notification step */
35
38
  data: NotificationStepData | TrainingNotificationStepData | PauseStepData;
36
39
  /** Step number to transition the workflow to on success */
package/src/logging.ts CHANGED
@@ -6,3 +6,9 @@ export interface AmpLogger {
6
6
  }
7
7
 
8
8
  export const defaultLogger: AmpLogger = console;
9
+ export const noopLogger: AmpLogger = {
10
+ info: () => {},
11
+ debug: () => {},
12
+ warn: () => {},
13
+ error: () => {},
14
+ };
@@ -6,7 +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
+ import {AmpLogger, noopLogger} from '../../logging';
10
10
 
11
11
  export type AmpRestClientOptions = {
12
12
  baseUrl: string;
@@ -14,7 +14,6 @@ export type AmpRestClientOptions = {
14
14
  timeout?: number;
15
15
  retryStrategy?: RestClientRetryStrategy;
16
16
  rateLimitStrategy?: RestClientRateLimitStrategy;
17
- verbose?: boolean;
18
17
  logger?: AmpLogger;
19
18
  client?: AxiosStatic;
20
19
  };
@@ -25,7 +24,6 @@ export type RestClientOptions = {
25
24
  timeout?: number;
26
25
  retryStrategy?: RestClientRetryStrategy;
27
26
  rateLimitStrategy?: RestClientRateLimitStrategy;
28
- verbose?: boolean;
29
27
  logger?: AmpLogger;
30
28
  client?: AxiosStatic;
31
29
  };
@@ -48,7 +46,6 @@ export class DefaultRestClient {
48
46
  protected readonly ampAxios: Axios;
49
47
  protected readonly retryStrategy: RestClientRetryStrategy;
50
48
  protected readonly rateLimitStrategy: RestClientRateLimitStrategy;
51
- protected readonly verbose: boolean;
52
49
  protected readonly logger: AmpLogger;
53
50
 
54
51
  constructor(options: RestClientOptions = {}) {
@@ -64,8 +61,7 @@ export class DefaultRestClient {
64
61
  Object.keys(options.headers ?? {}).forEach(key => {
65
62
  this.ampAxios.defaults.headers.common[key] = options.headers?.[key];
66
63
  });
67
- this.verbose = options.verbose || !!options.logger;
68
- this.logger = options.logger ?? defaultLogger;
64
+ this.logger = options.logger ?? noopLogger;
69
65
  this.ampAxios.defaults.headers.common['Accepts'] = 'application/json';
70
66
  this.ampAxios.defaults.headers.post['Content-Type'] = 'application/json';
71
67
  this.ampAxios.defaults.headers.put['Content-Type'] = 'application/json';
@@ -76,7 +72,7 @@ export class DefaultRestClient {
76
72
  const req = _.merge(request);
77
73
  try {
78
74
  await this.rateLimitStrategy.reserve(req);
79
- if (this.verbose) this.logger.info('Request', req);
75
+ this.logger.debug({req}); // noop logger by default
80
76
  const res = await this.ampAxios.request(req);
81
77
  return {
82
78
  status: res.status,
@@ -106,7 +102,7 @@ export const getAmpRestClient = (options: AmpRestClientOptions): RestClient => {
106
102
  Authorization: `Bearer ${options.token}`,
107
103
  },
108
104
  rateLimitStrategy: new StaticRestClientRateLimitStrategy(50),
109
- verbose: options.verbose ?? false,
105
+ logger: options.logger,
110
106
  client: options.client,
111
107
  });
112
108
  return ampClient;
@@ -1,11 +0,0 @@
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
@@ -1 +0,0 @@
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"}