@ampsec/platform-client 57.0.0 → 57.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.
@@ -0,0 +1,6 @@
1
+ export declare enum AIServiceModelName {
2
+ GPT3 = "gpt-3.5-turbo-16k",
3
+ GPT4 = "gpt-4",
4
+ TEXT_BISON = "text-bison-32k",
5
+ CODE_BISON = "code-bison-32k"
6
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AIServiceModelName = void 0;
4
+ /* eslint-disable no-unused-vars */
5
+ var AIServiceModelName;
6
+ (function (AIServiceModelName) {
7
+ AIServiceModelName["GPT3"] = "gpt-3.5-turbo-16k";
8
+ AIServiceModelName["GPT4"] = "gpt-4";
9
+ AIServiceModelName["TEXT_BISON"] = "text-bison-32k";
10
+ AIServiceModelName["CODE_BISON"] = "code-bison-32k";
11
+ })(AIServiceModelName || (exports.AIServiceModelName = AIServiceModelName = {}));
12
+ //# sourceMappingURL=aiServiceModelName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aiServiceModelName.js","sourceRoot":"","sources":["../../../../src/dto/enums/aiServiceModelName.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,gDAA0B,CAAA;IAC1B,oCAAc,CAAA;IACd,mDAA6B,CAAA;IAC7B,mDAA6B,CAAA;AAC/B,CAAC,EALW,kBAAkB,kCAAlB,kBAAkB,QAK7B"}
@@ -23,3 +23,4 @@ export * from './saasComponentKind';
23
23
  export * from './supportedMessageChannelKind.enum';
24
24
  export * from './workflowStep.kind';
25
25
  export * from './workflowTrigger.kind';
26
+ export * from './aiServiceModelName';
@@ -39,4 +39,5 @@ __exportStar(require("./saasComponentKind"), exports);
39
39
  __exportStar(require("./supportedMessageChannelKind.enum"), exports);
40
40
  __exportStar(require("./workflowStep.kind"), exports);
41
41
  __exportStar(require("./workflowTrigger.kind"), exports);
42
+ __exportStar(require("./aiServiceModelName"), exports);
42
43
  //# 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,sDAAoC;AACpC,6CAA2B;AAC3B,qDAAmC;AACnC,qDAAmC;AACnC,iDAA+B;AAC/B,yDAAuC;AACvC,0DAAwC;AACxC,gDAA8B;AAC9B,qDAAmC;AACnC,mDAAiC;AACjC,oDAAkC;AAClC,qDAAmC;AACnC,oDAAkC;AAClC,wDAAsC;AACtC,mDAAiC;AACjC,wDAAsC;AACtC,8DAA4C;AAC5C,yDAAuC;AACvC,sDAAoC;AACpC,qEAAmD;AACnD,sDAAoC;AACpC,yDAAuC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/dto/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,iDAA+B;AAC/B,wDAAsC;AACtC,sDAAoC;AACpC,6CAA2B;AAC3B,qDAAmC;AACnC,qDAAmC;AACnC,iDAA+B;AAC/B,yDAAuC;AACvC,0DAAwC;AACxC,gDAA8B;AAC9B,qDAAmC;AACnC,mDAAiC;AACjC,oDAAkC;AAClC,qDAAmC;AACnC,oDAAkC;AAClC,wDAAsC;AACtC,mDAAiC;AACjC,wDAAsC;AACtC,8DAA4C;AAC5C,yDAAuC;AACvC,sDAAoC;AACpC,qEAAmD;AACnD,sDAAoC;AACpC,yDAAuC;AACvC,uDAAqC"}
@@ -1,5 +1,5 @@
1
- import { AgentDto, AgentUpsertDto, AssetDto, FindingsInsightsDto, ProviderDto, ReportResultDto, SaasAssetDto, SaasComponentDto, SaasUserDto, TenantDto, TenantUpsertDto, UserDto } from '../dto';
2
- import { AmpEntityService, AmpDataService, AmpReportService, AmpSettingsService, ConnectorsService, FindingsService, NotificationService } from '.';
1
+ import { AgentDto, AgentUpsertDto, AssetDto, ProviderDto, ReportResultDto, SaasAssetDto, SaasComponentDto, SaasUserDto, TenantDto, TenantUpsertDto, UserDto } from '../dto';
2
+ import { AmpEntityService, AmpDataService, AmpReportService, AmpSettingsService, ConnectorsService, FindingsInsightsService, FindingsService, NotificationService, PredictionService } from '.';
3
3
  import { AmpRestClientOptions, AgentIdentityService, ConnectorInstallService, EnumService, RestClient } from './rest';
4
4
  export type AmpApiOptions = AmpRestClientOptions;
5
5
  /**
@@ -20,7 +20,7 @@ export declare class AmpApi {
20
20
  readonly connectors: ConnectorsService;
21
21
  readonly enums: EnumService;
22
22
  readonly findings: FindingsService;
23
- readonly findingsInsights: AmpDataService<FindingsInsightsDto>;
23
+ readonly findingsInsights: FindingsInsightsService;
24
24
  readonly identity: AgentIdentityService;
25
25
  readonly install: ConnectorInstallService;
26
26
  readonly notifications: NotificationService;
@@ -33,6 +33,7 @@ export declare class AmpApi {
33
33
  readonly settings: AmpSettingsService;
34
34
  readonly tenants: AmpEntityService<TenantUpsertDto, TenantDto>;
35
35
  readonly users: AmpDataService<UserDto>;
36
+ readonly prediction: PredictionService;
36
37
  constructor(rest: RestClient);
37
38
  static instance(options: AmpApiOptions): AmpApi;
38
39
  }
@@ -23,7 +23,7 @@ class AmpApi {
23
23
  this.connectors = new _1.ConnectorsService(rest);
24
24
  this.enums = new rest_1.DefaultEnumService(rest);
25
25
  this.findings = new _1.FindingsService(rest);
26
- this.findingsInsights = new _1.AmpDataServiceImpl(rest, constants_1.KIND.FINDINGS_INSIGHTS);
26
+ this.findingsInsights = new _1.FindingsInsightsService(rest, constants_1.KIND.FINDINGS_INSIGHTS);
27
27
  this.identity = new rest_1.AgentIdentityService(rest);
28
28
  this.install = new rest_1.ConnectorInstallService(rest, constants_1.TARGET_API_AGENT);
29
29
  this.notifications = new _1.NotificationService(rest);
@@ -36,6 +36,7 @@ class AmpApi {
36
36
  this.settings = new _1.AmpSettingsService(rest);
37
37
  this.tenants = new _1.AmpEntityServiceImpl(rest, constants_1.KIND.TENANTS);
38
38
  this.users = new _1.AmpDataServiceImpl(rest, constants_1.KIND.USERS);
39
+ this.prediction = new _1.PredictionService(rest, constants_1.KIND.FINDINGS);
39
40
  }
40
41
  static instance(options) {
41
42
  const rest = (0, rest_1.getAmpRestClient)(options);
@@ -1 +1 @@
1
- {"version":3,"file":"AmpApi.js","sourceRoot":"","sources":["../../../src/services/AmpApi.ts"],"names":[],"mappings":";;;AAcA,wBAWW;AACX,2CAAmD;AACnD,iCAA0J;AAI1J;;;;;;;;;;;GAWG;AACH,MAAa,MAAM;IAoBjB,YAAY,IAAgB;QAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,uBAAoB,CAA2B,IAAI,EAAE,gBAAI,CAAC,MAAM,CAAC,CAAC;QACpF,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAkB,CAAW,IAAI,EAAE,gBAAI,CAAC,MAAM,CAAC,CAAC;QACjE,IAAI,CAAC,UAAU,GAAG,IAAI,oBAAiB,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK,GAAG,IAAI,yBAAkB,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,IAAI,kBAAe,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,gBAAgB,GAAG,IAAI,qBAAkB,CAAsB,IAAI,EAAE,gBAAI,CAAC,iBAAiB,CAAC,CAAC;QAClG,IAAI,CAAC,QAAQ,GAAG,IAAI,2BAAoB,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,GAAG,IAAI,8BAAuB,CAAC,IAAI,EAAE,4BAAgB,CAAC,CAAC;QACnE,IAAI,CAAC,aAAa,GAAG,IAAI,sBAAmB,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAkB,CAAc,IAAI,EAAE,gBAAI,CAAC,SAAS,CAAC,CAA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I,uBAAoB,CAA6B,IAAI,EAAE,gBAAI,CAAC,OAAO,CAAC,CAAC;QACxF,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAkB,CAAU,IAAI,EAAE,gBAAI,CAAC,KAAK,CAAC,CAAC;QAC/D,IAAI,CAAC,UAAU,GAAG,IAAI,oBAAiB,CAAC,IAAI,EAAE,gBAAI,CAAC,QAAQ,CAAC,CAAC;IAC/D,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,OAAsB;QACpC,MAAM,IAAI,GAAG,IAAA,uBAAgB,EAAC,OAAO,CAAC,CAAC;QACvC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AA/CD,wBA+CC"}
@@ -7,7 +7,7 @@ import { EnumService } from './rest/EnumService';
7
7
  import { AmpSdkSettingsService } from './settings.service';
8
8
  import { AmpSaaSEntityService, AmpSdkSaasAssetService, AmpSdkSaasComponentService, AmpSdkSaasUserService } from './saasEntity.service';
9
9
  import { ContentfulService } from './contentful.service';
10
- import { PlatformFindingsInsightsDto, PlatformFindingsInsightsUpsertDto } from '../dto/platform/platform.findingsInsights.dto';
10
+ import { FindingsInsightsService } from './findingsInsights.service';
11
11
  export type AmpSdkOptions = AmpRestClientOptions;
12
12
  /**
13
13
  * AMP API
@@ -25,7 +25,7 @@ export declare class AmpSdkServices {
25
25
  readonly contentful: ContentfulService;
26
26
  readonly enums: EnumService;
27
27
  readonly findings: AmpSaaSEntityService<PlatformFindingUpsertDto, PlatformFindingDto>;
28
- readonly findingsInsights: AmpSaaSEntityService<PlatformFindingsInsightsUpsertDto, PlatformFindingsInsightsDto>;
28
+ readonly findingsInsights: FindingsInsightsService;
29
29
  readonly jobExecutions: AmpEntityService<PlatformJobExecutionStateUpsertDto, PlatformJobExecutionStateDto>;
30
30
  readonly jobs: AmpEntityService<PlatformJobSpecUpsertDto, PlatformJobSpecDto>;
31
31
  readonly notifications: AmpEntityService<PlatformNotificationUpsertDto, PlatformNotificationDto>;
@@ -8,6 +8,7 @@ const EnumService_1 = require("./rest/EnumService");
8
8
  const settings_service_1 = require("./settings.service");
9
9
  const saasEntity_service_1 = require("./saasEntity.service");
10
10
  const contentful_service_1 = require("./contentful.service");
11
+ const findingsInsights_service_1 = require("./findingsInsights.service");
11
12
  /**
12
13
  * AMP API
13
14
  * This client is a wrapper around the AMP REST API meant to be used by
@@ -25,7 +26,7 @@ class AmpSdkServices {
25
26
  this.contentful = new contentful_service_1.ContentfulService();
26
27
  this.enums = new EnumService_1.DefaultEnumService(rest, constants_1.TARGET_API_PLATFORM);
27
28
  this.findings = new saasEntity_service_1.AmpSaaSEntityServiceImpl(rest, constants_1.KIND.FINDINGS, constants_1.TARGET_API_PLATFORM);
28
- this.findingsInsights = new saasEntity_service_1.AmpSaaSEntityServiceImpl(rest, constants_1.KIND.FINDINGS_INSIGHTS, constants_1.TARGET_API_PLATFORM);
29
+ this.findingsInsights = new findingsInsights_service_1.FindingsInsightsService(rest, constants_1.KIND.FINDINGS_INSIGHTS, constants_1.TARGET_API_PLATFORM);
29
30
  this.jobExecutions = new entity_service_1.AmpEntityServiceImpl(rest, constants_1.KIND.JOB_EXECUTIONS, constants_1.TARGET_API_PLATFORM);
30
31
  this.jobs = new entity_service_1.AmpEntityServiceImpl(rest, constants_1.KIND.JOB_SPEC, constants_1.TARGET_API_PLATFORM);
31
32
  this.notifications = new entity_service_1.AmpEntityServiceImpl(rest, constants_1.KIND.NOTIFICATIONS, constants_1.TARGET_API_PLATFORM);
@@ -1 +1 @@
1
- {"version":3,"file":"AmpSdk.js","sourceRoot":"","sources":["../../../src/services/AmpSdk.ts"],"names":[],"mappings":";;;AAoBA,qDAAoI;AACpI,iCAA0E;AAC1E,2CAAsD;AAGtD,oDAAmE;AACnE,yDAAyD;AACzD,6DAA+J;AAC/J,6DAAuD;AAKvD;;;;;;;;GAQG;AACH,MAAa,cAAc;IAsBzB,YAAY,IAAgB;QAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,qCAAo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E,+BAAmB,CAAC,CAAC;QACtK,IAAI,CAAC,UAAU,GAAG,IAAI,2CAAsB,CAAC,IAAI,EAAE,+BAAmB,CAAC,CAAC;QACxE,IAAI,CAAC,cAAc,GAAG,IAAI,+CAA0B,CAAC,IAAI,EAAE,+BAAmB,CAAC,CAAC;QAChF,IAAI,CAAC,SAAS,GAAG,IAAI,0CAAqB,CAAC,IAAI,EAAE,+BAAmB,CAAC,CAAC;QACtE,IAAI,CAAC,QAAQ,GAAG,IAAI,wCAAqB,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,OAAO,GAAG,IAAI,qCAAoB,CAA6B,IAAI,EAAE,gBAAI,CAAC,OAAO,EAAE,+BAAmB,CAAC,CAAC;QAC7G,IAAI,CAAC,KAAK,GAAG,IAAI,kCAAiB,CAAC,IAAI,EAAE,+BAAmB,CAAC,CAAC;QAC9D,IAAI,CAAC,iBAAiB,GAAG,IAAI,qCAAoB,CAAiE,IAAI,EAAE,gBAAI,CAAC,iBAAiB,EAAE,+BAAmB,CAAC,CAAC;IACvK,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,OAAsB;QACpC,MAAM,IAAI,GAAG,IAAA,uBAAgB,EAAC,OAAO,CAAC,CAAC;QACvC,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AAjDD,wCAiDC"}
@@ -0,0 +1,25 @@
1
+ import { RestClient, RestRequest } from './rest';
2
+ import { ErrorHandler, TargetApi } from './constants';
3
+ import { z } from 'zod';
4
+ import { FilterCriteria } from '../FilterCriteria';
5
+ export declare const AmpFindingsFilterCriteriaSchema: any;
6
+ export type AmpFindingsFilterCriteria = z.infer<typeof AmpFindingsFilterCriteriaSchema>;
7
+ export declare class FindingsInsightsService {
8
+ protected call: <T>(req: RestRequest, errorHandler: ErrorHandler<T>) => Promise<T>;
9
+ protected getPage: (req: RestRequest) => Promise<{
10
+ data: never[];
11
+ kind: string;
12
+ error: string;
13
+ hints: {};
14
+ }>;
15
+ protected readonly rest: RestClient;
16
+ protected readonly kind: string;
17
+ protected readonly targetApi: string;
18
+ constructor(rest: RestClient, kind: string, targetApi?: TargetApi);
19
+ create: (filterCriteria: AmpFindingsFilterCriteria, queryParamsFilter?: FilterCriteria) => Promise<{
20
+ data: never[];
21
+ kind: string;
22
+ error: string;
23
+ hints: {};
24
+ }>;
25
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindingsInsightsService = exports.AmpFindingsFilterCriteriaSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.AmpFindingsFilterCriteriaSchema = zod_1.z.lazy(() => zod_1.z.union([
6
+ zod_1.z.record(zod_1.z.string()).refine(obj => Object.keys(obj).every(key => typeof key === 'string')),
7
+ zod_1.z.object({
8
+ $and: zod_1.z.array(exports.AmpFindingsFilterCriteriaSchema),
9
+ }),
10
+ zod_1.z.object({
11
+ $or: zod_1.z.array(exports.AmpFindingsFilterCriteriaSchema),
12
+ }),
13
+ ]));
14
+ class FindingsInsightsService {
15
+ constructor(rest, kind, targetApi = 'api') {
16
+ this.call = async (req, errorHandler) => {
17
+ try {
18
+ const res = await this.rest.call(req);
19
+ return res.data;
20
+ }
21
+ catch (error) {
22
+ if (error instanceof Error) {
23
+ console.error(error.message);
24
+ }
25
+ if (this.rest.strict) {
26
+ throw error;
27
+ }
28
+ return errorHandler(error);
29
+ }
30
+ };
31
+ this.getPage = async (req) => {
32
+ return this.call(req, (error) => {
33
+ const message = error instanceof Error ? error.message : 'Unknown error';
34
+ return {
35
+ data: [],
36
+ kind: this.kind.toUpperCase(),
37
+ error: message,
38
+ hints: {},
39
+ };
40
+ });
41
+ };
42
+ this.create = (filterCriteria, queryParamsFilter) => {
43
+ const filterOptions = exports.AmpFindingsFilterCriteriaSchema.parse(filterCriteria);
44
+ return this.getPage({
45
+ url: `/${this.targetApi}/v1/insights/findings`,
46
+ method: 'POST',
47
+ data: filterOptions,
48
+ params: queryParamsFilter,
49
+ });
50
+ };
51
+ this.rest = rest;
52
+ this.kind = kind;
53
+ this.targetApi = targetApi;
54
+ }
55
+ }
56
+ exports.FindingsInsightsService = FindingsInsightsService;
57
+ //# sourceMappingURL=findingsInsights.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findingsInsights.service.js","sourceRoot":"","sources":["../../../src/services/findingsInsights.service.ts"],"names":[],"mappings":";;;AAEA,6BAAsB;AAGT,QAAA,+BAA+B,GAAQ,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAC9D,OAAC,CAAC,KAAK,CAAC;IACN,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC;IAC1F,OAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,uCAA+B,CAAC;KAC/C,CAAC;IACF,OAAC,CAAC,MAAM,CAAC;QACP,GAAG,EAAE,OAAC,CAAC,KAAK,CAAC,uCAA+B,CAAC;KAC9C,CAAC;CACH,CAAC,CACH,CAAC;AAGF,MAAa,uBAAuB;IAgClC,YAAY,IAAgB,EAAE,IAAY,EAAE,YAAuB,KAAK;QA/B9D,SAAI,GAAG,KAAK,EAAK,GAAgB,EAAE,YAA6B,EAAc,EAAE;YACxF,IAAI;gBACF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACtC,OAAO,GAAG,CAAC,IAAS,CAAC;aACtB;YAAC,OAAO,KAAc,EAAE;gBACvB,IAAI,KAAK,YAAY,KAAK,EAAE;oBAC1B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;iBAC9B;gBACD,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;oBACpB,MAAM,KAAK,CAAC;iBACb;gBACD,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;aAC5B;QACH,CAAC,CAAC;QAEQ,YAAO,GAAG,KAAK,EAAE,GAAgB,EAAE,EAAE;YAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAc,EAAE,EAAE;gBACvC,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;gBACzE,OAAO;oBACL,IAAI,EAAE,EAAE;oBACR,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;oBAC7B,KAAK,EAAE,OAAO;oBACd,KAAK,EAAE,EAAE;iBACV,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAYF,WAAM,GAAG,CAAC,cAAyC,EAAE,iBAAkC,EAAE,EAAE;YACzF,MAAM,aAAa,GAAG,uCAA+B,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAC5E,OAAO,IAAI,CAAC,OAAO,CAAC;gBAClB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,uBAAuB;gBAC9C,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,aAAa;gBACnB,MAAM,EAAE,iBAAiB;aAC1B,CAAC,CAAC;QACL,CAAC,CAAC;QAbA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CAWF;AA/CD,0DA+CC"}
@@ -4,6 +4,7 @@ export * from './AmpSdk';
4
4
  export * from './constants';
5
5
  export * from './data.service';
6
6
  export * from './entity.service';
7
+ export * from './findingsInsights.service';
7
8
  export * from './findings.service';
8
9
  export * from './lookup.service';
9
10
  export * from './rest';
@@ -14,3 +15,4 @@ export * from './connectors.service';
14
15
  export * from './notification.service';
15
16
  export * from './reports.service';
16
17
  export * from './contentful.service';
18
+ export * from './prediction.service';
@@ -20,6 +20,7 @@ __exportStar(require("./AmpSdk"), exports);
20
20
  __exportStar(require("./constants"), exports);
21
21
  __exportStar(require("./data.service"), exports);
22
22
  __exportStar(require("./entity.service"), exports);
23
+ __exportStar(require("./findingsInsights.service"), exports);
23
24
  __exportStar(require("./findings.service"), exports);
24
25
  __exportStar(require("./lookup.service"), exports);
25
26
  __exportStar(require("./rest"), exports);
@@ -30,4 +31,5 @@ __exportStar(require("./connectors.service"), exports);
30
31
  __exportStar(require("./notification.service"), exports);
31
32
  __exportStar(require("./reports.service"), exports);
32
33
  __exportStar(require("./contentful.service"), exports);
34
+ __exportStar(require("./prediction.service"), exports);
33
35
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,iDAA+B;AAC/B,mDAAiC;AACjC,qDAAmC;AACnC,mDAAiC;AACjC,yCAAuB;AACvB,uDAAqC;AACrC,qDAAmC;AACnC,0CAAwB;AACxB,uDAAqC;AACrC,yDAAuC;AACvC,oDAAkC;AAClC,uDAAqC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,iDAA+B;AAC/B,mDAAiC;AACjC,6DAA2C;AAC3C,qDAAmC;AACnC,mDAAiC;AACjC,yCAAuB;AACvB,uDAAqC;AACrC,qDAAmC;AACnC,0CAAwB;AACxB,uDAAqC;AACrC,yDAAuC;AACvC,oDAAkC;AAClC,uDAAqC;AACrC,uDAAqC"}
@@ -0,0 +1,35 @@
1
+ import { RestClient, RestRequest } from './rest';
2
+ import { ErrorHandler, TargetApi } from './constants';
3
+ import { AIServiceModelName } from '../dto/enums/aiServiceModelName';
4
+ import { z } from 'zod';
5
+ declare const PREDICTION_SCHEMA: z.ZodObject<{
6
+ question: z.ZodArray<z.ZodString, "many">;
7
+ model: z.ZodOptional<z.ZodNativeEnum<typeof AIServiceModelName>>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ question: string[];
10
+ model?: AIServiceModelName | undefined;
11
+ }, {
12
+ question: string[];
13
+ model?: AIServiceModelName | undefined;
14
+ }>;
15
+ export type PREDICTION = z.infer<typeof PREDICTION_SCHEMA>;
16
+ export declare class PredictionService {
17
+ protected call: <T>(req: RestRequest, errorHandler: ErrorHandler<T>) => Promise<T>;
18
+ protected getPage: (req: RestRequest) => Promise<{
19
+ data: never[];
20
+ kind: string;
21
+ error: string;
22
+ hints: {};
23
+ }>;
24
+ protected readonly rest: RestClient;
25
+ protected readonly kind: string;
26
+ protected readonly targetApi: string;
27
+ constructor(rest: RestClient, kind: string, targetApi?: TargetApi);
28
+ create: ({ model, question }: PREDICTION) => Promise<{
29
+ data: never[];
30
+ kind: string;
31
+ error: string;
32
+ hints: {};
33
+ }>;
34
+ }
35
+ export {};
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PredictionService = void 0;
4
+ const aiServiceModelName_1 = require("../dto/enums/aiServiceModelName");
5
+ const zod_1 = require("zod");
6
+ const PREDICTION_SCHEMA = zod_1.z.object({
7
+ question: zod_1.z.array(zod_1.z.string()),
8
+ model: zod_1.z.nativeEnum(aiServiceModelName_1.AIServiceModelName).optional(),
9
+ });
10
+ class PredictionService {
11
+ constructor(rest, kind, targetApi = 'api') {
12
+ this.call = async (req, errorHandler) => {
13
+ try {
14
+ const res = await this.rest.call(req);
15
+ return res.data;
16
+ }
17
+ catch (error) {
18
+ if (error instanceof Error) {
19
+ console.error(error.message);
20
+ }
21
+ if (this.rest.strict) {
22
+ throw error;
23
+ }
24
+ return errorHandler(error);
25
+ }
26
+ };
27
+ this.getPage = async (req) => {
28
+ return this.call(req, (error) => {
29
+ const message = error instanceof Error ? error.message : 'Unknown error';
30
+ return {
31
+ data: [],
32
+ kind: this.kind.toUpperCase(),
33
+ error: message,
34
+ hints: {},
35
+ };
36
+ });
37
+ };
38
+ this.create = ({ model, question }) => {
39
+ return this.getPage({
40
+ url: `/${this.targetApi}/v1/ask/${this.kind}`,
41
+ method: 'POST',
42
+ data: { model, question },
43
+ });
44
+ };
45
+ this.rest = rest;
46
+ this.kind = kind;
47
+ this.targetApi = targetApi;
48
+ }
49
+ }
50
+ exports.PredictionService = PredictionService;
51
+ //# sourceMappingURL=prediction.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prediction.service.js","sourceRoot":"","sources":["../../../src/services/prediction.service.ts"],"names":[],"mappings":";;;AAEA,wEAAmE;AACnE,6BAAsB;AAEtB,MAAM,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;IAC7B,KAAK,EAAE,OAAC,CAAC,UAAU,CAAC,uCAAkB,CAAC,CAAC,QAAQ,EAAE;CACnD,CAAC,CAAC;AAIH,MAAa,iBAAiB;IAgC5B,YAAY,IAAgB,EAAE,IAAY,EAAE,YAAuB,KAAK;QA/B9D,SAAI,GAAG,KAAK,EAAK,GAAgB,EAAE,YAA6B,EAAc,EAAE;YACxF,IAAI;gBACF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACtC,OAAO,GAAG,CAAC,IAAS,CAAC;aACtB;YAAC,OAAO,KAAc,EAAE;gBACvB,IAAI,KAAK,YAAY,KAAK,EAAE;oBAC1B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;iBAC9B;gBACD,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;oBACpB,MAAM,KAAK,CAAC;iBACb;gBACD,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;aAC5B;QACH,CAAC,CAAC;QAEQ,YAAO,GAAG,KAAK,EAAE,GAAgB,EAAE,EAAE;YAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAc,EAAE,EAAE;gBACvC,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;gBACzE,OAAO;oBACL,IAAI,EAAE,EAAE;oBACR,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;oBAC7B,KAAK,EAAE,OAAO;oBACd,KAAK,EAAE,EAAE;iBACV,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAYF,WAAM,GAAG,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAa,EAAE,EAAE;YACzC,OAAO,IAAI,CAAC,OAAO,CAAC;gBAClB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,WAAW,IAAI,CAAC,IAAI,EAAE;gBAC7C,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,EAAC,KAAK,EAAE,QAAQ,EAAC;aACxB,CAAC,CAAC;QACL,CAAC,CAAC;QAXA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CASF;AA7CD,8CA6CC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampsec/platform-client",
3
- "version": "57.0.0",
3
+ "version": "57.1.0",
4
4
  "description": "",
5
5
  "main": "build/src/index.js",
6
6
  "runkitExampleFilename": "example/main.js",
@@ -28,7 +28,8 @@
28
28
  "immutable": "^5.0.0-beta.4",
29
29
  "lodash": "^4.17.21",
30
30
  "lodash.omit": "^4.5.0",
31
- "qs": "^6.11.2"
31
+ "qs": "^6.11.2",
32
+ "zod": "^3.22.4"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@jest/types": "^29.5.0",
@@ -0,0 +1,7 @@
1
+ /* eslint-disable no-unused-vars */
2
+ export enum AIServiceModelName {
3
+ GPT3 = 'gpt-3.5-turbo-16k',
4
+ GPT4 = 'gpt-4',
5
+ TEXT_BISON = 'text-bison-32k',
6
+ CODE_BISON = 'code-bison-32k',
7
+ }
@@ -23,3 +23,4 @@ export * from './saasComponentKind';
23
23
  export * from './supportedMessageChannelKind.enum';
24
24
  export * from './workflowStep.kind';
25
25
  export * from './workflowTrigger.kind';
26
+ export * from './aiServiceModelName';
@@ -1,17 +1,4 @@
1
- import {
2
- AgentDto,
3
- AgentUpsertDto,
4
- AssetDto,
5
- FindingsInsightsDto,
6
- ProviderDto,
7
- ReportResultDto,
8
- SaasAssetDto,
9
- SaasComponentDto,
10
- SaasUserDto,
11
- TenantDto,
12
- TenantUpsertDto,
13
- UserDto,
14
- } from '../dto';
1
+ import {AgentDto, AgentUpsertDto, AssetDto, ProviderDto, ReportResultDto, SaasAssetDto, SaasComponentDto, SaasUserDto, TenantDto, TenantUpsertDto, UserDto} from '../dto';
15
2
  import {
16
3
  AmpEntityService,
17
4
  AmpEntityServiceImpl,
@@ -21,8 +8,10 @@ import {
21
8
  AmpReportServiceImpl,
22
9
  AmpSettingsService,
23
10
  ConnectorsService,
11
+ FindingsInsightsService,
24
12
  FindingsService,
25
13
  NotificationService,
14
+ PredictionService,
26
15
  } from '.';
27
16
  import {KIND, TARGET_API_AGENT} from './constants';
28
17
  import {getAmpRestClient, AmpRestClientOptions, AgentIdentityService, ConnectorInstallService, DefaultEnumService, EnumService, RestClient} from './rest';
@@ -47,7 +36,7 @@ export class AmpApi {
47
36
  readonly connectors: ConnectorsService;
48
37
  readonly enums: EnumService;
49
38
  readonly findings: FindingsService;
50
- readonly findingsInsights: AmpDataService<FindingsInsightsDto>;
39
+ readonly findingsInsights: FindingsInsightsService;
51
40
  readonly identity: AgentIdentityService;
52
41
  readonly install: ConnectorInstallService;
53
42
  readonly notifications: NotificationService;
@@ -60,6 +49,7 @@ export class AmpApi {
60
49
  readonly settings: AmpSettingsService;
61
50
  readonly tenants: AmpEntityService<TenantUpsertDto, TenantDto>;
62
51
  readonly users: AmpDataService<UserDto>;
52
+ readonly prediction: PredictionService;
63
53
 
64
54
  constructor(rest: RestClient) {
65
55
  this.agents = new AmpEntityServiceImpl<AgentUpsertDto, AgentDto>(rest, KIND.AGENTS);
@@ -67,7 +57,7 @@ export class AmpApi {
67
57
  this.connectors = new ConnectorsService(rest);
68
58
  this.enums = new DefaultEnumService(rest);
69
59
  this.findings = new FindingsService(rest);
70
- this.findingsInsights = new AmpDataServiceImpl<FindingsInsightsDto>(rest, KIND.FINDINGS_INSIGHTS);
60
+ this.findingsInsights = new FindingsInsightsService(rest, KIND.FINDINGS_INSIGHTS);
71
61
  this.identity = new AgentIdentityService(rest);
72
62
  this.install = new ConnectorInstallService(rest, TARGET_API_AGENT);
73
63
  this.notifications = new NotificationService(rest);
@@ -80,6 +70,7 @@ export class AmpApi {
80
70
  this.settings = new AmpSettingsService(rest);
81
71
  this.tenants = new AmpEntityServiceImpl<TenantUpsertDto, TenantDto>(rest, KIND.TENANTS);
82
72
  this.users = new AmpDataServiceImpl<UserDto>(rest, KIND.USERS);
73
+ this.prediction = new PredictionService(rest, KIND.FINDINGS);
83
74
  }
84
75
 
85
76
  static instance(options: AmpApiOptions): AmpApi {
@@ -27,7 +27,7 @@ import {DefaultEnumService, EnumService} from './rest/EnumService';
27
27
  import {AmpSdkSettingsService} from './settings.service';
28
28
  import {AmpSaaSEntityService, AmpSaaSEntityServiceImpl, AmpSdkSaasAssetService, AmpSdkSaasComponentService, AmpSdkSaasUserService} from './saasEntity.service';
29
29
  import {ContentfulService} from './contentful.service';
30
- import {PlatformFindingsInsightsDto, PlatformFindingsInsightsUpsertDto} from '../dto/platform/platform.findingsInsights.dto';
30
+ import {FindingsInsightsService} from './findingsInsights.service';
31
31
 
32
32
  export type AmpSdkOptions = AmpRestClientOptions;
33
33
 
@@ -47,7 +47,7 @@ export class AmpSdkServices {
47
47
  readonly contentful: ContentfulService;
48
48
  readonly enums: EnumService;
49
49
  readonly findings: AmpSaaSEntityService<PlatformFindingUpsertDto, PlatformFindingDto>;
50
- readonly findingsInsights: AmpSaaSEntityService<PlatformFindingsInsightsUpsertDto, PlatformFindingsInsightsDto>;
50
+ readonly findingsInsights: FindingsInsightsService;
51
51
  readonly jobExecutions: AmpEntityService<PlatformJobExecutionStateUpsertDto, PlatformJobExecutionStateDto>;
52
52
  readonly jobs: AmpEntityService<PlatformJobSpecUpsertDto, PlatformJobSpecDto>;
53
53
  readonly notifications: AmpEntityService<PlatformNotificationUpsertDto, PlatformNotificationDto>;
@@ -69,7 +69,7 @@ export class AmpSdkServices {
69
69
  this.contentful = new ContentfulService();
70
70
  this.enums = new DefaultEnumService(rest, TARGET_API_PLATFORM);
71
71
  this.findings = new AmpSaaSEntityServiceImpl<PlatformFindingUpsertDto, PlatformFindingDto>(rest, KIND.FINDINGS, TARGET_API_PLATFORM);
72
- this.findingsInsights = new AmpSaaSEntityServiceImpl<PlatformFindingsInsightsUpsertDto, PlatformFindingsInsightsDto>(rest, KIND.FINDINGS_INSIGHTS, TARGET_API_PLATFORM);
72
+ this.findingsInsights = new FindingsInsightsService(rest, KIND.FINDINGS_INSIGHTS, TARGET_API_PLATFORM);
73
73
  this.jobExecutions = new AmpEntityServiceImpl<PlatformJobExecutionStateUpsertDto, PlatformJobExecutionStateDto>(rest, KIND.JOB_EXECUTIONS, TARGET_API_PLATFORM);
74
74
  this.jobs = new AmpEntityServiceImpl<PlatformJobSpecUpsertDto, PlatformJobSpecDto>(rest, KIND.JOB_SPEC, TARGET_API_PLATFORM);
75
75
  this.notifications = new AmpEntityServiceImpl<PlatformNotificationUpsertDto, PlatformNotificationDto>(rest, KIND.NOTIFICATIONS, TARGET_API_PLATFORM);
@@ -0,0 +1,66 @@
1
+ import {RestClient, RestRequest} from './rest';
2
+ import {ErrorHandler, TargetApi} from './constants';
3
+ import {z} from 'zod';
4
+ import {FilterCriteria} from '../FilterCriteria';
5
+
6
+ export const AmpFindingsFilterCriteriaSchema: any = z.lazy(() =>
7
+ z.union([
8
+ z.record(z.string()).refine(obj => Object.keys(obj).every(key => typeof key === 'string')),
9
+ z.object({
10
+ $and: z.array(AmpFindingsFilterCriteriaSchema),
11
+ }),
12
+ z.object({
13
+ $or: z.array(AmpFindingsFilterCriteriaSchema),
14
+ }),
15
+ ])
16
+ );
17
+
18
+ export type AmpFindingsFilterCriteria = z.infer<typeof AmpFindingsFilterCriteriaSchema>;
19
+ export class FindingsInsightsService {
20
+ protected call = async <T>(req: RestRequest, errorHandler: ErrorHandler<T>): Promise<T> => {
21
+ try {
22
+ const res = await this.rest.call(req);
23
+ return res.data as T;
24
+ } catch (error: unknown) {
25
+ if (error instanceof Error) {
26
+ console.error(error.message);
27
+ }
28
+ if (this.rest.strict) {
29
+ throw error;
30
+ }
31
+ return errorHandler(error);
32
+ }
33
+ };
34
+
35
+ protected getPage = async (req: RestRequest) => {
36
+ return this.call(req, (error: unknown) => {
37
+ const message = error instanceof Error ? error.message : 'Unknown error';
38
+ return {
39
+ data: [],
40
+ kind: this.kind.toUpperCase(),
41
+ error: message,
42
+ hints: {},
43
+ };
44
+ });
45
+ };
46
+
47
+ protected readonly rest: RestClient;
48
+ protected readonly kind: string;
49
+ protected readonly targetApi: string;
50
+
51
+ constructor(rest: RestClient, kind: string, targetApi: TargetApi = 'api') {
52
+ this.rest = rest;
53
+ this.kind = kind;
54
+ this.targetApi = targetApi;
55
+ }
56
+
57
+ create = (filterCriteria: AmpFindingsFilterCriteria, queryParamsFilter?: FilterCriteria) => {
58
+ const filterOptions = AmpFindingsFilterCriteriaSchema.parse(filterCriteria);
59
+ return this.getPage({
60
+ url: `/${this.targetApi}/v1/insights/findings`,
61
+ method: 'POST',
62
+ data: filterOptions,
63
+ params: queryParamsFilter,
64
+ });
65
+ };
66
+ }
@@ -4,6 +4,7 @@ export * from './AmpSdk';
4
4
  export * from './constants';
5
5
  export * from './data.service';
6
6
  export * from './entity.service';
7
+ export * from './findingsInsights.service';
7
8
  export * from './findings.service';
8
9
  export * from './lookup.service';
9
10
  export * from './rest';
@@ -14,3 +15,4 @@ export * from './connectors.service';
14
15
  export * from './notification.service';
15
16
  export * from './reports.service';
16
17
  export * from './contentful.service';
18
+ export * from './prediction.service';
@@ -0,0 +1,58 @@
1
+ import {RestClient, RestRequest} from './rest';
2
+ import {ErrorHandler, TargetApi} from './constants';
3
+ import {AIServiceModelName} from '../dto/enums/aiServiceModelName';
4
+ import {z} from 'zod';
5
+
6
+ const PREDICTION_SCHEMA = z.object({
7
+ question: z.array(z.string()),
8
+ model: z.nativeEnum(AIServiceModelName).optional(),
9
+ });
10
+
11
+ export type PREDICTION = z.infer<typeof PREDICTION_SCHEMA>;
12
+
13
+ export class PredictionService {
14
+ protected call = async <T>(req: RestRequest, errorHandler: ErrorHandler<T>): Promise<T> => {
15
+ try {
16
+ const res = await this.rest.call(req);
17
+ return res.data as T;
18
+ } catch (error: unknown) {
19
+ if (error instanceof Error) {
20
+ console.error(error.message);
21
+ }
22
+ if (this.rest.strict) {
23
+ throw error;
24
+ }
25
+ return errorHandler(error);
26
+ }
27
+ };
28
+
29
+ protected getPage = async (req: RestRequest) => {
30
+ return this.call(req, (error: unknown) => {
31
+ const message = error instanceof Error ? error.message : 'Unknown error';
32
+ return {
33
+ data: [],
34
+ kind: this.kind.toUpperCase(),
35
+ error: message,
36
+ hints: {},
37
+ };
38
+ });
39
+ };
40
+
41
+ protected readonly rest: RestClient;
42
+ protected readonly kind: string;
43
+ protected readonly targetApi: string;
44
+
45
+ constructor(rest: RestClient, kind: string, targetApi: TargetApi = 'api') {
46
+ this.rest = rest;
47
+ this.kind = kind;
48
+ this.targetApi = targetApi;
49
+ }
50
+
51
+ create = ({model, question}: PREDICTION) => {
52
+ return this.getPage({
53
+ url: `/${this.targetApi}/v1/ask/${this.kind}`,
54
+ method: 'POST',
55
+ data: {model, question},
56
+ });
57
+ };
58
+ }