@transai/connector-runner-gpms 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## 0.12.0 (2026-04-10)
2
+
3
+ ### 🚀 Features
4
+
5
+ - gpms handle api key header ([a959f10e1](https://github.com/xip-online-applications/xod-core/commit/a959f10e1))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - Youri Lefers @yourilefers
10
+
11
+ ## 0.11.0 (2026-04-09)
12
+
13
+ This was a version bump only for connector-runner-gpms to align it with other projects, there were no code changes.
14
+
1
15
  ## 0.10.1 (2026-04-03)
2
16
 
3
17
  ### 🧱 Updated Dependencies
package/index.cjs CHANGED
@@ -144,7 +144,7 @@ Please see the 3.x to 4.x migration guide for details on how to update your app.
144
144
  </Users>
145
145
  {{/if}}
146
146
  </Client>
147
- `;#e;#a;constructor(e,t){this.#e=e,this.#a=t}async execute(e,t,n){let i=this.#e.templating.compile(t.config.template??this.clientTemplate)({inputs:e}).trim();if(!n){let r=Buffer.from(i).toString("base64");await this.#a.post("/CreateClient",r,{headers:{"Content-Type":"text/plain"}}).catch(o=>{this.#e.logger.warn(`Failed to post client: ${o.error??String(o)}`)})}return{client:i}}};var So=Dt(require("node:path"));var Nt=class{identifier="create_order_file";#e;#a;constructor(e,t){this.#e=e,this.#a=t}async execute(e,t,n){let{orderId:i,files:r}=e;if(!i)throw new U("Missing orderId input");if(!r||!Array.isArray(r))throw new U("Missing files input");let o=await Promise.all(r.map(async(s,p)=>{if(typeof s=="string")return this.#t(i,s,n);if(typeof s!="object")throw new U(`File input on index ${p} must be an object`);let{filePath:c,fileName:l}=s;if(!c)throw new U(`File input on index ${p} must include a filePath property`);return this.#t(i,c,n,l)}));return{orderId:i,fileNames:o}}async#t(e,t,n,i){let o=await this.#e.files(t).read(".");i??=So.default.basename(o.path);try{let s=new FormData;s.append("OrderId",e),s.append("file",new File([Buffer.from(o.get())],i),i),n||(this.#e.logger.verbose(`[GPMS] Uploading file ${i} for order ${e}...`),await this.#a.post("/CreateOrderFile",s,{headers:{"Content-Type":"multipart/form-data"}}).catch(p=>{this.#e.logger.warn(`Failed to post order file: ${p.error??String(p)}`)}),this.#e.logger.debug(`[GPMS] Uploaded file ${i} for order ${e}`))}finally{o.close()}return i}};var zt=class{identifier="create_order";#e;#a;constructor(e,t){this.#e=e,this.#a=t}async execute(e,t,n){let i=this.#e.templating.compile(t.config.template)({inputs:e}).trim();if(!n){let r=Buffer.from(i).toString("base64");await this.#a.post("/CreateOrder",r,{headers:{"Content-Type":"text/plain"}}).catch(o=>{this.#e.logger.warn(`Failed to post order: ${o.error??String(o)}`)})}return{order:i}}};var Co=Dt(require("node:path"));var Bt=class{identifier="create_quote_file";#e;#a;constructor(e,t){this.#e=e,this.#a=t}async execute(e,t,n){let{quoteId:i,files:r}=e;if(!i)throw new U("Missing quoteId input");if(!r||!Array.isArray(r))throw new U("Missing files input");let o=await Promise.all(r.map(async(s,p)=>{if(typeof s=="string")return this.#t(i,s,n);if(typeof s!="object")throw new U(`File input on index ${p} must be an object`);let{filePath:c,fileName:l}=s;if(!c)throw new U(`File input on index ${p} must include a filePath property`);return this.#t(i,c,n,l)}));return{quoteId:i,fileNames:o}}async#t(e,t,n,i){let o=await this.#e.files(t).read(".");i??=Co.default.basename(o.path);try{let s=new FormData;s.append("QuoteId",e),s.append("file",new File([Buffer.from(o.get())],i),i),n||(this.#e.logger.verbose(`[GPMS] Uploading file ${i} for quote ${e}...`),await this.#a.post("/CreateQuoteFile",s,{headers:{"Content-Type":"multipart/form-data"}}).catch(p=>{this.#e.logger.warn(`Failed to post quote file: ${p.error??String(p)}`)}),this.#e.logger.debug(`[GPMS] Uploaded file ${i} for quote ${e}`))}finally{o.close()}return i}};var Mt=class{identifier="create_quote";#e;#a;constructor(e,t){this.#e=e,this.#a=t}async execute(e,t,n){let i=this.#e.templating.compile(t.config.template)({inputs:e}).trim();if(!n){let r=Buffer.from(i).toString("base64");await this.#a.post("/CreateQuote",r,{headers:{"Content-Type":"text/plain"}}).catch(o=>{this.#e.logger.warn(`Failed to post quote: ${o.error??String(o)}`)})}return{quote:i}}};var Lt=class{identifier="order_ready";#e;constructor(e,t){this.#e=t}async execute(e,t,n){if(!e.orderId)throw new U("Missing orderId configuration");let i={orderId:e.orderId,TrumpfSuccessful:e.trumpfSuccessful===!0};return n||await this.#e.post("/OrderReady",i),i}};var Ut=class{identifier="quote_ready";#e;constructor(e,t){this.#e=t}async execute(e,t,n){if(!e.quoteId)throw new U("Missing quoteId configuration");let i={quoteId:e.quoteId};return n||await this.#e.post("/QuoteReady",i),i}};var $t=class{#e=[zt,Nt,Lt,Mt,Bt,Ut,Rt];#a;#t={};constructor(e,t){this.#a=e,this.#e.forEach(n=>{let i=new n(e,t);this.#t[i.identifier]=i})}get callbackFunctionChain(){return this.#n(this.#a.receiver.emitEventType(this.#a.receiver.responses.ok()))}#n(e){return async(t,n)=>{let i=n.config.action;if(!i){let o=`[OROOX] Missing required action input parameters in message ${t.eventId}`;return this.#a.logger.warn(o),this.#a.receiver.responses.badRequest(o)(t)}let r=this.#t[i];if(!r){let o=`[OROOX] Action identifier ${i} does not exist in message ${t.eventId}`;return this.#a.logger.warn(o),this.#a.receiver.responses.badRequest(o)(t)}this.#a.logger.debug(`[OROOX] Parsed action: ${i}, params json size: ${JSON.stringify(t.payload).length}`);try{let o=await r.execute(t.payload,n,t.testRun===!0);return e({...t,payload:o??{}})}catch(o){if(o instanceof U)return this.#a.receiver.responses.badRequest(o.message)(t);let s=`[OROOX] Action ${i} execution failed: ${o instanceof Error?o.message:String(o)}`;return this.#a.logger.error(s,o),this.#a.receiver.responses.internalServerError(s)(t)}}}};var ym=Dt(bm()),ei=class{#e;#a;#t;#n;constructor(e){this.#e=e;let{config:t}=e;this.#t=(0,ym.default)(),this.#a=t.port||3050}init(){this.#t.post("/OrderStatusUpdate",this.#i.bind(this))}start(){this.#n=this.#t.listen(this.#a,()=>{this.#e.logger.info(`[GPMS] Webhook server started on 0.0.0.0:${this.#a}`)})}stop(){this.#n?.close()}async#i(e,t){this.#e.logger.debug("[GPMS] Received OrderStatusUpdate webhook with body:",e.body);let{body:n}=e;typeof e.body=="string"&&(n=JSON.parse(n));let{OrderNumber:i,OrderStatusId:r}=n;this.#e.logger.verbose("[GPMS] OrderStatusUpdate sending info as document:",{orderId:i,orderStatus:r}),await this.#e.sender.documents([{orderId:i,orderStatus:r}],{keyField:"orderId",collection:"gpms_order-status"}),this.#e.logger.verbose("[GPMS] OrderStatusUpdate webhook handled"),t.status(201).send("OK")}};var ko=class extends Ft{#e;#a;constructor(e,t){super(e,t),this.connectorSDK.config.webhooks===!0&&(this.#e=new ei(this.connectorSDK)),this.#a=this.connectorSDK.httpClient({baseUrl:this.connectorSDK.config.endpointUrl})}init=async()=>{let e=new $t(this.connectorSDK,this.#a);this.callbackFunction=e.callbackFunctionChain,this.#e?.init()};start=async()=>{this.#e?.start()};stop=async()=>{this.#e?.stop()}};0&&(module.exports={ConnectorRunnerGpms});
147
+ `;#e;#a;constructor(e,t){this.#e=e,this.#a=t}async execute(e,t,n){let i=this.#e.templating.compile(t.config.template??this.clientTemplate)({inputs:e}).trim();if(!n){let r=Buffer.from(i).toString("base64");await this.#a.post("/CreateClient",r,{headers:{"Content-Type":"text/plain"}}).catch(o=>{this.#e.logger.warn(`Failed to post client: ${o.error??String(o)}`)})}return{client:i}}};var So=Dt(require("node:path"));var Nt=class{identifier="create_order_file";#e;#a;constructor(e,t){this.#e=e,this.#a=t}async execute(e,t,n){let{orderId:i,files:r}=e;if(!i)throw new U("Missing orderId input");if(!r||!Array.isArray(r))throw new U("Missing files input");let o=await Promise.all(r.map(async(s,p)=>{if(typeof s=="string")return this.#t(i,s,n);if(typeof s!="object")throw new U(`File input on index ${p} must be an object`);let{filePath:c,fileName:l}=s;if(!c)throw new U(`File input on index ${p} must include a filePath property`);return this.#t(i,c,n,l)}));return{orderId:i,fileNames:o}}async#t(e,t,n,i){let o=await this.#e.files(t).read(".");i??=So.default.basename(o.path);try{let s=new FormData;s.append("OrderId",e),s.append("file",new File([Buffer.from(o.get())],i),i),n||(this.#e.logger.verbose(`[GPMS] Uploading file ${i} for order ${e}...`),await this.#a.post("/CreateOrderFile",s,{headers:{"Content-Type":"multipart/form-data"}}).catch(p=>{this.#e.logger.warn(`Failed to post order file: ${p.error??String(p)}`)}),this.#e.logger.debug(`[GPMS] Uploaded file ${i} for order ${e}`))}finally{o.close()}return i}};var zt=class{identifier="create_order";#e;#a;constructor(e,t){this.#e=e,this.#a=t}async execute(e,t,n){let i=this.#e.templating.compile(t.config.template)({inputs:e}).trim();if(!n){let r=Buffer.from(i).toString("base64");await this.#a.post("/CreateOrder",r,{headers:{"Content-Type":"text/plain"}}).catch(o=>{this.#e.logger.warn(`Failed to post order: ${o.error??String(o)}`)})}return{order:i}}};var Co=Dt(require("node:path"));var Bt=class{identifier="create_quote_file";#e;#a;constructor(e,t){this.#e=e,this.#a=t}async execute(e,t,n){let{quoteId:i,files:r}=e;if(!i)throw new U("Missing quoteId input");if(!r||!Array.isArray(r))throw new U("Missing files input");let o=await Promise.all(r.map(async(s,p)=>{if(typeof s=="string")return this.#t(i,s,n);if(typeof s!="object")throw new U(`File input on index ${p} must be an object`);let{filePath:c,fileName:l}=s;if(!c)throw new U(`File input on index ${p} must include a filePath property`);return this.#t(i,c,n,l)}));return{quoteId:i,fileNames:o}}async#t(e,t,n,i){let o=await this.#e.files(t).read(".");i??=Co.default.basename(o.path);try{let s=new FormData;s.append("QuoteId",e),s.append("file",new File([Buffer.from(o.get())],i),i),n||(this.#e.logger.verbose(`[GPMS] Uploading file ${i} for quote ${e}...`),await this.#a.post("/CreateQuoteFile",s,{headers:{"Content-Type":"multipart/form-data"}}).catch(p=>{this.#e.logger.warn(`Failed to post quote file: ${p.error??String(p)}`)}),this.#e.logger.debug(`[GPMS] Uploaded file ${i} for quote ${e}`))}finally{o.close()}return i}};var Mt=class{identifier="create_quote";#e;#a;constructor(e,t){this.#e=e,this.#a=t}async execute(e,t,n){let i=this.#e.templating.compile(t.config.template)({inputs:e}).trim();if(!n){let r=Buffer.from(i).toString("base64");await this.#a.post("/CreateQuote",r,{headers:{"Content-Type":"text/plain"}}).catch(o=>{this.#e.logger.warn(`Failed to post quote: ${o.error??String(o)}`)})}return{quote:i}}};var Lt=class{identifier="order_ready";#e;constructor(e,t){this.#e=t}async execute(e,t,n){if(!e.orderId)throw new U("Missing orderId configuration");let i={orderId:e.orderId,TrumpfSuccessful:e.trumpfSuccessful===!0};return n||await this.#e.post("/OrderReady",i),i}};var Ut=class{identifier="quote_ready";#e;constructor(e,t){this.#e=t}async execute(e,t,n){if(!e.quoteId)throw new U("Missing quoteId configuration");let i={quoteId:e.quoteId};return n||await this.#e.post("/QuoteReady",i),i}};var $t=class{#e=[zt,Nt,Lt,Mt,Bt,Ut,Rt];#a;#t={};constructor(e,t){this.#a=e,this.#e.forEach(n=>{let i=new n(e,t);this.#t[i.identifier]=i})}get callbackFunctionChain(){return this.#n(this.#a.receiver.emitEventType(this.#a.receiver.responses.ok()))}#n(e){return async(t,n)=>{let i=n.config.action;if(!i){let o=`[OROOX] Missing required action input parameters in message ${t.eventId}`;return this.#a.logger.warn(o),this.#a.receiver.responses.badRequest(o)(t)}let r=this.#t[i];if(!r){let o=`[OROOX] Action identifier ${i} does not exist in message ${t.eventId}`;return this.#a.logger.warn(o),this.#a.receiver.responses.badRequest(o)(t)}this.#a.logger.debug(`[OROOX] Parsed action: ${i}, params json size: ${JSON.stringify(t.payload).length}`);try{let o=await r.execute(t.payload,n,t.testRun===!0);return e({...t,payload:o??{}})}catch(o){if(o instanceof U)return this.#a.receiver.responses.badRequest(o.message)(t);let s=`[OROOX] Action ${i} execution failed: ${o instanceof Error?o.message:String(o)}`;return this.#a.logger.error(s,o),this.#a.receiver.responses.internalServerError(s)(t)}}}};var ym=Dt(bm()),ei=class{#e;#a;#t;#n;constructor(e){this.#e=e;let{config:t}=e;this.#t=(0,ym.default)(),this.#a=t.port||3050}init(){this.#t.post("/OrderStatusUpdate",this.#i.bind(this))}start(){this.#n=this.#t.listen(this.#a,()=>{this.#e.logger.info(`[GPMS] Webhook server started on 0.0.0.0:${this.#a}`)})}stop(){this.#n?.close()}async#i(e,t){this.#e.logger.debug("[GPMS] Received OrderStatusUpdate webhook with body:",e.body);let{body:n}=e;typeof e.body=="string"&&(n=JSON.parse(n));let{OrderNumber:i,OrderStatusId:r}=n;this.#e.logger.verbose("[GPMS] OrderStatusUpdate sending info as document:",{orderId:i,orderStatus:r}),await this.#e.sender.documents([{orderId:i,orderStatus:r}],{keyField:"orderId",collection:"gpms_order-status"}),this.#e.logger.verbose("[GPMS] OrderStatusUpdate webhook handled"),t.status(201).send("OK")}};var ko=class extends Ft{#e;#a;constructor(e,t){super(e,t),this.connectorSDK.config.webhooks===!0&&(this.#e=new ei(this.connectorSDK)),this.#a=this.connectorSDK.httpClient({baseUrl:this.connectorSDK.config.endpointUrl}).setRequestOptionsFormatter(this.#t)}init=async()=>{let e=new $t(this.connectorSDK,this.#a);this.callbackFunction=e.callbackFunctionChain,this.#e?.init()};start=async()=>{this.#e?.start()};stop=async()=>{this.#e?.stop()};#t=async e=>{let{config:t}=this.connectorSDK;return{...e,headers:{...e?.headers??{},"x-api-key":t.apiKey}}}};0&&(module.exports={ConnectorRunnerGpms});
148
148
  /*! Bundled license information:
149
149
 
150
150
  depd/index.js: