@ampsec/platform-client 25.1.0 → 25.3.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/enums/category.d.ts +1 -0
- package/build/src/dto/enums/category.js +1 -0
- package/build/src/dto/enums/category.js.map +1 -1
- package/build/src/dto/enums/notification.status.d.ts +5 -0
- package/build/src/dto/enums/notification.status.js +11 -0
- package/build/src/dto/enums/notification.status.js.map +1 -0
- package/build/src/dto/enums/notificationStep.type.d.ts +4 -0
- package/build/src/dto/enums/notificationStep.type.js +10 -0
- package/build/src/dto/enums/notificationStep.type.js.map +1 -0
- package/build/src/dto/enums/workflowTrigger.type.d.ts +4 -0
- package/build/src/dto/enums/workflowTrigger.type.js +10 -0
- package/build/src/dto/enums/workflowTrigger.type.js.map +1 -0
- package/build/src/dto/index.d.ts +2 -0
- package/build/src/dto/index.js +2 -0
- package/build/src/dto/index.js.map +1 -1
- package/build/src/dto/notification.dto.d.ts +24 -0
- package/build/src/dto/notification.dto.js +3 -0
- package/build/src/dto/notification.dto.js.map +1 -0
- package/build/src/dto/platform/platform.notification.dto.d.ts +4 -0
- package/build/src/dto/platform/platform.notification.dto.js +3 -0
- package/build/src/dto/platform/platform.notification.dto.js.map +1 -0
- package/build/src/dto/platform/platform.workflow.dto.d.ts +4 -0
- package/build/src/dto/platform/platform.workflow.dto.js +3 -0
- package/build/src/dto/platform/platform.workflow.dto.js.map +1 -0
- package/build/src/dto/platform/platform.workflowAssignment.dto.d.ts +4 -0
- package/build/src/dto/platform/platform.workflowAssignment.dto.js +3 -0
- package/build/src/dto/platform/platform.workflowAssignment.dto.js.map +1 -0
- package/build/src/dto/workflow.dto.d.ts +68 -0
- package/build/src/dto/workflow.dto.js +3 -0
- package/build/src/dto/workflow.dto.js.map +1 -0
- package/build/src/dto/workflowAssignment.dto.d.ts +8 -0
- package/build/src/dto/workflowAssignment.dto.js +3 -0
- package/build/src/dto/workflowAssignment.dto.js.map +1 -0
- package/build/src/services/entity.service.d.ts +22 -19
- package/build/src/services/entity.service.js +18 -8
- package/build/src/services/entity.service.js.map +1 -1
- package/package.json +1 -1
- package/src/dto/enums/category.ts +1 -0
- package/src/dto/enums/notification.status.ts +6 -0
- package/src/dto/enums/notificationStep.type.ts +5 -0
- package/src/dto/enums/workflowTrigger.type.ts +5 -0
- package/src/dto/index.ts +2 -0
- package/src/dto/notification.dto.ts +27 -0
- package/src/dto/platform/platform.notification.dto.ts +6 -0
- package/src/dto/platform/platform.workflow.dto.ts +6 -0
- package/src/dto/platform/platform.workflowAssignment.dto.ts +6 -0
- package/src/dto/workflow.dto.ts +83 -0
- package/src/dto/workflowAssignment.dto.ts +10 -0
- package/src/services/entity.service.ts +36 -22
|
@@ -10,6 +10,7 @@ var Category;
|
|
|
10
10
|
*/
|
|
11
11
|
Category["MFA"] = "MFA";
|
|
12
12
|
Category["IDENTITY"] = "IDENTITY";
|
|
13
|
+
Category["NOTIFICATION"] = "NOTIFICATION";
|
|
13
14
|
Category["TRAINING"] = "TRAINING";
|
|
14
15
|
Category["WEB_GATEWAY"] = "WEB_GATEWAY";
|
|
15
16
|
})(Category || (exports.Category = Category = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category.js","sourceRoot":"","sources":["../../../../src/dto/enums/category.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,
|
|
1
|
+
{"version":3,"file":"category.js","sourceRoot":"","sources":["../../../../src/dto/enums/category.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB,uBAAW,CAAA;IACX;;OAEG;IACH,uBAAW,CAAA;IACX,iCAAqB,CAAA;IACrB,yCAA6B,CAAA;IAC7B,iCAAqB,CAAA;IACrB,uCAA2B,CAAA;AAC7B,CAAC,EAVW,QAAQ,wBAAR,QAAQ,QAUnB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationStatus = void 0;
|
|
4
|
+
/* eslint-disable no-unused-vars */
|
|
5
|
+
var NotificationStatus;
|
|
6
|
+
(function (NotificationStatus) {
|
|
7
|
+
NotificationStatus["PENDING"] = "PENDING";
|
|
8
|
+
NotificationStatus["READ"] = "READ";
|
|
9
|
+
NotificationStatus["SENT"] = "SENT";
|
|
10
|
+
})(NotificationStatus || (exports.NotificationStatus = NotificationStatus = {}));
|
|
11
|
+
//# sourceMappingURL=notification.status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.status.js","sourceRoot":"","sources":["../../../../src/dto/enums/notification.status.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,yCAAmB,CAAA;IACnB,mCAAa,CAAA;IACb,mCAAa,CAAA;AACf,CAAC,EAJW,kBAAkB,kCAAlB,kBAAkB,QAI7B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationStepType = void 0;
|
|
4
|
+
/* eslint-disable no-unused-vars */
|
|
5
|
+
var NotificationStepType;
|
|
6
|
+
(function (NotificationStepType) {
|
|
7
|
+
NotificationStepType["NOTIFICATION"] = "NOTIFICATION";
|
|
8
|
+
NotificationStepType["PAUSE"] = "PAUSE";
|
|
9
|
+
})(NotificationStepType || (exports.NotificationStepType = NotificationStepType = {}));
|
|
10
|
+
//# sourceMappingURL=notificationStep.type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notificationStep.type.js","sourceRoot":"","sources":["../../../../src/dto/enums/notificationStep.type.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,qDAA6B,CAAA;IAC7B,uCAAe,CAAA;AACjB,CAAC,EAHW,oBAAoB,oCAApB,oBAAoB,QAG/B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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 || (exports.WorkflowTriggerType = WorkflowTriggerType = {}));
|
|
10
|
+
//# sourceMappingURL=workflowTrigger.type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflowTrigger.type.js","sourceRoot":"","sources":["../../../../src/dto/enums/workflowTrigger.type.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,0CAAmB,CAAA;IACnB,oCAAa,CAAA;AACf,CAAC,EAHW,mBAAmB,mCAAnB,mBAAmB,QAG9B"}
|
package/build/src/dto/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from './extKeyMap.dto';
|
|
|
9
9
|
export * from './findings.dto';
|
|
10
10
|
export * from './jwt';
|
|
11
11
|
export * from './message.dto';
|
|
12
|
+
export * from './notification.dto';
|
|
12
13
|
export * from './page.dto';
|
|
13
14
|
export * from './platform';
|
|
14
15
|
export * from './providers.dto';
|
|
@@ -20,3 +21,4 @@ export * from './saasUsers.dto';
|
|
|
20
21
|
export * from './ampSetting.dto';
|
|
21
22
|
export * from './tenants.dto';
|
|
22
23
|
export * from './users.dto';
|
|
24
|
+
export * from './workflow.dto';
|
package/build/src/dto/index.js
CHANGED
|
@@ -25,6 +25,7 @@ __exportStar(require("./extKeyMap.dto"), exports);
|
|
|
25
25
|
__exportStar(require("./findings.dto"), exports);
|
|
26
26
|
__exportStar(require("./jwt"), exports);
|
|
27
27
|
__exportStar(require("./message.dto"), exports);
|
|
28
|
+
__exportStar(require("./notification.dto"), exports);
|
|
28
29
|
__exportStar(require("./page.dto"), exports);
|
|
29
30
|
__exportStar(require("./platform"), exports);
|
|
30
31
|
__exportStar(require("./providers.dto"), exports);
|
|
@@ -36,4 +37,5 @@ __exportStar(require("./saasUsers.dto"), exports);
|
|
|
36
37
|
__exportStar(require("./ampSetting.dto"), exports);
|
|
37
38
|
__exportStar(require("./tenants.dto"), exports);
|
|
38
39
|
__exportStar(require("./users.dto"), exports);
|
|
40
|
+
__exportStar(require("./workflow.dto"), exports);
|
|
39
41
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,+CAA6B;AAC7B,8CAA4B;AAC5B,6CAA2B;AAC3B,mDAAiC;AACjC,6CAA2B;AAC3B,0CAAwB;AACxB,kDAAgC;AAChC,iDAA+B;AAC/B,wCAAsB;AACtB,gDAA8B;AAC9B,6CAA2B;AAC3B,6CAA2B;AAC3B,kDAAgC;AAChC,sDAAoC;AACpC,yDAAuC;AACvC,mDAAiC;AACjC,uDAAqC;AACrC,kDAAgC;AAChC,mDAAiC;AACjC,gDAA8B;AAC9B,8CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,+CAA6B;AAC7B,8CAA4B;AAC5B,6CAA2B;AAC3B,mDAAiC;AACjC,6CAA2B;AAC3B,0CAAwB;AACxB,kDAAgC;AAChC,iDAA+B;AAC/B,wCAAsB;AACtB,gDAA8B;AAC9B,qDAAmC;AACnC,6CAA2B;AAC3B,6CAA2B;AAC3B,kDAAgC;AAChC,sDAAoC;AACpC,yDAAuC;AACvC,mDAAiC;AACjC,uDAAqC;AACrC,kDAAgC;AAChC,mDAAiC;AACjC,gDAA8B;AAC9B,8CAA4B;AAC5B,iDAA+B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseDto } from './base.dto';
|
|
2
|
+
export type NotificationAddress = {
|
|
3
|
+
/** Connector ID for the notification channel */
|
|
4
|
+
cid: string;
|
|
5
|
+
/** Group IDs to which the notification is being sent */
|
|
6
|
+
groups?: string[] | number[];
|
|
7
|
+
/** User IDs to which the notification is being sent */
|
|
8
|
+
users?: string[] | number[];
|
|
9
|
+
/** Webhook URLs to which the notification is being sent */
|
|
10
|
+
webhooks?: string[];
|
|
11
|
+
};
|
|
12
|
+
export type NotificationUpsertDto = {
|
|
13
|
+
/** Workflow ID for which the notification is being created */
|
|
14
|
+
wfid: string;
|
|
15
|
+
/** Finding ID for which the notification is being created */
|
|
16
|
+
fid?: string;
|
|
17
|
+
/** Recipient address to which the notification is being sent */
|
|
18
|
+
to: NotificationAddress;
|
|
19
|
+
/** ID of the template to use for the notification */
|
|
20
|
+
templateId: string;
|
|
21
|
+
/** ID o fthe user to which the notification is being sent */
|
|
22
|
+
uid: string;
|
|
23
|
+
};
|
|
24
|
+
export type NotificationDto = NotificationUpsertDto & BaseDto;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.dto.js","sourceRoot":"","sources":["../../../src/dto/notification.dto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NotificationDto, NotificationUpsertDto } from '../notification.dto';
|
|
2
|
+
import { TenantBased } from './tenant.based.dto';
|
|
3
|
+
export type PlatformNotificationUpsertDto = NotificationUpsertDto & TenantBased;
|
|
4
|
+
export type PlatformNotificationDto = NotificationDto & TenantBased;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.notification.dto.js","sourceRoot":"","sources":["../../../../src/dto/platform/platform.notification.dto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.workflow.dto.js","sourceRoot":"","sources":["../../../../src/dto/platform/platform.workflow.dto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { WorkflowAssignmentUpsertDto } from '../workflowAssignment.dto';
|
|
2
|
+
import { TenantBased } from './tenant.based.dto';
|
|
3
|
+
export type PlatformWorkflowAssignmentUpsertDto = WorkflowAssignmentUpsertDto & TenantBased;
|
|
4
|
+
export type PlatformWorkflowAssignmentDto = PlatformWorkflowAssignmentUpsertDto & TenantBased;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.workflowAssignment.dto.js","sourceRoot":"","sources":["../../../../src/dto/platform/platform.workflowAssignment.dto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { BaseDto } from './base.dto';
|
|
2
|
+
import { NotificationStepType } from './enums/notificationStep.type';
|
|
3
|
+
import { WorkflowTriggerType } from './enums/workflowTrigger.type';
|
|
4
|
+
export type NotificationStepData = {
|
|
5
|
+
/** Name of the device to which the notification of finding applies */
|
|
6
|
+
deviceName?: string;
|
|
7
|
+
/** Description of the notification of finding */
|
|
8
|
+
description?: string;
|
|
9
|
+
/** Due date associated with the finding */
|
|
10
|
+
dueDate?: string;
|
|
11
|
+
/** Name of the software to which the finding applies */
|
|
12
|
+
softwareName: string;
|
|
13
|
+
};
|
|
14
|
+
export type PauseStepData = {
|
|
15
|
+
/** Estimated duration, in minutes, to resolve the finding */
|
|
16
|
+
duration: number;
|
|
17
|
+
};
|
|
18
|
+
export type WorkflowStep = {
|
|
19
|
+
/** Number of the step in the workflow */
|
|
20
|
+
stepNumber: number;
|
|
21
|
+
/** Type of the notification step, either NOTIFICATION or PAUSE */
|
|
22
|
+
type: NotificationStepType;
|
|
23
|
+
/** ID of the template to be used for the notification */
|
|
24
|
+
templateId?: string;
|
|
25
|
+
/** Data associated with the notification step */
|
|
26
|
+
data: NotificationStepData | PauseStepData;
|
|
27
|
+
/** Step number to transition the workflow to on success */
|
|
28
|
+
successStepNumber: number | null;
|
|
29
|
+
/** Step number to transition the workflow to on failure */
|
|
30
|
+
failureStepNumber: number | null;
|
|
31
|
+
/** Duration, in days, to wait before executing the next step in the workflow */
|
|
32
|
+
pauseDuration?: number | null;
|
|
33
|
+
};
|
|
34
|
+
export type WorkflowTriggerRule = {
|
|
35
|
+
[propName: string]: string | number | boolean | null | {
|
|
36
|
+
[propName: string]: string | number | boolean | WorkflowTriggerRule;
|
|
37
|
+
} | WorkflowTriggerRule[];
|
|
38
|
+
};
|
|
39
|
+
export type WorkflowTrigger = {
|
|
40
|
+
/** Type of the trigger */
|
|
41
|
+
type: WorkflowTriggerType;
|
|
42
|
+
/** Rule to which the applicable entity type must conform to trigger the workflow */
|
|
43
|
+
rule: unknown;
|
|
44
|
+
};
|
|
45
|
+
export type WorkflowUpsertDto = {
|
|
46
|
+
/** Name of the workflow */
|
|
47
|
+
name: string;
|
|
48
|
+
/** Description of the workflow */
|
|
49
|
+
description?: string;
|
|
50
|
+
/** Trigger that begins execution of the workflow */
|
|
51
|
+
trigger: WorkflowTrigger;
|
|
52
|
+
/** Steps in the workflow */
|
|
53
|
+
steps?: WorkflowStep[];
|
|
54
|
+
};
|
|
55
|
+
export type WorkflowDto = BaseDto & WorkflowUpsertDto;
|
|
56
|
+
export type WorkflowProgressUpsertDto = {
|
|
57
|
+
/** ID of the workflow */
|
|
58
|
+
wfid: string;
|
|
59
|
+
/** ID of the finding for which the workflow is being executed */
|
|
60
|
+
fid?: string | null;
|
|
61
|
+
/** Step number to transition the workflow to next */
|
|
62
|
+
nextStep: number;
|
|
63
|
+
/** ID of the user for which the workflow is being executed */
|
|
64
|
+
uid: string | null;
|
|
65
|
+
/** whether or not this instance of the workflow has been completed */
|
|
66
|
+
workflowCompleted: boolean;
|
|
67
|
+
};
|
|
68
|
+
export type WorkflowProgressDto = BaseDto & WorkflowProgressUpsertDto;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.dto.js","sourceRoot":"","sources":["../../../src/dto/workflow.dto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseDto } from './base.dto';
|
|
2
|
+
export type WorkflowAssignmentUpsertDto = {
|
|
3
|
+
/** ID of the workflow */
|
|
4
|
+
wfid: string;
|
|
5
|
+
/** ID of the user to which the workflow is being assigned */
|
|
6
|
+
uid: string;
|
|
7
|
+
};
|
|
8
|
+
export type WorkflowAssignmentDto = BaseDto & WorkflowAssignmentUpsertDto;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflowAssignment.dto.js","sourceRoot":"","sources":["../../../src/dto/workflowAssignment.dto.ts"],"names":[],"mappings":""}
|
|
@@ -2,39 +2,42 @@ import { BaseDto, BaseUpsertDto, ExtKeyMap, Page } from '../dto';
|
|
|
2
2
|
import { TargetApi } from './constants';
|
|
3
3
|
import { AmpDataService, AmpDataServiceImpl } from './data.service';
|
|
4
4
|
import { RestClient } from './rest';
|
|
5
|
+
export type EntityCallOptions = {
|
|
6
|
+
params: unknown;
|
|
7
|
+
};
|
|
5
8
|
export interface AmpEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
6
|
-
create(_model: WriteT): Promise<Page<ReadT>>;
|
|
7
|
-
update(_model: WriteT): Promise<Page<ReadT>>;
|
|
8
|
-
delete(_id: string): Promise<Page<ReadT>>;
|
|
9
|
+
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
10
|
+
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
11
|
+
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
9
12
|
}
|
|
10
13
|
export interface AmpSdkTenantService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
11
|
-
create(_model: WriteT): Promise<Page<ReadT>>;
|
|
12
|
-
update(_model: WriteT): Promise<Page<ReadT>>;
|
|
13
|
-
delete(_id: string,
|
|
14
|
+
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
15
|
+
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
16
|
+
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
14
17
|
}
|
|
15
18
|
export interface AmpGlobalEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
16
|
-
create(_model: WriteT): Promise<Page<ReadT>>;
|
|
17
|
-
update(_model: WriteT): Promise<Page<ReadT>>;
|
|
18
|
-
delete(_id: string): Promise<Page<ReadT>>;
|
|
19
|
-
getLookupIds(_tid: string): Promise<ExtKeyMap>;
|
|
19
|
+
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
20
|
+
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
21
|
+
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
22
|
+
getLookupIds(_tid: string, _options?: EntityCallOptions): Promise<ExtKeyMap>;
|
|
20
23
|
}
|
|
21
24
|
export interface AmpSaaSEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
22
|
-
create(_model: WriteT): Promise<Page<ReadT>>;
|
|
23
|
-
update(_model: WriteT): Promise<Page<ReadT>>;
|
|
24
|
-
delete(_id: string): Promise<Page<ReadT>>;
|
|
25
|
-
getLookupIds(_cid: string): Promise<ExtKeyMap>;
|
|
25
|
+
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
26
|
+
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
27
|
+
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
28
|
+
getLookupIds(_cid: string, _options?: EntityCallOptions): Promise<ExtKeyMap>;
|
|
26
29
|
}
|
|
27
30
|
export declare class AmpEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataServiceImpl<ReadT> implements AmpEntityService<WriteT, ReadT> {
|
|
28
31
|
constructor(rest: RestClient, kind: string, targetApi?: TargetApi);
|
|
29
|
-
create(model: WriteT): Promise<Page<ReadT>>;
|
|
30
|
-
update(model: WriteT): Promise<Page<ReadT>>;
|
|
31
|
-
delete(id: string,
|
|
32
|
+
create(model: WriteT, options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
33
|
+
update(model: WriteT, options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
34
|
+
delete(id: string, options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
32
35
|
}
|
|
33
36
|
export declare class AmpGlobalEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpEntityServiceImpl<WriteT, ReadT> implements AmpGlobalEntityService<WriteT, ReadT> {
|
|
34
37
|
constructor(rest: RestClient, kind: string, targetApi?: TargetApi);
|
|
35
|
-
getLookupIds(tid: string): Promise<ExtKeyMap>;
|
|
38
|
+
getLookupIds(tid: string, options?: EntityCallOptions): Promise<ExtKeyMap>;
|
|
36
39
|
}
|
|
37
40
|
export declare class AmpSaaSEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpEntityServiceImpl<WriteT, ReadT> implements AmpSaaSEntityService<WriteT, ReadT> {
|
|
38
41
|
constructor(rest: RestClient, kind: string, targetApi?: TargetApi);
|
|
39
|
-
getLookupIds(cid: string): Promise<ExtKeyMap>;
|
|
42
|
+
getLookupIds(cid: string, options?: EntityCallOptions): Promise<ExtKeyMap>;
|
|
40
43
|
}
|
|
@@ -7,27 +7,29 @@ class AmpEntityServiceImpl extends data_service_1.AmpDataServiceImpl {
|
|
|
7
7
|
constructor(rest, kind, targetApi = constants_1.TARGET_API_AGENT) {
|
|
8
8
|
super(rest, kind, targetApi);
|
|
9
9
|
}
|
|
10
|
-
create(model) {
|
|
10
|
+
create(model, options) {
|
|
11
11
|
return this.getPage({
|
|
12
12
|
url: `/${this.targetApi}/v1/${this.kind}`,
|
|
13
13
|
method: 'POST',
|
|
14
|
+
params: options === null || options === void 0 ? void 0 : options.params,
|
|
14
15
|
data: model,
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
|
-
update(model) {
|
|
18
|
+
update(model, options) {
|
|
18
19
|
return this.getPage({
|
|
19
20
|
url: `/${this.targetApi}/v1/${this.kind}/${model.id}`,
|
|
20
21
|
method: 'PUT',
|
|
22
|
+
params: options === null || options === void 0 ? void 0 : options.params,
|
|
21
23
|
data: model,
|
|
22
24
|
});
|
|
23
25
|
}
|
|
24
|
-
async delete(id,
|
|
26
|
+
async delete(id, options) {
|
|
25
27
|
const res = await this.getById(id);
|
|
26
28
|
if (res.data.length === 1) {
|
|
27
29
|
const req = {
|
|
28
30
|
url: `/${this.targetApi}/v1/${this.kind}/${id}`,
|
|
29
31
|
method: 'DELETE',
|
|
30
|
-
params:
|
|
32
|
+
params: options === null || options === void 0 ? void 0 : options.params,
|
|
31
33
|
};
|
|
32
34
|
const { error } = await this.call(req, (error) => {
|
|
33
35
|
if (error instanceof Error) {
|
|
@@ -53,11 +55,15 @@ class AmpGlobalEntityServiceImpl extends AmpEntityServiceImpl {
|
|
|
53
55
|
constructor(rest, kind, targetApi = constants_1.TARGET_API_AGENT) {
|
|
54
56
|
super(rest, kind, targetApi);
|
|
55
57
|
}
|
|
56
|
-
getLookupIds(tid) {
|
|
58
|
+
getLookupIds(tid, options) {
|
|
59
|
+
var _a;
|
|
57
60
|
const req = {
|
|
58
61
|
url: `/${this.targetApi}/v1/${this.kind}/ext_key_map`,
|
|
59
62
|
method: 'GET',
|
|
60
|
-
params: {
|
|
63
|
+
params: {
|
|
64
|
+
...((_a = options === null || options === void 0 ? void 0 : options.params) !== null && _a !== void 0 ? _a : {}),
|
|
65
|
+
tid,
|
|
66
|
+
},
|
|
61
67
|
};
|
|
62
68
|
return this.call(req, extIdMapErrorHandler);
|
|
63
69
|
}
|
|
@@ -67,11 +73,15 @@ class AmpSaaSEntityServiceImpl extends AmpEntityServiceImpl {
|
|
|
67
73
|
constructor(rest, kind, targetApi = constants_1.TARGET_API_AGENT) {
|
|
68
74
|
super(rest, kind, targetApi);
|
|
69
75
|
}
|
|
70
|
-
getLookupIds(cid) {
|
|
76
|
+
getLookupIds(cid, options) {
|
|
77
|
+
var _a;
|
|
71
78
|
const req = {
|
|
72
79
|
url: `/${this.targetApi}/v1/${this.kind}/ext_key_map`,
|
|
73
80
|
method: 'GET',
|
|
74
|
-
params: {
|
|
81
|
+
params: {
|
|
82
|
+
...((_a = options === null || options === void 0 ? void 0 : options.params) !== null && _a !== void 0 ? _a : {}),
|
|
83
|
+
cid,
|
|
84
|
+
},
|
|
75
85
|
};
|
|
76
86
|
return this.call(req, extIdMapErrorHandler);
|
|
77
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.service.js","sourceRoot":"","sources":["../../../src/services/entity.service.ts"],"names":[],"mappings":";;;AACA,2CAAsE;AACtE,iDAAkE;
|
|
1
|
+
{"version":3,"file":"entity.service.js","sourceRoot":"","sources":["../../../src/services/entity.service.ts"],"names":[],"mappings":";;;AACA,2CAAsE;AACtE,iDAAkE;AAgClE,MAAa,oBAA0E,SAAQ,iCAAyB;IACtH,YAAY,IAAgB,EAAE,IAAY,EAAE,YAAuB,4BAAgB;QACjF,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,KAAa,EAAE,OAA2B;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,EAAE;YACzC,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAkB;YACnC,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,KAAa,EAAE,OAA2B;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE,EAAE;YACrD,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAkB;YACnC,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,OAA2B;QAClD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACnC,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACzB,MAAM,GAAG,GAAgB;gBACvB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE;gBAC/C,MAAM,EAAE,QAAQ;gBAChB,MAAM,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAkB;aACpC,CAAC;YACF,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAc,EAAE,EAAE;gBACtD,IAAI,KAAK,YAAY,KAAK,EAAE;oBAC1B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;iBAC9B;gBACD,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC;YACjC,CAAC,CAAC,CAAC;YACH,IAAI,KAAK,EAAE;gBACT,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,CAAC,IAAI,aAAa,EAAE,GAAG,CAAC,CAAC;aAClE;SACF;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AA3CD,oDA2CC;AAED,MAAM,oBAAoB,GAA4B,CAAC,KAAc,EAAE,EAAE;IACvE,IAAI,KAAK,YAAY,KAAK,EAAE;QAC1B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC9B;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,MAAa,0BACX,SAAQ,oBAAmC;IAG3C,YAAY,IAAgB,EAAE,IAAY,EAAE,YAAuB,4BAAgB;QACjF,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/B,CAAC;IACD,YAAY,CAAC,GAAW,EAAE,OAA2B;;QACnD,MAAM,GAAG,GAAgB;YACvB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,cAAc;YACrD,MAAM,EAAE,KAAK;YACb,MAAM,EAAE;gBACN,GAAG,CAAC,MAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAmB,mCAAI,EAAE,CAAC;gBACxC,GAAG;aACJ;SACF,CAAC;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;IAC9C,CAAC;CACF;AAlBD,gEAkBC;AAED,MAAa,wBACX,SAAQ,oBAAmC;IAG3C,YAAY,IAAgB,EAAE,IAAY,EAAE,YAAuB,4BAAgB;QACjF,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/B,CAAC;IACD,YAAY,CAAC,GAAW,EAAE,OAA2B;;QACnD,MAAM,GAAG,GAAgB;YACvB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,cAAc;YACrD,MAAM,EAAE,KAAK;YACb,MAAM,EAAE;gBACN,GAAG,CAAC,MAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAmB,mCAAI,EAAE,CAAC;gBACxC,GAAG;aACJ;SACF,CAAC;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;IAC9C,CAAC;CACF;AAlBD,4DAkBC"}
|
package/package.json
CHANGED
package/src/dto/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from './extKeyMap.dto';
|
|
|
9
9
|
export * from './findings.dto';
|
|
10
10
|
export * from './jwt';
|
|
11
11
|
export * from './message.dto';
|
|
12
|
+
export * from './notification.dto';
|
|
12
13
|
export * from './page.dto';
|
|
13
14
|
export * from './platform';
|
|
14
15
|
export * from './providers.dto';
|
|
@@ -20,3 +21,4 @@ export * from './saasUsers.dto';
|
|
|
20
21
|
export * from './ampSetting.dto';
|
|
21
22
|
export * from './tenants.dto';
|
|
22
23
|
export * from './users.dto';
|
|
24
|
+
export * from './workflow.dto';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {BaseDto} from './base.dto';
|
|
2
|
+
|
|
3
|
+
export type NotificationAddress = {
|
|
4
|
+
/** Connector ID for the notification channel */
|
|
5
|
+
cid: string;
|
|
6
|
+
/** Group IDs to which the notification is being sent */
|
|
7
|
+
groups?: string[] | number[];
|
|
8
|
+
/** User IDs to which the notification is being sent */
|
|
9
|
+
users?: string[] | number[];
|
|
10
|
+
/** Webhook URLs to which the notification is being sent */
|
|
11
|
+
webhooks?: string[];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type NotificationUpsertDto = {
|
|
15
|
+
/** Workflow ID for which the notification is being created */
|
|
16
|
+
wfid: string;
|
|
17
|
+
/** Finding ID for which the notification is being created */
|
|
18
|
+
fid?: string;
|
|
19
|
+
/** Recipient address to which the notification is being sent */
|
|
20
|
+
to: NotificationAddress;
|
|
21
|
+
/** ID of the template to use for the notification */
|
|
22
|
+
templateId: string;
|
|
23
|
+
/** ID o fthe user to which the notification is being sent */
|
|
24
|
+
uid: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type NotificationDto = NotificationUpsertDto & BaseDto;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import {NotificationDto, NotificationUpsertDto} from '../notification.dto';
|
|
2
|
+
import {TenantBased} from './tenant.based.dto';
|
|
3
|
+
|
|
4
|
+
export type PlatformNotificationUpsertDto = NotificationUpsertDto & TenantBased;
|
|
5
|
+
|
|
6
|
+
export type PlatformNotificationDto = NotificationDto & TenantBased;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import {WorkflowAssignmentUpsertDto} from '../workflowAssignment.dto';
|
|
2
|
+
import {TenantBased} from './tenant.based.dto';
|
|
3
|
+
|
|
4
|
+
export type PlatformWorkflowAssignmentUpsertDto = WorkflowAssignmentUpsertDto & TenantBased;
|
|
5
|
+
|
|
6
|
+
export type PlatformWorkflowAssignmentDto = PlatformWorkflowAssignmentUpsertDto & TenantBased;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {BaseDto} from './base.dto';
|
|
2
|
+
import {NotificationStepType} from './enums/notificationStep.type';
|
|
3
|
+
import {WorkflowTriggerType} from './enums/workflowTrigger.type';
|
|
4
|
+
|
|
5
|
+
export type NotificationStepData = {
|
|
6
|
+
/** Name of the device to which the notification of finding applies */
|
|
7
|
+
deviceName?: string;
|
|
8
|
+
/** Description of the notification of finding */
|
|
9
|
+
description?: string;
|
|
10
|
+
/** Due date associated with the finding */
|
|
11
|
+
dueDate?: string;
|
|
12
|
+
/** Name of the software to which the finding applies */
|
|
13
|
+
softwareName: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type PauseStepData = {
|
|
17
|
+
/** Estimated duration, in minutes, to resolve the finding */
|
|
18
|
+
duration: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type WorkflowStep = {
|
|
22
|
+
/** Number of the step in the workflow */
|
|
23
|
+
stepNumber: number;
|
|
24
|
+
/** Type of the notification step, either NOTIFICATION or PAUSE */
|
|
25
|
+
type: NotificationStepType;
|
|
26
|
+
/** ID of the template to be used for the notification */
|
|
27
|
+
templateId?: string;
|
|
28
|
+
/** Data associated with the notification step */
|
|
29
|
+
data: NotificationStepData | PauseStepData;
|
|
30
|
+
/** Step number to transition the workflow to on success */
|
|
31
|
+
successStepNumber: number | null;
|
|
32
|
+
/** Step number to transition the workflow to on failure */
|
|
33
|
+
failureStepNumber: number | null;
|
|
34
|
+
/** Duration, in days, to wait before executing the next step in the workflow */
|
|
35
|
+
pauseDuration?: number | null;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type WorkflowTriggerRule = {
|
|
39
|
+
[propName: string]:
|
|
40
|
+
| string
|
|
41
|
+
| number
|
|
42
|
+
| boolean
|
|
43
|
+
| null
|
|
44
|
+
| {
|
|
45
|
+
[propName: string]: string | number | boolean | WorkflowTriggerRule;
|
|
46
|
+
}
|
|
47
|
+
| WorkflowTriggerRule[];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type WorkflowTrigger = {
|
|
51
|
+
/** Type of the trigger */
|
|
52
|
+
type: WorkflowTriggerType;
|
|
53
|
+
/** Rule to which the applicable entity type must conform to trigger the workflow */
|
|
54
|
+
rule: unknown;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type WorkflowUpsertDto = {
|
|
58
|
+
/** Name of the workflow */
|
|
59
|
+
name: string;
|
|
60
|
+
/** Description of the workflow */
|
|
61
|
+
description?: string;
|
|
62
|
+
/** Trigger that begins execution of the workflow */
|
|
63
|
+
trigger: WorkflowTrigger;
|
|
64
|
+
/** Steps in the workflow */
|
|
65
|
+
steps?: WorkflowStep[];
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type WorkflowDto = BaseDto & WorkflowUpsertDto;
|
|
69
|
+
|
|
70
|
+
export type WorkflowProgressUpsertDto = {
|
|
71
|
+
/** ID of the workflow */
|
|
72
|
+
wfid: string;
|
|
73
|
+
/** ID of the finding for which the workflow is being executed */
|
|
74
|
+
fid?: string | null;
|
|
75
|
+
/** Step number to transition the workflow to next */
|
|
76
|
+
nextStep: number;
|
|
77
|
+
/** ID of the user for which the workflow is being executed */
|
|
78
|
+
uid: string | null;
|
|
79
|
+
/** whether or not this instance of the workflow has been completed */
|
|
80
|
+
workflowCompleted: boolean;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type WorkflowProgressDto = BaseDto & WorkflowProgressUpsertDto;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {BaseDto} from './base.dto';
|
|
2
|
+
|
|
3
|
+
export type WorkflowAssignmentUpsertDto = {
|
|
4
|
+
/** ID of the workflow */
|
|
5
|
+
wfid: string;
|
|
6
|
+
/** ID of the user to which the workflow is being assigned */
|
|
7
|
+
uid: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type WorkflowAssignmentDto = BaseDto & WorkflowAssignmentUpsertDto;
|
|
@@ -2,28 +2,34 @@ import {BaseDto, BaseUpsertDto, ExtKeyMap, Page} from '../dto';
|
|
|
2
2
|
import {TargetApi, TARGET_API_AGENT, ErrorHandler} from './constants';
|
|
3
3
|
import {AmpDataService, AmpDataServiceImpl} from './data.service';
|
|
4
4
|
import {RestClient, RestRequest} from './rest';
|
|
5
|
+
import {QueryMap} from './rest/utils';
|
|
6
|
+
|
|
7
|
+
export type EntityCallOptions = {
|
|
8
|
+
params: unknown;
|
|
9
|
+
};
|
|
5
10
|
|
|
6
11
|
export interface AmpEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
7
|
-
create(_model: WriteT): Promise<Page<ReadT>>;
|
|
8
|
-
update(_model: WriteT): Promise<Page<ReadT>>;
|
|
9
|
-
delete(_id: string): Promise<Page<ReadT>>;
|
|
12
|
+
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
13
|
+
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
14
|
+
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
10
15
|
}
|
|
16
|
+
|
|
11
17
|
export interface AmpSdkTenantService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
12
|
-
create(_model: WriteT): Promise<Page<ReadT>>;
|
|
13
|
-
update(_model: WriteT): Promise<Page<ReadT>>;
|
|
14
|
-
delete(_id: string,
|
|
18
|
+
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
19
|
+
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
20
|
+
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
15
21
|
}
|
|
16
22
|
export interface AmpGlobalEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
17
|
-
create(_model: WriteT): Promise<Page<ReadT>>;
|
|
18
|
-
update(_model: WriteT): Promise<Page<ReadT>>;
|
|
19
|
-
delete(_id: string): Promise<Page<ReadT>>;
|
|
20
|
-
getLookupIds(_tid: string): Promise<ExtKeyMap>;
|
|
23
|
+
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
24
|
+
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
25
|
+
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
26
|
+
getLookupIds(_tid: string, _options?: EntityCallOptions): Promise<ExtKeyMap>;
|
|
21
27
|
}
|
|
22
28
|
export interface AmpSaaSEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
23
|
-
create(_model: WriteT): Promise<Page<ReadT>>;
|
|
24
|
-
update(_model: WriteT): Promise<Page<ReadT>>;
|
|
25
|
-
delete(_id: string): Promise<Page<ReadT>>;
|
|
26
|
-
getLookupIds(_cid: string): Promise<ExtKeyMap>;
|
|
29
|
+
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
30
|
+
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
31
|
+
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
32
|
+
getLookupIds(_cid: string, _options?: EntityCallOptions): Promise<ExtKeyMap>;
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
export class AmpEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataServiceImpl<ReadT> implements AmpEntityService<WriteT, ReadT> {
|
|
@@ -31,29 +37,31 @@ export class AmpEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends Ba
|
|
|
31
37
|
super(rest, kind, targetApi);
|
|
32
38
|
}
|
|
33
39
|
|
|
34
|
-
create(model: WriteT): Promise<Page<ReadT>> {
|
|
40
|
+
create(model: WriteT, options?: EntityCallOptions): Promise<Page<ReadT>> {
|
|
35
41
|
return this.getPage({
|
|
36
42
|
url: `/${this.targetApi}/v1/${this.kind}`,
|
|
37
43
|
method: 'POST',
|
|
44
|
+
params: options?.params as QueryMap,
|
|
38
45
|
data: model,
|
|
39
46
|
});
|
|
40
47
|
}
|
|
41
48
|
|
|
42
|
-
update(model: WriteT): Promise<Page<ReadT>> {
|
|
49
|
+
update(model: WriteT, options?: EntityCallOptions): Promise<Page<ReadT>> {
|
|
43
50
|
return this.getPage({
|
|
44
51
|
url: `/${this.targetApi}/v1/${this.kind}/${model.id}`,
|
|
45
52
|
method: 'PUT',
|
|
53
|
+
params: options?.params as QueryMap,
|
|
46
54
|
data: model,
|
|
47
55
|
});
|
|
48
56
|
}
|
|
49
57
|
|
|
50
|
-
async delete(id: string,
|
|
58
|
+
async delete(id: string, options?: EntityCallOptions): Promise<Page<ReadT>> {
|
|
51
59
|
const res = await this.getById(id);
|
|
52
60
|
if (res.data.length === 1) {
|
|
53
61
|
const req: RestRequest = {
|
|
54
62
|
url: `/${this.targetApi}/v1/${this.kind}/${id}`,
|
|
55
63
|
method: 'DELETE',
|
|
56
|
-
params:
|
|
64
|
+
params: options?.params as QueryMap,
|
|
57
65
|
};
|
|
58
66
|
const {error} = await this.call(req, (error: unknown) => {
|
|
59
67
|
if (error instanceof Error) {
|
|
@@ -83,11 +91,14 @@ export class AmpGlobalEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT exte
|
|
|
83
91
|
constructor(rest: RestClient, kind: string, targetApi: TargetApi = TARGET_API_AGENT) {
|
|
84
92
|
super(rest, kind, targetApi);
|
|
85
93
|
}
|
|
86
|
-
getLookupIds(tid: string): Promise<ExtKeyMap> {
|
|
94
|
+
getLookupIds(tid: string, options?: EntityCallOptions): Promise<ExtKeyMap> {
|
|
87
95
|
const req: RestRequest = {
|
|
88
96
|
url: `/${this.targetApi}/v1/${this.kind}/ext_key_map`,
|
|
89
97
|
method: 'GET',
|
|
90
|
-
params: {
|
|
98
|
+
params: {
|
|
99
|
+
...((options?.params as QueryMap) ?? {}),
|
|
100
|
+
tid,
|
|
101
|
+
},
|
|
91
102
|
};
|
|
92
103
|
return this.call(req, extIdMapErrorHandler);
|
|
93
104
|
}
|
|
@@ -100,11 +111,14 @@ export class AmpSaaSEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extend
|
|
|
100
111
|
constructor(rest: RestClient, kind: string, targetApi: TargetApi = TARGET_API_AGENT) {
|
|
101
112
|
super(rest, kind, targetApi);
|
|
102
113
|
}
|
|
103
|
-
getLookupIds(cid: string): Promise<ExtKeyMap> {
|
|
114
|
+
getLookupIds(cid: string, options?: EntityCallOptions): Promise<ExtKeyMap> {
|
|
104
115
|
const req: RestRequest = {
|
|
105
116
|
url: `/${this.targetApi}/v1/${this.kind}/ext_key_map`,
|
|
106
117
|
method: 'GET',
|
|
107
|
-
params: {
|
|
118
|
+
params: {
|
|
119
|
+
...((options?.params as QueryMap) ?? {}),
|
|
120
|
+
cid,
|
|
121
|
+
},
|
|
108
122
|
};
|
|
109
123
|
return this.call(req, extIdMapErrorHandler);
|
|
110
124
|
}
|