@skedulo/pulse-solution-services 0.0.14 → 0.0.15
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 +4 -0
- package/README.md +9 -1
- package/dist/clients/artifact-client.js +1 -1
- package/dist/clients/availability-api-client.js +1 -1
- package/dist/clients/base-client.js +1 -1
- package/dist/clients/config-features-client.js +1 -1
- package/dist/clients/config-template-client.js +1 -1
- package/dist/clients/config-var-client.js +1 -1
- package/dist/clients/files-api-client.js +1 -1
- package/dist/clients/geo-api-client.js +1 -1
- package/dist/clients/graphql-client.js +1 -1
- package/dist/clients/metadata-client.js +1 -1
- package/dist/clients/mobile-notification-client.js +1 -1
- package/dist/clients/org-preference-client.js +1 -1
- package/dist/clients/vocabulary-client.js +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/logging/decorators/log-method.js +1 -1
- package/dist/monitoring/decorators/monitor-call.js +1 -1
- package/dist/monitoring/monitoring-manager.js +1 -1
- package/dist/services/cache/cache-service.js +1 -1
- package/dist/services/cache/storage/config-var-cache-storage.js +1 -1
- package/dist/services/cache/storage/in-memory-cache-storage.js +1 -1
- package/dist/services/geoservice.js +1 -1
- package/dist/services/graph-batch/graph-batch.js +1 -1
- package/dist/services/graph-batch/unique-graph-batch.js +1 -1
- package/dist/services/graphql/graphql-service.js +1 -1
- package/dist/services/lock-service.js +1 -1
- package/dist/services/metadata-service.js +1 -1
- package/dist/services/resource-availability/builder/data-service.js +1 -1
- package/dist/services/resource-availability/builder/resource-availability-service.js +1 -1
- package/dist/services/resource-availability/builder/resource-builder.js +1 -1
- package/package.json +2 -2
- package/yarn.lock +517 -642
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -187,7 +187,15 @@ const updatedVocabularyItem = await context.vocabularyClient.updateVocabularyIte
|
|
|
187
187
|
#### GraphQL Client
|
|
188
188
|
Executes GraphQL queries and mutations against `/graphql/graphql`.
|
|
189
189
|
```javascript
|
|
190
|
+
// execute final query string
|
|
190
191
|
const queryResult = await context.graphqlClient.execute(queryString, {readOnly: true});
|
|
192
|
+
|
|
193
|
+
// using query string with variables
|
|
194
|
+
const graphQLRequest: GraphQLRequest = {
|
|
195
|
+
query: queryString,
|
|
196
|
+
variables: {}
|
|
197
|
+
}
|
|
198
|
+
const queryUsingVariablesResult = await context.graphqlClient.execute(graphQLRequest, {readOnly: true});
|
|
191
199
|
```
|
|
192
200
|
|
|
193
201
|
#### Config Variable Client
|
|
@@ -536,7 +544,7 @@ const updateResult = await context.graphqlService.mutate({
|
|
|
536
544
|
operation: GraphqlOperations.UPDATE,
|
|
537
545
|
operationName: 'updateResources',
|
|
538
546
|
records: recordsToUpdate,
|
|
539
|
-
bulkOperation: true // optional
|
|
547
|
+
bulkOperation: true, // optional
|
|
540
548
|
suppressChangeEvents: true // optional
|
|
541
549
|
});
|
|
542
550
|
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __decorate=this&&this.__decorate||function(t,e,n
|
|
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 s=t.length-1;s>=0;s--)(i=t[s])&&(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)};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,a={}){super(t,a),this.artifactType=e,this.baseEndpoint=`artifacts/${this.artifactType}`}async list(){return this._performRequest({endpoint:this.baseEndpoint})}async get(t={}){return this._performRequest({endpoint:this.buildEndpoint(t)})}async create(t,e){return this._performRequest({method:constants_1.HttpMethod.POST,endpoint:this.buildEndpoint(t),body:e})}async update(t,e){return this._performRequest({method:constants_1.HttpMethod.PUT,endpoint:this.buildEndpoint(t),body:e})}async delete(t){await this._performRequest({method:constants_1.HttpMethod.DELETE,endpoint:this.buildEndpoint(t)})}buildEndpoint(t){const{objectName:e,viewTypeName:a,name:n,scope:i}=t;let o=this.baseEndpoint;return e&&(o+=`/${e}`),a&&(o+=`/${a}`),n&&(o+=`/${n}`),i&&(o+=`/${i}`),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 __decorate=this&&this.__decorate||function(e,t,i,
|
|
1
|
+
"use strict";var __decorate=this&&this.__decorate||function(e,t,i,a){var r,n=arguments.length,o=n<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,a);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>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)};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{async fetchAvailability(e){var t,i,a,r;if(!e.resourceIds.length)throw new Error("At least one resource ID must be provided.");const n={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===(a=e.entries)||void 0===a?void 0:a.toString())&&void 0!==r?r:"true"};return await this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.AVAILABILITY.SIMPLE,queryParams:n})}}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,
|
|
1
|
+
"use strict";var __decorate=this&&this.__decorate||function(e,t,r,o){var n,s=arguments.length,a=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,o);else for(var i=e.length-1;i>=0;i--)(n=e[i])&&(a=(s<3?n(a):s>3?n(t,r,a):n(t,r))||a);return s>3&&a&&Object.defineProperty(t,r,a),a},__metadata=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};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}async performRequest({method:e="GET",endpoint:t,headers:r={},body:o,queryParams:n},s=this.executionOptions){return this._performRequest({method:e,endpoint:t,headers:r,body:o,queryParams:n},s)}async _performRequest({method:e="GET",endpoint:t,headers:r={},body:o,queryParams:n},s=this.executionOptions){try{const a=Object.assign(Object.assign({},this.getHeaders(s)),r),i=this.buildUrl(t,n),c=await fetch(i,{method:e,headers:a,body:o&&"GET"!==e?JSON.stringify(o):void 0});let d;const u=c.headers.get("content-type");if(u&&u.includes("application/json")?(d=await c.json(),d.result&&(d=d.result)):d=await c.text(),!c.ok)throw new Error(`HTTP error! Status: ${c.status}. Response: ${JSON.stringify(d)}`);return this.handleResponseData(d),d}catch(e){throw this.handleException(e),e}}handleResponseData(e){}getHeaders(e){var t,r;const o={Authorization:`Bearer ${this.config.apiToken}`,"Content-Type":"application/json"},n=e.requestSource||(null===(t=this.executionOptions)||void 0===t?void 0:t.requestSource),s=e.userAgent||(null===(r=this.executionOptions)||void 0===r?void 0:r.userAgent);return n&&(o[request_header_constants_1.REQUEST_HEADERS.X_SKEDULO_SOURCE]=n),s&&(o[request_header_constants_1.REQUEST_HEADERS.USER_AGENT]=s),o}buildUrl(e,t){const r=e.startsWith("http")?new URL(e):new URL(`${this.config.apiServer}/${e}`);return t&&Object.entries(t).forEach((([e,t])=>{r.searchParams.append(e,t)})),r.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 __decorate=this&&this.__decorate||function(t,
|
|
1
|
+
"use strict";var __decorate=this&&this.__decorate||function(e,t,n,a){var o,r=arguments.length,i=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,a);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(r<3?o(i):r>3?o(t,n,i):o(t,n))||i);return r>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)};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{async get(){return await this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_FEATURES.GET})}async update(e,t){return await 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(e),body:t})}}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 __decorate=this&&this.__decorate||function(t,e,n
|
|
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 _=t.length-1;_>=0;_--)(o=t[_])&&(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)};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{async get(t){return await this._performRequest({endpoint:`${constants_1.TENANT_ENDPOINTS.CONFIG_TEMPLATE.GET_TEMPLATES(t)}`})}async getTemmplateValues(t){return await this._performRequest({endpoint:`${constants_1.TENANT_ENDPOINTS.CONFIG_TEMPLATE.GET_VALUES(t)}`})}async upsertTemplateValues(t,e){return this._performRequest({method:constants_1.HttpMethod.PUT,endpoint:`${constants_1.TENANT_ENDPOINTS.CONFIG_TEMPLATE.UPDATE_VALUES(t)}`,body:e})}async delete(t){return await this._performRequest({method:constants_1.HttpMethod.DELETE,endpoint:`${constants_1.TENANT_ENDPOINTS.CONFIG_TEMPLATE.DELETE(t)}`})}async create(t){return await 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 __decorate=this&&this.__decorate||function(t,e,n
|
|
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 s=t.length-1;s>=0;s--)(o=t[s])&&(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)};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{async create(t){return await this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_VAR.CREATE,body:t})}async get(t){return await this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_VAR.GET(t)})}async update(t){const e=t.key||"";delete t.key;const a={};return void 0!==t.value&&(a.value=t.value),void 0!==t.description&&(a.description=t.description),void 0!==t.expiryDate&&(a.expiryDate=t.expiryDate),void 0!==t.status&&(a.status=t.status),await this._performRequest({method:constants_1.HttpMethod.PATCH,endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_VAR.UPDATE(e),body:a})}async upsert(t){try{return await this.update(Object.assign({},t))}catch(e){return await this.create(t)}}async search(t){return await this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.CONFIG_VAR.SEARCH,body:{pageSize:t&&t<1e3?t:1e3}})}async delete(t){return await 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 __decorate=this&&this.__decorate||function(t,e,n,a){var
|
|
1
|
+
"use strict";var __decorate=this&&this.__decorate||function(t,e,n,a){var o,r=arguments.length,s=r<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,a);else for(var i=t.length-1;i>=0;i--)(o=t[i])&&(s=(r<3?o(s):r>3?o(e,n,s):o(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s},__metadata=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FilesAPIClient=void 0;const constants_1=require("../constants"),monitor_call_1=require("../monitoring/decorators/monitor-call"),base_client_1=require("./base-client");class FilesAPIClient extends base_client_1.BaseClient{async getAvatar(t){const{userIds:e,sizeHint:n}=t,a={user_ids:e.join(",")};return n&&(a.size_hint=n),this._performRequest({method:constants_1.HttpMethod.GET,endpoint:constants_1.TENANT_ENDPOINTS.FILES.AVATAR,queryParams:a})}async getAttachments(t){return this._performRequest({method:constants_1.HttpMethod.GET,endpoint:constants_1.TENANT_ENDPOINTS.FILES.ATTACHMENTS(t)})}}exports.FilesAPIClient=FilesAPIClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],FilesAPIClient.prototype,"getAvatar",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String]),__metadata("design:returntype",Promise)],FilesAPIClient.prototype,"getAttachments",null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __decorate=this&&this.__decorate||function(t,e,o,n){var a,
|
|
1
|
+
"use strict";var __decorate=this&&this.__decorate||function(t,e,o,n){var a,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,n);else for(var i=t.length-1;i>=0;i--)(a=t[i])&&(s=(r<3?a(s):r>3?a(e,o,s):a(e,o))||s);return r>3&&s&&Object.defineProperty(e,o,s),s},__metadata=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)};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{async getDistanceMatrix(t){return this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.DISTANCE_MATRIX,body:t})}async getDirections(t){return this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.DIRECTIONS,body:t})}async geocodeAddress(t){return this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.GEOCODE,body:t})}async autocompleteAddress(t){return this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.AUTOCOMPLETE,body:t})}async getPlaceDetails(t){return this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.PLACE,body:t})}async getTimezone(t){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 __decorate=this&&this.__decorate||function(t,
|
|
1
|
+
"use strict";var __decorate=this&&this.__decorate||function(e,t,r,a){var n,o=arguments.length,i=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,a);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i},__metadata=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};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{async execute(e,t={}){return await this._performRequest({method:http_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GRAPHQL.SINGLE,body:"string"==typeof e?{query:e}:{query:e.query,variables:e.variables},headers:t})}async executeBatch(e,t={}){return await this._performRequest({method:http_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GRAPHQL.BATCH,body:"string"==typeof e?{query:e}:{query:e.query,variables:e.variables},headers:t})}handleResponseData(e){if(!e.data&&e.errors)throw new Error(`GraphQL error: ${JSON.stringify(e.errors)}`)}}exports.GraphQLClient=GraphQLClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object,Object]),__metadata("design:returntype",Promise)],GraphQLClient.prototype,"execute",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object,Object]),__metadata("design:returntype",Promise)],GraphQLClient.prototype,"executeBatch",null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __decorate=this&&this.__decorate||function(t,e,a,n){var
|
|
1
|
+
"use strict";var __decorate=this&&this.__decorate||function(t,e,a,n){var r,o=arguments.length,i=o<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--)(r=t[c])&&(i=(o<3?r(i):o>3?r(e,a,i):r(e,a))||i);return o>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)};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{async fetchAllMetadata(){return await this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.METADATA.ALL})}async fetchObjectMetadata(t){return await 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 __decorate=this&&this.__decorate||function(t,e,o
|
|
1
|
+
"use strict";var __decorate=this&&this.__decorate||function(t,e,a,o){var n,i=arguments.length,s=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,a):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,a,o);else for(var r=t.length-1;r>=0;r--)(n=t[r])&&(s=(i<3?n(s):i>3?n(e,a,s):n(e,a))||s);return i>3&&s&&Object.defineProperty(e,a,s),s},__metadata=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)};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{async getTemplates(){return await this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.GET_TEMPLATES})}async deleteTemplate(t,e){await this._performRequest({method:constants_1.HttpMethod.DELETE,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.DELETE_TEMPLATE(t,e)})}async setTemplate(t,e,a){await this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.SET_TEMPLATE(t,e),body:{template:a}})}async dispatchResources(t){return await this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.DISPATCH,body:t})}async notifyAllocatedResources(t){return await this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.NOTIFY,body:t})}async notifyJobCancellation(t){return await this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.NOTIFY_CANCEL,body:t})}async sendOneOffMessage(t){return await this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.ONE_OFF,body:t})}async sendSms(t){return await this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.NOTIFICATIONS.SEND_SMS,body:t})}async requestSmsConfirmation(t){return await 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 __decorate=this&&this.__decorate||function(e,t,n
|
|
1
|
+
"use strict";var __decorate=this&&this.__decorate||function(e,t,r,n){var a,o=arguments.length,i=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(i=(o<3?a(i):o>3?a(t,r,i):a(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i},__metadata=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};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{async get(){return await this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.ORG_PREFERENCE.GET})}async deploy(e){return await 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 __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)}
|
|
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)};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{async getVocabularyItems(t,e){return await this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.VOCABULARY.GET_ITEMS(t,e)})}async addVocabularyItem(t,e,a){return await this._performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.VOCABULARY.ADD_ITEM(t,e),body:a})}async updateVocabularyItem(t,e,a,n){return await 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);
|
package/dist/index.d.ts
CHANGED
|
@@ -596,6 +596,10 @@ export interface MutationResult {
|
|
|
596
596
|
};
|
|
597
597
|
};
|
|
598
598
|
}
|
|
599
|
+
export interface GraphQLRequest {
|
|
600
|
+
query: string;
|
|
601
|
+
variables: object;
|
|
602
|
+
}
|
|
599
603
|
/**
|
|
600
604
|
* A client for executing GraphQL queries and mutations.
|
|
601
605
|
* Extends the BaseClient to interact with the GraphQL API.
|
|
@@ -603,20 +607,20 @@ export interface MutationResult {
|
|
|
603
607
|
export declare class GraphQLClient extends BaseClient {
|
|
604
608
|
/**
|
|
605
609
|
* Executes a GraphQL query or mutation.
|
|
606
|
-
* @param {string} graphqlQuery - The GraphQL query or mutation string.
|
|
610
|
+
* @param {string | GraphQLRequest} graphqlQuery - The GraphQL query or mutation string.
|
|
607
611
|
* @param {Record<string, string>} headers - Additional headers to include in the request.
|
|
608
612
|
* @returns {Promise<GraphQlResponse>} - The response from the GraphQL API.
|
|
609
613
|
* @throws {Error} - If the request fails or if there are errors in the response.
|
|
610
614
|
*/
|
|
611
|
-
execute(graphqlQuery: string, headers?: Record<string, string>): Promise<GraphQlResponse>;
|
|
615
|
+
execute(graphqlQuery: string | GraphQLRequest, headers?: Record<string, string>): Promise<GraphQlResponse>;
|
|
612
616
|
/**
|
|
613
617
|
* Executes a GraphQL query or mutation.
|
|
614
|
-
* @param {string} graphqlQuery - The GraphQL
|
|
618
|
+
* @param {string | GraphQLRequest} graphqlQuery - The GraphQL query or mutation string.
|
|
615
619
|
* @param {Record<string, string>} headers - Additional headers to include in the request.
|
|
616
620
|
* @returns {Promise<GraphQlResponse>} - The response from the GraphQL API.
|
|
617
621
|
* @throws {Error} - If the request fails or if there are errors in the response.
|
|
618
622
|
*/
|
|
619
|
-
executeBatch(graphqlQuery: string, headers?: Record<string, string>): Promise<GraphQlResponse>;
|
|
623
|
+
executeBatch(graphqlQuery: string | GraphQLRequest, headers?: Record<string, string>): Promise<GraphQlResponse>;
|
|
620
624
|
protected handleResponseData(responseData: any): void;
|
|
621
625
|
}
|
|
622
626
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LogMethod=LogMethod;const logging_utils_1=require("../logging-utils"),PULSE_SOLUTION_NAMESPACE="PSS",COLORS={RESET:"[0m",GREEN:"[32m",YELLOW:"[33m",RED:"[31m",CYAN:"[36m",MAGENTA:"[35m"};function LogMethod(t=PULSE_SOLUTION_NAMESPACE){return function(e,n,o){const r=o.value,E=process.env.LOG_NAMESPACE||"";if(!E)return o;const O=parseInt(process.env.LOG_ENTRY_MAX_LENGTH||"120",10),s=E===t||"ALL"===E.toUpperCase();function S(t,e,n,o,r){const E=(new Date).toISOString(),s="ERROR"===o?COLORS.RED:"INPUT"===o?COLORS.CYAN:COLORS.MAGENTA;console.log(`${COLORS.GREEN}[${t.toUpperCase()}]${COLORS.RESET} | ${COLORS.YELLOW}${E}${COLORS.RESET} | ${COLORS.GREEN}${PULSE_SOLUTION_NAMESPACE}${COLORS.RESET} | ${e.constructor.name} | ${n} - ${s}${o}${COLORS.RESET}: ${function(t){if(!t)return"";const e=(0,logging_utils_1.maskSensitiveData)(t);return e.length>O?`${e.substring(0,O-3)}...`:e}(r)}`)}return o.value=async function(...t){s&&S("info",this,n.toString(),"INPUT",t);try{const e=await Promise.resolve(r.apply(this,t));return s&&S("info",this,n.toString(),"OUTPUT",e),e}catch(t){throw S("error",this,n.toString(),"ERROR",t.message||t),t}},o}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MonitorCall=MonitorCall;const monitoring_registry_1=require("../monitoring-registry");function MonitorCall(r){return function(t,n,o){const e=o.value;return o.value=async function(...o){const i=r||`${t.constructor.name}.${n}`;return(0,monitoring_registry_1.getGlobalMonitorManager)().measure(i,(async()=>e.apply(this,o)))},o}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __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}async measure(t,e){this.incrementTotalCallsCount(),this.incrementMethodCount(t),this.trackConcurrentRequest(1,t);const s=Date.now();let o;try{o=await e()}finally{this.trackConcurrentRequest(-1,t)}const i=Date.now()-s;return this.trackExecutionTime(t,i),this.checkMethodDuration(t,i),o}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 s=`methodCallLimit:${t}`,o=this.thresholds.maxMethodCalls;o&&this.methodCallCounts[t]>o&&this.handleViolation(s,`Method [${t}] call limit exceeded: ${this.methodCallCounts[t]} (Allowed: ${o})`)}trackExecutionTime(t,e){this.methodExecutionTimes[t]||(this.methodExecutionTimes[t]={totalTime:0,count:0,min:Number.MAX_VALUE,max:0});const s=this.methodExecutionTimes[t];s.totalTime+=e,s.count+=1,s.min=Math.min(s.min,e),s.max=Math.max(s.max,e)}checkMethodDuration(t,e){const s=this.thresholds.maxMethodExecutionTimeMs,o=`methodDurationLimit:${t}`;s&&e>s&&this.handleViolation(o,`Method [${t}] exceeded duration limit: ${e}ms (Allowed: ${s}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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __decorate=this&&this.__decorate||function(e,t,r
|
|
1
|
+
"use strict";var __decorate=this&&this.__decorate||function(e,t,a,r){var i,n=arguments.length,s=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,a):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,a,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(n<3?i(s):n>3?i(t,a,s):i(t,a))||s);return n>3&&s&&Object.defineProperty(t,a,s),s},__metadata=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CacheService=void 0;const logging_1=require("../../logging"),logger_1=__importDefault(require("../../logging/logger")),KEY_PREFIX="Z_CACHE_",DEFAULT_TTL=36e5;class CacheService{constructor(e){this.storage=e}setSecondaryCache(e){this.secondaryCache=e}async get(e,t){e=this.addPrefix(e);const a=await this.storage.get(e);if(a)try{const t=JSON.parse(a);return t.expiresAt&&Date.now()>t.expiresAt?(await this.delete(e),null):this.deserialize(t)}catch(e){return logger_1.default.error("Cache deserialization failed:",e),null}if((null==t?void 0:t.useSecondaryCache)&&this.secondaryCache){const a=await this.secondaryCache.get(e,t);return null!==a&&await this.set(e,a,{ttl:null==t?void 0:t.ttl}),a}return null}async set(e,t,a){var r;e=this.addPrefix(e);const i={type:t instanceof Date?"date":typeof t,value:t,expiresAt:Date.now()+(null!==(r=null==a?void 0:a.ttl)&&void 0!==r?r:36e5)},n=JSON.stringify(i);await this.storage.set(e,n),(null==a?void 0:a.useSecondaryCache)&&this.secondaryCache&&await this.secondaryCache.set(e,t,a)}async delete(e){e=this.addPrefix(e),await this.storage.delete(e)}async clear(){await this.storage.clear()}addPrefix(e){return e.startsWith("Z_CACHE_")?e:"Z_CACHE_"+e}deserialize(e){switch(e.type){case"number":return Number(e.value);case"boolean":return Boolean(e.value);case"object":return e.value;case"date":case"datetime":const t=new Date(e.value);return isNaN(t.getTime())?(logger_1.default.error(`Invalid ${e.type} string:`,e.value),null):t;default:return String(e.value)}}}exports.CacheService=CacheService,__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String,Object]),__metadata("design:returntype",Promise)],CacheService.prototype,"get",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String,Object,Object]),__metadata("design:returntype",Promise)],CacheService.prototype,"set",null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConfigVarCacheStorage=void 0;const config_var_constants_1=require("../../../constants/config-var-constants");class ConfigVarCacheStorage{constructor(e){this.configVarClient=e}async set(e,t){try{await this.configVarClient.create({key:e,value:t,configType:config_var_constants_1.ConfigVariableType.PLAIN_TEXT})}catch(a){await this.configVarClient.update({key:e,value:t,configType:config_var_constants_1.ConfigVariableType.PLAIN_TEXT})}}async get(e){var t;try{const t=await this.configVarClient.get(e);if(t)return t.value}catch(e){if(null===(t=null==e?void 0:e.message)||void 0===t?void 0:t.includes("not_found"))return null;throw e}return null}async delete(e){await this.configVarClient.delete(e)}async clear(){throw new Error("Clear operation is not supported by ConfigVarCacheStorage")}}exports.ConfigVarCacheStorage=ConfigVarCacheStorage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.InMemoryCacheStorage=void 0;class InMemoryCacheStorage{constructor(){this.cache=new Map}async set(e,c){this.cache.set(e,c)}async get(e){const c=this.cache.get(e);return c||null}async delete(e){this.cache.delete(e)}async clear(){this.cache.clear()}}exports.InMemoryCacheStorage=InMemoryCacheStorage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GeoService=void 0;const uuid_1=require("uuid");class GeoService{constructor(e){this.sessionId="",this.geoAPIClient=e,this.sessionId=this.generateNewSessionId()}async getDistanceMatrix(e,t){const s=e.map((e=>({lat:parseFloat(this.stripTrailingZeros(e.lat)),lng:parseFloat(this.stripTrailingZeros(e.lng))}))),i=t.map((e=>({lat:parseFloat(this.stripTrailingZeros(e.lat)),lng:parseFloat(this.stripTrailingZeros(e.lng))}))),r=await this.geoAPIClient.getDistanceMatrix({origins:s,destinations:i});if(!r||!r.matrix||0===r.matrix.length)throw new Error("Failed to retrieve distance matrix data");const n=new Map;for(let o=0;o<e.length;o++)for(let e=0;e<t.length;e++){const t=this.createKey(s[o],i[e]),a=r.matrix[o][e];n.set(t,a)}return n}async getAddressSuggestions(e,t=1){const s=e.sessionId||this.sessionId;e.sessionId||(e.sessionId=this.sessionId);const i=await this.geoAPIClient.autocompleteAddress(e);if(0===i.predictions.length)return null;const r=i.predictions.slice(0,t);return Promise.all(r.map((e=>this.geoAPIClient.getPlaceDetails({placeId:e.placeId,sessionId:s}))))}async getTimezone(e){return(await this.geoAPIClient.getTimezone(e)).timeZoneId}generateNewSessionId(){return(0,uuid_1.v4)()}stripTrailingZeros(e){return parseFloat(e.toFixed(8)).toString()}createKey(e,t){return`${this.stripTrailingZeros(e.lat)},${this.stripTrailingZeros(e.lng)}-${this.stripTrailingZeros(t.lat)},${this.stripTrailingZeros(t.lng)}`}}exports.GeoService=GeoService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";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}async run(){var t,e;if(this.queryBuilder=await this.start(),!this.queryBuilder)throw new Error("Query builder was not defined in start().");this.queryBuilder.withLimit(this.config.batchSize);let i=0,s=!0;for(;s&&!this.isMaxBatchesReached(i)&&(this.queryResult=await this.fetchNextPage(),this.queryResult.records&&0!==this.queryResult.records.length);)await this.execute(this.queryResult.records),i++,this.config.delaySeconds&&!this.isMaxBatchesReached(i)&&await this.delay(1e3*this.config.delaySeconds),s=null!==(e=null===(t=this.queryResult.pageInfo)||void 0===t?void 0:t.hasNextPage)&&void 0!==e&&e;await this.finish()}async finish(){this.context.logger.info("Batch process completed.")}async fetchNextPage(){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}async delay(t){return new Promise((e=>setTimeout(e,t)))}}exports.GraphBatch=GraphBatch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.UniqueGraphBatch=void 0;const logger_1=__importDefault(require("../../logging/logger")),graph_batch_1=require("./graph-batch");class UniqueGraphBatch extends graph_batch_1.GraphBatch{constructor(e,t){super(e,t),this.name=(null==t?void 0:t.name)||this.constructor.name,this.name=this.name.toUpperCase().replace(/[^A-Z0-9]/g,"_"),this.lockTtl=(null==t?void 0:t.lockTtl)||96e4}async run(){const e={name:this.name,ttl:this.lockTtl,description:`Lock for batch process: ${this.name}`};try{if(!await this.context.lockService.acquireLock(e))return void logger_1.default.error(`A batch with name '${this.name}' is already running.`);await super.run()}catch(e){logger_1.default.error(`Error running batch with name '${this.name}': ${e.message}`)}finally{await this.context.lockService.releaseLock(this.name)}}async start(){throw new Error("Subclasses must implement the 'start' method.")}async execute(e){throw new Error("Subclasses must implement the 'execute' method.")}async finish(){await super.finish()}}exports.UniqueGraphBatch=UniqueGraphBatch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __decorate=this&&this.__decorate||function(e,t,a,r){var o,n=arguments.length,
|
|
1
|
+
"use strict";var __decorate=this&&this.__decorate||function(e,t,a,r){var o,n=arguments.length,s=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,a):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,a,r);else for(var i=e.length-1;i>=0;i--)(o=e[i])&&(s=(n<3?o(s):n>3?o(t,a,s):o(t,a))||s);return n>3&&s&&Object.defineProperty(t,a,s),s},__metadata=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GraphQLService=void 0;const constants_1=require("../../constants"),request_header_constants_1=require("../../core/request-header-constants"),logging_1=require("../../logging"),queries_1=require("./queries");class GraphQLService{constructor(e){this.client=e}async query(e){var t,a,r,o,n,s,i,d,_,c,u,l;e.objectName=this.getQueryName(e.objectName);const p=(0,queries_1.FETCH_RECORDS_QUERY)(e),g=this.getQueryHeaders(e),h=await this.client.execute(p,g),m={records:(null===(a=null===(t=null==h?void 0:h.data)||void 0===t?void 0:t[e.objectName])||void 0===a?void 0:a.edges.map((e=>e.node)))||[],totalCount:(null===(o=null===(r=null==h?void 0:h.data)||void 0===r?void 0:r[e.objectName])||void 0===o?void 0:o.totalCount)||0,pageInfo:(null===(s=null===(n=null==h?void 0:h.data)||void 0===n?void 0:n[e.objectName])||void 0===s?void 0:s.pageInfo)||{}};if(m.records.length>0){const t=(null===(_=null===(d=null===(i=null==h?void 0:h.data)||void 0===i?void 0:i[e.objectName])||void 0===d?void 0:d.edges)||void 0===_?void 0:_.map((e=>e.offset)))||[],a=(null===(l=null===(u=null===(c=null==h?void 0:h.data)||void 0===c?void 0:c[e.objectName])||void 0===u?void 0:u.edges)||void 0===l?void 0:l.map((e=>e.cursor)))||[];m.endOffset=t[t.length-1],m.endCursor=a[a.length-1]}return m}async mutate(e){if(!e.records||0===e.records.length)return Promise.resolve({message:"No records to process"});let t="";switch(e.operation){case constants_1.GraphqlOperations.DELETE:t=(0,queries_1.DELETE_OBJECTS_MUTATION)(e);break;case constants_1.GraphqlOperations.UPDATE:case constants_1.GraphqlOperations.INSERT:t=(0,queries_1.UPSERT_OBJECTS_MUTATION)(e);break;default:throw new Error(`Invalid operation: ${e.operation}`)}const a=this.getMutationHeaders(e);return await this.client.execute(t,a)}async delete(e){return e.operation=constants_1.GraphqlOperations.DELETE,this.mutate(e)}async update(e){return e.operation=constants_1.GraphqlOperations.UPDATE,this.mutate(e)}async insert(e){return e.operation=constants_1.GraphqlOperations.INSERT,this.mutate(e)}extractJobUIDs(e){var t;return(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.schema)?Object.values(e.data.schema):[]}getQueryName(e){return e.charAt(0).toLowerCase()+e.slice(1)}getQueryHeaders(e){const t=this.getOperationHeader(e.operationName);return e.readOnly&&(t[request_header_constants_1.REQUEST_HEADERS.X_SKEDULO_READ_ONLY]="true"),t}getMutationHeaders(e){const t=this.getOperationHeader(e.operationName);return e.bulkOperation&&(t[request_header_constants_1.REQUEST_HEADERS.X_SKEDULO_BULK_OPERATION]="true"),e.suppressChangeEvents&&(t[request_header_constants_1.REQUEST_HEADERS.X_SKEDULO_SUPPRESS_CHANGE_EVENTS]="true"),t}getOperationHeader(e){return{[request_header_constants_1.REQUEST_HEADERS.X_GRAPHQL_OPERATION]:e}}}exports.GraphQLService=GraphQLService,__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"query",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"mutate",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"delete",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"update",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"insert",null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __decorate=this&&this.__decorate||function(e,t,r
|
|
1
|
+
"use strict";var __decorate=this&&this.__decorate||function(e,t,a,r){var i,o=arguments.length,c=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,a):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,a,r);else for(var n=e.length-1;n>=0;n--)(i=e[n])&&(c=(o<3?i(c):o>3?i(t,a,c):i(t,a))||c);return o>3&&c&&Object.defineProperty(t,a,c),c},__metadata=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.LockService=void 0;const logging_1=require("../logging"),logger_1=__importDefault(require("../logging/logger")),KEY_PREFIX="Z_LOCK_";class LockService{constructor(e){this.configVarClient=e}async acquireLock(e){const t="Z_LOCK_"+e.name,a=new Date(Date.now()+e.ttl).toISOString();try{let r=null;try{r=await this.configVarClient.get(t)}catch(e){}if(r){if(r.expiryDate&&new Date<new Date(r.expiryDate))return!1;await this.configVarClient.delete(t)}return await this.configVarClient.create({key:t,value:e.name,configType:"plain-text",description:e.description,expiryDate:a}),!0}catch(t){return logger_1.default.error(`Failed to acquire lock: ${e.name}`),!1}}async releaseLock(e){const t="Z_LOCK_"+e;try{let e=null;try{e=await this.configVarClient.get(t)}catch(e){}e&&await this.configVarClient.delete(t)}catch(t){logger_1.default.error(`Failed to release lock: ${e}`)}}}exports.LockService=LockService,__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],LockService.prototype,"acquireLock",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[String]),__metadata("design:returntype",Promise)],LockService.prototype,"releaseLock",null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MetadataService=void 0;class MetadataService{constructor(t){this.client=t}async getObjectMetadata(t){const e=await this.client.fetchAllMetadata(),a={};for(const c of t){const t=e.find((t=>t.name===c));if(!t)throw new Error(`Metadata mapping not found for object: ${c}`);a[c]=await this.client.fetchObjectMetadata(t.mapping)}return a}getPicklistValues(t){const e=t.fields.filter((t=>"picklist"===t.type)),a={};for(const t of e)a[t.name]=t.values.map((t=>t.value));return a}}exports.MetadataService=MetadataService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DataService=void 0;const tenant_objects_1=require("../../../core/tenant-objects"),graphql_1=require("../../graphql");class DataService{constructor(e){this.graphqlService=e}async getResources(e){const t=this.newQueryBuilder({objectName:tenant_objects_1.TenantObjects.Resources.Name,operationName:"fetchResourcesWithAvailabilities"});t.withFields(tenant_objects_1.TenantObjects.Resources.Fields).withFilter("IsActive == true"),t.withParentQuery("PrimaryRegion").withFields(tenant_objects_1.TenantObjects.Regions.Fields),e.resourceIds&&e.resourceIds.size>0?t.withFilter(`UID IN ${JSON.stringify(Array.from(e.resourceIds))}`):e.regionIds&&e.regionIds.size>0&&t.withFilter(`PrimaryRegionId IN [${Array.from(e.regionIds).map((e=>`'${e}'`)).join(",")}]`),e.useTag&&t.withChildQuery(tenant_objects_1.TenantObjects.ResourceTags.Name).withParentQuery("Tag").withFields(tenant_objects_1.TenantObjects.Tags.Fields),e.useActivity&&t.withChildQuery(tenant_objects_1.TenantObjects.Activities.Name).withFields(tenant_objects_1.TenantObjects.Activities.Fields),e.useAvailability&&t.withChildQuery(tenant_objects_1.TenantObjects.Availabilities.Name).withFields(tenant_objects_1.TenantObjects.Availabilities.Fields),e.useJobAllocation&&t.withChildQuery(tenant_objects_1.TenantObjects.JobAllocations.Name).withFields(tenant_objects_1.TenantObjects.JobAllocations.Fields).withFilter("Status NOTIN ['Deleted', 'Declined']").withParentQuery("Job").withFields(tenant_objects_1.TenantObjects.Jobs.Fields);return(await t.execute()).records}async getHolidays(e,t,i){const s={},n=t?t.toISOString().split("T")[0]:null,a=i?i.toISOString().split("T")[0]:null,r=this.newQueryBuilder({objectName:tenant_objects_1.TenantObjects.Holidays.Name,operationName:"fetchHolidays"});r.withFields(tenant_objects_1.TenantObjects.Holidays.Fields),r.withFilter("Global == true"),n&&r.withFilter(`EndDate >= ${n}`),a&&r.withFilter(`StartDate <= ${a}`);const o=await r.execute();if(s.GLOBAL=o.records||[],e&&e.length>0){const t=this.newQueryBuilder({objectName:tenant_objects_1.TenantObjects.Holidays.Name,operationName:"fetchHolidays"});t.withFields(tenant_objects_1.TenantObjects.Holidays.Fields),t.withChildQuery(tenant_objects_1.TenantObjects.HolidayRegions.Name).withFields(tenant_objects_1.TenantObjects.HolidayRegions.Fields).withFilter(`RegionId IN [${e.map((e=>`'${e}'`)).join(",")}]`),n&&t.withFilter(`EndDate >= ${n}`),a&&t.withFilter(`StartDate <= ${a}`);const i=await t.execute();for(const e of i.records||[])for(const t of e.HolidayRegions||[]){const i=t.RegionId;s[i]||(s[i]=[]),s[i].push(e)}}return s}newQueryBuilder(e){const t=new graphql_1.GraphQLQueryBuilder(e);return t.setGraphqlService(this.graphqlService),t}}exports.DataService=DataService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ResourceAvailabilityService=void 0;class ResourceAvailabilityService{constructor(e){this.availabilityAPIClient=e}async getAvailabilityPatterns(e){const t=await this.availabilityAPIClient.fetchAvailability({resourceIds:Array.from(e.resourceIds||[]),start:e.startTime.toISOString(),end:e.endTime.toISOString(),mergedAvailabilities:!1,entries:!0}),i=new Map;return t.forEach((e=>{if(!e.entries)return;const t=e.entries.filter((e=>"pattern"===e.type)).map((e=>({id:`${e.start}_${e.end}`,name:`${e.name}(${e.type})`,start:e.start?new Date(e.start):new Date(0),finish:e.end?new Date(e.end):new Date(0),eventType:e.type})));i.set(e.resourceId,t)})),i}}exports.ResourceAvailabilityService=ResourceAvailabilityService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __decorate=this&&this.__decorate||function(e,t,i,a){var r
|
|
1
|
+
"use strict";var __decorate=this&&this.__decorate||function(e,t,i,a){var s,r=arguments.length,o=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,a);else for(var n=e.length-1;n>=0;n--)(s=e[n])&&(o=(r<3?s(o):r>3?s(t,i,o):s(t,i))||o);return r>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)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ResourceBuilder=void 0;const entity_factory_1=require("../../../core/entity-factory"),logging_1=require("../../../logging"),utils_1=require("../../../utils"),resource_query_param_1=require("./resource-query-param");class ResourceBuilder{constructor(e,t){this.dataService=e,this.availabilityService=t}async build(e){var t,i;if(!e)throw new Error("ResourceBuilder Error: queryParam is required");const a=[],s=await this.dataService.getResources(e);e.resourceIds&&0!==e.resourceIds.size||(e.resourceIds=new Set(s.map((e=>e.UID))));for(const t of s){const i=entity_factory_1.EntityFactory.createResource(t);a.push(i),e.useActivity&&this.loadActivityEvents(t,i),e.useAvailability&&this.loadAvailabilityEvents(t,i),e.useJobAllocation&&this.loadJobAllocationEvents(t,i),e.useResourceShift&&this.loadResourceShiftEvents(t,i),e.useHoliday&&this.loadHolidayEvents(i,e)}e.useAvailabilityPattern&&await this.loadAvailabilityPatterns(a,e);for(const s of a)e.mergeAvailability?s.availabilities=utils_1.DateTimeUtils.mergeEvents(s.availabilities):null===(t=s.availabilities)||void 0===t||t.sort(((e,t)=>e.start.getTime()-t.start.getTime())),e.mergeEvents?s.events=utils_1.DateTimeUtils.mergeEvents(s.events):null===(i=s.events)||void 0===i||i.sort(((e,t)=>e.start.getTime()-t.start.getTime()));return this.buildMore(a)}async loadAvailabilityPatterns(e,t){const i=await this.availabilityService.getAvailabilityPatterns(t);for(const t of e)t.availabilities.push(...i.get(t.id)||[])}loadActivityEvents(e,t){e.Activities&&t.events.push(...e.Activities.map((e=>({id:e.UID,name:e.Name,start:new Date(e.Start),finish:new Date(e.End),eventType:"activity"}))))}loadAvailabilityEvents(e,t){if(e.availabilities){const i=[],a=[];e.Availabilities.forEach((e=>{e.IsAvailable?i.push(entity_factory_1.EntityFactory.createBaseEvent(e)):a.push(entity_factory_1.EntityFactory.createBaseEvent(e))})),t.availabilities=i,t.events.push(...a)}}loadJobAllocationEvents(e,t){e.JobAllocations&&t.events.push(...e.JobAllocations.map((e=>({id:e.UID,name:e.Name,start:e.Start?new Date(e.Start):void 0,finish:e.End?new Date(e.End):void 0,eventType:"job_allocation"}))))}loadResourceShiftEvents(e,t){e.resourceShifts&&t.events.push(...e.resourceShifts.map((e=>({id:e.id,name:e.name,start:e.start?new Date(e.start):new Date(0),finish:e.finish?new Date(e.finish):new Date(0),eventType:"resource_shift"}))))}async loadHolidayEvents(e,t){const i=await this.dataService.getHolidays(Array.from(t.regionIds||[]),t.startTime,t.endTime),a=i.GLOBAL||[];i[e.regionId]&&a.push(...i[e.regionId]),a.forEach((i=>{let a=utils_1.DateTimeUtils.getStartOfDate(i.StartDate,e.timezone),s=utils_1.DateTimeUtils.getEndOfDate(i.EndDate,e.timezone);a<t.startTime&&(a=t.startTime),s>t.endTime&&(s=t.endTime),e.events.push({id:`${a.toISOString()}_${s.toISOString()}`,name:i.Name,start:a,finish:s,eventType:"holiday"})}))}buildMore(e){return e}}exports.ResourceBuilder=ResourceBuilder,__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[resource_query_param_1.ResourceQueryParam]),__metadata("design:returntype",Promise)],ResourceBuilder.prototype,"build",null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skedulo/pulse-solution-services",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
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",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"yarn.lock"
|
|
25
25
|
],
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@tsconfig/node18": "^18.2.
|
|
27
|
+
"@tsconfig/node18": "^18.2.4",
|
|
28
28
|
"@types/uuid": "^10.0.0",
|
|
29
29
|
"@typescript-eslint/eslint-plugin": "^8.11.0",
|
|
30
30
|
"@typescript-eslint/parser": "^8.11.0",
|