@mbanq/core-sdk-js 1.0.0-alpha.10 → 1.0.0-alpha.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.
@@ -0,0 +1 @@
1
+ import{a as y,c as g,d as f}from"./chunk-RX3BFHHX.mjs";var v=t=>{let n=[];if(!t.baseUrl)n.push("baseUrl is required");else if(typeof t.baseUrl!="string")n.push("baseUrl must be a string");else try{new URL(t.baseUrl)}catch{n.push("baseUrl must be a valid URL")}return t.axiosConfig?.timeout!==void 0&&(typeof t.axiosConfig.timeout!="number"||t.axiosConfig.timeout<0)&&n.push("timeout must be a positive number"),n};import{z as e}from"zod";var O=e.enum(["originatorName","originatorAccount","originatorBankRoutingCode","recipientName","recipientAccount","recipientBankRoutingCode","reference","traceNumber","externalId","clientId","dateFormat","locale","originatedBy","paymentRail","paymentType","fromValueDate","toValueDate","fromExecuteDate","toExecuteDate","status","fromReturnDate","toReturnDate","isSettlement","orderBy","sortOrder"]),h=e.enum(["DRAFT","AML_SCREENING","AML_REJECTED","EXECUTION_SCHEDULED","EXECUTION_PROCESSING","EXECUTION_SUCCESS","EXECUTION_FAILURE","RETURNED","CANCELLED","COMPLIANCE_FAILURE","DELETED","UNKNOWN"]),P=e.enum(["ACH","SAMEDAYACH","WIRE","SWIFT","INTERNAL","FXPAY","CARD"]),C=e.enum(["CREDIT","DEBIT"]),w=e.enum(["ASC","DESC"]),Fe=O.options,Ue=h.options,Le=P.options,_e=C.options,ze=w.options,N=t=>O.parse(t),k=t=>h.parse(t),B=t=>P.parse(t),F=t=>C.parse(t),U=t=>w.parse(t),L=e.string().min(1),_=e.string().min(1),z=e.string().min(1),V=e.string().min(1),j=e.string().min(1),$=e.string().min(1),M=e.string().min(1),G=e.string().min(1),q=e.string().min(1),K=e.union([e.string(),e.number()]),H=e.string(),Y=e.string(),W=e.string(),D=e.string(),A=e.string(),T=e.string(),X=e.boolean(),J=e.string(),Q=t=>L.parse(t),Z=t=>_.parse(t),ee=t=>z.parse(t),te=t=>V.parse(t),ne=t=>j.parse(t),ae=t=>$.parse(t),re=t=>M.parse(t),oe=t=>G.parse(t),ie=t=>q.parse(t),se=t=>K.parse(t),pe=t=>H.parse(t),ce=t=>Y.parse(t),me=t=>W.parse(t),de=t=>D.parse(t),ye=t=>A.parse(t),le=t=>T.parse(t),ue=t=>X.parse(t),ge=t=>J.parse(t),De={originatorName:L.optional(),originatorAccount:_.optional(),originatorBankRoutingCode:z.optional(),recipientName:V.optional(),recipientAccount:j.optional(),recipientBankRoutingCode:$.optional(),reference:M.optional(),traceNumber:G.optional(),externalId:q.optional(),clientId:K.optional(),dateFormat:H.optional(),locale:Y.optional(),originatedBy:W.optional(),paymentRail:P.optional(),paymentType:C.optional(),fromValueDate:D.optional(),toValueDate:D.optional(),fromExecuteDate:A.optional(),toExecuteDate:A.optional(),status:h.optional(),fromReturnDate:T.optional(),toReturnDate:T.optional(),isSettlement:X.optional(),orderBy:J.optional(),sortOrder:w.optional(),limit:e.number().positive().optional(),offset:e.number().min(0).optional()},Ve=e.object(De).partial();var fe=e.object({id:e.number(),clientId:e.number(),amount:e.number().positive(),correlationId:e.string(),paymentType:C,paymentRail:P,recipient:e.object({cardId:e.string().optional(),recipientType:e.string(),address:e.object({line1:e.string().optional(),line2:e.string().optional(),stateCode:e.string().optional(),countryCode:e.string(),postalCode:e.string().optional()}),name:e.string()}),originator:e.object({accountId:e.string().optional(),recipientType:e.string(),address:e.object({line1:e.string().optional(),line2:e.string().optional(),stateCode:e.string().optional(),countryCode:e.string(),postalCode:e.string().optional()}),name:e.string()}),executedAt:e.string(),createdAt:e.string(),externalId:e.string(),status:h,paymentRailMetaData:e.record(e.string(),e.any()).optional(),currencyData:e.object({code:e.string(),name:e.string(),decimalPlaces:e.number(),displaySymbol:e.string(),nameCode:e.string(),currencyCodeInDigit:e.number(),isBaseCurrency:e.boolean()}),currency:e.string().min(3).max(3)}).catchall(e.any()),xe=e.object({streetAddress:e.string().optional(),city:e.string().optional(),state:e.string().optional(),country:e.string().optional(),postalCode:e.string().optional()}).optional(),Ae=e.object({name:e.string().optional(),identifier:e.string().optional(),address:xe}).optional(),E=e.object({name:e.string(),identifier:e.string(),accountType:e.enum(["CHECKING","SAVINGS"]).optional(),address:xe,agent:Ae}),Te=e.object({amount:e.number().positive(),currency:e.string().min(3).max(3),paymentRail:P,paymentType:C,debtor:E,creditor:E,clientId:e.string().optional(),correspondent:E.optional(),exchangeRate:e.number().positive().optional(),externalId:e.string().optional(),reference:e.union([e.string(),e.array(e.string())]).optional(),paymentRailMetaData:e.record(e.string(),e.any()).optional(),chargeBearer:e.enum(["OUR","BEN","SHA"]).optional(),purposeCode:e.string().optional(),valueDate:e.string().optional(),executionDate:e.string().optional()}).catchall(e.any()).refine(t=>(t.paymentRail==="WIRE"||t.paymentRail==="SWIFT")&&t.creditor?t.creditor.address&&t.creditor.address.state&&t.creditor.address.country:!0,{message:"For WIRE transfers, recipient address with state and country is mandatory"}),we=e.object({amount:e.number().positive().optional(),correspondent:e.object({name:e.string().optional(),identifier:e.string().optional(),accountType:e.string().optional()}).optional(),creditor:e.object({name:e.string().optional(),identifier:e.string().optional(),accountType:e.string().optional(),agent:e.object({name:e.string().optional(),identifier:e.string().optional()}).optional()}).optional(),debtor:e.object({name:e.string().optional(),identifier:e.string().optional(),accountType:e.string().optional(),agent:e.object({name:e.string().optional(),identifier:e.string().optional()}).optional()}).optional(),exchangeRate:e.number().positive().optional(),externalId:e.string().optional(),errorCode:e.string().optional(),errorMessage:e.string().optional(),reference:e.union([e.string(),e.array(e.string())]).optional(),paymentRailMetaData:e.record(e.string(),e.any()).optional(),status:h.optional()}).catchall(e.any()),je=e.object({totalFilteredRecords:e.number(),pageItems:e.array(fe)}),S=t=>fe.parse(t),Ie=t=>Te.parse(t),he=t=>we.parse(t);import{ZodError as b}from"zod";var Oe=t=>{try{N(t)}catch(n){throw n instanceof b?y({message:`Invalid filter key: '${t}'. ${n.message}`,code:"invalid_filter_key"}):n}},Ne=(t,n)=>{try{switch(t){case"status":k(n);break;case"paymentRail":B(n);break;case"paymentType":F(n);break;case"sortOrder":U(n);break;case"originatorName":Q(n);break;case"originatorAccount":Z(n);break;case"originatorBankRoutingCode":ee(n);break;case"recipientName":te(n);break;case"recipientAccount":ne(n);break;case"recipientBankRoutingCode":ae(n);break;case"reference":re(n);break;case"traceNumber":oe(n);break;case"externalId":ie(n);break;case"clientId":se(n);break;case"dateFormat":pe(n);break;case"locale":ce(n);break;case"originatedBy":me(n);break;case"fromValueDate":case"toValueDate":de(n);break;case"fromExecuteDate":case"toExecuteDate":ye(n);break;case"fromReturnDate":case"toReturnDate":le(n);break;case"isSettlement":ue(n);break;case"orderBy":ge(n);break;default:break}}catch(r){throw r instanceof b?y({message:`Invalid value for '${t}': '${n}'. ${r.message}`,code:`invalid_${t}_value`}):r}},Pe=t=>({input:t,metadata:{commandName:"CreatePayment",path:"/v1/payments",method:"POST"},execute:async n=>{try{Ie(t.payment)}catch(a){throw a instanceof b?y({message:`Invalid payment data: ${a.message}`,code:"invalid_payment_input"}):a}t.tenantId&&(n.tenantId=t.tenantId);let r=await f(n);try{let a=await r.post("/v1/payments",t.payment);return S(a.data)}catch(a){g(a)}}}),Ce=t=>({input:t,metadata:{commandName:"GetPayment",path:`/v1/payments/${t.id}`,method:"GET"},execute:async n=>{t.tenantId&&(n.tenantId=t.tenantId);let r=await f(n);try{let a=await r.get(`/v1/payments/${t.id}`);return S(a.data)}catch(a){g(a)}}}),Re=t=>({input:t,metadata:{commandName:"UpdatePayment",path:`/v1/payments/${t.id}`,method:"PUT"},execute:async n=>{try{he(t.payment)}catch(a){throw a instanceof b?y({message:`Invalid payment update data: ${a.message}`,code:"invalid_payment_update_input"}):a}t.tenantId&&(n.tenantId=t.tenantId);let r=await f(n);try{let a=await r.put(`/v1/payments/${t.id}`,t.payment);return S(a.data)}catch(a){g(a)}}}),R=(t,n,r,a)=>{if(n!==void 0&&n!==0&&n<=0)throw y({message:`Invalid limit: ${n}. Limit must be positive or 0 for fetching all records.`,code:"invalid_limit"});if(r!==void 0&&r<0)throw y({message:`Invalid offset: ${r}. Offset must be non-negative.`,code:"invalid_offset"});return{where:c=>(Oe(c),{eq:o=>(Ne(c,o),R({...t,[c]:o},n,r,a))}),limit:c=>R(t,c,r,a),offset:c=>R(t,n,c,a),all:()=>R(t,0,r,a),execute:()=>{let c={...t,limit:n||200,offset:r||0};return{input:{filters:t,limit:n,offset:r,tenantId:a},metadata:{commandName:"ListPayments",path:"/v1/payments",method:"GET"},execute:async o=>{a&&(o.tenantId=a);let s=await f(o);try{if(n===0){let i=[],m=r||0,l=0;do{let u={...t,limit:200,offset:m},I=await s.get("/v1/payments",{params:u}),{totalFilteredRecords:ve,pageItems:Ee}=I.data;i.push(...Ee),l=ve,m+=200}while(m<l);return{totalFilteredRecords:l,pageItems:i}}else return(await s.get("/v1/payments",{params:c})).data}catch(i){g(i)}}}}}},Se=t=>({list:()=>R({},void 0,void 0,t?.tenantId)}),He=(t,n)=>({input:{params:t,configuration:n},metadata:{commandName:"GetPayments",path:"/v1/payments",method:"GET"},execute:async r=>{n.tenantId&&(r.tenantId=n.tenantId);let a=await f(r),d=[],x=t.limit||20,c=t.offset||0,o=0,s={...t,limit:x,offset:c};try{if(t.limit===0){do{let i=await a.get("/v1/payments",{params:s}),{totalFilteredRecords:p,pageItems:m}=i.data;d.push(...m),o=p,c+=x}while(c<o);return{totalFilteredRecords:o,pageItems:d}}else return(await a.get("/v1/payments",{params:s})).data}catch(i){g(i)}}}),be=t=>({input:t,metadata:{commandName:"DeletePayment",path:`/v1/payments/${t.id}`,method:"DELETE"},execute:async n=>{t.tenantId&&(n.tenantId=t.tenantId);let r=await f(n);try{await r.delete(`/v1/payments/${t.id}`)}catch(a){g(a)}}});var Qe=t=>{let n=v(t);if(n.length>0)throw y({message:`Invalid configuration: ${n.join(", ")}`,code:"invalid_config"});let r=async(o,s,i)=>{if(t.middlewares)for(let p of t.middlewares)o==="before"&&p.before?await p.before(s):o==="after"&&p.after?await p.after(s,i):o==="onError"&&p.onError&&await p.onError(s,i)},a={...t},d=async o=>{try{await r("before",o);let s=await o.execute(a);return await r("after",o,s),s}catch(s){throw await r("onError",o,s),s}},x=o=>{let s=o||a.tenantId;return{payment:{create:i=>{let p=Pe({payment:i,tenantId:s});return{execute:async()=>d(p)}},get:i=>{let p=Ce({id:i,tenantId:s});return{execute:async()=>d(p)}},update:(i,p)=>{let m=Re({id:i,payment:p,tenantId:s});return{execute:async()=>d(m)}},delete:i=>{let p=be({id:i,tenantId:s});return{execute:async()=>d(p)}},list:()=>{let p=Se({tenantId:s}).list(),m=l=>({where:l.where,limit:u=>{let I=l.limit(u);return m(I)},offset:u=>{let I=l.offset(u);return m(I)},all:()=>{let u=l.all();return m(u)},execute:async()=>{let u=l.execute();return d(u)}});return m(p)}}}};return{setConfig:o=>{a=o},updateConfig:o=>{let s={...a,...o,axiosConfig:{...a.axiosConfig,...o.axiosConfig,headers:{...a.axiosConfig?.headers,...o.axiosConfig?.headers}}},i=v(s);if(i.length>0)throw y({message:`Invalid configuration: ${i.join(", ")}`,code:"invalid_config"});a=s},resetConfig:()=>{a=t},request:d,tenant:o=>x(o),...x()}};export{O as a,h as b,P as c,C as d,w as e,De as f,Ve as g,Te as h,we as i,je as j,Pe as k,Ce as l,Re as m,He as n,Qe as o};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkOGW7GTJPjs = require('./chunk-OGW7GTJP.js');var v=t=>{let n=[];if(!t.baseUrl)n.push("baseUrl is required");else if(typeof t.baseUrl!="string")n.push("baseUrl must be a string");else try{new URL(t.baseUrl)}catch (e2){n.push("baseUrl must be a valid URL")}return _optionalChain([t, 'access', _2 => _2.axiosConfig, 'optionalAccess', _3 => _3.timeout])!==void 0&&(typeof t.axiosConfig.timeout!="number"||t.axiosConfig.timeout<0)&&n.push("timeout must be a positive number"),n};var _zod = require('zod');var O=_zod.z.enum(["originatorName","originatorAccount","originatorBankRoutingCode","recipientName","recipientAccount","recipientBankRoutingCode","reference","traceNumber","externalId","clientId","dateFormat","locale","originatedBy","paymentRail","paymentType","fromValueDate","toValueDate","fromExecuteDate","toExecuteDate","status","fromReturnDate","toReturnDate","isSettlement","orderBy","sortOrder"]),h= exports.b =_zod.z.enum(["DRAFT","AML_SCREENING","AML_REJECTED","EXECUTION_SCHEDULED","EXECUTION_PROCESSING","EXECUTION_SUCCESS","EXECUTION_FAILURE","RETURNED","CANCELLED","COMPLIANCE_FAILURE","DELETED","UNKNOWN"]),P= exports.c =_zod.z.enum(["ACH","SAMEDAYACH","WIRE","SWIFT","INTERNAL","FXPAY","CARD"]),C= exports.d =_zod.z.enum(["CREDIT","DEBIT"]),w= exports.e =_zod.z.enum(["ASC","DESC"]),Fe=O.options,Ue=h.options,Le=P.options,_e=C.options,ze=w.options,N=t=>O.parse(t),k=t=>h.parse(t),B=t=>P.parse(t),F=t=>C.parse(t),U=t=>w.parse(t),L=_zod.z.string().min(1),_=_zod.z.string().min(1),z=_zod.z.string().min(1),V=_zod.z.string().min(1),j=_zod.z.string().min(1),$=_zod.z.string().min(1),M=_zod.z.string().min(1),G=_zod.z.string().min(1),q=_zod.z.string().min(1),K=_zod.z.union([_zod.z.string(),_zod.z.number()]),H=_zod.z.string(),Y=_zod.z.string(),W=_zod.z.string(),D=_zod.z.string(),A=_zod.z.string(),T=_zod.z.string(),X=_zod.z.boolean(),J=_zod.z.string(),Q=t=>L.parse(t),Z=t=>_.parse(t),ee=t=>z.parse(t),te=t=>V.parse(t),ne=t=>j.parse(t),ae=t=>$.parse(t),re=t=>M.parse(t),oe=t=>G.parse(t),ie=t=>q.parse(t),se=t=>K.parse(t),pe=t=>H.parse(t),ce=t=>Y.parse(t),me=t=>W.parse(t),de=t=>D.parse(t),ye=t=>A.parse(t),le=t=>T.parse(t),ue=t=>X.parse(t),ge=t=>J.parse(t),De= exports.f ={originatorName:L.optional(),originatorAccount:_.optional(),originatorBankRoutingCode:z.optional(),recipientName:V.optional(),recipientAccount:j.optional(),recipientBankRoutingCode:$.optional(),reference:M.optional(),traceNumber:G.optional(),externalId:q.optional(),clientId:K.optional(),dateFormat:H.optional(),locale:Y.optional(),originatedBy:W.optional(),paymentRail:P.optional(),paymentType:C.optional(),fromValueDate:D.optional(),toValueDate:D.optional(),fromExecuteDate:A.optional(),toExecuteDate:A.optional(),status:h.optional(),fromReturnDate:T.optional(),toReturnDate:T.optional(),isSettlement:X.optional(),orderBy:J.optional(),sortOrder:w.optional(),limit:_zod.z.number().positive().optional(),offset:_zod.z.number().min(0).optional()},Ve= exports.g =_zod.z.object(De).partial();var fe=_zod.z.object({id:_zod.z.number(),clientId:_zod.z.number(),amount:_zod.z.number().positive(),correlationId:_zod.z.string(),paymentType:C,paymentRail:P,recipient:_zod.z.object({cardId:_zod.z.string().optional(),recipientType:_zod.z.string(),address:_zod.z.object({line1:_zod.z.string().optional(),line2:_zod.z.string().optional(),stateCode:_zod.z.string().optional(),countryCode:_zod.z.string(),postalCode:_zod.z.string().optional()}),name:_zod.z.string()}),originator:_zod.z.object({accountId:_zod.z.string().optional(),recipientType:_zod.z.string(),address:_zod.z.object({line1:_zod.z.string().optional(),line2:_zod.z.string().optional(),stateCode:_zod.z.string().optional(),countryCode:_zod.z.string(),postalCode:_zod.z.string().optional()}),name:_zod.z.string()}),executedAt:_zod.z.string(),createdAt:_zod.z.string(),externalId:_zod.z.string(),status:h,paymentRailMetaData:_zod.z.record(_zod.z.string(),_zod.z.any()).optional(),currencyData:_zod.z.object({code:_zod.z.string(),name:_zod.z.string(),decimalPlaces:_zod.z.number(),displaySymbol:_zod.z.string(),nameCode:_zod.z.string(),currencyCodeInDigit:_zod.z.number(),isBaseCurrency:_zod.z.boolean()}),currency:_zod.z.string().min(3).max(3)}).catchall(_zod.z.any()),xe=_zod.z.object({streetAddress:_zod.z.string().optional(),city:_zod.z.string().optional(),state:_zod.z.string().optional(),country:_zod.z.string().optional(),postalCode:_zod.z.string().optional()}).optional(),Ae=_zod.z.object({name:_zod.z.string().optional(),identifier:_zod.z.string().optional(),address:xe}).optional(),E=_zod.z.object({name:_zod.z.string(),identifier:_zod.z.string(),accountType:_zod.z.enum(["CHECKING","SAVINGS"]).optional(),address:xe,agent:Ae}),Te= exports.h =_zod.z.object({amount:_zod.z.number().positive(),currency:_zod.z.string().min(3).max(3),paymentRail:P,paymentType:C,debtor:E,creditor:E,clientId:_zod.z.string().optional(),correspondent:E.optional(),exchangeRate:_zod.z.number().positive().optional(),externalId:_zod.z.string().optional(),reference:_zod.z.union([_zod.z.string(),_zod.z.array(_zod.z.string())]).optional(),paymentRailMetaData:_zod.z.record(_zod.z.string(),_zod.z.any()).optional(),chargeBearer:_zod.z.enum(["OUR","BEN","SHA"]).optional(),purposeCode:_zod.z.string().optional(),valueDate:_zod.z.string().optional(),executionDate:_zod.z.string().optional()}).catchall(_zod.z.any()).refine(t=>(t.paymentRail==="WIRE"||t.paymentRail==="SWIFT")&&t.creditor?t.creditor.address&&t.creditor.address.state&&t.creditor.address.country:!0,{message:"For WIRE transfers, recipient address with state and country is mandatory"}),we= exports.i =_zod.z.object({amount:_zod.z.number().positive().optional(),correspondent:_zod.z.object({name:_zod.z.string().optional(),identifier:_zod.z.string().optional(),accountType:_zod.z.string().optional()}).optional(),creditor:_zod.z.object({name:_zod.z.string().optional(),identifier:_zod.z.string().optional(),accountType:_zod.z.string().optional(),agent:_zod.z.object({name:_zod.z.string().optional(),identifier:_zod.z.string().optional()}).optional()}).optional(),debtor:_zod.z.object({name:_zod.z.string().optional(),identifier:_zod.z.string().optional(),accountType:_zod.z.string().optional(),agent:_zod.z.object({name:_zod.z.string().optional(),identifier:_zod.z.string().optional()}).optional()}).optional(),exchangeRate:_zod.z.number().positive().optional(),externalId:_zod.z.string().optional(),errorCode:_zod.z.string().optional(),errorMessage:_zod.z.string().optional(),reference:_zod.z.union([_zod.z.string(),_zod.z.array(_zod.z.string())]).optional(),paymentRailMetaData:_zod.z.record(_zod.z.string(),_zod.z.any()).optional(),status:h.optional()}).catchall(_zod.z.any()),je= exports.j =_zod.z.object({totalFilteredRecords:_zod.z.number(),pageItems:_zod.z.array(fe)}),S=t=>fe.parse(t),Ie=t=>Te.parse(t),he=t=>we.parse(t);var Oe=t=>{try{N(t)}catch(n){throw n instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid filter key: '${t}'. ${n.message}`,code:"invalid_filter_key"}):n}},Ne=(t,n)=>{try{switch(t){case"status":k(n);break;case"paymentRail":B(n);break;case"paymentType":F(n);break;case"sortOrder":U(n);break;case"originatorName":Q(n);break;case"originatorAccount":Z(n);break;case"originatorBankRoutingCode":ee(n);break;case"recipientName":te(n);break;case"recipientAccount":ne(n);break;case"recipientBankRoutingCode":ae(n);break;case"reference":re(n);break;case"traceNumber":oe(n);break;case"externalId":ie(n);break;case"clientId":se(n);break;case"dateFormat":pe(n);break;case"locale":ce(n);break;case"originatedBy":me(n);break;case"fromValueDate":case"toValueDate":de(n);break;case"fromExecuteDate":case"toExecuteDate":ye(n);break;case"fromReturnDate":case"toReturnDate":le(n);break;case"isSettlement":ue(n);break;case"orderBy":ge(n);break;default:break}}catch(r){throw r instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid value for '${t}': '${n}'. ${r.message}`,code:`invalid_${t}_value`}):r}},Pe= exports.k =t=>({input:t,metadata:{commandName:"CreatePayment",path:"/v1/payments",method:"POST"},execute:async n=>{try{Ie(t.payment)}catch(a){throw a instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid payment data: ${a.message}`,code:"invalid_payment_input"}):a}t.tenantId&&(n.tenantId=t.tenantId);let r=await _chunkOGW7GTJPjs.d.call(void 0, n);try{let a=await r.post("/v1/payments",t.payment);return S(a.data)}catch(a){_chunkOGW7GTJPjs.c.call(void 0, a)}}}),Ce= exports.l =t=>({input:t,metadata:{commandName:"GetPayment",path:`/v1/payments/${t.id}`,method:"GET"},execute:async n=>{t.tenantId&&(n.tenantId=t.tenantId);let r=await _chunkOGW7GTJPjs.d.call(void 0, n);try{let a=await r.get(`/v1/payments/${t.id}`);return S(a.data)}catch(a){_chunkOGW7GTJPjs.c.call(void 0, a)}}}),Re= exports.m =t=>({input:t,metadata:{commandName:"UpdatePayment",path:`/v1/payments/${t.id}`,method:"PUT"},execute:async n=>{try{he(t.payment)}catch(a){throw a instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid payment update data: ${a.message}`,code:"invalid_payment_update_input"}):a}t.tenantId&&(n.tenantId=t.tenantId);let r=await _chunkOGW7GTJPjs.d.call(void 0, n);try{let a=await r.put(`/v1/payments/${t.id}`,t.payment);return S(a.data)}catch(a){_chunkOGW7GTJPjs.c.call(void 0, a)}}}),R=(t,n,r,a)=>{if(n!==void 0&&n!==0&&n<=0)throw _chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid limit: ${n}. Limit must be positive or 0 for fetching all records.`,code:"invalid_limit"});if(r!==void 0&&r<0)throw _chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid offset: ${r}. Offset must be non-negative.`,code:"invalid_offset"});return{where:c=>(Oe(c),{eq:o=>(Ne(c,o),R({...t,[c]:o},n,r,a))}),limit:c=>R(t,c,r,a),offset:c=>R(t,n,c,a),all:()=>R(t,0,r,a),execute:()=>{let c={...t,limit:n||200,offset:r||0};return{input:{filters:t,limit:n,offset:r,tenantId:a},metadata:{commandName:"ListPayments",path:"/v1/payments",method:"GET"},execute:async o=>{a&&(o.tenantId=a);let s=await _chunkOGW7GTJPjs.d.call(void 0, o);try{if(n===0){let i=[],m=r||0,l=0;do{let u={...t,limit:200,offset:m},I=await s.get("/v1/payments",{params:u}),{totalFilteredRecords:ve,pageItems:Ee}=I.data;i.push(...Ee),l=ve,m+=200}while(m<l);return{totalFilteredRecords:l,pageItems:i}}else return(await s.get("/v1/payments",{params:c})).data}catch(i){_chunkOGW7GTJPjs.c.call(void 0, i)}}}}}},Se=t=>({list:()=>R({},void 0,void 0,_optionalChain([t, 'optionalAccess', _4 => _4.tenantId]))}),He= exports.n =(t,n)=>({input:{params:t,configuration:n},metadata:{commandName:"GetPayments",path:"/v1/payments",method:"GET"},execute:async r=>{n.tenantId&&(r.tenantId=n.tenantId);let a=await _chunkOGW7GTJPjs.d.call(void 0, r),d=[],x=t.limit||20,c=t.offset||0,o=0,s={...t,limit:x,offset:c};try{if(t.limit===0){do{let i=await a.get("/v1/payments",{params:s}),{totalFilteredRecords:p,pageItems:m}=i.data;d.push(...m),o=p,c+=x}while(c<o);return{totalFilteredRecords:o,pageItems:d}}else return(await a.get("/v1/payments",{params:s})).data}catch(i){_chunkOGW7GTJPjs.c.call(void 0, i)}}}),be=t=>({input:t,metadata:{commandName:"DeletePayment",path:`/v1/payments/${t.id}`,method:"DELETE"},execute:async n=>{t.tenantId&&(n.tenantId=t.tenantId);let r=await _chunkOGW7GTJPjs.d.call(void 0, n);try{await r.delete(`/v1/payments/${t.id}`)}catch(a){_chunkOGW7GTJPjs.c.call(void 0, a)}}});var Qe=t=>{let n=v(t);if(n.length>0)throw _chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid configuration: ${n.join(", ")}`,code:"invalid_config"});let r=async(o,s,i)=>{if(t.middlewares)for(let p of t.middlewares)o==="before"&&p.before?await p.before(s):o==="after"&&p.after?await p.after(s,i):o==="onError"&&p.onError&&await p.onError(s,i)},a={...t},d=async o=>{try{await r("before",o);let s=await o.execute(a);return await r("after",o,s),s}catch(s){throw await r("onError",o,s),s}},x=o=>{let s=o||a.tenantId;return{payment:{create:i=>{let p=Pe({payment:i,tenantId:s});return{execute:async()=>d(p)}},get:i=>{let p=Ce({id:i,tenantId:s});return{execute:async()=>d(p)}},update:(i,p)=>{let m=Re({id:i,payment:p,tenantId:s});return{execute:async()=>d(m)}},delete:i=>{let p=be({id:i,tenantId:s});return{execute:async()=>d(p)}},list:()=>{let p=Se({tenantId:s}).list(),m=l=>({where:l.where,limit:u=>{let I=l.limit(u);return m(I)},offset:u=>{let I=l.offset(u);return m(I)},all:()=>{let u=l.all();return m(u)},execute:async()=>{let u=l.execute();return d(u)}});return m(p)}}}};return{setConfig:o=>{a=o},updateConfig:o=>{let s={...a,...o,axiosConfig:{...a.axiosConfig,...o.axiosConfig,headers:{..._optionalChain([a, 'access', _5 => _5.axiosConfig, 'optionalAccess', _6 => _6.headers]),..._optionalChain([o, 'access', _7 => _7.axiosConfig, 'optionalAccess', _8 => _8.headers])}}},i=v(s);if(i.length>0)throw _chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid configuration: ${i.join(", ")}`,code:"invalid_config"});a=s},resetConfig:()=>{a=t},request:d,tenant:o=>x(o),...x()}};exports.a = O; exports.b = h; exports.c = P; exports.d = C; exports.e = w; exports.f = De; exports.g = Ve; exports.h = Te; exports.i = we; exports.j = je; exports.k = Pe; exports.l = Ce; exports.m = Re; exports.n = He; exports.o = Qe;
@@ -1,5 +1,5 @@
1
1
  import 'zod';
