@ampsec/platform-client 47.3.0 → 47.5.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/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/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/rest/RestClient.d.ts +2 -0
- package/build/src/services/rest/RestClient.js +1 -0
- package/build/src/services/rest/RestClient.js.map +1 -1
- 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/extKeyMap.dto.ts +2 -0
- package/src/dto/index.ts +1 -0
- 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/rest/RestClient.ts +3 -0
- package/src/services/saasEntity.service.ts +181 -0
- package/src/services/utils.ts +8 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup.service.js","sourceRoot":"","sources":["../../../src/services/lookup.service.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,mCAAyC;AAEzC,MAAa,iBAAiB;IAA9B;QACmB,mBAAc,GAAG,IAAI,GAAG,EAAqB,CAAC;QAC9C,mBAAc,GAAG,IAAI,GAAG,EAAqB,CAAC;QACvD,gBAAW,GAAG,IAAI,IAAI,CAAC,0BAA0B,CAAC,CAAC;IA4E7D,CAAC;IA1EC,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;IACxC,CAAC;IAED,2CAA2C;IAC3C;;OAEG;IACH,GAAG,CAAC,IAAe;QACjB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;QACjF,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;SAC3C;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;IAChC,CAAC;IAED,2CAA2C;IAC3C;;OAEG;IACH,MAAM,CAAC,OAAoB;QACzB,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,EAAE,CAAC;SACX;QACD,MAAM,OAAO,GAAG,EAAiB,CAAC;QAClC,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,IAAI,OAAO,CAAC,YAAY,EAAE;YACxB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY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,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAe7D,CAAC;IAbC,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;IACxC,CAAC;IAED,2CAA2C;IAC3C,GAAG,CAAC,EAAsB;QACxB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;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"}
|
|
@@ -13,6 +13,8 @@ export type AmpRestClientOptions = {
|
|
|
13
13
|
rateLimitStrategy?: RestClientRateLimitStrategy;
|
|
14
14
|
logger?: AmpLogger;
|
|
15
15
|
client?: AxiosStatic;
|
|
16
|
+
/** Throws errors on non-200 responses if `true`. Default `false` */
|
|
17
|
+
strict?: boolean;
|
|
16
18
|
};
|
|
17
19
|
export type RestClientOptions = {
|
|
18
20
|
baseUrl?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RestClient.js","sourceRoot":"","sources":["../../../../src/services/rest/RestClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAuB;AACvB,4CAAoB;AACpB,+CAA4D;AAG5D,6CAA4E;AAC5E,mCAAmD;AACnD,qDAAiI;AACjI,2CAAoD;
|
|
1
|
+
{"version":3,"file":"RestClient.js","sourceRoot":"","sources":["../../../../src/services/rest/RestClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAuB;AACvB,4CAAoB;AACpB,+CAA4D;AAG5D,6CAA4E;AAC5E,mCAAmD;AACnD,qDAAiI;AACjI,2CAAoD;AAiCpD;;;;;;GAMG;AACH,MAAa,iBAAiB;IAO5B,YAAY,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AAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAC;QACxE,IAAI,CAAC,aAAa,GAAG,MAAA,OAAO,CAAC,aAAa,mCAAI,kCAAqB,CAAC;QACpE,IAAI,CAAC,iBAAiB,GAAG,MAAA,OAAO,CAAC,iBAAiB,mCAAI,gDAA+B,CAAC;QACtF,IAAI,CAAC,MAAM,GAAG,MAAA,OAAO,CAAC,MAAM,mCAAI,KAAK,CAAC;IACxC,CAAC;CAoCF;AA/DD,8CA+DC;AAEM,MAAM,gBAAgB,GAAG,CAAC,OAA6B,EAAc,EAAE;IAC5E,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC;QACtC,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,OAAO,CAAC,KAAK,EAAE;SACzC;QACD,iBAAiB,EAAE,IAAI,kDAAiC,CAAC,EAAE,CAAC;QAC5D,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAZW,QAAA,gBAAgB,oBAY3B"}
|
|
@@ -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,iBAAY,GAAG,CAAC,GAAW,EAAE,OAA2B,EAAsB,EAAE;;YAC9E,MAAM,GAAG,GAAgB;gBACvB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,cAAc;gBACrD,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE;oBACN,GAAG,CAAC,MAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAmB,mCAAI,EAAE,CAAC;oBACxC,GAAG;iBACJ;aACF,CAAC;YACF,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;QAC9C,CAAC,CAAC;IAbF,CAAC;CAcF;AApBD,4DAoBC;AAED,MAAM,YAAY,GAAG,CAAC,KAAc,EAAE,EAAE;IACtC,IAAI,KAAK,YAAY,KAAK,EAAE;QAC1B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC9B;IACD,MAAM,KAAK,CAAC;AACd,CAAC,CAAC;AAEF,MAAa,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GAAG,CAAC,OAAO,EAAE,kBAAkB,EAAE,EAAC,GAAG,EAAE,MAAM,CAAC,cAAc,EAAE,EAAC,CAAC,CAAC;YACnE,OAAO,OAAO,EAAE;gBACd,MAAM,GAAG,GAAgB;oBACvB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,aAAa;oBACpD,MAAM,EAAE,KAAK;oBACb,MAAM,EAAE;wBACN,GAAG,CAAC,MAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAmB,mCAAI,EAAE,CAAC;wBACxC,GAAG;wBACH,KAAK;wBACL,MAAM;qBACP;iBACF,CAAC;gBACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,YAAsD,CAAC,CAAC;gBAC1F,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,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/extKeyMap.dto.ts
CHANGED
package/src/dto/index.ts
CHANGED
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
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import {BaseDto, BaseUpsertDto, ExtKeyMap, Page} from '../dto';
|
|
3
|
-
import {TargetApi, TARGET_API_AGENT, ErrorHandler} from './constants';
|
|
2
|
+
import {AssetIdDto, BaseDto, BaseUpsertDto, ExtKeyMap, Page, PlatformAssetDto, PlatformAssetUpsertDto, PlatformUserDto, PlatformUserUpsertDto, UserIdDto} from '../dto';
|
|
3
|
+
import {TargetApi, TARGET_API_AGENT, ErrorHandler, KIND} from './constants';
|
|
4
4
|
import {AmpDataService, AmpDataServiceImpl} from './data.service';
|
|
5
5
|
import {RestClient, RestRequest} from './rest';
|
|
6
6
|
import {QueryMap} from './rest/utils';
|
|
7
|
+
import {AssetLookupService, UserLookupService} from './lookup.service';
|
|
8
|
+
|
|
9
|
+
const LOOKUP_ID_PAGE_SIZE = 50;
|
|
7
10
|
|
|
8
11
|
export type EntityCallOptions = {
|
|
9
12
|
params: unknown;
|
|
@@ -20,18 +23,13 @@ export interface AmpSdkTenantService<WriteT extends BaseUpsertDto, ReadT extends
|
|
|
20
23
|
update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
21
24
|
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
22
25
|
}
|
|
26
|
+
|
|
23
27
|
export interface AmpGlobalEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
24
28
|
create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
25
29
|
update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
26
30
|
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
27
31
|
getLookupIds(_tid: string, _options?: EntityCallOptions): Promise<ExtKeyMap>;
|
|
28
32
|
}
|
|
29
|
-
export interface AmpSaaSEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
30
|
-
create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
31
|
-
update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
32
|
-
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
33
|
-
getLookupIds(_cid: string, _options?: EntityCallOptions): Promise<ExtKeyMap>;
|
|
34
|
-
}
|
|
35
33
|
|
|
36
34
|
export class AmpEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataServiceImpl<ReadT> implements AmpEntityService<WriteT, ReadT> {
|
|
37
35
|
constructor(rest: RestClient, kind: string, targetApi: TargetApi = TARGET_API_AGENT) {
|
|
@@ -93,6 +91,8 @@ export class AmpGlobalEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT exte
|
|
|
93
91
|
constructor(rest: RestClient, kind: string, targetApi: TargetApi = TARGET_API_AGENT) {
|
|
94
92
|
super(rest, kind, targetApi);
|
|
95
93
|
}
|
|
94
|
+
|
|
95
|
+
/** @deprecated */
|
|
96
96
|
getLookupIds = (tid: string, options?: EntityCallOptions): Promise<ExtKeyMap> => {
|
|
97
97
|
const req: RestRequest = {
|
|
98
98
|
url: `/${this.targetApi}/v1/${this.kind}/ext_key_map`,
|
|
@@ -106,22 +106,85 @@ export class AmpGlobalEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT exte
|
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
{
|
|
113
|
-
constructor(rest: RestClient, kind: string, targetApi: TargetApi = TARGET_API_AGENT) {
|
|
114
|
-
super(rest, kind, targetApi);
|
|
109
|
+
const errorHandler = (error: unknown) => {
|
|
110
|
+
if (error instanceof Error) {
|
|
111
|
+
console.error(error.message);
|
|
115
112
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
113
|
+
throw error;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export class AmpSdkUserService extends AmpGlobalEntityServiceImpl<PlatformUserUpsertDto, PlatformUserDto> {
|
|
117
|
+
constructor(rest: RestClient, targetApi: TargetApi = TARGET_API_AGENT) {
|
|
118
|
+
super(rest, KIND.USERS, targetApi);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
getLookup = async (tid: string, options?: EntityCallOptions): Promise<UserLookupService> => {
|
|
122
|
+
const lookup = new UserLookupService();
|
|
123
|
+
return this.refreshLookup(lookup, tid, options);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
refreshLookup = async (lookup: UserLookupService, tid: string, options?: EntityCallOptions): Promise<UserLookupService> => {
|
|
127
|
+
const limit = LOOKUP_ID_PAGE_SIZE;
|
|
128
|
+
let offset = 0;
|
|
129
|
+
let hasMore = true;
|
|
130
|
+
if (!options) {
|
|
131
|
+
options = {params: {}};
|
|
132
|
+
}
|
|
133
|
+
_.set(options, 'params.updatedAt', {$gt: lookup.getLastUpdated()});
|
|
134
|
+
while (hasMore) {
|
|
135
|
+
const req: RestRequest = {
|
|
136
|
+
url: `/${this.targetApi}/v1/${this.kind}/id_summary`,
|
|
137
|
+
method: 'GET',
|
|
138
|
+
params: {
|
|
139
|
+
...((options?.params as QueryMap) ?? {}),
|
|
140
|
+
tid,
|
|
141
|
+
limit,
|
|
142
|
+
offset,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
const page = await this.call(req, errorHandler as ErrorHandler<Page<UserIdDto>>);
|
|
146
|
+
page.data.forEach(ids => lookup.add(ids));
|
|
147
|
+
offset = (page.hints.offset ?? offset) + limit;
|
|
148
|
+
hasMore = page.hints.hasMore ?? false;
|
|
149
|
+
}
|
|
150
|
+
return lookup;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export class AmpSdkAssetService extends AmpGlobalEntityServiceImpl<PlatformAssetUpsertDto, PlatformAssetDto> {
|
|
155
|
+
constructor(rest: RestClient, targetApi: TargetApi = TARGET_API_AGENT) {
|
|
156
|
+
super(rest, KIND.ASSETS, targetApi);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
getLookup = async (tid: string, options?: EntityCallOptions): Promise<AssetLookupService> => {
|
|
160
|
+
const lookup = new AssetLookupService();
|
|
161
|
+
return this.refreshLookup(lookup, tid, options);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
refreshLookup = async (lookup: AssetLookupService, tid: string, options?: EntityCallOptions): Promise<AssetLookupService> => {
|
|
165
|
+
const limit = LOOKUP_ID_PAGE_SIZE;
|
|
166
|
+
let offset = 0;
|
|
167
|
+
let hasMore = true;
|
|
168
|
+
if (!options) {
|
|
169
|
+
options = {params: {}};
|
|
170
|
+
}
|
|
171
|
+
_.set(options, 'params.updatedAt', {$gt: lookup.getLastUpdated()});
|
|
172
|
+
while (hasMore) {
|
|
173
|
+
const req: RestRequest = {
|
|
174
|
+
url: `/${this.targetApi}/v1/${this.kind}/id_summary`,
|
|
175
|
+
method: 'GET',
|
|
176
|
+
params: {
|
|
177
|
+
...((options?.params as QueryMap) ?? {}),
|
|
178
|
+
tid,
|
|
179
|
+
limit,
|
|
180
|
+
offset,
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
const page = await this.call(req, errorHandler as ErrorHandler<Page<AssetIdDto>>);
|
|
184
|
+
page.data.forEach(ids => lookup.add(ids));
|
|
185
|
+
offset = (page.hints.offset ?? offset) + limit;
|
|
186
|
+
hasMore = page.hints.hasMore ?? false;
|
|
187
|
+
}
|
|
188
|
+
return lookup;
|
|
126
189
|
};
|
|
127
190
|
}
|
package/src/services/index.ts
CHANGED
|
@@ -5,5 +5,8 @@ export * from './constants';
|
|
|
5
5
|
export * from './data.service';
|
|
6
6
|
export * from './entity.service';
|
|
7
7
|
export * from './findings.service';
|
|
8
|
+
export * from './lookup.service';
|
|
8
9
|
export * from './rest';
|
|
10
|
+
export * from './saasEntity.service';
|
|
9
11
|
export * from './settings.service';
|
|
12
|
+
export * from './utils';
|