@skedulo/pulse-solution-services 0.0.18 → 0.0.19

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,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.0.19] - 2025-08-04
4
+ ### Fixed
5
+ - Fixed unique batch issue
6
+
3
7
  ## [v0.0.18] - 2025-07-16
4
8
  ### Update
5
9
  - Support upsert and status polling in artifact client
package/README.md CHANGED
@@ -23,7 +23,7 @@
23
23
  - [Batch Queries](#batch-queries)
24
24
  - [Update Data](#update-data)
25
25
  - [Upsert Data](#upsert-data)
26
- - [Batch mMtations](#batch-mutations)
26
+ - [Batch Mutations](#batch-mutations)
27
27
  - [Pagination](#pagination)
28
28
  - [Resource Service](#resource-service)
29
29
  - [Resource Builder](#resource-builder)
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,a){function o(t){try{s(i.next(t))}catch(t){a(t)}}function c(t){try{s(i.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,c)}s((i=i.apply(t,e||[])).next())}))},__importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};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(t,e){super(t,e),this.name=(null==e?void 0:e.name)||this.constructor.name,this.name=this.name.toUpperCase().replace(/[^A-Z0-9]/g,"_"),this.lockTtl=(null==e?void 0:e.lockTtl)||96e4}run(){const t=Object.create(null,{run:{get:()=>super.run}});return __awaiter(this,void 0,void 0,(function*(){const e={name:this.name,ttl:this.lockTtl,description:`Lock for batch process: ${this.name}`};try{if(!(yield this.context.lockService.acquireLock(e)))return void logger_1.default.error(`A batch with name '${this.name}' is already running.`);yield t.run.call(this)}catch(t){logger_1.default.error(`Error running batch with name '${this.name}': ${t.message}`)}finally{yield this.context.lockService.releaseLock(this.name)}}))}start(){return __awaiter(this,void 0,void 0,(function*(){throw new Error("Subclasses must implement the 'start' method.")}))}execute(t){return __awaiter(this,void 0,void 0,(function*(){throw new Error("Subclasses must implement the 'execute' method.")}))}finish(){const t=Object.create(null,{finish:{get:()=>super.finish}});return __awaiter(this,void 0,void 0,(function*(){yield t.finish.call(this)}))}}exports.UniqueGraphBatch=UniqueGraphBatch;
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,a){function o(t){try{s(i.next(t))}catch(t){a(t)}}function c(t){try{s(i.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,c)}s((i=i.apply(t,e||[])).next())}))},__importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};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(t,e){super(t,e),this.name=(null==e?void 0:e.name)||this.constructor.name,this.name=this.name.toUpperCase().replace(/[^A-Z0-9]/g,"_"),this.lockTtl=(null==e?void 0:e.lockTtl)||96e4}run(){const t=Object.create(null,{run:{get:()=>super.run}});return __awaiter(this,void 0,void 0,(function*(){const e={name:this.name,ttl:this.lockTtl,description:`Lock for batch process: ${this.name}`};try{if(!(yield this.context.lockService.acquireLock(e)))return void logger_1.default.error(`A batch with name '${this.name}' is already running.`);yield t.run.call(this)}catch(t){logger_1.default.error(`Error running batch with name '${this.name}': ${t.message}`)}yield this.context.lockService.releaseLock(this.name)}))}start(){return __awaiter(this,void 0,void 0,(function*(){throw new Error("Subclasses must implement the 'start' method.")}))}execute(t){return __awaiter(this,void 0,void 0,(function*(){throw new Error("Subclasses must implement the 'execute' method.")}))}finish(){const t=Object.create(null,{finish:{get:()=>super.finish}});return __awaiter(this,void 0,void 0,(function*(){yield t.finish.call(this)}))}}exports.UniqueGraphBatch=UniqueGraphBatch;
@@ -1 +1 @@
1
- "use strict";var __decorate=this&&this.__decorate||function(e,t,r,i){var o,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(a=(n<3?o(a):n>3?o(t,r,a):o(t,r))||a);return n>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)},__awaiter=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(o,n){function a(e){try{l(i.next(e))}catch(e){n(e)}}function c(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}l((i=i.apply(e,t||[])).next())}))},__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}acquireLock(e){return __awaiter(this,void 0,void 0,(function*(){const t="Z_LOCK_"+e.name,r=new Date(Date.now()+e.ttl).toISOString();try{let i=null;try{i=yield this.configVarClient.get(t)}catch(e){}if(i){if(i.expiryDate&&new Date<new Date(i.expiryDate))return!1;yield this.configVarClient.delete(t)}return yield this.configVarClient.create({key:t,value:e.name,configType:"plain-text",description:e.description,expiryDate:r}),!0}catch(t){return logger_1.default.error(`Failed to acquire lock: ${e.name}`),!1}}))}releaseLock(e){return __awaiter(this,void 0,void 0,(function*(){const t="Z_LOCK_"+e;try{let e=null;try{e=yield this.configVarClient.get(t)}catch(e){}e&&(yield 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
+ "use strict";var __decorate=this&&this.__decorate||function(e,t,i,r){var n,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,r);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(a=(o<3?n(a):o>3?n(t,i,a):n(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a},__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,r){return new(i||(i=Promise))((function(n,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function c(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,c)}l((r=r.apply(e,t||[])).next())}))},__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}acquireLock(e){return __awaiter(this,void 0,void 0,(function*(){const t="Z_LOCK_"+e.name,i=new Date(Date.now()+e.ttl).toISOString();try{let r=null;try{r=yield this.configVarClient.get(t)}catch(e){}if(r){if(r.expiryDate&&new Date<new Date(r.expiryDate))return!1;yield this.configVarClient.delete(t)}return yield this.configVarClient.create({key:t,value:e.name,configType:"plain-text",description:e.description,expiryDate:i}),!0}catch(t){return logger_1.default.info(`Failed to acquire lock: ${e.name}`),!1}}))}releaseLock(e){return __awaiter(this,void 0,void 0,(function*(){const t="Z_LOCK_"+e;try{let e=null;try{e=yield this.configVarClient.get(t)}catch(e){}e&&(yield this.configVarClient.delete(t))}catch(t){logger_1.default.info(`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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skedulo/pulse-solution-services",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
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",