2
2
  import '../config.d-CyK6ZM6s.mjs';
3
- export { c as createClient } from '../index-CCyptSZo.mjs';
3
+ export { c as createClient } from '../index-CASxEasn.mjs';
4
4
  import 'graphql';
5
5
  import 'axios';
@@ -1,5 +1,5 @@
1
1
  import 'zod';
2
2
  import '../config.d-CyK6ZM6s.js';
3
- export { c as createClient } from '../index-Dn5rWIBE.js';
3
+ export { c as createClient } from '../index-CDXiIoqN.js';
4
4
  import 'graphql';
5
5
  import 'axios';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTL2MJ56Sjs = require('../chunk-TL2MJ56S.js');require('../chunk-OGW7GTJP.js');exports.createClient = _chunkTL2MJ56Sjs.n;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkSMOK4ASFjs = require('../chunk-SMOK4ASF.js');require('../chunk-OGW7GTJP.js');exports.createClient = _chunkSMOK4ASFjs.o;
@@ -1 +1 @@
1
- import{n as a}from"../chunk-6YLCCDXD.mjs";import"../chunk-RX3BFHHX.mjs";export{a as createClient};
1
+ import{o as a}from"../chunk-DVUWFF32.mjs";import"../chunk-RX3BFHHX.mjs";export{a as createClient};
@@ -10,6 +10,35 @@ declare const SortOrderSchema: z.ZodEnum<["ASC", "DESC"]>;
10
10
  type PaymentStatus = z.infer<typeof PaymentStatusSchema>;
