@hahnpro/hpc-api 2024.4.0-0 → 2025.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.
Files changed (134) hide show
  1. package/CHANGELOG.md +383 -0
  2. package/README.md +507 -0
  3. package/package.json +9 -7
  4. package/src/index.js +27 -20
  5. package/src/index.js.map +1 -0
  6. package/src/lib/Queue.js +21 -10
  7. package/src/lib/Queue.js.map +1 -0
  8. package/src/lib/api-base.js +15 -3
  9. package/src/lib/api-base.js.map +1 -0
  10. package/src/lib/api.js +53 -42
  11. package/src/lib/api.js.map +1 -0
  12. package/src/lib/asset.interface.js +6 -1
  13. package/src/lib/asset.interface.js.map +1 -0
  14. package/src/lib/asset.service.js +45 -20
  15. package/src/lib/asset.service.js.map +1 -0
  16. package/src/lib/assettypes.service.js +26 -12
  17. package/src/lib/assettypes.service.js.map +1 -0
  18. package/src/lib/content.interface.js +15 -3
  19. package/src/lib/content.interface.js.map +1 -0
  20. package/src/lib/content.service.js +62 -32
  21. package/src/lib/content.service.js.map +1 -0
  22. package/src/lib/data.interface.js +13 -1
  23. package/src/lib/data.interface.js.map +1 -0
  24. package/src/lib/data.service.js +45 -24
  25. package/src/lib/data.service.js.map +1 -0
  26. package/src/lib/endpoint.interface.js +6 -1
  27. package/src/lib/endpoint.interface.js.map +1 -0
  28. package/src/lib/endpoint.service.js +16 -4
  29. package/src/lib/endpoint.service.js.map +1 -0
  30. package/src/lib/events.interface.js +6 -1
  31. package/src/lib/events.interface.js.map +1 -0
  32. package/src/lib/events.service.js +16 -4
  33. package/src/lib/events.service.js.map +1 -0
  34. package/src/lib/flow-deployment.interface.js +6 -1
  35. package/src/lib/flow-deployment.interface.js.map +1 -0
  36. package/src/lib/flow-deployment.service.js +58 -25
  37. package/src/lib/flow-deployment.service.js.map +1 -0
  38. package/src/lib/flow-function.interface.js +6 -1
  39. package/src/lib/flow-function.interface.js.map +1 -0
  40. package/src/lib/flow-function.service.js +20 -6
  41. package/src/lib/flow-function.service.js.map +1 -0
  42. package/src/lib/flow-module.interface.js +6 -1
  43. package/src/lib/flow-module.interface.js.map +1 -0
  44. package/src/lib/flow-module.service.js +20 -6
  45. package/src/lib/flow-module.service.js.map +1 -0
  46. package/src/lib/flow.interface.js +6 -1
  47. package/src/lib/flow.interface.js.map +1 -0
  48. package/src/lib/flow.service.js +27 -13
  49. package/src/lib/flow.service.js.map +1 -0
  50. package/src/lib/http.service.d.ts +1 -1
  51. package/src/lib/http.service.js +102 -62
  52. package/src/lib/http.service.js.map +1 -0
  53. package/src/lib/label.interface.js +6 -1
  54. package/src/lib/label.interface.js.map +1 -0
  55. package/src/lib/label.service.js +17 -5
  56. package/src/lib/label.service.js.map +1 -0
  57. package/src/lib/mock/api-base.mock.js +17 -6
  58. package/src/lib/mock/api-base.mock.js.map +1 -0
  59. package/src/lib/mock/api.mock.js +204 -193
  60. package/src/lib/mock/api.mock.js.map +1 -0
  61. package/src/lib/mock/asset.mock.service.js +55 -38
  62. package/src/lib/mock/asset.mock.service.js.map +1 -0
  63. package/src/lib/mock/assetTypes.mock.service.js +45 -27
  64. package/src/lib/mock/assetTypes.mock.service.js.map +1 -0
  65. package/src/lib/mock/content.mock.service.js +45 -37
  66. package/src/lib/mock/content.mock.service.js.map +1 -0
  67. package/src/lib/mock/data.mock.service.js +49 -40
  68. package/src/lib/mock/data.mock.service.js.map +1 -0
  69. package/src/lib/mock/endpoint.mock.service.js +17 -5
  70. package/src/lib/mock/endpoint.mock.service.js.map +1 -0
  71. package/src/lib/mock/events.mock.service.js +16 -4
  72. package/src/lib/mock/events.mock.service.js.map +1 -0
  73. package/src/lib/mock/flow-deployment.mock.service.js +81 -36
  74. package/src/lib/mock/flow-deployment.mock.service.js.map +1 -0
  75. package/src/lib/mock/flow-functions.mock.service.js +33 -20
  76. package/src/lib/mock/flow-functions.mock.service.js.map +1 -0
  77. package/src/lib/mock/flow-modules.mock.service.js +18 -6
  78. package/src/lib/mock/flow-modules.mock.service.js.map +1 -0
  79. package/src/lib/mock/flow.mock.service.js +44 -29
  80. package/src/lib/mock/flow.mock.service.js.map +1 -0
  81. package/src/lib/mock/index.js +18 -11
  82. package/src/lib/mock/index.js.map +1 -0
  83. package/src/lib/mock/label.mock.service.js +17 -5
  84. package/src/lib/mock/label.mock.service.js.map +1 -0
  85. package/src/lib/mock/notification.mock.service.js +16 -4
  86. package/src/lib/mock/notification.mock.service.js.map +1 -0
  87. package/src/lib/mock/secret.mock.service.js +24 -12
  88. package/src/lib/mock/secret.mock.service.js.map +1 -0
  89. package/src/lib/mock/task.mock.service.js +24 -12
  90. package/src/lib/mock/task.mock.service.js.map +1 -0
  91. package/src/lib/mock/timeseries.mock.service.js +88 -43
  92. package/src/lib/mock/timeseries.mock.service.js.map +1 -0
  93. package/src/lib/mock/trash.mock.service.js +28 -14
  94. package/src/lib/mock/trash.mock.service.js.map +1 -0
  95. package/src/lib/mock/user.mock.service.js +17 -6
  96. package/src/lib/mock/user.mock.service.js.map +1 -0
  97. package/src/lib/mock/vault.mock.service.js +17 -5
  98. package/src/lib/mock/vault.mock.service.js.map +1 -0
  99. package/src/lib/notification.interface.js +6 -1
  100. package/src/lib/notification.interface.js.map +1 -0
  101. package/src/lib/notification.service.js +16 -4
  102. package/src/lib/notification.service.js.map +1 -0
  103. package/src/lib/proxy.service.js +19 -7
  104. package/src/lib/proxy.service.js.map +1 -0
  105. package/src/lib/resource.interface.js +6 -1
  106. package/src/lib/resource.interface.js.map +1 -0
  107. package/src/lib/schema.interface.js +6 -1
  108. package/src/lib/schema.interface.js.map +1 -0
  109. package/src/lib/secret.interface.js +6 -1
  110. package/src/lib/secret.interface.js.map +1 -0
  111. package/src/lib/secret.service.js +23 -11
  112. package/src/lib/secret.service.js.map +1 -0
  113. package/src/lib/storage.interface.js +6 -1
  114. package/src/lib/storage.interface.js.map +1 -0
  115. package/src/lib/task.interface.js +6 -1
  116. package/src/lib/task.interface.js.map +1 -0
  117. package/src/lib/task.service.js +23 -11
  118. package/src/lib/task.service.js.map +1 -0
  119. package/src/lib/timeseries.interface.js +6 -1
  120. package/src/lib/timeseries.interface.js.map +1 -0
  121. package/src/lib/timeseries.service.js +97 -66
  122. package/src/lib/timeseries.service.js.map +1 -0
  123. package/src/lib/token-set.js +15 -3
  124. package/src/lib/token-set.js.map +1 -0
  125. package/src/lib/trash.service.js +23 -5
  126. package/src/lib/trash.service.js.map +1 -0
  127. package/src/lib/user-settings.interface.js +6 -1
  128. package/src/lib/user-settings.interface.js.map +1 -0
  129. package/src/lib/user.service.js +18 -7
  130. package/src/lib/user.service.js.map +1 -0
  131. package/src/lib/vault.interface.js +6 -1
  132. package/src/lib/vault.interface.js.map +1 -0
  133. package/src/lib/vault.service.js +23 -6
  134. package/src/lib/vault.service.js.map +1 -0
