@mbanq/core-sdk-js 1.0.0-alpha.12 → 1.0.0-alpha.14
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 +141 -33
- package/dist/chunk-GZY2CY5Q.mjs +1 -0
- package/dist/chunk-ZTU6WB3T.js +1 -0
- package/dist/client/index.d.mts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.mjs +1 -1
- package/dist/{index-CASxEasn.d.mts → index-DvE2ddFU.d.mts} +571 -7
- package/dist/{index-CDXiIoqN.d.ts → index-vaBvDmsq.d.ts} +571 -7
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-DVUWFF32.mjs +0 -1
- package/dist/chunk-SMOK4ASF.js +0 -1
package/README.md
CHANGED
|
@@ -40,47 +40,44 @@ 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 {
|
|
47
|
+
import { CoreSDK } from '@mbanq/core-sdk-js';
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
secret: 'your-api-secret',
|
|
49
|
+
const coreSDK = new CoreSDK({
|
|
50
|
+
secret: 'your-jwt-secret',
|
|
49
51
|
signee: 'YOUR-SIGNEE',
|
|
50
|
-
baseUrl: 'https://api.cloud.mbanq.com',
|
|
51
|
-
tenantId: 'your-tenant-id'
|
|
52
|
+
baseUrl: 'https://api.cloud.mbanq.com',
|
|
53
|
+
tenantId: 'your-tenant-id'
|
|
52
54
|
});
|
|
53
55
|
|
|
54
|
-
// Create
|
|
55
|
-
const payment = await
|
|
56
|
-
amount:
|
|
56
|
+
// Create payment using fluent API
|
|
57
|
+
const payment = await coreSDK.payment.create({
|
|
58
|
+
amount: 100.00,
|
|
57
59
|
currency: 'USD',
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
agent: {
|
|
72
|
-
name: 'Second Bank',
|
|
73
|
-
identifier: '121000248'
|
|
74
|
-
}
|
|
75
|
-
}
|
|
60
|
+
description: 'Payment for invoice #123'
|
|
61
|
+
}).execute();
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Command Pattern
|
|
65
|
+
```javascript
|
|
66
|
+
import { CoreSDK, GetTransfers } from '@mbanq/core-sdk-js';
|
|
67
|
+
|
|
68
|
+
const coreSDK = new CoreSDK({
|
|
69
|
+
secret: 'your-jwt-secret',
|
|
70
|
+
signee: 'YOUR-SIGNEE',
|
|
71
|
+
baseUrl: 'https://api.cloud.mbanq.com',
|
|
72
|
+
tenantId: 'your-tenant-id'
|
|
76
73
|
});
|
|
77
74
|
|
|
78
|
-
//
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
75
|
+
// Get transfers using command pattern
|
|
76
|
+
const command = GetTransfers({
|
|
77
|
+
transferStatus: 'EXECUTION_SCHEDULED',
|
|
78
|
+
tenantId: 'default'
|
|
79
|
+
});
|
|
80
|
+
const transfers = await coreSDK.request(command);
|
|
84
81
|
```
|
|
85
82
|
|
|
86
83
|
## Setup
|
|
@@ -341,6 +338,117 @@ const client = createClient({
|
|
|
341
338
|
|
|
342
339
|
## API Reference
|
|
343
340
|
|
|
341
|
+
The SDK provides two API patterns for different operations:
|
|
342
|
+
|
|
343
|
+
### Modern Fluent API (Recommended)
|
|
344
|
+
For payment operations, use the modern fluent API with method chaining:
|
|
345
|
+
|
|
346
|
+
```javascript
|
|
347
|
+
// Create payment
|
|
348
|
+
const payment = await apiClient.payment.create(paymentData).execute();
|
|
349
|
+
|
|
350
|
+
// Get payment
|
|
351
|
+
const payment = await apiClient.payment.get('payment-456').execute();
|
|
352
|
+
|
|
353
|
+
// List with filters
|
|
354
|
+
const payments = await apiClient.payment.list()
|
|
355
|
+
.where('status').eq('DRAFT')
|
|
356
|
+
.where('paymentRail').eq('ACH')
|
|
357
|
+
.execute();
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Command Pattern (Legacy Support)
|
|
361
|
+
For transfer operations, the SDK also supports the traditional command pattern:
|
|
362
|
+
|
|
363
|
+
```javascript
|
|
364
|
+
// Get transfers with filters
|
|
365
|
+
const getTransfersCommand = GetTransfers({
|
|
366
|
+
transferStatus: 'EXECUTION_SCHEDULED',
|
|
367
|
+
executedAt: '2025-01-22',
|
|
368
|
+
paymentType: 'ACH',
|
|
369
|
+
queryLimit: 200,
|
|
370
|
+
tenantId: 'default'
|
|
371
|
+
});
|
|
372
|
+
const transfers = await coreSDK.request(getTransfersCommand);
|
|
373
|
+
|
|
374
|
+
// Create a new transfer
|
|
375
|
+
const createTransferCommand = CreateTransfer({
|
|
376
|
+
amount: 1000,
|
|
377
|
+
currency: 'USD',
|
|
378
|
+
paymentRail: 'ACH',
|
|
379
|
+
paymentType: 'CREDIT',
|
|
380
|
+
debtor: {
|
|
381
|
+
name: 'Sender Name',
|
|
382
|
+
identifier: '123456789',
|
|
383
|
+
agent: { name: 'Bank Name', identifier: '021000021' }
|
|
384
|
+
},
|
|
385
|
+
creditor: {
|
|
386
|
+
name: 'Recipient Name',
|
|
387
|
+
identifier: '987654321',
|
|
388
|
+
agent: { name: 'Recipient Bank', identifier: '121000248' }
|
|
389
|
+
},
|
|
390
|
+
tenantId: 'default'
|
|
391
|
+
});
|
|
392
|
+
const newTransfer = await coreSDK.request(createTransferCommand);
|
|
393
|
+
|
|
394
|
+
// Get specific transfer by ID
|
|
395
|
+
const getTransferCommand = GetTransfer({
|
|
396
|
+
transferId: 'transfer-123',
|
|
397
|
+
tenantId: 'default'
|
|
398
|
+
});
|
|
399
|
+
const transfer = await coreSDK.request(getTransferCommand);
|
|
400
|
+
|
|
401
|
+
// Mark transfer as successful
|
|
402
|
+
const markSuccessCommand = MarkAsSuccess({
|
|
403
|
+
transferId: 'transfer-123',
|
|
404
|
+
tenantId: 'default'
|
|
405
|
+
});
|
|
406
|
+
await coreSDK.request(markSuccessCommand);
|
|
407
|
+
|
|
408
|
+
// Mark transfer as processing
|
|
409
|
+
const markProcessingCommand = MarkAsProcessing({
|
|
410
|
+
transferId: 'transfer-123',
|
|
411
|
+
tenantId: 'default'
|
|
412
|
+
});
|
|
413
|
+
await coreSDK.request(markProcessingCommand);
|
|
414
|
+
|
|
415
|
+
// Mark transfer as returned
|
|
416
|
+
const markReturnedCommand = MarkAsReturned({
|
|
417
|
+
transferId: 'transfer-123',
|
|
418
|
+
returnCode: 'R01',
|
|
419
|
+
returnReason: 'Insufficient funds',
|
|
420
|
+
tenantId: 'default'
|
|
421
|
+
});
|
|
422
|
+
await coreSDK.request(markReturnedCommand);
|
|
423
|
+
|
|
424
|
+
// Log failed transfer
|
|
425
|
+
const logFailCommand = LogFailTransfer({
|
|
426
|
+
transferId: 'transfer-123',
|
|
427
|
+
errorCode: 'E001',
|
|
428
|
+
errorMessage: 'Processing error',
|
|
429
|
+
tenantId: 'default'
|
|
430
|
+
});
|
|
431
|
+
await coreSDK.request(logFailCommand);
|
|
432
|
+
|
|
433
|
+
// Mark transfer as failed
|
|
434
|
+
const markFailCommand = MarkAsFail({
|
|
435
|
+
transferId: 'transfer-123',
|
|
436
|
+
failureReason: 'Bank rejected',
|
|
437
|
+
tenantId: 'default'
|
|
438
|
+
});
|
|
439
|
+
await coreSDK.request(markFailCommand);
|
|
440
|
+
|
|
441
|
+
// Update trace number
|
|
442
|
+
const updateTraceCommand = UpdateTraceNumber({
|
|
443
|
+
transferId: 'transfer-123',
|
|
444
|
+
traceNumber: 'TRC123456789',
|
|
445
|
+
tenantId: 'default'
|
|
446
|
+
});
|
|
447
|
+
await coreSDK.request(updateTraceCommand);
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
Available transfer commands: `GetTransfers`, `CreateTransfer`, `GetTransfer`, `MarkAsSuccess`, `MarkAsProcessing`, `MarkAsReturned`, `LogFailTransfer`, `MarkAsFail`, `UpdateTraceNumber`
|
|
451
|
+
|
|
344
452
|
### Payment Operations
|
|
345
453
|
|
|
346
454
|
#### 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;
|
package/dist/client/index.d.mts
CHANGED
package/dist/client/index.d.ts
CHANGED
package/dist/client/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZTU6WB3Tjs = require('../chunk-ZTU6WB3T.js');require('../chunk-OGW7GTJP.js');exports.createClient = _chunkZTU6WB3Tjs.r;
|
package/dist/client/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{r as a}from"../chunk-GZY2CY5Q.mjs";import"../chunk-RX3BFHHX.mjs";export{a as createClient};
|