11
11
  type PaymentRailType = z.infer<typeof PaymentRailSchema>;
12
12
  type PaymentType = z.infer<typeof PaymentTypeSchema>;
13
+ declare const PaymentFilterShape: {
14
+ originatorName: z.ZodOptional<z.ZodString>;
15
+ originatorAccount: z.ZodOptional<z.ZodString>;
16
+ originatorBankRoutingCode: z.ZodOptional<z.ZodString>;
17
+ recipientName: z.ZodOptional<z.ZodString>;
18
+ recipientAccount: z.ZodOptional<z.ZodString>;
19
+ recipientBankRoutingCode: z.ZodOptional<z.ZodString>;
20
+ reference: z.ZodOptional<z.ZodString>;
21
+ traceNumber: z.ZodOptional<z.ZodString>;
22
+ externalId: z.ZodOptional<z.ZodString>;
23
+ clientId: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
24
+ dateFormat: z.ZodOptional<z.ZodString>;
25
+ locale: z.ZodOptional<z.ZodString>;
26
+ originatedBy: z.ZodOptional<z.ZodString>;
27
+ paymentRail: z.ZodOptional<z.ZodEnum<["ACH", "SAMEDAYACH", "WIRE", "SWIFT", "INTERNAL", "FXPAY", "CARD"]>>;
28
+ paymentType: z.ZodOptional<z.ZodEnum<["CREDIT", "DEBIT"]>>;
29
+ fromValueDate: z.ZodOptional<z.ZodString>;
30
+ toValueDate: z.ZodOptional<z.ZodString>;
31
+ fromExecuteDate: z.ZodOptional<z.ZodString>;
32
+ toExecuteDate: z.ZodOptional<z.ZodString>;
33
+ status: z.ZodOptional<z.ZodEnum<["DRAFT", "AML_SCREENING", "AML_REJECTED", "EXECUTION_SCHEDULED", "EXECUTION_PROCESSING", "EXECUTION_SUCCESS", "EXECUTION_FAILURE", "RETURNED", "CANCELLED", "COMPLIANCE_FAILURE", "DELETED", "UNKNOWN"]>>;
34
+ fromReturnDate: z.ZodOptional<z.ZodString>;
35
+ toReturnDate: z.ZodOptional<z.ZodString>;
36
+ isSettlement: z.ZodOptional<z.ZodBoolean>;
37
+ orderBy: z.ZodOptional<z.ZodString>;
38
+ sortOrder: z.ZodOptional<z.ZodEnum<["ASC", "DESC"]>>;
39
+ limit: z.ZodOptional<z.ZodNumber>;
40
+ offset: z.ZodOptional<z.ZodNumber>;
41
+ };
13
42
  declare const PaymentFiltersSchema: z.ZodObject<{
14
43
  originatorName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
15
44
  originatorAccount: z.ZodOptional<z.ZodOptional<z.ZodString>>;
@@ -3549,6 +3578,7 @@ declare const createClient: (initialConfig: Config) => {
3549
3578
  where: any;
3550
3579
  limit: (value: number) => /*elided*/ any;
3551
3580
  offset: (value: number) => /*elided*/ any;
3581
+ all: () => /*elided*/ any;
3552
3582
  execute: () => Promise<unknown>;
3553
3583
  };
3554
3584
  };
