@mbanq/core-sdk-js 1.0.0-alpha.6 → 1.0.0-alpha.8

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
@@ -1,25 +1,34 @@
1
+ <p align="center">
2
+ <img src="https://avatars.githubusercontent.com/u/26124358?s=200&v=4" alt="Mbanq Logo" width="120"/>
3
+ </p>
4
+
1
5
  # Core SDK JS
6
+
7
+ ![npm version](https://img.shields.io/npm/v/@mbanq/core-sdk-js.svg)
8
+ [![Download](https://img.shields.io/npm/dm/@mbanq/core-sdk-js)](https://www.npmjs.com/package/@mbanq/core-sdk-js)
9
+ ![license](https://img.shields.io/github/license/Mbanq/core-sdk-js)
10
+
2
11
  ## Table of Contents
3
12
 
4
- - ### Introduction
5
- - ### Installation
6
- - ### Quick Start
7
- - ### Setup
8
- - #### Axios Instance Logger
9
- - ### Middleware
10
- - #### Logging Middleware
11
- - #### Metrics Middleware
12
- - #### Custom Middleware
13
- - ### API Reference
14
- - #### Payment Operations
15
- - #### Create Payment
16
- - #### Get Payment
17
- - #### Update Payment
18
- - #### List Payments
19
- - #### Multi-Tenant Support
20
- - ### Type Safety & Validation
21
- - ### Error Handling
22
- - ### Examples
13
+ - [Introduction](#introduction)
14
+ - [Installation](#installation)
15
+ - [Quick Start](#quick-start)
16
+ - [Setup](#setup)
17
+ - [Axios Instance Logger](#axios-instance-logger)
18
+ - [Middleware](#middleware)
19
+ - [Logging Middleware](#logging-middleware)
20
+ - [Metrics Middleware](#metrics-middleware)
21
+ - [Custom Middleware](#custom-middleware)
22
+ - [API Reference](#api-reference)
23
+ - [Payment Operations](#payment-operations)
24
+ - [Create Payment](#create-payment)
25
+ - [Get Payment](#get-payment)
26
+ - [Update Payment](#update-payment)
27
+ - [List Payments](#list-payments)
28
+ - [Multi-Tenant Support](#multi-tenant-support)
29
+ - [Type Safety & Validation](#type-safety--validation)
30
+ - [Error Handling](#error-handling)
31
+ - [Examples](#examples)
23
32
 
24
33
  ## Introduction
25
34
  This library provides a comprehensive JavaScript SDK for interacting with the Mbanq payment API. It offers type-safe payment operations with built-in validation, multi-tenant support, and a modern fluent API design.
@@ -385,7 +394,7 @@ const payment = await apiClient.payment.create({
385
394
  priority: 'high',
386
395
  category: 'business'
387
396
  }
388
- });
397
+ }).execute();
389
398
  ```
390
399
 
391
400
  #### Get Payment
@@ -393,7 +402,7 @@ const payment = await apiClient.payment.create({
393
402
  Retrieves a specific payment by ID.
394
403
 
395
404
  ```javascript
396
- const payment = await apiClient.payment.get('payment-456');
405
+ const payment = await apiClient.payment.get('payment-456').execute();
397
406
  ```
398
407
 
399
408
  #### Update Payment
@@ -414,7 +423,7 @@ const updatedPayment = await apiClient.payment.update('payment-456', {
414
423
  paymentRailMetaData: {
415
424
  updated: true
416
425
  }
417
- });
426
+ }).execute();
418
427
  ```
419
428
 
420
429
  #### List Payments
@@ -452,7 +461,7 @@ The SDK supports multi-tenant operations through tenant context.
452
461
  Uses the `tenantId` from client configuration:
453
462
 
454
463
  ```javascript
455
- const payment = await apiClient.payment.create(paymentData);
464
+ const payment = await apiClient.payment.create(paymentData).execute();
456
465
  const payments = await apiClient.payment.list().execute();
457
466
  ```
458
467
 
@@ -461,13 +470,13 @@ Override tenant for specific operations:
461
470
 
462
471
  ```javascript
463
472
  // Create payment for specific tenant
464
- const payment = await apiClient.tenant('tenant-123').payment.create(paymentData);
473
+ const payment = await apiClient.tenant('tenant-123').payment.create(paymentData).execute();
465
474
 
466
475
  // Get payment from specific tenant
467
- const payment = await apiClient.tenant('tenant-123').payment.get('payment-456');
476
+ const payment = await apiClient.tenant('tenant-123').payment.get('payment-456').execute();
468
477
 
469
478
  // Update payment in specific tenant
470
- await apiClient.tenant('tenant-123').payment.update('payment-456', updateData);
479
+ await apiClient.tenant('tenant-123').payment.update('payment-456', updateData).execute();
471
480
 
472
481
  // List payments from specific tenant with filters
473
482
  const payments = await apiClient.tenant('tenant-123').payment.list()
@@ -560,7 +569,7 @@ const achPayment = await apiClient.payment.create({
560
569
  },
561
570
  clientId: 'client-abc123',
562
571
  reference: ['Invoice-2025-001']
563
- });
572
+ }).execute();
564
573
 
565
574
  console.log('Created payment:', achPayment.id);
566
575
 
@@ -596,10 +605,10 @@ const wirePayment = await apiClient.payment.create({
596
605
  chargeBearer: 'OUR',
597
606
  reference: ['Contract-2025-002'],
598
607
  exchangeRate: 0.85
599
- });
608
+ }).execute();
600
609
 
601
610
  // Retrieve and monitor payments
602
- const payment = await apiClient.payment.get(achPayment.id);
611
+ const payment = await apiClient.payment.get(achPayment.id).execute();
603
612
  console.log('Payment status:', payment.status);
604
613
 
605
614
  // Update payment if needed
@@ -629,7 +638,7 @@ const tenantPayment = await apiClient.tenant('different-tenant').payment.create(
629
638
  paymentType: 'CREDIT',
630
639
  debtor: { name: 'Internal Sender', identifier: '111111' },
631
640
  creditor: { name: 'Internal Receiver', identifier: '222222' }
632
- });
641
+ }).execute();
633
642
  ```
634
643
 
635
644
  ### Error Handling Example
@@ -642,7 +651,7 @@ try {
642
651
  amount: -100, // Invalid: negative amount
643
652
  currency: 'INVALID', // Invalid: not 3-character code
644
653
  // Missing required fields
645
- });
654
+ }).execute();
646
655
  } catch (error) {
647
656
  if (isCommandError(error)) {
648
657
  console.error('Payment creation failed:');
@@ -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 x=e=>{let a=[];if(!e.baseUrl)a.push("baseUrl is required");else if(typeof e.baseUrl!="string")a.push("baseUrl must be a string");else try{new URL(e.baseUrl)}catch (e2){a.push("baseUrl must be a valid URL")}return _optionalChain([e, 'access', _2 => _2.axiosConfig, 'optionalAccess', _3 => _3.timeout])!==void 0&&(typeof e.axiosConfig.timeout!="number"||e.axiosConfig.timeout<0)&&a.push("timeout must be a positive number"),a};var _zod = require('zod');var v=_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"]),l= exports.b =_zod.z.enum(["DRAFT","AML_SCREENING","AML_REJECTED","EXECUTION_SCHEDULED","EXECUTION_PROCESSING","EXECUTION_SUCCESS","EXECUTION_FAILURE","RETURNED","CANCELLED","COMPLIANCE_FAILURE","DELETED","UNKNOWN"]),E= exports.c =_zod.z.enum(["ACH","SAMEDAYACH","WIRE","SWIFT","INTERNAL","FXPAY","CARD"]),S= exports.d =_zod.z.enum(["CREDIT","DEBIT"]),R= exports.e =_zod.z.enum(["ASC","DESC"]),H=v.options,Y=l.options,W=E.options,X=S.options,J=R.options,b=e=>v.parse(e),T=e=>l.parse(e),w=e=>E.parse(e),A=e=>S.parse(e),U=e=>R.parse(e),D=_zod.z.object({id:_zod.z.string(),amount:_zod.z.number().positive(),clientId:_zod.z.string(),currency:_zod.z.string().min(3).max(3),status:l.optional(),createdAt:_zod.z.string().optional(),updatedAt:_zod.z.string().optional()}).catchall(_zod.z.any()),_=_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(),V=_zod.z.object({name:_zod.z.string().optional(),identifier:_zod.z.string().optional(),address:_}).optional(),h=_zod.z.object({name:_zod.z.string(),identifier:_zod.z.string(),accountType:_zod.z.enum(["CHECKING","SAVINGS"]).optional(),address:_,agent:V}),G= exports.f =_zod.z.object({amount:_zod.z.number().positive(),currency:_zod.z.string().min(3).max(3),paymentRail:E,paymentType:S,debtor:h,creditor:h,clientId:_zod.z.string().optional(),correspondent:h.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(e=>(e.paymentRail==="WIRE"||e.paymentRail==="SWIFT")&&e.creditor?e.creditor.address&&e.creditor.address.state&&e.creditor.address.country:!0,{message:"For WIRE transfers, recipient address with state and country is mandatory"}),q= exports.g =_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:l.optional()}).catchall(_zod.z.any()),Q= exports.h =_zod.z.object({totalFilteredRecords:_zod.z.number(),pageItems:_zod.z.array(D)}),g=e=>D.parse(e),N=e=>G.parse(e),L=e=>q.parse(e);var k=e=>{try{b(e)}catch(a){throw a instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid filter key: '${e}'. ${a.message}`,code:"invalid_filter_key"}):a}},z=(e,a)=>{try{switch(e){case"status":T(a);break;case"paymentRail":w(a);break;case"paymentType":A(a);break;case"sortOrder":U(a);break;default:break}}catch(o){throw o instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid value for '${e}': '${a}'. ${o.message}`,code:`invalid_${e}_value`}):o}},O= exports.i =e=>({input:e,metadata:{commandName:"CreatePayment",path:"/v1/transfers",method:"POST"},execute:async a=>{try{N(e.payment)}catch(n){throw n instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid payment data: ${n.message}`,code:"invalid_payment_input"}):n}e.tenantId&&(a.tenantId=e.tenantId);let o=await _chunkOGW7GTJPjs.d.call(void 0, a);try{let n=await o.post("/v1/transfers",e.payment);return g(n.data)}catch(n){_chunkOGW7GTJPjs.c.call(void 0, n)}}}),F= exports.j =e=>({input:e,metadata:{commandName:"GetPayment",path:`/v1/transfers/${e.id}`,method:"GET"},execute:async a=>{e.tenantId&&(a.tenantId=e.tenantId);let o=await _chunkOGW7GTJPjs.d.call(void 0, a);try{let n=await o.get(`/v1/transfers/${e.id}`);return g(n.data)}catch(n){_chunkOGW7GTJPjs.c.call(void 0, n)}}}),$= exports.k =e=>({input:e,metadata:{commandName:"UpdatePayment",path:`/v1/transfers/${e.id}`,method:"PUT"},execute:async a=>{try{L(e.payment)}catch(n){throw n instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid payment update data: ${n.message}`,code:"invalid_payment_update_input"}):n}e.tenantId&&(a.tenantId=e.tenantId);let o=await _chunkOGW7GTJPjs.d.call(void 0, a);try{let n=await o.put(`/v1/transfers/${e.id}`,e.payment);return g(n.data)}catch(n){_chunkOGW7GTJPjs.c.call(void 0, n)}}}),f=(e,a,o,n)=>({where:m=>(k(m),{eq:r=>(z(m,r),f({...e,[m]:r},a,o,n))}),limit:m=>f(e,m,o,n),offset:m=>f(e,a,m,n),execute:()=>{let m={...e,limit:a||200,offset:o||0};return{input:{filters:e,limit:a,offset:o,tenantId:n},metadata:{commandName:"GetPayments",path:"/v1/transfers",method:"GET"},execute:async r=>{n&&(r.tenantId=n);let i=await _chunkOGW7GTJPjs.d.call(void 0, r);try{return(await i.get("/v1/transfers",{params:m})).data.pageItems}catch(p){_chunkOGW7GTJPjs.c.call(void 0, p)}}}}}),j= exports.l =e=>({list:()=>f({},void 0,void 0,_optionalChain([e, 'optionalAccess', _4 => _4.tenantId]))}),M=e=>({input:e,metadata:{commandName:"DeletePayment",path:`/v1/transfers/${e.id}`,method:"DELETE"},execute:async a=>{e.tenantId&&(a.tenantId=e.tenantId);let o=await _chunkOGW7GTJPjs.d.call(void 0, a);try{await o.delete(`/v1/transfers/${e.id}`)}catch(n){_chunkOGW7GTJPjs.c.call(void 0, n)}}});var pt=e=>{let a=x(e);if(a.length>0)throw _chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid configuration: ${a.join(", ")}`,code:"invalid_config"});let o=async(r,i,p)=>{if(e.middlewares)for(let s of e.middlewares)r==="before"&&s.before?await s.before(i):r==="after"&&s.after?await s.after(i,p):r==="onError"&&s.onError&&await s.onError(i,p)},n={...e},d=async r=>{try{await o("before",r);let i=await r.execute(n);return await o("after",r,i),i}catch(i){throw await o("onError",r,i),i}},I=r=>{let i=r||n.tenantId;return{payment:{create:async p=>{let s=O({payment:p,tenantId:i});return{execute:async()=>d(s)}},get:async p=>{let s=F({id:p,tenantId:i});return{execute:async()=>d(s)}},update:async(p,s)=>{let C=$({id:p,payment:s,tenantId:i});return{execute:async()=>d(C)}},delete:async p=>{let s=M({id:p,tenantId:i});return{execute:async()=>d(s)}},list:()=>{let s=j({tenantId:i}).list();return{where:s.where,limit:s.limit,offset:s.offset,execute:async()=>{let C=s.execute();return d(C)}}}}}};return{setConfig:r=>{n=r},updateConfig:r=>{let i={...n,...r,axiosConfig:{...n.axiosConfig,...r.axiosConfig,headers:{..._optionalChain([n, 'access', _5 => _5.axiosConfig, 'optionalAccess', _6 => _6.headers]),..._optionalChain([r, 'access', _7 => _7.axiosConfig, 'optionalAccess', _8 => _8.headers])}}},p=x(i);if(p.length>0)throw _chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid configuration: ${p.join(", ")}`,code:"invalid_config"});n=i},resetConfig:()=>{n=e},request:d,tenant:r=>I(r),...I()}};exports.a = v; exports.b = l; exports.c = E; exports.d = S; exports.e = R; exports.f = G; exports.g = q; exports.h = Q; exports.i = O; exports.j = F; exports.k = $; exports.l = j; exports.m = pt;
@@ -1 +1 @@
1
- import{a as c,c as d,d as u}from"./chunk-RX3BFHHX.mjs";var h=e=>{let a=[];if(!e.baseUrl)a.push("baseUrl is required");else if(typeof e.baseUrl!="string")a.push("baseUrl must be a string");else try{new URL(e.baseUrl)}catch{a.push("baseUrl must be a valid URL")}return e.axiosConfig?.timeout!==void 0&&(typeof e.axiosConfig.timeout!="number"||e.axiosConfig.timeout<0)&&a.push("timeout must be a positive number"),a};import{z as t}from"zod";var v=t.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"]),l=t.enum(["DRAFT","AML_SCREENING","AML_REJECTED","EXECUTION_SCHEDULED","EXECUTION_PROCESSING","EXECUTION_SUCCESS","EXECUTION_FAILURE","RETURNED","CANCELLED","COMPLIANCE_FAILURE","DELETED","UNKNOWN"]),E=t.enum(["ACH","SAMEDAYACH","WIRE","SWIFT","INTERNAL","FXPAY","CARD"]),S=t.enum(["CREDIT","DEBIT"]),R=t.enum(["ASC","DESC"]),H=v.options,Y=l.options,W=E.options,X=S.options,J=R.options,b=e=>v.parse(e),T=e=>l.parse(e),w=e=>E.parse(e),A=e=>S.parse(e),U=e=>R.parse(e),D=t.object({id:t.string(),amount:t.number().positive(),clientId:t.string(),currency:t.string().min(3).max(3),status:l.optional(),createdAt:t.string().optional(),updatedAt:t.string().optional()}).catchall(t.any()),_=t.object({streetAddress:t.string().optional(),city:t.string().optional(),state:t.string().optional(),country:t.string().optional(),postalCode:t.string().optional()}).optional(),V=t.object({name:t.string().optional(),identifier:t.string().optional(),address:_}).optional(),x=t.object({name:t.string(),identifier:t.string(),accountType:t.enum(["CHECKING","SAVINGS"]).optional(),address:_,agent:V}),G=t.object({amount:t.number().positive(),currency:t.string().min(3).max(3),paymentRail:E,paymentType:S,debtor:x,creditor:x,clientId:t.string().optional(),correspondent:x.optional(),exchangeRate:t.number().positive().optional(),externalId:t.string().optional(),reference:t.union([t.string(),t.array(t.string())]).optional(),paymentRailMetaData:t.record(t.string(),t.any()).optional(),chargeBearer:t.enum(["OUR","BEN","SHA"]).optional(),purposeCode:t.string().optional(),valueDate:t.string().optional(),executionDate:t.string().optional()}).catchall(t.any()).refine(e=>(e.paymentRail==="WIRE"||e.paymentRail==="SWIFT")&&e.creditor?e.creditor.address&&e.creditor.address.state&&e.creditor.address.country:!0,{message:"For WIRE transfers, recipient address with state and country is mandatory"}),q=t.object({amount:t.number().positive().optional(),correspondent:t.object({name:t.string().optional(),identifier:t.string().optional(),accountType:t.string().optional()}).optional(),creditor:t.object({name:t.string().optional(),identifier:t.string().optional(),accountType:t.string().optional(),agent:t.object({name:t.string().optional(),identifier:t.string().optional()}).optional()}).optional(),debtor:t.object({name:t.string().optional(),identifier:t.string().optional(),accountType:t.string().optional(),agent:t.object({name:t.string().optional(),identifier:t.string().optional()}).optional()}).optional(),exchangeRate:t.number().positive().optional(),externalId:t.string().optional(),errorCode:t.string().optional(),errorMessage:t.string().optional(),reference:t.union([t.string(),t.array(t.string())]).optional(),paymentRailMetaData:t.record(t.string(),t.any()).optional(),status:l.optional()}).catchall(t.any()),Q=t.object({totalFilteredRecords:t.number(),pageItems:t.array(D)}),g=e=>D.parse(e),N=e=>G.parse(e),L=e=>q.parse(e);import{ZodError as P}from"zod";var k=e=>{try{b(e)}catch(a){throw a instanceof P?c({message:`Invalid filter key: '${e}'. ${a.message}`,code:"invalid_filter_key"}):a}},z=(e,a)=>{try{switch(e){case"status":T(a);break;case"paymentRail":w(a);break;case"paymentType":A(a);break;case"sortOrder":U(a);break;default:break}}catch(o){throw o instanceof P?c({message:`Invalid value for '${e}': '${a}'. ${o.message}`,code:`invalid_${e}_value`}):o}},O=e=>({input:e,metadata:{commandName:"CreatePayment",path:"/v1/payments",method:"POST"},execute:async a=>{try{N(e.payment)}catch(n){throw n instanceof P?c({message:`Invalid payment data: ${n.message}`,code:"invalid_payment_input"}):n}e.tenantId&&(a.tenantId=e.tenantId);let o=await u(a);try{let n=await o.post("/v1/payments",e.payment);return g(n.data)}catch(n){d(n)}}}),F=e=>({input:e,metadata:{commandName:"GetPayment",path:`/v1/payments/${e.id}`,method:"GET"},execute:async a=>{e.tenantId&&(a.tenantId=e.tenantId);let o=await u(a);try{let n=await o.get(`/v1/payments/${e.id}`);return g(n.data)}catch(n){d(n)}}}),$=e=>({input:e,metadata:{commandName:"UpdatePayment",path:`/v1/payments/${e.id}`,method:"PUT"},execute:async a=>{try{L(e.payment)}catch(n){throw n instanceof P?c({message:`Invalid payment update data: ${n.message}`,code:"invalid_payment_update_input"}):n}e.tenantId&&(a.tenantId=e.tenantId);let o=await u(a);try{let n=await o.put(`/v1/payments/${e.id}`,e.payment);return g(n.data)}catch(n){d(n)}}}),f=(e,a,o,n)=>({where:m=>(k(m),{eq:r=>(z(m,r),f({...e,[m]:r},a,o,n))}),limit:m=>f(e,m,o,n),offset:m=>f(e,a,m,n),execute:()=>{let m={...e,limit:a||200,offset:o||0};return{input:{filters:e,limit:a,offset:o,tenantId:n},metadata:{commandName:"GetPayments",path:"/v1/payments",method:"GET"},execute:async r=>{n&&(r.tenantId=n);let i=await u(r);try{return(await i.get("/v1/payments",{params:m})).data.pageItems}catch(p){d(p)}}}}}),j=e=>({list:()=>f({},void 0,void 0,e?.tenantId)}),M=e=>({input:e,metadata:{commandName:"DeletePayment",path:`/v1/payments/${e.id}`,method:"DELETE"},execute:async a=>{e.tenantId&&(a.tenantId=e.tenantId);let o=await u(a);try{await o.delete(`/v1/payments/${e.id}`)}catch(n){d(n)}}});var pt=e=>{let a=h(e);if(a.length>0)throw c({message:`Invalid configuration: ${a.join(", ")}`,code:"invalid_config"});let o=async(r,i,p)=>{if(e.middlewares)for(let s of e.middlewares)r==="before"&&s.before?await s.before(i):r==="after"&&s.after?await s.after(i,p):r==="onError"&&s.onError&&await s.onError(i,p)},n={...e},y=async r=>{try{await o("before",r);let i=await r.execute(n);return await o("after",r,i),i}catch(i){throw await o("onError",r,i),i}},I=r=>{let i=r||n.tenantId;return{payment:{create:async p=>{let s=O({payment:p,tenantId:i});return y(s)},get:async p=>{let s=F({id:p,tenantId:i});return y(s)},update:async(p,s)=>{let C=$({id:p,payment:s,tenantId:i});return y(C)},delete:async p=>{let s=M({id:p,tenantId:i});return y(s)},list:()=>{let s=j({tenantId:i}).list();return{where:s.where,limit:s.limit,offset:s.offset,execute:async()=>{let C=s.execute();return y(C)}}}}}};return{setConfig:r=>{n=r},updateConfig:r=>{let i={...n,...r,axiosConfig:{...n.axiosConfig,...r.axiosConfig,headers:{...n.axiosConfig?.headers,...r.axiosConfig?.headers}}},p=h(i);if(p.length>0)throw c({message:`Invalid configuration: ${p.join(", ")}`,code:"invalid_config"});n=i},resetConfig:()=>{n=e},request:y,tenant:r=>I(r),...I()}};export{O as a,F as b,$ as c,j as d,pt as e};
1
+ import{a as c,c as y,d as u}from"./chunk-RX3BFHHX.mjs";var x=e=>{let a=[];if(!e.baseUrl)a.push("baseUrl is required");else if(typeof e.baseUrl!="string")a.push("baseUrl must be a string");else try{new URL(e.baseUrl)}catch{a.push("baseUrl must be a valid URL")}return e.axiosConfig?.timeout!==void 0&&(typeof e.axiosConfig.timeout!="number"||e.axiosConfig.timeout<0)&&a.push("timeout must be a positive number"),a};import{z as t}from"zod";var v=t.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"]),l=t.enum(["DRAFT","AML_SCREENING","AML_REJECTED","EXECUTION_SCHEDULED","EXECUTION_PROCESSING","EXECUTION_SUCCESS","EXECUTION_FAILURE","RETURNED","CANCELLED","COMPLIANCE_FAILURE","DELETED","UNKNOWN"]),E=t.enum(["ACH","SAMEDAYACH","WIRE","SWIFT","INTERNAL","FXPAY","CARD"]),S=t.enum(["CREDIT","DEBIT"]),R=t.enum(["ASC","DESC"]),H=v.options,Y=l.options,W=E.options,X=S.options,J=R.options,b=e=>v.parse(e),T=e=>l.parse(e),w=e=>E.parse(e),A=e=>S.parse(e),U=e=>R.parse(e),D=t.object({id:t.string(),amount:t.number().positive(),clientId:t.string(),currency:t.string().min(3).max(3),status:l.optional(),createdAt:t.string().optional(),updatedAt:t.string().optional()}).catchall(t.any()),_=t.object({streetAddress:t.string().optional(),city:t.string().optional(),state:t.string().optional(),country:t.string().optional(),postalCode:t.string().optional()}).optional(),V=t.object({name:t.string().optional(),identifier:t.string().optional(),address:_}).optional(),h=t.object({name:t.string(),identifier:t.string(),accountType:t.enum(["CHECKING","SAVINGS"]).optional(),address:_,agent:V}),G=t.object({amount:t.number().positive(),currency:t.string().min(3).max(3),paymentRail:E,paymentType:S,debtor:h,creditor:h,clientId:t.string().optional(),correspondent:h.optional(),exchangeRate:t.number().positive().optional(),externalId:t.string().optional(),reference:t.union([t.string(),t.array(t.string())]).optional(),paymentRailMetaData:t.record(t.string(),t.any()).optional(),chargeBearer:t.enum(["OUR","BEN","SHA"]).optional(),purposeCode:t.string().optional(),valueDate:t.string().optional(),executionDate:t.string().optional()}).catchall(t.any()).refine(e=>(e.paymentRail==="WIRE"||e.paymentRail==="SWIFT")&&e.creditor?e.creditor.address&&e.creditor.address.state&&e.creditor.address.country:!0,{message:"For WIRE transfers, recipient address with state and country is mandatory"}),q=t.object({amount:t.number().positive().optional(),correspondent:t.object({name:t.string().optional(),identifier:t.string().optional(),accountType:t.string().optional()}).optional(),creditor:t.object({name:t.string().optional(),identifier:t.string().optional(),accountType:t.string().optional(),agent:t.object({name:t.string().optional(),identifier:t.string().optional()}).optional()}).optional(),debtor:t.object({name:t.string().optional(),identifier:t.string().optional(),accountType:t.string().optional(),agent:t.object({name:t.string().optional(),identifier:t.string().optional()}).optional()}).optional(),exchangeRate:t.number().positive().optional(),externalId:t.string().optional(),errorCode:t.string().optional(),errorMessage:t.string().optional(),reference:t.union([t.string(),t.array(t.string())]).optional(),paymentRailMetaData:t.record(t.string(),t.any()).optional(),status:l.optional()}).catchall(t.any()),Q=t.object({totalFilteredRecords:t.number(),pageItems:t.array(D)}),g=e=>D.parse(e),N=e=>G.parse(e),L=e=>q.parse(e);import{ZodError as P}from"zod";var k=e=>{try{b(e)}catch(a){throw a instanceof P?c({message:`Invalid filter key: '${e}'. ${a.message}`,code:"invalid_filter_key"}):a}},z=(e,a)=>{try{switch(e){case"status":T(a);break;case"paymentRail":w(a);break;case"paymentType":A(a);break;case"sortOrder":U(a);break;default:break}}catch(o){throw o instanceof P?c({message:`Invalid value for '${e}': '${a}'. ${o.message}`,code:`invalid_${e}_value`}):o}},O=e=>({input:e,metadata:{commandName:"CreatePayment",path:"/v1/transfers",method:"POST"},execute:async a=>{try{N(e.payment)}catch(n){throw n instanceof P?c({message:`Invalid payment data: ${n.message}`,code:"invalid_payment_input"}):n}e.tenantId&&(a.tenantId=e.tenantId);let o=await u(a);try{let n=await o.post("/v1/transfers",e.payment);return g(n.data)}catch(n){y(n)}}}),F=e=>({input:e,metadata:{commandName:"GetPayment",path:`/v1/transfers/${e.id}`,method:"GET"},execute:async a=>{e.tenantId&&(a.tenantId=e.tenantId);let o=await u(a);try{let n=await o.get(`/v1/transfers/${e.id}`);return g(n.data)}catch(n){y(n)}}}),$=e=>({input:e,metadata:{commandName:"UpdatePayment",path:`/v1/transfers/${e.id}`,method:"PUT"},execute:async a=>{try{L(e.payment)}catch(n){throw n instanceof P?c({message:`Invalid payment update data: ${n.message}`,code:"invalid_payment_update_input"}):n}e.tenantId&&(a.tenantId=e.tenantId);let o=await u(a);try{let n=await o.put(`/v1/transfers/${e.id}`,e.payment);return g(n.data)}catch(n){y(n)}}}),f=(e,a,o,n)=>({where:m=>(k(m),{eq:r=>(z(m,r),f({...e,[m]:r},a,o,n))}),limit:m=>f(e,m,o,n),offset:m=>f(e,a,m,n),execute:()=>{let m={...e,limit:a||200,offset:o||0};return{input:{filters:e,limit:a,offset:o,tenantId:n},metadata:{commandName:"GetPayments",path:"/v1/transfers",method:"GET"},execute:async r=>{n&&(r.tenantId=n);let i=await u(r);try{return(await i.get("/v1/transfers",{params:m})).data.pageItems}catch(p){y(p)}}}}}),j=e=>({list:()=>f({},void 0,void 0,e?.tenantId)}),M=e=>({input:e,metadata:{commandName:"DeletePayment",path:`/v1/transfers/${e.id}`,method:"DELETE"},execute:async a=>{e.tenantId&&(a.tenantId=e.tenantId);let o=await u(a);try{await o.delete(`/v1/transfers/${e.id}`)}catch(n){y(n)}}});var pt=e=>{let a=x(e);if(a.length>0)throw c({message:`Invalid configuration: ${a.join(", ")}`,code:"invalid_config"});let o=async(r,i,p)=>{if(e.middlewares)for(let s of e.middlewares)r==="before"&&s.before?await s.before(i):r==="after"&&s.after?await s.after(i,p):r==="onError"&&s.onError&&await s.onError(i,p)},n={...e},d=async r=>{try{await o("before",r);let i=await r.execute(n);return await o("after",r,i),i}catch(i){throw await o("onError",r,i),i}},I=r=>{let i=r||n.tenantId;return{payment:{create:async p=>{let s=O({payment:p,tenantId:i});return{execute:async()=>d(s)}},get:async p=>{let s=F({id:p,tenantId:i});return{execute:async()=>d(s)}},update:async(p,s)=>{let C=$({id:p,payment:s,tenantId:i});return{execute:async()=>d(C)}},delete:async p=>{let s=M({id:p,tenantId:i});return{execute:async()=>d(s)}},list:()=>{let s=j({tenantId:i}).list();return{where:s.where,limit:s.limit,offset:s.offset,execute:async()=>{let C=s.execute();return d(C)}}}}}};return{setConfig:r=>{n=r},updateConfig:r=>{let i={...n,...r,axiosConfig:{...n.axiosConfig,...r.axiosConfig,headers:{...n.axiosConfig?.headers,...r.axiosConfig?.headers}}},p=x(i);if(p.length>0)throw c({message:`Invalid configuration: ${p.join(", ")}`,code:"invalid_config"});n=i},resetConfig:()=>{n=e},request:d,tenant:r=>I(r),...I()}};export{v as a,l as b,E as c,S as d,R as e,G as f,q as g,Q as h,O as i,F as j,$ as k,j as l,pt as m};
@@ -1,4 +1,4 @@
1
- export { c as createClient } from '../index-BwrcqeVR.mjs';
1
+ export { c as createClient } from '../index-Dyfp_UmI.mjs';
2
2
  import '../config.d-CyK6ZM6s.mjs';
3
3
  import 'zod';
4
4
  import 'graphql';
@@ -1,4 +1,4 @@
1
- export { c as createClient } from '../index-BlNgOA4v.js';
1
+ export { c as createClient } from '../index-BcfN4PwO.js';
2
2
  import '../config.d-CyK6ZM6s.js';
3
3
  import 'zod';
4
4
  import 'graphql';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkNVFP3TSFjs = require('../chunk-NVFP3TSF.js');require('../chunk-OGW7GTJP.js');exports.createClient = _chunkNVFP3TSFjs.e;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPE5GKPHFjs = require('../chunk-PE5GKPHF.js');require('../chunk-OGW7GTJP.js');exports.createClient = _chunkPE5GKPHFjs.m;
@@ -1 +1 @@
1
- import{e as a}from"../chunk-LXODYKLU.mjs";import"../chunk-RX3BFHHX.mjs";export{a as createClient};
1
+ import{m as a}from"../chunk-RKHBWABU.mjs";import"../chunk-RX3BFHHX.mjs";export{a as createClient};
@@ -1,6 +1,33 @@
1
1
  import { a as Config, C as Command } from './config.d-CyK6ZM6s.js';
2
2
  import { z } from 'zod';
3
3
 
4
+ declare const PaymentFilterKeySchema: z.ZodEnum<{
5
+ originatorName: "originatorName";
6
+ originatorAccount: "originatorAccount";
7
+ originatorBankRoutingCode: "originatorBankRoutingCode";
8
+ recipientName: "recipientName";
9
+ recipientAccount: "recipientAccount";
10
+ recipientBankRoutingCode: "recipientBankRoutingCode";
11
+ reference: "reference";
12
+ traceNumber: "traceNumber";
13
+ externalId: "externalId";
14
+ clientId: "clientId";
15
+ dateFormat: "dateFormat";
16
+ locale: "locale";
17
+ originatedBy: "originatedBy";
18
+ paymentRail: "paymentRail";
19
+ paymentType: "paymentType";
20
+ fromValueDate: "fromValueDate";
21
+ toValueDate: "toValueDate";
22
+ fromExecuteDate: "fromExecuteDate";
23
+ toExecuteDate: "toExecuteDate";
24
+ status: "status";
25
+ fromReturnDate: "fromReturnDate";
26
+ toReturnDate: "toReturnDate";
27
+ isSettlement: "isSettlement";
28
+ orderBy: "orderBy";
29
+ sortOrder: "sortOrder";
30
+ }>;
4
31
  declare const PaymentStatusSchema: z.ZodEnum<{
5
32
  DRAFT: "DRAFT";
6
33
  AML_SCREENING: "AML_SCREENING";
@@ -28,6 +55,10 @@ declare const PaymentTypeSchema: z.ZodEnum<{
28
55
  CREDIT: "CREDIT";
29
56
  DEBIT: "DEBIT";
30
57
  }>;
58
+ declare const SortOrderSchema: z.ZodEnum<{
59
+ ASC: "ASC";
60
+ DESC: "DESC";
61
+ }>;
31
62
  type PaymentStatus = z.infer<typeof PaymentStatusSchema>;
32
63
  type PaymentRailType = z.infer<typeof PaymentRailSchema>;
33
64
  type PaymentType = z.infer<typeof PaymentTypeSchema>;
@@ -240,36 +271,44 @@ type PaymentResponse = z.infer<typeof PaymentResponseSchema>;
240
271
  declare const createClient: (initialConfig: Config) => {
241
272
  payment: {
242
273
  create: (data: CreatePaymentInput) => Promise<{
243
- [x: string]: any;
244
- id: string;
245
- amount: number;
246
- clientId: string;
247
- currency: string;
248
- status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
249
- createdAt?: string | undefined;
250
- updatedAt?: string | undefined;
251
- } | undefined>;
274
+ execute: () => Promise<{
275
+ [x: string]: any;
276
+ id: string;
277
+ amount: number;
278
+ clientId: string;
279
+ currency: string;
280
+ status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
281
+ createdAt?: string | undefined;
282
+ updatedAt?: string | undefined;
283
+ } | undefined>;
284
+ }>;
252
285
  get: (id: string) => Promise<{
253
- [x: string]: any;
254
- id: string;
255
- amount: number;
256
- clientId: string;
257
- currency: string;
258
- status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
259
- createdAt?: string | undefined;
260
- updatedAt?: string | undefined;
261
- } | undefined>;
286
+ execute: () => Promise<{
287
+ [x: string]: any;
288
+ id: string;
289
+ amount: number;
290
+ clientId: string;
291
+ currency: string;
292
+ status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
293
+ createdAt?: string | undefined;
294
+ updatedAt?: string | undefined;
295
+ } | undefined>;
296
+ }>;
262
297
  update: (id: string, data: UpdatePaymentInput) => Promise<{
263
- [x: string]: any;
264
- id: string;
265
- amount: number;
266
- clientId: string;
267
- currency: string;
268
- status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
269
- createdAt?: string | undefined;
270
- updatedAt?: string | undefined;
271
- } | undefined>;
272
- delete: (id: string) => Promise<void | undefined>;
298
+ execute: () => Promise<{
299
+ [x: string]: any;
300
+ id: string;
301
+ amount: number;
302
+ clientId: string;
303
+ currency: string;
304
+ status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
305
+ createdAt?: string | undefined;
306
+ updatedAt?: string | undefined;
307
+ } | undefined>;
308
+ }>;
309
+ delete: (id: string) => Promise<{
310
+ execute: () => Promise<void | undefined>;
311
+ }>;
273
312
  list: () => {
274
313
  where: (field: string) => {
275
314
  eq: (value: any) => {
@@ -314,36 +353,44 @@ declare const createClient: (initialConfig: Config) => {
314
353
  tenant: (tenantId: string) => {
315
354
  payment: {
316
355
  create: (data: CreatePaymentInput) => Promise<{
317
- [x: string]: any;
318
- id: string;
319
- amount: number;
320
- clientId: string;
321
- currency: string;
322
- status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
323
- createdAt?: string | undefined;
324
- updatedAt?: string | undefined;
325
- } | undefined>;
356
+ execute: () => Promise<{
357
+ [x: string]: any;
358
+ id: string;
359
+ amount: number;
360
+ clientId: string;
361
+ currency: string;
362
+ status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
363
+ createdAt?: string | undefined;
364
+ updatedAt?: string | undefined;
365
+ } | undefined>;
366
+ }>;
326
367
  get: (id: string) => Promise<{
327
- [x: string]: any;
328
- id: string;
329
- amount: number;
330
- clientId: string;
331
- currency: string;
332
- status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
333
- createdAt?: string | undefined;
334
- updatedAt?: string | undefined;
335
- } | undefined>;
368
+ execute: () => Promise<{
369
+ [x: string]: any;
370
+ id: string;
371
+ amount: number;
372
+ clientId: string;
373
+ currency: string;
374
+ status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
375
+ createdAt?: string | undefined;
376
+ updatedAt?: string | undefined;
377
+ } | undefined>;
378
+ }>;
336
379
  update: (id: string, data: UpdatePaymentInput) => Promise<{
337
- [x: string]: any;
338
- id: string;
339
- amount: number;
340
- clientId: string;
341
- currency: string;
342
- status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
343
- createdAt?: string | undefined;
344
- updatedAt?: string | undefined;
345
- } | undefined>;
346
- delete: (id: string) => Promise<void | undefined>;
380
+ execute: () => Promise<{
381
+ [x: string]: any;
382
+ id: string;
383
+ amount: number;
384
+ clientId: string;
385
+ currency: string;
386
+ status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
387
+ createdAt?: string | undefined;
388
+ updatedAt?: string | undefined;
389
+ } | undefined>;
390
+ }>;
391
+ delete: (id: string) => Promise<{
392
+ execute: () => Promise<void | undefined>;
393
+ }>;
347
394
  list: () => {
348
395
  where: (field: string) => {
349
396
  eq: (value: any) => {
@@ -384,4 +431,4 @@ declare const createClient: (initialConfig: Config) => {
384
431
  };
385
432
  };
386
433
 
387
- export { type CreatePaymentInput as C, type Payment as P, type UpdatePaymentInput as U, type PaymentResponse as a, type PaymentStatus as b, createClient as c, type PaymentRailType as d, type PaymentType as e };
434
+ 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, PaymentStatusSchema as f, PaymentFilterKeySchema as g, PaymentRailSchema as h, PaymentTypeSchema as i, CreatePaymentInputSchema as j, UpdatePaymentInputSchema as k, PaymentResponseSchema as l };
@@ -1,6 +1,33 @@
1
1
  import { a as Config, C as Command } from './config.d-CyK6ZM6s.mjs';
2
2
  import { z } from 'zod';
3
3
 
4
+ declare const PaymentFilterKeySchema: z.ZodEnum<{
5
+ originatorName: "originatorName";
6
+ originatorAccount: "originatorAccount";
7
+ originatorBankRoutingCode: "originatorBankRoutingCode";
8
+ recipientName: "recipientName";
9
+ recipientAccount: "recipientAccount";
10
+ recipientBankRoutingCode: "recipientBankRoutingCode";
11
+ reference: "reference";
12
+ traceNumber: "traceNumber";
13
+ externalId: "externalId";
14
+ clientId: "clientId";
15
+ dateFormat: "dateFormat";
16
+ locale: "locale";
17
+ originatedBy: "originatedBy";
18
+ paymentRail: "paymentRail";
19
+ paymentType: "paymentType";
20
+ fromValueDate: "fromValueDate";
21
+ toValueDate: "toValueDate";
22
+ fromExecuteDate: "fromExecuteDate";
23
+ toExecuteDate: "toExecuteDate";
24
+ status: "status";
25
+ fromReturnDate: "fromReturnDate";
26
+ toReturnDate: "toReturnDate";
27
+ isSettlement: "isSettlement";
28
+ orderBy: "orderBy";
29
+ sortOrder: "sortOrder";
30
+ }>;
4
31
  declare const PaymentStatusSchema: z.ZodEnum<{
5
32
  DRAFT: "DRAFT";
6
33
  AML_SCREENING: "AML_SCREENING";
@@ -28,6 +55,10 @@ declare const PaymentTypeSchema: z.ZodEnum<{
28
55
  CREDIT: "CREDIT";
29
56
  DEBIT: "DEBIT";
30
57
  }>;
58
+ declare const SortOrderSchema: z.ZodEnum<{
59
+ ASC: "ASC";
60
+ DESC: "DESC";
61
+ }>;
31
62
  type PaymentStatus = z.infer<typeof PaymentStatusSchema>;
32
63
  type PaymentRailType = z.infer<typeof PaymentRailSchema>;
33
64
  type PaymentType = z.infer<typeof PaymentTypeSchema>;
@@ -240,36 +271,44 @@ type PaymentResponse = z.infer<typeof PaymentResponseSchema>;
240
271
  declare const createClient: (initialConfig: Config) => {
241
272
  payment: {
242
273
  create: (data: CreatePaymentInput) => Promise<{
243
- [x: string]: any;
244
- id: string;
245
- amount: number;
246
- clientId: string;
247
- currency: string;
248
- status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
249
- createdAt?: string | undefined;
250
- updatedAt?: string | undefined;
251
- } | undefined>;
274
+ execute: () => Promise<{
275
+ [x: string]: any;
276
+ id: string;
277
+ amount: number;
278
+ clientId: string;
279
+ currency: string;
280
+ status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
281
+ createdAt?: string | undefined;
282
+ updatedAt?: string | undefined;
283
+ } | undefined>;
284
+ }>;
252
285
  get: (id: string) => Promise<{
253
- [x: string]: any;
254
- id: string;
255
- amount: number;
256
- clientId: string;
257
- currency: string;
258
- status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
259
- createdAt?: string | undefined;
260
- updatedAt?: string | undefined;
261
- } | undefined>;
286
+ execute: () => Promise<{
287
+ [x: string]: any;
288
+ id: string;
289
+ amount: number;
290
+ clientId: string;
291
+ currency: string;
292
+ status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
293
+ createdAt?: string | undefined;
294
+ updatedAt?: string | undefined;
295
+ } | undefined>;
296
+ }>;
262
297
  update: (id: string, data: UpdatePaymentInput) => Promise<{
263
- [x: string]: any;
264
- id: string;
265
- amount: number;
266
- clientId: string;
267
- currency: string;
268
- status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
269
- createdAt?: string | undefined;
270
- updatedAt?: string | undefined;
271
- } | undefined>;
272
- delete: (id: string) => Promise<void | undefined>;
298
+ execute: () => Promise<{
299
+ [x: string]: any;
300
+ id: string;
301
+ amount: number;
302
+ clientId: string;
303
+ currency: string;
304
+ status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
305
+ createdAt?: string | undefined;
306
+ updatedAt?: string | undefined;
307
+ } | undefined>;
308
+ }>;
309
+ delete: (id: string) => Promise<{
310
+ execute: () => Promise<void | undefined>;
311
+ }>;
273
312
  list: () => {
274
313
  where: (field: string) => {
275
314
  eq: (value: any) => {
@@ -314,36 +353,44 @@ declare const createClient: (initialConfig: Config) => {
314
353
  tenant: (tenantId: string) => {
315
354
  payment: {
316
355
  create: (data: CreatePaymentInput) => Promise<{
317
- [x: string]: any;
318
- id: string;
319
- amount: number;
320
- clientId: string;
321
- currency: string;
322
- status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
323
- createdAt?: string | undefined;
324
- updatedAt?: string | undefined;
325
- } | undefined>;
356
+ execute: () => Promise<{
357
+ [x: string]: any;
358
+ id: string;
359
+ amount: number;
360
+ clientId: string;
361
+ currency: string;
362
+ status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
363
+ createdAt?: string | undefined;
364
+ updatedAt?: string | undefined;
365
+ } | undefined>;
366
+ }>;
326
367
  get: (id: string) => Promise<{
327
- [x: string]: any;
328
- id: string;
329
- amount: number;
330
- clientId: string;
331
- currency: string;
332
- status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
333
- createdAt?: string | undefined;
334
- updatedAt?: string | undefined;
335
- } | undefined>;
368
+ execute: () => Promise<{
369
+ [x: string]: any;
370
+ id: string;
371
+ amount: number;
372
+ clientId: string;
373
+ currency: string;
374
+ status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
375
+ createdAt?: string | undefined;
376
+ updatedAt?: string | undefined;
377
+ } | undefined>;
378
+ }>;
336
379
  update: (id: string, data: UpdatePaymentInput) => Promise<{
337
- [x: string]: any;
338
- id: string;
339
- amount: number;
340
- clientId: string;
341
- currency: string;
342
- status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
343
- createdAt?: string | undefined;
344
- updatedAt?: string | undefined;
345
- } | undefined>;
346
- delete: (id: string) => Promise<void | undefined>;
380
+ execute: () => Promise<{
381
+ [x: string]: any;
382
+ id: string;
383
+ amount: number;
384
+ clientId: string;
385
+ currency: string;
386
+ status?: "DRAFT" | "AML_SCREENING" | "AML_REJECTED" | "EXECUTION_SCHEDULED" | "EXECUTION_PROCESSING" | "EXECUTION_SUCCESS" | "EXECUTION_FAILURE" | "RETURNED" | "CANCELLED" | "COMPLIANCE_FAILURE" | "DELETED" | "UNKNOWN" | undefined;
387
+ createdAt?: string | undefined;
388
+ updatedAt?: string | undefined;
389
+ } | undefined>;
390
+ }>;
391
+ delete: (id: string) => Promise<{
392
+ execute: () => Promise<void | undefined>;
393
+ }>;
347
394
  list: () => {
348
395
  where: (field: string) => {
349
396
  eq: (value: any) => {
@@ -384,4 +431,4 @@ declare const createClient: (initialConfig: Config) => {
384
431
  };
385
432
  };
386
433
 
387
- export { type CreatePaymentInput as C, type Payment as P, type UpdatePaymentInput as U, type PaymentResponse as a, type PaymentStatus as b, createClient as c, type PaymentRailType as d, type PaymentType as e };
434
+ 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, PaymentStatusSchema as f, PaymentFilterKeySchema as g, PaymentRailSchema as h, PaymentTypeSchema as i, CreatePaymentInputSchema as j, UpdatePaymentInputSchema as k, PaymentResponseSchema as l };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CreatePaymentInput, P as Payment, U as UpdatePaymentInput } from './index-BwrcqeVR.mjs';
2
- export { d as PaymentRailType, a as PaymentResponse, b as PaymentStatus, e as PaymentType, c as createClient } from './index-BwrcqeVR.mjs';
1
+ import { C as CreatePaymentInput, P as Payment, U as UpdatePaymentInput } from './index-Dyfp_UmI.mjs';
2
+ export { j as CreatePaymentInputZod, g as PaymentFilterKeyZod, d as PaymentRailType, h as PaymentRailZod, a as PaymentResponse, l as PaymentResponseZod, b as PaymentStatus, f as PaymentStatusZod, e as PaymentType, i as PaymentTypeZod, S as SortOrderZod, k as UpdatePaymentInputZod, c as createClient } from './index-Dyfp_UmI.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';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CreatePaymentInput, P as Payment, U as UpdatePaymentInput } from './index-BlNgOA4v.js';
2
- export { d as PaymentRailType, a as PaymentResponse, b as PaymentStatus, e as PaymentType, c as createClient } from './index-BlNgOA4v.js';
1
+ import { C as CreatePaymentInput, P as Payment, U as UpdatePaymentInput } from './index-BcfN4PwO.js';
2
+ export { j as CreatePaymentInputZod, g as PaymentFilterKeyZod, d as PaymentRailType, h as PaymentRailZod, a as PaymentResponse, l as PaymentResponseZod, b as PaymentStatus, f as PaymentStatusZod, e as PaymentType, i as PaymentTypeZod, S as SortOrderZod, k as UpdatePaymentInputZod, c as createClient } from './index-BcfN4PwO.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';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkNVFP3TSFjs = require('./chunk-NVFP3TSF.js');var _chunkBDI3SHA2js = require('./chunk-BDI3SHA2.js');var _chunkOGW7GTJPjs = require('./chunk-OGW7GTJP.js');var u=(r=console)=>({before:async e=>{r.info(`Executing ${e.metadata.commandName}`,{input:e.input,metadata:e.metadata})},after:async(e,t)=>{r.info(`Completed ${e.metadata.commandName}`,{response:t,metadata:e.metadata})},onError:async(e,t)=>{r.error(`Error in ${e.metadata.commandName}`,{error:t,input:e.input,metadata:e.metadata})}});var x=r=>({before:async e=>{r.incrementCounter(`${e.metadata.commandName}_started`)},after:async e=>{r.incrementCounter(`${e.metadata.commandName}_completed`)},onError:async(e,t)=>{r.incrementCounter(`${e.metadata.commandName}_error`),r.recordError&&typeof r.recordError=="function"&&r.recordError(t)}});exports.CreatePayment = _chunkNVFP3TSFjs.a; exports.GetClientData = _chunkBDI3SHA2js.c; exports.GetPayment = _chunkNVFP3TSFjs.b; exports.GetPayments = _chunkNVFP3TSFjs.d; exports.GraphQL = _chunkBDI3SHA2js.f; exports.SendAuthorizationToCore = _chunkBDI3SHA2js.a; exports.UpdateCardID = _chunkBDI3SHA2js.b; exports.UpdateClient = _chunkBDI3SHA2js.d; exports.UpdateClientIdentifier = _chunkBDI3SHA2js.e; exports.UpdatePayment = _chunkNVFP3TSFjs.c; exports.createClient = _chunkNVFP3TSFjs.e; exports.createLoggingMiddleware = u; exports.createMetricsMiddleware = x; exports.isCommandError = _chunkOGW7GTJPjs.b;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPE5GKPHFjs = require('./chunk-PE5GKPHF.js');var _chunkBDI3SHA2js = require('./chunk-BDI3SHA2.js');var _chunkOGW7GTJPjs = require('./chunk-OGW7GTJP.js');var h=(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 E=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 = _chunkPE5GKPHFjs.i; exports.CreatePaymentInputZod = _chunkPE5GKPHFjs.f; exports.GetClientData = _chunkBDI3SHA2js.c; exports.GetPayment = _chunkPE5GKPHFjs.j; exports.GetPayments = _chunkPE5GKPHFjs.l; exports.GraphQL = _chunkBDI3SHA2js.f; exports.PaymentFilterKeyZod = _chunkPE5GKPHFjs.a; exports.PaymentRailZod = _chunkPE5GKPHFjs.c; exports.PaymentResponseZod = _chunkPE5GKPHFjs.h; exports.PaymentStatusZod = _chunkPE5GKPHFjs.b; exports.PaymentTypeZod = _chunkPE5GKPHFjs.d; exports.SendAuthorizationToCore = _chunkBDI3SHA2js.a; exports.SortOrderZod = _chunkPE5GKPHFjs.e; exports.UpdateCardID = _chunkBDI3SHA2js.b; exports.UpdateClient = _chunkBDI3SHA2js.d; exports.UpdateClientIdentifier = _chunkBDI3SHA2js.e; exports.UpdatePayment = _chunkPE5GKPHFjs.k; exports.UpdatePaymentInputZod = _chunkPE5GKPHFjs.g; exports.createClient = _chunkPE5GKPHFjs.m; exports.createLoggingMiddleware = h; exports.createMetricsMiddleware = E; exports.isCommandError = _chunkOGW7GTJPjs.b;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as o,b as n,c as m,d,e as i}from"./chunk-LXODYKLU.mjs";import{a as p,b as s,c,d as y,e as f,f as g}from"./chunk-5PEETHWV.mjs";import{b as a}from"./chunk-RX3BFHHX.mjs";var u=(r=console)=>({before:async e=>{r.info(`Executing ${e.metadata.commandName}`,{input:e.input,metadata:e.metadata})},after:async(e,t)=>{r.info(`Completed ${e.metadata.commandName}`,{response:t,metadata:e.metadata})},onError:async(e,t)=>{r.error(`Error in ${e.metadata.commandName}`,{error:t,input:e.input,metadata:e.metadata})}});var x=r=>({before:async e=>{r.incrementCounter(`${e.metadata.commandName}_started`)},after:async e=>{r.incrementCounter(`${e.metadata.commandName}_completed`)},onError:async(e,t)=>{r.incrementCounter(`${e.metadata.commandName}_error`),r.recordError&&typeof r.recordError=="function"&&r.recordError(t)}});export{o as CreatePayment,c as GetClientData,n as GetPayment,d as GetPayments,g as GraphQL,p as SendAuthorizationToCore,s as UpdateCardID,y as UpdateClient,f as UpdateClientIdentifier,m as UpdatePayment,i as createClient,u as createLoggingMiddleware,x as createMetricsMiddleware,a as isCommandError};
1
+ import{a as o,b as n,c as m,d,e as i,f as p,g as s,h as y,i as c,j as f,k as u,l as P,m as g}from"./chunk-RKHBWABU.mjs";import{a as l,b as x,c as C,d as w,e as M,f as S}from"./chunk-5PEETHWV.mjs";import{b as r}from"./chunk-RX3BFHHX.mjs";var h=(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 E=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{c as CreatePayment,p as CreatePaymentInputZod,C as GetClientData,f as GetPayment,P as GetPayments,S as GraphQL,o as PaymentFilterKeyZod,m as PaymentRailZod,y as PaymentResponseZod,n as PaymentStatusZod,d as PaymentTypeZod,l as SendAuthorizationToCore,i as SortOrderZod,x as UpdateCardID,w as UpdateClient,M as UpdateClientIdentifier,u as UpdatePayment,s as UpdatePaymentInputZod,g as createClient,h as createLoggingMiddleware,E 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.6",
3
+ "version": "1.0.0-alpha.8",
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
- "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 h=e=>{let a=[];if(!e.baseUrl)a.push("baseUrl is required");else if(typeof e.baseUrl!="string")a.push("baseUrl must be a string");else try{new URL(e.baseUrl)}catch (e2){a.push("baseUrl must be a valid URL")}return _optionalChain([e, 'access', _2 => _2.axiosConfig, 'optionalAccess', _3 => _3.timeout])!==void 0&&(typeof e.axiosConfig.timeout!="number"||e.axiosConfig.timeout<0)&&a.push("timeout must be a positive number"),a};var _zod = require('zod');var v=_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"]),l=_zod.z.enum(["DRAFT","AML_SCREENING","AML_REJECTED","EXECUTION_SCHEDULED","EXECUTION_PROCESSING","EXECUTION_SUCCESS","EXECUTION_FAILURE","RETURNED","CANCELLED","COMPLIANCE_FAILURE","DELETED","UNKNOWN"]),E=_zod.z.enum(["ACH","SAMEDAYACH","WIRE","SWIFT","INTERNAL","FXPAY","CARD"]),S=_zod.z.enum(["CREDIT","DEBIT"]),R=_zod.z.enum(["ASC","DESC"]),H=v.options,Y=l.options,W=E.options,X=S.options,J=R.options,b=e=>v.parse(e),T=e=>l.parse(e),w=e=>E.parse(e),A=e=>S.parse(e),U=e=>R.parse(e),D=_zod.z.object({id:_zod.z.string(),amount:_zod.z.number().positive(),clientId:_zod.z.string(),currency:_zod.z.string().min(3).max(3),status:l.optional(),createdAt:_zod.z.string().optional(),updatedAt:_zod.z.string().optional()}).catchall(_zod.z.any()),_=_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(),V=_zod.z.object({name:_zod.z.string().optional(),identifier:_zod.z.string().optional(),address:_}).optional(),x=_zod.z.object({name:_zod.z.string(),identifier:_zod.z.string(),accountType:_zod.z.enum(["CHECKING","SAVINGS"]).optional(),address:_,agent:V}),G=_zod.z.object({amount:_zod.z.number().positive(),currency:_zod.z.string().min(3).max(3),paymentRail:E,paymentType:S,debtor:x,creditor:x,clientId:_zod.z.string().optional(),correspondent:x.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(e=>(e.paymentRail==="WIRE"||e.paymentRail==="SWIFT")&&e.creditor?e.creditor.address&&e.creditor.address.state&&e.creditor.address.country:!0,{message:"For WIRE transfers, recipient address with state and country is mandatory"}),q=_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:l.optional()}).catchall(_zod.z.any()),Q=_zod.z.object({totalFilteredRecords:_zod.z.number(),pageItems:_zod.z.array(D)}),g=e=>D.parse(e),N=e=>G.parse(e),L=e=>q.parse(e);var k=e=>{try{b(e)}catch(a){throw a instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid filter key: '${e}'. ${a.message}`,code:"invalid_filter_key"}):a}},z=(e,a)=>{try{switch(e){case"status":T(a);break;case"paymentRail":w(a);break;case"paymentType":A(a);break;case"sortOrder":U(a);break;default:break}}catch(o){throw o instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid value for '${e}': '${a}'. ${o.message}`,code:`invalid_${e}_value`}):o}},O= exports.a =e=>({input:e,metadata:{commandName:"CreatePayment",path:"/v1/payments",method:"POST"},execute:async a=>{try{N(e.payment)}catch(n){throw n instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid payment data: ${n.message}`,code:"invalid_payment_input"}):n}e.tenantId&&(a.tenantId=e.tenantId);let o=await _chunkOGW7GTJPjs.d.call(void 0, a);try{let n=await o.post("/v1/payments",e.payment);return g(n.data)}catch(n){_chunkOGW7GTJPjs.c.call(void 0, n)}}}),F= exports.b =e=>({input:e,metadata:{commandName:"GetPayment",path:`/v1/payments/${e.id}`,method:"GET"},execute:async a=>{e.tenantId&&(a.tenantId=e.tenantId);let o=await _chunkOGW7GTJPjs.d.call(void 0, a);try{let n=await o.get(`/v1/payments/${e.id}`);return g(n.data)}catch(n){_chunkOGW7GTJPjs.c.call(void 0, n)}}}),$= exports.c =e=>({input:e,metadata:{commandName:"UpdatePayment",path:`/v1/payments/${e.id}`,method:"PUT"},execute:async a=>{try{L(e.payment)}catch(n){throw n instanceof _zod.ZodError?_chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid payment update data: ${n.message}`,code:"invalid_payment_update_input"}):n}e.tenantId&&(a.tenantId=e.tenantId);let o=await _chunkOGW7GTJPjs.d.call(void 0, a);try{let n=await o.put(`/v1/payments/${e.id}`,e.payment);return g(n.data)}catch(n){_chunkOGW7GTJPjs.c.call(void 0, n)}}}),f=(e,a,o,n)=>({where:m=>(k(m),{eq:r=>(z(m,r),f({...e,[m]:r},a,o,n))}),limit:m=>f(e,m,o,n),offset:m=>f(e,a,m,n),execute:()=>{let m={...e,limit:a||200,offset:o||0};return{input:{filters:e,limit:a,offset:o,tenantId:n},metadata:{commandName:"GetPayments",path:"/v1/payments",method:"GET"},execute:async r=>{n&&(r.tenantId=n);let i=await _chunkOGW7GTJPjs.d.call(void 0, r);try{return(await i.get("/v1/payments",{params:m})).data.pageItems}catch(p){_chunkOGW7GTJPjs.c.call(void 0, p)}}}}}),j= exports.d =e=>({list:()=>f({},void 0,void 0,_optionalChain([e, 'optionalAccess', _4 => _4.tenantId]))}),M=e=>({input:e,metadata:{commandName:"DeletePayment",path:`/v1/payments/${e.id}`,method:"DELETE"},execute:async a=>{e.tenantId&&(a.tenantId=e.tenantId);let o=await _chunkOGW7GTJPjs.d.call(void 0, a);try{await o.delete(`/v1/payments/${e.id}`)}catch(n){_chunkOGW7GTJPjs.c.call(void 0, n)}}});var pt=e=>{let a=h(e);if(a.length>0)throw _chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid configuration: ${a.join(", ")}`,code:"invalid_config"});let o=async(r,i,p)=>{if(e.middlewares)for(let s of e.middlewares)r==="before"&&s.before?await s.before(i):r==="after"&&s.after?await s.after(i,p):r==="onError"&&s.onError&&await s.onError(i,p)},n={...e},y=async r=>{try{await o("before",r);let i=await r.execute(n);return await o("after",r,i),i}catch(i){throw await o("onError",r,i),i}},I=r=>{let i=r||n.tenantId;return{payment:{create:async p=>{let s=O({payment:p,tenantId:i});return y(s)},get:async p=>{let s=F({id:p,tenantId:i});return y(s)},update:async(p,s)=>{let C=$({id:p,payment:s,tenantId:i});return y(C)},delete:async p=>{let s=M({id:p,tenantId:i});return y(s)},list:()=>{let s=j({tenantId:i}).list();return{where:s.where,limit:s.limit,offset:s.offset,execute:async()=>{let C=s.execute();return y(C)}}}}}};return{setConfig:r=>{n=r},updateConfig:r=>{let i={...n,...r,axiosConfig:{...n.axiosConfig,...r.axiosConfig,headers:{..._optionalChain([n, 'access', _5 => _5.axiosConfig, 'optionalAccess', _6 => _6.headers]),..._optionalChain([r, 'access', _7 => _7.axiosConfig, 'optionalAccess', _8 => _8.headers])}}},p=h(i);if(p.length>0)throw _chunkOGW7GTJPjs.a.call(void 0, {message:`Invalid configuration: ${p.join(", ")}`,code:"invalid_config"});n=i},resetConfig:()=>{n=e},request:y,tenant:r=>I(r),...I()}};exports.a = O; exports.b = F; exports.c = $; exports.d = j; exports.e = pt;