@skedulo/pulse-solution-services 0.0.10 → 0.0.12

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/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Changelog
2
2
 
3
- ## [v0.0.10] - 2025-02-03
3
+ ## [v0.0.12] - 2025-03-19
4
+ ### Updated
5
+ - Include `baseClient.performRequest` in execution limits calculation.
6
+ - Create a singleton instance for `ExecutionContext`.
7
+
8
+ ## [v0.0.11] - 2025-03-17
9
+ ### Added
10
+ - Execution Limits
11
+
12
+ ## [v0.0.10] - 2025-03-03
4
13
  ### Changed
5
14
  - Minor changes
6
15
 
package/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
  - [Installation](#installation)
5
5
  - [Quick Start](#quick-start)
6
6
  - [Initialize Execution Context](#initialize-execution-context)
7
+ - [Execution Limits](#execution-limits)
7
8
  - [API Clients](#api-clients)
8
9
  - [Metadata Client](#metadata-client)
9
10
  - [Vocabulary Client](#vocabulary-client)
@@ -67,6 +68,61 @@ const context = ExecutionContext.fromCredentials({
67
68
  });
68
69
  ```
69
70
  Once initialized, the context object provides access to the various services detailed in subsequent sections.
71
+
72
+ ### Execution Limits
73
+
74
+ #### Overview
75
+
76
+ Execution Limits serve two main purposes:
77
+
78
+ - Provide execution metrics to help developers optimize their code.
79
+ - Ensure system stability by terminating executions that exceed limits. While this is not currently the default behavior, it may be in the future.
80
+
81
+ By default, the following limit are set:
82
+
83
+ - Total API Calls: 50
84
+ - Max Concurrent Requests: 5
85
+ - Max Method Execution Time: 12 seconds
86
+
87
+ A warning is logged if a limit is violated.
88
+
89
+ #### Example
90
+
91
+ **Using default limits**
92
+
93
+ ```javascript
94
+ // Initialize the execution context
95
+ const context = ExecutionContext.fromContext(skedContext, {
96
+ requestSource: "my-cool-project",
97
+ userAgent: "my-cool-function"
98
+ });
99
+
100
+ // Call services with the context
101
+ const artifactClient = context.newArtifactClient(ArtifactType.WEBHOOK);
102
+ const webhooks = await artifactClient.list();
103
+ const functionPromises = webhooks.map((webhook: any) => artifactClient.get(webhook.name));
104
+ await Promise.all(functionPromises);
105
+ // Get execution metric
106
+ console.log(context.getExecutionMetrics());
107
+ ```
108
+
109
+ **Overriding limits**
110
+
111
+ ```javascript
112
+ const limits = {
113
+ totalCalls: 50,
114
+ maxConcurrentRequests: 10,
115
+ maxMethodExecutionTimeMs: 10000,
116
+ throwOnViolation: true // Throws an error if limits are exceeded
117
+ };
118
+
119
+ const context = ExecutionContext.fromContext(skedContext, {
120
+ requestSource: "my-cool-project",
121
+ userAgent: "my-cool-function",
122
+ limits
123
+ });
124
+ ```
125
+
70
126
  ### API Clients
71
127
 
72
128
  #### Metadata Client
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function s(t){try{d(n.next(t))}catch(t){r(t)}}function a(t){try{d(n.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}d((n=n.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ArtifactClient=void 0;const constants_1=require("../constants"),base_client_1=require("./base-client");class ArtifactClient extends base_client_1.BaseClient{constructor(t,e,i={}){super(t,i),this.artifactType=e,this.baseEndpoint=`artifacts/${this.artifactType}`}list(){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({endpoint:this.baseEndpoint})}))}get(){return __awaiter(this,arguments,void 0,(function*(t={}){return this.performRequest({endpoint:this.buildEndpoint(t)})}))}create(t,e){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.POST,endpoint:this.buildEndpoint(t),body:e})}))}update(t,e){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.PUT,endpoint:this.buildEndpoint(t),body:e})}))}delete(t){return __awaiter(this,void 0,void 0,(function*(){yield this.performRequest({method:constants_1.HttpMethod.DELETE,endpoint:this.buildEndpoint(t)})}))}buildEndpoint(t){const{objectName:e,viewTypeName:i,name:n,scope:o}=t;let r=this.baseEndpoint;return e&&(r+=`/${e}`),i&&(r+=`/${i}`),n&&(r+=`/${n}`),o&&(r+=`/${o}`),r}}exports.ArtifactClient=ArtifactClient;
1
+ "use strict";var __decorate=this&&this.__decorate||function(t,e,n,i){var a,o=arguments.length,r=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,i);else for(var s=t.length-1;s>=0;s--)(a=t[s])&&(r=(o<3?a(r):o>3?a(e,n,r):a(e,n))||r);return o>3&&r&&Object.defineProperty(e,n,r),r},__metadata=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__awaiter=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(a,o){function r(t){try{c(i.next(t))}catch(t){o(t)}}function s(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,s)}c((i=i.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ArtifactClient=void 0;const constants_1=require("../constants"),monitor_call_1=require("../monitoring/decorators/monitor-call"),base_client_1=require("./base-client");class ArtifactClient extends base_client_1.BaseClient{constructor(t,e,n={}){super(t,n),this.artifactType=e,this.baseEndpoint=`artifacts/${this.artifactType}`}list(){return __awaiter(this,void 0,void 0,(function*(){return this._performRequest({endpoint:this.baseEndpoint})}))}get(){return __awaiter(this,arguments,void 0,(function*(t={}){return this._performRequest({endpoint:this.buildEndpoint(t)})}))}create(t,e){return __awaiter(this,void 0,void 0,(function*(){return this._performRequest({method:constants_1.HttpMethod.POST,endpoint:this.buildEndpoint(t),body:e})}))}update(t,e){return __awaiter(this,void 0,void 0,(function*(){return this._performRequest({method:constants_1.HttpMethod.PUT,endpoint:this.buildEndpoint(t),body:e})}))}delete(t){return __awaiter(this,void 0,void 0,(function*(){yield this._performRequest({method:constants_1.HttpMethod.DELETE,endpoint:this.buildEndpoint(t)})}))}buildEndpoint(t){const{objectName:e,viewTypeName:n,name:i,scope:a}=t;let o=this.baseEndpoint;return e&&(o+=`/${e}`),n&&(o+=`/${n}`),i&&(o+=`/${i}`),a&&(o+=`/${a}`),o}}exports.ArtifactClient=ArtifactClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],ArtifactClient.prototype,"list",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],ArtifactClient.prototype,"get",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object,Object]),__metadata("design:returntype",Promise)],ArtifactClient.prototype,"create",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object,Object]),__metadata("design:returntype",Promise)],ArtifactClient.prototype,"update",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],ArtifactClient.prototype,"delete",null);
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function o(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.AvailabilityAPIClient=void 0;const constants_1=require("../constants"),base_client_1=require("./base-client");class AvailabilityAPIClient extends base_client_1.BaseClient{fetchAvailability(e){return __awaiter(this,void 0,void 0,(function*(){var t,i,n,r;if(!e.resourceIds.length)throw new Error("At least one resource ID must be provided.");const s={resource_ids:e.resourceIds.join(","),start:e.start,end:e.end,mergedAvailabilities:null!==(i=null===(t=e.mergedAvailabilities)||void 0===t?void 0:t.toString())&&void 0!==i?i:"false",entries:null!==(r=null===(n=e.entries)||void 0===n?void 0:n.toString())&&void 0!==r?r:"true"};return yield this.performRequest({endpoint:constants_1.TENANT_ENDPOINTS.AVAILABILITY.SIMPLE,queryParams:s})}))}}exports.AvailabilityAPIClient=AvailabilityAPIClient;
1
+ "use strict";var __decorate=this&&this.__decorate||function(e,t,i,n){var r,a=arguments.length,o=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(o=(a<3?r(o):a>3?r(t,i,o):r(t,i))||o);return a>3&&o&&Object.defineProperty(t,i,o),o},__metadata=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__awaiter=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,a){function o(e){try{s(n.next(e))}catch(e){a(e)}}function l(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,l)}s((n=n.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.AvailabilityAPIClient=void 0;const constants_1=require("../constants"),monitor_call_1=require("../monitoring/decorators/monitor-call"),base_client_1=require("./base-client");class AvailabilityAPIClient extends base_client_1.BaseClient{fetchAvailability(e){return __awaiter(this,void 0,void 0,(function*(){var t,i,n,r;if(!e.resourceIds.length)throw new Error("At least one resource ID must be provided.");const a={resource_ids:e.resourceIds.join(","),start:e.start,end:e.end,mergedAvailabilities:null!==(i=null===(t=e.mergedAvailabilities)||void 0===t?void 0:t.toString())&&void 0!==i?i:"false",entries:null!==(r=null===(n=e.entries)||void 0===n?void 0:n.toString())&&void 0!==r?r:"true"};return yield this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.AVAILABILITY.SIMPLE,queryParams:a})}))}}exports.AvailabilityAPIClient=AvailabilityAPIClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],AvailabilityAPIClient.prototype,"fetchAvailability",null);
@@ -1 +1 @@
1
- "use strict";var __decorate=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},__metadata=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseClient=void 0;const request_header_constants_1=require("../core/request-header-constants"),logging_1=require("../logging");class BaseClient{constructor(e,t={}){this.config=e,this.executionOptions=t}performRequest(e){return __awaiter(this,arguments,void 0,(function*({method:e="GET",endpoint:t,headers:n={},body:r,queryParams:o},i=this.executionOptions){try{const s=Object.assign(Object.assign({},this.getHeaders(i)),n),a=this.buildUrl(t,o),c=yield fetch(a,{method:e,headers:s,body:r&&"GET"!==e?JSON.stringify(r):void 0});let u;const d=c.headers.get("content-type");if(d&&d.includes("application/json")?(u=yield c.json(),u.result&&(u=u.result)):u=yield c.text(),!c.ok)throw new Error(`HTTP error! Status: ${c.status}. Response: ${JSON.stringify(u)}`);return this.handleResponseData(u),u}catch(e){throw this.handleException(e),e}}))}handleResponseData(e){}getHeaders(e){var t,n;const r={Authorization:`Bearer ${this.config.apiToken}`,"Content-Type":"application/json"},o=e.requestSource||(null===(t=this.executionOptions)||void 0===t?void 0:t.requestSource),i=e.userAgent||(null===(n=this.executionOptions)||void 0===n?void 0:n.userAgent);return o&&(r[request_header_constants_1.REQUEST_HEADERS.X_SKEDULO_SOURCE]=o),i&&(r[request_header_constants_1.REQUEST_HEADERS.USER_AGENT]=i),r}buildUrl(e,t){const n=e.startsWith("http")?new URL(e):new URL(`${this.config.apiServer}/${e}`);return t&&Object.entries(t).forEach((([e,t])=>{n.searchParams.append(e,t)})),n.toString()}handleException(e){}}exports.BaseClient=BaseClient,__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object,Object]),__metadata("design:returntype",Promise)],BaseClient.prototype,"performRequest",null);
1
+ "use strict";var __decorate=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},__metadata=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseClient=void 0;const request_header_constants_1=require("../core/request-header-constants"),logging_1=require("../logging"),monitor_call_1=require("../monitoring/decorators/monitor-call");class BaseClient{constructor(e,t={}){this.config=e,this.executionOptions=t}performRequest(e){return __awaiter(this,arguments,void 0,(function*({method:e="GET",endpoint:t,headers:n={},body:r,queryParams:o},i=this.executionOptions){return this._performRequest({method:e,endpoint:t,headers:n,body:r,queryParams:o},i)}))}_performRequest(e){return __awaiter(this,arguments,void 0,(function*({method:e="GET",endpoint:t,headers:n={},body:r,queryParams:o},i=this.executionOptions){try{const s=Object.assign(Object.assign({},this.getHeaders(i)),n),a=this.buildUrl(t,o),c=yield fetch(a,{method:e,headers:s,body:r&&"GET"!==e?JSON.stringify(r):void 0});let u;const d=c.headers.get("content-type");if(d&&d.includes("application/json")?(u=yield c.json(),u.result&&(u=u.result)):u=yield c.text(),!c.ok)throw new Error(`HTTP error! Status: ${c.status}. Response: ${JSON.stringify(u)}`);return this.handleResponseData(u),u}catch(e){throw this.handleException(e),e}}))}handleResponseData(e){}getHeaders(e){var t,n;const r={Authorization:`Bearer ${this.config.apiToken}`,"Content-Type":"application/json"},o=e.requestSource||(null===(t=this.executionOptions)||void 0===t?void 0:t.requestSource),i=e.userAgent||(null===(n=this.executionOptions)||void 0===n?void 0:n.userAgent);return o&&(r[request_header_constants_1.REQUEST_HEADERS.X_SKEDULO_SOURCE]=o),i&&(r[request_header_constants_1.REQUEST_HEADERS.USER_AGENT]=i),r}buildUrl(e,t){const n=e.startsWith("http")?new URL(e):new URL(`${this.config.apiServer}/${e}`);return t&&Object.entries(t).forEach((([e,t])=>{n.searchParams.append(e,t)})),n.toString()}handleException(e){}}exports.BaseClient=BaseClient,__decorate([(0,logging_1.LogMethod)(),(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object,Object]),__metadata("design:returntype",Promise)],BaseClient.prototype,"performRequest",null);
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{u(i.next(t))}catch(t){r(t)}}function a(t){try{u(i.throw(t))}catch(t){r(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConfigFeaturesClient=void 0;const constants_1=require("../constants"),base_client_1=require("./base-client");class ConfigFeaturesClient extends base_client_1.BaseClient{get(){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_FEATURES.GET})}))}update(t,e){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:constants_1.HttpMethod.POST,headers:{Authorization:`Bearer ${this.config.internalApiToken}`,"Content-Type":"application/json"},endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_FEATURES.UPDATE(t),body:e})}))}}exports.ConfigFeaturesClient=ConfigFeaturesClient;
1
+ "use strict";var __decorate=this&&this.__decorate||function(t,e,n,o){var a,i=arguments.length,r=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,o);else for(var s=t.length-1;s>=0;s--)(a=t[s])&&(r=(i<3?a(r):i>3?a(e,n,r):a(e,n))||r);return i>3&&r&&Object.defineProperty(e,n,r),r},__metadata=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__awaiter=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(a,i){function r(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,s)}c((o=o.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConfigFeaturesClient=void 0;const constants_1=require("../constants"),monitor_call_1=require("../monitoring/decorators/monitor-call"),base_client_1=require("./base-client");class ConfigFeaturesClient extends base_client_1.BaseClient{get(){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_FEATURES.GET})}))}update(t,e){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({method:constants_1.HttpMethod.POST,headers:{Authorization:`Bearer ${this.config.internalApiToken}`,"Content-Type":"application/json"},endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_FEATURES.UPDATE(t),body:e})}))}}exports.ConfigFeaturesClient=ConfigFeaturesClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],ConfigFeaturesClient.prototype,"get",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String,Object]),__metadata("design:returntype",Promise)],ConfigFeaturesClient.prototype,"update",null);
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{_(i.next(t))}catch(t){r(t)}}function a(t){try{_(i.throw(t))}catch(t){r(t)}}function _(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}_((i=i.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConfigTemplateClient=void 0;const constants_1=require("../constants"),base_client_1=require("./base-client");class ConfigTemplateClient extends base_client_1.BaseClient{get(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({endpoint:`${constants_1.TENANT_ENDPOINTS.CONFIG_TEMPLATE.GET_TEMPLATES(t)}`})}))}getTemmplateValues(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({endpoint:`${constants_1.TENANT_ENDPOINTS.CONFIG_TEMPLATE.GET_VALUES(t)}`})}))}upsertTemplateValues(t,e){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.PUT,endpoint:`${constants_1.TENANT_ENDPOINTS.CONFIG_TEMPLATE.UPDATE_VALUES(t)}`,body:e})}))}delete(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:constants_1.HttpMethod.DELETE,endpoint:`${constants_1.TENANT_ENDPOINTS.CONFIG_TEMPLATE.DELETE(t)}`})}))}create(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:constants_1.HttpMethod.POST,endpoint:`${constants_1.TENANT_ENDPOINTS.CONFIG_TEMPLATE.CREATE}`,body:t})}))}}exports.ConfigTemplateClient=ConfigTemplateClient;
1
+ "use strict";var __decorate=this&&this.__decorate||function(t,e,n,a){var o,i=arguments.length,r=i<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,a);else for(var _=t.length-1;_>=0;_--)(o=t[_])&&(r=(i<3?o(r):i>3?o(e,n,r):o(e,n))||r);return i>3&&r&&Object.defineProperty(e,n,r),r},__metadata=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__awaiter=this&&this.__awaiter||function(t,e,n,a){return new(n||(n=Promise))((function(o,i){function r(t){try{s(a.next(t))}catch(t){i(t)}}function _(t){try{s(a.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,_)}s((a=a.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConfigTemplateClient=void 0;const constants_1=require("../constants"),monitor_call_1=require("../monitoring/decorators/monitor-call"),base_client_1=require("./base-client");class ConfigTemplateClient extends base_client_1.BaseClient{get(t){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({endpoint:`${constants_1.TENANT_ENDPOINTS.CONFIG_TEMPLATE.GET_TEMPLATES(t)}`})}))}getTemmplateValues(t){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({endpoint:`${constants_1.TENANT_ENDPOINTS.CONFIG_TEMPLATE.GET_VALUES(t)}`})}))}upsertTemplateValues(t,e){return __awaiter(this,void 0,void 0,(function*(){return this._performRequest({method:constants_1.HttpMethod.PUT,endpoint:`${constants_1.TENANT_ENDPOINTS.CONFIG_TEMPLATE.UPDATE_VALUES(t)}`,body:e})}))}delete(t){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({method:constants_1.HttpMethod.DELETE,endpoint:`${constants_1.TENANT_ENDPOINTS.CONFIG_TEMPLATE.DELETE(t)}`})}))}create(t){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({method:constants_1.HttpMethod.POST,endpoint:`${constants_1.TENANT_ENDPOINTS.CONFIG_TEMPLATE.CREATE}`,body:t})}))}}exports.ConfigTemplateClient=ConfigTemplateClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String]),__metadata("design:returntype",Promise)],ConfigTemplateClient.prototype,"get",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String]),__metadata("design:returntype",Promise)],ConfigTemplateClient.prototype,"getTemmplateValues",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String,Array]),__metadata("design:returntype",Promise)],ConfigTemplateClient.prototype,"upsertTemplateValues",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String]),__metadata("design:returntype",Promise)],ConfigTemplateClient.prototype,"delete",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],ConfigTemplateClient.prototype,"create",null);
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{d(i.next(t))}catch(t){r(t)}}function a(t){try{d(i.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}d((i=i.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConfigVarClient=void 0;const constants_1=require("../constants"),base_client_1=require("./base-client");class ConfigVarClient extends base_client_1.BaseClient{create(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_VAR.CREATE,body:t})}))}get(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_VAR.GET(t)})}))}update(t){return __awaiter(this,void 0,void 0,(function*(){const e=t.key||"";delete t.key;const n={};return void 0!==t.value&&(n.value=t.value),void 0!==t.description&&(n.description=t.description),void 0!==t.expiryDate&&(n.expiryDate=t.expiryDate),void 0!==t.status&&(n.status=t.status),yield this.performRequest({method:constants_1.HttpMethod.PATCH,endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_VAR.UPDATE(e),body:n})}))}upsert(t){return __awaiter(this,void 0,void 0,(function*(){try{return yield this.update(Object.assign({},t))}catch(e){return yield this.create(t)}}))}search(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_VAR.SEARCH,body:{pageSize:t&&t<1e3?t:1e3}})}))}delete(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:constants_1.HttpMethod.DELETE,endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_VAR.DELETE(t)})}))}}exports.ConfigVarClient=ConfigVarClient;
1
+ "use strict";var __decorate=this&&this.__decorate||function(t,e,n,a){var i,o=arguments.length,r=o<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,a);else for(var _=t.length-1;_>=0;_--)(i=t[_])&&(r=(o<3?i(r):o>3?i(e,n,r):i(e,n))||r);return o>3&&r&&Object.defineProperty(e,n,r),r},__metadata=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__awaiter=this&&this.__awaiter||function(t,e,n,a){return new(n||(n=Promise))((function(i,o){function r(t){try{s(a.next(t))}catch(t){o(t)}}function _(t){try{s(a.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,_)}s((a=a.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConfigVarClient=void 0;const constants_1=require("../constants"),monitor_call_1=require("../monitoring/decorators/monitor-call"),base_client_1=require("./base-client");class ConfigVarClient extends base_client_1.BaseClient{create(t){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_VAR.CREATE,body:t})}))}get(t){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_VAR.GET(t)})}))}update(t){return __awaiter(this,void 0,void 0,(function*(){const e=t.key||"";delete t.key;const n={};return void 0!==t.value&&(n.value=t.value),void 0!==t.description&&(n.description=t.description),void 0!==t.expiryDate&&(n.expiryDate=t.expiryDate),void 0!==t.status&&(n.status=t.status),yield this._performRequest({method:constants_1.HttpMethod.PATCH,endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_VAR.UPDATE(e),body:n})}))}upsert(t){return __awaiter(this,void 0,void 0,(function*(){try{return yield this.update(Object.assign({},t))}catch(e){return yield this.create(t)}}))}search(t){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_VAR.SEARCH,body:{pageSize:t&&t<1e3?t:1e3}})}))}delete(t){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({method:constants_1.HttpMethod.DELETE,endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_VAR.DELETE(t)})}))}}exports.ConfigVarClient=ConfigVarClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],ConfigVarClient.prototype,"create",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String]),__metadata("design:returntype",Promise)],ConfigVarClient.prototype,"get",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],ConfigVarClient.prototype,"update",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Number]),__metadata("design:returntype",Promise)],ConfigVarClient.prototype,"search",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String]),__metadata("design:returntype",Promise)],ConfigVarClient.prototype,"delete",null);
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(i,s){function r(t){try{c(o.next(t))}catch(t){s(t)}}function a(t){try{c(o.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}c((o=o.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GeoAPIClient=void 0;const constants_1=require("../constants"),base_client_1=require("./base-client");class GeoAPIClient extends base_client_1.BaseClient{getDistanceMatrix(t){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.DISTANCE_MATRIX,body:t})}))}getDirections(t){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.DIRECTIONS,body:t})}))}geocodeAddress(t){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.GEOCODE,body:t})}))}autocompleteAddress(t){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.AUTOCOMPLETE,body:t})}))}getPlaceDetails(t){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.PLACE,body:t})}))}getTimezone(t){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.GET,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.TIMEZONE,queryParams:{location:t.location.join(","),timestamp:t.timestamp.toString()}})}))}}exports.GeoAPIClient=GeoAPIClient;
1
+ "use strict";var __decorate=this&&this.__decorate||function(t,e,o,n){var a,i=arguments.length,r=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,o,n);else for(var s=t.length-1;s>=0;s--)(a=t[s])&&(r=(i<3?a(r):i>3?a(e,o,r):a(e,o))||r);return i>3&&r&&Object.defineProperty(e,o,r),r},__metadata=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__awaiter=this&&this.__awaiter||function(t,e,o,n){return new(o||(o=Promise))((function(a,i){function r(t){try{_(n.next(t))}catch(t){i(t)}}function s(t){try{_(n.throw(t))}catch(t){i(t)}}function _(t){var e;t.done?a(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(r,s)}_((n=n.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GeoAPIClient=void 0;const constants_1=require("../constants"),monitor_call_1=require("../monitoring/decorators/monitor-call"),base_client_1=require("./base-client");class GeoAPIClient extends base_client_1.BaseClient{getDistanceMatrix(t){return __awaiter(this,void 0,void 0,(function*(){return this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.DISTANCE_MATRIX,body:t})}))}getDirections(t){return __awaiter(this,void 0,void 0,(function*(){return this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.DIRECTIONS,body:t})}))}geocodeAddress(t){return __awaiter(this,void 0,void 0,(function*(){return this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.GEOCODE,body:t})}))}autocompleteAddress(t){return __awaiter(this,void 0,void 0,(function*(){return this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.AUTOCOMPLETE,body:t})}))}getPlaceDetails(t){return __awaiter(this,void 0,void 0,(function*(){return this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.PLACE,body:t})}))}getTimezone(t){return __awaiter(this,void 0,void 0,(function*(){return this._performRequest({method:constants_1.HttpMethod.GET,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.TIMEZONE,queryParams:{location:t.location.join(","),timestamp:t.timestamp.toString()}})}))}}exports.GeoAPIClient=GeoAPIClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GeoAPIClient.prototype,"getDistanceMatrix",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GeoAPIClient.prototype,"getDirections",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GeoAPIClient.prototype,"geocodeAddress",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GeoAPIClient.prototype,"autocompleteAddress",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GeoAPIClient.prototype,"getPlaceDetails",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GeoAPIClient.prototype,"getTimezone",null);
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,a){function s(t){try{c(r.next(t))}catch(t){a(t)}}function o(t){try{c(r.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,o)}c((r=r.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GraphQLClient=void 0;const constants_1=require("../constants"),http_1=require("../constants/http"),base_client_1=require("./base-client");class GraphQLClient extends base_client_1.BaseClient{execute(t){return __awaiter(this,arguments,void 0,(function*(t,e={}){return yield this.performRequest({method:http_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GRAPHQL,body:{query:t},headers:e})}))}handleResponseData(t){if(!t.data&&t.errors)throw new Error(`GraphQL error: ${JSON.stringify(t.errors)}`)}}exports.GraphQLClient=GraphQLClient;
1
+ "use strict";var __decorate=this&&this.__decorate||function(t,e,r,n){var a,o=arguments.length,i=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(a=t[c])&&(i=(o<3?a(i):o>3?a(e,r,i):a(e,r))||i);return o>3&&i&&Object.defineProperty(e,r,i),i},__metadata=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__awaiter=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(a,o){function i(t){try{s(n.next(t))}catch(t){o(t)}}function c(t){try{s(n.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?a(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,c)}s((n=n.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GraphQLClient=void 0;const constants_1=require("../constants"),http_1=require("../constants/http"),monitor_call_1=require("../monitoring/decorators/monitor-call"),base_client_1=require("./base-client");class GraphQLClient extends base_client_1.BaseClient{execute(t){return __awaiter(this,arguments,void 0,(function*(t,e={}){return yield this._performRequest({method:http_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GRAPHQL.SINGLE,body:{query:t},headers:e})}))}executeBatch(t){return __awaiter(this,arguments,void 0,(function*(t,e={}){return yield this._performRequest({method:http_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GRAPHQL.BATCH,body:{query:t},headers:e})}))}handleResponseData(t){if(!t.data&&t.errors)throw new Error(`GraphQL error: ${JSON.stringify(t.errors)}`)}}exports.GraphQLClient=GraphQLClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String,Object]),__metadata("design:returntype",Promise)],GraphQLClient.prototype,"execute",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String,Object]),__metadata("design:returntype",Promise)],GraphQLClient.prototype,"executeBatch",null);
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(t,e,n,a){return new(n||(n=Promise))((function(i,r){function s(t){try{c(a.next(t))}catch(t){r(t)}}function o(t){try{c(a.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,o)}c((a=a.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.MetadataClient=void 0;const constants_1=require("../constants"),base_client_1=require("./base-client");class MetadataClient extends base_client_1.BaseClient{fetchAllMetadata(){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({endpoint:constants_1.TENANT_ENDPOINTS.METADATA.ALL})}))}fetchObjectMetadata(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({endpoint:constants_1.TENANT_ENDPOINTS.METADATA.OBJECT(t)})}))}}exports.MetadataClient=MetadataClient;
1
+ "use strict";var __decorate=this&&this.__decorate||function(t,e,a,n){var i,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,a):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,a,n);else for(var c=t.length-1;c>=0;c--)(i=t[c])&&(r=(o<3?i(r):o>3?i(e,a,r):i(e,a))||r);return o>3&&r&&Object.defineProperty(e,a,r),r},__metadata=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__awaiter=this&&this.__awaiter||function(t,e,a,n){return new(a||(a=Promise))((function(i,o){function r(t){try{_(n.next(t))}catch(t){o(t)}}function c(t){try{_(n.throw(t))}catch(t){o(t)}}function _(t){var e;t.done?i(t.value):(e=t.value,e instanceof a?e:new a((function(t){t(e)}))).then(r,c)}_((n=n.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.MetadataClient=void 0;const constants_1=require("../constants"),monitor_call_1=require("../monitoring/decorators/monitor-call"),base_client_1=require("./base-client");class MetadataClient extends base_client_1.BaseClient{fetchAllMetadata(){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.METADATA.ALL})}))}fetchObjectMetadata(t){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.METADATA.OBJECT(t)})}))}}exports.MetadataClient=MetadataClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],MetadataClient.prototype,"fetchAllMetadata",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String]),__metadata("design:returntype",Promise)],MetadataClient.prototype,"fetchObjectMetadata",null);
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(i,s){function r(t){try{a(o.next(t))}catch(t){s(t)}}function T(t){try{a(o.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,T)}a((o=o.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.MobileNotificationClient=void 0;const constants_1=require("../constants"),base_client_1=require("./base-client");class MobileNotificationClient extends base_client_1.BaseClient{getTemplates(){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.GET_TEMPLATES})}))}deleteTemplate(t,e){return __awaiter(this,void 0,void 0,(function*(){yield this.performRequest({method:constants_1.HttpMethod.DELETE,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.DELETE_TEMPLATE(t,e)})}))}setTemplate(t,e,n){return __awaiter(this,void 0,void 0,(function*(){yield this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.SET_TEMPLATE(t,e),body:{template:n}})}))}dispatchResources(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.DISPATCH,body:t})}))}notifyAllocatedResources(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.NOTIFY,body:t})}))}notifyJobCancellation(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.NOTIFY_CANCEL,body:t})}))}sendOneOffMessage(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.ONE_OFF,body:t})}))}sendSms(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.SEND_SMS,body:t})}))}requestSmsConfirmation(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.SMS_CONFIRMATION_REQUEST,body:t})}))}}exports.MobileNotificationClient=MobileNotificationClient;
1
+ "use strict";var __decorate=this&&this.__decorate||function(t,e,o,n){var i,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,o,n);else for(var _=t.length-1;_>=0;_--)(i=t[_])&&(r=(a<3?i(r):a>3?i(e,o,r):i(e,o))||r);return a>3&&r&&Object.defineProperty(e,o,r),r},__metadata=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__awaiter=this&&this.__awaiter||function(t,e,o,n){return new(o||(o=Promise))((function(i,a){function r(t){try{s(n.next(t))}catch(t){a(t)}}function _(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(r,_)}s((n=n.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.MobileNotificationClient=void 0;const constants_1=require("../constants"),monitor_call_1=require("../monitoring/decorators/monitor-call"),base_client_1=require("./base-client");class MobileNotificationClient extends base_client_1.BaseClient{getTemplates(){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.GET_TEMPLATES})}))}deleteTemplate(t,e){return __awaiter(this,void 0,void 0,(function*(){yield this._performRequest({method:constants_1.HttpMethod.DELETE,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.DELETE_TEMPLATE(t,e)})}))}setTemplate(t,e,o){return __awaiter(this,void 0,void 0,(function*(){yield this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.SET_TEMPLATE(t,e),body:{template:o}})}))}dispatchResources(t){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.DISPATCH,body:t})}))}notifyAllocatedResources(t){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.NOTIFY,body:t})}))}notifyJobCancellation(t){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.NOTIFY_CANCEL,body:t})}))}sendOneOffMessage(t){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.ONE_OFF,body:t})}))}sendSms(t){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.SEND_SMS,body:t})}))}requestSmsConfirmation(t){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.SMS_CONFIRMATION_REQUEST,body:t})}))}}exports.MobileNotificationClient=MobileNotificationClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],MobileNotificationClient.prototype,"getTemplates",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String,String]),__metadata("design:returntype",Promise)],MobileNotificationClient.prototype,"deleteTemplate",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String,String,String]),__metadata("design:returntype",Promise)],MobileNotificationClient.prototype,"setTemplate",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],MobileNotificationClient.prototype,"dispatchResources",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],MobileNotificationClient.prototype,"notifyAllocatedResources",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],MobileNotificationClient.prototype,"notifyJobCancellation",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],MobileNotificationClient.prototype,"sendOneOffMessage",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],MobileNotificationClient.prototype,"sendSms",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],MobileNotificationClient.prototype,"requestSmsConfirmation",null);
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function c(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OrgPreferenceClient=void 0;const constants_1=require("../constants"),base_client_1=require("./base-client");class OrgPreferenceClient extends base_client_1.BaseClient{get(){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({endpoint:constants_1.TENANT_ENDPOINTS.ORG_PREFERENCE.GET})}))}deploy(e){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.ORG_PREFERENCE.UPDATE,body:e})}))}}exports.OrgPreferenceClient=OrgPreferenceClient;
1
+ "use strict";var __decorate=this&&this.__decorate||function(e,t,n,r){var o,a=arguments.length,i=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(i=(a<3?o(i):a>3?o(t,n,i):o(t,n))||i);return a>3&&i&&Object.defineProperty(t,n,i),i},__metadata=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{_(r.next(e))}catch(e){a(e)}}function c(e){try{_(r.throw(e))}catch(e){a(e)}}function _(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}_((r=r.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OrgPreferenceClient=void 0;const constants_1=require("../constants"),monitor_call_1=require("../monitoring/decorators/monitor-call"),base_client_1=require("./base-client");class OrgPreferenceClient extends base_client_1.BaseClient{get(){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.ORG_PREFERENCE.GET})}))}deploy(e){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.ORG_PREFERENCE.UPDATE,body:e})}))}}exports.OrgPreferenceClient=OrgPreferenceClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],OrgPreferenceClient.prototype,"get",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],OrgPreferenceClient.prototype,"deploy",null);
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function a(t){try{c(o.next(t))}catch(t){r(t)}}function s(t){try{c(o.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((o=o.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.VocabularyClient=void 0;const constants_1=require("../constants"),base_client_1=require("./base-client");class VocabularyClient extends base_client_1.BaseClient{getVocabularyItems(t,e){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({endpoint:constants_1.TENANT_ENDPOINTS.VOCABULARY.GET_ITEMS(t,e)})}))}addVocabularyItem(t,e,n){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.VOCABULARY.ADD_ITEM(t,e),body:n})}))}updateVocabularyItem(t,e,n,o){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:constants_1.HttpMethod.PUT,endpoint:constants_1.TENANT_ENDPOINTS.VOCABULARY.UPDATE_ITEM(t,e,n),body:o})}))}}exports.VocabularyClient=VocabularyClient;
1
+ "use strict";var __decorate=this&&this.__decorate||function(t,e,a,n){var o,r=arguments.length,i=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,a):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,a,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(i=(r<3?o(i):r>3?o(e,a,i):o(e,a))||i);return r>3&&i&&Object.defineProperty(e,a,i),i},__metadata=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__awaiter=this&&this.__awaiter||function(t,e,a,n){return new(a||(a=Promise))((function(o,r){function i(t){try{_(n.next(t))}catch(t){r(t)}}function c(t){try{_(n.throw(t))}catch(t){r(t)}}function _(t){var e;t.done?o(t.value):(e=t.value,e instanceof a?e:new a((function(t){t(e)}))).then(i,c)}_((n=n.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.VocabularyClient=void 0;const constants_1=require("../constants"),monitor_call_1=require("../monitoring/decorators/monitor-call"),base_client_1=require("./base-client");class VocabularyClient extends base_client_1.BaseClient{getVocabularyItems(t,e){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.VOCABULARY.GET_ITEMS(t,e)})}))}addVocabularyItem(t,e,a){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.VOCABULARY.ADD_ITEM(t,e),body:a})}))}updateVocabularyItem(t,e,a,n){return __awaiter(this,void 0,void 0,(function*(){return yield this._performRequest({method:constants_1.HttpMethod.PUT,endpoint:constants_1.TENANT_ENDPOINTS.VOCABULARY.UPDATE_ITEM(t,e,a),body:n})}))}}exports.VocabularyClient=VocabularyClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String,String]),__metadata("design:returntype",Promise)],VocabularyClient.prototype,"getVocabularyItems",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String,String,Object]),__metadata("design:returntype",Promise)],VocabularyClient.prototype,"addVocabularyItem",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String,String,String,Object]),__metadata("design:returntype",Promise)],VocabularyClient.prototype,"updateVocabularyItem",null);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TENANT_ENDPOINTS=void 0,exports.TENANT_ENDPOINTS={CONFIG_VAR:{CREATE:"configuration/extension",GET:e=>`configuration/extension/${e}`,UPDATE:e=>`configuration/extension/${e}`,DELETE:e=>`configuration/extension/${e}`,SEARCH:"configuration/extension/search"},GRAPHQL:"graphql/graphql",METADATA:{ALL:"custom/metadata",OBJECT:e=>`custom/metadata/${e}`},ORG_PREFERENCE:{GET:"config/org_preference",UPDATE:"config/org_preference"},CONFIG_TEMPLATE:{GET_TEMPLATES:e=>`config/templates/${e}`,GET_VALUES:e=>`config/template/${e}/values`,UPDATE_VALUES:e=>`config/template/${e}/values`,CREATE:"config/template",DELETE:e=>`config/template/${e}`},CONFIG_FEATURES:{GET:"config/features",UPDATE:e=>`config/features/${e}`},VOCABULARY:{GET_ITEMS:(e,o)=>`custom/vocabulary/${e}/${o}`,ADD_ITEM:(e,o)=>`custom/vocabulary/${e}/${o}`,UPDATE_ITEM:(e,o,i)=>`custom/vocabulary/${e}/${o}/${i}`},NOTIFICATIONS:{GET_TEMPLATES:"notifications/v2/templates",DELETE_TEMPLATE:(e,o)=>`notifications/v2/template/${e}/${o}`,SET_TEMPLATE:(e,o)=>`notifications/v2/template/${e}/${o}`,DISPATCH:"notifications/dispatch",NOTIFY:"notifications/notify",NOTIFY_CANCEL:"notifications/notify_cancel",ONE_OFF:"notifications/oneoff",SEND_SMS:"notifications/sms",SMS_CONFIRMATION_REQUEST:"notifications/sms/confirmation_request"},GEOSERVICES:{DISTANCE_MATRIX:"geoservices/distanceMatrix",DIRECTIONS:"geoservices/directions",GEOCODE:"geoservices/geocode",AUTOCOMPLETE:"geoservices/autocomplete",PLACE:"geoservices/place",TIMEZONE:"geoservices/timezone"},AVAILABILITY:{SIMPLE:"availability/simple"}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TENANT_ENDPOINTS=void 0,exports.TENANT_ENDPOINTS={CONFIG_VAR:{CREATE:"configuration/extension",GET:e=>`configuration/extension/${e}`,UPDATE:e=>`configuration/extension/${e}`,DELETE:e=>`configuration/extension/${e}`,SEARCH:"configuration/extension/search"},GRAPHQL:{SINGLE:"graphql/graphql",BATCH:"graphql/graphql/batch"},METADATA:{ALL:"custom/metadata",OBJECT:e=>`custom/metadata/${e}`},ORG_PREFERENCE:{GET:"config/org_preference",UPDATE:"config/org_preference"},CONFIG_TEMPLATE:{GET_TEMPLATES:e=>`config/templates/${e}`,GET_VALUES:e=>`config/template/${e}/values`,UPDATE_VALUES:e=>`config/template/${e}/values`,CREATE:"config/template",DELETE:e=>`config/template/${e}`},CONFIG_FEATURES:{GET:"config/features",UPDATE:e=>`config/features/${e}`},VOCABULARY:{GET_ITEMS:(e,o)=>`custom/vocabulary/${e}/${o}`,ADD_ITEM:(e,o)=>`custom/vocabulary/${e}/${o}`,UPDATE_ITEM:(e,o,t)=>`custom/vocabulary/${e}/${o}/${t}`},NOTIFICATIONS:{GET_TEMPLATES:"notifications/v2/templates",DELETE_TEMPLATE:(e,o)=>`notifications/v2/template/${e}/${o}`,SET_TEMPLATE:(e,o)=>`notifications/v2/template/${e}/${o}`,DISPATCH:"notifications/dispatch",NOTIFY:"notifications/notify",NOTIFY_CANCEL:"notifications/notify_cancel",ONE_OFF:"notifications/oneoff",SEND_SMS:"notifications/sms",SMS_CONFIRMATION_REQUEST:"notifications/sms/confirmation_request"},GEOSERVICES:{DISTANCE_MATRIX:"geoservices/distanceMatrix",DIRECTIONS:"geoservices/directions",GEOCODE:"geoservices/geocode",AUTOCOMPLETE:"geoservices/autocomplete",PLACE:"geoservices/place",TIMEZONE:"geoservices/timezone"},AVAILABILITY:{SIMPLE:"availability/simple"}};
@@ -1 +1 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ExecutionContext=void 0;const function_utilities_1=require("@skedulo/function-utilities"),clients_1=require("../clients"),artifact_client_1=require("../clients/artifact-client"),availability_api_client_1=require("../clients/availability-api-client"),config_features_client_1=require("../clients/config-features-client"),config_template_client_1=require("../clients/config-template-client"),config_var_client_1=require("../clients/config-var-client"),geo_api_client_1=require("../clients/geo-api-client"),graphql_client_1=require("../clients/graphql-client"),metadata_client_1=require("../clients/metadata-client"),mobile_notification_client_1=require("../clients/mobile-notification-client"),org_preference_client_1=require("../clients/org-preference-client"),vocabulary_client_1=require("../clients/vocabulary-client"),logger_1=__importDefault(require("../logging/logger")),cache_service_1=require("../services/cache/cache-service"),storage_1=require("../services/cache/storage"),geoservice_1=require("../services/geoservice"),graphql_1=require("../services/graphql"),lock_service_1=require("../services/lock-service"),metadata_service_1=require("../services/metadata-service"),data_service_1=require("../services/resource-availability/builder/data-service"),resource_availability_service_1=require("../services/resource-availability/builder/resource-availability-service"),resource_builder_1=require("../services/resource-availability/builder/resource-builder"),utils_1=require("../utils"),request_header_constants_1=require("./request-header-constants");class ExecutionContext{constructor(e,i={}){this.logger=logger_1.default,this.services=new Map,this.skedContext=e,this.contextData={},this._executionOptions=i,this.baseConfig={apiToken:e.auth.token,apiServer:e.auth.baseUrl}}static fromContext(e,i={}){return new ExecutionContext(e,i)}static fromCredentials(e,i={}){const t={Authorization:`Bearer ${e.apiToken}`,[request_header_constants_1.REQUEST_HEADERS.SKED_API_SERVER]:e.apiServer},r=(0,function_utilities_1.createSkedContext)(t),n=new ExecutionContext(r,i);return n.baseConfig=Object.assign(Object.assign({},e),n.baseConfig),n}set executionOptions(e){this._executionOptions=Object.assign(Object.assign({},this._executionOptions),e)}get executionOptions(){return this._executionOptions}getOrCreateService(e,i){return this.services.has(e)||this.services.set(e,i()),this.services.get(e)}get configHelper(){return this.getOrCreateService("configHelper",(()=>new utils_1.ConfigHelper(this.skedContext.configVars)))}get baseClient(){return this.getOrCreateService("baseClient",(()=>new clients_1.BaseClient(this.baseConfig,this.executionOptions)))}get graphqlClient(){return this.getOrCreateService("graphqlClient",(()=>new graphql_client_1.GraphQLClient(this.baseConfig,this.executionOptions)))}get graphqlService(){return this.getOrCreateService("graphqlService",(()=>new graphql_1.GraphQLService(this.graphqlClient)))}get metadataClient(){return this.getOrCreateService("metadataClient",(()=>new metadata_client_1.MetadataClient(this.baseConfig,this.executionOptions)))}get metadataService(){return this.getOrCreateService("metadataService",(()=>new metadata_service_1.MetadataService(this.metadataClient)))}get vocabularyClient(){return this.getOrCreateService("vocabularyClient",(()=>new vocabulary_client_1.VocabularyClient(this.baseConfig,this.executionOptions)))}get orgPreferencesClient(){return this.getOrCreateService("orgPreferencesClient",(()=>new org_preference_client_1.OrgPreferenceClient(this.baseConfig,this.executionOptions)))}get configTemplateClient(){return this.getOrCreateService("configTemplateClient",(()=>new config_template_client_1.ConfigTemplateClient(this.baseConfig,this.executionOptions)))}get configFeaturesClient(){return this.getOrCreateService("configFeaturesClient",(()=>new config_features_client_1.ConfigFeaturesClient(this.baseConfig,this.executionOptions)))}get configVarClient(){return this.getOrCreateService("configVarClient",(()=>new config_var_client_1.ConfigVarClient(this.baseConfig,this.executionOptions)))}get mobileNotificationClient(){return this.getOrCreateService("mobileNotificationClient",(()=>new mobile_notification_client_1.MobileNotificationClient(this.baseConfig,this.executionOptions)))}get geoAPIClient(){return this.getOrCreateService("geoAPIClient",(()=>new geo_api_client_1.GeoAPIClient(this.baseConfig,this.executionOptions)))}get availabilityAPIClient(){return this.getOrCreateService("availabilityAPIClient",(()=>new availability_api_client_1.AvailabilityAPIClient(this.baseConfig,this.executionOptions)))}get geoService(){return this.getOrCreateService("geoService",(()=>new geoservice_1.GeoService(this.geoAPIClient)))}get lockService(){return this.getOrCreateService("lockService",(()=>new lock_service_1.LockService(this.configVarClient)))}get configVarCache(){return this.getOrCreateService("configVarCache",(()=>new cache_service_1.CacheService(new storage_1.ConfigVarCacheStorage(this.configVarClient))))}get inMemoryCache(){return this.getOrCreateService("inMemoryCache",(()=>{const e=new cache_service_1.CacheService(new storage_1.InMemoryCacheStorage);return e.setSecondaryCache(this.configVarCache),e}))}get resourceAvailabilityService(){return this.getOrCreateService("resourceAvailabilityService",(()=>new resource_availability_service_1.ResourceAvailabilityService(this.availabilityAPIClient)))}get dataService(){return this.getOrCreateService("dataService",(()=>new data_service_1.DataService(this.graphqlService)))}get resourceBuilder(){return this.getOrCreateService("resourceBuilder",(()=>new resource_builder_1.ResourceBuilder(this.dataService,this.resourceAvailabilityService)))}newQueryBuilder(e){const i=new graphql_1.GraphQLQueryBuilder(e);return i.setGraphqlService(this.graphqlService),i}newArtifactClient(e){return this.getOrCreateService(`${e}Client`,(()=>new artifact_client_1.ArtifactClient(this.baseConfig,e,this.executionOptions)))}dispose(){this.services.clear()}}exports.ExecutionContext=ExecutionContext;
1
+ "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ExecutionContext=void 0;const function_utilities_1=require("@skedulo/function-utilities"),clients_1=require("../clients"),artifact_client_1=require("../clients/artifact-client"),availability_api_client_1=require("../clients/availability-api-client"),config_features_client_1=require("../clients/config-features-client"),config_template_client_1=require("../clients/config-template-client"),config_var_client_1=require("../clients/config-var-client"),geo_api_client_1=require("../clients/geo-api-client"),graphql_client_1=require("../clients/graphql-client"),metadata_client_1=require("../clients/metadata-client"),mobile_notification_client_1=require("../clients/mobile-notification-client"),org_preference_client_1=require("../clients/org-preference-client"),vocabulary_client_1=require("../clients/vocabulary-client"),logger_1=__importDefault(require("../logging/logger")),monitoring_constants_1=require("../monitoring/monitoring-constants"),monitoring_registry_1=require("../monitoring/monitoring-registry"),cache_service_1=require("../services/cache/cache-service"),storage_1=require("../services/cache/storage"),geoservice_1=require("../services/geoservice"),graphql_1=require("../services/graphql"),lock_service_1=require("../services/lock-service"),metadata_service_1=require("../services/metadata-service"),data_service_1=require("../services/resource-availability/builder/data-service"),resource_availability_service_1=require("../services/resource-availability/builder/resource-availability-service"),resource_builder_1=require("../services/resource-availability/builder/resource-builder"),utils_1=require("../utils"),request_header_constants_1=require("./request-header-constants");class ExecutionContext{constructor(e,t={},i){this.logger=logger_1.default,this.services=new Map,this.skedContext=e,this.contextData={},this._executionOptions=t,this.baseConfig={apiToken:e.auth.token,apiServer:e.auth.baseUrl},(0,monitoring_registry_1.initGlobalMonitorManager)(i)}static fromContext(e,t={},i=monitoring_constants_1.DEFAULT_THRESHOLD_CONFIG){return ExecutionContext.instance?ExecutionContext.instance.updateConfig(e,t,i):ExecutionContext.instance=new ExecutionContext(e,t,Object.assign(Object.assign({},monitoring_constants_1.DEFAULT_THRESHOLD_CONFIG),i)),ExecutionContext.instance}static fromCredentials(e,t={},i=monitoring_constants_1.DEFAULT_THRESHOLD_CONFIG){const r={Authorization:`Bearer ${e.apiToken}`,[request_header_constants_1.REQUEST_HEADERS.SKED_API_SERVER]:e.apiServer},n=(0,function_utilities_1.createSkedContext)(r);return ExecutionContext.instance?ExecutionContext.instance.updateConfig(n,t,i,e):ExecutionContext.instance=new ExecutionContext(n,t,Object.assign(Object.assign({},monitoring_constants_1.DEFAULT_THRESHOLD_CONFIG),i)),ExecutionContext.instance}updateConfig(e,t,i,r){this.skedContext=e,this._executionOptions=Object.assign(Object.assign({},this._executionOptions),t),r&&(this.baseConfig=Object.assign(Object.assign({},r),this.baseConfig))}set executionOptions(e){this._executionOptions=Object.assign(Object.assign({},this._executionOptions),e)}get executionOptions(){return this._executionOptions}getOrCreateService(e,t){return this.services.has(e)||this.services.set(e,t()),this.services.get(e)}get configHelper(){return this.getOrCreateService("configHelper",(()=>new utils_1.ConfigHelper(this.skedContext.configVars)))}get baseClient(){return this.getOrCreateService("baseClient",(()=>new clients_1.BaseClient(this.baseConfig,this.executionOptions)))}get graphqlClient(){return this.getOrCreateService("graphqlClient",(()=>new graphql_client_1.GraphQLClient(this.baseConfig,this.executionOptions)))}get graphqlService(){return this.getOrCreateService("graphqlService",(()=>new graphql_1.GraphQLService(this.graphqlClient)))}get metadataClient(){return this.getOrCreateService("metadataClient",(()=>new metadata_client_1.MetadataClient(this.baseConfig,this.executionOptions)))}get metadataService(){return this.getOrCreateService("metadataService",(()=>new metadata_service_1.MetadataService(this.metadataClient)))}get vocabularyClient(){return this.getOrCreateService("vocabularyClient",(()=>new vocabulary_client_1.VocabularyClient(this.baseConfig,this.executionOptions)))}get orgPreferencesClient(){return this.getOrCreateService("orgPreferencesClient",(()=>new org_preference_client_1.OrgPreferenceClient(this.baseConfig,this.executionOptions)))}get configTemplateClient(){return this.getOrCreateService("configTemplateClient",(()=>new config_template_client_1.ConfigTemplateClient(this.baseConfig,this.executionOptions)))}get configFeaturesClient(){return this.getOrCreateService("configFeaturesClient",(()=>new config_features_client_1.ConfigFeaturesClient(this.baseConfig,this.executionOptions)))}get configVarClient(){return this.getOrCreateService("configVarClient",(()=>new config_var_client_1.ConfigVarClient(this.baseConfig,this.executionOptions)))}get mobileNotificationClient(){return this.getOrCreateService("mobileNotificationClient",(()=>new mobile_notification_client_1.MobileNotificationClient(this.baseConfig,this.executionOptions)))}get geoAPIClient(){return this.getOrCreateService("geoAPIClient",(()=>new geo_api_client_1.GeoAPIClient(this.baseConfig,this.executionOptions)))}get availabilityAPIClient(){return this.getOrCreateService("availabilityAPIClient",(()=>new availability_api_client_1.AvailabilityAPIClient(this.baseConfig,this.executionOptions)))}get geoService(){return this.getOrCreateService("geoService",(()=>new geoservice_1.GeoService(this.geoAPIClient)))}get lockService(){return this.getOrCreateService("lockService",(()=>new lock_service_1.LockService(this.configVarClient)))}get configVarCache(){return this.getOrCreateService("configVarCache",(()=>new cache_service_1.CacheService(new storage_1.ConfigVarCacheStorage(this.configVarClient))))}get inMemoryCache(){return this.getOrCreateService("inMemoryCache",(()=>{const e=new cache_service_1.CacheService(new storage_1.InMemoryCacheStorage);return e.setSecondaryCache(this.configVarCache),e}))}get resourceAvailabilityService(){return this.getOrCreateService("resourceAvailabilityService",(()=>new resource_availability_service_1.ResourceAvailabilityService(this.availabilityAPIClient)))}get dataService(){return this.getOrCreateService("dataService",(()=>new data_service_1.DataService(this.graphqlService)))}get resourceBuilder(){return this.getOrCreateService("resourceBuilder",(()=>new resource_builder_1.ResourceBuilder(this.dataService,this.resourceAvailabilityService)))}newQueryBuilder(e){const t=new graphql_1.GraphQLQueryBuilder(e);return t.setGraphqlService(this.graphqlService),t}newArtifactClient(e){return this.getOrCreateService(`${e}Client`,(()=>new artifact_client_1.ArtifactClient(this.baseConfig,e,this.executionOptions)))}dispose(){this.services.clear()}getExecutionMetrics(){return(0,monitoring_registry_1.getGlobalMonitorManager)().getExecutionMetrics()}}exports.ExecutionContext=ExecutionContext,ExecutionContext.instance=null;
package/dist/index.d.ts CHANGED
@@ -111,6 +111,7 @@ export declare class BaseClient {
111
111
  * @throws {Error} - If the request fails or the response is not OK.
112
112
  */
113
113
  performRequest<T = any>({ method, endpoint, headers, body, queryParams }: RequestParams, executionOptions?: Partial<ExecutionOptions>): Promise<T>;
114
+ protected _performRequest<T = any>({ method, endpoint, headers, body, queryParams }: RequestParams, executionOptions?: Partial<ExecutionOptions>): Promise<T>;
114
115
  protected handleResponseData(response: Response): void;
115
116
  /**
116
117
  * Constructs the headers for API requests.
@@ -321,7 +322,10 @@ export declare const TENANT_ENDPOINTS: {
321
322
  readonly DELETE: (key: string) => string;
322
323
  readonly SEARCH: "configuration/extension/search";
323
324
  };
324
- readonly GRAPHQL: "graphql/graphql";
325
+ readonly GRAPHQL: {
326
+ readonly SINGLE: "graphql/graphql";
327
+ readonly BATCH: "graphql/graphql/batch";
328
+ };
325
329
  readonly METADATA: {
326
330
  readonly ALL: "custom/metadata";
327
331
  readonly OBJECT: (objectMapping: string) => string;
@@ -422,6 +426,14 @@ export declare class GraphQLClient extends BaseClient {
422
426
  * @throws {Error} - If the request fails or if there are errors in the response.
423
427
  */
424
428
  execute(graphqlQuery: string, headers?: Record<string, string>): Promise<GraphQlResponse>;
429
+ /**
430
+ * Executes a GraphQL query or mutation.
431
+ * @param {string} graphqlQuery - The GraphQL queries and/or mutations.
432
+ * @param {Record<string, string>} headers - Additional headers to include in the request.
433
+ * @returns {Promise<GraphQlResponse>} - The response from the GraphQL API.
434
+ * @throws {Error} - If the request fails or if there are errors in the response.
435
+ */
436
+ executeBatch(graphqlQuery: string, headers?: Record<string, string>): Promise<GraphQlResponse>;
425
437
  protected handleResponseData(responseData: any): void;
426
438
  }
427
439
  /**
@@ -862,6 +874,13 @@ export interface LockInfo {
862
874
  description?: string;
863
875
  }
864
876
  declare const logger: import("winston").Logger;
877
+ export interface ThresholdConfig {
878
+ totalCalls?: number;
879
+ maxConcurrentRequests?: number;
880
+ maxMethodExecutionTimeMs?: number;
881
+ maxMethodCalls?: number;
882
+ throwOnViolation?: boolean;
883
+ }
865
884
  export declare class CacheService<T> {
866
885
  private storage;
867
886
  private secondaryCache?;
@@ -1202,15 +1221,17 @@ export declare class DateTimeUtils {
1202
1221
  static mergeEvents(events: BaseEvent[]): BaseEvent[];
1203
1222
  }
1204
1223
  export declare class ExecutionContext {
1224
+ private static instance;
1205
1225
  skedContext: any;
1206
1226
  contextData: any;
1207
1227
  private baseConfig;
1208
1228
  logger: typeof logger;
1209
1229
  private services;
1210
1230
  private _executionOptions;
1211
- protected constructor(skedContext: any, executionOptions?: Partial<ExecutionOptions>);
1212
- static fromContext(skedContext: any, executionOptions?: Partial<ExecutionOptions>): ExecutionContext;
1213
- static fromCredentials(config: BaseConfig, executionOptions?: Partial<ExecutionOptions>): ExecutionContext;
1231
+ protected constructor(skedContext: any, executionOptions: Partial<ExecutionOptions> | undefined, threshholds: ThresholdConfig);
1232
+ static fromContext(skedContext: any, executionOptions?: Partial<ExecutionOptions>, threshholds?: ThresholdConfig): ExecutionContext;
1233
+ static fromCredentials(config: BaseConfig, executionOptions?: Partial<ExecutionOptions>, threshholds?: ThresholdConfig): ExecutionContext;
1234
+ private updateConfig;
1214
1235
  set executionOptions(executionOptions: Partial<ExecutionOptions>);
1215
1236
  get executionOptions(): Partial<ExecutionOptions>;
1216
1237
  /**
@@ -1241,6 +1262,7 @@ export declare class ExecutionContext {
1241
1262
  newQueryBuilder(params: GraphqlQueryParams): GraphQLQueryBuilder;
1242
1263
  newArtifactClient(artifactType: ArtifactType): ArtifactClient;
1243
1264
  dispose(): void;
1265
+ getExecutionMetrics(): any;
1244
1266
  }
1245
1267
  export declare const REQUEST_HEADERS: Record<string, string>;
1246
1268
  export declare const TenantObjects: {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const winston_1=require("winston"),devFormat=winston_1.format.printf((({timestamp:e,level:o,message:t})=>`[${e}] ${o.toUpperCase()}: ${t}`)),logger=(0,winston_1.createLogger)({level:process.env.LOG_LEVEL||"info",format:winston_1.format.combine(winston_1.format.timestamp({format:"YYYY-MM-DD HH:mm:ss"}),"production"===process.env.NODE_ENV?winston_1.format.json():devFormat),transports:[new winston_1.transports.Console]});exports.default=logger;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const winston_1=require("winston"),devFormat=winston_1.format.printf((({timestamp:e,level:o,message:t})=>`[${e}] ${o.toUpperCase()}: ${t}`)),logger=(0,winston_1.createLogger)({level:process.env.LOG_LEVEL||"info",format:winston_1.format.combine(winston_1.format.timestamp({format:"YYYY-MM-DD HH:mm:ss.SSS"}),"production"===process.env.NODE_ENV?winston_1.format.json():devFormat),transports:[new winston_1.transports.Console]});exports.default=logger;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Decorator factory that takes a MonitoringManager instance and an optional
3
+ * explicit methodIdentifier override. If not provided, the decorator will
4
+ * default to ClassName.MethodName.
5
+ */
6
+ export declare function MonitorCall(methodIdentifier?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
@@ -0,0 +1 @@
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(t,n,r,o){return new(r||(r=Promise))((function(e,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function u(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,u)}c((o=o.apply(t,n||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.MonitorCall=MonitorCall;const monitoring_registry_1=require("../monitoring-registry");function MonitorCall(t){return function(n,r,o){const e=o.value;return o.value=function(...o){return __awaiter(this,void 0,void 0,(function*(){const i=t||`${n.constructor.name}.${r}`;return(0,monitoring_registry_1.getGlobalMonitorManager)().measure(i,(()=>__awaiter(this,void 0,void 0,(function*(){return e.apply(this,o)}))))}))},o}}
@@ -0,0 +1 @@
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(t,n,r,o){return new(r||(r=Promise))((function(e,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function u(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,u)}c((o=o.apply(t,n||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.MonitorCall=MonitorCall;const monitoring_registry_1=require("./monitoring-registry");function MonitorCall(t){return function(n,r,o){const e=o.value;return o.value=function(...o){return __awaiter(this,void 0,void 0,(function*(){const i=t||`${n.constructor.name}.${r}`;return(0,monitoring_registry_1.getGlobalMonitorManager)().measure(i,(()=>__awaiter(this,void 0,void 0,(function*(){return e.apply(this,o)}))))}))},o}}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_THRESHOLD_CONFIG=void 0,exports.DEFAULT_THRESHOLD_CONFIG={totalCalls:50,maxConcurrentRequests:5,maxMethodExecutionTimeMs:12e3,throwOnViolation:!1};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1 @@
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(t,e,o,s){return new(o||(o=Promise))((function(i,n){function a(t){try{r(s.next(t))}catch(t){n(t)}}function l(t){try{r(s.throw(t))}catch(t){n(t)}}function r(t){var e;t.done?i(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(a,l)}r((s=s.apply(t,e||[])).next())}))},__importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.MonitoringManager=void 0;const logger_1=__importDefault(require("../logging/logger"));class MonitoringManager{constructor(t={}){this.totalCalls=0,this.methodCallCounts={},this.methodExecutionTimes={},this.concurrentRequests=0,this.peakConcurrentRequests=0,this.startTime=Date.now(),this.violations={},this.thresholds=t}measure(t,e){return __awaiter(this,void 0,void 0,(function*(){this.incrementTotalCallsCount(),this.incrementMethodCount(t),this.trackConcurrentRequest(1,t);const o=Date.now();let s;try{s=yield e()}finally{this.trackConcurrentRequest(-1,t)}const i=Date.now()-o;return this.trackExecutionTime(t,i),this.checkMethodDuration(t,i),s}))}trackConcurrentRequest(t,e){this.concurrentRequests+=t,this.peakConcurrentRequests=Math.max(this.peakConcurrentRequests,this.concurrentRequests),this.thresholds.maxConcurrentRequests&&this.peakConcurrentRequests>this.thresholds.maxConcurrentRequests&&this.handleViolation("maxConcurrentRequests",`Method ${e} max concurrent requests exceeded: ${this.peakConcurrentRequests} (Allowed: ${this.thresholds.maxConcurrentRequests})`)}getExecutionMetrics(){return{totalCalls:this.totalCalls,totalExecutionTimeMs:Date.now()-this.startTime,peakConcurrentRequests:this.peakConcurrentRequests,methodCallCounts:Object.assign({},this.methodCallCounts),methodExecutionTimes:Object.assign({},this.methodExecutionTimes),violations:Object.values(this.violations)}}incrementTotalCallsCount(){this.totalCalls++,this.thresholds.totalCalls&&this.totalCalls>this.thresholds.totalCalls&&this.handleViolation("totalCalls",`Total calls limit exceeded: ${this.totalCalls} (Allowed: ${this.thresholds.totalCalls})`)}incrementMethodCount(t){var e;this.methodCallCounts[t]=(null!==(e=this.methodCallCounts[t])&&void 0!==e?e:0)+1;const o=`methodCallLimit:${t}`,s=this.thresholds.maxMethodCalls;s&&this.methodCallCounts[t]>s&&this.handleViolation(o,`Method [${t}] call limit exceeded: ${this.methodCallCounts[t]} (Allowed: ${s})`)}trackExecutionTime(t,e){this.methodExecutionTimes[t]||(this.methodExecutionTimes[t]={totalTime:0,count:0,min:Number.MAX_VALUE,max:0});const o=this.methodExecutionTimes[t];o.totalTime+=e,o.count+=1,o.min=Math.min(o.min,e),o.max=Math.max(o.max,e)}checkMethodDuration(t,e){const o=this.thresholds.maxMethodExecutionTimeMs,s=`methodDurationLimit:${t}`;o&&e>o&&this.handleViolation(s,`Method [${t}] exceeded duration limit: ${e}ms (Allowed: ${o}ms)`)}handleViolation(t,e){if(this.violations[t]=e,this.thresholds.throwOnViolation)throw new Error(e);logger_1.default.warn(`[Violation] ${e}`)}}exports.MonitoringManager=MonitoringManager;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getGlobalMonitorManager=getGlobalMonitorManager,exports.initGlobalMonitorManager=initGlobalMonitorManager;const monitoring_manager_1=require("./monitoring-manager");let manager=null;function getGlobalMonitorManager(){return manager||(manager=new monitoring_manager_1.MonitoringManager),manager}function initGlobalMonitorManager(n={}){manager=new monitoring_manager_1.MonitoringManager(n)}
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(t,e,i,r){return new(i||(i=Promise))((function(a,s){function n(t){try{o(r.next(t))}catch(t){s(t)}}function h(t){try{o(r.throw(t))}catch(t){s(t)}}function o(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(n,h)}o((r=r.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GraphBatch=void 0;const graph_batch_config_1=require("./configs/graph-batch-config"),pagination_strategy_1=require("./pagination-strategy");class GraphBatch{constructor(t,e){this.startTime=new Date,this.context=t,this.config=(0,graph_batch_config_1.initializeConfig)(e),this.startTime=new Date}run(){return __awaiter(this,void 0,void 0,(function*(){var t,e;if(this.queryBuilder=yield this.start(),!this.queryBuilder)throw new Error("Query builder was not defined in start().");this.queryBuilder.withLimit(this.config.batchSize);let i=0,r=!0;for(;r&&!this.isMaxBatchesReached(i)&&(this.queryResult=yield this.fetchNextPage(),this.queryResult.records&&0!==this.queryResult.records.length);)yield this.execute(this.queryResult.records),i++,r=null!==(e=null===(t=this.queryResult.pageInfo)||void 0===t?void 0:t.hasNextPage)&&void 0!==e&&e;yield this.finish()}))}finish(){return __awaiter(this,void 0,void 0,(function*(){this.context.logger.info("Batch process completed.")}))}fetchNextPage(){return __awaiter(this,void 0,void 0,(function*(){var t,e,i;switch(this.config.strategy){case pagination_strategy_1.PaginationStrategy.OFFSET:this.queryResult&&(null===(t=this.queryBuilder)||void 0===t||t.withOffset(this.queryResult.endOffset+1));break;case pagination_strategy_1.PaginationStrategy.CURSOR:this.queryResult&&(null===(e=this.queryBuilder)||void 0===e||e.withCursor(this.queryResult.endCursor));break;case pagination_strategy_1.PaginationStrategy.NONE:default:null===(i=this.queryBuilder)||void 0===i||i.withFilter(`LastModifiedDate < ${this.startTime.toISOString()}`)}return this.queryBuilder.execute()}))}isMaxBatchesReached(t){return!!this.config.maxBatches&&t>=this.config.maxBatches}delay(t){return __awaiter(this,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}))}}exports.GraphBatch=GraphBatch;
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(t,e,i,r){return new(i||(i=Promise))((function(a,s){function n(t){try{o(r.next(t))}catch(t){s(t)}}function h(t){try{o(r.throw(t))}catch(t){s(t)}}function o(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(n,h)}o((r=r.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GraphBatch=void 0;const graph_batch_config_1=require("./configs/graph-batch-config"),pagination_strategy_1=require("./pagination-strategy");class GraphBatch{constructor(t,e){this.startTime=new Date,this.context=t,this.config=(0,graph_batch_config_1.initializeConfig)(e),this.startTime=new Date}run(){return __awaiter(this,void 0,void 0,(function*(){var t,e;if(this.queryBuilder=yield this.start(),!this.queryBuilder)throw new Error("Query builder was not defined in start().");this.queryBuilder.withLimit(this.config.batchSize);let i=0,r=!0;for(;r&&!this.isMaxBatchesReached(i)&&(this.queryResult=yield this.fetchNextPage(),this.queryResult.records&&0!==this.queryResult.records.length);)yield this.execute(this.queryResult.records),i++,this.config.delaySeconds&&!this.isMaxBatchesReached(i)&&(yield this.delay(1e3*this.config.delaySeconds)),r=null!==(e=null===(t=this.queryResult.pageInfo)||void 0===t?void 0:t.hasNextPage)&&void 0!==e&&e;yield this.finish()}))}finish(){return __awaiter(this,void 0,void 0,(function*(){this.context.logger.info("Batch process completed.")}))}fetchNextPage(){return __awaiter(this,void 0,void 0,(function*(){var t,e,i;switch(this.config.strategy){case pagination_strategy_1.PaginationStrategy.OFFSET:this.queryResult&&(null===(t=this.queryBuilder)||void 0===t||t.withOffset(this.queryResult.endOffset+1));break;case pagination_strategy_1.PaginationStrategy.CURSOR:this.queryResult&&(null===(e=this.queryBuilder)||void 0===e||e.withCursor(this.queryResult.endCursor));break;case pagination_strategy_1.PaginationStrategy.NONE:default:null===(i=this.queryBuilder)||void 0===i||i.withFilter(`LastModifiedDate < ${this.startTime.toISOString()}`)}return this.queryBuilder.execute()}))}isMaxBatchesReached(t){return!!this.config.maxBatches&&t>=this.config.maxBatches}delay(t){return __awaiter(this,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}))}}exports.GraphBatch=GraphBatch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skedulo/pulse-solution-services",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "A collection of services and utilities to support solution development on the Pulse platform.",
5
5
  "author": "Skedulo",
6
6
  "license": "MIT",