@ampsec/platform-client 22.1.0 → 22.2.1

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/README.md CHANGED
@@ -42,6 +42,20 @@ cd /path/to/application
42
42
  npm link @ampsec/platform-client
43
43
  ```
44
44
 
45
+ ## Testing
46
+
47
+ Unit tests are written with [Jest](https://jestjs.io/). To run the tests:
48
+
49
+ ```sh
50
+ npm run test
51
+ ```
52
+
53
+ Integration tests are written with [Jest](https://jestjs.io/). To run the tests:
54
+
55
+ ```sh
56
+ npm run test:integration
57
+ ```
58
+
45
59
  ### Generating Docs
46
60
 
47
61
  Published to <https://amplifier-security.gitlab.io/ampsec-platform/amp-platform-client/>
@@ -1,5 +1,5 @@
1
1
  import { PlatformAgentDto, PlatformAgentUpsertDto, PlatformAssetDto, PlatformAssetUpsertDto, PlatformConnectorDto, PlatformConnectorUpsertDto, PlatformFindingDto, PlatformFindingUpsertDto, PlatformProviderUpsertDto, PlatformReportResultDto, PlatformReportResultUpsertDto, PlatformRiskContributorDto, PlatformRiskContributorUpsertDto, PlatformSaasAssetDto, PlatformSaasAssetUpsertDto, PlatformSaasComponentDto, PlatformSaasComponentUpsertDto, PlatformSaasUserDto, PlatformSaasUserUpsertDto, PlatformUserDto, PlatformUserUpsertDto, ProviderDto, TenantDto, TenantUpsertDto } from '../dto';
2
- import { AmpEntityService, AmpGlobalEntityService, AmpSaaSEntityService } from './entity.service';
2
+ import { AmpEntityService, AmpGlobalEntityService, AmpSaaSEntityService, AmpSdkTenantService } from './entity.service';
3
3
  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';
@@ -30,7 +30,7 @@ export declare class AmpSdkServices {
30
30
  readonly saasComponents: AmpSaaSEntityService<PlatformSaasComponentUpsertDto, PlatformSaasComponentDto>;
31
31
  readonly saasUsers: AmpSaaSEntityService<PlatformSaasUserUpsertDto, PlatformSaasUserDto>;
32
32
  readonly settings: AmpSettingsService;
33
- readonly tenants: AmpEntityService<TenantUpsertDto, TenantDto>;
33
+ readonly tenants: AmpSdkTenantService<TenantUpsertDto, TenantDto>;
34
34
  readonly users: AmpGlobalEntityService<PlatformUserUpsertDto, PlatformUserDto>;
35
35
  constructor(rest: RestClient);
36
36
  static instance(options: AmpSdkOptions): AmpSdkServices;
@@ -1 +1 @@
1
- {"version":3,"file":"AmpSdk.js","sourceRoot":"","sources":["../../../src/services/AmpSdk.ts"],"names":[],"mappings":";;;AA0BA,qDAA4K;AAC5K,iCAA0E;AAC1E,2CAAsD;AAGtD,oDAAmE;AACnE,yDAAsD;AAItD;;;;;;;;GAQG;AACH,MAAa,cAAc;IAkBzB,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,q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AAI,yCAAwB,CAA+D,IAAI,EAAE,gBAAI,CAAC,iBAAiB,EAAE,+BAAmB,CAAC,CAAC;QACtK,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;AAzCD,wCAyCC"}
@@ -7,6 +7,11 @@ export interface AmpEntityService<WriteT extends BaseUpsertDto, ReadT extends Ba
7
7
  update(_model: WriteT): Promise<Page<ReadT>>;
8
8
  delete(_id: string): Promise<Page<ReadT>>;
9
9
  }
10
+ export interface AmpSdkTenantService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
11
+ create(_model: WriteT): Promise<Page<ReadT>>;
12
+ update(_model: WriteT): Promise<Page<ReadT>>;
13
+ delete(_id: string, _deleteRelated?: boolean): Promise<Page<ReadT>>;
14
+ }
10
15
  export interface AmpGlobalEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
11
16
  create(_model: WriteT): Promise<Page<ReadT>>;
12
17
  update(_model: WriteT): Promise<Page<ReadT>>;
@@ -23,7 +28,7 @@ export declare class AmpEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT ex
23
28
  constructor(rest: RestClient, kind: string, targetApi?: TargetApi);
24
29
  create(model: WriteT): Promise<Page<ReadT>>;
25
30
  update(model: WriteT): Promise<Page<ReadT>>;
26
- delete(id: string): Promise<Page<ReadT>>;
31
+ delete(id: string, deleteRelated?: boolean): Promise<Page<ReadT>>;
27
32
  }
28
33
  export declare class AmpGlobalEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpEntityServiceImpl<WriteT, ReadT> implements AmpGlobalEntityService<WriteT, ReadT> {
29
34
  constructor(rest: RestClient, kind: string, targetApi?: TargetApi);
@@ -21,12 +21,13 @@ class AmpEntityServiceImpl extends data_service_1.AmpDataServiceImpl {
21
21
  data: model,
22
22
  });
23
23
  }
24
- async delete(id) {
24
+ async delete(id, deleteRelated) {
25
25
  const res = await this.getById(id);
26
26
  if (res.data.length === 1) {
27
27
  const req = {
28
28
  url: `/${this.targetApi}/v1/${this.kind}/${id}`,
29
29
  method: 'DELETE',
30
+ params: { deleteRelated },
30
31
  };
31
32
  const { error } = await this.call(req, (error) => {
32
33
  if (error instanceof Error) {
@@ -1 +1 @@
1
- {"version":3,"file":"entity.service.js","sourceRoot":"","sources":["../../../src/services/entity.service.ts"],"names":[],"mappings":";;;AACA,2CAAsE;AACtE,iDAAkE;AAqBlE,MAAa,oBAA0E,SAAQ,iCAAyB;IACtH,YAAY,IAAgB,EAAE,IAAY,EAAE,YAAuB,4BAAgB;QACjF,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,OAAO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package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampsec/platform-client",
3
- "version": "22.1.0",
3
+ "version": "22.2.1",
4
4
  "description": "",
5
5
  "main": "build/src/index.js",
6
6
  "runkitExampleFilename": "example/main.js",
@@ -14,7 +14,8 @@
14
14
  "lint": "gts lint src",
15
15
  "clean": "gts clean src",
16
16
  "fix": "gts fix",
17
- "test": "jest",
17
+ "test": "jest /test/unit",
18
+ "test:integration": "jest /test/integration",
18
19
  "verify": "npm run lint && npm run test && npm run build && npm outdated"
19
20
  },
20
21
  "keywords": [],
@@ -24,7 +24,15 @@ import {
24
24
  TenantDto,
25
25
  TenantUpsertDto,
26
26
  } from '../dto';
27
- import {AmpEntityService, AmpEntityServiceImpl, AmpGlobalEntityService, AmpGlobalEntityServiceImpl, AmpSaaSEntityService, AmpSaaSEntityServiceImpl} from './entity.service';
27
+ import {
28
+ AmpEntityService,
29
+ AmpEntityServiceImpl,
30
+ AmpGlobalEntityService,
31
+ AmpGlobalEntityServiceImpl,
32
+ AmpSaaSEntityService,
33
+ AmpSaaSEntityServiceImpl,
34
+ AmpSdkTenantService,
35
+ } from './entity.service';
28
36
  import {AmpRestClientOptions, RestClient, getAmpRestClient} from './rest';
29
37
  import {KIND, TARGET_API_PLATFORM} from './constants';
30
38
  import {PlatformJobSpecDto, PlatformJobSpecUpsertDto} from '../dto/platform/platform.jobSpec.dto';
@@ -58,7 +66,7 @@ export class AmpSdkServices {
58
66
  readonly saasComponents: AmpSaaSEntityService<PlatformSaasComponentUpsertDto, PlatformSaasComponentDto>;
59
67
  readonly saasUsers: AmpSaaSEntityService<PlatformSaasUserUpsertDto, PlatformSaasUserDto>;
60
68
  readonly settings: AmpSettingsService;
61
- readonly tenants: AmpEntityService<TenantUpsertDto, TenantDto>;
69
+ readonly tenants: AmpSdkTenantService<TenantUpsertDto, TenantDto>;
62
70
  readonly users: AmpGlobalEntityService<PlatformUserUpsertDto, PlatformUserDto>;
63
71
 
64
72
  constructor(rest: RestClient) {
@@ -8,6 +8,11 @@ export interface AmpEntityService<WriteT extends BaseUpsertDto, ReadT extends Ba
8
8
  update(_model: WriteT): Promise<Page<ReadT>>;
9
9
  delete(_id: string): Promise<Page<ReadT>>;
10
10
  }
11
+ export interface AmpSdkTenantService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
12
+ create(_model: WriteT): Promise<Page<ReadT>>;
13
+ update(_model: WriteT): Promise<Page<ReadT>>;
14
+ delete(_id: string, _deleteRelated?: boolean): Promise<Page<ReadT>>;
15
+ }
11
16
  export interface AmpGlobalEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
12
17
  create(_model: WriteT): Promise<Page<ReadT>>;
13
18
  update(_model: WriteT): Promise<Page<ReadT>>;
@@ -42,12 +47,13 @@ export class AmpEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends Ba
42
47
  });
43
48
  }
44
49
 
45
- async delete(id: string): Promise<Page<ReadT>> {
50
+ async delete(id: string, deleteRelated?: boolean): Promise<Page<ReadT>> {
46
51
  const res = await this.getById(id);
47
52
  if (res.data.length === 1) {
48
53
  const req: RestRequest = {
49
54
  url: `/${this.targetApi}/v1/${this.kind}/${id}`,
50
55
  method: 'DELETE',
56
+ params: {deleteRelated},
51
57
  };
52
58
  const {error} = await this.call(req, (error: unknown) => {
53
59
  if (error instanceof Error) {