@ampsec/platform-client 3.0.0 → 4.0.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.
Files changed (118) hide show
  1. package/build/src/FilterCriteria.d.ts +18 -0
  2. package/build/src/FilterCriteria.js +3 -0
  3. package/build/src/FilterCriteria.js.map +1 -0
  4. package/build/src/dto/enums/agent.status.js +1 -0
  5. package/build/src/dto/enums/agent.status.js.map +1 -1
  6. package/build/src/dto/enums/connector.status.js +1 -0
  7. package/build/src/dto/enums/connector.status.js.map +1 -1
  8. package/build/src/dto/enums/finding.severity.js +1 -0
  9. package/build/src/dto/enums/finding.severity.js.map +1 -1
  10. package/build/src/dto/enums/finding.status.js +1 -0
  11. package/build/src/dto/enums/finding.status.js.map +1 -1
  12. package/build/src/dto/page.dto.d.ts +8 -0
  13. package/build/src/dto/platform/platform.agents.dto.d.ts +2 -2
  14. package/build/src/dto/platform/platform.assets.dto.d.ts +2 -2
  15. package/build/src/dto/platform/platform.connectors.dto.d.ts +2 -2
  16. package/build/src/dto/platform/platform.findings.dto.d.ts +2 -2
  17. package/build/src/dto/platform/platform.metrics.dto.d.ts +2 -2
  18. package/build/src/dto/platform/platform.reportResults.dto.d.ts +2 -2
  19. package/build/src/dto/platform/platform.saasAssets.dto.d.ts +2 -2
  20. package/build/src/dto/platform/platform.saasComponents.dto.d.ts +2 -2
  21. package/build/src/dto/platform/platform.saasUsers.dto.d.ts +1 -1
  22. package/build/src/dto/platform/platform.users.dto.d.ts +2 -2
  23. package/build/src/etag.d.ts +3 -0
  24. package/build/src/etag.js +6 -1
  25. package/build/src/etag.js.map +1 -1
  26. package/build/src/index.d.ts +2 -0
  27. package/build/src/index.js +2 -0
  28. package/build/src/index.js.map +1 -1
  29. package/build/src/services/AmpApi.d.ts +32 -0
  30. package/build/src/services/AmpApi.js +39 -0
  31. package/build/src/services/AmpApi.js.map +1 -0
  32. package/build/src/services/AmpSdk.d.ts +31 -0
  33. package/build/src/services/AmpSdk.js +38 -0
  34. package/build/src/services/AmpSdk.js.map +1 -0
  35. package/build/src/services/data.service.d.ts +23 -0
  36. package/build/src/services/data.service.js +52 -0
  37. package/build/src/services/data.service.js.map +1 -0
  38. package/build/src/services/entity.service.d.ts +34 -0
  39. package/build/src/services/entity.service.js +78 -0
  40. package/build/src/services/entity.service.js.map +1 -0
  41. package/build/src/services/index.d.ts +5 -0
  42. package/build/src/services/index.js +22 -0
  43. package/build/src/services/index.js.map +1 -0
  44. package/build/src/services/rest/RestClient.d.ts +46 -0
  45. package/build/src/services/rest/RestClient.js +106 -0
  46. package/build/src/services/rest/RestClient.js.map +1 -0
  47. package/build/src/services/rest/RestRequest.d.ts +8 -0
  48. package/build/src/services/rest/RestRequest.js +3 -0
  49. package/build/src/services/rest/RestRequest.js.map +1 -0
  50. package/build/src/services/rest/RestResponse.d.ts +7 -0
  51. package/build/src/services/rest/RestResponse.js +3 -0
  52. package/build/src/services/rest/RestResponse.js.map +1 -0
  53. package/build/src/services/rest/index.d.ts +5 -0
  54. package/build/src/services/rest/index.js +22 -0
  55. package/build/src/services/rest/index.js.map +1 -0
  56. package/build/src/services/rest/rateLimit.rest.d.ts +11 -0
  57. package/build/src/services/rest/rateLimit.rest.js +25 -0
  58. package/build/src/services/rest/rateLimit.rest.js.map +1 -0
  59. package/build/src/services/rest/retry.rest.d.ts +7 -0
  60. package/build/src/services/rest/retry.rest.js +18 -0
  61. package/build/src/services/rest/retry.rest.js.map +1 -0
  62. package/build/src/services/rest/utils.d.ts +7 -0
  63. package/build/src/services/rest/utils.js +12 -0
  64. package/build/src/services/rest/utils.js.map +1 -0
  65. package/package.json +7 -3
  66. package/src/FilterCriteria.ts +18 -0
  67. package/src/dto/agents.dto.ts +15 -0
  68. package/src/dto/assets.dto.ts +10 -0
  69. package/src/dto/base.dto.ts +25 -0
  70. package/src/dto/connectors.dto.ts +13 -0
  71. package/src/dto/enums/agent.status.ts +6 -0
  72. package/src/dto/enums/connector.status.ts +7 -0
  73. package/src/dto/enums/finding.severity.ts +7 -0
  74. package/src/dto/enums/finding.status.ts +5 -0
  75. package/src/dto/enums/index.ts +4 -0
  76. package/src/dto/extKeyMap.dto.ts +6 -0
  77. package/src/dto/findings.dto.ts +26 -0
  78. package/src/dto/index.ts +19 -0
  79. package/src/dto/message.dto.ts +3 -0
  80. package/src/dto/metrics.dto.ts +10 -0
  81. package/src/dto/page.dto.ts +14 -0
  82. package/src/dto/platform/index.ts +13 -0
  83. package/src/dto/platform/multi.tenant.based.dto.ts +11 -0
  84. package/src/dto/platform/platform.agents.dto.ts +6 -0
  85. package/src/dto/platform/platform.assets.dto.ts +6 -0
  86. package/src/dto/platform/platform.connectors.dto.ts +6 -0
  87. package/src/dto/platform/platform.findings.dto.ts +6 -0
  88. package/src/dto/platform/platform.metrics.dto.ts +6 -0
  89. package/src/dto/platform/platform.providers.dto.ts +5 -0
  90. package/src/dto/platform/platform.reportResults.dto.ts +6 -0
  91. package/src/dto/platform/platform.saasAssets.dto.ts +5 -0
  92. package/src/dto/platform/platform.saasComponents.dto.ts +6 -0
  93. package/src/dto/platform/platform.saasUsers.dto.ts +6 -0
  94. package/src/dto/platform/platform.tenants.dto.ts +5 -0
  95. package/src/dto/platform/platform.users.dto.ts +6 -0
  96. package/src/dto/platform/tenant.based.dto.ts +11 -0
  97. package/src/dto/providers.dto.ts +8 -0
  98. package/src/dto/reportResults.dto.ts +12 -0
  99. package/src/dto/riskContributors.dto.ts +10 -0
  100. package/src/dto/saasAssets.dto.ts +16 -0
  101. package/src/dto/saasComponents.dto.ts +18 -0
  102. package/src/dto/saasUsers.dto.ts +14 -0
  103. package/src/dto/tenants.dto.ts +8 -0
  104. package/src/dto/users.dto.ts +28 -0
  105. package/src/etag.ts +17 -0
  106. package/src/index.ts +4 -0
  107. package/src/services/AmpApi.ts +66 -0
  108. package/src/services/AmpSdk.ts +72 -0
  109. package/src/services/data.service.ts +69 -0
  110. package/src/services/entity.service.ts +104 -0
  111. package/src/services/index.ts +5 -0
  112. package/src/services/rest/RestClient.ts +103 -0
  113. package/src/services/rest/RestRequest.ts +9 -0
  114. package/src/services/rest/RestResponse.ts +8 -0
  115. package/src/services/rest/index.ts +5 -0
  116. package/src/services/rest/rateLimit.rest.ts +31 -0
  117. package/src/services/rest/retry.rest.ts +21 -0
  118. package/src/services/rest/utils.ts +13 -0
@@ -0,0 +1,18 @@
1
+ export type FilterCriteria = {
2
+ /** Number of records to return. */
3
+ limit?: number;
4
+ /** Number of records to skip before capturing results. */
5
+ offset?: number;
6
+ /** Tenant ID */
7
+ tid?: number;
8
+ /** Connector ID */
9
+ cid?: number;
10
+ /** Organization name. Defaults to `*` which matches all organizations. */
11
+ organization?: '*' | 'EXTERNAL' | string;
12
+ /** Department name. Defaults to `*` which matches all departments. */
13
+ department?: '*' | string;
14
+ /** User ID */
15
+ uid?: number;
16
+ /** Asset ID */
17
+ aid?: number;
18
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=FilterCriteria.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterCriteria.js","sourceRoot":"","sources":["../../src/FilterCriteria.ts"],"names":[],"mappings":""}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AgentStatus = void 0;
4
+ /* eslint-disable no-unused-vars */
4
5
  var AgentStatus;
5
6
  (function (AgentStatus) {
6
7
  AgentStatus["ACTIVE"] = "ACTIVE";
@@ -1 +1 @@
1
- {"version":3,"file":"agent.status.js","sourceRoot":"","sources":["../../../../src/dto/enums/agent.status.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,kCAAmB,CAAA;IACnB,sCAAuB,CAAA;AACzB,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB"}
1
+ {"version":3,"file":"agent.status.js","sourceRoot":"","sources":["../../../../src/dto/enums/agent.status.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,kCAAmB,CAAA;IACnB,sCAAuB,CAAA;AACzB,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConnectorStatus = void 0;
4
+ /* eslint-disable no-unused-vars */
4
5
  var ConnectorStatus;
5
6
  (function (ConnectorStatus) {
6
7
  ConnectorStatus["ACTIVE"] = "ACTIVE";
@@ -1 +1 @@
1
- {"version":3,"file":"connector.status.js","sourceRoot":"","sources":["../../../../src/dto/enums/connector.status.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;IACjB,wCAAqB,CAAA;AACvB,CAAC,EALW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAK1B"}
1
+ {"version":3,"file":"connector.status.js","sourceRoot":"","sources":["../../../../src/dto/enums/connector.status.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;IACjB,wCAAqB,CAAA;AACvB,CAAC,EALW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAK1B"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FindingSeverity = void 0;
4
+ /* eslint-disable no-unused-vars */
4
5
  var FindingSeverity;
5
6
  (function (FindingSeverity) {
6
7
  FindingSeverity["LOW"] = "LOW";
@@ -1 +1 @@
1
- {"version":3,"file":"finding.severity.js","sourceRoot":"","sources":["../../../../src/dto/enums/finding.severity.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,oCAAiB,CAAA;IACjB,gCAAa,CAAA;IACb,wCAAqB,CAAA;AACvB,CAAC,EALW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAK1B"}
1
+ {"version":3,"file":"finding.severity.js","sourceRoot":"","sources":["../../../../src/dto/enums/finding.severity.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,oCAAiB,CAAA;IACjB,gCAAa,CAAA;IACb,wCAAqB,CAAA;AACvB,CAAC,EALW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAK1B"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FindingStatus = void 0;
4
+ /* eslint-disable no-unused-vars */
4
5
  var FindingStatus;
5
6
  (function (FindingStatus) {
6
7
  FindingStatus["OPEN"] = "OPEN";
@@ -1 +1 @@
1
- {"version":3,"file":"finding.status.js","sourceRoot":"","sources":["../../../../src/dto/enums/finding.status.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,kCAAiB,CAAA;AACnB,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB"}
1
+ {"version":3,"file":"finding.status.js","sourceRoot":"","sources":["../../../../src/dto/enums/finding.status.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,kCAAiB,CAAA;AACnB,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB"}
@@ -3,6 +3,14 @@ export type Page<T> = {
3
3
  data: T[];
4
4
  error: string | null;
5
5
  hints: {
6
+ limit?: number;
7
+ offset?: number;
8
+ hasMore?: boolean;
9
+ next?: string;
10
+ count?: number;
11
+ links?: {
12
+ [keyName: string]: string;
13
+ };
6
14
  [propName: string]: number | string | boolean | null | {
7
15
  [keyName: string]: string;
8
16
  } | undefined;
@@ -1,4 +1,4 @@
1
- import { AgentUpsertDto } from '../agents.dto';
1
+ import { AgentDto, AgentUpsertDto } from '../agents.dto';
2
2
  import { MultiTenantBased, UpsertMultiTenantBased } from './multi.tenant.based.dto';
3
3
  export type PlatformAgentUpsertDto = AgentUpsertDto & UpsertMultiTenantBased;
4
- export type PlatformAgentDto = MultiTenantBased & PlatformAgentUpsertDto;
4
+ export type PlatformAgentDto = AgentDto & MultiTenantBased;
@@ -1,4 +1,4 @@
1
- import { AssetUpsertDto } from '../assets.dto';
1
+ import { AssetDto, AssetUpsertDto } from '../assets.dto';
2
2
  import { TenantBased, UpsertTenantBased } from './tenant.based.dto';
3
3
  export type PlatformAssetUpsertDto = AssetUpsertDto & UpsertTenantBased;
4
- export type PlatformAssetDto = TenantBased & PlatformAssetUpsertDto;
4
+ export type PlatformAssetDto = AssetDto & TenantBased;
@@ -1,4 +1,4 @@
1
- import { ConnectorUpsertDto } from '../connectors.dto';
1
+ import { ConnectorDto, ConnectorUpsertDto } from '../connectors.dto';
2
2
  import { TenantBased, UpsertTenantBased } from './tenant.based.dto';
3
3
  export type PlatformConnectorUpsertDto = ConnectorUpsertDto & UpsertTenantBased;
4
- export type PlatformConnectorDto = TenantBased & PlatformConnectorUpsertDto;
4
+ export type PlatformConnectorDto = ConnectorDto & TenantBased;
@@ -1,4 +1,4 @@
1
- import { FindingUpsertDto } from '../findings.dto';
1
+ import { FindingDto, FindingUpsertDto } from '../findings.dto';
2
2
  import { TenantBased, UpsertTenantBased } from './tenant.based.dto';
3
3
  export type PlatformFindingUpsertDto = FindingUpsertDto & UpsertTenantBased;
4
- export type PlatformFindingDto = TenantBased & PlatformFindingUpsertDto;
4
+ export type PlatformFindingDto = FindingDto & TenantBased;
@@ -1,4 +1,4 @@
1
- import { MetricUpsertDto } from '../metrics.dto';
1
+ import { MetricDto, MetricUpsertDto } from '../metrics.dto';
2
2
  import { TenantBased, UpsertTenantBased } from './tenant.based.dto';
3
3
  export type PlatformMetricUpsertDto = MetricUpsertDto & UpsertTenantBased;
4
- export type PlatformMetricDto = TenantBased & PlatformMetricUpsertDto;
4
+ export type PlatformMetricDto = MetricDto & TenantBased;
@@ -1,4 +1,4 @@
1
- import { ReportResultUpsertDto } from '../reportResults.dto';
1
+ import { ReportResultDto, ReportResultUpsertDto } from '../reportResults.dto';
2
2
  import { TenantBased, UpsertTenantBased } from './tenant.based.dto';
3
3
  export type PlatformReportResultUpsertDto = ReportResultUpsertDto & UpsertTenantBased;
4
- export type PlatformReportResultDto = TenantBased & PlatformReportResultUpsertDto;
4
+ export type PlatformReportResultDto = ReportResultDto & TenantBased;
@@ -1,4 +1,4 @@
1
- import { SaasAssetUpsertDto } from '../saasAssets.dto';
1
+ import { SaasAssetDto, SaasAssetUpsertDto } from '../saasAssets.dto';
2
2
  import { TenantBased, UpsertTenantBased } from './tenant.based.dto';
3
3
  export type PlatformSaasAssetUpsertDto = SaasAssetUpsertDto & UpsertTenantBased;
4
- export type PlatformSaasAssetDto = TenantBased & PlatformSaasAssetUpsertDto;
4
+ export type PlatformSaasAssetDto = SaasAssetDto & TenantBased;
@@ -1,4 +1,4 @@
1
- import { SaasComponentUpsertDto } from '../saasComponents.dto';
1
+ import { SaasComponentDto, SaasComponentUpsertDto } from '../saasComponents.dto';
2
2
  import { TenantBased, UpsertTenantBased } from './tenant.based.dto';
3
3
  export type PlatformSaasComponentUpsertDto = SaasComponentUpsertDto & UpsertTenantBased;
4
- export type PlatformSaasComponentDto = TenantBased & PlatformSaasComponentUpsertDto;
4
+ export type PlatformSaasComponentDto = SaasComponentDto & TenantBased;
@@ -1,4 +1,4 @@
1
1
  import { SaasUserUpsertDto } from '../saasUsers.dto';
2
2
  import { TenantBased, UpsertTenantBased } from './tenant.based.dto';
3
3
  export type PlatformSaasUserUpsertDto = SaasUserUpsertDto & UpsertTenantBased;
4
- export type PlatformSaasUserDto = TenantBased & PlatformSaasUserUpsertDto;
4
+ export type PlatformSaasUserDto = SaasUserUpsertDto & TenantBased;
@@ -1,4 +1,4 @@
1
- import { UserUpsertDto } from '../users.dto';
1
+ import { UserDto, UserUpsertDto } from '../users.dto';
2
2
  import { TenantBased, UpsertTenantBased } from './tenant.based.dto';
3
3
  export type PlatformUserUpsertDto = UserUpsertDto & UpsertTenantBased;
4
- export type PlatformUserDto = TenantBased & PlatformUserUpsertDto;
4
+ export type PlatformUserDto = UserDto & TenantBased;
@@ -1,3 +1,6 @@
1
1
  import { ChangeAwareDto, ChangeAwareUpsertDto } from './';
2
2
  export declare function calculateEtag(model: unknown): string;
3
3
  export declare function withEtag(model: ChangeAwareDto | ChangeAwareUpsertDto): void;
4
+ export declare function createWithEtag<T extends {
5
+ etag: string;
6
+ }>(model: T): T;
package/build/src/etag.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.withEtag = exports.calculateEtag = void 0;
6
+ exports.createWithEtag = exports.withEtag = exports.calculateEtag = void 0;
7
7
  const blueimp_md5_1 = __importDefault(require("blueimp-md5"));
8
8
  function calculateEtag(model) {
9
9
  const hashObject = { ...model };
@@ -15,4 +15,9 @@ function withEtag(model) {
15
15
  model.etag = calculateEtag(model);
16
16
  }
17
17
  exports.withEtag = withEtag;
18
+ function createWithEtag(model) {
19
+ model.etag = calculateEtag(model);
20
+ return model;
21
+ }
22
+ exports.createWithEtag = createWithEtag;
18
23
  //# sourceMappingURL=etag.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"etag.js","sourceRoot":"","sources":["../../src/etag.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA8B;AAG9B,SAAgB,aAAa,CAAC,KAAc;IAC1C,MAAM,UAAU,GAAoB,EAAC,GAAI,KAAgB,EAAC,CAAC;IAC3D,OAAO,UAAU,CAAC,IAAI,CAAC;IACvB,OAAO,IAAA,qBAAG,EAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;AACzC,CAAC;AAJD,sCAIC;AAED,SAAgB,QAAQ,CAAC,KAA4C;IACnE,KAAK,CAAC,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAFD,4BAEC"}
1
+ {"version":3,"file":"etag.js","sourceRoot":"","sources":["../../src/etag.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA8B;AAG9B,SAAgB,aAAa,CAAC,KAAc;IAC1C,MAAM,UAAU,GAAoB,EAAC,GAAI,KAAgB,EAAC,CAAC;IAC3D,OAAO,UAAU,CAAC,IAAI,CAAC;IACvB,OAAO,IAAA,qBAAG,EAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;AACzC,CAAC;AAJD,sCAIC;AAED,SAAgB,QAAQ,CAAC,KAA4C;IACnE,KAAK,CAAC,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAFD,4BAEC;AAED,SAAgB,cAAc,CAA2B,KAAQ;IAC/D,KAAK,CAAC,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC;AACf,CAAC;AAHD,wCAGC"}
@@ -1,2 +1,4 @@
1
1
  export * from './dto';
2
2
  export * from './etag';
3
+ export * from './services';
4
+ export * from './FilterCriteria';
@@ -16,4 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./dto"), exports);
18
18
  __exportStar(require("./etag"), exports);
19
+ __exportStar(require("./services"), exports);
20
+ __exportStar(require("./FilterCriteria"), exports);
19
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,yCAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,yCAAuB;AACvB,6CAA2B;AAC3B,mDAAiC"}
@@ -0,0 +1,32 @@
1
+ import { AgentDto, AgentUpsertDto, AssetDto, ConnectorDto, ConnectorUpsertDto, FindingDto, ProviderDto, ReportResultDto, SaasAssetDto, SaasComponentDto, SaasUserDto, TenantDto, TenantUpsertDto, UserDto } from '../dto';
2
+ import { AmpEntityService } from './entity.service';
3
+ import { AmpDataService } from './data.service';
4
+ import { AmpRestClientOptions, RestClient } from './rest';
5
+ export type AmpApiOptions = AmpRestClientOptions;
6
+ /**
7
+ * AMP API
8
+ * This client is a wrapper around the AMP REST API meant to be used by
9
+ * agents, i.e. Amplifier Security's customers. If you are trying to implement
10
+ * a plugin leverage the AmpSdk instead (see {@link AmpSdkServices} ).
11
+ *
12
+ * This client provides READ_ONLY access to most of the AMP API. You will
13
+ * have write access to the following resources:
14
+ * - Agents: {@link AmpApi.agents}
15
+ * - Connectors: {@link AmpApi.connectors}
16
+ * - Tenants: {@link AmpApi.tenants}
17
+ */
18
+ export declare class AmpApi {
19
+ readonly agents: AmpEntityService<AgentUpsertDto, AgentDto>;
20
+ readonly asset: AmpDataService<AssetDto>;
21
+ readonly connectors: AmpEntityService<ConnectorUpsertDto, ConnectorDto>;
22
+ readonly findings: AmpDataService<FindingDto>;
23
+ readonly providers: AmpDataService<ProviderDto>;
24
+ readonly reports: AmpDataService<ReportResultDto>;
25
+ readonly saasAssets: AmpDataService<SaasAssetDto>;
26
+ readonly saasComponents: AmpDataService<SaasComponentDto>;
27
+ readonly saasUsers: AmpDataService<SaasUserDto>;
28
+ readonly tenants: AmpEntityService<TenantUpsertDto, TenantDto>;
29
+ readonly users: AmpDataService<UserDto>;
30
+ constructor(rest: RestClient);
31
+ static instance(options: AmpApiOptions): AmpApi;
32
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AmpApi = void 0;
4
+ const entity_service_1 = require("./entity.service");
5
+ const data_service_1 = require("./data.service");
6
+ const rest_1 = require("./rest");
7
+ /**
8
+ * AMP API
9
+ * This client is a wrapper around the AMP REST API meant to be used by
10
+ * agents, i.e. Amplifier Security's customers. If you are trying to implement
11
+ * a plugin leverage the AmpSdk instead (see {@link AmpSdkServices} ).
12
+ *
13
+ * This client provides READ_ONLY access to most of the AMP API. You will
14
+ * have write access to the following resources:
15
+ * - Agents: {@link AmpApi.agents}
16
+ * - Connectors: {@link AmpApi.connectors}
17
+ * - Tenants: {@link AmpApi.tenants}
18
+ */
19
+ class AmpApi {
20
+ constructor(rest) {
21
+ this.agents = new entity_service_1.AmpEntityServiceImpl(rest, 'agents');
22
+ this.asset = new data_service_1.AmpDataServiceImpl(rest, 'assets');
23
+ this.connectors = new entity_service_1.AmpEntityServiceImpl(rest, 'connectors');
24
+ this.findings = new data_service_1.AmpDataServiceImpl(rest, 'findings');
25
+ this.providers = new data_service_1.AmpDataServiceImpl(rest, 'providers');
26
+ this.reports = new data_service_1.AmpDataServiceImpl(rest, 'report_results');
27
+ this.saasAssets = new data_service_1.AmpDataServiceImpl(rest, 'saas_assets');
28
+ this.saasComponents = new data_service_1.AmpDataServiceImpl(rest, 'saas_components');
29
+ this.saasUsers = new data_service_1.AmpDataServiceImpl(rest, 'saas_users');
30
+ this.tenants = new entity_service_1.AmpEntityServiceImpl(rest, 'agents');
31
+ this.users = new data_service_1.AmpDataServiceImpl(rest, 'users');
32
+ }
33
+ static instance(options) {
34
+ const rest = (0, rest_1.getAmpRestClient)(options);
35
+ return new AmpApi(rest);
36
+ }
37
+ }
38
+ exports.AmpApi = AmpApi;
39
+ //# sourceMappingURL=AmpApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AmpApi.js","sourceRoot":"","sources":["../../../src/services/Am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"}
@@ -0,0 +1,31 @@
1
+ import { ConnectorDto, ConnectorUpsertDto, PlatformAgentDto, PlatformAgentUpsertDto, PlatformAssetDto, PlatformAssetUpsertDto, PlatformFindingDto, PlatformFindingUpsertDto, PlatformReportResultDto, PlatformReportResultUpsertDto, PlatformSaasAssetDto, PlatformSaasAssetUpsertDto, PlatformSaasComponentDto, PlatformSaasComponentUpsertDto, PlatformSaasUserDto, PlatformSaasUserUpsertDto, PlatformUserDto, PlatformUserUpsertDto, ProviderDto, TenantDto, TenantUpsertDto } from '../dto';
2
+ import { AmpEntityService, AmpGlobalEntityService, AmpSaaSEntityService } from './entity.service';
3
+ import { AmpDataService } from './data.service';
4
+ import { AmpRestClientOptions, RestClient } from './rest';
5
+ export type AmpSdkOptions = AmpRestClientOptions;
6
+ /**
7
+ * AMP API
8
+ * This client is a wrapper around the AMP REST API meant to be used by
9
+ * service accounts, i.e. plugins and platform extensions. If you are
10
+ * trying to implement a simple web client you should leverage the AmpApi
11
+ * instead (see {@link AmpApi} ).
12
+ *
13
+ * This client provides CRUD access to most of the AMP API. You
14
+ * have READ_ONLY access to the following resources:
15
+ * - providers: {@link AmpSdkServices.providers}
16
+ */
17
+ export declare class AmpSdkServices {
18
+ readonly agents: AmpEntityService<PlatformAgentUpsertDto, PlatformAgentDto>;
19
+ readonly asset: AmpGlobalEntityService<PlatformAssetUpsertDto, PlatformAssetDto>;
20
+ readonly connectors: AmpEntityService<ConnectorUpsertDto, ConnectorDto>;
21
+ readonly findings: AmpSaaSEntityService<PlatformFindingUpsertDto, PlatformFindingDto>;
22
+ readonly providers: AmpDataService<ProviderDto>;
23
+ readonly reports: AmpSaaSEntityService<PlatformReportResultUpsertDto, PlatformReportResultDto>;
24
+ readonly saasAssets: AmpSaaSEntityService<PlatformSaasAssetUpsertDto, PlatformSaasAssetDto>;
25
+ readonly saasComponents: AmpSaaSEntityService<PlatformSaasComponentUpsertDto, PlatformSaasComponentDto>;
26
+ readonly saasUsers: AmpSaaSEntityService<PlatformSaasUserUpsertDto, PlatformSaasUserDto>;
27
+ readonly tenants: AmpEntityService<TenantUpsertDto, TenantDto>;
28
+ readonly users: AmpGlobalEntityService<PlatformUserUpsertDto, PlatformUserDto>;
29
+ constructor(rest: RestClient);
30
+ static instance(options: AmpSdkOptions): AmpSdkServices;
31
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AmpSdkServices = void 0;
4
+ const entity_service_1 = require("./entity.service");
5
+ const data_service_1 = require("./data.service");
6
+ const rest_1 = require("./rest");
7
+ /**
8
+ * AMP API
9
+ * This client is a wrapper around the AMP REST API meant to be used by
10
+ * service accounts, i.e. plugins and platform extensions. If you are
11
+ * trying to implement a simple web client you should leverage the AmpApi
12
+ * instead (see {@link AmpApi} ).
13
+ *
14
+ * This client provides CRUD access to most of the AMP API. You
15
+ * have READ_ONLY access to the following resources:
16
+ * - providers: {@link AmpSdkServices.providers}
17
+ */
18
+ class AmpSdkServices {
19
+ constructor(rest) {
20
+ this.agents = new entity_service_1.AmpEntityServiceImpl(rest, 'agents', data_service_1.TARGET_API_PLATFORM);
21
+ this.asset = new entity_service_1.AmpGlobalEntityServiceImpl(rest, 'assets', data_service_1.TARGET_API_PLATFORM);
22
+ this.connectors = new entity_service_1.AmpEntityServiceImpl(rest, 'connectors', data_service_1.TARGET_API_PLATFORM);
23
+ this.findings = new entity_service_1.AmpSaaSEntityServiceImpl(rest, 'findings', data_service_1.TARGET_API_PLATFORM);
24
+ this.providers = new data_service_1.AmpDataServiceImpl(rest, 'providers', data_service_1.TARGET_API_AGENT);
25
+ this.reports = new entity_service_1.AmpSaaSEntityServiceImpl(rest, 'report_results', data_service_1.TARGET_API_PLATFORM);
26
+ this.saasAssets = new entity_service_1.AmpSaaSEntityServiceImpl(rest, 'saas_assets', data_service_1.TARGET_API_PLATFORM);
27
+ this.saasComponents = new entity_service_1.AmpSaaSEntityServiceImpl(rest, 'saas_components', data_service_1.TARGET_API_PLATFORM);
28
+ this.saasUsers = new entity_service_1.AmpSaaSEntityServiceImpl(rest, 'saas_users', data_service_1.TARGET_API_PLATFORM);
29
+ this.tenants = new entity_service_1.AmpEntityServiceImpl(rest, 'tenants', data_service_1.TARGET_API_PLATFORM);
30
+ this.users = new entity_service_1.AmpGlobalEntityServiceImpl(rest, 'users', data_service_1.TARGET_API_PLATFORM);
31
+ }
32
+ static instance(options) {
33
+ const rest = (0, rest_1.getAmpRestClient)(options);
34
+ return new AmpSdkServices(rest);
35
+ }
36
+ }
37
+ exports.AmpSdkServices = AmpSdkServices;
38
+ //# sourceMappingURL=AmpSdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AmpSdk.js","sourceRoot":"","sources":["../../../src/services/AmpSdk.ts"],"names":[],"mappings":";;;AAuBA,qDAA4K;AAC5K,iDAAyG;AACzG,iCAA0E;AAI1E;;;;;;;;;;GAUG;AACH,MAAa,cAAc;IAazB,YAAY,IAAgB;QAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,qCAAoB,CAA2C,IAAI,EAAE,QAAQ,EAAE,kCAAmB,CAAC,CAAC;QACtH,IAAI,CAAC,KAAK,GAAG,IAAI,2CAA0B,CAA2C,IAAI,EAAE,QAAQ,EAAE,kCAAmB,CAAC,CAAC;QAC3H,IAAI,CAAC,UAAU,GAAG,IAAI,qCAAoB,CAAmC,IAAI,EAAE,YAAY,EAAE,kCAAmB,CAAC,CAAC;QACtH,IAAI,CAAC,QAAQ,GAAG,IAAI,yCAAwB,CAA+C,IAAI,EAAE,UAAU,EAAE,kCAAmB,CAAC,CAAC;QAClI,IAAI,CAAC,SAAS,GAAG,IAAI,iCAAkB,CAAc,IAAI,EAAE,WAAW,EAAE,+BAAgB,CAAC,CAAC;QAC1F,IAAI,CAAC,OAAO,GAAG,IAAI,yCAAwB,CAAyD,IAAI,EAAE,gBAAgB,EAAE,kCAAmB,CAAC,CAAC;QACjJ,IAAI,CAAC,UAAU,GAAG,IAAI,yCAAwB,CAAmD,IAAI,EAAE,aAAa,EAAE,kCAAmB,CAAC,CAAC;QAC3I,IAAI,CAAC,cAAc,GAAG,IAAI,yCAAwB,CAA2D,IAAI,EAAE,iBAAiB,EAAE,kCAAmB,CAAC,CAAC;QAC3J,IAAI,CAAC,SAAS,GAAG,IAAI,yCAAwB,CAAiD,IAAI,EAAE,YAAY,EAAE,kCAAmB,CAAC,CAAC;QACvI,IAAI,CAAC,OAAO,GAAG,IAAI,qCAAoB,CAA6B,IAAI,EAAE,SAAS,EAAE,kCAAmB,CAAC,CAAC;QAC1G,IAAI,CAAC,KAAK,GAAG,IAAI,2CAA0B,CAAyC,IAAI,EAAE,OAAO,EAAE,kCAAmB,CAAC,CAAC;IAC1H,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;AA/BD,wCA+BC"}
@@ -0,0 +1,23 @@
1
+ import { BaseDto, Page } from '../dto';
2
+ import { FilterCriteria } from '../FilterCriteria';
3
+ import { RestClient, RestRequest } from './rest';
4
+ export interface AmpDataService<ReadT extends BaseDto> {
5
+ list(_filter: FilterCriteria): Promise<Page<ReadT>>;
6
+ getById(_id: number): Promise<Page<ReadT>>;
7
+ }
8
+ export interface ErrorHandler<T> {
9
+ (_error: unknown): T;
10
+ }
11
+ export type TargetApi = 'api' | 'platform';
12
+ export declare const TARGET_API_PLATFORM: TargetApi;
13
+ export declare const TARGET_API_AGENT: TargetApi;
14
+ export declare class AmpDataServiceImpl<ReadT extends BaseDto> implements AmpDataService<ReadT> {
15
+ protected readonly rest: RestClient;
16
+ protected readonly kind: string;
17
+ protected readonly targetApi: string;
18
+ constructor(rest: RestClient, kind: string, targetApi?: TargetApi);
19
+ protected call<T>(req: RestRequest, errorHandler: ErrorHandler<T>): Promise<T>;
20
+ protected getPage(req: RestRequest): Promise<Page<ReadT>>;
21
+ list(filter: FilterCriteria): Promise<Page<ReadT>>;
22
+ getById(id: number): Promise<Page<ReadT>>;
23
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AmpDataServiceImpl = exports.TARGET_API_AGENT = exports.TARGET_API_PLATFORM = void 0;
4
+ exports.TARGET_API_PLATFORM = 'platform';
5
+ exports.TARGET_API_AGENT = 'api';
6
+ class AmpDataServiceImpl {
7
+ constructor(rest, kind, targetApi = 'api') {
8
+ this.rest = rest;
9
+ this.kind = kind;
10
+ this.targetApi = targetApi;
11
+ }
12
+ async call(req, errorHandler) {
13
+ try {
14
+ const res = await this.rest.call(req);
15
+ return res.data;
16
+ }
17
+ catch (error) {
18
+ if (error instanceof Error) {
19
+ console.error(error.message);
20
+ }
21
+ return errorHandler(error);
22
+ }
23
+ }
24
+ async getPage(req) {
25
+ return this.call(req, (error) => {
26
+ if (error instanceof Error) {
27
+ console.error(error.message);
28
+ }
29
+ return {
30
+ data: [],
31
+ kind: this.kind.toUpperCase(),
32
+ error: error.message,
33
+ hints: {},
34
+ };
35
+ });
36
+ }
37
+ list(filter) {
38
+ return this.getPage({
39
+ url: `/${this.targetApi}/v1/${this.kind}`,
40
+ method: 'GET',
41
+ params: filter,
42
+ });
43
+ }
44
+ getById(id) {
45
+ return this.getPage({
46
+ url: `/${this.targetApi}/v1/${this.kind}/${id}`,
47
+ method: 'GET',
48
+ });
49
+ }
50
+ }
51
+ exports.AmpDataServiceImpl = AmpDataServiceImpl;
52
+ //# sourceMappingURL=data.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.service.js","sourceRoot":"","sources":["../../../src/services/data.service.ts"],"names":[],"mappings":";;;AAca,QAAA,mBAAmB,GAAc,UAAU,CAAC;AAC5C,QAAA,gBAAgB,GAAc,KAAK,CAAC;AAEjD,MAAa,kBAAkB;IAK7B,YAAY,IAAgB,EAAE,IAAY,EAAE,YAAuB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,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE;YAC/C,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IACL,CAAC;CACF;AAnDD,gDAmDC"}
@@ -0,0 +1,34 @@
1
+ import { BaseDto, BaseUpsertDto, ExtKeyMap, Page } from '../dto';
2
+ import { AmpDataService, AmpDataServiceImpl, TargetApi } from './data.service';
3
+ import { RestClient } from './rest';
4
+ export interface AmpEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
5
+ create(_model: WriteT): Promise<Page<ReadT>>;
6
+ update(_model: WriteT): Promise<Page<ReadT>>;
7
+ delete(_id: number): Promise<Page<ReadT>>;
8
+ }
9
+ export interface AmpGlobalEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
10
+ create(_model: WriteT): Promise<Page<ReadT>>;
11
+ update(_model: WriteT): Promise<Page<ReadT>>;
12
+ delete(_id: number): Promise<Page<ReadT>>;
13
+ getLookupIds(_tid: number): Promise<ExtKeyMap>;
14
+ }
15
+ export interface AmpSaaSEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
16
+ create(_model: WriteT): Promise<Page<ReadT>>;
17
+ update(_model: WriteT): Promise<Page<ReadT>>;
18
+ delete(_id: number): Promise<Page<ReadT>>;
19
+ getLookupIds(_cid: number): Promise<ExtKeyMap>;
20
+ }
21
+ export declare class AmpEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataServiceImpl<ReadT> implements AmpEntityService<WriteT, ReadT> {
22
+ constructor(rest: RestClient, kind: string, targetApi?: TargetApi);
23
+ create(model: WriteT): Promise<Page<ReadT>>;
24
+ update(model: WriteT): Promise<Page<ReadT>>;
25
+ delete(id: number): Promise<Page<ReadT>>;
26
+ }
27
+ export declare class AmpGlobalEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpEntityServiceImpl<WriteT, ReadT> implements AmpGlobalEntityService<WriteT, ReadT> {
28
+ constructor(rest: RestClient, kind: string, targetApi?: TargetApi);
29
+ getLookupIds(tid: number): Promise<ExtKeyMap>;
30
+ }
31
+ export declare class AmpSaaSEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpEntityServiceImpl<WriteT, ReadT> implements AmpSaaSEntityService<WriteT, ReadT> {
32
+ constructor(rest: RestClient, kind: string, targetApi?: TargetApi);
33
+ getLookupIds(cid: number): Promise<ExtKeyMap>;
34
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AmpSaaSEntityServiceImpl = exports.AmpGlobalEntityServiceImpl = exports.AmpEntityServiceImpl = void 0;
4
+ const data_service_1 = require("./data.service");
5
+ class AmpEntityServiceImpl extends data_service_1.AmpDataServiceImpl {
6
+ constructor(rest, kind, targetApi = data_service_1.TARGET_API_AGENT) {
7
+ super(rest, kind, targetApi);
8
+ }
9
+ create(model) {
10
+ return this.getPage({
11
+ url: `/${this.targetApi}/v1/${this.kind}`,
12
+ method: 'POST',
13
+ data: model,
14
+ });
15
+ }
16
+ update(model) {
17
+ return this.getPage({
18
+ url: `/${this.targetApi}/v1/${this.kind}/${model.id}`,
19
+ method: 'PUT',
20
+ data: model,
21
+ });
22
+ }
23
+ async delete(id) {
24
+ const res = await this.getById(id);
25
+ if (res.data.length === 1) {
26
+ const req = {
27
+ url: `/${this.targetApi}/v1/${this.kind}/${id}`,
28
+ method: 'DELETE',
29
+ };
30
+ const { error } = await this.call(req, (error) => {
31
+ if (error instanceof Error) {
32
+ console.error(error.message);
33
+ }
34
+ return { success: false, error };
35
+ });
36
+ if (error) {
37
+ throw new Error(`Failed to delete ${this.kind} with id="${id}"`);
38
+ }
39
+ }
40
+ return res;
41
+ }
42
+ }
43
+ exports.AmpEntityServiceImpl = AmpEntityServiceImpl;
44
+ const extIdMapErrorHandler = (error) => {
45
+ if (error instanceof Error) {
46
+ console.error(error.message);
47
+ }
48
+ return {};
49
+ };
50
+ class AmpGlobalEntityServiceImpl extends AmpEntityServiceImpl {
51
+ constructor(rest, kind, targetApi = data_service_1.TARGET_API_AGENT) {
52
+ super(rest, kind, targetApi);
53
+ }
54
+ getLookupIds(tid) {
55
+ const req = {
56
+ url: `/${this.targetApi}/v1/${this.kind}/ext_key_map`,
57
+ method: 'GET',
58
+ params: { tid },
59
+ };
60
+ return this.call(req, extIdMapErrorHandler);
61
+ }
62
+ }
63
+ exports.AmpGlobalEntityServiceImpl = AmpGlobalEntityServiceImpl;
64
+ class AmpSaaSEntityServiceImpl extends AmpEntityServiceImpl {
65
+ constructor(rest, kind, targetApi = data_service_1.TARGET_API_AGENT) {
66
+ super(rest, kind, targetApi);
67
+ }
68
+ getLookupIds(cid) {
69
+ const req = {
70
+ url: `/${this.targetApi}/v1/${this.kind}/ext_key_map`,
71
+ method: 'GET',
72
+ params: { cid },
73
+ };
74
+ return this.call(req, extIdMapErrorHandler);
75
+ }
76
+ }
77
+ exports.AmpSaaSEntityServiceImpl = AmpSaaSEntityServiceImpl;
78
+ //# sourceMappingURL=entity.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.service.js","sourceRoot":"","sources":["../../../src/services/entity.service.ts"],"names":[],"mappings":";;;AACA,iDAA6G;AAqB7G,MAAa,oBAA0E,SAAQ,iCAAyB;IACtH,YAAY,IAAgB,EAAE,IAAY,EAAE,YAAuB,+BAAgB;QACjF,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,EAAE;YACzC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,OAAO,I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AAE,IAAY,EAAE,YAAuB,+BAAgB;QACjF,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/B,CAAC;IACD,YAAY,CAAC,GAAW;QACtB,MAAM,GAAG,GAAgB;YACvB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,cAAc;YACrD,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,EAAC,GAAG,EAAC;SACd,CAAC;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;IAC9C,CAAC;CACF;AAfD,gEAeC;AAED,MAAa,wBACX,SAAQ,oBAAmC;IAG3C,YAAY,IAAgB,EAAE,IAAY,EAAE,YAAuB,+BAAgB;QACjF,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/B,CAAC;IACD,YAAY,CAAC,GAAW;QACtB,MAAM,GAAG,GAAgB;YACvB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,cAAc;YACrD,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,EAAC,GAAG,EAAC;SACd,CAAC;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;IAC9C,CAAC;CACF;AAfD,4DAeC"}
@@ -0,0 +1,5 @@
1
+ export * from './AmpApi';
2
+ export * from './AmpSdk';
3
+ export * from './data.service';
4
+ export * from './entity.service';
5
+ export * from './rest';
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AmpApi"), exports);
18
+ __exportStar(require("./AmpSdk"), exports);
19
+ __exportStar(require("./data.service"), exports);
20
+ __exportStar(require("./entity.service"), exports);
21
+ __exportStar(require("./rest"), exports);
22
+ //# sourceMappingURL=index.js.map