@mbanq/core-sdk-js 1.0.0-alpha.11 → 1.0.0-alpha.13

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/README.md CHANGED
@@ -40,47 +40,42 @@ npm install @mbanq/core-sdk-js
40
40
 
41
41
  ## Quick Start
42
42
 
43
+ Choose your preferred API pattern:
44
+
45
+ ### Modern Fluent API
43
46
  ```javascript
44
- import { createClient } from '@mbanq/core-sdk-js';
47
+ import { CoreSDK } from '@zacbank/core-sdk-js';
45
48
 
46
- // Initialize the client
47
- const apiClient = createClient({
48
- secret: 'your-api-secret',
49
- signee: 'YOUR-SIGNEE',
50
- baseUrl: 'https://api.cloud.mbanq.com',
51
- tenantId: 'your-tenant-id'
49
+ const coreSDK = new CoreSDK({
50
+ sandbox: true,
51
+ apiKey: 'your-api-key',
52
+ apiVersion: 'v2'
52
53
  });
53
54
 
54
- // Create a payment
55
- const payment = await apiClient.payment.create({
56
- amount: 1000,
55
+ // Create payment using fluent API
56
+ const payment = await coreSDK.payment.create({
57
+ amount: 100.00,
57
58
  currency: 'USD',
58
- paymentRail: 'ACH',
59
- paymentType: 'CREDIT',
60
- debtor: {
61
- name: 'John Sender',
62
- identifier: '123456789',
63
- agent: {
64
- name: 'First Bank',
65
- identifier: '021000021'
66
- }
67
- },
68
- creditor: {
69
- name: 'Jane Receiver',
70
- identifier: '987654321',
71
- agent: {
72
- name: 'Second Bank',
73
- identifier: '121000248'
74
- }
75
- }
59
+ description: 'Payment for invoice #123'
60
+ }).execute();
61
+ ```
62
+
63
+ ### Command Pattern
64
+ ```javascript
65
+ import { CoreSDK, GetTransfers } from '@zacbank/core-sdk-js';
66
+
67
+ const coreSDK = new CoreSDK({
68
+ sandbox: true,
69
+ apiKey: 'your-api-key',
70
+ apiVersion: 'v2'
76
71
  });
77
72
 
78
- // List payments with filtering
79
- const payments = await apiClient.payment.list()
80
- .where('status').eq('DRAFT')
81
- .where('paymentRail').eq('ACH')
82
- .limit(10)
83
- .execute();
73
+ // Get transfers using command pattern
74
+ const command = GetTransfers({
75
+ transferStatus: 'EXECUTION_SCHEDULED',
76
+ tenantId: 'default'
77
+ });
78
+ const transfers = await coreSDK.request(command);
84
79
  ```
85
80
 
86
81
  ## Setup