@@ -3964,10 +3994,11 @@ declare const createClient: (initialConfig: Config) => {
3964
3994
  where: any;
3965
3995
  limit: (value: number) => /*elided*/ any;
3966
3996
  offset: (value: number) => /*elided*/ any;
3997
+ all: () => /*elided*/ any;
3967
3998
  execute: () => Promise<unknown>;
3968
3999
  };
3969
4000
  };
3970
4001
  };
3971
4002
  };
3972
4003
 
3973
- export { type CreatePaymentInput as C, type Payment as P, SortOrderSchema as S, type UpdatePaymentInput as U, type PaymentResponse as a, type PaymentStatus as b, createClient as c, type PaymentRailType as d, type PaymentType as e, type PaymentFilters as f, PaymentStatusSchema as g, PaymentFilterKeySchema as h, PaymentRailSchema as i, PaymentTypeSchema as j, CreatePaymentInputSchema as k, UpdatePaymentInputSchema as l, PaymentResponseSchema as m, PaymentFiltersSchema as n };
4004
+ export { type CreatePaymentInput as C, type Payment as P, SortOrderSchema as S, type UpdatePaymentInput as U, type PaymentFilters as a, type PaymentResponse as b, createClient as c, type PaymentStatus as d, type PaymentRailType as e, type PaymentType as f, PaymentStatusSchema as g, PaymentFilterKeySchema as h, PaymentRailSchema as i, PaymentTypeSchema as j, CreatePaymentInputSchema as k, UpdatePaymentInputSchema as l, PaymentResponseSchema as m, PaymentFiltersSchema as n, PaymentFilterShape as o };
@@ -10,6 +10,35 @@ declare const SortOrderSchema: z.ZodEnum<["ASC", "DESC"]>;
10
10
  type PaymentStatus = z.infer<typeof PaymentStatusSchema>;
11
11
  type PaymentRailType = z.infer<typeof PaymentRailSchema>;
12
12
  type PaymentType = z.infer<typeof PaymentTypeSchema>;
13
+ declare const PaymentFilterShape: {
14
+ originatorName: z.ZodOptional<z.ZodString>;
15
+ originatorAccount: z.ZodOptional<z.ZodString>;
16
+ originatorBankRoutingCode: z.ZodOptional<z.ZodString>;
17
+ recipientName: z.ZodOptional<z.ZodString>;
18
+ recipientAccount: z.ZodOptional<z.ZodString>;
19
+ recipientBankRoutingCode: z.ZodOptional<z.ZodString>;
20
+ reference: z.ZodOptional<z.ZodString>;
21
+ traceNumber: z.ZodOptional<z.ZodString>;
22
+ externalId: z.ZodOptional<z.ZodString>;
23
+ clientId: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
24
+ dateFormat: z.ZodOptional<z.ZodString>;
25
+ locale: z.ZodOptional<z.ZodString>;
26
+ originatedBy: z.ZodOptional<z.ZodString>;
27
+ paymentRail: z.ZodOptional<z.ZodEnum<["ACH", "SAMEDAYACH", "WIRE", "SWIFT", "INTERNAL", "FXPAY", "CARD"]>>;
28
+ paymentType: z.ZodOptional<z.ZodEnum<["CREDIT", "DEBIT"]>>;
29
+ fromValueDate: z.ZodOptional<z.ZodString>;
30
+ toValueDate: z.ZodOptional<z.ZodString>;
31
+ fromExecuteDate: z.ZodOptional<z.ZodString>;
32
+ toExecuteDate: z.ZodOptional<z.ZodString>;
33
+ status: z.ZodOptional<z.ZodEnum<["DRAFT", "AML_SCREENING", "AML_REJECTED", "EXECUTION_SCHEDULED", "EXECUTION_PROCESSING", "EXECUTION_SUCCESS", "EXECUTION_FAILURE", "RETURNED", "CANCELLED", "COMPLIANCE_FAILURE", "DELETED", "UNKNOWN"]>>;
34
+ fromReturnDate: z.ZodOptional<z.ZodString>;
35
+ toReturnDate: z.ZodOptional<z.ZodString>;
36
+ isSettlement: z.ZodOptional<z.ZodBoolean>;
37
+ orderBy: z.ZodOptional<z.ZodString>;
38
+ sortOrder: z.ZodOptional<z.ZodEnum<["ASC", "DESC"]>>;
39
+ limit: z.ZodOptional<z.ZodNumber>;
40
+ offset: z.ZodOptional<z.ZodNumber>;
41
+ };
13
42
  declare const PaymentFiltersSchema: z.ZodObject<{
14
43
  originatorName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
15
44
  originatorAccount: z.ZodOptional<z.ZodOptional<z.ZodString>>;
@@ -3549,6 +3578,7 @@ declare const createClient: (initialConfig: Config) => {
3549
3578
  where: any;
3550
3579
  limit: (value: number) => /*elided*/ any;
3551
3580
  offset: (value: number) => /*elided*/ any;
3581
+ all: () => /*elided*/ any;
3552
3582
  execute: () => Promise<unknown>;
3553
3583
  };
3554
3584
  };
@@ -3964,10 +3994,11 @@ declare const createClient: (initialConfig: Config) => {
3964
3994
  where: any;
3965
3995
  limit: (value: number) => /*elided*/ any;
3966
3996
  offset: (value: number) => /*elided*/ any;
3997
+ all: () => /*elided*/ any;
3967
3998
  execute: () => Promise<unknown>;
3968
3999
  };
3969
4000
  };
3970
4001
  };
3971
4002
  };
3972
4003
 
3973
- export { type CreatePaymentInput as C, type Payment as P, SortOrderSchema as S, type UpdatePaymentInput as U, type PaymentResponse as a, type PaymentStatus as b, createClient as c, type PaymentRailType as d, type PaymentType as e, type PaymentFilters as f, PaymentStatusSchema as g, PaymentFilterKeySchema as h, PaymentRailSchema as i, PaymentTypeSchema as j, CreatePaymentInputSchema as k, UpdatePaymentInputSchema as l, PaymentResponseSchema as m, PaymentFiltersSchema as n };
4004
+ export { type CreatePaymentInput as C, type Payment as P, SortOrderSchema as S, type UpdatePaymentInput as U, type PaymentFilters as a, type PaymentResponse as b, createClient as c, type PaymentStatus as d, type PaymentRailType as e, type PaymentType as f, PaymentStatusSchema as g, PaymentFilterKeySchema as h, PaymentRailSchema as i, PaymentTypeSchema as j, CreatePaymentInputSchema as k, UpdatePaymentInputSchema as l, PaymentResponseSchema as m, PaymentFiltersSchema as n, PaymentFilterShape as o };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CreatePaymentInput, P as Payment, U as UpdatePaymentInput, a as PaymentResponse } from './index-CCyptSZo.mjs';
2
- export { k as CreatePaymentInputZod, h as PaymentFilterKeyZod, f as PaymentFilters, n as PaymentFiltersZod, d as PaymentRailType, i as PaymentRailZod, m as PaymentResponseZod, b as PaymentStatus, g as PaymentStatusZod, e as PaymentType, j as PaymentTypeZod, S as SortOrderZod, l as UpdatePaymentInputZod, c as createClient } from './index-CCyptSZo.mjs';
1
+ import { C as CreatePaymentInput, P as Payment, U as UpdatePaymentInput, a as PaymentFilters, b as PaymentResponse } from './index-CASxEasn.mjs';
2
+ export { k as CreatePaymentInputZod, h as PaymentFilterKeyZod, o as PaymentFilterShape, n as PaymentFiltersZod, e as PaymentRailType, i as PaymentRailZod, m as PaymentResponseZod, d as PaymentStatus, g as PaymentStatusZod, f as PaymentType, j as PaymentTypeZod, S as SortOrderZod, l as UpdatePaymentInputZod, c as createClient } from './index-CASxEasn.mjs';
3
3
  import { M as Middleware, C as Command } from './config.d-CyK6ZM6s.mjs';
