@ampsec/platform-client 66.2.1 → 67.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.
- package/build/src/dto/agents.dto.d.ts +76 -53
- package/build/src/dto/agents.dto.js +15 -10
- package/build/src/dto/agents.dto.js.map +1 -1
- package/build/src/dto/enums/auth.role.d.ts +19 -0
- package/build/src/dto/enums/auth.role.js +20 -1
- package/build/src/dto/enums/auth.role.js.map +1 -1
- package/build/src/dto/findings.dto.js +1 -6
- package/build/src/dto/findings.dto.js.map +1 -1
- package/build/src/dto/flows.dto.d.ts +284 -188
- package/build/src/dto/flows.dto.js +6 -2
- package/build/src/dto/flows.dto.js.map +1 -1
- package/build/src/dto/platform/platform.agents.dto.d.ts +148 -4
- package/build/src/dto/platform/platform.agents.dto.js +21 -0
- package/build/src/dto/platform/platform.agents.dto.js.map +1 -1
- package/build/src/dto/platform/platform.flows.dto.d.ts +164 -112
- package/build/src/etag.js +1 -1
- package/build/src/etag.js.map +1 -1
- package/build/src/services/AgentsService.d.ts +18 -41
- package/build/src/services/AgentsService.js +39 -6
- package/build/src/services/AgentsService.js.map +1 -1
- package/build/src/services/AmpSdk.d.ts +3 -2
- package/build/src/services/AmpSdk.js +2 -1
- package/build/src/services/AmpSdk.js.map +1 -1
- package/package.json +1 -1
- package/src/dto/agents.dto.ts +22 -34
- package/src/dto/enums/auth.role.ts +29 -1
- package/src/dto/findings.dto.ts +2 -7
- package/src/dto/flows.dto.ts +7 -2
- package/src/dto/platform/platform.agents.dto.ts +24 -4
- package/src/etag.ts +1 -1
- package/src/services/AgentsService.ts +43 -10
- package/src/services/AmpSdk.ts +3 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlatformActionExecutionDto, PlatformActionExecutionUpsertDto,
|
|
1
|
+
import { PlatformActionExecutionDto, PlatformActionExecutionUpsertDto, PlatformCustomActionDto, PlatformCustomActionUpsertDto, PlatformCustomScoreCohortDto, PlatformCustomScoreCohortUpsertDto, PlatformCustomScoreValueDto, PlatformCustomScoreValueUpsertDto, PlatformFindingDto, PlatformFindingSpecDto, PlatformFindingSpecUpsertDto, PlatformFindingUpsertDto, PlatformFlowSpecDto, PlatformFlowSpecUpsertDto, PlatformFlowStateDto, PlatformFlowStateUpsertDto, PlatformJobExecutionStateDto, PlatformJobExecutionStateUpsertDto, PlatformJobSpecDto, PlatformJobSpecUpsertDto, PlatformNotificationDto, PlatformNotificationUpsertDto, PlatformProviderUpsertDto, PlatformReportResultDto, PlatformReportResultUpsertDto, PlatformRiskContributorDto, PlatformRiskContributorUpsertDto, PlatformSaasComponentDto, PlatformSaasComponentUpsertDto, PlatformStagedSaasAssetDto, PlatformStagedSaasAssetUpsertDto, PlatformStagedSaasUserDto, PlatformStagedSaasUserUpsertDto, PlatformTokenDto, PlatformTokenUpsertDto, ProviderDto, TenantDto, TenantUpsertDto } from '../dto';
|
|
2
2
|
import { AmpEntityService, AmpSdkAssetService, AmpSdkTenantService, AmpSdkUserService, TruncatableAmpEntityService } from './entity.service';
|
|
3
3
|
import { AmpRestClientOptions, RestClient } from './rest';
|
|
4
4
|
import { EnumService } from './rest/EnumService';
|
|
@@ -7,6 +7,7 @@ import { AmpSaaSEntityService, AmpSdkSaasAssetService, AmpSdkSaasComponentServic
|
|
|
7
7
|
import { ContentfulService } from './contentful.service';
|
|
8
8
|
import { FindingsInsightsService } from './findingsInsights.service';
|
|
9
9
|
import { PlatformConnectorService } from './connector.platform.service';
|
|
10
|
+
import { PlatformAgentService } from './AgentsService';
|
|
10
11
|
export type AmpSdkOptions = AmpRestClientOptions;
|
|
11
12
|
/**
|
|
12
13
|
* AMP API
|
|
@@ -19,7 +20,7 @@ export type AmpSdkOptions = AmpRestClientOptions;
|
|
|
19
20
|
*/
|
|
20
21
|
export declare class AmpSdkServices {
|
|
21
22
|
readonly actionExecutions: AmpEntityService<PlatformActionExecutionUpsertDto, PlatformActionExecutionDto>;
|
|
22
|
-
readonly agents:
|
|
23
|
+
readonly agents: PlatformAgentService;
|
|
23
24
|
readonly asset: AmpSdkAssetService;
|
|
24
25
|
readonly connectors: PlatformConnectorService;
|
|
25
26
|
readonly contentful: ContentfulService;
|
|
@@ -10,6 +10,7 @@ const saasEntity_service_1 = require("./saasEntity.service");
|
|
|
10
10
|
const contentful_service_1 = require("./contentful.service");
|
|
11
11
|
const findingsInsights_service_1 = require("./findingsInsights.service");
|
|
12
12
|
const connector_platform_service_1 = require("./connector.platform.service");
|
|
13
|
+
const AgentsService_1 = require("./AgentsService");
|
|
13
14
|
/**
|
|
14
15
|
* AMP API
|
|
15
16
|
* This client is a wrapper around the AMP REST API meant to be used by
|
|
@@ -22,7 +23,7 @@ const connector_platform_service_1 = require("./connector.platform.service");
|
|
|
22
23
|
class AmpSdkServices {
|
|
23
24
|
constructor(rest) {
|
|
24
25
|
this.actionExecutions = new entity_service_1.AmpEntityServiceImpl(rest, constants_1.KIND.ACTION_EXECUTION, constants_1.TARGET_API_PLATFORM);
|
|
25
|
-
this.agents = new
|
|
26
|
+
this.agents = new AgentsService_1.PlatformAgentService(rest);
|
|
26
27
|
this.asset = new entity_service_1.AmpSdkAssetService(rest, constants_1.TARGET_API_PLATFORM);
|
|
27
28
|
this.connectors = new connector_platform_service_1.PlatformConnectorService(rest);
|
|
28
29
|
this.contentful = new contentful_service_1.ContentfulService();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmpSdk.js","sourceRoot":"","sources":["../../../src/services/AmpSdk.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AmpSdk.js","sourceRoot":"","sources":["../../../src/services/AmpSdk.ts"],"names":[],"mappings":";;;AA0CA,qDAQ0B;AAC1B,iCAA0E;AAC1E,2CAAsD;AACtD,oDAAmE;AACnE,yDAAyD;AACzD,6DAA+J;AAC/J,6DAAuD;AACvD,yEAAmE;AACnE,6EAAsE;AACtE,mDAAqD;AAIrD;;;;;;;;GAQG;AACH,MAAa,cAAc;IAgCzB,YAA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B,CAC7D,IAAI,EACJ,gBAAI,CAAC,sBAAsB,EAC3B,+BAAmB,CACpB,CAAC;QACF,IAAI,CAAC,eAAe,GAAG,IAAI,gDAA+B,CAA6D,IAAI,EAAE,gBAAI,CAAC,iBAAiB,EAAE,+BAAmB,CAAC,CAAC;QAE1K,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,MAAM,GAAG,IAAI,qCAAoB,CAA2C,IAAI,EAAE,gBAAI,CAAC,MAAM,EAAE,+BAAmB,CAAC,CAAC;QACzH,IAAI,CAAC,KAAK,GAAG,IAAI,kCAAiB,CAAC,IAAI,EAAE,+BAAmB,CAAC,CAAC;IAChE,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;AA1ED,wCA0EC"}
|
package/package.json
CHANGED
package/src/dto/agents.dto.ts
CHANGED
|
@@ -1,39 +1,27 @@
|
|
|
1
1
|
import {AgentStatus} from './enums/agent.status';
|
|
2
|
-
import {
|
|
3
|
-
import {AuthRole} from './enums';
|
|
2
|
+
import {UPSERT_DTO_MASK, _BaseDto, _BaseUpsertDto} from './base.dto';
|
|
4
3
|
import {z} from 'zod';
|
|
5
|
-
|
|
4
|
+
import {AgentAuthRoles} from './enums';
|
|
6
5
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
pictureUrl?: string;
|
|
18
|
-
/** Agent role */
|
|
19
|
-
// TODO: role: AgentRole; // for now all agents are `OWNER`. Need to map role to tenant
|
|
20
|
-
};
|
|
6
|
+
export const _AgentDto = _BaseDto.extend({
|
|
7
|
+
firstName: z.string().nullable(),
|
|
8
|
+
lastName: z.string().nullable(),
|
|
9
|
+
status: z.nativeEnum(AgentStatus),
|
|
10
|
+
role: z.nativeEnum(AgentAuthRoles),
|
|
11
|
+
email: z.string(),
|
|
12
|
+
pictureUrl: z.string().nullable(),
|
|
13
|
+
lastLoggedIn: z.string().nullable(),
|
|
14
|
+
});
|
|
15
|
+
export type AgentDto = z.infer<typeof _AgentDto>;
|
|
21
16
|
|
|
22
|
-
export
|
|
17
|
+
export const _AgentUpsertDto = _AgentDto.partial(UPSERT_DTO_MASK);
|
|
18
|
+
export type AgentUpsertDto = z.infer<typeof _AgentUpsertDto>;
|
|
23
19
|
|
|
24
|
-
export const
|
|
25
|
-
.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
lastLoggedIn: z.date().nullable(),
|
|
33
|
-
})
|
|
34
|
-
.merge(_BaseDto);
|
|
35
|
-
|
|
36
|
-
export type AgentSummaryDto = z.infer<typeof _AgentSummaryDto>;
|
|
37
|
-
|
|
38
|
-
export const _AgentSummaryUpsertDto = _AgentSummaryDto.partial();
|
|
39
|
-
export type AgentSummaryUpsertDto = z.infer<typeof _AgentSummaryUpsertDto>;
|
|
20
|
+
export const _AgentInviteDto = z.object({
|
|
21
|
+
email: z.string(),
|
|
22
|
+
role: z.nativeEnum(AgentAuthRoles),
|
|
23
|
+
firstName: z.string().optional(),
|
|
24
|
+
lastName: z.string().optional(),
|
|
25
|
+
pictureUrl: z.string().optional(),
|
|
26
|
+
});
|
|
27
|
+
export type AgentInviteDto = z.infer<typeof _AgentInviteDto>;
|
|
@@ -46,8 +46,36 @@ const authRoleLookupMap: {[key: string]: AuthRole} = {
|
|
|
46
46
|
SUPPORT: AuthRole.SUPPORT,
|
|
47
47
|
OPERATOR: AuthRole.OPERATOR,
|
|
48
48
|
SERVICE_ACCOUNT: AuthRole.SERVICE_ACCOUNT,
|
|
49
|
-
};
|
|
49
|
+
} as const;
|
|
50
50
|
|
|
51
51
|
export function lookupAuthRole(role: string): AuthRole {
|
|
52
52
|
return authRoleLookupMap[role] || AuthRole.UNKNOWN;
|
|
53
53
|
}
|
|
54
|
+
|
|
55
|
+
// Create the type of the subset
|
|
56
|
+
export type UserAuthRoles = Extract<AuthRole, AuthRole.USER>;
|
|
57
|
+
// And the const that goes with it
|
|
58
|
+
export const UserAuthRoles = {
|
|
59
|
+
[AuthRole.USER]: AuthRole.USER,
|
|
60
|
+
} as const;
|
|
61
|
+
|
|
62
|
+
// Create the type of the subset
|
|
63
|
+
export type AgentAuthRoles = Extract<AuthRole, AuthRole.ADMIN | AuthRole.AGENT | AuthRole.OWNER | AuthRole.REPORT_VIEWER | AuthRole.VIEWER>;
|
|
64
|
+
// And the const that goes with it
|
|
65
|
+
export const AgentAuthRoles = {
|
|
66
|
+
[AuthRole.ADMIN]: AuthRole.ADMIN,
|
|
67
|
+
[AuthRole.AGENT]: AuthRole.AGENT,
|
|
68
|
+
[AuthRole.OWNER]: AuthRole.OWNER,
|
|
69
|
+
[AuthRole.REPORT_VIEWER]: AuthRole.REPORT_VIEWER,
|
|
70
|
+
[AuthRole.VIEWER]: AuthRole.VIEWER,
|
|
71
|
+
} as const;
|
|
72
|
+
|
|
73
|
+
// Create the type of the subset
|
|
74
|
+
export type PlatformAuthRoles = Extract<AuthRole, AuthRole.CUSTOMER_SUCCESS | AuthRole.OPERATOR | AuthRole.SERVICE_ACCOUNT | AuthRole.SUPPORT>;
|
|
75
|
+
// And the const that goes with it
|
|
76
|
+
export const PlatformAuthRoles = {
|
|
77
|
+
[AuthRole.CUSTOMER_SUCCESS]: AuthRole.CUSTOMER_SUCCESS,
|
|
78
|
+
[AuthRole.OPERATOR]: AuthRole.OPERATOR,
|
|
79
|
+
[AuthRole.SERVICE_ACCOUNT]: AuthRole.SERVICE_ACCOUNT,
|
|
80
|
+
[AuthRole.SUPPORT]: AuthRole.SUPPORT,
|
|
81
|
+
} as const;
|
package/src/dto/findings.dto.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {z} from 'zod';
|
|
2
2
|
import {SimpleAssetDto} from './assets.dto';
|
|
3
|
-
import {BaseDto, BaseUpsertDto, _BaseDto} from './base.dto';
|
|
3
|
+
import {BaseDto, BaseUpsertDto, UPSERT_DTO_MASK, _BaseDto} from './base.dto';
|
|
4
4
|
import {Category, FindingKind, FindingSpecKind, SaasComponentKind} from './enums';
|
|
5
5
|
import {FindingOutcome, FindingSeverity, FindingStatus} from './enums';
|
|
6
6
|
import {SimpleProviderDto} from './providers.dto';
|
|
@@ -107,12 +107,7 @@ export const _FindingSpecDto = _BaseDto.extend({
|
|
|
107
107
|
});
|
|
108
108
|
export type FindingSpecDto = z.infer<typeof _FindingSpecDto>;
|
|
109
109
|
|
|
110
|
-
export const _FindingSpecUpsertDto = _FindingSpecDto.partial(
|
|
111
|
-
id: true,
|
|
112
|
-
createdAt: true,
|
|
113
|
-
updatedAt: true,
|
|
114
|
-
deletedAt: true,
|
|
115
|
-
});
|
|
110
|
+
export const _FindingSpecUpsertDto = _FindingSpecDto.partial(UPSERT_DTO_MASK);
|
|
116
111
|
export type FindingSpecUpsertDto = z.infer<typeof _FindingSpecUpsertDto>;
|
|
117
112
|
|
|
118
113
|
export const _FindingSummaryDto = z.object({
|
package/src/dto/flows.dto.ts
CHANGED
|
@@ -131,8 +131,8 @@ export const _FlowInterval = z.object({
|
|
|
131
131
|
export type FlowInterval = z.infer<typeof _FlowInterval>;
|
|
132
132
|
|
|
133
133
|
const _FlowActionDetails = z.object({
|
|
134
|
-
actionId: z.string(),
|
|
135
|
-
findingStatus: z.nativeEnum(FindingStatus).optional(),
|
|
134
|
+
actionId: z.string().nullable(),
|
|
135
|
+
findingStatus: z.nativeEnum(FindingStatus).optional().nullable(),
|
|
136
136
|
});
|
|
137
137
|
|
|
138
138
|
export const _FlowActions = z.object({
|
|
@@ -157,6 +157,8 @@ export const _FlowActions = z.object({
|
|
|
157
157
|
*/
|
|
158
158
|
resolveNowActionId: z.string().optional(),
|
|
159
159
|
resolveNowAction: _FlowActionDetails.optional(),
|
|
160
|
+
|
|
161
|
+
scheduleResolutionAction: _FlowActionDetails.optional(),
|
|
160
162
|
});
|
|
161
163
|
export type FlowActions = z.infer<typeof _FlowActions>;
|
|
162
164
|
export const _FlowRewardsConfig = z.object({
|
|
@@ -188,6 +190,9 @@ export const _FlowSpecDto = _BaseDto.merge(
|
|
|
188
190
|
rewards: z.array(_FlowRewardsConfig).optional(),
|
|
189
191
|
customMessage: z.object({template: z.string().optional(), append: z.boolean().optional()}).optional(),
|
|
190
192
|
additionalContext: z.object({data: z.string().optional()}).optional(),
|
|
193
|
+
/**
|
|
194
|
+
* @deprecated Use scheduleResolutionAction instead
|
|
195
|
+
*/
|
|
191
196
|
scheduleConfig: z.object({required: z.boolean()}).optional(),
|
|
192
197
|
activity: z
|
|
193
198
|
.object({
|
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {z} from 'zod';
|
|
2
|
+
import {AgentAuthRoles, AgentStatus} from '../enums';
|
|
3
|
+
import {UPSERT_DTO_MASK, _BaseDto} from '../base.dto';
|
|
4
|
+
import {_AgentUpsertDto} from '../agents.dto';
|
|
3
5
|
|
|
4
|
-
export
|
|
6
|
+
export const _PlatformAgentMembership = z.object({
|
|
7
|
+
tid: z.string(),
|
|
8
|
+
role: z.nativeEnum(AgentAuthRoles),
|
|
9
|
+
status: z.nativeEnum(AgentStatus),
|
|
10
|
+
organization: z.string().nullable(),
|
|
11
|
+
department: z.string().nullable(),
|
|
12
|
+
lastLoggedIn: z.string().nullable(),
|
|
13
|
+
});
|
|
14
|
+
export type PlatformAgentMembership = z.infer<typeof _PlatformAgentMembership>;
|
|
5
15
|
|
|
6
|
-
export
|
|
16
|
+
export const _PlatformAgentDto = _BaseDto.extend({
|
|
17
|
+
firstName: z.string().nullable(),
|
|
18
|
+
lastName: z.string().nullable(),
|
|
19
|
+
email: z.string(),
|
|
20
|
+
memberships: z.array(_PlatformAgentMembership),
|
|
21
|
+
pictureUrl: z.string().nullable(),
|
|
22
|
+
});
|
|
23
|
+
export type PlatformAgentDto = z.infer<typeof _PlatformAgentDto>;
|
|
24
|
+
|
|
25
|
+
export const _PlatformAgentUpsertDto = _AgentUpsertDto.partial(UPSERT_DTO_MASK);
|
|
26
|
+
export type PlatformAgentUpsertDto = z.infer<typeof _PlatformAgentUpsertDto>;
|
package/src/etag.ts
CHANGED
|
@@ -8,7 +8,7 @@ export function calculateEtag(model: unknown): string {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export function withEtag(model: ChangeAwareDto | ChangeAwareUpsertDto) {
|
|
11
|
-
model.etag = calculateEtag(model);
|
|
11
|
+
model.etag = calculateEtag({...model, etag: ''});
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export function createWithEtag<T extends {etag: string}>(model: T): T {
|
|
@@ -1,25 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {AgentAuthRoles, AgentDto, AgentInviteDto, AgentStatus, AgentUpsertDto, Page, PlatformAgentDto, _AgentUpsertDto} from '../dto';
|
|
2
|
+
import {KIND, TARGET_API_PLATFORM} from './constants';
|
|
3
|
+
import {AmpDataServiceImpl} from './data.service';
|
|
4
4
|
import {AmpEntityServiceImpl} from './entity.service';
|
|
5
5
|
import {RestClient} from './rest';
|
|
6
6
|
|
|
7
|
-
export const _AgentSummaryPayload = _AgentSummaryUpsertDto.required({email: true, role: true});
|
|
8
|
-
export type AgentSummaryPayload = z.infer<typeof _AgentSummaryPayload>;
|
|
9
|
-
|
|
10
7
|
export class AgentsService extends AmpEntityServiceImpl<AgentUpsertDto, AgentDto> {
|
|
11
8
|
constructor(rest: RestClient) {
|
|
12
9
|
super(rest, KIND.AGENTS);
|
|
13
10
|
}
|
|
14
|
-
invite = async (
|
|
15
|
-
const payload = _AgentSummaryPayload.parse(agentSavePayload);
|
|
16
|
-
|
|
11
|
+
invite = async (agentInvitePayload: AgentInviteDto): Promise<Page<AgentDto>> => {
|
|
17
12
|
const res = await this.rest.call({
|
|
18
13
|
url: `/${this.targetApi}/v1/${this.kind}/invite`,
|
|
19
14
|
method: 'POST',
|
|
20
|
-
data:
|
|
15
|
+
data: agentInvitePayload,
|
|
21
16
|
});
|
|
22
17
|
|
|
23
18
|
return res.data as Page<AgentDto>;
|
|
24
19
|
};
|
|
25
20
|
}
|
|
21
|
+
|
|
22
|
+
export class PlatformAgentService extends AmpDataServiceImpl<PlatformAgentDto> {
|
|
23
|
+
constructor(rest: RestClient) {
|
|
24
|
+
super(rest, KIND.AGENTS, TARGET_API_PLATFORM);
|
|
25
|
+
}
|
|
26
|
+
create = async (email: string) => {
|
|
27
|
+
return this.rest.call({
|
|
28
|
+
url: `/${this.targetApi}/v1/${this.kind}`,
|
|
29
|
+
method: 'POST',
|
|
30
|
+
data: {email},
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/json',
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
delete = async (id: string) => {
|
|
38
|
+
return this.rest.call({
|
|
39
|
+
url: `/${this.targetApi}/v1/${this.kind}/${id}`,
|
|
40
|
+
method: 'DELETE',
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
upsertMembership = async ({tid, agentId, role, status}: {tid: string; agentId: string; role: AgentAuthRoles; status: AgentStatus}) => {
|
|
45
|
+
return this.rest.call({
|
|
46
|
+
url: `/${this.targetApi}/v1/${this.kind}/memberships`,
|
|
47
|
+
method: 'PUT',
|
|
48
|
+
data: {tid, agentId, role, status},
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
deleteMembership = async ({tid, agentId}: {tid: string; agentId: string}) => {
|
|
53
|
+
return this.rest.call({
|
|
54
|
+
url: `/${this.targetApi}/v1/${this.kind}/memberships/agentId/${agentId}/tid/${tid}`,
|
|
55
|
+
method: 'DELETE',
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
}
|
package/src/services/AmpSdk.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PlatformActionExecutionDto,
|
|
3
3
|
PlatformActionExecutionUpsertDto,
|
|
4
|
-
PlatformAgentDto,
|
|
5
|
-
PlatformAgentUpsertDto,
|
|
6
4
|
PlatformCustomActionDto,
|
|
7
5
|
PlatformCustomActionUpsertDto,
|
|
8
6
|
PlatformCustomScoreCohortDto,
|
|
@@ -59,6 +57,7 @@ import {AmpSaaSEntityService, AmpSaaSEntityServiceImpl, AmpSdkSaasAssetService,
|
|
|
59
57
|
import {ContentfulService} from './contentful.service';
|
|
60
58
|
import {FindingsInsightsService} from './findingsInsights.service';
|
|
61
59
|
import {PlatformConnectorService} from './connector.platform.service';
|
|
60
|
+
import {PlatformAgentService} from './AgentsService';
|
|
62
61
|
|
|
63
62
|
export type AmpSdkOptions = AmpRestClientOptions;
|
|
64
63
|
|
|
@@ -73,7 +72,7 @@ export type AmpSdkOptions = AmpRestClientOptions;
|
|
|
73
72
|
*/
|
|
74
73
|
export class AmpSdkServices {
|
|
75
74
|
readonly actionExecutions: AmpEntityService<PlatformActionExecutionUpsertDto, PlatformActionExecutionDto>;
|
|
76
|
-
readonly agents:
|
|
75
|
+
readonly agents: PlatformAgentService;
|
|
77
76
|
readonly asset: AmpSdkAssetService;
|
|
78
77
|
readonly connectors: PlatformConnectorService;
|
|
79
78
|
readonly contentful: ContentfulService;
|
|
@@ -105,7 +104,7 @@ export class AmpSdkServices {
|
|
|
105
104
|
|
|
106
105
|
constructor(rest: RestClient) {
|
|
107
106
|
this.actionExecutions = new AmpEntityServiceImpl<PlatformActionExecutionUpsertDto, PlatformActionExecutionDto>(rest, KIND.ACTION_EXECUTION, TARGET_API_PLATFORM);
|
|
108
|
-
this.agents = new
|
|
107
|
+
this.agents = new PlatformAgentService(rest);
|
|
109
108
|
this.asset = new AmpSdkAssetService(rest, TARGET_API_PLATFORM);
|
|
110
109
|
this.connectors = new PlatformConnectorService(rest);
|
|
111
110
|
this.contentful = new ContentfulService();
|