@@ -341,6 +336,117 @@ const client = createClient({
341
336
 
342
337
  ## API Reference
343
338
 
339
+ The SDK provides two API patterns for different operations:
340
+
341
+ ### Modern Fluent API (Recommended)
342
+ For payment operations, use the modern fluent API with method chaining:
343
+
344
+ ```javascript
345
+ // Create payment
346
+ const payment = await apiClient.payment.create(paymentData).execute();
347
+
348
+ // Get payment
349
+ const payment = await apiClient.payment.get('payment-456').execute();
350
+
351
+ // List with filters
352
+ const payments = await apiClient.payment.list()
353
+ .where('status').eq('DRAFT')
354
+ .where('paymentRail').eq('ACH')
355
+ .execute();
356
+ ```
357
+
358
+ ### Command Pattern (Legacy Support)
359
+ For transfer operations, the SDK also supports the traditional command pattern:
360
+
361
+ ```javascript
362
+ // Get transfers with filters
363
+ const getTransfersCommand = GetTransfers({
364
+ transferStatus: 'EXECUTION_SCHEDULED',
365
+ executedAt: '2025-01-22',
366
+ paymentType: 'ACH',
367
+ queryLimit: 200,
368
+ tenantId: 'default'
369
+ });
370
+ const transfers = await coreSDK.request(getTransfersCommand);
371
+
372
+ // Create a new transfer
373
+ const createTransferCommand = CreateTransfer({
374
+ amount: 1000,
375
+ currency: 'USD',
376
+ paymentRail: 'ACH',
377
+ paymentType: 'CREDIT',
378
+ debtor: {
379
+ name: 'Sender Name',
380
+ identifier: '123456789',
381
+ agent: { name: 'Bank Name', identifier: '021000021' }
382
+ },
383
+ creditor: {
384
+ name: 'Recipient Name',
385
+ identifier: '987654321',
386
+ agent: { name: 'Recipient Bank', identifier: '121000248' }
387
+ },
388
+ tenantId: 'default'
389
+ });
390
+ const newTransfer = await coreSDK.request(createTransferCommand);
391
+
392
+ // Get specific transfer by ID
393
+ const getTransferCommand = GetTransfer({
394
+ transferId: 'transfer-123',
395
+ tenantId: 'default'
396
+ });
397
+ const transfer = await coreSDK.request(getTransferCommand);
398
+
399
+ // Mark transfer as successful
400
+ const markSuccessCommand = MarkAsSuccess({
401
+ transferId: 'transfer-123',
402
+ tenantId: 'default'
403
+ });
404
+ await coreSDK.request(markSuccessCommand);
405
+
406
+ // Mark transfer as processing
407
+ const markProcessingCommand = MarkAsProcessing({
408
+ transferId: 'transfer-123',
409
+ tenantId: 'default'
410
+ });
411
+ await coreSDK.request(markProcessingCommand);
412
+
413
+ // Mark transfer as returned
414
+ const markReturnedCommand = MarkAsReturned({
415
+ transferId: 'transfer-123',
416
+ returnCode: 'R01',
417
+ returnReason: 'Insufficient funds',
418
+ tenantId: 'default'
419
+ });
420
+ await coreSDK.request(markReturnedCommand);
421
+
422
+ // Log failed transfer
423
+ const logFailCommand = LogFailTransfer({
424
+ transferId: 'transfer-123',
425
+ errorCode: 'E001',
426
+ errorMessage: 'Processing error',
427
+ tenantId: 'default'
428
+ });
429
+ await coreSDK.request(logFailCommand);
430
+
431
+ // Mark transfer as failed
432
+ const markFailCommand = MarkAsFail({
433
+ transferId: 'transfer-123',
434
+ failureReason: 'Bank rejected',
435
+ tenantId: 'default'
436
+ });
437
+ await coreSDK.request(markFailCommand);
438
+
439
+ // Update trace number
440
+ const updateTraceCommand = UpdateTraceNumber({
441
+ transferId: 'transfer-123',
442
+ traceNumber: 'TRC123456789',
443
+ tenantId: 'default'
444
+ });
445
+ await coreSDK.request(updateTraceCommand);
446
+ ```
447
+
448
+ Available transfer commands: `GetTransfers`, `CreateTransfer`, `GetTransfer`, `MarkAsSuccess`, `MarkAsProcessing`, `MarkAsReturned`, `LogFailTransfer`, `MarkAsFail`, `UpdateTraceNumber`
449
+
344
450
  ### Payment Operations
345
451
 
346
452
  #### Create Payment
@@ -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"]),_e=O.options,ze=h.options,Ve=P.options,je=C.options,$e=w.options,N=t=>O.parse(t),k=t=>h.parse(t),B=t=>P.parse(t),U=t=>C.parse(t),F=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()},Me=e.object(De).partial();var Ae={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)},fe=e.object(Ae).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(),Te=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:Te}),we={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()},Oe=e.object(we).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"}),Ne={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()},ke=e.object(Ne).catchall(e.any()),Ge=e.object({totalFilteredRecords:e.number(),pageItems:e.array(fe)}),S=t=>fe.parse(t),Ie=t=>Oe.parse(t),he=t=>ke.parse(t);import{ZodError as b}from"zod";var Be=t=>{try{N(t)}catch(n){throw n instanceof b?y({message:`Invalid filter key: '${t}'. ${n.message}`,code:"invalid_filter_key"}):n}},Ue=(t,n)=>{try{switch(t){case"status":k(n);break;case"paymentRail":B(n);break;case"paymentType":U(n);break;case"sortOrder":F(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=>(Be(c),{eq:o=>(Ue(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)}),Xe=(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 tt=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,Me as g,Ae as h,we as i,Oe as j,Ne as k,ke as l,Ge as m,Pe as n,Ce as o,Re as p,Xe as q,tt as r};
@@ -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"]),_e=O.options,ze=h.options,Ve=P.options,je=C.options,$e=w.options,N=t=>O.parse(t),k=t=>h.parse(t),B=t=>P.parse(t),U=t=>C.parse(t),F=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()},Me= exports.g =_zod.z.object(De).partial();var Ae={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)},fe=_zod.z.object(Ae).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(),Te=_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:Te}),we= exports.i ={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()},Oe= exports.j =_zod.z.object(we).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"}),Ne= exports.k ={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()},ke= exports.l =_zod.z.object(Ne).catchall(_zod.z.any()),Ge= exports.m =_zod.z.object({totalFilteredRecords:_zod.z.number(),pageItems:_zod.z.array(fe)}),S=t=>fe.parse(t),Ie=t=>Oe.parse(t),he=t=>ke.parse(t);var Be=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}},Ue=(t,n)=>{try{switch(t){case"status":k(n);break;case"paymentRail":B(n);break;case"paymentType":U(n);break;case"sortOrder":F(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.n =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.o =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.p =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=>(Be(c),{eq:o=>(Ue(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]))}),Xe= exports.q =(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 tt=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 = Me; exports.h = Ae; exports.i = we; exports.j = Oe; exports.k = Ne; exports.l = ke; exports.m = Ge; exports.n = Pe; exports.o = Ce; exports.p = Re; exports.q = Xe; exports.r = tt;
@@ -1,5 +1,5 @@
1
1
  import 'zod';
2
2
  import '../config.d-CyK6ZM6s.mjs';
3
- export { c as createClient } from '../index-DR1B_Zgp.mjs';
3
+ export { c as createClient } from '../index-DvE2ddFU.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-DN96wLIt.js';
3
+ export { c as createClient } from '../index-vaBvDmsq.js';
4
4
  import 'graphql';
5
5
  import 'axios';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkDOV4J2LBjs = require('../chunk-DOV4J2LB.js');require('../chunk-OGW7GTJP.js');exports.createClient = _chunkDOV4J2LBjs.o;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZTU6WB3Tjs = require('../chunk-ZTU6WB3T.js');require('../chunk-OGW7GTJP.js');exports.createClient = _chunkZTU6WB3Tjs.r;
@@ -1 +1 @@
1
- import{o as a}from"../chunk-3RTZWSKG.mjs";import"../chunk-RX3BFHHX.mjs";export{a as createClient};
1
+ import{r as a}from"../chunk-GZY2CY5Q.mjs";import"../chunk-RX3BFHHX.mjs";export{a as createClient};