@ampsec/platform-client 17.4.0 → 18.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/ampSetting.dto.d.ts +13 -0
- package/build/src/dto/ampSetting.dto.js +3 -0
- package/build/src/dto/ampSetting.dto.js.map +1 -0
- package/build/src/dto/enums/index.d.ts +1 -0
- package/build/src/dto/enums/index.js +1 -0
- package/build/src/dto/enums/index.js.map +1 -1
- package/build/src/dto/enums/riskContributor.type.d.ts +9 -0
- package/build/src/dto/enums/riskContributor.type.js +15 -0
- package/build/src/dto/enums/riskContributor.type.js.map +1 -0
- package/build/src/dto/index.d.ts +1 -0
- package/build/src/dto/index.js +1 -0
- package/build/src/dto/index.js.map +1 -1
- package/build/src/dto/platform/index.d.ts +1 -0
- package/build/src/dto/platform/index.js +1 -0
- package/build/src/dto/platform/index.js.map +1 -1
- package/build/src/dto/platform/platform.ampSetting.dto.d.ts +4 -0
- package/build/src/dto/platform/platform.ampSetting.dto.js +3 -0
- package/build/src/dto/platform/platform.ampSetting.dto.js.map +1 -0
- package/build/src/dto/riskContributors.dto.d.ts +3 -0
- package/build/src/dto/users.dto.d.ts +2 -2
- package/build/src/services/AmpApi.d.ts +2 -0
- package/build/src/services/AmpApi.js +2 -0
- package/build/src/services/AmpApi.js.map +1 -1
- package/build/src/services/AmpSdk.d.ts +2 -0
- package/build/src/services/AmpSdk.js +2 -0
- package/build/src/services/AmpSdk.js.map +1 -1
- package/build/src/services/index.d.ts +1 -0
- package/build/src/services/index.js +1 -0
- package/build/src/services/index.js.map +1 -1
- package/build/src/services/settings.service.d.ts +32 -0
- package/build/src/services/settings.service.js +98 -0
- package/build/src/services/settings.service.js.map +1 -0
- package/build/src/settings.d.ts +9 -0
- package/build/src/settings.js +26 -0
- package/build/src/settings.js.map +1 -0
- package/package.json +1 -1
- package/src/dto/ampSetting.dto.ts +16 -0
- package/src/dto/enums/index.ts +1 -0
- package/src/dto/enums/riskContributor.type.ts +10 -0
- package/src/dto/index.ts +1 -0
- package/src/dto/platform/index.ts +1 -0
- package/src/dto/platform/platform.ampSetting.dto.ts +6 -0
- package/src/dto/riskContributors.dto.ts +3 -0
- package/src/dto/users.dto.ts +2 -2
- package/src/services/AmpApi.ts +3 -0
- package/src/services/AmpSdk.ts +3 -0
- package/src/services/index.ts +1 -0
- package/src/services/settings.service.ts +118 -0
- package/src/settings.ts +29 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseDto, BaseUpsertDto } from './base.dto';
|
|
2
|
+
export type AmpSettingKey = string;
|
|
3
|
+
export type AmpSettingUpsertDto = BaseUpsertDto & {
|
|
4
|
+
/** Tenant ID */
|
|
5
|
+
tid: string;
|
|
6
|
+
/** Connector ID */
|
|
7
|
+
cid?: string;
|
|
8
|
+
/** Setting key */
|
|
9
|
+
key: AmpSettingKey;
|
|
10
|
+
/** Setting value */
|
|
11
|
+
value?: unknown;
|
|
12
|
+
};
|
|
13
|
+
export type AmpSettingDto = BaseDto & AmpSettingUpsertDto;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ampSetting.dto.js","sourceRoot":"","sources":["../../../src/dto/ampSetting.dto.ts"],"names":[],"mappings":""}
|
|
@@ -22,5 +22,6 @@ __exportStar(require("./findingKind"), exports);
|
|
|
22
22
|
__exportStar(require("./finding.severity"), exports);
|
|
23
23
|
__exportStar(require("./finding.status"), exports);
|
|
24
24
|
__exportStar(require("./jobExecution.status"), exports);
|
|
25
|
+
__exportStar(require("./riskContributor.type"), exports);
|
|
25
26
|
__exportStar(require("./saasComponentKind"), exports);
|
|
26
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/dto/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,iDAA+B;AAC/B,6CAA2B;AAC3B,qDAAmC;AACnC,gDAA8B;AAC9B,qDAAmC;AACnC,mDAAiC;AACjC,wDAAsC;AACtC,sDAAoC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/dto/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,iDAA+B;AAC/B,6CAA2B;AAC3B,qDAAmC;AACnC,gDAA8B;AAC9B,qDAAmC;AACnC,mDAAiC;AACjC,wDAAsC;AACtC,yDAAuC;AACvC,sDAAoC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RiskContributorType = void 0;
|
|
4
|
+
/* eslint-disable no-unused-vars */
|
|
5
|
+
var RiskContributorType;
|
|
6
|
+
(function (RiskContributorType) {
|
|
7
|
+
RiskContributorType["IS_EXECUTIVE"] = "IS_EXECUTIVE";
|
|
8
|
+
RiskContributorType["MFA"] = "MFA";
|
|
9
|
+
RiskContributorType["PRODUCTION_ACCESS"] = "PRODUCTION_ACCESS";
|
|
10
|
+
RiskContributorType["PRIVILEGED_ACCESS"] = "PRIVILEGED_ACCESS";
|
|
11
|
+
RiskContributorType["TOOLING"] = "TOOLING";
|
|
12
|
+
RiskContributorType["TRAINING"] = "TRAINING";
|
|
13
|
+
RiskContributorType["VULNERABILITY"] = "VULNERABILITY";
|
|
14
|
+
})(RiskContributorType || (exports.RiskContributorType = RiskContributorType = {}));
|
|
15
|
+
//# sourceMappingURL=riskContributor.type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"riskContributor.type.js","sourceRoot":"","sources":["../../../../src/dto/enums/riskContributor.type.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,mBAQX;AARD,WAAY,mBAAmB;IAC7B,oDAA6B,CAAA;IAC7B,kCAAW,CAAA;IACX,8DAAuC,CAAA;IACvC,8DAAuC,CAAA;IACvC,0CAAmB,CAAA;IACnB,4CAAqB,CAAA;IACrB,sDAA+B,CAAA;AACjC,CAAC,EARW,mBAAmB,mCAAnB,mBAAmB,QAQ9B"}
|
package/build/src/dto/index.d.ts
CHANGED
package/build/src/dto/index.js
CHANGED
|
@@ -32,6 +32,7 @@ __exportStar(require("./riskContributors.dto"), exports);
|
|
|
32
32
|
__exportStar(require("./saasAssets.dto"), exports);
|
|
33
33
|
__exportStar(require("./saasComponents.dto"), exports);
|
|
34
34
|
__exportStar(require("./saasUsers.dto"), exports);
|
|
35
|
+
__exportStar(require("./ampSetting.dto"), exports);
|
|
35
36
|
__exportStar(require("./tenants.dto"), exports);
|
|
36
37
|
__exportStar(require("./users.dto"), exports);
|
|
37
38
|
//# 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,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,gDAA8B;AAC9B,8CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,+CAA6B;AAC7B,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"}
|
|
@@ -9,6 +9,7 @@ export * from './platform.reportResults.dto';
|
|
|
9
9
|
export * from './platform.saasAssets.dto';
|
|
10
10
|
export * from './platform.saasComponents.dto';
|
|
11
11
|
export * from './platform.saasUsers.dto';
|
|
12
|
+
export * from './platform.ampSetting.dto';
|
|
12
13
|
export * from './platform.tenants.dto';
|
|
13
14
|
export * from './platform.users.dto';
|
|
14
15
|
export * from './tenant.based.dto';
|
|
@@ -25,6 +25,7 @@ __exportStar(require("./platform.reportResults.dto"), exports);
|
|
|
25
25
|
__exportStar(require("./platform.saasAssets.dto"), exports);
|
|
26
26
|
__exportStar(require("./platform.saasComponents.dto"), exports);
|
|
27
27
|
__exportStar(require("./platform.saasUsers.dto"), exports);
|
|
28
|
+
__exportStar(require("./platform.ampSetting.dto"), exports);
|
|
28
29
|
__exportStar(require("./platform.tenants.dto"), exports);
|
|
29
30
|
__exportStar(require("./platform.users.dto"), exports);
|
|
30
31
|
__exportStar(require("./tenant.based.dto"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/dto/platform/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,wDAAsC;AACtC,4DAA0C;AAC1C,0DAAwC;AACxC,mEAAiD;AACjD,yDAAuC;AACvC,2DAAyC;AACzC,+DAA6C;AAC7C,4DAA0C;AAC1C,gEAA8C;AAC9C,2DAAyC;AACzC,yDAAuC;AACvC,uDAAqC;AACrC,qDAAmC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/dto/platform/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,wDAAsC;AACtC,4DAA0C;AAC1C,0DAAwC;AACxC,mEAAiD;AACjD,yDAAuC;AACvC,2DAAyC;AACzC,+DAA6C;AAC7C,4DAA0C;AAC1C,gEAA8C;AAC9C,2DAAyC;AACzC,4DAA0C;AAC1C,yDAAuC;AACvC,uDAAqC;AACrC,qDAAmC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AmpSettingDto, AmpSettingUpsertDto } from '../ampSetting.dto';
|
|
2
|
+
import { TenantBased, UpsertTenantBased } from './tenant.based.dto';
|
|
3
|
+
export type PlatformAmpSettingUpsertDto = AmpSettingUpsertDto & UpsertTenantBased;
|
|
4
|
+
export type PlatformAmpSettingDto = AmpSettingDto & TenantBased;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.ampSetting.dto.js","sourceRoot":"","sources":["../../../../src/dto/platform/platform.ampSetting.dto.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { BaseDto, BaseUpsertDto } from './base.dto';
|
|
2
|
+
import { RiskContributorType } from './enums';
|
|
2
3
|
export type RiskContributorUpsertDto = BaseUpsertDto & {
|
|
4
|
+
/** Type of risk contributor */
|
|
5
|
+
type: RiskContributorType;
|
|
3
6
|
/** Short descriptor of the risk contributor, e.g. V, P, etc... */
|
|
4
7
|
displayValue: string;
|
|
5
8
|
/** Description of the risk contributor */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChangeAwareDto, ChangeAwareUpsertDto } from './base.dto';
|
|
2
2
|
import { MetricResults } from './reportResults.dto';
|
|
3
|
-
import {
|
|
3
|
+
import { RiskContributorUpsertDto } from './riskContributors.dto';
|
|
4
4
|
export type UserUpsertDto = ChangeAwareUpsertDto & {
|
|
5
5
|
/** Tenant ID */
|
|
6
6
|
tid: string;
|
|
@@ -23,7 +23,7 @@ export type UserUpsertDto = ChangeAwareUpsertDto & {
|
|
|
23
23
|
/** Employment start date used for calculating tenure */
|
|
24
24
|
startDate?: string;
|
|
25
25
|
/** Risk Contributors associated with the user */
|
|
26
|
-
riskContributors:
|
|
26
|
+
riskContributors: RiskContributorUpsertDto[];
|
|
27
27
|
/** Metrics associated with the user */
|
|
28
28
|
metrics?: MetricResults;
|
|
29
29
|
};
|
|
@@ -4,6 +4,7 @@ import { AmpDataService } from './data.service';
|
|
|
4
4
|
import { AmpRestClientOptions, RestClient } from './rest';
|
|
5
5
|
import { AmpReportService } from './reports.service';
|
|
6
6
|
import { EnumService } from './rest/EnumService';
|
|
7
|
+
import { AmpSettingsService } from './settings.service';
|
|
7
8
|
export type AmpApiOptions = AmpRestClientOptions;
|
|
8
9
|
/**
|
|
9
10
|
* AMP API
|
|
@@ -29,6 +30,7 @@ export declare class AmpApi {
|
|
|
29
30
|
readonly saasAssets: AmpDataService<SaasAssetDto>;
|
|
30
31
|
readonly saasComponents: AmpDataService<SaasComponentDto>;
|
|
31
32
|
readonly saasUsers: AmpDataService<SaasUserDto>;
|
|
33
|
+
readonly settings: AmpSettingsService;
|
|
32
34
|
readonly tenants: AmpEntityService<TenantUpsertDto, TenantDto>;
|
|
33
35
|
readonly users: AmpDataService<UserDto>;
|
|
34
36
|
constructor(rest: RestClient);
|
|
@@ -7,6 +7,7 @@ const rest_1 = require("./rest");
|
|
|
7
7
|
const constants_1 = require("./constants");
|
|
8
8
|
const reports_service_1 = require("./reports.service");
|
|
9
9
|
const EnumService_1 = require("./rest/EnumService");
|
|
10
|
+
const settings_service_1 = require("./settings.service");
|
|
10
11
|
/**
|
|
11
12
|
* AMP API
|
|
12
13
|
* This client is a wrapper around the AMP REST API meant to be used by
|
|
@@ -32,6 +33,7 @@ class AmpApi {
|
|
|
32
33
|
this.saasAssets = new data_service_1.AmpDataServiceImpl(rest, constants_1.KIND.SAAS_ASSETS);
|
|
33
34
|
this.saasComponents = new data_service_1.AmpDataServiceImpl(rest, constants_1.KIND.SAAS_COMPONENTS);
|
|
34
35
|
this.saasUsers = new data_service_1.AmpDataServiceImpl(rest, constants_1.KIND.SAAS_USERS);
|
|
36
|
+
this.settings = new settings_service_1.AmpSettingsService(rest);
|
|
35
37
|
this.tenants = new entity_service_1.AmpEntityServiceImpl(rest, constants_1.KIND.TENANTS);
|
|
36
38
|
this.users = new data_service_1.AmpDataServiceImpl(rest, constants_1.KIND.USERS);
|
|
37
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmpApi.js","sourceRoot":"","sources":["../../../src/services/AmpApi.ts"],"names":[],"mappings":";;;AAgBA,qDAAwE;AACxE,iDAAkE;AAClE,iCAA0E;AAC1E,2CAAiC;AACjC,uDAAyE;AACzE,oDAAmE;
|
|
1
|
+
{"version":3,"file":"AmpApi.js","sourceRoot":"","sources":["../../../src/services/AmpApi.ts"],"names":[],"mappings":";;;AAgBA,qDAAwE;AACxE,iDAAkE;AAClE,iCAA0E;AAC1E,2CAAiC;AACjC,uDAAyE;AACzE,oDAAmE;AACnE,yDAAsD;AAItD;;;;;;;;;;;GAWG;AACH,MAAa,MAAM;IAgBjB,YAAY,IAAgB;QAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,qCAAoB,CAA2B,IAAI,EAAE,gBAAI,CAAC,MAAM,CAAC,CAAC;QACpF,IAAI,CAAC,KAAK,GAAG,IAAI,iCAAkB,CAAW,IAAI,EAAE,gBAAI,CAAC,MAAM,CAAC,CAAC;QACjE,IAAI,CAAC,UAAU,GAAG,IAAI,qCAAoB,CAAmC,IAAI,EAAE,gBAAI,CAAC,UAAU,CAAC,CAAC;QACpG,IAAI,CAAC,KAAK,GAAG,IAAI,gCAAkB,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,IAAI,iCAAkB,CAAa,IAAI,EAAE,gBAAI,CAAC,QAAQ,CAAC,CAAC;QACxE,IAAI,CAAC,SAAS,GAAG,IAAI,iCAAkB,CAAc,IAAI,EAAE,gBAAI,CAAC,SAAS,CAAC,CAAC;QAC3E,IAAI,CAAC,aAAa,GAAG,IAAI,iCAAkB,CAAkB,IAAI,EAAE,gBAAI,CAAC,cAAc,CAAC,CAAC;QACxF,IAAI,CAAC,OAAO,GAAG,IAAI,sCAAoB,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,UAAU,GAAG,IAAI,iCAAkB,CAAe,IAAI,EAAE,gBAAI,CAAC,WAAW,CAAC,CAAC;QAC/E,IAAI,CAAC,cAAc,GAAG,IAAI,iCAAkB,CAAmB,IAAI,EAAE,gBAAI,CAAC,eAAe,CAAC,CAAC;QAC3F,IAAI,CAAC,SAAS,GAAG,IAAI,iCAAkB,CAAc,IAAI,EAAE,gBAAI,CAAC,UAAU,CAAC,CAAC;QAC5E,IAAI,CAAC,QAAQ,GAAG,IAAI,qCAAkB,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,qCAAoB,CAA6B,IAAI,EAAE,gBAAI,CAAC,OAAO,CAAC,CAAC;QACxF,IAAI,CAAC,KAAK,GAAG,IAAI,iCAAkB,CAAU,IAAI,EAAE,gBAAI,CAAC,KAAK,CAAC,CAAC;IACjE,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;AArCD,wBAqCC"}
|
|
@@ -4,6 +4,7 @@ import { AmpRestClientOptions, RestClient } from './rest';
|
|
|
4
4
|
import { PlatformJobSpecDto, PlatformJobSpecUpsertDto } from '../dto/platform/platform.jobSpec.dto';
|
|
5
5
|
import { PlatformJobExecutionStateDto, PlatformJobExecutionStateUpsertDto } from '../dto/platform/platform.jobExecutionState.dto';
|
|
6
6
|
import { EnumService } from './rest/EnumService';
|
|
7
|
+
import { AmpSettingsService } from './settings.service';
|
|
7
8
|
export type AmpSdkOptions = AmpRestClientOptions;
|
|
8
9
|
/**
|
|
9
10
|
* AMP API
|
|
@@ -27,6 +28,7 @@ export declare class AmpSdkServices {
|
|
|
27
28
|
readonly saasAssets: AmpSaaSEntityService<PlatformSaasAssetUpsertDto, PlatformSaasAssetDto>;
|
|
28
29
|
readonly saasComponents: AmpSaaSEntityService<PlatformSaasComponentUpsertDto, PlatformSaasComponentDto>;
|
|
29
30
|
readonly saasUsers: AmpSaaSEntityService<PlatformSaasUserUpsertDto, PlatformSaasUserDto>;
|
|
31
|
+
readonly settings: AmpSettingsService;
|
|
30
32
|
readonly tenants: AmpEntityService<TenantUpsertDto, TenantDto>;
|
|
31
33
|
readonly users: AmpGlobalEntityService<PlatformUserUpsertDto, PlatformUserDto>;
|
|
32
34
|
constructor(rest: RestClient);
|
|
@@ -5,6 +5,7 @@ const entity_service_1 = require("./entity.service");
|
|
|
5
5
|
const rest_1 = require("./rest");
|
|
6
6
|
const constants_1 = require("./constants");
|
|
7
7
|
const EnumService_1 = require("./rest/EnumService");
|
|
8
|
+
const settings_service_1 = require("./settings.service");
|
|
8
9
|
/**
|
|
9
10
|
* AMP API
|
|
10
11
|
* This client is a wrapper around the AMP REST API meant to be used by
|
|
@@ -28,6 +29,7 @@ class AmpSdkServices {
|
|
|
28
29
|
this.saasAssets = new entity_service_1.AmpSaaSEntityServiceImpl(rest, constants_1.KIND.SAAS_ASSETS, constants_1.TARGET_API_PLATFORM);
|
|
29
30
|
this.saasComponents = new entity_service_1.AmpSaaSEntityServiceImpl(rest, constants_1.KIND.SAAS_COMPONENTS, constants_1.TARGET_API_PLATFORM);
|
|
30
31
|
this.saasUsers = new entity_service_1.AmpSaaSEntityServiceImpl(rest, constants_1.KIND.SAAS_USERS, constants_1.TARGET_API_PLATFORM);
|
|
32
|
+
this.settings = new settings_service_1.AmpSettingsService(rest, constants_1.TARGET_API_PLATFORM);
|
|
31
33
|
this.tenants = new entity_service_1.AmpEntityServiceImpl(rest, constants_1.KIND.TENANTS, constants_1.TARGET_API_PLATFORM);
|
|
32
34
|
this.users = new entity_service_1.AmpGlobalEntityServiceImpl(rest, constants_1.KIND.USERS, constants_1.TARGET_API_PLATFORM);
|
|
33
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmpSdk.js","sourceRoot":"","sources":["../../../src/services/AmpSdk.ts"],"names":[],"mappings":";;;AAwBA,qDAA4K;AAC5K,iCAA0E;AAC1E,2CAAsD;AAGtD,oDAAmE;
|
|
1
|
+
{"version":3,"file":"AmpSdk.js","sourceRoot":"","sources":["../../../src/services/AmpSdk.ts"],"names":[],"mappings":";;;AAwBA,qDAA4K;AAC5K,iCAA0E;AAC1E,2CAAsD;AAGtD,oDAAmE;AACnE,yDAAsD;AAItD;;;;;;;;GAQG;AACH,MAAa,cAAc;IAiBzB,YAAY,IAAgB;QAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,qCAAoB,CAA2C,IAAI,EAAE,gBAAI,CAAC,MAAM,EAAE,+BAAmB,CAAC,CAAC;QACzH,IAAI,CAAC,KAAK,GAAG,IAAI,2CAA0B,CAA2C,IAAI,EAAE,gBAAI,CAAC,MAAM,EAAE,+BAAmB,CAAC,CAAC;QAC9H,IAAI,CAAC,UAAU,GAAG,IAAI,qCAAoB,CAAmD,IAAI,EAAE,gBAAI,CAAC,UAAU,EAAE,+BAAmB,CAAC,CAAC;QACzI,IAAI,CAAC,KAAK,GAAG,IAAI,gCAAkB,CAAC,IAAI,EAAE,+BAAmB,CAAC,CAAC;QAC/D,IAAI,CAAC,QAAQ,GAAG,IAAI,yCAAwB,CAA+C,IAAI,EAAE,gBAAI,CAAC,QAAQ,EAAE,+BAAmB,CAAC,CAAC;QACrI,IAAI,CAAC,aAAa,GAAG,IAAI,qCAAoB,CAAmE,IAAI,EAAE,gBAAI,CAAC,cAAc,EAAE,+BAAmB,CAAC,CAAC;QAChK,IAAI,CAAC,IAAI,GAAG,IAAI,qCAAoB,CAA+C,IAAI,EAAE,gBAAI,CAAC,QAAQ,EAAE,+BAAmB,CAAC,CAAC;QAC7H,IAAI,CAAC,SAAS,GAAG,IAAI,qCAAoB,CAAyC,IAAI,EAAE,gBAAI,CAAC,SAAS,EAAE,+BAAmB,CAAC,CAAC;QAC7H,IAAI,CAAC,aAAa,GAAG,IAAI,yCAAwB,CAAyD,IAAI,EAAE,gBAAI,CAAC,cAAc,EAAE,+BAAmB,CAAC,CAAC;QAC1J,IAAI,CAAC,UAAU,GAAG,IAAI,yCAAwB,CAAmD,IAAI,EAAE,gBAAI,CAAC,WAAW,EAAE,+BAAmB,CAAC,CAAC;QAC9I,IAAI,CAAC,cAAc,GAAG,IAAI,yCAAwB,CAA2D,IAAI,EAAE,gBAAI,CAAC,eAAe,EAAE,+BAAmB,CAAC,CAAC;QAC9J,IAAI,CAAC,SAAS,GAAG,IAAI,yCAAwB,CAAiD,IAAI,EAAE,gBAAI,CAAC,UAAU,EAAE,+BAAmB,CAAC,CAAC;QAC1I,IAAI,CAAC,QAAQ,GAAG,IAAI,qCAAkB,CAAC,IAAI,EAAE,+BAAmB,CAAC,CAAC;QAClE,IAAI,CAAC,OAAO,GAAG,IAAI,qCAAoB,CAA6B,IAAI,EAAE,gBAAI,CAAC,OAAO,EAAE,+BAAmB,CAAC,CAAC;QAC7G,IAAI,CAAC,KAAK,GAAG,IAAI,2CAA0B,CAAyC,IAAI,EAAE,gBAAI,CAAC,KAAK,EAAE,+BAAmB,CAAC,CAAC;IAC7H,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;AAvCD,wCAuCC"}
|
|
@@ -20,4 +20,5 @@ __exportStar(require("./constants"), exports);
|
|
|
20
20
|
__exportStar(require("./data.service"), exports);
|
|
21
21
|
__exportStar(require("./entity.service"), exports);
|
|
22
22
|
__exportStar(require("./rest"), exports);
|
|
23
|
+
__exportStar(require("./settings.service"), exports);
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,8CAA4B;AAC5B,iDAA+B;AAC/B,mDAAiC;AACjC,yCAAuB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,8CAA4B;AAC5B,iDAA+B;AAC/B,mDAAiC;AACjC,yCAAuB;AACvB,qDAAmC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AmpSettingDto, AmpSettingUpsertDto, AmpSettingKey } from '../dto/ampSetting.dto';
|
|
2
|
+
import { RestClient } from './rest';
|
|
3
|
+
import { TargetApi } from './constants';
|
|
4
|
+
export type TypedAmpSettingsKey<T> = {
|
|
5
|
+
id: AmpSettingKey;
|
|
6
|
+
defaultValue: T;
|
|
7
|
+
};
|
|
8
|
+
export type RawAmpSettingsMap = {
|
|
9
|
+
[key: AmpSettingKey]: unknown;
|
|
10
|
+
};
|
|
11
|
+
export type TenantSettingsMap = {
|
|
12
|
+
tenantSettings: RawAmpSettingsMap;
|
|
13
|
+
connectorSettings: {
|
|
14
|
+
[cid: string]: RawAmpSettingsMap;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare class AmpSettingsService {
|
|
18
|
+
protected readonly rest: RestClient;
|
|
19
|
+
protected readonly targetApi: string;
|
|
20
|
+
constructor(rest: RestClient, targetApi?: TargetApi);
|
|
21
|
+
getSettingsMap(tid?: string): Promise<AmpSettingsMap>;
|
|
22
|
+
create<T>(key: TypedAmpSettingsKey<T>, value: T, tid: string, cid?: string): Promise<AmpSettingDto>;
|
|
23
|
+
update(id: string, entity: AmpSettingUpsertDto): Promise<AmpSettingDto>;
|
|
24
|
+
}
|
|
25
|
+
export declare class AmpSettingsMap {
|
|
26
|
+
private readonly settings;
|
|
27
|
+
constructor(settings: TenantSettingsMap);
|
|
28
|
+
getGlobalSetting<T>(key: TypedAmpSettingsKey<T>): T;
|
|
29
|
+
getConnectorSetting<T>(cid: string, key: TypedAmpSettingsKey<T>): T;
|
|
30
|
+
getConnectorSettings(cid: string): RawAmpSettingsMap | undefined;
|
|
31
|
+
static asKey<T>(key: AmpSettingKey, defaultValue: T): TypedAmpSettingsKey<T>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AmpSettingsMap = exports.AmpSettingsService = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
class AmpSettingsService {
|
|
9
|
+
constructor(rest, targetApi = 'api') {
|
|
10
|
+
this.rest = rest;
|
|
11
|
+
this.targetApi = targetApi;
|
|
12
|
+
}
|
|
13
|
+
async getSettingsMap(tid) {
|
|
14
|
+
const page = await this.rest.call({
|
|
15
|
+
url: `/${this.targetApi}/v1/settings`,
|
|
16
|
+
method: 'GET',
|
|
17
|
+
params: { tid },
|
|
18
|
+
});
|
|
19
|
+
const settings = page.data;
|
|
20
|
+
const rawSettingsMap = {
|
|
21
|
+
tenantSettings: {},
|
|
22
|
+
connectorSettings: {},
|
|
23
|
+
};
|
|
24
|
+
settings.forEach(setting => {
|
|
25
|
+
if (setting.cid) {
|
|
26
|
+
if (!rawSettingsMap.connectorSettings[setting.cid]) {
|
|
27
|
+
rawSettingsMap.connectorSettings[setting.cid] = {};
|
|
28
|
+
}
|
|
29
|
+
rawSettingsMap.connectorSettings[setting.cid][setting.key] = setting.value;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
rawSettingsMap.tenantSettings[setting.key] = setting.value;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return new AmpSettingsMap(rawSettingsMap);
|
|
36
|
+
}
|
|
37
|
+
async create(key, value, tid, cid) {
|
|
38
|
+
const page = await this.rest.call({
|
|
39
|
+
url: `/${this.targetApi}/v1/settings`,
|
|
40
|
+
method: 'POST',
|
|
41
|
+
data: {
|
|
42
|
+
tid,
|
|
43
|
+
cid,
|
|
44
|
+
key,
|
|
45
|
+
value,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
const settings = page.data;
|
|
49
|
+
return settings[0];
|
|
50
|
+
}
|
|
51
|
+
async update(id, entity) {
|
|
52
|
+
const page = await this.rest.call({
|
|
53
|
+
url: `/${this.targetApi}/v1/settings/${id}`,
|
|
54
|
+
method: 'PUT',
|
|
55
|
+
data: entity,
|
|
56
|
+
});
|
|
57
|
+
const settings = page.data;
|
|
58
|
+
return settings[0];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.AmpSettingsService = AmpSettingsService;
|
|
62
|
+
class AmpSettingsMap {
|
|
63
|
+
constructor(settings) {
|
|
64
|
+
this.settings = settings;
|
|
65
|
+
}
|
|
66
|
+
getGlobalSetting(key) {
|
|
67
|
+
const tenantVal = this.settings.tenantSettings[key.id];
|
|
68
|
+
if (tenantVal) {
|
|
69
|
+
return tenantVal;
|
|
70
|
+
}
|
|
71
|
+
return key.defaultValue;
|
|
72
|
+
}
|
|
73
|
+
getConnectorSetting(cid, key) {
|
|
74
|
+
const tenantVal = this.settings.tenantSettings[key.id];
|
|
75
|
+
const connectorVal = this.settings.connectorSettings[cid][key.id];
|
|
76
|
+
if (connectorVal) {
|
|
77
|
+
return connectorVal;
|
|
78
|
+
}
|
|
79
|
+
if (tenantVal) {
|
|
80
|
+
return tenantVal;
|
|
81
|
+
}
|
|
82
|
+
return key.defaultValue;
|
|
83
|
+
}
|
|
84
|
+
getConnectorSettings(cid) {
|
|
85
|
+
if (!this.settings.connectorSettings[cid]) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
return lodash_1.default.clone(this.settings.connectorSettings[cid]);
|
|
89
|
+
}
|
|
90
|
+
static asKey(key, defaultValue) {
|
|
91
|
+
return {
|
|
92
|
+
id: key,
|
|
93
|
+
defaultValue,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.AmpSettingsMap = AmpSettingsMap;
|
|
98
|
+
//# sourceMappingURL=settings.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.service.js","sourceRoot":"","sources":["../../../src/services/settings.service.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const NOTIFICATIONS_ENALBED: import("./services").TypedAmpSettingsKey<boolean>;
|
|
2
|
+
/********************
|
|
3
|
+
* PROVIDERS *
|
|
4
|
+
********************/
|
|
5
|
+
export declare const SLACK_EXECUTIVE_GROUPS: import("./services").TypedAmpSettingsKey<string[]>;
|
|
6
|
+
export declare const SLACK_PROD_ACCESS_GROUPS: import("./services").TypedAmpSettingsKey<string[]>;
|
|
7
|
+
export declare const SLACK_PRIV_ACCESS_GROUPS: import("./services").TypedAmpSettingsKey<string[]>;
|
|
8
|
+
export declare const SLACK_CONTACT_SECURITY_CHANNEL: import("./services").TypedAmpSettingsKey<string>;
|
|
9
|
+
export declare const SLACK_CONTACT_SECURITY_TEMPLATE: import("./services").TypedAmpSettingsKey<string>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SLACK_CONTACT_SECURITY_TEMPLATE = exports.SLACK_CONTACT_SECURITY_CHANNEL = exports.SLACK_PRIV_ACCESS_GROUPS = exports.SLACK_PROD_ACCESS_GROUPS = exports.SLACK_EXECUTIVE_GROUPS = exports.NOTIFICATIONS_ENALBED = void 0;
|
|
4
|
+
const services_1 = require("./services");
|
|
5
|
+
/*
|
|
6
|
+
* GLOBAL ONLY
|
|
7
|
+
* TODO:
|
|
8
|
+
*/
|
|
9
|
+
/*
|
|
10
|
+
* GLOBAL
|
|
11
|
+
* Note: these can be overridden by connector level settings
|
|
12
|
+
*/
|
|
13
|
+
exports.NOTIFICATIONS_ENALBED = services_1.AmpSettingsMap.asKey('notifications.enabled', false); // TODO: enble by default
|
|
14
|
+
/********************
|
|
15
|
+
* PROVIDERS *
|
|
16
|
+
********************/
|
|
17
|
+
/*
|
|
18
|
+
* SLACK
|
|
19
|
+
*/
|
|
20
|
+
exports.SLACK_EXECUTIVE_GROUPS = services_1.AmpSettingsMap.asKey('slack.executive.groups', []);
|
|
21
|
+
exports.SLACK_PROD_ACCESS_GROUPS = services_1.AmpSettingsMap.asKey('slack.prod_access.groups', []);
|
|
22
|
+
exports.SLACK_PRIV_ACCESS_GROUPS = services_1.AmpSettingsMap.asKey('slack.priv_access.groups', []);
|
|
23
|
+
exports.SLACK_CONTACT_SECURITY_CHANNEL = services_1.AmpSettingsMap.asKey('slack.contact_security.channel', '');
|
|
24
|
+
// TODO: localization
|
|
25
|
+
exports.SLACK_CONTACT_SECURITY_TEMPLATE = services_1.AmpSettingsMap.asKey('slack.contact_security.template', 'Thanks for getting in touch! We forwarded your message to our security team and they will get back to you shortly.');
|
|
26
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/settings.ts"],"names":[],"mappings":";;;AAAA,yCAA0C;AAE1C;;;GAGG;AAEH;;;GAGG;AACU,QAAA,qBAAqB,GAAG,yBAAc,CAAC,KAAK,CAAU,uBAAuB,EAAE,KAAK,CAAC,CAAC,CAAC,yBAAyB;AAE7H;;sBAEsB;AAEtB;;GAEG;AACU,QAAA,sBAAsB,GAAG,yBAAc,CAAC,KAAK,CAAW,wBAAwB,EAAE,EAAE,CAAC,CAAC;AACtF,QAAA,wBAAwB,GAAG,yBAAc,CAAC,KAAK,CAAW,0BAA0B,EAAE,EAAE,CAAC,CAAC;AAC1F,QAAA,wBAAwB,GAAG,yBAAc,CAAC,KAAK,CAAW,0BAA0B,EAAE,EAAE,CAAC,CAAC;AAC1F,QAAA,8BAA8B,GAAG,yBAAc,CAAC,KAAK,CAAS,gCAAgC,EAAE,EAAE,CAAC,CAAC;AACjH,qBAAqB;AACR,QAAA,+BAA+B,GAAG,yBAAc,CAAC,KAAK,CACjE,iCAAiC,EACjC,oHAAoH,CACrH,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {BaseDto, BaseUpsertDto} from './base.dto';
|
|
2
|
+
|
|
3
|
+
export type AmpSettingKey = string;
|
|
4
|
+
|
|
5
|
+
export type AmpSettingUpsertDto = BaseUpsertDto & {
|
|
6
|
+
/** Tenant ID */
|
|
7
|
+
tid: string;
|
|
8
|
+
/** Connector ID */
|
|
9
|
+
cid?: string;
|
|
10
|
+
/** Setting key */
|
|
11
|
+
key: AmpSettingKey;
|
|
12
|
+
/** Setting value */
|
|
13
|
+
value?: unknown;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type AmpSettingDto = BaseDto & AmpSettingUpsertDto;
|
package/src/dto/enums/index.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
export enum RiskContributorType {
|
|
3
|
+
IS_EXECUTIVE = 'IS_EXECUTIVE',
|
|
4
|
+
MFA = 'MFA',
|
|
5
|
+
PRODUCTION_ACCESS = 'PRODUCTION_ACCESS',
|
|
6
|
+
PRIVILEGED_ACCESS = 'PRIVILEGED_ACCESS',
|
|
7
|
+
TOOLING = 'TOOLING',
|
|
8
|
+
TRAINING = 'TRAINING',
|
|
9
|
+
VULNERABILITY = 'VULNERABILITY',
|
|
10
|
+
}
|
package/src/dto/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from './platform.reportResults.dto';
|
|
|
9
9
|
export * from './platform.saasAssets.dto';
|
|
10
10
|
export * from './platform.saasComponents.dto';
|
|
11
11
|
export * from './platform.saasUsers.dto';
|
|
12
|
+
export * from './platform.ampSetting.dto';
|
|
12
13
|
export * from './platform.tenants.dto';
|
|
13
14
|
export * from './platform.users.dto';
|
|
14
15
|
export * from './tenant.based.dto';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import {AmpSettingDto, AmpSettingUpsertDto} from '../ampSetting.dto';
|
|
2
|
+
import {TenantBased, UpsertTenantBased} from './tenant.based.dto';
|
|
3
|
+
|
|
4
|
+
export type PlatformAmpSettingUpsertDto = AmpSettingUpsertDto & UpsertTenantBased;
|
|
5
|
+
|
|
6
|
+
export type PlatformAmpSettingDto = AmpSettingDto & TenantBased;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {BaseDto, BaseUpsertDto} from './base.dto';
|
|
2
|
+
import {RiskContributorType} from './enums';
|
|
2
3
|
|
|
3
4
|
export type RiskContributorUpsertDto = BaseUpsertDto & {
|
|
5
|
+
/** Type of risk contributor */
|
|
6
|
+
type: RiskContributorType;
|
|
4
7
|
/** Short descriptor of the risk contributor, e.g. V, P, etc... */
|
|
5
8
|
displayValue: string;
|
|
6
9
|
/** Description of the risk contributor */
|
package/src/dto/users.dto.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {ChangeAwareDto, ChangeAwareUpsertDto} from './base.dto';
|
|
2
2
|
import {MetricResults} from './reportResults.dto';
|
|
3
|
-
import {
|
|
3
|
+
import {RiskContributorUpsertDto} from './riskContributors.dto';
|
|
4
4
|
|
|
5
5
|
export type UserUpsertDto = ChangeAwareUpsertDto & {
|
|
6
6
|
/** Tenant ID */
|
|
@@ -24,7 +24,7 @@ export type UserUpsertDto = ChangeAwareUpsertDto & {
|
|
|
24
24
|
/** Employment start date used for calculating tenure */
|
|
25
25
|
startDate?: string;
|
|
26
26
|
/** Risk Contributors associated with the user */
|
|
27
|
-
riskContributors:
|
|
27
|
+
riskContributors: RiskContributorUpsertDto[];
|
|
28
28
|
/** Metrics associated with the user */
|
|
29
29
|
metrics?: MetricResults;
|
|
30
30
|
};
|
package/src/services/AmpApi.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {AmpRestClientOptions, RestClient, getAmpRestClient} from './rest';
|
|
|
20
20
|
import {KIND} from './constants';
|
|
21
21
|
import {AmpReportService, AmpReportServiceImpl} from './reports.service';
|
|
22
22
|
import {DefaultEnumService, EnumService} from './rest/EnumService';
|
|
23
|
+
import {AmpSettingsService} from './settings.service';
|
|
23
24
|
|
|
24
25
|
export type AmpApiOptions = AmpRestClientOptions;
|
|
25
26
|
|
|
@@ -47,6 +48,7 @@ export class AmpApi {
|
|
|
47
48
|
readonly saasAssets: AmpDataService<SaasAssetDto>;
|
|
48
49
|
readonly saasComponents: AmpDataService<SaasComponentDto>;
|
|
49
50
|
readonly saasUsers: AmpDataService<SaasUserDto>;
|
|
51
|
+
readonly settings: AmpSettingsService;
|
|
50
52
|
readonly tenants: AmpEntityService<TenantUpsertDto, TenantDto>;
|
|
51
53
|
readonly users: AmpDataService<UserDto>;
|
|
52
54
|
|
|
@@ -62,6 +64,7 @@ export class AmpApi {
|
|
|
62
64
|
this.saasAssets = new AmpDataServiceImpl<SaasAssetDto>(rest, KIND.SAAS_ASSETS);
|
|
63
65
|
this.saasComponents = new AmpDataServiceImpl<SaasComponentDto>(rest, KIND.SAAS_COMPONENTS);
|
|
64
66
|
this.saasUsers = new AmpDataServiceImpl<SaasUserDto>(rest, KIND.SAAS_USERS);
|
|
67
|
+
this.settings = new AmpSettingsService(rest);
|
|
65
68
|
this.tenants = new AmpEntityServiceImpl<TenantUpsertDto, TenantDto>(rest, KIND.TENANTS);
|
|
66
69
|
this.users = new AmpDataServiceImpl<UserDto>(rest, KIND.USERS);
|
|
67
70
|
}
|
package/src/services/AmpSdk.ts
CHANGED
|
@@ -28,6 +28,7 @@ import {KIND, TARGET_API_PLATFORM} from './constants';
|
|
|
28
28
|
import {PlatformJobSpecDto, PlatformJobSpecUpsertDto} from '../dto/platform/platform.jobSpec.dto';
|
|
29
29
|
import {PlatformJobExecutionStateDto, PlatformJobExecutionStateUpsertDto} from '../dto/platform/platform.jobExecutionState.dto';
|
|
30
30
|
import {DefaultEnumService, EnumService} from './rest/EnumService';
|
|
31
|
+
import {AmpSettingsService} from './settings.service';
|
|
31
32
|
|
|
32
33
|
export type AmpSdkOptions = AmpRestClientOptions;
|
|
33
34
|
|
|
@@ -53,6 +54,7 @@ export class AmpSdkServices {
|
|
|
53
54
|
readonly saasAssets: AmpSaaSEntityService<PlatformSaasAssetUpsertDto, PlatformSaasAssetDto>;
|
|
54
55
|
readonly saasComponents: AmpSaaSEntityService<PlatformSaasComponentUpsertDto, PlatformSaasComponentDto>;
|
|
55
56
|
readonly saasUsers: AmpSaaSEntityService<PlatformSaasUserUpsertDto, PlatformSaasUserDto>;
|
|
57
|
+
readonly settings: AmpSettingsService;
|
|
56
58
|
readonly tenants: AmpEntityService<TenantUpsertDto, TenantDto>;
|
|
57
59
|
readonly users: AmpGlobalEntityService<PlatformUserUpsertDto, PlatformUserDto>;
|
|
58
60
|
|
|
@@ -69,6 +71,7 @@ export class AmpSdkServices {
|
|
|
69
71
|
this.saasAssets = new AmpSaaSEntityServiceImpl<PlatformSaasAssetUpsertDto, PlatformSaasAssetDto>(rest, KIND.SAAS_ASSETS, TARGET_API_PLATFORM);
|
|
70
72
|
this.saasComponents = new AmpSaaSEntityServiceImpl<PlatformSaasComponentUpsertDto, PlatformSaasComponentDto>(rest, KIND.SAAS_COMPONENTS, TARGET_API_PLATFORM);
|
|
71
73
|
this.saasUsers = new AmpSaaSEntityServiceImpl<PlatformSaasUserUpsertDto, PlatformSaasUserDto>(rest, KIND.SAAS_USERS, TARGET_API_PLATFORM);
|
|
74
|
+
this.settings = new AmpSettingsService(rest, TARGET_API_PLATFORM);
|
|
72
75
|
this.tenants = new AmpEntityServiceImpl<TenantUpsertDto, TenantDto>(rest, KIND.TENANTS, TARGET_API_PLATFORM);
|
|
73
76
|
this.users = new AmpGlobalEntityServiceImpl<PlatformUserUpsertDto, PlatformUserDto>(rest, KIND.USERS, TARGET_API_PLATFORM);
|
|
74
77
|
}
|
package/src/services/index.ts
CHANGED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import {AmpSettingDto, AmpSettingUpsertDto, AmpSettingKey} from '../dto/ampSetting.dto';
|
|
3
|
+
import {RestClient} from './rest';
|
|
4
|
+
import {TargetApi} from './constants';
|
|
5
|
+
|
|
6
|
+
export type TypedAmpSettingsKey<T> = {
|
|
7
|
+
id: AmpSettingKey;
|
|
8
|
+
defaultValue: T;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type RawAmpSettingsMap = {[key: AmpSettingKey]: unknown};
|
|
12
|
+
|
|
13
|
+
export type TenantSettingsMap = {
|
|
14
|
+
tenantSettings: RawAmpSettingsMap;
|
|
15
|
+
connectorSettings: {
|
|
16
|
+
[cid: string]: RawAmpSettingsMap;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export class AmpSettingsService {
|
|
21
|
+
protected readonly rest: RestClient;
|
|
22
|
+
protected readonly targetApi: string;
|
|
23
|
+
constructor(rest: RestClient, targetApi: TargetApi = 'api') {
|
|
24
|
+
this.rest = rest;
|
|
25
|
+
this.targetApi = targetApi;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async getSettingsMap(tid?: string): Promise<AmpSettingsMap> {
|
|
29
|
+
const page = await this.rest.call({
|
|
30
|
+
url: `/${this.targetApi}/v1/settings`,
|
|
31
|
+
method: 'GET',
|
|
32
|
+
params: {tid},
|
|
33
|
+
});
|
|
34
|
+
const settings = page.data as AmpSettingDto[];
|
|
35
|
+
const rawSettingsMap: TenantSettingsMap = {
|
|
36
|
+
tenantSettings: {},
|
|
37
|
+
connectorSettings: {},
|
|
38
|
+
};
|
|
39
|
+
settings.forEach(setting => {
|
|
40
|
+
if (setting.cid) {
|
|
41
|
+
if (!rawSettingsMap.connectorSettings[setting.cid]) {
|
|
42
|
+
rawSettingsMap.connectorSettings[setting.cid] = {};
|
|
43
|
+
}
|
|
44
|
+
rawSettingsMap.connectorSettings[setting.cid][setting.key] = setting.value;
|
|
45
|
+
} else {
|
|
46
|
+
rawSettingsMap.tenantSettings[setting.key] = setting.value;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return new AmpSettingsMap(rawSettingsMap);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async create<T>(key: TypedAmpSettingsKey<T>, value: T, tid: string, cid?: string): Promise<AmpSettingDto> {
|
|
53
|
+
const page = await this.rest.call({
|
|
54
|
+
url: `/${this.targetApi}/v1/settings`,
|
|
55
|
+
method: 'POST',
|
|
56
|
+
data: {
|
|
57
|
+
tid,
|
|
58
|
+
cid,
|
|
59
|
+
key,
|
|
60
|
+
value,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
const settings = page.data as AmpSettingDto[];
|
|
64
|
+
return settings[0];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async update(id: string, entity: AmpSettingUpsertDto): Promise<AmpSettingDto> {
|
|
68
|
+
const page = await this.rest.call({
|
|
69
|
+
url: `/${this.targetApi}/v1/settings/${id}`,
|
|
70
|
+
method: 'PUT',
|
|
71
|
+
data: entity,
|
|
72
|
+
});
|
|
73
|
+
const settings = page.data as AmpSettingDto[];
|
|
74
|
+
return settings[0];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export class AmpSettingsMap {
|
|
79
|
+
private readonly settings: TenantSettingsMap;
|
|
80
|
+
|
|
81
|
+
constructor(settings: TenantSettingsMap) {
|
|
82
|
+
this.settings = settings;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getGlobalSetting<T>(key: TypedAmpSettingsKey<T>): T {
|
|
86
|
+
const tenantVal = this.settings.tenantSettings[key.id];
|
|
87
|
+
if (tenantVal) {
|
|
88
|
+
return tenantVal as T;
|
|
89
|
+
}
|
|
90
|
+
return key.defaultValue;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
getConnectorSetting<T>(cid: string, key: TypedAmpSettingsKey<T>): T {
|
|
94
|
+
const tenantVal = this.settings.tenantSettings[key.id];
|
|
95
|
+
const connectorVal = this.settings.connectorSettings[cid][key.id];
|
|
96
|
+
if (connectorVal) {
|
|
97
|
+
return connectorVal as T;
|
|
98
|
+
}
|
|
99
|
+
if (tenantVal) {
|
|
100
|
+
return tenantVal as T;
|
|
101
|
+
}
|
|
102
|
+
return key.defaultValue;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
getConnectorSettings(cid: string): RawAmpSettingsMap | undefined {
|
|
106
|
+
if (!this.settings.connectorSettings[cid]) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
return _.clone(this.settings.connectorSettings[cid]);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static asKey<T>(key: AmpSettingKey, defaultValue: T): TypedAmpSettingsKey<T> {
|
|
113
|
+
return {
|
|
114
|
+
id: key,
|
|
115
|
+
defaultValue,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
package/src/settings.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {AmpSettingsMap} from './services';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* GLOBAL ONLY
|
|
5
|
+
* TODO:
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* GLOBAL
|
|
10
|
+
* Note: these can be overridden by connector level settings
|
|
11
|
+
*/
|
|
12
|
+
export const NOTIFICATIONS_ENALBED = AmpSettingsMap.asKey<boolean>('notifications.enabled', false); // TODO: enble by default
|
|
13
|
+
|
|
14
|
+
/********************
|
|
15
|
+
* PROVIDERS *
|
|
16
|
+
********************/
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* SLACK
|
|
20
|
+
*/
|
|
21
|
+
export const SLACK_EXECUTIVE_GROUPS = AmpSettingsMap.asKey<string[]>('slack.executive.groups', []);
|
|
22
|
+
export const SLACK_PROD_ACCESS_GROUPS = AmpSettingsMap.asKey<string[]>('slack.prod_access.groups', []);
|
|
23
|
+
export const SLACK_PRIV_ACCESS_GROUPS = AmpSettingsMap.asKey<string[]>('slack.priv_access.groups', []);
|
|
24
|
+
export const SLACK_CONTACT_SECURITY_CHANNEL = AmpSettingsMap.asKey<string>('slack.contact_security.channel', '');
|
|
25
|
+
// TODO: localization
|
|
26
|
+
export const SLACK_CONTACT_SECURITY_TEMPLATE = AmpSettingsMap.asKey<string>(
|
|
27
|
+
'slack.contact_security.template',
|
|
28
|
+
'Thanks for getting in touch! We forwarded your message to our security team and they will get back to you shortly.'
|
|
29
|
+
);
|