4
4
  export { a as Config } from './config.d-CyK6ZM6s.mjs';
5
5
  export { G as GetClientData, c as GraphQL, S as SendAuthorizationToCore, U as UpdateCardID, a as UpdateClient, b as UpdateClientIdentifier } from './index-5Sj83ZJ4.mjs';
@@ -44,18 +44,14 @@ declare const UpdatePayment: (params: {
44
44
  payment: UpdatePaymentInput;
45
45
  tenantId?: string;
46
46
  }, Payment>;
47
- declare const GetPayments: (params?: {
47
+ declare const GetPayments: (params: PaymentFilters, configuration: {
48
48
  tenantId?: string;
49
- }) => {
50
- list: () => {
51
- where: (field: string) => {
52
- eq: (value: any) => /*elided*/ any;
53
- };
54
- limit: (value: number) => /*elided*/ any;
55
- offset: (value: number) => /*elided*/ any;
56
- execute: () => Command<any, PaymentResponse>;
49
+ }) => Command<{
50
+ params: PaymentFilters;
51
+ configuration: {
52
+ tenantId?: string;
57
53
  };
58
- };
54
+ }, PaymentResponse>;
59
55
 
60
56
  interface ApiError {
61
57
  name: string;
@@ -68,4 +64,4 @@ interface ApiError {
68
64
 
69
65
  declare const isCommandError: (error: unknown) => error is ApiError;
70
66
 
71
- export { Command, CreatePayment, CreatePaymentInput, GetPayment, GetPayments, type Logger, type MetricsClient, Middleware, Payment, PaymentResponse, UpdatePayment, UpdatePaymentInput, createLoggingMiddleware, createMetricsMiddleware, isCommandError };
67
+ export { Command, CreatePayment, CreatePaymentInput, GetPayment, GetPayments, type Logger, type MetricsClient, Middleware, Payment, PaymentFilters, PaymentResponse, UpdatePayment, UpdatePaymentInput, createLoggingMiddleware, createMetricsMiddleware, isCommandError };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CreatePaymentInput, P as Payment, U as UpdatePaymentInput, a as PaymentResponse } from './index-Dn5rWIBE.js';
2
- export { k as CreatePaymentInputZod, h as PaymentFilterKeyZod, f as PaymentFilters, n as PaymentFiltersZod, d as PaymentRailType, i as PaymentRailZod, m as PaymentResponseZod, b as PaymentStatus, g as PaymentStatusZod, e as PaymentType, j as PaymentTypeZod, S as SortOrderZod, l as UpdatePaymentInputZod, c as createClient } from './index-Dn5rWIBE.js';
1
+ import { C as CreatePaymentInput, P as Payment, U as UpdatePaymentInput, a as PaymentFilters, b as PaymentResponse } from './index-CDXiIoqN.js';
2
+ export { k as CreatePaymentInputZod, h as PaymentFilterKeyZod, o as PaymentFilterShape, n as PaymentFiltersZod, e as PaymentRailType, i as PaymentRailZod, m as PaymentResponseZod, d as PaymentStatus, g as PaymentStatusZod, f as PaymentType, j as PaymentTypeZod, S as SortOrderZod, l as UpdatePaymentInputZod, c as createClient } from './index-CDXiIoqN.js';
3
3
  import { M as Middleware, C as Command } from './config.d-CyK6ZM6s.js';
4
4
  export { a as Config } from './config.d-CyK6ZM6s.js';
5
5
  export { G as GetClientData, c as GraphQL, S as SendAuthorizationToCore, U as UpdateCardID, a as UpdateClient, b as UpdateClientIdentifier } from './index-DXK5OdKW.js';
@@ -44,18 +44,14 @@ declare const UpdatePayment: (params: {
44
44
  payment: UpdatePaymentInput;
45
45
  tenantId?: string;
46
46
  }, Payment>;
47
- declare const GetPayments: (params?: {
47
+ declare const GetPayments: (params: PaymentFilters, configuration: {
48
48
  tenantId?: string;
49
- }) => {
50
- list: () => {
51
- where: (field: string) => {
52
- eq: (value: any) => /*elided*/ any;
53
- };
54
- limit: (value: number) => /*elided*/ any;
55
- offset: (value: number) => /*elided*/ any;
56
- execute: () => Command<any, PaymentResponse>;
49
+ }) => Command<{
50
+ params: PaymentFilters;
51
+ configuration: {
52
+ tenantId?: string;
57
53
  };
58
- };
54
+ }, PaymentResponse>;
59
55
 
60
56
  interface ApiError {
61
57
  name: string;
@@ -68,4 +64,4 @@ interface ApiError {
68
64
 
69
65
  declare const isCommandError: (error: unknown) => error is ApiError;
70
66
 
71
- export { Command, CreatePayment, CreatePaymentInput, GetPayment, GetPayments, type Logger, type MetricsClient, Middleware, Payment, PaymentResponse, UpdatePayment, UpdatePaymentInput, createLoggingMiddleware, createMetricsMiddleware, isCommandError };
67
+ export { Command, CreatePayment, CreatePaymentInput, GetPayment, GetPayments, type Logger, type MetricsClient, Middleware, Payment, PaymentFilters, PaymentResponse, UpdatePayment, UpdatePaymentInput, createLoggingMiddleware, createMetricsMiddleware, isCommandError };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTL2MJ56Sjs = require('./chunk-TL2MJ56S.js');var _chunkBDI3SHA2js = require('./chunk-BDI3SHA2.js');var _chunkOGW7GTJPjs = require('./chunk-OGW7GTJP.js');var E=(t=console)=>({before:async e=>{t.info(`Executing ${e.metadata.commandName}`,{input:e.input,metadata:e.metadata})},after:async(e,a)=>{t.info(`Completed ${e.metadata.commandName}`,{response:a,metadata:e.metadata})},onError:async(e,a)=>{t.error(`Error in ${e.metadata.commandName}`,{error:a,input:e.input,metadata:e.metadata})}});var Z=t=>({before:async e=>{t.incrementCounter(`${e.metadata.commandName}_started`)},after:async e=>{t.incrementCounter(`${e.metadata.commandName}_completed`)},onError:async(e,a)=>{t.incrementCounter(`${e.metadata.commandName}_error`),t.recordError&&typeof t.recordError=="function"&&t.recordError(a)}});exports.CreatePayment = _chunkTL2MJ56Sjs.j; exports.CreatePaymentInputZod = _chunkTL2MJ56Sjs.g; exports.GetClientData = _chunkBDI3SHA2js.c; exports.GetPayment = _chunkTL2MJ56Sjs.k; exports.GetPayments = _chunkTL2MJ56Sjs.m; exports.GraphQL = _chunkBDI3SHA2js.f; exports.PaymentFilterKeyZod = _chunkTL2MJ56Sjs.a; exports.PaymentFiltersZod = _chunkTL2MJ56Sjs.f; exports.PaymentRailZod = _chunkTL2MJ56Sjs.c; exports.PaymentResponseZod = _chunkTL2MJ56Sjs.i; exports.PaymentStatusZod = _chunkTL2MJ56Sjs.b; exports.PaymentTypeZod = _chunkTL2MJ56Sjs.d; exports.SendAuthorizationToCore = _chunkBDI3SHA2js.a; exports.SortOrderZod = _chunkTL2MJ56Sjs.e; exports.UpdateCardID = _chunkBDI3SHA2js.b; exports.UpdateClient = _chunkBDI3SHA2js.d; exports.UpdateClientIdentifier = _chunkBDI3SHA2js.e; exports.UpdatePayment = _chunkTL2MJ56Sjs.l; exports.UpdatePaymentInputZod = _chunkTL2MJ56Sjs.h; exports.createClient = _chunkTL2MJ56Sjs.n; exports.createLoggingMiddleware = E; exports.createMetricsMiddleware = Z; exports.isCommandError = _chunkOGW7GTJPjs.b;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkSMOK4ASFjs = require('./chunk-SMOK4ASF.js');var _chunkBDI3SHA2js = require('./chunk-BDI3SHA2.js');var _chunkOGW7GTJPjs = require('./chunk-OGW7GTJP.js');var Z=(t=console)=>({before:async e=>{t.info(`Executing ${e.metadata.commandName}`,{input:e.input,metadata:e.metadata})},after:async(e,a)=>{t.info(`Completed ${e.metadata.commandName}`,{response:a,metadata:e.metadata})},onError:async(e,a)=>{t.error(`Error in ${e.metadata.commandName}`,{error:a,input:e.input,metadata:e.metadata})}});var I=t=>({before:async e=>{t.incrementCounter(`${e.metadata.commandName}_started`)},after:async e=>{t.incrementCounter(`${e.metadata.commandName}_completed`)},onError:async(e,a)=>{t.incrementCounter(`${e.metadata.commandName}_error`),t.recordError&&typeof t.recordError=="function"&&t.recordError(a)}});exports.CreatePayment = _chunkSMOK4ASFjs.k; exports.CreatePaymentInputZod = _chunkSMOK4ASFjs.h; exports.GetClientData = _chunkBDI3SHA2js.c; exports.GetPayment = _chunkSMOK4ASFjs.l; exports.GetPayments = _chunkSMOK4ASFjs.n; exports.GraphQL = _chunkBDI3SHA2js.f; exports.PaymentFilterKeyZod = _chunkSMOK4ASFjs.a; exports.PaymentFilterShape = _chunkSMOK4ASFjs.f; exports.PaymentFiltersZod = _chunkSMOK4ASFjs.g; exports.PaymentRailZod = _chunkSMOK4ASFjs.c; exports.PaymentResponseZod = _chunkSMOK4ASFjs.j; exports.PaymentStatusZod = _chunkSMOK4ASFjs.b; exports.PaymentTypeZod = _chunkSMOK4ASFjs.d; exports.SendAuthorizationToCore = _chunkBDI3SHA2js.a; exports.SortOrderZod = _chunkSMOK4ASFjs.e; exports.UpdateCardID = _chunkBDI3SHA2js.b; exports.UpdateClient = _chunkBDI3SHA2js.d; exports.UpdateClientIdentifier = _chunkBDI3SHA2js.e; exports.UpdatePayment = _chunkSMOK4ASFjs.m; exports.UpdatePaymentInputZod = _chunkSMOK4ASFjs.i; exports.createClient = _chunkSMOK4ASFjs.o; exports.createLoggingMiddleware = Z; exports.createMetricsMiddleware = I; exports.isCommandError = _chunkOGW7GTJPjs.b;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as n,b as o,c as m,d,e as i,f as p,g as s,h as y,i as c,j as P,k as f,l as u,m as g,n as l}from"./chunk-6YLCCDXD.mjs";import{a as x,b as C,c as S,d as w,e as M,f as h}from"./chunk-5PEETHWV.mjs";import{b as r}from"./chunk-RX3BFHHX.mjs";var E=(t=console)=>({before:async e=>{t.info(`Executing ${e.metadata.commandName}`,{input:e.input,metadata:e.metadata})},after:async(e,a)=>{t.info(`Completed ${e.metadata.commandName}`,{response:a,metadata:e.metadata})},onError:async(e,a)=>{t.error(`Error in ${e.metadata.commandName}`,{error:a,input:e.input,metadata:e.metadata})}});var Z=t=>({before:async e=>{t.incrementCounter(`${e.metadata.commandName}_started`)},after:async e=>{t.incrementCounter(`${e.metadata.commandName}_completed`)},onError:async(e,a)=>{t.incrementCounter(`${e.metadata.commandName}_error`),t.recordError&&typeof t.recordError=="function"&&t.recordError(a)}});export{P as CreatePayment,s as CreatePaymentInputZod,S as GetClientData,f as GetPayment,g as GetPayments,h as GraphQL,n as PaymentFilterKeyZod,p as PaymentFiltersZod,m as PaymentRailZod,c as PaymentResponseZod,o as PaymentStatusZod,d as PaymentTypeZod,x as SendAuthorizationToCore,i as SortOrderZod,C as UpdateCardID,w as UpdateClient,M as UpdateClientIdentifier,u as UpdatePayment,y as UpdatePaymentInputZod,l as createClient,E as createLoggingMiddleware,Z as createMetricsMiddleware,r as isCommandError};
1
+ import{a as n,b as o,c as m,d,e as i,f as p,g as s,h as y,i as c,j as P,k as f,l as u,m as g,n as l,o as x}from"./chunk-DVUWFF32.mjs";import{a as C,b as S,c as w,d as M,e as h,f as E}from"./chunk-5PEETHWV.mjs";import{b as r}from"./chunk-RX3BFHHX.mjs";var Z=(t=console)=>({before:async e=>{t.info(`Executing ${e.metadata.commandName}`,{input:e.input,metadata:e.metadata})},after:async(e,a)=>{t.info(`Completed ${e.metadata.commandName}`,{response:a,metadata:e.metadata})},onError:async(e,a)=>{t.error(`Error in ${e.metadata.commandName}`,{error:a,input:e.input,metadata:e.metadata})}});var I=t=>({before:async e=>{t.incrementCounter(`${e.metadata.commandName}_started`)},after:async e=>{t.incrementCounter(`${e.metadata.commandName}_completed`)},onError:async(e,a)=>{t.incrementCounter(`${e.metadata.commandName}_error`),t.recordError&&typeof t.recordError=="function"&&t.recordError(a)}});export{f as CreatePayment,y as CreatePaymentInputZod,w as GetClientData,u as GetPayment,l as GetPayments,E as GraphQL,n as PaymentFilterKeyZod,p as PaymentFilterShape,s as PaymentFiltersZod,m as PaymentRailZod,P as PaymentResponseZod,o as PaymentStatusZod,d as PaymentTypeZod,C as SendAuthorizationToCore,i as SortOrderZod,S as UpdateCardID,M as UpdateClient,h as UpdateClientIdentifier,g as UpdatePayment,c as UpdatePaymentInputZod,x as createClient,Z as createLoggingMiddleware,I as createMetricsMiddleware,r as isCommandError};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mbanq/core-sdk-js",
3
- "version": "1.0.0-alpha.10",
3
+ "version": "1.0.0-alpha.12",
4
4
  "description": "A comprehensive JavaScript SDK for interacting with the Mbanq payment API. Features type-safe payment operations, multi-tenant support, and Zod validation.",
5
5
  "main": "dist/index.js",
6
6
  "publishConfig": {
@@ -1 +0,0 @@
1
- import{a as m,c as y,d as u}from"./chunk-RX3BFHHX.mjs";var E=t=>{let n=[];if(!t.baseUrl)n.push("baseUrl is required");else if(typeof t.baseUrl!="string")n.push("baseUrl must be a string");else try{new URL(t.baseUrl)}catch{n.push("baseUrl must be a valid URL")}return t.axiosConfig?.timeout!==void 0&&(typeof t.axiosConfig.timeout!="number"||t.axiosConfig.timeout<0)&&n.push("timeout must be a positive number"),n};import{z as e}from"zod";var N=e.enum(["originatorName","originatorAccount","originatorBankRoutingCode","recipientName","recipientAccount","recipientBankRoutingCode","reference","traceNumber","externalId","clientId","dateFormat","locale","originatedBy","paymentRail","paymentType","fromValueDate","toValueDate","fromExecuteDate","toExecuteDate","status","fromReturnDate","toReturnDate","isSettlement","orderBy","sortOrder"]),f=e.enum(["DRAFT","AML_SCREENING","AML_REJECTED","EXECUTION_SCHEDULED","EXECUTION_PROCESSING","EXECUTION_SUCCESS","EXECUTION_FAILURE","RETURNED","CANCELLED","COMPLIANCE_FAILURE","DELETED","UNKNOWN"]),x=e.enum(["ACH","SAMEDAYACH","WIRE","SWIFT","INTERNAL","FXPAY","CARD"]),I=e.enum(["CREDIT","DEBIT"]),O=e.enum(["ASC","DESC"]),we=N.options,ke=f.options,Be=x.options,Ue=I.options,_e=O.options,w=t=>N.parse(t),k=t=>f.parse(t),B=t=>x.parse(t),U=t=>I.parse(t),_=t=>O.parse(t),F=e.string().min(1),L=e.string().min(1),z=e.string().min(1),V=e.string().min(1),j=e.string().min(1),$=e.string().min(1),M=e.string().min(1),G=e.string().min(1),q=e.string().min(1),K=e.union([e.string(),e.number()]),H=e.string(),Y=e.string(),W=e.string(),D=e.string(),T=e.string(),A=e.string(),X=e.boolean(),J=e.string(),Q=t=>F.parse(t),Z=t=>L.parse(t),ee=t=>z.parse(t),te=t=>V.parse(t),ne=t=>j.parse(t),ae=t=>$.parse(t),re=t=>M.parse(t),oe=t=>G.parse(t),ie=t=>q.parse(t),se=t=>K.parse(t),pe=t=>H.parse(t),ce=t=>Y.parse(t),me=t=>W.parse(t),de=t=>D.parse(t),ye=t=>T.parse(t),ue=t=>A.parse(t),le=t=>X.parse(t),ge=t=>J.parse(t),Fe=e.object({originatorName:F.optional(),originatorAccount:L.optional(),originatorBankRoutingCode:z.optional(),recipientName:V.optional(),recipientAccount:j.optional(),recipientBankRoutingCode:$.optional(),reference:M.optional(),traceNumber:G.optional(),externalId:q.optional(),clientId:K.optional(),dateFormat:H.optional(),locale:Y.optional(),originatedBy:W.optional(),paymentRail:x.optional(),paymentType:I.optional(),fromValueDate:D.optional(),toValueDate:D.optional(),fromExecuteDate:T.optional(),toExecuteDate:T.optional(),status:f.optional(),fromReturnDate:A.optional(),toReturnDate:A.optional(),isSettlement:X.optional(),orderBy:J.optional(),sortOrder:O.optional(),limit:e.number().positive().optional(),offset:e.number().min(0).optional()}).partial();var fe=e.object({id:e.number(),clientId:e.number(),amount:e.number().positive(),correlationId:e.string(),paymentType:I,paymentRail:x,recipient:e.object({cardId:e.string().optional(),recipientType:e.string(),address:e.object({line1:e.string().optional(),line2:e.string().optional(),stateCode:e.string().optional(),countryCode:e.string(),postalCode:e.string().optional()}),name:e.string()}),originator:e.object({accountId:e.string().optional(),recipientType:e.string(),address:e.object({line1:e.string().optional(),line2:e.string().optional(),stateCode:e.string().optional(),countryCode:e.string(),postalCode:e.string().optional()}),name:e.string()}),executedAt:e.string(),createdAt:e.string(),externalId:e.string(),status:f,paymentRailMetaData:e.record(e.string(),e.any()).optional(),currencyData:e.object({code:e.string(),name:e.string(),decimalPlaces:e.number(),displaySymbol:e.string(),nameCode:e.string(),currencyCodeInDigit:e.number(),isBaseCurrency:e.boolean()}),currency:e.string().min(3).max(3)}).catchall(e.any()),xe=e.object({streetAddress:e.string().optional(),city:e.string().optional(),state:e.string().optional(),country:e.string().optional(),postalCode:e.string().optional()}).optional(),Ee=e.object({name:e.string().optional(),identifier:e.string().optional(),address:xe}).optional(),v=e.object({name:e.string(),identifier:e.string(),accountType:e.enum(["CHECKING","SAVINGS"]).optional(),address:xe,agent:Ee}),ve=e.object({amount:e.number().positive(),currency:e.string().min(3).max(3),paymentRail:x,paymentType:I,debtor:v,creditor:v,clientId:e.string().optional(),correspondent:v.optional(),exchangeRate:e.number().positive().optional(),externalId:e.string().optional(),reference:e.union([e.string(),e.array(e.string())]).optional(),paymentRailMetaData:e.record(e.string(),e.any()).optional(),chargeBearer:e.enum(["OUR","BEN","SHA"]).optional(),purposeCode:e.string().optional(),valueDate:e.string().optional(),executionDate:e.string().optional()}).catchall(e.any()).refine(t=>(t.paymentRail==="WIRE"||t.paymentRail==="SWIFT")&&t.creditor?t.creditor.address&&t.creditor.address.state&&t.creditor.address.country:!0,{message:"For WIRE transfers, recipient address with state and country is mandatory"}),De=e.object({amount:e.number().positive().optional(),correspondent:e.object({name:e.string().optional(),identifier:e.string().optional(),accountType:e.string().optional()}).optional(),creditor:e.object({name:e.string().optional(),identifier:e.string().optional(),accountType:e.string().optional(),agent:e.object({name:e.string().optional(),identifier:e.string().optional()}).optional()}).optional(),debtor:e.object({name:e.string().optional(),identifier:e.string().optional(),accountType:e.string().optional(),agent:e.object({name:e.string().optional(),identifier:e.string().optional()}).optional()}).optional(),exchangeRate:e.number().positive().optional(),externalId:e.string().optional(),errorCode:e.string().optional(),errorMessage:e.string().optional(),reference:e.union([e.string(),e.array(e.string())]).optional(),paymentRailMetaData:e.record(e.string(),e.any()).optional(),status:f.optional()}).catchall(e.any()),Le=e.object({totalFilteredRecords:e.number(),pageItems:e.array(fe)}),C=t=>fe.parse(t),Ie=t=>ve.parse(t),he=t=>De.parse(t);import{ZodError as S}from"zod";var Te=t=>{try{w(t)}catch(n){throw n instanceof S?m({message:`Invalid filter key: '${t}'. ${n.message}`,code:"invalid_filter_key"}):n}},Ae=(t,n)=>{try{switch(t){case"status":k(n);break;case"paymentRail":B(n);break;case"paymentType":U(n);break;case"sortOrder":_(n);break;case"originatorName":Q(n);break;case"originatorAccount":Z(n);break;case"originatorBankRoutingCode":ee(n);break;case"recipientName":te(n);break;case"recipientAccount":ne(n);break;case"recipientBankRoutingCode":ae(n);break;case"reference":re(n);break;case"traceNumber":oe(n);break;case"externalId":ie(n);break;case"clientId":se(n);break;case"dateFormat":pe(n);break;case"locale":ce(n);break;case"originatedBy":me(n);break;case"fromValueDate":case"toValueDate":de(n);break;case"fromExecuteDate":case"toExecuteDate":ye(n);break;case"fromReturnDate":case"toReturnDate":ue(n);break;case"isSettlement":le(n);break;case"orderBy":ge(n);break;default:break}}catch(o){throw o instanceof S?m({message:`Invalid value for '${t}': '${n}'. ${o.message}`,code:`invalid_${t}_value`}):o}},Ce=t=>({input:t,metadata:{commandName:"CreatePayment",path:"/v1/payments",method:"POST"},execute:async n=>{try{Ie(t.payment)}catch(a){throw a instanceof S?m({message:`Invalid payment data: ${a.message}`,code:"invalid_payment_input"}):a}t.tenantId&&(n.tenantId=t.tenantId);let o=await u(n);try{let a=await o.post("/v1/payments",t.payment);return C(a.data)}catch(a){y(a)}}}),Re=t=>({input:t,metadata:{commandName:"GetPayment",path:`/v1/payments/${t.id}`,method:"GET"},execute:async n=>{t.tenantId&&(n.tenantId=t.tenantId);let o=await u(n);try{let a=await o.get(`/v1/payments/${t.id}`);return C(a.data)}catch(a){y(a)}}}),Se=t=>({input:t,metadata:{commandName:"UpdatePayment",path:`/v1/payments/${t.id}`,method:"PUT"},execute:async n=>{try{he(t.payment)}catch(a){throw a instanceof S?m({message:`Invalid payment update data: ${a.message}`,code:"invalid_payment_update_input"}):a}t.tenantId&&(n.tenantId=t.tenantId);let o=await u(n);try{let a=await o.put(`/v1/payments/${t.id}`,t.payment);return C(a.data)}catch(a){y(a)}}}),R=(t,n,o,a)=>({where:c=>(Te(c),{eq:r=>(Ae(c,r),R({...t,[c]:r},n,o,a))}),limit:c=>R(t,c,o,a),offset:c=>R(t,n,c,a),execute:()=>{let c={...t,limit:n||200,offset:o||0};return{input:{filters:t,limit:n,offset:o,tenantId:a},metadata:{commandName:"GetPayments",path:"/v1/payments",method:"GET"},execute:async r=>{a&&(r.tenantId=a);let i=await u(r);try{return(await i.get("/v1/payments",{params:c})).data}catch(s){y(s)}}}}}),be=t=>({list:()=>R({},void 0,void 0,t?.tenantId)}),Pe=t=>({input:t,metadata:{commandName:"DeletePayment",path:`/v1/payments/${t.id}`,method:"DELETE"},execute:async n=>{t.tenantId&&(n.tenantId=t.tenantId);let o=await u(n);try{await o.delete(`/v1/payments/${t.id}`)}catch(a){y(a)}}});var Ye=t=>{let n=E(t);if(n.length>0)throw m({message:`Invalid configuration: ${n.join(", ")}`,code:"invalid_config"});let o=async(r,i,s)=>{if(t.middlewares)for(let p of t.middlewares)r==="before"&&p.before?await p.before(i):r==="after"&&p.after?await p.after(i,s):r==="onError"&&p.onError&&await p.onError(i,s)},a={...t},d=async r=>{try{await o("before",r);let i=await r.execute(a);return await o("after",r,i),i}catch(i){throw await o("onError",r,i),i}},b=r=>{let i=r||a.tenantId;return{payment:{create:s=>{let p=Ce({payment:s,tenantId:i});return{execute:async()=>d(p)}},get:s=>{let p=Re({id:s,tenantId:i});return{execute:async()=>d(p)}},update:(s,p)=>{let l=Se({id:s,payment:p,tenantId:i});return{execute:async()=>d(l)}},delete:s=>{let p=Pe({id:s,tenantId:i});return{execute:async()=>d(p)}},list:()=>{let p=be({tenantId:i}).list(),l=h=>({where:h.where,limit:g=>{let P=h.limit(g);return l(P)},offset:g=>{let P=h.offset(g);return l(P)},execute:async()=>{let g=h.execute();return d(g)}});return l(p)}}}};return{setConfig:r=>{a=r},updateConfig:r=>{let i={...a,...r,axiosConfig:{...a.axiosConfig,...r.axiosConfig,headers:{...a.axiosConfig?.headers,...r.axiosConfig?.headers}}},s=E(i);if(s.length>0)throw m({message:`Invalid configuration: ${s.join(", ")}`,code:"invalid_config"});a=i},resetConfig:()=>{a=t},request:d,tenant:r=>b(r),...b()}};export{N as a,f as b,x as c,I as d,O as e,Fe as f,ve as g,De as h,Le as i,Ce as j,Re as k,Se as l,be as m,Ye as n};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkOGW7GTJPjs = require('./chunk-OGW7GTJP.js');var E=t=>{let n=[];if(!t.baseUrl)n.push("baseUrl is required");else if(typeof t.baseUrl!="string")n.push("baseUrl must be a string");else try{new URL(t.baseUrl)}catch (e2){n.push("baseUrl must be a valid URL")}return _optionalChain([t, 'access', _2 => _2.axiosConfig, 'optionalAccess', _3 => _3.timeout])!==void 0&&(typeof t.axiosConfig.timeout!="number"||t.axiosConfig.timeout<0)&&n.push("timeout must be a positive number"),n};var _zod = require('zod');var N=_zod.z.enum(["originatorName","originatorAccount","originatorBankRoutingCode","recipientName","recipientAccount","recipientBankRoutingCode","reference","traceNumber","externalId","clientId","dateFormat","locale","originatedBy","paymentRail","paymentType","fromValueDate","toValueDate","fromExecuteDate","toExecuteDate","status","fromReturnDate","toReturnDate","isSettlement","orderBy","sortOrder"]),f= exports.b =_zod.z.enum(["DRAFT","AML_SCREENING","AML_REJECTED","EXECUTION_SCHEDULED","EXECUTION_PROCESSING","EXECUTION_SUCCESS","EXECUTION_FAILURE","RETURNED","CANCELLED","COMPLIANCE_FAILURE","DELETED","UNKNOWN"]),x= exports.c =_zod.z.enum(["ACH","SAMEDAYACH","WIRE","SWIFT","INTERNAL","FXPAY","CARD"]),I= exports.d =_zod.z.enum(["CREDIT","DEBIT"]),O= exports.e =_zod.z.enum(["ASC","DESC"]),we=N.options,ke=f.options,Be=x.options,Ue=I.options,_e=O.options,w=t=>N.parse(t),k=t=>f.parse(t),B=t=>x.parse(t),U=t=>I.parse(t),_=t=>O.parse(t),F=_zod.z.string().min(1),L=_zod.z.string().min(1),z=_zod.z.string().min(1),V=_zod.z.string().min(1),j=_zod.z.string().min(1),$=_zod.z.string().min(1),M=_zod.z.string().min(1),G=_zod.z.string().min(1),q=_zod.z.string().min(1),K=_zod.z.union([_zod.z.string(),_zod.z.number()]),H=_zod.z.string(),Y=_zod.z.string(),W=_zod.z.string(),D=_zod.z.string(),T=_zod.z.string(),A=_zod.z.string(),X=_zod.z.boolean(),J=_zod.z.string(),Q=t=>F.parse(t),Z=t=>L.parse(t),ee=t=>z.parse(t),te=t=>V.parse(t),ne=t=>j.parse(t),ae=t=>$.parse(t),re=t=>M.parse(t),oe=t=>G.parse(t),ie=t=>q.parse(t),se=t=>K.parse(t),pe=t=>H.parse(t),ce=t=>Y.parse(t),me=t=>W.parse(t),de=t=>D.parse(t),ye=t=>T.parse(t),ue=t=>A.parse(t),le=t=>X.parse(t),ge=t=>J.parse(t),Fe= exports.f =_zod.z.object({originatorName:F.optional(),originatorAccount:L.optional(),originatorBankRoutingCode:z.optional(),recipientName:V.optional(),recipientAccount:j.optional(),recipientBankRoutingCode:$.optional(),reference:M.optional(),traceNumber:G.optional(),externalId:q.optional(),clientId:K.optional(),dateFormat:H.optional(),locale:Y.optional(),originatedBy:W.optional(),paymentRail:x.optional(),paymentType:I.optional(),fromValueDate:D.optional(),toValueDate:D.optional(),fromExecuteDate:T.optional(),toExecuteDate:T.optional(),status:f.optional(),fromReturnDate:A.optional(),toReturnDate:A.optional(),isSettlement:X.optional(),orderBy:J.optional(),sortOrder:O.optional(),limit:_zod.z.number().positive().optional(),offset:_zod.z.number().min(0).optional()}).partial();var fe=_zod.z.object({id:_zod.z.number(),clientId:_zod.z.number(),amount:_zod.z.number().positive(),correlationId:_zod.z.string(),paymentType:I,paymentRail:x,recipient:_zod.z.object({cardId:_zod.z.string().optional(),recipientType:_zod.z.string(),address:_zod.z.object({line1:_zod.z.string().optional(),line2:_zod.z.string().optional(),stateCode:_zod.z.string().optional(),countryCode:_zod.z.string(),postalCode:_zod.z.string().optional()}),name:_zod.z.string()}),originator:_zod.z.object({accountId:_zod.z.string().optional(),recipientType:_zod.z.string(),address:_zod.z.object({line1:_zod.z.string().optional(),line2:_zod.z.string().optional(),stateCode:_zod.z.string().optional(),countryCode:_zod.z.string(),postalCode:_zod.z.string().optional()}),name:_zod.z.string()}),executedAt:_zod.z.string(),createdAt:_zod.z.string(),externalId:_zod.z.string(),status:f,paymentRailMetaData:_zod.z.record(_zod.z.string(),_zod.z.any()).optional(),currencyData:_zod.z.object({code:_zod.z.string(),name:_zod.z.string(),decimalPlaces:_zod.z.number(),displaySymbol:_zod.z.string(),nameCode:_zod.z.string(),currencyCodeInDigit:_zod.z.number(),isBaseCurrency:_zod.z.boolean()}),currency:_zod.z.string().min(3).max(3)}).catchall(_zod.z.any()),xe=_zod.z.object({streetAddress:_zod.z.string().optional(),city:_zod.z.string().optional(),state:_zod.z.string().optional(),country:_zod.z.string().optional(),postalCode:_zod.z.string().optional()}).optional(),Ee=_zod.z.object({name:_zod.z.string().optional(),identifier:_zod.z.string().optional(),address:xe}).optional(),v=_zod.z.object({name:_zod.z.string(),identifier:_zod.z.string(),accountType:_zod.z.enum(["CHECKING","SAVINGS"]).optional(),address:xe,agent:Ee}),ve= exports.g =_zod.z.object({amount:_zod.z.number().positive(),currency:_zod.z.string().min(3).max(3),paymentRail:x,paymentType:I,debtor:v,creditor:v,clientId:_zod.z.string().optional(),correspondent:v.optional(),exchangeRate:_zod.z.number().positive().optional(),externalId:_zod.z.string().optional(),reference:_zod.z.union([_zod.z.string(),_zod.z.array(_zod.z.string())]).optional(),paymentRailMetaData:_zod.z.record(_zod.z.string(),_zod.z.any()).optional(),chargeBearer:_zod.z.enum(["OUR","BEN","SHA"]).optional(),purposeCode:_zod.z.string().optional(),valueDate:_zod.z.string().optional(),executionDate:_zod.z.string().optional()}).catchall(_zod.z.any()).refine(t=>(t.paymentRail==="WIRE"||t.paymentRail==="SWIFT")&&t.creditor?t.creditor.address&&t.creditor.address.state&&t.creditor.address.country:!0,{message:"For WIRE transfers, recipient address with state and country is mandatory"}),De= exports.h =_zod.z.object({amount:_zod.z.number().positive().optional(),correspondent:_zod.z.object({name:_zod.z.string().optional(),identifier:_zod.z.string().optional(),accountType:_zod.z.string().optional()}).optional(),creditor:_zod.z.object({name:_zod.z.string().optional(),identifier:_zod.z.string().optional(),accountType:_zod.z.string().optional(),agent:_zod.z.object({name:_zod.z.string().optional(),identifier:_zod.z.string().optional()}).optional()}).optional(),debtor:_zod.z.object({name:_zod.z.string().optional(),identifier:_zod.z.string().optional(),accountType:_zod.z.string().optional(),agent:_zod.z.object({name:_zod.z.string().optional(),identifier:_zod.z.string().optional()}).optional()}).optional(),exchangeRate:_zod.z.number().positive().optional(),externalId:_zod.z.string().optional(),errorCode:_zod.z.string().optional(),errorMessage:_zod.z.string().optional(),reference:_zod.z.union([_zod.z.string(),_zod.z.array(_zod.z.string())]).optional(),paymentRailMetaData:_zod.z.record(_zod.z.string(),_zod.z.any()).optional(),status:f.optional()}).catchall(_zod.z.any()),Le= exports.i =_zod.z.object({totalFilteredRecords:_zod.z.number(),pageItems:_zod.z.array(fe)}),C=t=>fe.parse(t),Ie=t=>ve.parse(t),he=t=>De.parse(t);var Te=t=>{try{w(t)}catch(n){throw n instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid filter key: '${t}'. ${n.message}`,code:"invalid_filter_key"}):n}},Ae=(t,n)=>{try{switch(t){case"status":k(n);break;case"paymentRail":B(n);break;case"paymentType":U(n);break;case"sortOrder":_(n);break;case"originatorName":Q(n);break;case"originatorAccount":Z(n);break;case"originatorBankRoutingCode":ee(n);break;case"recipientName":te(n);break;case"recipientAccount":ne(n);break;case"recipientBankRoutingCode":ae(n);break;case"reference":re(n);break;case"traceNumber":oe(n);break;case"externalId":ie(n);break;case"clientId":se(n);break;case"dateFormat":pe(n);break;case"locale":ce(n);break;case"originatedBy":me(n);break;case"fromValueDate":case"toValueDate":de(n);break;case"fromExecuteDate":case"toExecuteDate":ye(n);break;case"fromReturnDate":case"toReturnDate":ue(n);break;case"isSettlement":le(n);break;case"orderBy":ge(n);break;default:break}}catch(o){throw o instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid value for '${t}': '${n}'. ${o.message}`,code:`invalid_${t}_value`}):o}},Ce= exports.j =t=>({input:t,metadata:{commandName:"CreatePayment",path:"/v1/payments",method:"POST"},execute:async n=>{try{Ie(t.payment)}catch(a){throw a instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid payment data: ${a.message}`,code:"invalid_payment_input"}):a}t.tenantId&&(n.tenantId=t.tenantId);let o=await _chunkOGW7GTJPjs.d.call(void 0, n);try{let a=await o.post("/v1/payments",t.payment);return C(a.data)}catch(a){_chunkOGW7GTJPjs.c.call(void 0, a)}}}),Re= exports.k =t=>({input:t,metadata:{commandName:"GetPayment",path:`/v1/payments/${t.id}`,method:"GET"},execute:async n=>{t.tenantId&&(n.tenantId=t.tenantId);let o=await _chunkOGW7GTJPjs.d.call(void 0, n);try{let a=await o.get(`/v1/payments/${t.id}`);return C(a.data)}catch(a){_chunkOGW7GTJPjs.c.call(void 0, a)}}}),Se= exports.l =t=>({input:t,metadata:{commandName:"UpdatePayment",path:`/v1/payments/${t.id}`,method:"PUT"},execute:async n=>{try{he(t.payment)}catch(a){throw a instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid payment update data: ${a.message}`,code:"invalid_payment_update_input"}):a}t.tenantId&&(n.tenantId=t.tenantId);let o=await _chunkOGW7GTJPjs.d.call(void 0, n);try{let a=await o.put(`/v1/payments/${t.id}`,t.payment);return C(a.data)}catch(a){_chunkOGW7GTJPjs.c.call(void 0, a)}}}),R=(t,n,o,a)=>({where:c=>(Te(c),{eq:r=>(Ae(c,r),R({...t,[c]:r},n,o,a))}),limit:c=>R(t,c,o,a),offset:c=>R(t,n,c,a),execute:()=>{let c={...t,limit:n||200,offset:o||0};return{input:{filters:t,limit:n,offset:o,tenantId:a},metadata:{commandName:"GetPayments",path:"/v1/payments",method:"GET"},execute:async r=>{a&&(r.tenantId=a);let i=await _chunkOGW7GTJPjs.d.call(void 0, r);try{return(await i.get("/v1/payments",{params:c})).data}catch(s){_chunkOGW7GTJPjs.c.call(void 0, s)}}}}}),be= exports.m =t=>({list:()=>R({},void 0,void 0,_optionalChain([t, 'optionalAccess', _4 => _4.tenantId]))}),Pe=t=>({input:t,metadata:{commandName:"DeletePayment",path:`/v1/payments/${t.id}`,method:"DELETE"},execute:async n=>{t.tenantId&&(n.tenantId=t.tenantId);let o=await _chunkOGW7GTJPjs.d.call(void 0, n);try{await o.delete(`/v1/payments/${t.id}`)}catch(a){_chunkOGW7GTJPjs.c.call(void 0, a)}}});var Ye=t=>{let n=E(t);if(n.length>0)throw _chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid configuration: ${n.join(", ")}`,code:"invalid_config"});let o=async(r,i,s)=>{if(t.middlewares)for(let p of t.middlewares)r==="before"&&p.before?await p.before(i):r==="after"&&p.after?await p.after(i,s):r==="onError"&&p.onError&&await p.onError(i,s)},a={...t},d=async r=>{try{await o("before",r);let i=await r.execute(a);return await o("after",r,i),i}catch(i){throw await o("onError",r,i),i}},b=r=>{let i=r||a.tenantId;return{payment:{create:s=>{let p=Ce({payment:s,tenantId:i});return{execute:async()=>d(p)}},get:s=>{let p=Re({id:s,tenantId:i});return{execute:async()=>d(p)}},update:(s,p)=>{let l=Se({id:s,payment:p,tenantId:i});return{execute:async()=>d(l)}},delete:s=>{let p=Pe({id:s,tenantId:i});return{execute:async()=>d(p)}},list:()=>{let p=be({tenantId:i}).list(),l=h=>({where:h.where,limit:g=>{let P=h.limit(g);return l(P)},offset:g=>{let P=h.offset(g);return l(P)},execute:async()=>{let g=h.execute();return d(g)}});return l(p)}}}};return{setConfig:r=>{a=r},updateConfig:r=>{let i={...a,...r,axiosConfig:{...a.axiosConfig,...r.axiosConfig,headers:{..._optionalChain([a, 'access', _5 => _5.axiosConfig, 'optionalAccess', _6 => _6.headers]),..._optionalChain([r, 'access', _7 => _7.axiosConfig, 'optionalAccess', _8 => _8.headers])}}},s=E(i);if(s.length>0)throw _chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid configuration: ${s.join(", ")}`,code:"invalid_config"});a=i},resetConfig:()=>{a=t},request:d,tenant:r=>b(r),...b()}};exports.a = N; exports.b = f; exports.c = x; exports.d = I; exports.e = O; exports.f = Fe; exports.g = ve; exports.h = De; exports.i = Le; exports.j = Ce; exports.k = Re; exports.l = Se; exports.m = be; exports.n = Ye;