package/src/lib/api.js CHANGED
@@ -1,31 +1,40 @@
1
- import { AssetService } from './asset.service';
2
- import { AssetTypesService } from './assettypes.service';
3
- import { ContentService } from './content.service';
4
- import { EndpointService } from './endpoint.service';
5
- import { EventsService } from './events.service';
6
- import { FlowDeploymentService } from './flow-deployment.service';
7
- import { FlowFunctionService } from './flow-function.service';
8
- import { FlowModuleService } from './flow-module.service';
9
- import { FlowService } from './flow.service';
10
- import { HttpClient } from './http.service';
11
- import { LabelService } from './label.service';
12
- import { NotificationService } from './notification.service';
13
- import { ProxyService } from './proxy.service';
14
- import { SecretService } from './secret.service';
15
- import { TaskService } from './task.service';
16
- import { TimeSeriesService } from './timeseries.service';
17
- import { UserService } from './user.service';
18
- import { VaultService } from './vault.service';
19
- export class API {
20
- constructor(httpClient, context) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "API", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return API;
9
+ }
10
+ });
11
+ const _assetservice = require("./asset.service");
12
+ const _assettypesservice = require("./assettypes.service");
13
+ const _contentservice = require("./content.service");
14
+ const _endpointservice = require("./endpoint.service");
15
+ const _eventsservice = require("./events.service");
16
+ const _flowdeploymentservice = require("./flow-deployment.service");
17
+ const _flowfunctionservice = require("./flow-function.service");
18
+ const _flowmoduleservice = require("./flow-module.service");
19
+ const _flowservice = require("./flow.service");
20
+ const _httpservice = require("./http.service");
21
+ const _labelservice = require("./label.service");
22
+ const _notificationservice = require("./notification.service");
23
+ const _proxyservice = require("./proxy.service");
24
+ const _secretservice = require("./secret.service");
25
+ const _taskservice = require("./task.service");
26
+ const _timeseriesservice = require("./timeseries.service");
27
+ const _userservice = require("./user.service");
28
+ const _vaultservice = require("./vault.service");
29
+ let API = class API {
30
+ constructor(httpClient, context){
21
31
  this.httpClient = httpClient;
22
32
  if (!httpClient) {
23
33
  // remove leading and trailing slashes
24
- const normalizePath = (value = '', defaultValue = '') => value.replace(/(?:^\/+)|(?:\/+$)/g, '') || defaultValue;
34
+ const normalizePath = (value = '', defaultValue = '')=>value.replace(/(?:^\/+)|(?:\/+$)/g, '') || defaultValue;
25
35
  let apiBaseUrl = process.env.API_BASE_URL || 'https://testing.hahnpro.com';
26
36
  if (!apiBaseUrl.startsWith('https') && !apiBaseUrl.startsWith('http')) {
27
- /* eslint-disable-next-line no-console */
28
- console.info('no protocol specified - using HTTPS');
37
+ /* eslint-disable-next-line no-console */ console.info('no protocol specified - using HTTPS');
29
38
  apiBaseUrl = `https://${apiBaseUrl}`;
30
39
  }
31
40
  const apiUrl = apiBaseUrl + '/' + normalizePath(process.env.API_BASE_PATH, 'api');
@@ -37,24 +46,26 @@ export class API {
37
46
  if (!secret) {
38
47
  throw new Error('"API_BASE_URL", "API_USER", "AUTH_REALM" and "AUTH_SECRET" environment variables must be set');
39
48
  }
40
- this.httpClient = new HttpClient(apiUrl, authUrl, realm, client, secret, context?.tokenSubject);
49
+ this.httpClient = new _httpservice.HttpClient(apiUrl, authUrl, realm, client, secret, context?.tokenSubject);
41
50
  }
42
- this.assets = new AssetService(this.httpClient);
43
- this.assetTypes = new AssetTypesService(this.httpClient);
44
- this.contents = new ContentService(this.httpClient);
45
- this.endpoints = new EndpointService(this.httpClient);
46
- this.events = new EventsService(this.httpClient);
47
- this.flows = new FlowService(this.httpClient);
48
- this.flowDeployments = new FlowDeploymentService(this.httpClient);
49
- this.flowFunctions = new FlowFunctionService(this.httpClient);
50
- this.flowModules = new FlowModuleService(this.httpClient);
51
- this.labels = new LabelService(this.httpClient);
52
- this.proxy = new ProxyService(this.httpClient);
53
- this.secrets = new SecretService(this.httpClient);
54
- this.tasks = new TaskService(this.httpClient);
55
- this.timeSeries = new TimeSeriesService(this.httpClient);
56
- this.users = new UserService(this.httpClient);
57
- this.vault = new VaultService(this.httpClient);
58
- this.notifications = new NotificationService(this.httpClient);
51
+ this.assets = new _assetservice.AssetService(this.httpClient);
52
+ this.assetTypes = new _assettypesservice.AssetTypesService(this.httpClient);
53
+ this.contents = new _contentservice.ContentService(this.httpClient);
54
+ this.endpoints = new _endpointservice.EndpointService(this.httpClient);
55
+ this.events = new _eventsservice.EventsService(this.httpClient);
56
+ this.flows = new _flowservice.FlowService(this.httpClient);
57
+ this.flowDeployments = new _flowdeploymentservice.FlowDeploymentService(this.httpClient);
58
+ this.flowFunctions = new _flowfunctionservice.FlowFunctionService(this.httpClient);
59
+ this.flowModules = new _flowmoduleservice.FlowModuleService(this.httpClient);
60
+ this.labels = new _labelservice.LabelService(this.httpClient);
61
+ this.proxy = new _proxyservice.ProxyService(this.httpClient);
62
+ this.secrets = new _secretservice.SecretService(this.httpClient);
63
+ this.tasks = new _taskservice.TaskService(this.httpClient);
64
+ this.timeSeries = new _timeseriesservice.TimeSeriesService(this.httpClient);
65
+ this.users = new _userservice.UserService(this.httpClient);
66
+ this.vault = new _vaultservice.VaultService(this.httpClient);
67
+ this.notifications = new _notificationservice.NotificationService(this.httpClient);
59
68
  }
60
- }
69
+ };
70
+
71
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../lib/hpc-api/src/lib/api.ts"],"sourcesContent":["import { AssetService } from './asset.service';\nimport { AssetTypesService } from './assettypes.service';\nimport { ContentService } from './content.service';\nimport { EndpointService } from './endpoint.service';\nimport { EventsService } from './events.service';\nimport { FlowDeploymentService } from './flow-deployment.service';\nimport { FlowFunctionService } from './flow-function.service';\nimport { FlowModuleService } from './flow-module.service';\nimport { FlowService } from './flow.service';\nimport { HttpClient } from './http.service';\nimport { LabelService } from './label.service';\nimport { NotificationService } from './notification.service';\nimport { ProxyService } from './proxy.service';\nimport { SecretService } from './secret.service';\nimport { TaskService } from './task.service';\nimport { TimeSeriesService } from './timeseries.service';\nimport { UserService } from './user.service';\nimport { VaultService } from './vault.service';\n\nexport class API {\n public assets: AssetService;\n public assetTypes: AssetTypesService;\n public contents: ContentService;\n public endpoints: EndpointService;\n public events: EventsService;\n public flows: FlowService;\n public flowDeployments: FlowDeploymentService;\n public flowFunctions: FlowFunctionService;\n public flowModules: FlowModuleService;\n public labels: LabelService;\n public proxy: ProxyService;\n public secrets: SecretService;\n public tasks: TaskService;\n public timeSeries: TimeSeriesService;\n public users: UserService;\n public vault: VaultService;\n public notifications: NotificationService;\n\n constructor(\n public readonly httpClient?: HttpClient,\n context?: { tokenSubject?: string },\n ) {\n if (!httpClient) {\n // remove leading and trailing slashes\n const normalizePath = (value = '', defaultValue = '') => value.replace(/(?:^\\/+)|(?:\\/+$)/g, '') || defaultValue;\n\n let apiBaseUrl = process.env.API_BASE_URL || 'https://testing.hahnpro.com';\n if (!apiBaseUrl.startsWith('https') && !apiBaseUrl.startsWith('http')) {\n /* eslint-disable-next-line no-console */\n console.info('no protocol specified - using HTTPS');\n apiBaseUrl = `https://${apiBaseUrl}`;\n }\n const apiUrl = apiBaseUrl + '/' + normalizePath(process.env.API_BASE_PATH, 'api');\n const authBaseUrl = process.env.AUTH_BASE_URL || apiBaseUrl;\n const authUrl = authBaseUrl + '/' + normalizePath(process.env.AUTH_BASE_PATH, 'auth');\n const realm = process.env.AUTH_REALM || 'hpc';\n const client = process.env.API_USER || 'flow-executor-service';\n const secret = process.env.AUTH_SECRET;\n if (!secret) {\n throw new Error('\"API_BASE_URL\", \"API_USER\", \"AUTH_REALM\" and \"AUTH_SECRET\" environment variables must be set');\n }\n this.httpClient = new HttpClient(apiUrl, authUrl, realm, client, secret, context?.tokenSubject);\n }\n\n this.assets = new AssetService(this.httpClient);\n this.assetTypes = new AssetTypesService(this.httpClient);\n this.contents = new ContentService(this.httpClient);\n this.endpoints = new EndpointService(this.httpClient);\n this.events = new EventsService(this.httpClient);\n this.flows = new FlowService(this.httpClient);\n this.flowDeployments = new FlowDeploymentService(this.httpClient);\n this.flowFunctions = new FlowFunctionService(this.httpClient);\n this.flowModules = new FlowModuleService(this.httpClient);\n this.labels = new LabelService(this.httpClient);\n this.proxy = new ProxyService(this.httpClient);\n this.secrets = new SecretService(this.httpClient);\n this.tasks = new TaskService(this.httpClient);\n this.timeSeries = new TimeSeriesService(this.httpClient);\n this.users = new UserService(this.httpClient);\n this.vault = new VaultService(this.httpClient);\n this.notifications = new NotificationService(this.httpClient);\n }\n}\n"],"names":["API","constructor","httpClient","context","normalizePath","value","defaultValue","replace","apiBaseUrl","process","env","API_BASE_URL","startsWith","console","info","apiUrl","API_BASE_PATH","authBaseUrl","AUTH_BASE_URL","authUrl","AUTH_BASE_PATH","realm","AUTH_REALM","client","API_USER","secret","AUTH_SECRET","Error","HttpClient","tokenSubject","assets","AssetService","assetTypes","AssetTypesService","contents","ContentService","endpoints","EndpointService","events","EventsService","flows","FlowService","flowDeployments","FlowDeploymentService","flowFunctions","FlowFunctionService","flowModules","FlowModuleService","labels","LabelService","proxy","ProxyService","secrets","SecretService","tasks","TaskService","timeSeries","TimeSeriesService","users","UserService","vault","VaultService","notifications","NotificationService"],"mappings":";;;;+BAmBaA;;;eAAAA;;;8BAnBgB;mCACK;gCACH;iCACC;+BACF;uCACQ;qCACF;mCACF;6BACN;6BACD;8BACE;qCACO;8BACP;+BACC;6BACF;mCACM;6BACN;8BACC;AAEtB,IAAA,AAAMA,MAAN,MAAMA;I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CAACoC,MAAM,GAAG,IAAIC,4BAAa,CAAC,IAAI,CAACrC,UAAU;QAC/C,IAAI,CAACsC,KAAK,GAAG,IAAIC,wBAAW,CAAC,IAAI,CAACvC,UAAU;QAC5C,IAAI,CAACwC,eAAe,GAAG,IAAIC,4CAAqB,CAAC,IAAI,CAACzC,UAAU;QAChE,IAAI,CAAC0C,aAAa,GAAG,IAAIC,wCAAmB,CAAC,IAAI,CAAC3C,UAAU;QAC5D,IAAI,CAAC4C,WAAW,GAAG,IAAIC,oCAAiB,CAAC,IAAI,CAAC7C,UAAU;QACxD,IAAI,CAAC8C,MAAM,GAAG,IAAIC,0BAAY,CAAC,IAAI,CAAC/C,UAAU;QAC9C,IAAI,CAACgD,KAAK,GAAG,IAAIC,0BAAY,CAAC,IAAI,CAACjD,UAAU;QAC7C,IAAI,CAACkD,OAAO,GAAG,IAAIC,4BAAa,CAAC,IAAI,CAACnD,UAAU;QAChD,IAAI,CAACoD,KAAK,GAAG,IAAIC,wBAAW,CAAC,IAAI,CAACrD,UAAU;QAC5C,IAAI,CAACsD,UAAU,GAAG,IAAIC,oCAAiB,CAAC,IAAI,CAACvD,UAAU;QACvD,IAAI,CAACwD,KAAK,GAAG,IAAIC,wBAAW,CAAC,IAAI,CAACzD,UAAU;QAC5C,IAAI,CAAC0D,KAAK,GAAG,IAAIC,0BAAY,CAAC,IAAI,CAAC3D,UAAU;QAC7C,IAAI,CAAC4D,aAAa,GAAG,IAAIC,wCAAmB,CAAC,IAAI,CAAC7D,UAAU;IAC9D;AACF"}
@@ -1 +1,6 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+
6
+ //# sourceMappingURL=asset.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../lib/hpc-api/src/lib/asset.interface.ts"],"names":[],"mappings":""}
@@ -1,39 +1,60 @@
1
- import { __decorate } from "tslib";
2
- import { mix } from 'ts-mixer';
3
- import { APIBase } from './api-base';
4
- import { DataService } from './data.service';
5
- import { TrashService } from './trash.service';
6
- let BaseService = class BaseService extends APIBase {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "AssetService", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return AssetService;
9
+ }
10
+ });
11
+ const _ts_decorate = require("@swc/helpers/_/_ts_decorate");
12
+ const _tsmixer = require("ts-mixer");
13
+ const _apibase = require("./api-base");
14
+ const _dataservice = require("./data.service");
15
+ const _trashservice = require("./trash.service");
16
+ let BaseService = class BaseService extends _apibase.APIBase {
7
17
  };
8
- BaseService = __decorate([
9
- mix(DataService, TrashService)
18
+ BaseService = _ts_decorate._([
19
+ (0, _tsmixer.mix)(_dataservice.DataService, _trashservice.TrashService)
10
20
  ], BaseService);
11
- export class AssetService extends BaseService {
12
- constructor(httpClient) {
13
- super(httpClient, '/assets');
14
- this.addAttachment = (id, form, options = {}) => {
15
- const headers = { ...form.getHeaders() };
21
+ let AssetService = class AssetService extends BaseService {
22
+ constructor(httpClient){
23
+ super(httpClient, '/assets'), this.addAttachment = (id, form, options = {})=>{
24
+ const headers = {
25
+ ...form.getHeaders()
26
+ };
16
27
  return this.httpClient.post(`${this.basePath}/${id}/attachment`, form, {
17
28
  headers,
18
29
  maxBodyLength: Infinity,
19
30
  maxContentLength: Infinity,
20
- ...options,
31
+ ...options
21
32
  });
22
33
  };
23
34
  }
24
35
  deleteOne(id, force = false, options = {}) {
25
- return this.httpClient.delete(`${this.basePath}/${id}`, { params: { force }, ...options });
36
+ return this.httpClient.delete(`${this.basePath}/${id}`, {
37
+ params: {
38
+ force
39
+ },
40
+ ...options
41
+ });
26
42
  }
27
43
  getChildren(assetId, params = {}, options = {}) {
28
- return this.getManyFiltered({ parent: assetId }, params, options);
44
+ return this.getManyFiltered({
45
+ parent: assetId
46
+ }, params, options);
29
47
  }
30
48
  getAttachments(assetId, options = {}) {
31
49
  return this.httpClient.get(`${this.basePath}/${assetId}/attachments`, options);
32
50
  }
33
51
  getEventLevelOverride(ids, causes, options = {}) {
34
52
  return this.httpClient.get(`${this.basePath}/eventcauses`, {
35
- params: { ids: ids.join(','), causes: causes.join(',') },
36
- ...options,
53
+ params: {
54
+ ids: ids.join(','),
55
+ causes: causes.join(',')
56
+ },
57
+ ...options
37
58
  });
38
59
  }
39
60
  updateEventCausesAsset(id, dto, options = {}) {
@@ -43,9 +64,13 @@ export class AssetService extends BaseService {
43
64
  return this.httpClient.get(`${this.basePath}/${assetId}/revisions`, options);
44
65
  }
45
66
  rollback(assetId, revisionId, options = {}) {
46
- return this.httpClient.put(`${this.basePath}/${assetId}/rollback`, { revisionId }, options);
67
+ return this.httpClient.put(`${this.basePath}/${assetId}/rollback`, {
68
+ revisionId
69
+ }, options);
47
70
  }
48
71
  deleteRevision(assetId, revisionId, options = {}) {
49
72
  return this.httpClient.delete(`${this.basePath}/${assetId}/revisions/${revisionId}`, options);
50
73
  }
51
- }
74
+ };
75
+
76
+ //# sourceMappingURL=asset.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../lib/hpc-api/src/lib/asset.service.ts"],"sourcesContent":["import FormData from 'form-data';\nimport { mix } from 'ts-mixer';\n\nimport { APIBase } from './api-base';\nimport { Asset, AssetRevision, Attachment, EventCause, EventLevelOverride } from './asset.interface';\nimport { Paginated, RequestParameter } from './data.interface';\nimport { DataService } from './data.service';\nimport { HttpClient, TokenOption } from './http.service';\nimport { TrashService } from './trash.service';\n\ninterface BaseService extends DataService<Asset>, TrashService<Asset> {}\n@mix(DataService, TrashService)\nclass BaseService extends APIBase {}\n\nexport class AssetService extends BaseService {\n constructor(httpClient: HttpClient) {\n super(httpClient, '/assets');\n }\n\n public deleteOne(id: string, force = false, options: TokenOption = {}): Promise<any> {\n return this.httpClient.delete(`${this.basePath}/${id}`, { params: { force }, ...options });\n }\n\n public addAttachment = (id: string, form: FormData, options: TokenOption = {}): Promise<Asset> => {\n const headers = { ...form.getHeaders() };\n return this.httpClient.post<Asset>(`${this.basePath}/${id}/attachment`, form, {\n headers,\n maxBodyLength: Infinity,\n maxContentLength: Infinity,\n ...options,\n });\n };\n\n public getChildren(assetId: string, params: RequestParameter = {}, options: TokenOption = {}): Promise<Paginated<Asset[]>> {\n return this.getManyFiltered({ parent: assetId }, params, options);\n }\n\n public getAttachments(assetId: string, options: TokenOption = {}): Promise<Paginated<Attachment[]>> {\n return this.httpClient.get<Paginated<Attachment[]>>(`${this.basePath}/${assetId}/attachments`, options);\n }\n\n public getEventLevelOverride(ids: string[], causes: string[], options: TokenOption = {}): Promise<EventLevelOverride> {\n return this.httpClient.get<EventLevelOverride>(`${this.basePath}/eventcauses`, {\n params: { ids: ids.join(','), causes: causes.join(',') },\n ...options,\n });\n }\n\n public updateEventCausesAsset(id: string, dto: EventCause, options: TokenOption = {}): Promise<Asset> {\n return this.httpClient.put<Asset>(`${this.basePath}/${id}/eventcauses`, dto, options);\n }\n\n public getRevisions(assetId: string, options: TokenOption = {}): Promise<Paginated<AssetRevision[]>> {\n return this.httpClient.get<Paginated<AssetRevision[]>>(`${this.basePath}/${assetId}/revisions`, options);\n }\n\n public rollback(assetId: string, revisionId: string, options: TokenOption = {}): Promise<Asset> {\n return this.httpClient.put<Asset>(`${this.basePath}/${assetId}/rollback`, { revisionId }, options);\n }\n\n public deleteRevision(assetId: string, revisionId: string, options: TokenOption = {}): Promise<any> {\n return this.httpClient.delete(`${this.basePath}/${assetId}/revisions/${revisionId}`, options);\n }\n}\n"],"names":["AssetService","BaseService","APIBase","constructor","httpClient","addAttachment","id","form","options","headers","getHeaders","post","basePath","maxBodyLength","Infinity","maxContentLength","deleteOne","force","delete","params","getChildren","assetId","getManyFiltered","parent","getAttachments","get","getEventLevelOverride","ids","causes","join","updateEventCausesAsset","dto","put","getRevisions","rollback","revisionId","deleteRevision"],"mappings":";;;;+BAcaA;;;eAAAA;;;;yBAbO;yBAEI;6BAGI;8BAEC;AAG7B,IAAA,AACMC,cADN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,KAAKA,IAAIE,IAAI,CAAC;gBAAMD,QAAQA,OAAOC,IAAI,CAAC;YAAK;YACvD,GAAGrB,OAAO;QACZ;IACF;IAEOsB,uBAAuBxB,EAAU,EAAEyB,GAAe,EAAEvB,UAAuB,CAAC,CAAC,EAAkB;QACpG,OAAO,IAAI,CAACJ,UAAU,CAAC4B,GAAG,CAAQ,GAAG,IAAI,CAACpB,QAAQ,CAAC,CAAC,EAAEN,GAAG,YAAY,CAAC,EAAEyB,KAAKvB;IAC/E;IAEOyB,aAAaZ,OAAe,EAAEb,UAAuB,CAAC,CAAC,EAAuC;QACnG,OAAO,IAAI,CAACJ,UAAU,CAACqB,GAAG,CAA6B,GAAG,IAAI,CAACb,QAAQ,CAAC,CAAC,EAAES,QAAQ,UAAU,CAAC,EAAEb;IAClG;IAEO0B,SAASb,OAAe,EAAEc,UAAkB,EAAE3B,UAAuB,CAAC,CAAC,EAAkB;QAC9F,OAAO,IAAI,CAACJ,UAAU,CAAC4B,GAAG,CAAQ,GAAG,IAAI,CAACpB,QAAQ,CAAC,CAAC,EAAES,QAAQ,SAAS,CAAC,EAAE;YAAEc;QAAW,GAAG3B;IAC5F;IAEO4B,eAAef,OAAe,EAAEc,UAAkB,EAAE3B,UAAuB,CAAC,CAAC,EAAgB;QAClG,OAAO,IAAI,CAACJ,UAAU,CAACc,MAAM,CAAC,GAAG,IAAI,CAACN,QAAQ,CAAC,CAAC,EAAES,QAAQ,WAAW,EAAEc,YAAY,EAAE3B;IACvF;AACF"}
@@ -1,24 +1,38 @@
1
- import { __decorate } from "tslib";
2
- import { mix } from 'ts-mixer';
3
- import { APIBase } from './api-base';
4
- import { DataService } from './data.service';
5
- import { TrashService } from './trash.service';
6
- let BaseService = class BaseService extends APIBase {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "AssetTypesService", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return AssetTypesService;
9
+ }
10
+ });
11
+ const _ts_decorate = require("@swc/helpers/_/_ts_decorate");
12
+ const _tsmixer = require("ts-mixer");
13
+ const _apibase = require("./api-base");
14
+ const _dataservice = require("./data.service");
15
+ const _trashservice = require("./trash.service");
16
+ let BaseService = class BaseService extends _apibase.APIBase {
7
17
  };
8
- BaseService = __decorate([
9
- mix(DataService, TrashService)
18
+ BaseService = _ts_decorate._([
19
+ (0, _tsmixer.mix)(_dataservice.DataService, _trashservice.TrashService)
10
20
  ], BaseService);
11
- export class AssetTypesService extends BaseService {
12
- constructor(httpClient) {
21
+ let AssetTypesService = class AssetTypesService extends BaseService {
22
+ constructor(httpClient){
13
23
  super(httpClient, '/assettypes');
14
24
  }
15
25
  getRevisions(id, options = {}) {
16
26
  return this.httpClient.get(`${this.basePath}/${id}/revisions`, options);
17
27
  }
18
28
  rollback(id, revisionId, options = {}) {
19
- return this.httpClient.put(`${this.basePath}/${id}/rollback`, { revisionId }, options);
29
+ return this.httpClient.put(`${this.basePath}/${id}/rollback`, {
30
+ revisionId
31
+ }, options);
20
32
  }
21
33
  deleteRevision(id, revisionId, options = {}) {
22
34
  return this.httpClient.delete(`${this.basePath}/${id}/revisions/${revisionId}`, options);
23
35
  }
24
- }
36
+ };
37
+
38
+ //# sourceMappingURL=assettypes.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../lib/hpc-api/src/lib/assettypes.service.ts"],"sourcesContent":["import { mix } from 'ts-mixer';\n\nimport { APIBase } from './api-base';\nimport { AssetType } from './asset.interface';\nimport { Paginated } from './data.interface';\nimport { DataService } from './data.service';\nimport { HttpClient, TokenOption } from './http.service';\nimport { TrashService } from './trash.service';\n\ninterface BaseService extends DataService<AssetType>, TrashService<AssetType> {}\n@mix(DataService, TrashService)\nclass BaseService extends APIBase {}\n\nexport class AssetTypesService extends BaseService {\n constructor(httpClient: HttpClient) {\n super(httpClient, '/assettypes');\n }\n\n public getRevisions(id: string, options: TokenOption = {}): Promise<Paginated<AssetType[]>> {\n return this.httpClient.get<Paginated<AssetType[]>>(`${this.basePath}/${id}/revisions`, options);\n }\n\n public rollback(id: string, revisionId: string, options: TokenOption = {}): Promise<AssetType> {\n return this.httpClient.put<AssetType>(`${this.basePath}/${id}/rollback`, { revisionId }, options);\n }\n\n public deleteRevision(id: string, revisionId: string, options: TokenOption = {}): Promise<any> {\n return this.httpClient.delete(`${this.basePath}/${id}/revisions/${revisionId}`, options);\n }\n}\n"],"names":["AssetTypesService","BaseService","APIBase","constructor","httpClient","getRevisions","id","options","get","basePath","rollback","revisionId","put","deleteRevision","delete"],"mappings":";;;;+BAaaA;;;eAAAA;;;;yBAbO;yBAEI;6BAGI;8BAEC;AAG7B,IAAA,AACMC,cADN,MACMA,oBAAoBC,gBAAO;AAAE;;;;AAE5B,IAAA,AAAMF,oBAAN,MAAMA,0BAA0BC;IACrCE,YAAYC,UAAsB,CAAE;QAClC,KAAK,CAACA,YAAY;IACpB;IAEOC,aAAaC,EAAU,EAAEC,UAAuB,CAAC,CAAC,EAAmC;QAC1F,OAAO,IAAI,CAACH,UAAU,CAACI,GAAG,CAAyB,GAAG,IAAI,CAACC,QAAQ,CAAC,CAAC,EAAEH,GAAG,UAAU,CAAC,EAAEC;IACzF;IAEOG,SAASJ,EAAU,EAAEK,UAAkB,EAAEJ,UAAuB,CAAC,CAAC,EAAsB;QAC7F,OAAO,IAAI,CAACH,UAAU,CAACQ,GAAG,CAAY,GAAG,IAAI,CAACH,QAAQ,CAAC,CAAC,EAAEH,GAAG,SAAS,CAAC,EAAE;YAAEK;QAAW,GAAGJ;IAC3F;IAEOM,eAAeP,EAAU,EAAEK,UAAkB,EAAEJ,UAAuB,CAAC,CAAC,EAAgB;QAC7F,OAAO,IAAI,CAACH,UAAU,CAACU,MAAM,CAAC,GAAG,IAAI,CAACL,QAAQ,CAAC,CAAC,EAAEH,GAAG,WAAW,EAAEK,YAAY,EAAEJ;IAClF;AACF"}
@@ -1,9 +1,21 @@
1
- export var ReturnType;
2
- (function (ReturnType) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ReturnType", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ReturnType;
9
+ }
10
+ });
11
+ var ReturnType = /*#__PURE__*/ function(ReturnType) {
3
12
  ReturnType[ReturnType["TEXT"] = 0] = "TEXT";
4
13
  ReturnType[ReturnType["JSON"] = 1] = "JSON";
5
14
  ReturnType[ReturnType["NODEBUFFER"] = 2] = "NODEBUFFER";
6
15
  ReturnType[ReturnType["BLOB"] = 3] = "BLOB";
7
16
  ReturnType[ReturnType["ARRAYBUFFER"] = 4] = "ARRAYBUFFER";
8
17
  ReturnType[ReturnType["NODESTREAM"] = 5] = "NODESTREAM";
9
- })(ReturnType || (ReturnType = {}));
18
+ return ReturnType;
19
+ }({});
20
+
21
+ //# sourceMappingURL=content.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../lib/hpc-api/src/lib/content.interface.ts"],"sourcesContent":["import { Storage } from './storage.interface';\n\nexport interface Content {\n id?: string;\n fileId: string;\n filename: string;\n mimetype: string;\n size: number;\n readPermissions: string[];\n readWritePermissions: string[];\n tags?: string[];\n assets?: string[];\n files?: Storage[];\n createdAt?: string;\n updatedAt?: string;\n deletedAt?: string;\n}\n\nexport enum ReturnType {\n TEXT,\n JSON,\n NODEBUFFER,\n BLOB,\n ARRAYBUFFER,\n NODESTREAM,\n}\n"],"names":["ReturnType"],"mappings":";;;;+BAkBYA;;;eAAAA;;;AAAL,IAAA,AAAKA,oCAAAA;;;;;;;WAAAA"}
@@ -1,49 +1,79 @@
1
- import { __decorate } from "tslib";
2
- import { mix } from 'ts-mixer';
3
- import { APIBase } from './api-base';
4
- import { ReturnType } from './content.interface';
5
- import { DataService } from './data.service';
6
- import { TrashService } from './trash.service';
7
- let BaseService = class BaseService extends APIBase {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ContentService", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ContentService;
9
+ }
10
+ });
11
+ const _ts_decorate = require("@swc/helpers/_/_ts_decorate");
12
+ const _tsmixer = require("ts-mixer");
13
+ const _apibase = require("./api-base");
14
+ const _contentinterface = require("./content.interface");
15
+ const _dataservice = require("./data.service");
16
+ const _trashservice = require("./trash.service");
17
+ let BaseService = class BaseService extends _apibase.APIBase {
8
18
  };
9
- BaseService = __decorate([
10
- mix(DataService, TrashService)
19
+ BaseService = _ts_decorate._([
20
+ (0, _tsmixer.mix)(_dataservice.DataService, _trashservice.TrashService)
11
21
  ], BaseService);
12
- export class ContentService extends BaseService {
13
- constructor(httpClient) {
14
- super(httpClient, '/contents');
15
- this.upload = (form, options = {}) => {
16
- const headers = { ...form.getHeaders() };
22
+ let ContentService = class ContentService extends BaseService {
23
+ constructor(httpClient){
24
+ super(httpClient, '/contents'), this.upload = (form, options = {})=>{
25
+ const headers = {
26
+ ...form.getHeaders()
27
+ };
17
28
  return this.httpClient.post(`${this.basePath}`, form, {
18
29
  headers,
19
30
  maxBodyLength: Infinity,
20
31
  maxContentLength: Infinity,
21
- ...options,
32
+ ...options
22
33
  });
23
34
  };
24
35
  }
25
36
  async download(id, second, options = {}) {
26
37
  let returnType;
27
38
  if (typeof second === 'boolean' || second == null) {
28
- returnType = second ? ReturnType.ARRAYBUFFER : ReturnType.BLOB;
29
- }
30
- else {
39
+ returnType = second ? _contentinterface.ReturnType.ARRAYBUFFER : _contentinterface.ReturnType.BLOB;
40
+ } else {
31
41
  returnType = second;
32
42
  }
33
43
  const url = `${this.basePath}/${id}/download`;
34
- switch (returnType) {
35
- case ReturnType.TEXT:
36
- return this.httpClient.get(url, { responseType: 'text', ...options });
37
- case ReturnType.JSON:
38
- return this.httpClient.get(url, { responseType: 'json', ...options });
39
- case ReturnType.NODEBUFFER:
40
- return Buffer.from(new Uint8Array(await this.httpClient.get(url, { responseType: 'arraybuffer', ...options })));
41
- case ReturnType.BLOB:
42
- return this.httpClient.get(url, { responseType: 'blob', ...options });
43
- case ReturnType.ARRAYBUFFER:
44
- return this.httpClient.get(url, { responseType: 'arraybuffer', ...options });
45
- case ReturnType.NODESTREAM:
46
- return this.httpClient.get(url, { responseType: 'stream', ...options });
44
+ switch(returnType){
45
+ case _contentinterface.ReturnType.TEXT:
46
+ return this.httpClient.get(url, {
47
+ responseType: 'text',
48
+ ...options
49
+ });
50
+ case _contentinterface.ReturnType.JSON:
51
+ return this.httpClient.get(url, {
52
+ responseType: 'json',
53
+ ...options
54
+ });
55
+ case _contentinterface.ReturnType.NODEBUFFER:
56
+ return Buffer.from(new Uint8Array(await this.httpClient.get(url, {
57
+ responseType: 'arraybuffer',
58
+ ...options
59
+ })));
60
+ case _contentinterface.ReturnType.BLOB:
61
+ return this.httpClient.get(url, {
62
+ responseType: 'blob',
63
+ ...options
64
+ });
65
+ case _contentinterface.ReturnType.ARRAYBUFFER:
66
+ return this.httpClient.get(url, {
67
+ responseType: 'arraybuffer',
68
+ ...options
69
+ });
70
+ case _contentinterface.ReturnType.NODESTREAM:
71
+ return this.httpClient.get(url, {
72
+ responseType: 'stream',
73
+ ...options
74
+ });
47
75
  }
48
76
  }
49
- }
77
+ };
78
+
79
+ //# sourceMappingURL=content.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../lib/hpc-api/src/lib/content.service.ts"],"sourcesContent":["import { Readable } from 'stream';\n\nimport FormData from 'form-data';\nimport { mix } from 'ts-mixer';\n\nimport { APIBase } from './api-base';\nimport { Content, ReturnType } from './content.interface';\nimport { DataService } from './data.service';\nimport { HttpClient, TokenOption } from './http.service';\nimport { TrashService } from './trash.service';\n\ninterface BaseService extends DataService<Content>, TrashService<Content> {}\n@mix(DataService, TrashService)\nclass BaseService extends APIBase {}\n\nexport class ContentService extends BaseService {\n constructor(httpClient: HttpClient) {\n super(httpClient, '/contents');\n }\n\n upload = (form: FormData, options: TokenOption = {}): Promise<Content> => {\n const headers = { ...form.getHeaders() };\n return this.httpClient.post<Content>(`${this.basePath}`, form, {\n headers,\n maxBodyLength: Infinity,\n maxContentLength: Infinity,\n ...options,\n });\n };\n\n download(id: string, raw?: boolean, options?: TokenOption): Promise<Blob | ArrayBuffer>;\n\n download(id: string, returnType: ReturnType.TEXT, options?: TokenOption): Promise<string>;\n download(id: string, returnType: ReturnType.JSON, options?: TokenOption): Promise<Record<string, unknown>>;\n download(id: string, returnType: ReturnType.NODEBUFFER, options?: TokenOption): Promise<Buffer>;\n download(id: string, returnType: ReturnType.BLOB, options?: TokenOption): Promise<Blob>;\n download(id: string, returnType: ReturnType.ARRAYBUFFER, options?: TokenOption): Promise<ArrayBuffer>;\n download(id: string, returnType: ReturnType.NODESTREAM, options?: TokenOption): Promise<Readable>;\n\n async download(\n id: string,\n second: any,\n options: TokenOption = {},\n ): Promise<string | Record<string, unknown> | Buffer | Blob | ArrayBuffer | Readable> {\n let returnType: ReturnType;\n if (typeof second === 'boolean' || second == null) {\n returnType = second ? ReturnType.ARRAYBUFFER : ReturnType.BLOB;\n } else {\n returnType = second;\n }\n\n const url = `${this.basePath}/${id}/download`;\n switch (returnType) {\n case ReturnType.TEXT:\n return this.httpClient.get<string>(url, { responseType: 'text', ...options });\n case ReturnType.JSON:\n return this.httpClient.get<Record<string, unknown>>(url, { responseType: 'json', ...options });\n case ReturnType.NODEBUFFER:\n return Buffer.from(new Uint8Array(await this.httpClient.get<ArrayBuffer>(url, { responseType: 'arraybuffer', ...options })));\n case ReturnType.BLOB:\n return this.httpClient.get<Blob>(url, { responseType: 'blob', ...options });\n case ReturnType.ARRAYBUFFER:\n return this.httpClient.get<ArrayBuffer>(url, { responseType: 'arraybuffer', ...options });\n case ReturnType.NODESTREAM:\n return this.httpClient.get<Readable>(url, { responseType: 'stream', ...options });\n }\n }\n}\n"],"names":["ContentService","BaseService","APIBase","constructor","httpClient","upload","form","options","headers","getHeaders","post","basePath","maxBodyLength","Infinity","maxContentLength","download","id","second","returnType","ReturnType","ARRAYBUFF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IC,WAAW,MAAM,IAAI,CAAC1B,UAAU,CAACoB,GAAG,CAAcF,KAAK;oBAAEG,cAAc;oBAAe,GAAGlB,OAAO;gBAAC;YAC1H,KAAKY,4BAAU,CAACE,IAAI;gBAClB,OAAO,IAAI,CAACjB,UAAU,CAACoB,GAAG,CAAOF,KAAK;oBAAEG,cAAc;oBAAQ,GAAGlB,OAAO;gBAAC;YAC3E,KAAKY,4BAAU,CAACC,WAAW;gBACzB,OAAO,IAAI,CAAChB,UAAU,CAACoB,GAAG,CAAcF,KAAK;oBAAEG,cAAc;oBAAe,GAAGlB,OAAO;gBAAC;YACzF,KAAKY,4BAAU,CAACY,UAAU;gBACxB,OAAO,IAAI,CAAC3B,UAAU,CAACoB,GAAG,CAAWF,KAAK;oBAAEG,cAAc;oBAAU,GAAGlB,OAAO;gBAAC;QACnF;IACF;AACF"}
@@ -1,3 +1,15 @@
1
- export function instanceOfTimePeriod(object) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "instanceOfTimePeriod", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return instanceOfTimePeriod;
9
+ }
10
+ });
11
+ function instanceOfTimePeriod(object) {
2
12
  return 'from' in object && 'to' in object;
3
13
  }
14
+
15
+ //# sourceMappingURL=data.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../lib/hpc-api/src/lib/data.interface.ts"],"sourcesContent":["import { TokenOption } from './http.service';\n\nexport interface Paginated<T> {\n docs: T;\n total: number;\n limit: number;\n page?: number;\n pages?: number;\n offset?: number;\n}\n\nexport interface RequestParameter {\n filter?: string;\n limit?: number;\n page?: number;\n populate?: string;\n sort?: string;\n}\n\ninterface TimePeriod {\n from: Date;\n to: Date;\n}\n\nexport function instanceOfTimePeriod(object: any): object is TimePeriod {\n return 'from' in object && 'to' in object;\n}\n\nexport type Filter = Record<string, string | string[] | TimePeriod>;\n\nexport interface DataInterface<T> {\n addOne(dto: any, options?: TokenOption): Promise<T>;\n addMany(dto: any[], options?: TokenOption & { [key: string]: any }): Promise<T[]>;\n getOne(id: string, options?: TokenOption & { [key: string]: any }): Promise<T>;\n getMany(params?: RequestParameter, options?: TokenOption): Promise<Paginated<T[]>>;\n getManyFiltered(filter: Filter, params?: RequestParameter, options?: TokenOption): Promise<Paginated<T[]>>;\n updateOne(id: string, dto: any, options?: TokenOption & { [key: string]: any }): Promise<T>;\n deleteOne(id: string, force: boolean, options?: TokenOption): Promise<any>;\n}\n"],"names":["instanceOfTimePeriod","object"],"mappings":";;;;+BAwBgBA;;;eAAAA;;;AAAT,SAASA,qBAAqBC,MAAW;IAC9C,OAAO,UAAUA,UAAU,QAAQA;AACrC"}
@@ -1,6 +1,16 @@
1
- import { APIBase } from './api-base';
2
- import { instanceOfTimePeriod } from './data.interface';
3
- export class DataService extends APIBase {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "DataService", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return DataService;
9
+ }
10
+ });
11
+ const _apibase = require("./api-base");
12
+ const _datainterface = require("./data.interface");
13
+ let DataService = class DataService extends _apibase.APIBase {
4
14
  addOne(dto, options = {}) {
5
15
  return this.httpClient.post(this.basePath, dto, options);
6
16
  }
@@ -8,25 +18,31 @@ export class DataService extends APIBase {
8
18
  return this.httpClient.post(`${this.basePath}/many`, dto, options);
9
19
  }
10
20
  getOne(id, options = {}) {
11
- const params = options.populate ? { populate: options.populate } : {};
12
- return this.httpClient.get(`${this.basePath}/${id}`, { params });
21
+ const params = options.populate ? {
22
+ populate: options.populate
23
+ } : {};
24
+ return this.httpClient.get(`${this.basePath}/${id}`, {
25
+ params
26
+ });
13
27
  }
14
28
  getMany(params = {}, options = {}) {
15
29
  params.limit = params.limit || 0;
16
30
  params.page = params.page || 1;
17
- return this.httpClient.get(`${this.basePath}`, { params, ...options });
31
+ return this.httpClient.get(`${this.basePath}`, {
32
+ params,
33
+ ...options
34
+ });
18
35
  }
19
36
  /**
20
- * Filters the elements by the passed properties. The object with these properties has to be of the form:
21
- * {
22
- * propertyName: string | string[] | { from: Date, to: Date },
23
- * ...
24
- * }.
25
- * @param filter The Object with the properties to filter by.
26
- * @param params Other request parameters.
27
- * @param options Parameters for authentication
28
- */
29
- getManyFiltered(filter, params = {}, options = {}) {
37
+ * Filters the elements by the passed properties. The object with these properties has to be of the form:
38
+ * {
39
+ * propertyName: string | string[] | { from: Date, to: Date },
40
+ * ...
41
+ * }.
42
+ * @param filter The Object with the properties to filter by.
43
+ * @param params Other request parameters.
44
+ * @param options Parameters for authentication
45
+ */ getManyFiltered(filter, params = {}, options = {}) {
30
46
  params.filter = this.getFilterString(filter);
31
47
  return this.getMany(params, options);
32
48
  }
@@ -34,24 +50,29 @@ export class DataService extends APIBase {
34
50
  return this.httpClient.put(`${this.basePath}/${id}`, dto, options);
35
51
  }
36
52
  deleteOne(id, force = false, options = {}) {
37
- return this.httpClient.delete(`${this.basePath}/${id}`, { params: { force }, ...options });
53
+ return this.httpClient.delete(`${this.basePath}/${id}`, {
54
+ params: {
55
+ force
56
+ },
57
+ ...options
58
+ });
38
59
  }
39
60
  getFilterString(filter) {
40
61
  const filters = [];
41
- for (const [key, value] of Object.entries(filter)) {
62
+ for (const [key, value] of Object.entries(filter)){
42
63
  if (value != null && value !== '') {
43
64
  // filter out null and undefined values and empty strings
44
- if (typeof value === 'object' && instanceOfTimePeriod(value)) {
65
+ if (typeof value === 'object' && (0, _datainterface.instanceOfTimePeriod)(value)) {
45
66
  filters.push(`${key}>=${value.from.toISOString()};${key}<=${value.to.toISOString()}`);
46
- }
47
- else if (Array.isArray(value)) {
67
+ } else if (Array.isArray(value)) {
48
68
  filters.push(`${key}=@${value.join(',')}`);
49
- }
50
- else {
69
+ } else {
51
70
  filters.push(`${key}==${value}`);
52
71
  }
53
72
  }
54
73
  }
55
74
  return filters.join(';');
56
75
  }
57
- }
76
+ };
77
+
78
+ //# sourceMappingURL=data.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../lib/hpc-api/src/lib/data.service.ts"],"sourcesContent":["import { APIBase } from './api-base';\nimport { DataInterface, Filter, instanceOfTimePeriod, Paginated, RequestParameter } from './data.interface';\nimport { TokenOption } from './http.service';\n\nexport class DataService<T> extends APIBase implements DataInterface<T> {\n public addOne(dto: any, options: TokenOption = {}): Promise<T> {\n return this.httpClient.post<T>(this.basePath, dto, options);\n }\n\n public addMany(dto: any[], options: TokenOption = {}): Promise<T[]> {\n return this.httpClient.post<T[]>(`${this.basePath}/many`, dto, options);\n }\n\n public getOne(id: string, options: TokenOption & { [key: string]: any } = {}): Promise<T> {\n const params = options.populate ? { populate: options.populate } : {};\n return this.httpClient.get<T>(`${this.basePath}/${id}`, { params });\n }\n\n public getMany(params: RequestParameter = {}, options: TokenOption = {}): Promise<Paginated<T[]>> {\n params.limit = params.limit || 0;\n params.page = params.page || 1;\n return this.httpClient.get<Paginated<T[]>>(`${this.basePath}`, { params, ...options });\n }\n\n /**\n * Filters the elements by the passed properties. The object with these properties has to be of the form:\n * {\n * propertyName: string | string[] | { from: Date, to: Date },\n * ...\n * }.\n * @param filter The Object with the properties to filter by.\n * @param params Other request parameters.\n * @param options Parameters for authentication\n */\n public getManyFiltered(filter: Filter, params: RequestParameter = {}, options: TokenOption = {}): Promise<Paginated<T[]>> {\n params.filter = this.getFilterString(filter);\n return this.getMany(params, options);\n }\n\n public updateOne(id: string, dto: any, options: TokenOption & { [key: string]: any } = {}): Promise<T> {\n return this.httpClient.put<T>(`${this.basePath}/${id}`, dto, options);\n }\n\n public deleteOne(id: string, force = false, options: TokenOption = {}): Promise<any> {\n return this.httpClient.delete(`${this.basePath}/${id}`, { params: { force }, ...options });\n }\n\n private getFilterString(filter: Filter) {\n const filters: string[] = [];\n for (const [key, value] of Object.entries(filter)) {\n if (value != null && value !== '') {\n // filter out null and undefined values and empty strings\n if (typeof value === 'object' && instanceOfTimePeriod(value)) {\n filters.push(`${key}>=${value.from.toISOString()};${key}<=${value.to.toISOString()}`);\n } else if (Array.isArray(value)) {\n filters.push(`${key}=@${value.join(',')}`);\n } else {\n filters.push(`${key}==${value}`);\n }\n }\n }\n return filters.join(';');\n }\n}\n"],"names":["DataService","APIBase","addOne","dto","options","httpClient","post","basePath","addMany","getOne","id","params","populate","get","getMany","limit","page","getManyFiltered","filter","getFilterString","updateOne","put","deleteOne","force","delete","filters","key","value","Object","entries","instanceOfTimePeriod","push","from","toISOString","to","Array","isArray","join"],"mappings":";;;;+BAIaA;;;eAAAA;;;yBAJW;+BACiE;AAGlF,IAAA,AAAMA,cAAN,MAAMA,oBAAuBC,gBAAO;IAClCC,OAAOC,GAAQ,EAAEC,UAAuB,CAAC,CAAC,EAAc;QAC7D,OAAO,IAAI,CAACC,UAAU,CAACC,IAAI,CAAI,IAAI,CAACC,QAAQ,EAAEJ,KAAKC;IACrD;IAEOI,QAAQL,GAAU,EAAEC,UAAuB,CAAC,CAAC,EAAgB;QAClE,OAAO,IAAI,CAACC,UAAU,CAACC,IAAI,CAAM,GAAG,IAAI,CAACC,QAAQ,CAAC,KAAK,CAAC,EAAEJ,KAAKC;IACjE;IAEOK,OAAOC,EAAU,EAAEN,UAAgD,CAAC,CAAC,EAAc;QACxF,MAAMO,SAASP,QAAQQ,QAAQ,GAAG;YAAEA,UAAUR,QAAQQ,QAAQ;QAAC,IAAI,CAAC;QACpE,OAAO,IAAI,CAACP,UAAU,CAACQ,GAAG,CAAI,GAAG,IAAI,CAACN,QAAQ,CAAC,CAAC,EAAEG,IAAI,EAAE;YAAEC;QAAO;IACnE;IAEOG,QAAQH,SAA2B,CAAC,CAAC,EAAEP,UAAuB,CAAC,CAAC,EAA2B;QAChGO,OAAOI,KAAK,GAAGJ,OAAOI,KAAK,IAAI;QAC/BJ,OAAOK,IAAI,GAAGL,OAAOK,IAAI,IAAI;QAC7B,OAAO,IAAI,CAACX,UAAU,CAACQ,GAAG,CAAiB,GAAG,IAA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AAM;gBAC3C,OAAO;oBACLZ,QAAQM,IAAI,CAAC,GAAGL,IAAI,EAAE,EAAEC,OAAO;gBACjC;YACF;QACF;QACA,OAAOF,QAAQY,IAAI,CAAC;IACtB;AACF"}
@@ -1 +1,6 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+
6
+ //# sourceMappingURL=endpoint.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../lib/hpc-api/src/lib/endpoint.interface.ts"],"names":[],"mappings":""}