@ampsec/platform-client 27.1.0 → 27.2.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/services/entity.service.d.ts +10 -10
- package/build/src/services/entity.service.js +6 -1
- package/build/src/services/entity.service.js.map +1 -1
- package/build/src/services/rest/AgentIdentityService.d.ts +4 -1
- package/build/src/services/rest/AgentIdentityService.js.map +1 -1
- package/package.json +1 -1
- package/src/services/entity.service.ts +13 -11
- package/src/services/rest/AgentIdentityService.ts +6 -2
|
@@ -6,31 +6,31 @@ export type EntityCallOptions = {
|
|
|
6
6
|
params: unknown;
|
|
7
7
|
};
|
|
8
8
|
export interface AmpEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
9
|
-
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
10
|
-
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
9
|
+
create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
10
|
+
update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
11
11
|
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
12
12
|
}
|
|
13
13
|
export interface AmpSdkTenantService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
14
|
-
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
15
|
-
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
14
|
+
create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
15
|
+
update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
16
16
|
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
17
17
|
}
|
|
18
18
|
export interface AmpGlobalEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
19
|
-
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
20
|
-
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
19
|
+
create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
20
|
+
update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
21
21
|
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
22
22
|
getLookupIds(_tid: string, _options?: EntityCallOptions): Promise<ExtKeyMap>;
|
|
23
23
|
}
|
|
24
24
|
export interface AmpSaaSEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
25
|
-
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
26
|
-
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
25
|
+
create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
26
|
+
update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
27
27
|
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
28
28
|
getLookupIds(_cid: string, _options?: EntityCallOptions): Promise<ExtKeyMap>;
|
|
29
29
|
}
|
|
30
30
|
export declare class AmpEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataServiceImpl<ReadT> implements AmpEntityService<WriteT, ReadT> {
|
|
31
31
|
constructor(rest: RestClient, kind: string, targetApi?: TargetApi);
|
|
32
|
-
create(model: WriteT, options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
33
|
-
update(model: WriteT, options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
32
|
+
create(model: WriteT | WriteT[], options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
33
|
+
update(model: WriteT | WriteT[], options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
34
34
|
delete(id: string, options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
35
35
|
}
|
|
36
36
|
export declare class AmpGlobalEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpEntityServiceImpl<WriteT, ReadT> implements AmpGlobalEntityService<WriteT, ReadT> {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.AmpSaaSEntityServiceImpl = exports.AmpGlobalEntityServiceImpl = exports.AmpEntityServiceImpl = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
4
8
|
const constants_1 = require("./constants");
|
|
5
9
|
const data_service_1 = require("./data.service");
|
|
6
10
|
class AmpEntityServiceImpl extends data_service_1.AmpDataServiceImpl {
|
|
@@ -16,8 +20,9 @@ class AmpEntityServiceImpl extends data_service_1.AmpDataServiceImpl {
|
|
|
16
20
|
});
|
|
17
21
|
}
|
|
18
22
|
update(model, options) {
|
|
23
|
+
const url = lodash_1.default.isArray(model) ? `/${this.targetApi}/v1/${this.kind}` : `/${this.targetApi}/v1/${this.kind}/${model.id}`;
|
|
19
24
|
return this.getPage({
|
|
20
|
-
url
|
|
25
|
+
url,
|
|
21
26
|
method: 'PUT',
|
|
22
27
|
params: options === null || options === void 0 ? void 0 : options.params,
|
|
23
28
|
data: model,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.service.js","sourceRoot":"","sources":["../../../src/services/entity.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entity.service.js","sourceRoot":"","sources":["../../../src/services/entity.service.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA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O,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;IAC9C,CAAC;CACF;AAlBD,gEAkBC;AAED,MAAa,wBACX,SAAQ,oBAAmC;IAG3C,YAAY,IAAgB,EAAE,IAAY,EAAE,YAAuB,4BAAgB;QACjF,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/B,CAAC;IACD,YAAY,CAAC,GAAW,EAAE,OAA2B;;QACnD,MAAM,GAAG,GAAgB;YACvB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,cAAc;YACrD,MAAM,EAAE,KAAK;YACb,MAAM,EAAE;gBACN,GAAG,CAAC,MAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAmB,mCAAI,EAAE,CAAC;gBACxC,GAAG;aACJ;SACF,CAAC;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;IAC9C,CAAC;CACF;AAlBD,4DAkBC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { AgentDto } from '../../dto';
|
|
2
2
|
import { RestClient } from './RestClient';
|
|
3
|
+
export type TokenResponse = {
|
|
4
|
+
token: string;
|
|
5
|
+
};
|
|
3
6
|
export declare class AgentIdentityService {
|
|
4
7
|
protected readonly rest: RestClient;
|
|
5
8
|
constructor(rest: RestClient);
|
|
6
|
-
exchangeToken(targetTenantId: string): Promise<
|
|
9
|
+
exchangeToken(targetTenantId: string): Promise<TokenResponse>;
|
|
7
10
|
me(): Promise<AgentDto>;
|
|
8
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentIdentityService.js","sourceRoot":"","sources":["../../../../src/services/rest/AgentIdentityService.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AgentIdentityService.js","sourceRoot":"","sources":["../../../../src/services/rest/AgentIdentityService.ts"],"names":[],"mappings":";;;AAOA,MAAa,oBAAoB;IAE/B,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,KAAK,CAAC,aAAa,CAAC,cAAsB;QACxC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YAC/B,GAAG,EAAE,6BAA6B;YAClC,MAAM,EAAE,KAAK;YACb,MAAM,EAAE;gBACN,GAAG,EAAE,cAAc;aACpB;SACF,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,IAAqB,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,EAAE;QACN,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YAC/B,GAAG,EAAE,YAAY;YACjB,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,IAAgB,CAAC;IAC9B,CAAC;CACF;AAvBD,oDAuBC"}
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
1
2
|
import {BaseDto, BaseUpsertDto, ExtKeyMap, Page} from '../dto';
|
|
2
3
|
import {TargetApi, TARGET_API_AGENT, ErrorHandler} from './constants';
|
|
3
4
|
import {AmpDataService, AmpDataServiceImpl} from './data.service';
|
|
@@ -9,25 +10,25 @@ export type EntityCallOptions = {
|
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
export interface AmpEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
12
|
-
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
13
|
-
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
13
|
+
create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
14
|
+
update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
14
15
|
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export interface AmpSdkTenantService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
18
|
-
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
19
|
-
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
19
|
+
create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
20
|
+
update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
20
21
|
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
21
22
|
}
|
|
22
23
|
export interface AmpGlobalEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
23
|
-
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
24
|
-
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
24
|
+
create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
25
|
+
update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
25
26
|
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
26
27
|
getLookupIds(_tid: string, _options?: EntityCallOptions): Promise<ExtKeyMap>;
|
|
27
28
|
}
|
|
28
29
|
export interface AmpSaaSEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
29
|
-
create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
30
|
-
update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
30
|
+
create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
31
|
+
update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
31
32
|
delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
|
|
32
33
|
getLookupIds(_cid: string, _options?: EntityCallOptions): Promise<ExtKeyMap>;
|
|
33
34
|
}
|
|
@@ -37,7 +38,7 @@ export class AmpEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends Ba
|
|
|
37
38
|
super(rest, kind, targetApi);
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
create(model: WriteT, options?: EntityCallOptions): Promise<Page<ReadT>> {
|
|
41
|
+
create(model: WriteT | WriteT[], options?: EntityCallOptions): Promise<Page<ReadT>> {
|
|
41
42
|
return this.getPage({
|
|
42
43
|
url: `/${this.targetApi}/v1/${this.kind}`,
|
|
43
44
|
method: 'POST',
|
|
@@ -46,9 +47,10 @@ export class AmpEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends Ba
|
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
update(model: WriteT, options?: EntityCallOptions): Promise<Page<ReadT>> {
|
|
50
|
+
update(model: WriteT | WriteT[], options?: EntityCallOptions): Promise<Page<ReadT>> {
|
|
51
|
+
const url = _.isArray(model) ? `/${this.targetApi}/v1/${this.kind}` : `/${this.targetApi}/v1/${this.kind}/${model.id}`;
|
|
50
52
|
return this.getPage({
|
|
51
|
-
url
|
|
53
|
+
url,
|
|
52
54
|
method: 'PUT',
|
|
53
55
|
params: options?.params as QueryMap,
|
|
54
56
|
data: model,
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import {AgentDto} from '../../dto';
|
|
2
2
|
import {RestClient} from './RestClient';
|
|
3
3
|
|
|
4
|
+
export type TokenResponse = {
|
|
5
|
+
token: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
4
8
|
export class AgentIdentityService {
|
|
5
9
|
protected readonly rest: RestClient;
|
|
6
10
|
constructor(rest: RestClient) {
|
|
7
11
|
this.rest = rest;
|
|
8
12
|
}
|
|
9
|
-
async exchangeToken(targetTenantId: string): Promise<
|
|
13
|
+
async exchangeToken(targetTenantId: string): Promise<TokenResponse> {
|
|
10
14
|
const res = await this.rest.call({
|
|
11
15
|
url: '/api/v1/auth/token/exchange',
|
|
12
16
|
method: 'GET',
|
|
@@ -14,7 +18,7 @@ export class AgentIdentityService {
|
|
|
14
18
|
tid: targetTenantId,
|
|
15
19
|
},
|
|
16
20
|
});
|
|
17
|
-
return res.data as
|
|
21
|
+
return res.data as TokenResponse;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
async me(): Promise<AgentDto> {
|