@ampsec/platform-client 47.2.0 → 47.4.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/assetKeys.d.ts +2 -0
- package/build/src/dto/entityIdSummaries.dto.d.ts +22 -0
- package/build/src/dto/entityIdSummaries.dto.js +3 -0
- package/build/src/dto/entityIdSummaries.dto.js.map +1 -0
- package/build/src/dto/enums/globalUser.type.d.ts +1 -0
- package/build/src/dto/enums/globalUser.type.js +1 -0
- package/build/src/dto/enums/globalUser.type.js.map +1 -1
- 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/supportedMessageChannelKind.enum.d.ts +5 -0
- package/build/src/dto/enums/supportedMessageChannelKind.enum.js +21 -0
- package/build/src/dto/enums/supportedMessageChannelKind.enum.js.map +1 -0
- package/build/src/dto/extKeyMap.dto.d.ts +2 -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/notification.dto.d.ts +6 -1
- package/build/src/services/AmpSdk.d.ts +8 -7
- package/build/src/services/AmpSdk.js +9 -8
- package/build/src/services/AmpSdk.js.map +1 -1
- package/build/src/services/entity.service.d.ts +12 -10
- package/build/src/services/entity.service.js +81 -16
- package/build/src/services/entity.service.js.map +1 -1
- package/build/src/services/index.d.ts +3 -0
- package/build/src/services/index.js +3 -0
- package/build/src/services/index.js.map +1 -1
- package/build/src/services/lookup.service.d.ts +55 -0
- package/build/src/services/lookup.service.js +173 -0
- package/build/src/services/lookup.service.js.map +1 -0
- package/build/src/services/saasEntity.service.d.ts +32 -0
- package/build/src/services/saasEntity.service.js +154 -0
- package/build/src/services/saasEntity.service.js.map +1 -0
- package/build/src/services/utils.d.ts +1 -0
- package/build/src/services/utils.js +15 -0
- package/build/src/services/utils.js.map +1 -0
- package/package.json +1 -1
- package/src/dto/assetKeys.ts +2 -0
- package/src/dto/entityIdSummaries.dto.ts +27 -0
- package/src/dto/enums/globalUser.type.ts +1 -0
- package/src/dto/enums/index.ts +1 -0
- package/src/dto/enums/supportedMessageChannelKind.enum.ts +17 -0
- package/src/dto/extKeyMap.dto.ts +2 -0
- package/src/dto/index.ts +1 -0
- package/src/dto/notification.dto.ts +7 -1
- package/src/services/AmpSdk.ts +12 -29
- package/src/services/entity.service.ts +87 -24
- package/src/services/index.ts +3 -0
- package/src/services/lookup.service.ts +176 -0
- package/src/services/saasEntity.service.ts +181 -0
- package/src/services/utils.ts +8 -0
|
@@ -0,0 +1,173 @@
|
|
|
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.SaasComponentLookupService = exports.AssetLookupService = exports.UserLookupService = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
class UserLookupService {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.emailLookupMap = new Map();
|
|
12
|
+
this.extIdLookupMap = new Map();
|
|
13
|
+
this.lastUpdated = new Date('2023-04-17T13:00:00.000Z');
|
|
14
|
+
}
|
|
15
|
+
getLastUpdated() {
|
|
16
|
+
return this.lastUpdated.toISOString();
|
|
17
|
+
}
|
|
18
|
+
// TODO throw errors if conflicts are found
|
|
19
|
+
/**
|
|
20
|
+
* Emails are normalized to lower case but external IDs are case sensitive
|
|
21
|
+
*/
|
|
22
|
+
add(user) {
|
|
23
|
+
user.emails.forEach(email => this.emailLookupMap.set(email.toLowerCase(), user));
|
|
24
|
+
if (user.extId) {
|
|
25
|
+
this.extIdLookupMap.set(user.extId, user);
|
|
26
|
+
}
|
|
27
|
+
this.lastUpdated = new Date();
|
|
28
|
+
}
|
|
29
|
+
// TODO throw errors if conflicts are found
|
|
30
|
+
/**
|
|
31
|
+
* Calls through to `byEmails` and `byExtId`
|
|
32
|
+
*/
|
|
33
|
+
lookup(userIds) {
|
|
34
|
+
if (!userIds) {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
const matches = [];
|
|
38
|
+
const emails = [];
|
|
39
|
+
if (userIds.primaryEmail) {
|
|
40
|
+
emails.push(userIds.primaryEmail);
|
|
41
|
+
}
|
|
42
|
+
if (Array.isArray(userIds.emails)) {
|
|
43
|
+
emails.push(...userIds.emails);
|
|
44
|
+
}
|
|
45
|
+
matches.push(...this.byEmails(emails));
|
|
46
|
+
if (userIds.extId) {
|
|
47
|
+
const match = this.byExtId(userIds.extId);
|
|
48
|
+
if (match) {
|
|
49
|
+
matches.push(match);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return lodash_1.default.uniqBy(matches, 'id');
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Emails are normalized to lower case
|
|
56
|
+
*/
|
|
57
|
+
byEmails(emails) {
|
|
58
|
+
const matches = [];
|
|
59
|
+
if (!Array.isArray(emails)) {
|
|
60
|
+
emails = [emails];
|
|
61
|
+
}
|
|
62
|
+
emails = lodash_1.default.uniq(emails);
|
|
63
|
+
for (const email of emails) {
|
|
64
|
+
const match = this.emailLookupMap.get(email.toLocaleLowerCase());
|
|
65
|
+
if (match) {
|
|
66
|
+
matches.push(match);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return lodash_1.default.uniqBy(matches, 'id');
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Emails are normalized to lower case
|
|
73
|
+
*/
|
|
74
|
+
byEmail(email) {
|
|
75
|
+
return this.emailLookupMap.get(email.toLocaleLowerCase());
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* External IDs are case sensitive
|
|
79
|
+
*/
|
|
80
|
+
byExtId(extId) {
|
|
81
|
+
return this.extIdLookupMap.get(extId);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.UserLookupService = UserLookupService;
|
|
85
|
+
class AssetLookupService {
|
|
86
|
+
constructor() {
|
|
87
|
+
this.macsLookupMap = new Map();
|
|
88
|
+
this.snLookupMap = new Map();
|
|
89
|
+
this.extIdLookupMap = new Map();
|
|
90
|
+
this.lastUpdated = new Date('2023-04-17T13:00:00.000Z');
|
|
91
|
+
}
|
|
92
|
+
getLastUpdated() {
|
|
93
|
+
return this.lastUpdated.toISOString();
|
|
94
|
+
}
|
|
95
|
+
// TODO throw errors if conflicts are found
|
|
96
|
+
/**
|
|
97
|
+
* Macs are normalized to standard format using `formatMacAddress` but serial numbers and external IDs are case sensitive
|
|
98
|
+
*/
|
|
99
|
+
add(asset) {
|
|
100
|
+
var _a;
|
|
101
|
+
(_a = asset.macs) === null || _a === void 0 ? void 0 : _a.forEach(mac => this.macsLookupMap.set((0, utils_1.formatMacAddress)(mac), asset));
|
|
102
|
+
if (asset.sn) {
|
|
103
|
+
this.snLookupMap.set(asset.sn, asset);
|
|
104
|
+
}
|
|
105
|
+
if (asset.extId) {
|
|
106
|
+
this.extIdLookupMap.set(asset.extId, asset);
|
|
107
|
+
}
|
|
108
|
+
this.lastUpdated = new Date();
|
|
109
|
+
}
|
|
110
|
+
// TODO throw errors if conflicts are found
|
|
111
|
+
lookup(keys) {
|
|
112
|
+
const matches = [];
|
|
113
|
+
matches.push(...this.byMacs(keys.macs));
|
|
114
|
+
if (keys.sn) {
|
|
115
|
+
const ids = this.bySn(keys.sn);
|
|
116
|
+
if (ids) {
|
|
117
|
+
matches.push(ids);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (keys.extId) {
|
|
121
|
+
const match = this.byExtId(keys.extId);
|
|
122
|
+
if (match) {
|
|
123
|
+
matches.push(match);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return lodash_1.default.uniqBy(matches, 'id');
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Macs are normalized to standard format using `formatMacAddress`
|
|
130
|
+
*/
|
|
131
|
+
byMacs(macs) {
|
|
132
|
+
const matches = [];
|
|
133
|
+
if (!Array.isArray(macs)) {
|
|
134
|
+
macs = [macs];
|
|
135
|
+
}
|
|
136
|
+
for (const mac of macs) {
|
|
137
|
+
const match = this.macsLookupMap.get((0, utils_1.formatMacAddress)(mac));
|
|
138
|
+
if (match) {
|
|
139
|
+
matches.push(match);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return lodash_1.default.uniqBy(matches, 'id');
|
|
143
|
+
}
|
|
144
|
+
bySn(sn) {
|
|
145
|
+
return sn ? this.snLookupMap.get(sn) : undefined;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* External IDs are case sensitive
|
|
149
|
+
*/
|
|
150
|
+
byExtId(extId) {
|
|
151
|
+
return this.extIdLookupMap.get(extId);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.AssetLookupService = AssetLookupService;
|
|
155
|
+
class SaasComponentLookupService {
|
|
156
|
+
constructor() {
|
|
157
|
+
this.extIdLookupMap = new Map();
|
|
158
|
+
this.lastUpdated = new Date('2023-04-17T13:00:00.000Z');
|
|
159
|
+
}
|
|
160
|
+
getLastUpdated() {
|
|
161
|
+
return this.lastUpdated.toISOString();
|
|
162
|
+
}
|
|
163
|
+
// TODO throw errors if conflicts are found
|
|
164
|
+
add(sc) {
|
|
165
|
+
this.extIdLookupMap.set(sc.extId, sc);
|
|
166
|
+
this.lastUpdated = new Date();
|
|
167
|
+
}
|
|
168
|
+
byExtId(extId) {
|
|
169
|
+
return this.extIdLookupMap.get(extId);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.SaasComponentLookupService = SaasComponentLookupService;
|
|
173
|
+
//# sourceMappingURL=lookup.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup.service.js","sourceRoot":"","sources":["../../../src/services/lookup.service.ts"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C;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;IAChC,CAAC;IAED,OAAO,CAAC,KAAa;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;CACF;AAjBD,gEAiBC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BaseDto, BaseUpsertDto, ExtKeyMap, Page, PlatformSaasAssetDto, PlatformSaasAssetUpsertDto, PlatformSaasComponentDto, PlatformSaasComponentUpsertDto, PlatformSaasUserDto, PlatformSaasUserUpsertDto } from '../dto';
|
|
2
|
+
import { TargetApi } from './constants';
|
|
3
|
+
import { AmpDataService } from './data.service';
|
|
4
|
+
import { RestClient } from './rest';
|
|
5
|
+
import { AssetLookupService, SaasComponentLookupService, UserLookupService } from './lookup.service';
|
|
6
|
+
import { AmpEntityServiceImpl, EntityCallOptions } from './entity.service';
|
|
7
|
+
export interface AmpSaaSEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
8
|
+
create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
9
|
+
update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
10
|
+
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
11
|
+
getLookupIds(_cid: string, _options?: EntityCallOptions): Promise<ExtKeyMap>;
|
|
12
|
+
}
|
|
13
|
+
export declare class AmpSaaSEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpEntityServiceImpl<WriteT, ReadT> implements AmpSaaSEntityService<WriteT, ReadT> {
|
|
14
|
+
constructor(rest: RestClient, kind: string, targetApi?: TargetApi);
|
|
15
|
+
/** @deprecated */
|
|
16
|
+
getLookupIds: (cid: string, options?: EntityCallOptions) => Promise<ExtKeyMap>;
|
|
17
|
+
}
|
|
18
|
+
export declare class AmpSdkSaasUserService extends AmpSaaSEntityServiceImpl<PlatformSaasUserUpsertDto, PlatformSaasUserDto> {
|
|
19
|
+
constructor(rest: RestClient, targetApi?: TargetApi);
|
|
20
|
+
getLookup: (cid: string, options?: EntityCallOptions) => Promise<UserLookupService>;
|
|
21
|
+
refreshLookup: (lookup: UserLookupService, cid: string, options?: EntityCallOptions) => Promise<UserLookupService>;
|
|
22
|
+
}
|
|
23
|
+
export declare class AmpSdkSaasAssetService extends AmpSaaSEntityServiceImpl<PlatformSaasAssetUpsertDto, PlatformSaasAssetDto> {
|
|
24
|
+
constructor(rest: RestClient, targetApi?: TargetApi);
|
|
25
|
+
getLookup: (cid: string, options?: EntityCallOptions) => Promise<AssetLookupService>;
|
|
26
|
+
refreshLookup: (lookup: AssetLookupService, cid: string, options?: EntityCallOptions) => Promise<AssetLookupService>;
|
|
27
|
+
}
|
|
28
|
+
export declare class AmpSdkSaasComponentService extends AmpSaaSEntityServiceImpl<PlatformSaasComponentUpsertDto, PlatformSaasComponentDto> {
|
|
29
|
+
constructor(rest: RestClient, targetApi?: TargetApi);
|
|
30
|
+
getLookup: (cid: string, options?: EntityCallOptions) => Promise<SaasComponentLookupService>;
|
|
31
|
+
refreshLookup: (lookup: SaasComponentLookupService, cid: string, options?: EntityCallOptions) => Promise<SaasComponentLookupService>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
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.AmpSdkSaasComponentService = exports.AmpSdkSaasAssetService = exports.AmpSdkSaasUserService = exports.AmpSaaSEntityServiceImpl = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
const lookup_service_1 = require("./lookup.service");
|
|
10
|
+
const entity_service_1 = require("./entity.service");
|
|
11
|
+
const LOOKUP_ID_PAGE_SIZE = 50;
|
|
12
|
+
const extIdMapErrorHandler = (error) => {
|
|
13
|
+
if (error instanceof Error) {
|
|
14
|
+
console.error(error.message);
|
|
15
|
+
}
|
|
16
|
+
return {};
|
|
17
|
+
};
|
|
18
|
+
class AmpSaaSEntityServiceImpl extends entity_service_1.AmpEntityServiceImpl {
|
|
19
|
+
constructor(rest, kind, targetApi = constants_1.TARGET_API_AGENT) {
|
|
20
|
+
super(rest, kind, targetApi);
|
|
21
|
+
/** @deprecated */
|
|
22
|
+
this.getLookupIds = (cid, options) => {
|
|
23
|
+
var _a;
|
|
24
|
+
const req = {
|
|
25
|
+
url: `/${this.targetApi}/v1/${this.kind}/ext_key_map`,
|
|
26
|
+
method: 'GET',
|
|
27
|
+
params: {
|
|
28
|
+
...((_a = options === null || options === void 0 ? void 0 : options.params) !== null && _a !== void 0 ? _a : {}),
|
|
29
|
+
cid,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
return this.call(req, extIdMapErrorHandler);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.AmpSaaSEntityServiceImpl = AmpSaaSEntityServiceImpl;
|
|
37
|
+
const errorHandler = (error) => {
|
|
38
|
+
if (error instanceof Error) {
|
|
39
|
+
console.error(error.message);
|
|
40
|
+
}
|
|
41
|
+
throw error;
|
|
42
|
+
};
|
|
43
|
+
class AmpSdkSaasUserService extends AmpSaaSEntityServiceImpl {
|
|
44
|
+
constructor(rest, targetApi = constants_1.TARGET_API_AGENT) {
|
|
45
|
+
super(rest, constants_1.KIND.SAAS_USERS, targetApi);
|
|
46
|
+
this.getLookup = async (cid, options) => {
|
|
47
|
+
const lookup = new lookup_service_1.UserLookupService();
|
|
48
|
+
return this.refreshLookup(lookup, cid, options);
|
|
49
|
+
};
|
|
50
|
+
this.refreshLookup = async (lookup, cid, options) => {
|
|
51
|
+
var _a, _b, _c;
|
|
52
|
+
const limit = LOOKUP_ID_PAGE_SIZE;
|
|
53
|
+
let offset = 0;
|
|
54
|
+
let hasMore = true;
|
|
55
|
+
if (!options) {
|
|
56
|
+
options = { params: {} };
|
|
57
|
+
}
|
|
58
|
+
lodash_1.default.set(options, 'params.updatedAt', { $gt: lookup.getLastUpdated() });
|
|
59
|
+
while (hasMore) {
|
|
60
|
+
const req = {
|
|
61
|
+
url: `/${this.targetApi}/v1/${this.kind}/id_summary`,
|
|
62
|
+
method: 'GET',
|
|
63
|
+
params: {
|
|
64
|
+
...((_a = options === null || options === void 0 ? void 0 : options.params) !== null && _a !== void 0 ? _a : {}),
|
|
65
|
+
cid,
|
|
66
|
+
limit,
|
|
67
|
+
offset,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
const page = await this.call(req, errorHandler);
|
|
71
|
+
page.data.forEach(ids => lookup.add(ids));
|
|
72
|
+
offset = ((_b = page.hints.offset) !== null && _b !== void 0 ? _b : offset) + limit;
|
|
73
|
+
hasMore = (_c = page.hints.hasMore) !== null && _c !== void 0 ? _c : false;
|
|
74
|
+
}
|
|
75
|
+
return lookup;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.AmpSdkSaasUserService = AmpSdkSaasUserService;
|
|
80
|
+
class AmpSdkSaasAssetService extends AmpSaaSEntityServiceImpl {
|
|
81
|
+
constructor(rest, targetApi = constants_1.TARGET_API_AGENT) {
|
|
82
|
+
super(rest, constants_1.KIND.SAAS_ASSETS, targetApi);
|
|
83
|
+
this.getLookup = async (cid, options) => {
|
|
84
|
+
const lookup = new lookup_service_1.AssetLookupService();
|
|
85
|
+
return this.refreshLookup(lookup, cid, options);
|
|
86
|
+
};
|
|
87
|
+
this.refreshLookup = async (lookup, cid, options) => {
|
|
88
|
+
var _a, _b, _c;
|
|
89
|
+
const limit = LOOKUP_ID_PAGE_SIZE;
|
|
90
|
+
let offset = 0;
|
|
91
|
+
let hasMore = true;
|
|
92
|
+
if (!options) {
|
|
93
|
+
options = { params: {} };
|
|
94
|
+
}
|
|
95
|
+
lodash_1.default.set(options, 'params.updatedAt', { $gt: lookup.getLastUpdated() });
|
|
96
|
+
while (hasMore) {
|
|
97
|
+
const req = {
|
|
98
|
+
url: `/${this.targetApi}/v1/${this.kind}/id_summary`,
|
|
99
|
+
method: 'GET',
|
|
100
|
+
params: {
|
|
101
|
+
...((_a = options === null || options === void 0 ? void 0 : options.params) !== null && _a !== void 0 ? _a : {}),
|
|
102
|
+
cid,
|
|
103
|
+
limit,
|
|
104
|
+
offset,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
const page = await this.call(req, errorHandler);
|
|
108
|
+
page.data.forEach(ids => lookup.add(ids));
|
|
109
|
+
offset = ((_b = page.hints.offset) !== null && _b !== void 0 ? _b : offset) + limit;
|
|
110
|
+
hasMore = (_c = page.hints.hasMore) !== null && _c !== void 0 ? _c : false;
|
|
111
|
+
}
|
|
112
|
+
return lookup;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.AmpSdkSaasAssetService = AmpSdkSaasAssetService;
|
|
117
|
+
class AmpSdkSaasComponentService extends AmpSaaSEntityServiceImpl {
|
|
118
|
+
constructor(rest, targetApi = constants_1.TARGET_API_AGENT) {
|
|
119
|
+
super(rest, constants_1.KIND.SAAS_COMPONENTS, targetApi);
|
|
120
|
+
this.getLookup = async (cid, options) => {
|
|
121
|
+
const lookup = new lookup_service_1.SaasComponentLookupService();
|
|
122
|
+
return this.refreshLookup(lookup, cid, options);
|
|
123
|
+
};
|
|
124
|
+
this.refreshLookup = async (lookup, cid, options) => {
|
|
125
|
+
var _a, _b, _c;
|
|
126
|
+
const limit = LOOKUP_ID_PAGE_SIZE;
|
|
127
|
+
let offset = 0;
|
|
128
|
+
let hasMore = true;
|
|
129
|
+
if (!options) {
|
|
130
|
+
options = { params: {} };
|
|
131
|
+
}
|
|
132
|
+
lodash_1.default.set(options, 'params.updatedAt', { $gt: lookup.getLastUpdated() });
|
|
133
|
+
while (hasMore) {
|
|
134
|
+
const req = {
|
|
135
|
+
url: `/${this.targetApi}/v1/${this.kind}/id_summary`,
|
|
136
|
+
method: 'GET',
|
|
137
|
+
params: {
|
|
138
|
+
...((_a = options === null || options === void 0 ? void 0 : options.params) !== null && _a !== void 0 ? _a : {}),
|
|
139
|
+
cid,
|
|
140
|
+
limit,
|
|
141
|
+
offset,
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
const page = await this.call(req, errorHandler);
|
|
145
|
+
page.data.forEach(ids => lookup.add(ids));
|
|
146
|
+
offset = ((_b = page.hints.offset) !== null && _b !== void 0 ? _b : offset) + limit;
|
|
147
|
+
hasMore = (_c = page.hints.hasMore) !== null && _c !== void 0 ? _c : false;
|
|
148
|
+
}
|
|
149
|
+
return lookup;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.AmpSdkSaasComponentService = AmpSdkSaasComponentService;
|
|
154
|
+
//# sourceMappingURL=saasEntity.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"saasEntity.service.js","sourceRoot":"","sources":["../../../src/services/saasEntity.service.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAgBvB,2CAA4E;AAI5E,qDAAmG;AACnG,qDAAyE;AAEzE,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAS/B,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,wBACX,SAAQ,qCAAmC;IAG3C,YAAY,IAAgB,EAAE,IAAY,EAAE,YAAuB,4BAAgB;QACjF,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;QAG/B,kBAAkB;QAClB,iB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,CAAC,CAAC;gBAC1C,MAAM,GAAG,CAAC,MAAA,IAAI,CAAC,KAAK,CAAC,MAAM,mCAAI,MAAM,CAAC,GAAG,KAAK,CAAC;gBAC/C,OAAO,GAAG,MAAA,IAAI,CAAC,KAAK,CAAC,OAAO,mCAAI,KAAK,CAAC;aACvC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;IAhCF,CAAC;CAiCF;AApCD,gEAoCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatMacAddress(raw: string): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
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.formatMacAddress = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
function formatMacAddress(raw) {
|
|
9
|
+
const lower = raw.toLowerCase().replace(/[^a-f0-9]/g, '');
|
|
10
|
+
return lodash_1.default.chunk(lower.split(''), 2)
|
|
11
|
+
.map(chunk => chunk.join(''))
|
|
12
|
+
.join(':');
|
|
13
|
+
}
|
|
14
|
+
exports.formatMacAddress = formatMacAddress;
|
|
15
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/services/utils.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,SAAgB,gBAAgB,CAAC,GAAW;IAC1C,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAC1D,OAAO,gBAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;SAC/B,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SAC5B,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AALD,4CAKC"}
|
package/package.json
CHANGED
package/src/dto/assetKeys.ts
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {AssetKeys} from './assetKeys';
|
|
2
|
+
|
|
3
|
+
export type UserIdDto = {
|
|
4
|
+
id: string;
|
|
5
|
+
etag: string;
|
|
6
|
+
extId?: string;
|
|
7
|
+
emails: string[];
|
|
8
|
+
uid?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type AssetIdDto = AssetKeys & {
|
|
12
|
+
id: string;
|
|
13
|
+
etag: string;
|
|
14
|
+
extId?: string;
|
|
15
|
+
// AssetKeys.sn?: string;
|
|
16
|
+
// AssetKeys.macs: string[];
|
|
17
|
+
aid?: string;
|
|
18
|
+
uid?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type SaasComponentIdDto = {
|
|
22
|
+
id: string;
|
|
23
|
+
etag: string;
|
|
24
|
+
extId: string;
|
|
25
|
+
aid?: string;
|
|
26
|
+
uid?: string;
|
|
27
|
+
};
|
package/src/dto/enums/index.ts
CHANGED
|
@@ -15,5 +15,6 @@ export * from './notification.status';
|
|
|
15
15
|
export * from './requiredDataProperty.enum';
|
|
16
16
|
export * from './riskContributor.type';
|
|
17
17
|
export * from './saasComponentKind';
|
|
18
|
+
export * from './supportedMessageChannelKind.enum';
|
|
18
19
|
export * from './workflowStep.kind';
|
|
19
20
|
export * from './workflowTrigger.kind';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
export enum SupportedMessageChannelKind {
|
|
3
|
+
SLACK = 'SLACK',
|
|
4
|
+
UNSUPPORTED = 'UNSUPPORTED',
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const getSupportedMessageChannelKindFrom = (description: string | undefined): SupportedMessageChannelKind => {
|
|
8
|
+
if (description) {
|
|
9
|
+
for (const kind in SupportedMessageChannelKind) {
|
|
10
|
+
if (description.toUpperCase().includes(kind)) {
|
|
11
|
+
return SupportedMessageChannelKind[kind as keyof typeof SupportedMessageChannelKind] as SupportedMessageChannelKind;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return SupportedMessageChannelKind.UNSUPPORTED;
|
|
17
|
+
};
|
package/src/dto/extKeyMap.dto.ts
CHANGED
package/src/dto/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {BaseDto, BaseUpsertDto} from './base.dto';
|
|
|
2
2
|
import {Category, DeliveryStrategyKind, FindingKind, FindingSeverity, NotificationStatus} from './enums';
|
|
3
3
|
import {ContentStrategyKind} from './enums/contentStrategy.kind';
|
|
4
4
|
import {FindingOutcome} from './enums/finding.outcome';
|
|
5
|
+
import {SupportedMessageChannelKind} from './enums/supportedMessageChannelKind.enum';
|
|
5
6
|
|
|
6
7
|
export type NotificationAddress = {
|
|
7
8
|
/** Connector ID for the notification channel */
|
|
@@ -14,7 +15,12 @@ export type NotificationAddress = {
|
|
|
14
15
|
webhooks?: string[];
|
|
15
16
|
};
|
|
16
17
|
|
|
17
|
-
export type
|
|
18
|
+
export type MessageNotificationAddress = NotificationAddress & {
|
|
19
|
+
/** Channel kind for messaging applications */
|
|
20
|
+
kind: SupportedMessageChannelKind;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type SlackNotificationAddress = MessageNotificationAddress & {
|
|
18
24
|
teamId: string;
|
|
19
25
|
};
|
|
20
26
|
|
package/src/services/AmpSdk.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PlatformAgentDto,
|
|
3
3
|
PlatformAgentUpsertDto,
|
|
4
|
-
PlatformAssetDto,
|
|
5
|
-
PlatformAssetUpsertDto,
|
|
6
4
|
PlatformConnectorDto,
|
|
7
5
|
PlatformConnectorUpsertDto,
|
|
8
6
|
PlatformFindingDto,
|
|
@@ -14,35 +12,20 @@ import {
|
|
|
14
12
|
PlatformReportResultUpsertDto,
|
|
15
13
|
PlatformRiskContributorDto,
|
|
16
14
|
PlatformRiskContributorUpsertDto,
|
|
17
|
-
PlatformSaasAssetDto,
|
|
18
|
-
PlatformSaasAssetUpsertDto,
|
|
19
|
-
PlatformSaasComponentDto,
|
|
20
|
-
PlatformSaasComponentUpsertDto,
|
|
21
|
-
PlatformSaasUserDto,
|
|
22
|
-
PlatformSaasUserUpsertDto,
|
|
23
|
-
PlatformUserDto,
|
|
24
|
-
PlatformUserUpsertDto,
|
|
25
15
|
PlatformWorkflowProgressDto,
|
|
26
16
|
PlatformWorkflowProgressUpsertDto,
|
|
27
17
|
ProviderDto,
|
|
28
18
|
TenantDto,
|
|
29
19
|
TenantUpsertDto,
|
|
30
20
|
} from '../dto';
|
|
31
|
-
import {
|
|
32
|
-
AmpEntityService,
|
|
33
|
-
AmpEntityServiceImpl,
|
|
34
|
-
AmpGlobalEntityService,
|
|
35
|
-
AmpGlobalEntityServiceImpl,
|
|
36
|
-
AmpSaaSEntityService,
|
|
37
|
-
AmpSaaSEntityServiceImpl,
|
|
38
|
-
AmpSdkTenantService,
|
|
39
|
-
} from './entity.service';
|
|
21
|
+
import {AmpEntityService, AmpEntityServiceImpl, AmpSdkAssetService, AmpSdkTenantService, AmpSdkUserService} from './entity.service';
|
|
40
22
|
import {AmpRestClientOptions, RestClient, getAmpRestClient} from './rest';
|
|
41
23
|
import {KIND, TARGET_API_PLATFORM} from './constants';
|
|
42
24
|
import {PlatformJobSpecDto, PlatformJobSpecUpsertDto} from '../dto/platform/platform.jobSpec.dto';
|
|
43
25
|
import {PlatformJobExecutionStateDto, PlatformJobExecutionStateUpsertDto} from '../dto/platform/platform.jobExecutionState.dto';
|
|
44
26
|
import {DefaultEnumService, EnumService} from './rest/EnumService';
|
|
45
27
|
import {AmpSettingsService} from './settings.service';
|
|
28
|
+
import {AmpSaaSEntityService, AmpSaaSEntityServiceImpl, AmpSdkSaasAssetService, AmpSdkSaasComponentService, AmpSdkSaasUserService} from './saasEntity.service';
|
|
46
29
|
|
|
47
30
|
export type AmpSdkOptions = AmpRestClientOptions;
|
|
48
31
|
|
|
@@ -57,7 +40,7 @@ export type AmpSdkOptions = AmpRestClientOptions;
|
|
|
57
40
|
*/
|
|
58
41
|
export class AmpSdkServices {
|
|
59
42
|
readonly agents: AmpEntityService<PlatformAgentUpsertDto, PlatformAgentDto>;
|
|
60
|
-
readonly asset:
|
|
43
|
+
readonly asset: AmpSdkAssetService;
|
|
61
44
|
readonly connectors: AmpEntityService<PlatformConnectorUpsertDto, PlatformConnectorDto>;
|
|
62
45
|
readonly enums: EnumService;
|
|
63
46
|
readonly findings: AmpSaaSEntityService<PlatformFindingUpsertDto, PlatformFindingDto>;
|
|
@@ -67,17 +50,17 @@ export class AmpSdkServices {
|
|
|
67
50
|
readonly providers: AmpEntityService<PlatformProviderUpsertDto, ProviderDto>;
|
|
68
51
|
readonly reportResults: AmpSaaSEntityService<PlatformReportResultUpsertDto, PlatformReportResultDto>;
|
|
69
52
|
readonly riskContributors: AmpSaaSEntityService<PlatformRiskContributorUpsertDto, PlatformRiskContributorDto>;
|
|
70
|
-
readonly saasAssets:
|
|
71
|
-
readonly saasComponents:
|
|
72
|
-
readonly saasUsers:
|
|
53
|
+
readonly saasAssets: AmpSdkSaasAssetService;
|
|
54
|
+
readonly saasComponents: AmpSdkSaasComponentService;
|
|
55
|
+
readonly saasUsers: AmpSdkSaasUserService;
|
|
73
56
|
readonly settings: AmpSettingsService;
|
|
74
57
|
readonly tenants: AmpSdkTenantService<TenantUpsertDto, TenantDto>;
|
|
75
|
-
readonly users:
|
|
58
|
+
readonly users: AmpSdkUserService;
|
|
76
59
|
readonly workflowsProgress: AmpEntityService<PlatformWorkflowProgressUpsertDto, PlatformWorkflowProgressDto>;
|
|
77
60
|
|
|
78
61
|
constructor(rest: RestClient) {
|
|
79
62
|
this.agents = new AmpEntityServiceImpl<PlatformAgentUpsertDto, PlatformAgentDto>(rest, KIND.AGENTS, TARGET_API_PLATFORM);
|
|
80
|
-
this.asset = new
|
|
63
|
+
this.asset = new AmpSdkAssetService(rest, TARGET_API_PLATFORM);
|
|
81
64
|
this.connectors = new AmpEntityServiceImpl<PlatformConnectorUpsertDto, PlatformConnectorDto>(rest, KIND.CONNECTORS, TARGET_API_PLATFORM);
|
|
82
65
|
this.enums = new DefaultEnumService(rest, TARGET_API_PLATFORM);
|
|
83
66
|
this.findings = new AmpSaaSEntityServiceImpl<PlatformFindingUpsertDto, PlatformFindingDto>(rest, KIND.FINDINGS, TARGET_API_PLATFORM);
|
|
@@ -87,12 +70,12 @@ export class AmpSdkServices {
|
|
|
87
70
|
this.providers = new AmpEntityServiceImpl<PlatformProviderUpsertDto, ProviderDto>(rest, KIND.PROVIDERS, TARGET_API_PLATFORM);
|
|
88
71
|
this.reportResults = new AmpSaaSEntityServiceImpl<PlatformReportResultUpsertDto, PlatformReportResultDto>(rest, KIND.REPORT_RESULTS, TARGET_API_PLATFORM);
|
|
89
72
|
this.riskContributors = new AmpSaaSEntityServiceImpl<PlatformRiskContributorUpsertDto, PlatformRiskContributorDto>(rest, KIND.RISK_CONTRIBUTORS, TARGET_API_PLATFORM);
|
|
90
|
-
this.saasAssets = new
|
|
91
|
-
this.saasComponents = new
|
|
92
|
-
this.saasUsers = new
|
|
73
|
+
this.saasAssets = new AmpSdkSaasAssetService(rest, TARGET_API_PLATFORM);
|
|
74
|
+
this.saasComponents = new AmpSdkSaasComponentService(rest, TARGET_API_PLATFORM);
|
|
75
|
+
this.saasUsers = new AmpSdkSaasUserService(rest, TARGET_API_PLATFORM);
|
|
93
76
|
this.settings = new AmpSettingsService(rest, TARGET_API_PLATFORM);
|
|
94
77
|
this.tenants = new AmpEntityServiceImpl<TenantUpsertDto, TenantDto>(rest, KIND.TENANTS, TARGET_API_PLATFORM);
|
|
95
|
-
this.users = new
|
|
78
|
+
this.users = new AmpSdkUserService(rest, TARGET_API_PLATFORM);
|
|
96
79
|
this.workflowsProgress = new AmpEntityServiceImpl<PlatformWorkflowProgressUpsertDto, PlatformWorkflowProgressDto>(rest, KIND.WORKFLOW_PROGRESS, TARGET_API_PLATFORM);
|
|
97
80
|
}
|
|
98
81
|
|